mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-27 01:25:41 +08:00
added TestAuth
This commit is contained in:
parent
50c40e4ce5
commit
99979c6609
1 changed files with 46 additions and 3 deletions
|
@ -26,13 +26,13 @@ uint8_t TestDataPadded[16] = {0x11, 0x22, 0x33, 0x44, 0x80, 0x00, 0x00, 0x00, 0x
|
|||
static bool TestKVV(void) {
|
||||
uint8_t kvv[CIPURSE_KVV_LENGTH] = {0};
|
||||
CipurseCGetKVV(Key, kvv);
|
||||
//PrintAndLogEx(INFO, "kvv: %s", sprint_hex(kvv, 4));
|
||||
|
||||
bool res = memcmp(KeyKvv, kvv, CIPURSE_KVV_LENGTH) == 0;
|
||||
|
||||
if (res)
|
||||
PrintAndLogEx(INFO, "kvv: " _GREEN_("passed"));
|
||||
else
|
||||
PrintAndLogEx(INFO, "kvv: " _RED_("fail"));
|
||||
PrintAndLogEx(ERR, "kvv: " _RED_("fail"));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ static bool TestISO9797M2(void) {
|
|||
if (res)
|
||||
PrintAndLogEx(INFO, "ISO9797M2: " _GREEN_("passed"));
|
||||
else
|
||||
PrintAndLogEx(INFO, "ISO9797M2: " _RED_("fail"));
|
||||
PrintAndLogEx(ERR, "ISO9797M2: " _RED_("fail"));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -89,6 +89,48 @@ static bool TestSMI(void) {
|
|||
return res;
|
||||
}
|
||||
|
||||
static bool TestAuth(void) {
|
||||
CipurseContext ctx = {0};
|
||||
CipurseCClearContext(&ctx);
|
||||
|
||||
bool res = (isCipurseCChannelSecuritySet(&ctx) == false);
|
||||
|
||||
CipurseCSetKey(&ctx, 1, Key);
|
||||
res = res && (memcmp(ctx.key, Key, 16) == 0);
|
||||
res = res && (ctx.keyId == 1);
|
||||
|
||||
uint8_t random[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x20, 0x21, 0x22};
|
||||
CipurseCSetRandomFromPICC(&ctx, random);
|
||||
res = res && (memcmp(ctx.RP, random, 16) == 0);
|
||||
res = res && (memcmp(ctx.rP, &random[16], 6) == 0);
|
||||
|
||||
uint8_t hrandom[] = {0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20};
|
||||
CipurseCSetRandomHost(&ctx);
|
||||
res = res && (memcmp(ctx.RT, hrandom, 16) == 0);
|
||||
res = res && (memcmp(ctx.rT, &hrandom[16], 6) == 0);
|
||||
|
||||
uint8_t authparams[16 + 16 + 6] = {0};
|
||||
CipurseCAuthenticateHost(&ctx, authparams);
|
||||
uint8_t aparamstest[] = {0x12, 0xAA, 0x79, 0xA9, 0x03, 0xC5, 0xB4, 0x6A, 0x27, 0x1B, 0x13, 0xAE, 0x02, 0x50, 0x1C, 0x99, 0x10, 0x10, 0x10, 0x10, 0x10,
|
||||
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20};
|
||||
res = res && (memcmp(authparams, aparamstest, sizeof(authparams)) == 0);
|
||||
|
||||
uint8_t ct[] = {0xBE, 0x10, 0x6B, 0xB9, 0xAD, 0x84, 0xBC, 0xE1, 0x9F, 0xAE, 0x0C, 0x62, 0xCC, 0xC7, 0x0D, 0x41};
|
||||
res = res && CipurseCCheckCT(&ctx, ct);
|
||||
PrintAndLogEx(INFO, "SMI: %s", sprint_hex(ctx.CT, 16));
|
||||
|
||||
CipurseCChannelSetSecurityLevels(&ctx, CPSMACed, CPSMACed);
|
||||
res = res && (isCipurseCChannelSecuritySet(&ctx) == true);
|
||||
|
||||
if (res)
|
||||
PrintAndLogEx(INFO, "Auth: " _GREEN_("passed"));
|
||||
else
|
||||
PrintAndLogEx(ERR, "Auth: " _RED_("fail"));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool CIPURSETest(bool verbose) {
|
||||
|
@ -99,6 +141,7 @@ bool CIPURSETest(bool verbose) {
|
|||
res = res && TestKVV();
|
||||
res = res && TestISO9797M2();
|
||||
res = res && TestSMI();
|
||||
res = res && TestAuth();
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue