mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-25 06:13:14 +03:00
1510d8773b
* CCID: Improve request and response data handling - Add iso7816_set_response function: serves a helpers to set SW1 and SW2 values - improved iso7816_read_response_apdu by correctly parsing Lc and Le values - add client script to make testing easier * lint and rename * Format * Review changes: pragma once, typedef * Move command/response data and datalen into respective structures * Remove conditional for Lc=0 * Fix comment: Le * Make PVS happy and fix spelling Co-authored-by: あく <alleteam@gmail.com>
43 lines
1.0 KiB
C
43 lines
1.0 KiB
C
#pragma once
|
|
|
|
#include <stdint.h>
|
|
#include "iso7816_atr.h"
|
|
#include "core/common_defines.h"
|
|
|
|
#define ISO7816_READ_COMMAND_APDU_OK 0
|
|
#define ISO7816_READ_COMMAND_APDU_ERROR_WRONG_LE 1
|
|
#define ISO7816_READ_COMMAND_APDU_ERROR_WRONG_LENGTH 2
|
|
|
|
typedef struct {
|
|
//header
|
|
uint8_t CLA;
|
|
uint8_t INS;
|
|
uint8_t P1;
|
|
uint8_t P2;
|
|
|
|
//body
|
|
uint16_t Lc; //data length
|
|
uint16_t Le; //maximum response data length expected by client
|
|
|
|
//Le can have value of 0x00, which actually meand 0x100 = 256
|
|
bool LePresent;
|
|
uint8_t Data[0];
|
|
} FURI_PACKED ISO7816_Command_APDU;
|
|
|
|
typedef struct {
|
|
uint8_t SW1;
|
|
uint8_t SW2;
|
|
uint16_t DataLen;
|
|
uint8_t Data[0];
|
|
} FURI_PACKED ISO7816_Response_APDU;
|
|
|
|
void iso7816_answer_to_reset(Iso7816Atr* atr);
|
|
uint8_t iso7816_read_command_apdu(
|
|
ISO7816_Command_APDU* command,
|
|
const uint8_t* pcToReaderDataBlock,
|
|
uint32_t pcToReaderDataBlockLen);
|
|
void iso7816_write_response_apdu(
|
|
const ISO7816_Response_APDU* response,
|
|
uint8_t* readerToPcDataBlock,
|
|
uint32_t* readerToPcDataBlockLen);
|