fix and style

This commit is contained in:
iceman1001 2024-09-06 22:36:44 +02:00
commit 72900d1bf9
10 changed files with 79 additions and 28 deletions

View file

@ -131,17 +131,18 @@ bool Encrypt(uint8_t *src, uint8_t *dest) {
// Call with block6
void DecodeBlock6(uint8_t *src) {
int resp_len = 0;
uint8_t resp[254] = {0};
uint8_t c[] = {0x96, CARD_INS_DECODE, 0x00, 0x00, 0x09, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
memcpy(c + 6, src, 8);
int resp_len = 0;
uint8_t resp[254] = {0};
// first part
ExchangeAPDUSC(false, c, sizeof(c), false, true, resp, sizeof(resp), &resp_len);
if (resp_len < 11) {
PrintAndLogEx(DEBUG, "decodeblock6, wrong response len, expected 11 got ( " _RED_("%d") " )", resp_len);
return;
}
@ -151,10 +152,11 @@ void DecodeBlock6(uint8_t *src) {
c[5] = 0x02;
ExchangeAPDUSC(false, c, sizeof(c), false, false, resp, sizeof(resp), &resp_len);
if (resp_len < 11) {
PrintAndLogEx(DEBUG, "decodeblock6, wrong response len, expected 11 got ( " _RED_("%d") " )", resp_len);
return;
}
PrintAndLogEx(SUCCESS, "%.*s", resp_len - 11, resp + 9);
}
@ -166,7 +168,6 @@ uint8_t GetNumberBlocksForUserId(uint8_t *src) {
memcpy(c + 5, src, 8);
ExchangeAPDUSC(false, c, sizeof(c), false, false, resp, sizeof(resp), &resp_len);
if (resp_len < 8) {
return 0;
}
@ -192,8 +193,9 @@ uint8_t GetPinSize(uint8_t *src) {
}
int GetConfigCardByIdx(uint8_t typ, uint8_t *blocks) {
if (blocks == NULL)
if (blocks == NULL) {
return PM3_EINVARG;
}
int resp_len = 0;
uint8_t resp[254] = {0};
@ -212,8 +214,9 @@ int GetConfigCardByIdx(uint8_t typ, uint8_t *blocks) {
}
int GetConfigCardStrByIdx(uint8_t typ, uint8_t *out) {
if (out == NULL)
if (out == NULL) {
return PM3_EINVARG;
}
int resp_len = 0;
uint8_t resp[254] = {0};
@ -232,8 +235,9 @@ int GetConfigCardStrByIdx(uint8_t typ, uint8_t *out) {
}
int VerifyRdv4Signature(uint8_t *memid, uint8_t *signature) {
if (memid == NULL || signature == NULL)
if (memid == NULL || signature == NULL) {
return PM3_EINVARG;
}
int resp_len = 0;
uint8_t resp[254] = {0};

View file

@ -152,7 +152,9 @@ void computeSignalProperties(const uint8_t *samples, uint32_t size) {
}
void removeSignalOffset(uint8_t *samples, uint32_t size) {
if (samples == NULL || size < SIGNAL_MIN_SAMPLES) return;
if (samples == NULL || size < SIGNAL_MIN_SAMPLES) {
return;
}
int acc_off = 0;
uint32_t offset_size = size - SIGNAL_IGNORE_FIRST_SAMPLES;
@ -458,7 +460,14 @@ static size_t findModStart(const uint8_t *src, size_t size, uint8_t expWaveSize)
} else {
waveSizeCnt++;
}
if (thresholdCnt > 10) break;
if (thresholdCnt > 10) {
break;
}
}
if (g_debugMode == 2) {
prnt("DEBUG: threshold Count reached at index %zu, count: %u", i, thresholdCnt);
}
return i;
}