mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 22:03:42 -07:00
make style
This commit is contained in:
parent
4d8a411413
commit
d94c74b24b
4 changed files with 66 additions and 52 deletions
|
@ -418,6 +418,12 @@ int APDUDecode(uint8_t *data, size_t len, APDUStruct *apdu) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int APDUEncode(APDUStruct *apdu, uint8_t *data, size_t *len) {
|
int APDUEncode(APDUStruct *apdu, uint8_t *data, size_t *len) {
|
||||||
|
if (len)
|
||||||
|
*len = 0;
|
||||||
|
|
||||||
|
if (apdu->le > 0x10000 || apdu->lc != 0xffff)
|
||||||
|
return 1;
|
||||||
|
|
||||||
size_t dptr = 0;
|
size_t dptr = 0;
|
||||||
data[dptr++] = apdu->cla;
|
data[dptr++] = apdu->cla;
|
||||||
data[dptr++] = apdu->ins;
|
data[dptr++] = apdu->ins;
|
||||||
|
@ -425,7 +431,7 @@ int APDUEncode(APDUStruct *apdu, uint8_t *data, size_t *len) {
|
||||||
data[dptr++] = apdu->p2;
|
data[dptr++] = apdu->p2;
|
||||||
|
|
||||||
if (apdu->lc) {
|
if (apdu->lc) {
|
||||||
if (apdu->extended_apdu || apdu->lc > 0xff || apdu->le > 0xff) {
|
if (apdu->extended_apdu || apdu->lc > 0xff || apdu->le > 0x100) {
|
||||||
data[dptr++] = 0x00;
|
data[dptr++] = 0x00;
|
||||||
data[dptr++] = (apdu->lc >> 8) & 0xff;
|
data[dptr++] = (apdu->lc >> 8) & 0xff;
|
||||||
data[dptr++] = (apdu->lc) & 0xff;
|
data[dptr++] = (apdu->lc) & 0xff;
|
||||||
|
@ -441,19 +447,29 @@ int APDUEncode(APDUStruct *apdu, uint8_t *data, size_t *len) {
|
||||||
|
|
||||||
if (apdu->le) {
|
if (apdu->le) {
|
||||||
if (apdu->extended_apdu) {
|
if (apdu->extended_apdu) {
|
||||||
|
if (apdu->le != 0x10000) {
|
||||||
data[dptr++] = 0x00;
|
data[dptr++] = 0x00;
|
||||||
data[dptr++] = (apdu->le >> 8) & 0xff;
|
data[dptr++] = (apdu->le >> 8) & 0xff;
|
||||||
data[dptr++] = (apdu->le) & 0xff;
|
data[dptr++] = (apdu->le) & 0xff;
|
||||||
} else {
|
} else {
|
||||||
|
data[dptr++] = 0x00;
|
||||||
|
data[dptr++] = 0x00;
|
||||||
|
data[dptr++] = 0x00;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (apdu->le != 0x100)
|
||||||
data[dptr++] = apdu->le;
|
data[dptr++] = apdu->le;
|
||||||
|
else
|
||||||
|
data[dptr++] = 0x00;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (len)
|
||||||
*len = dptr;
|
*len = dptr;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void APDUPrint(APDUStruct apdu) {
|
void APDUPrint(APDUStruct apdu) {
|
||||||
PrintAndLogEx(INFO, "apdu: %scase=%02x cla=%02x ins=%02x p1=%02x p2=%02x lc=%d le=%d\n",
|
PrintAndLogEx(INFO, "apdu: %scase=%02x cla=%02x ins=%02x p1=%02x p2=%02x Lc=%d Le=%d\n",
|
||||||
apdu.extended_apdu ? "[e]" : "", apdu.case_type, apdu.cla, apdu.ins, apdu.p1, apdu.p2, apdu.lc, apdu.le);
|
apdu.extended_apdu ? "[e]" : "", apdu.case_type, apdu.cla, apdu.ins, apdu.p1, apdu.p2, apdu.lc, apdu.le);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,8 +32,7 @@ typedef struct {
|
||||||
const APDUCode *GetAPDUCode(uint8_t sw1, uint8_t sw2);
|
const APDUCode *GetAPDUCode(uint8_t sw1, uint8_t sw2);
|
||||||
const char *GetAPDUCodeDescription(uint8_t sw1, uint8_t sw2);
|
const char *GetAPDUCodeDescription(uint8_t sw1, uint8_t sw2);
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
uint8_t cla;
|
uint8_t cla;
|
||||||
uint8_t ins;
|
uint8_t ins;
|
||||||
uint8_t p1;
|
uint8_t p1;
|
||||||
|
@ -41,8 +40,7 @@ typedef struct
|
||||||
uint8_t lc[3];
|
uint8_t lc[3];
|
||||||
} __attribute__((packed)) ExtAPDUHeader;
|
} __attribute__((packed)) ExtAPDUHeader;
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
uint8_t cla;
|
uint8_t cla;
|
||||||
uint8_t ins;
|
uint8_t ins;
|
||||||
uint8_t p1;
|
uint8_t p1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue