mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-23 06:35:38 -07:00
fix coverity
This commit is contained in:
parent
682de4eee0
commit
d5b379207e
1 changed files with 14 additions and 8 deletions
|
@ -389,7 +389,7 @@ void *mifare_cryto_preprocess_data(desfiretag_t tag, void *data, size_t *nbytes,
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
switch (communication_settings & MDCM_MASK) {
|
switch (communication_settings & MDCM_MASK) {
|
||||||
case MDCM_PLAIN:
|
case MDCM_PLAIN: {
|
||||||
if (AS_LEGACY == DESFIRE(tag)->authentication_scheme)
|
if (AS_LEGACY == DESFIRE(tag)->authentication_scheme)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -404,9 +404,9 @@ void *mifare_cryto_preprocess_data(desfiretag_t tag, void *data, size_t *nbytes,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
append_mac = false;
|
append_mac = false;
|
||||||
|
}
|
||||||
/* pass through */
|
/* pass through */
|
||||||
case MDCM_MACED:
|
case MDCM_MACED: {
|
||||||
communication_settings |= NO_CRC;
|
communication_settings |= NO_CRC;
|
||||||
|
|
||||||
switch (DESFIRE(tag)->authentication_scheme) {
|
switch (DESFIRE(tag)->authentication_scheme) {
|
||||||
|
@ -455,7 +455,8 @@ void *mifare_cryto_preprocess_data(desfiretag_t tag, void *data, size_t *nbytes,
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MDCM_ENCIPHERED:
|
}
|
||||||
|
case MDCM_ENCIPHERED: {
|
||||||
/* |<-------------- data -------------->|
|
/* |<-------------- data -------------->|
|
||||||
* |<--- offset -->| |
|
* |<--- offset -->| |
|
||||||
* +---------------+--------------------+-----+---------+
|
* +---------------+--------------------+-----+---------+
|
||||||
|
@ -473,21 +474,25 @@ void *mifare_cryto_preprocess_data(desfiretag_t tag, void *data, size_t *nbytes,
|
||||||
|
|
||||||
if (!(communication_settings & ENC_COMMAND))
|
if (!(communication_settings & ENC_COMMAND))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
edl = enciphered_data_length(tag, *nbytes - offset, communication_settings) + offset;
|
edl = enciphered_data_length(tag, *nbytes - offset, communication_settings) + offset;
|
||||||
|
|
||||||
// Fill in the crypto buffer with data ...
|
// Fill in the crypto buffer with data ...
|
||||||
memcpy(res, data, *nbytes);
|
memcpy(res, data, *nbytes);
|
||||||
|
|
||||||
if (!(communication_settings & NO_CRC)) {
|
if (!(communication_settings & NO_CRC)) {
|
||||||
// ... CRC ...
|
// ... CRC ...
|
||||||
switch (DESFIRE(tag)->authentication_scheme) {
|
switch (DESFIRE(tag)->authentication_scheme) {
|
||||||
case AS_LEGACY:
|
case AS_LEGACY: {
|
||||||
AddCrc14A(res + offset, *nbytes - offset);
|
AddCrc14A(res + offset, *nbytes - offset);
|
||||||
*nbytes += 2;
|
*nbytes += 2;
|
||||||
break;
|
break;
|
||||||
case AS_NEW:
|
}
|
||||||
|
case AS_NEW: {
|
||||||
crc32_append(res, *nbytes);
|
crc32_append(res, *nbytes);
|
||||||
*nbytes += 4;
|
*nbytes += 4;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ... and padding
|
// ... and padding
|
||||||
|
@ -497,11 +502,12 @@ void *mifare_cryto_preprocess_data(desfiretag_t tag, void *data, size_t *nbytes,
|
||||||
|
|
||||||
mifare_cypher_blocks_chained(tag, NULL, NULL, res + offset, *nbytes - offset, MCD_SEND, (AS_NEW == DESFIRE(tag)->authentication_scheme) ? MCO_ENCYPHER : MCO_DECYPHER);
|
mifare_cypher_blocks_chained(tag, NULL, NULL, res + offset, *nbytes - offset, MCD_SEND, (AS_NEW == DESFIRE(tag)->authentication_scheme) ? MCO_ENCYPHER : MCO_DECYPHER);
|
||||||
break;
|
break;
|
||||||
default:
|
}
|
||||||
|
default: {
|
||||||
*nbytes = -1;
|
*nbytes = -1;
|
||||||
res = NULL;
|
res = NULL;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue