mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
Make style
This commit is contained in:
parent
5adc8e876a
commit
e0bf636aaf
3 changed files with 211 additions and 229 deletions
|
@ -38,13 +38,15 @@ struct desfire_key default_key = {0};
|
||||||
|
|
||||||
uint8_t desdefaultkeys[3][8] = {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, //Official
|
uint8_t desdefaultkeys[3][8] = {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, //Official
|
||||||
{0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47},
|
{0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47},
|
||||||
{0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07}};
|
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}
|
||||||
|
};
|
||||||
|
|
||||||
uint8_t aesdefaultkeys[5][16] = {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, //Official, TRF7970A
|
uint8_t aesdefaultkeys[5][16] = {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, //Official, TRF7970A
|
||||||
{0x79, 0x70, 0x25, 0x53, 0x79, 0x70, 0x25, 0x53, 0x79, 0x70, 0x25, 0x53, 0x79, 0x70, 0x25, 0x53}, // TRF7970A
|
{0x79, 0x70, 0x25, 0x53, 0x79, 0x70, 0x25, 0x53, 0x79, 0x70, 0x25, 0x53, 0x79, 0x70, 0x25, 0x53}, // TRF7970A
|
||||||
{0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}, // TRF7970A
|
{0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}, // TRF7970A
|
||||||
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f},
|
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f},
|
||||||
{0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f}};
|
{0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f}
|
||||||
|
};
|
||||||
|
|
||||||
uint8_t k3kdefaultkeys[1][24] = {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
|
uint8_t k3kdefaultkeys[1][24] = {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
|
||||||
|
|
||||||
|
@ -700,12 +702,10 @@ int handler_desfire_auth(mfdes_authinput_t *payload, mfdes_auth_res_t *rpayload)
|
||||||
uint8_t subcommand = MFDES_AUTHENTICATE;
|
uint8_t subcommand = MFDES_AUTHENTICATE;
|
||||||
tag->authentication_scheme = AS_LEGACY;
|
tag->authentication_scheme = AS_LEGACY;
|
||||||
|
|
||||||
if (payload->mode == MFDES_AUTH_AES)
|
if (payload->mode == MFDES_AUTH_AES) {
|
||||||
{
|
|
||||||
subcommand = MFDES_AUTHENTICATE_AES;
|
subcommand = MFDES_AUTHENTICATE_AES;
|
||||||
tag->authentication_scheme = AS_NEW;
|
tag->authentication_scheme = AS_NEW;
|
||||||
}
|
} else if (payload->mode == MFDES_AUTH_ISO) {
|
||||||
else if (payload->mode == MFDES_AUTH_ISO) {
|
|
||||||
subcommand = MFDES_AUTHENTICATE_ISO;
|
subcommand = MFDES_AUTHENTICATE_ISO;
|
||||||
tag->authentication_scheme = AS_NEW;
|
tag->authentication_scheme = AS_NEW;
|
||||||
}
|
}
|
||||||
|
@ -1037,8 +1037,7 @@ static int handler_desfire_freemem(uint32_t *free_mem) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mifare_desfire_change_key(uint8_t key_no, uint8_t* new_key, int new_algo, uint8_t* old_key, int old_algo, int aes_version)
|
static int mifare_desfire_change_key(uint8_t key_no, uint8_t *new_key, int new_algo, uint8_t *old_key, int old_algo, int aes_version) {
|
||||||
{
|
|
||||||
key_no &= 0x0F;
|
key_no &= 0x0F;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1127,8 +1126,7 @@ static int mifare_desfire_change_key(uint8_t key_no, uint8_t* new_key, int new_a
|
||||||
uint16_t sw = 0;
|
uint16_t sw = 0;
|
||||||
int res = send_desfire_cmd(&apdu, true, NULL, &recv_len, &sw, 0, true);
|
int res = send_desfire_cmd(&apdu, true, NULL, &recv_len, &sw, 0, true);
|
||||||
|
|
||||||
if (res != PM3_SUCCESS)
|
if (res != PM3_SUCCESS) {
|
||||||
{
|
|
||||||
PrintAndLogEx(WARNING, _RED_(" Can't change key -> %s"), GetErrorString(res, &sw));
|
PrintAndLogEx(WARNING, _RED_(" Can't change key -> %s"), GetErrorString(res, &sw));
|
||||||
DropField();
|
DropField();
|
||||||
return res;
|
return res;
|
||||||
|
@ -1972,8 +1970,7 @@ static void swap16(uint8_t *data) {
|
||||||
data[1] = tmp;
|
data[1] = tmp;
|
||||||
};
|
};
|
||||||
|
|
||||||
int desfire_authenticate(int cmdAuthMode, int cmdAuthAlgo, uint8_t* aid, uint8_t* key, int cmdKeyNo, mfdes_auth_res_t* rpayload)
|
int desfire_authenticate(int cmdAuthMode, int cmdAuthAlgo, uint8_t *aid, uint8_t *key, int cmdKeyNo, mfdes_auth_res_t *rpayload) {
|
||||||
{
|
|
||||||
switch (cmdAuthMode) {
|
switch (cmdAuthMode) {
|
||||||
case MFDES_AUTH_DES:
|
case MFDES_AUTH_DES:
|
||||||
if (cmdAuthAlgo != MFDES_ALGO_DES && cmdAuthAlgo != MFDES_ALGO_3DES) {
|
if (cmdAuthAlgo != MFDES_ALGO_DES && cmdAuthAlgo != MFDES_ALGO_3DES) {
|
||||||
|
@ -2270,8 +2267,7 @@ static int selectfile(uint8_t* aid, int fileno, uint8_t* cs){
|
||||||
int fileset_len = 0;
|
int fileset_len = 0;
|
||||||
int res = handler_desfire_filesettings(fileno, filesettings, &fileset_len);
|
int res = handler_desfire_filesettings(fileno, filesettings, &fileset_len);
|
||||||
|
|
||||||
if (tag->session_key!=NULL)
|
if (tag->session_key != NULL) {
|
||||||
{
|
|
||||||
mfdes_auth_res_t rpayload;
|
mfdes_auth_res_t rpayload;
|
||||||
int keyno = (filesettings[0] >> 4) & 0xF;
|
int keyno = (filesettings[0] >> 4) & 0xF;
|
||||||
if (keyno != 0xE && currentauth[keyno].keyno == keyno) {
|
if (keyno != 0xE && currentauth[keyno].keyno == keyno) {
|
||||||
|
@ -2279,8 +2275,7 @@ static int selectfile(uint8_t* aid, int fileno, uint8_t* cs){
|
||||||
PrintAndLogEx(ERR, _RED_(" Couldn't authenticate key."));
|
PrintAndLogEx(ERR, _RED_(" Couldn't authenticate key."));
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
} else if (keyno!=0xE)
|
} else if (keyno != 0xE) {
|
||||||
{
|
|
||||||
PrintAndLogEx(ERR, _RED_(" Please authenticate first."));
|
PrintAndLogEx(ERR, _RED_(" Please authenticate first."));
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
@ -2336,8 +2331,7 @@ static int CmdHF14ADesClearRecordFile(const char *Cmd) {
|
||||||
memcpy(aid, (uint8_t *)&tag->selected_application, 3);
|
memcpy(aid, (uint8_t *)&tag->selected_application, 3);
|
||||||
}
|
}
|
||||||
uint8_t cs = 0;
|
uint8_t cs = 0;
|
||||||
if (selectfile(aid,fileno[0],&cs)!=PM3_SUCCESS)
|
if (selectfile(aid, fileno[0], &cs) != PM3_SUCCESS) {
|
||||||
{
|
|
||||||
PrintAndLogEx(ERR, _RED_(" Error on selecting file."));
|
PrintAndLogEx(ERR, _RED_(" Error on selecting file."));
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
@ -2397,8 +2391,7 @@ static int CmdHF14ADesDeleteFile(const char *Cmd) {
|
||||||
memcpy(aid, (uint8_t *)&tag->selected_application, 3);
|
memcpy(aid, (uint8_t *)&tag->selected_application, 3);
|
||||||
}
|
}
|
||||||
uint8_t cs = 0;
|
uint8_t cs = 0;
|
||||||
if (selectfile(aid,fileno[0],&cs)!=PM3_SUCCESS)
|
if (selectfile(aid, fileno[0], &cs) != PM3_SUCCESS) {
|
||||||
{
|
|
||||||
PrintAndLogEx(ERR, _RED_(" Error on selecting file."));
|
PrintAndLogEx(ERR, _RED_(" Error on selecting file."));
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
@ -2578,8 +2571,7 @@ static int CmdHF14ADesGetValueData(const char *Cmd) {
|
||||||
memcpy(aid, (uint8_t *)&tag->selected_application, 3);
|
memcpy(aid, (uint8_t *)&tag->selected_application, 3);
|
||||||
}
|
}
|
||||||
uint8_t cs = 0;
|
uint8_t cs = 0;
|
||||||
if (selectfile(aid,value.fileno,&cs)!=PM3_SUCCESS)
|
if (selectfile(aid, value.fileno, &cs) != PM3_SUCCESS) {
|
||||||
{
|
|
||||||
PrintAndLogEx(ERR, _RED_(" Error on selecting file."));
|
PrintAndLogEx(ERR, _RED_(" Error on selecting file."));
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
@ -2684,8 +2676,7 @@ static int CmdHF14ADesReadData(const char *Cmd) {
|
||||||
memcpy(aid, (uint8_t *)&tag->selected_application, 3);
|
memcpy(aid, (uint8_t *)&tag->selected_application, 3);
|
||||||
}
|
}
|
||||||
uint8_t cs = 0;
|
uint8_t cs = 0;
|
||||||
if (selectfile(aid,ft.fileno,&cs)!=PM3_SUCCESS)
|
if (selectfile(aid, ft.fileno, &cs) != PM3_SUCCESS) {
|
||||||
{
|
|
||||||
PrintAndLogEx(ERR, _RED_(" Error on selecting file."));
|
PrintAndLogEx(ERR, _RED_(" Error on selecting file."));
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
@ -2783,8 +2774,7 @@ static int CmdHF14ADesChangeValue(const char *Cmd) {
|
||||||
memcpy(aid, (uint8_t *)&tag->selected_application, 3);
|
memcpy(aid, (uint8_t *)&tag->selected_application, 3);
|
||||||
}
|
}
|
||||||
uint8_t cs = 0;
|
uint8_t cs = 0;
|
||||||
if (selectfile(aid,fileno[0],&cs)!=PM3_SUCCESS)
|
if (selectfile(aid, fileno[0], &cs) != PM3_SUCCESS) {
|
||||||
{
|
|
||||||
PrintAndLogEx(ERR, _RED_(" Error on selecting file."));
|
PrintAndLogEx(ERR, _RED_(" Error on selecting file."));
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
@ -2907,8 +2897,7 @@ static int CmdHF14ADesWriteData(const char *Cmd) {
|
||||||
memcpy(aid, (uint8_t *)&tag->selected_application, 3);
|
memcpy(aid, (uint8_t *)&tag->selected_application, 3);
|
||||||
}
|
}
|
||||||
uint8_t cs = 0;
|
uint8_t cs = 0;
|
||||||
if (selectfile(aid,fileno[0],&cs)!=PM3_SUCCESS)
|
if (selectfile(aid, fileno[0], &cs) != PM3_SUCCESS) {
|
||||||
{
|
|
||||||
PrintAndLogEx(ERR, _RED_(" Error on selecting file."));
|
PrintAndLogEx(ERR, _RED_(" Error on selecting file."));
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
@ -3040,8 +3029,7 @@ static int CmdHF14ADesCreateRecordFile(const char *Cmd) {
|
||||||
}
|
}
|
||||||
memcpy(aid, (uint8_t *)&tag->selected_application, 3);
|
memcpy(aid, (uint8_t *)&tag->selected_application, 3);
|
||||||
}
|
}
|
||||||
if (handler_desfire_select_application(aid)!=PM3_SUCCESS)
|
if (handler_desfire_select_application(aid) != PM3_SUCCESS) {
|
||||||
{
|
|
||||||
PrintAndLogEx(ERR, _RED_(" Error on selecting aid."));
|
PrintAndLogEx(ERR, _RED_(" Error on selecting aid."));
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
@ -3173,8 +3161,7 @@ static int CmdHF14ADesCreateValueFile(const char *Cmd) {
|
||||||
memcpy(aid, (uint8_t *)&tag->selected_application, 3);
|
memcpy(aid, (uint8_t *)&tag->selected_application, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handler_desfire_select_application(aid)!=PM3_SUCCESS)
|
if (handler_desfire_select_application(aid) != PM3_SUCCESS) {
|
||||||
{
|
|
||||||
PrintAndLogEx(ERR, _RED_(" Error on selecting aid."));
|
PrintAndLogEx(ERR, _RED_(" Error on selecting aid."));
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -872,8 +872,7 @@ void mifare_cypher_blocks_chained(desfiretag_t tag, desfirekey_t key, uint8_t *i
|
||||||
#define CRC32_PRESET 0xFFFFFFFF
|
#define CRC32_PRESET 0xFFFFFFFF
|
||||||
|
|
||||||
static void
|
static void
|
||||||
desfire_crc32_byte(uint32_t *crc, const uint8_t value)
|
desfire_crc32_byte(uint32_t *crc, const uint8_t value) {
|
||||||
{
|
|
||||||
/* x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x + 1 */
|
/* x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x + 1 */
|
||||||
const uint32_t poly = 0xEDB88320;
|
const uint32_t poly = 0xEDB88320;
|
||||||
|
|
||||||
|
@ -886,8 +885,7 @@ desfire_crc32_byte(uint32_t *crc, const uint8_t value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void desfire_crc32(const uint8_t *data, const size_t len, uint8_t *crc)
|
void desfire_crc32(const uint8_t *data, const size_t len, uint8_t *crc) {
|
||||||
{
|
|
||||||
uint32_t desfire_crc = CRC32_PRESET;
|
uint32_t desfire_crc = CRC32_PRESET;
|
||||||
for (size_t i = 0; i < len; i++) {
|
for (size_t i = 0; i < len; i++) {
|
||||||
desfire_crc32_byte(&desfire_crc, data[i]);
|
desfire_crc32_byte(&desfire_crc, data[i]);
|
||||||
|
@ -896,17 +894,14 @@ void desfire_crc32(const uint8_t *data, const size_t len, uint8_t *crc)
|
||||||
*((uint32_t *)(crc)) = htole32(desfire_crc);
|
*((uint32_t *)(crc)) = htole32(desfire_crc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void desfire_crc32_append(uint8_t *data, const size_t len)
|
void desfire_crc32_append(uint8_t *data, const size_t len) {
|
||||||
{
|
|
||||||
desfire_crc32(data, len, data + len);
|
desfire_crc32(data, len, data + len);
|
||||||
}
|
}
|
||||||
|
|
||||||
void iso14443a_crc_append(uint8_t* data, size_t len)
|
void iso14443a_crc_append(uint8_t *data, size_t len) {
|
||||||
{
|
|
||||||
return compute_crc(CRC_14443_A, data, len, data + len, data + len + 1);
|
return compute_crc(CRC_14443_A, data, len, data + len, data + len + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void iso14443a_crc(uint8_t* data, size_t len, uint8_t* pbtCrc)
|
void iso14443a_crc(uint8_t *data, size_t len, uint8_t *pbtCrc) {
|
||||||
{
|
|
||||||
return compute_crc(CRC_14443_A, data, len, pbtCrc, pbtCrc + 1);
|
return compute_crc(CRC_14443_A, data, len, pbtCrc, pbtCrc + 1);
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue