mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
Port des on device to mbedtls_des
This commit is contained in:
parent
c06864dcc7
commit
4501805709
6 changed files with 41 additions and 683 deletions
|
@ -18,7 +18,7 @@
|
|||
#include "commonutil.h"
|
||||
#include "crc16.h"
|
||||
#include "protocols.h"
|
||||
#include "des.h"
|
||||
#include "desfire_crypto.h"
|
||||
|
||||
int DBGLEVEL = DBG_ERROR;
|
||||
|
||||
|
@ -296,7 +296,7 @@ int mifare_ultra_auth(uint8_t *keybytes) {
|
|||
memcpy(enc_random_b, resp + 1, 8);
|
||||
|
||||
// decrypt nonce.
|
||||
tdes_2key_dec((void *)random_b, (void *)enc_random_b, sizeof(random_b), (const void *)key, IV);
|
||||
tdes_nxp_receive((void *)enc_random_b, (void *)random_b, sizeof(random_b), (const void *)key, IV,2);
|
||||
rol(random_b, 8);
|
||||
memcpy(rnd_ab, random_a, 8);
|
||||
memcpy(rnd_ab + 8, random_b, 8);
|
||||
|
@ -316,7 +316,7 @@ int mifare_ultra_auth(uint8_t *keybytes) {
|
|||
}
|
||||
|
||||
// encrypt out, in, length, key, iv
|
||||
tdes_2key_enc(rnd_ab, rnd_ab, sizeof(rnd_ab), key, enc_random_b);
|
||||
tdes_nxp_send(rnd_ab, rnd_ab, sizeof(rnd_ab), key, enc_random_b,2);
|
||||
|
||||
len = mifare_sendcmd(MIFARE_ULC_AUTH_2, rnd_ab, sizeof(rnd_ab), resp, respPar, NULL);
|
||||
if (len != 11) {
|
||||
|
@ -329,7 +329,7 @@ int mifare_ultra_auth(uint8_t *keybytes) {
|
|||
memcpy(enc_resp, resp + 1, 8);
|
||||
|
||||
// decrypt out, in, length, key, iv
|
||||
tdes_2key_dec(resp_random_a, enc_resp, 8, key, enc_random_b);
|
||||
tdes_nxp_receive(enc_resp, resp_random_a, 8, key, enc_random_b,2);
|
||||
if (memcmp(resp_random_a, random_a, 8) != 0) {
|
||||
if (DBGLEVEL >= DBG_ERROR) Dbprintf("failed authentication");
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue