refactoring. add ability to produce command specific apdu codes

This commit is contained in:
merlokk committed 2022-01-28 20:16:48 +02:00
1 parent 788e712a6c
commit 43577b3db4
3 files changed
+15 -13

No files matched your search

+8
View File
@@ -329,6 +329,14 @@ const char *GetAPDUCodeDescription(uint8_t sw1, uint8_t sw2) {
return APDUCodeTable[0].Description; //empty string
}
const char *GetSpecificAPDUCodeDesc(const APDUSpcCodeDescription_t *desc, const size_t desclen, uint16_t code) {
for (int i = 0; i < desclen; i++) {
if (desc[i].Code == code)
return desc[i].Description;
}
return GetAPDUCodeDescription(code >> 8, code & 0xff);
}
int APDUDecode(uint8_t *data, int len, APDU_t *apdu) {
ExtAPDUHeader_t *hapdu = (ExtAPDUHeader_t *)data;
+7
View File
@@ -38,6 +38,13 @@ typedef struct {
const APDUCode_t *GetAPDUCode(uint8_t sw1, uint8_t sw2);
const char *GetAPDUCodeDescription(uint8_t sw1, uint8_t sw2);
typedef struct {
const uint16_t Code;
const char *Description;
} APDUSpcCodeDescription_t;
const char *GetSpecificAPDUCodeDesc(const APDUSpcCodeDescription_t *desc, const size_t desclen, uint16_t code);
typedef struct {
uint8_t CLA;
uint8_t INS;