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
|
@ -136,7 +136,7 @@ static void SendCommandNG_internal(uint16_t cmd, uint8_t *data, size_t len, bool
|
|||
txBufferNG.pre.ng = ng;
|
||||
txBufferNG.pre.length = len;
|
||||
txBufferNG.pre.cmd = cmd;
|
||||
if ( len > 0 && data )
|
||||
if (len > 0 && data)
|
||||
memcpy(&txBufferNG.data, data, len);
|
||||
|
||||
if ((conn.send_via_fpc_usart && conn.send_with_crc_on_fpc) || ((!conn.send_via_fpc_usart) && conn.send_with_crc_on_usb)) {
|
||||
|
|
|
@ -418,6 +418,12 @@ int APDUDecode(uint8_t *data, size_t len, APDUStruct *apdu) {
|
|||
}
|
||||
|
||||
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;
|
||||
data[dptr++] = apdu->cla;
|
||||
data[dptr++] = apdu->ins;
|
||||
|
@ -425,7 +431,7 @@ int APDUEncode(APDUStruct *apdu, uint8_t *data, size_t *len) {
|
|||
data[dptr++] = apdu->p2;
|
||||
|
||||
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++] = (apdu->lc >> 8) & 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->extended_apdu) {
|
||||
if (apdu->le != 0x10000) {
|
||||
data[dptr++] = 0x00;
|
||||
data[dptr++] = (apdu->le >> 8) & 0xff;
|
||||
data[dptr++] = (apdu->le) & 0xff;
|
||||
} else {
|
||||
data[dptr++] = 0x00;
|
||||
data[dptr++] = 0x00;
|
||||
data[dptr++] = 0x00;
|
||||
}
|
||||
} else {
|
||||
if (apdu->le != 0x100)
|
||||
data[dptr++] = apdu->le;
|
||||
else
|
||||
data[dptr++] = 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
if (len)
|
||||
*len = dptr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void APDUPrint(APDUStruct apdu) {
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -32,8 +32,7 @@ typedef struct {
|
|||
const APDUCode *GetAPDUCode(uint8_t sw1, uint8_t sw2);
|
||||
const char *GetAPDUCodeDescription(uint8_t sw1, uint8_t sw2);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
uint8_t cla;
|
||||
uint8_t ins;
|
||||
uint8_t p1;
|
||||
|
@ -41,8 +40,7 @@ typedef struct
|
|||
uint8_t lc[3];
|
||||
} __attribute__((packed)) ExtAPDUHeader;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
uint8_t cla;
|
||||
uint8_t ins;
|
||||
uint8_t p1;
|
||||
|
|
|
@ -170,7 +170,7 @@ bool CheckStringIsHEXValue(const char *value) {
|
|||
void hex_to_buffer(const uint8_t *buf, const uint8_t *hex_data, const size_t hex_len, const size_t hex_max_len,
|
||||
const size_t min_str_len, const size_t spaces_between, bool uppercase) {
|
||||
|
||||
if (buf == NULL ) return;
|
||||
if (buf == NULL) return;
|
||||
|
||||
char *tmp = (char *)buf;
|
||||
size_t i;
|
||||
|
@ -197,7 +197,7 @@ void hex_to_buffer(const uint8_t *buf, const uint8_t *hex_data, const size_t hex
|
|||
|
||||
// printing and converting functions
|
||||
void print_hex(const uint8_t *data, const size_t len) {
|
||||
if (data == NULL || len == 0 ) return;
|
||||
if (data == NULL || len == 0) return;
|
||||
|
||||
for (size_t i = 0; i < len; i++)
|
||||
printf("%02x ", data[i]);
|
||||
|
@ -205,7 +205,7 @@ void print_hex(const uint8_t *data, const size_t len) {
|
|||
}
|
||||
|
||||
void print_hex_break(const uint8_t *data, const size_t len, uint8_t breaks) {
|
||||
if (data == NULL || len == 0 ) return;
|
||||
if (data == NULL || len == 0) return;
|
||||
|
||||
int rownum = 0;
|
||||
printf("[%02d] | ", rownum);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue