added more non-zero key tests to desfire self tests
This commit is contained in:
1 parent
4984db4191
commit
266cee1f31
1 file changed
+23
@@ -442,6 +442,19 @@ static bool TestTransSessionKeys(void) {
|
||||
uint8_t keyenc[] = {0x11, 0x9B, 0x90, 0x2A, 0x07, 0xB1, 0x8A, 0x86, 0x5B, 0x8E, 0x1B, 0x00, 0x60, 0x59, 0x47, 0x84};
|
||||
res = res && (memcmp(sessionkey, keyenc, sizeof(keyenc)) == 0);
|
||||
|
||||
// Second non-zero key vector, cross-checked with an independent AES-CMAC implementation
|
||||
uint8_t key2[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10};
|
||||
uint8_t uid2[] = {0x04, 0xA1, 0xB2, 0xC3, 0xD4, 0xE5, 0xF6};
|
||||
uint32_t trCntr2 = 0x12345678;
|
||||
uint8_t keymac2[] = {0x8F, 0x76, 0xD2, 0x1B, 0xAE, 0x67, 0x65, 0x84, 0x51, 0x88, 0xBC, 0xF9, 0x15, 0x9B, 0xE0, 0xEC};
|
||||
uint8_t keyenc2[] = {0x6F, 0x70, 0x1D, 0xC0, 0x37, 0xA5, 0xF0, 0x75, 0x7A, 0x7F, 0xF6, 0x67, 0x05, 0x5F, 0x4B, 0x25};
|
||||
|
||||
DesfireGenTransSessionKeyEV2(key2, trCntr2, uid2, true, sessionkey);
|
||||
res = res && (memcmp(sessionkey, keymac2, sizeof(keymac2)) == 0);
|
||||
|
||||
DesfireGenTransSessionKeyEV2(key2, trCntr2, uid2, false, sessionkey);
|
||||
res = res && (memcmp(sessionkey, keyenc2, sizeof(keyenc2)) == 0);
|
||||
|
||||
PrintAndLogEx(INFO, "Trans session key. ( %s )", (res) ? _GREEN_("ok") : _RED_("fail"));
|
||||
return res;
|
||||
}
|
||||
@@ -807,6 +820,16 @@ static bool TestLRPSessionKeys(void) {
|
||||
DesfireGenSessionKeyLRP(key, rnda, rndb, true, sessionkey);
|
||||
res = res && (memcmp(sessionkey, sessionkeyres, sizeof(sessionkeyres)) == 0);
|
||||
|
||||
// Non-zero key vector, cross-checked with an independent LRP-CMAC implementation
|
||||
uint8_t key2[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF};
|
||||
uint8_t rnda2[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF};
|
||||
uint8_t rndb2[] = {0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10};
|
||||
uint8_t sessionkeyres2[] = {0x1A, 0xC2, 0xB1, 0x02, 0x1F, 0x6E, 0xF9, 0x9E, 0x79, 0xB7, 0x03, 0xB6, 0xB3, 0x3F, 0x65, 0xE6};
|
||||
|
||||
memset(sessionkey, 0, sizeof(sessionkey));
|
||||
DesfireGenSessionKeyLRP(key2, rnda2, rndb2, true, sessionkey);
|
||||
res = res && (memcmp(sessionkey, sessionkeyres2, sizeof(sessionkeyres2)) == 0);
|
||||
|
||||
PrintAndLogEx(INFO, "LRP session keys.. ( %s )", (res) ? _GREEN_("ok") : _RED_("fail"));
|
||||
return res;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user