mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-09-21 15:56:21 +08:00
test and remove debug
This commit is contained in:
parent
67d198d946
commit
10457726f1
|
@ -606,14 +606,9 @@ void DesfireGenSessionKeyLRP(uint8_t *key, uint8_t *rndA, uint8_t *rndB, bool en
|
|||
data[30] = 0x96;
|
||||
data[31] = 0x69;
|
||||
|
||||
PrintAndLogEx(INFO, "rndA: %s", sprint_hex(rndA, CRYPTO_AES_BLOCK_SIZE));
|
||||
PrintAndLogEx(INFO, "rndB: %s", sprint_hex(rndB, CRYPTO_AES_BLOCK_SIZE));
|
||||
PrintAndLogEx(INFO, "data: %s", sprint_hex(data, 32));
|
||||
|
||||
LRPContext ctx = {0};
|
||||
LRPSetKey(&ctx, key, 0, true);
|
||||
LRPCMAC(&ctx, data, 32, sessionkey);
|
||||
PrintAndLogEx(INFO, "mk: %s", sprint_hex(sessionkey, CRYPTO_AES_BLOCK_SIZE));
|
||||
}
|
||||
|
||||
void DesfireEV2FillIV(DesfireContext *ctx, bool ivforcommand, uint8_t *iv) {
|
||||
|
|
|
@ -857,6 +857,28 @@ static bool TestLRPCMAC(void) {
|
|||
return res;
|
||||
}
|
||||
|
||||
// https://www.nxp.com/docs/en/application-note/AN12343.pdf
|
||||
// page 33-34
|
||||
static bool TestLRPSessionKeys(void) {
|
||||
bool res = true;
|
||||
|
||||
uint8_t key[16] = {0};
|
||||
uint8_t rnda[] = {0x74, 0xD7, 0xDF, 0x6A, 0x2C, 0xEC, 0x0B, 0x72, 0xB4, 0x12, 0xDE, 0x0D, 0x2B, 0x11, 0x17, 0xE6};
|
||||
uint8_t rndb[] = {0x56, 0x10, 0x9A, 0x31, 0x97, 0x7C, 0x85, 0x53, 0x19, 0xCD, 0x46, 0x18, 0xC9, 0xD2, 0xAE, 0xD2};
|
||||
uint8_t sessionkeyres[] = {0x13, 0x2D, 0x7E, 0x6F, 0x35, 0xBA, 0x86, 0x1F, 0x39, 0xB3, 0x72, 0x21, 0x21, 0x4E, 0x25, 0xA5};
|
||||
|
||||
uint8_t sessionkey[16] = {0};
|
||||
DesfireGenSessionKeyLRP(key, rnda, rndb, true, sessionkey);
|
||||
res = res && (memcmp(sessionkey, sessionkeyres, sizeof(sessionkeyres)) == 0);
|
||||
|
||||
if (res)
|
||||
PrintAndLogEx(INFO, "LRP session keys.. " _GREEN_("passed"));
|
||||
else
|
||||
PrintAndLogEx(ERR, "LRP session keys.. " _RED_("fail"));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool DesfireTest(bool verbose) {
|
||||
bool res = true;
|
||||
|
||||
|
@ -883,6 +905,7 @@ bool DesfireTest(bool verbose) {
|
|||
res = res && TestLRPDecode();
|
||||
res = res && TestLRPSubkeys();
|
||||
res = res && TestLRPCMAC();
|
||||
res = res && TestLRPSessionKeys();
|
||||
|
||||
PrintAndLogEx(INFO, "---------------------------");
|
||||
if (res)
|
||||
|
|
Loading…
Reference in a new issue