mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 10:37:23 -07:00
adapt regression tests
This commit is contained in:
parent
365454bb3c
commit
67c14c5314
9 changed files with 53 additions and 85 deletions
|
@ -40,11 +40,7 @@ static bool TestKVV(void) {
|
|||
|
||||
bool res = memcmp(KeyKvv, kvv, CIPURSE_KVV_LENGTH) == 0;
|
||||
|
||||
if (res)
|
||||
PrintAndLogEx(INFO, "kvv.............. " _GREEN_("passed"));
|
||||
else
|
||||
PrintAndLogEx(ERR, "kvv.............. " _RED_("fail"));
|
||||
|
||||
PrintAndLogEx(SUCCESS, "kvv.............. ( %s )", (res) ? _GREEN_("ok") : _RED_("fail"));
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -58,11 +54,7 @@ static bool TestISO9797M2(void) {
|
|||
|
||||
res = res && (FindISO9797M2PaddingDataLen(data, ddatalen) == 4);
|
||||
|
||||
if (res)
|
||||
PrintAndLogEx(INFO, "ISO9797M2........ " _GREEN_("passed"));
|
||||
else
|
||||
PrintAndLogEx(ERR, "ISO9797M2........ " _RED_("fail"));
|
||||
|
||||
PrintAndLogEx(SUCCESS, "ISO9797M2........ ( %s )", (res) ? _GREEN_("ok") : _RED_("fail"));
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -92,11 +84,7 @@ static bool TestSMI(void) {
|
|||
res = res && (CipurseCGetSMI(&ctx, false) == 0x88);
|
||||
res = res && (CipurseCGetSMI(&ctx, true) == 0x89);
|
||||
|
||||
if (res)
|
||||
PrintAndLogEx(INFO, "SMI.............. " _GREEN_("passed"));
|
||||
else
|
||||
PrintAndLogEx(ERR, "SMI.............. " _RED_("fail"));
|
||||
|
||||
PrintAndLogEx(SUCCESS, "SMI.............. ( %s )", (res) ? _GREEN_("ok") : _RED_("fail"));
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -115,15 +103,10 @@ static bool TestMIC(void) {
|
|||
|
||||
res = res && (CipurseCCheckMIC(TestData, 6, mic));
|
||||
|
||||
if (res)
|
||||
PrintAndLogEx(INFO, "MIC.............. " _GREEN_("passed"));
|
||||
else
|
||||
PrintAndLogEx(ERR, "MIC.............. " _RED_("fail"));
|
||||
|
||||
PrintAndLogEx(SUCCESS, "MIC.............. ( %s )", (res) ? _GREEN_("ok") : _RED_("fail"));
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
static bool TestAuth(void) {
|
||||
CipurseContext_t ctx = {0};
|
||||
CipurseCClearContext(&ctx);
|
||||
|
@ -159,11 +142,7 @@ static bool TestAuth(void) {
|
|||
uint8_t framekey[] = {0xCF, 0x6F, 0x3A, 0x47, 0xFC, 0xAC, 0x8D, 0x38, 0x25, 0x75, 0x8B, 0xFC, 0x8B, 0x61, 0x68, 0xF3};
|
||||
res = res && (memcmp(ctx.frameKey, framekey, sizeof(framekey)) == 0);
|
||||
|
||||
if (res)
|
||||
PrintAndLogEx(INFO, "Auth............. " _GREEN_("passed"));
|
||||
else
|
||||
PrintAndLogEx(ERR, "Auth............. " _RED_("fail"));
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Auth............. ( %s )", (res) ? _GREEN_("ok") : _RED_("fail"));
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -211,11 +190,7 @@ static bool TestMAC(void) {
|
|||
uint8_t framekey4[] = {0xA0, 0x65, 0x1A, 0x62, 0x56, 0x5D, 0xD7, 0xC9, 0x32, 0xAE, 0x1D, 0xE0, 0xCF, 0x8D, 0xC1, 0xB9};
|
||||
res = res && (memcmp(ctx.frameKey, framekey4, sizeof(framekey4)) == 0);
|
||||
|
||||
if (res)
|
||||
PrintAndLogEx(INFO, "channel MAC...... " _GREEN_("passed"));
|
||||
else
|
||||
PrintAndLogEx(ERR, "channel MAC...... " _RED_("fail"));
|
||||
|
||||
PrintAndLogEx(SUCCESS, "channel MAC...... ( %s )", (res) ? _GREEN_("ok") : _RED_("fail"));
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -259,11 +234,7 @@ static bool TestEncDec(void) {
|
|||
res = res && (dstdatalen == 16);
|
||||
res = res && (memcmp(dstdata, TestData, 16) == 0);
|
||||
|
||||
if (res)
|
||||
PrintAndLogEx(INFO, "channel EncDec... " _GREEN_("passed"));
|
||||
else
|
||||
PrintAndLogEx(ERR, "channel EncDec... " _RED_("fail"));
|
||||
|
||||
PrintAndLogEx(SUCCESS, "channel EncDec... ( %s )", (res) ? _GREEN_("ok") : _RED_("fail"));
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -351,11 +322,7 @@ static bool TestAPDU(void) {
|
|||
res = res && (memcmp(test6, dstdata, dstdatalen) == 0);
|
||||
res = res && (sw == 0xccdd);
|
||||
|
||||
if (res)
|
||||
PrintAndLogEx(INFO, "apdu............. " _GREEN_("passed"));
|
||||
else
|
||||
PrintAndLogEx(ERR, "apdu............. " _RED_("fail"));
|
||||
|
||||
PrintAndLogEx(SUCCESS, "apdu............. ( %s )", (res) ? _GREEN_("ok") : _RED_("fail"));
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -374,11 +341,7 @@ bool CIPURSETest(bool verbose) {
|
|||
res = res && TestAPDU();
|
||||
|
||||
PrintAndLogEx(INFO, "---------------------------");
|
||||
if (res)
|
||||
PrintAndLogEx(SUCCESS, " Tests [ %s ]", _GREEN_("ok"));
|
||||
else
|
||||
PrintAndLogEx(FAILED, " Tests [ %s ]", _RED_("fail"));
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Tests ( %s )", (res) ? _GREEN_("ok") : _RED_("fail"));
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -153,10 +153,10 @@ int roca_self_test(void) {
|
|||
|
||||
int ret = 0;
|
||||
if (emv_rocacheck(keyp, 64, false)) {
|
||||
PrintAndLogEx(SUCCESS, "Weak modulus [ %s ]", _GREEN_("PASS"));
|
||||
PrintAndLogEx(SUCCESS, "Weak modulus ( %s )", _GREEN_("ok"));
|
||||
} else {
|
||||
ret++;
|
||||
PrintAndLogEx(FAILED, "Weak modulus [ %s ]", _RED_("Fail"));
|
||||
PrintAndLogEx(FAILED, "Weak modulus ( %s )", _RED_("fail"));
|
||||
}
|
||||
|
||||
// negative
|
||||
|
@ -167,9 +167,9 @@ int roca_self_test(void) {
|
|||
|
||||
if (emv_rocacheck(keyn, 64, false)) {
|
||||
ret++;
|
||||
PrintAndLogEx(FAILED, "Strong modulus [ %s ]", _RED_("Fail"));
|
||||
PrintAndLogEx(FAILED, "Strong modulus ( %s )", _RED_("fail"));
|
||||
} else {
|
||||
PrintAndLogEx(SUCCESS, "Strong modulus [ %s ]", _GREEN_("PASS"));
|
||||
PrintAndLogEx(SUCCESS, "Strong modulus ( %s )", _GREEN_("ok"));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -427,16 +427,16 @@ static int cda_test_pk(bool verbose) {
|
|||
int exec_cda_test(bool verbose) {
|
||||
int ret = cda_test_raw(verbose);
|
||||
if (ret) {
|
||||
PrintAndLogEx(WARNING, "CDA raw test: (%s)", _RED_("failed"));
|
||||
PrintAndLogEx(WARNING, "CDA raw test ( %s )", _RED_("fail"));
|
||||
return ret;
|
||||
}
|
||||
PrintAndLogEx(INFO, "CDA raw test: (%s)", _GREEN_("passed"));
|
||||
PrintAndLogEx(INFO, "CDA raw test ( %s )", _GREEN_("ok"));
|
||||
|
||||
ret = cda_test_pk(verbose);
|
||||
if (ret) {
|
||||
PrintAndLogEx(WARNING, "CDA test pk: (%s)", _RED_("failed"));
|
||||
PrintAndLogEx(WARNING, "CDA test pk ( %s )", _RED_("fail"));
|
||||
return ret;
|
||||
}
|
||||
PrintAndLogEx(INFO, "CDA test pk: (%s)", _GREEN_("passed"));
|
||||
PrintAndLogEx(INFO, "CDA test pk ( %s )", _GREEN_("ok"));
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -310,16 +310,16 @@ int exec_crypto_test(bool verbose, bool include_slow_tests) {
|
|||
unsigned int extra_keylengths[] = {1152, 1408, 1984, 3072, 4096};
|
||||
int ret = test_pk(verbose);
|
||||
if (ret) {
|
||||
PrintAndLogEx(WARNING, "Crypto raw test: (%s)", _RED_("failed"));
|
||||
PrintAndLogEx(WARNING, "Crypto raw test ( %s )", _RED_("fail"));
|
||||
return ret;
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "Crypto raw test (%s)", _GREEN_("passed"));
|
||||
PrintAndLogEx(SUCCESS, "Crypto raw test ( %s )", _GREEN_("ok"));
|
||||
|
||||
for (int i = 0; i < ARRAYLEN(keylengths); i++) {
|
||||
unsigned int kl = keylengths[i];
|
||||
ret = test_genkey(kl, message, kl / 8, verbose);
|
||||
if (ret) {
|
||||
PrintAndLogEx(WARNING, "Crypto generate key[%u] test: (%s)", kl, _RED_("failed"));
|
||||
PrintAndLogEx(WARNING, "Crypto generate key[ %u ] test ( %s )", kl, _RED_("fail"));
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -328,7 +328,7 @@ int exec_crypto_test(bool verbose, bool include_slow_tests) {
|
|||
unsigned int kl = extra_keylengths[i];
|
||||
ret = test_genkey(kl, message, kl / 8, verbose);
|
||||
if (ret) {
|
||||
PrintAndLogEx(WARNING, "Crypto generate key[%u] test: (%s)", kl, _RED_("failed"));
|
||||
PrintAndLogEx(WARNING, "Crypto generate key[ %u ] test ( %s )", kl, _RED_("fail"));
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,9 +111,9 @@ int ExecuteCryptoTests(bool verbose, bool ignore_time, bool include_slow_tests)
|
|||
PrintAndLogEx(INFO, "--------------------------");
|
||||
|
||||
if (TestFail)
|
||||
PrintAndLogEx(FAILED, "\tTest(s) [ %s ]", _RED_("fail"));
|
||||
PrintAndLogEx(FAILED, "Tests ( %s )", _RED_("fail"));
|
||||
else
|
||||
PrintAndLogEx(SUCCESS, "\tTest(s) [ %s ]", _GREEN_("ok"));
|
||||
PrintAndLogEx(SUCCESS, "Tests ( %s )", _GREEN_("ok"));
|
||||
|
||||
return TestFail;
|
||||
}
|
||||
|
|
|
@ -373,16 +373,16 @@ static int dda_test_pk(bool verbose) {
|
|||
int exec_dda_test(bool verbose) {
|
||||
int ret = dda_test_raw(verbose);
|
||||
if (ret) {
|
||||
PrintAndLogEx(WARNING, "DDA raw test: %s", _RED_("failed"));
|
||||
PrintAndLogEx(WARNING, "DDA raw test ( %s )", _RED_("fail"));
|
||||
return ret;
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "DDA raw test: %s", _GREEN_("passed"));
|
||||
PrintAndLogEx(SUCCESS, "DDA raw test ( %s )", _GREEN_("ok"));
|
||||
|
||||
ret = dda_test_pk(verbose);
|
||||
if (ret) {
|
||||
PrintAndLogEx(WARNING, "DDA test pk: %s", _RED_("failed"));
|
||||
PrintAndLogEx(WARNING, "DDA test pk ( %s )", _RED_("fail"));
|
||||
return ret;
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "DDA test pk: %s", _GREEN_("passed"));
|
||||
PrintAndLogEx(SUCCESS, "DDA test pk ( %s )", _GREEN_("ok"));
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -262,16 +262,16 @@ static int sda_test_pk(bool verbose) {
|
|||
int exec_sda_test(bool verbose) {
|
||||
int ret = sda_test_raw(verbose);
|
||||
if (ret) {
|
||||
PrintAndLogEx(WARNING, "SDA raw test: %s", _RED_("failed"));
|
||||
PrintAndLogEx(WARNING, "SDA raw test ( %s )", _RED_("fa1l"));
|
||||
return ret;
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "SDA raw test: %s", _GREEN_("passed"));
|
||||
PrintAndLogEx(SUCCESS, "SDA raw test ( %s )", _GREEN_("ok"));
|
||||
|
||||
ret = sda_test_pk(verbose);
|
||||
if (ret) {
|
||||
PrintAndLogEx(WARNING, "SDA test pk: %s", _RED_("failed"));
|
||||
PrintAndLogEx(WARNING, "SDA test pk ( %s )", _RED_("fail"));
|
||||
return ret;
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "SDA test pk: %s", _GREEN_("passed"));
|
||||
PrintAndLogEx(SUCCESS, "SDA test pk ( %s )", _GREEN_("ok"));
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -968,8 +968,9 @@ int mbedtls_x509_self_test(int verbose) {
|
|||
mbedtls_x509_crt cacert;
|
||||
mbedtls_x509_crt clicert;
|
||||
|
||||
if (verbose != 0)
|
||||
mbedtls_printf(" X.509 certificate load: ");
|
||||
if (verbose != 0) {
|
||||
mbedtls_printf(" X.509 certificate load ");
|
||||
}
|
||||
|
||||
mbedtls_x509_crt_init(&cacert);
|
||||
mbedtls_x509_crt_init(&clicert);
|
||||
|
@ -977,8 +978,9 @@ int mbedtls_x509_self_test(int verbose) {
|
|||
ret = mbedtls_x509_crt_parse(&clicert, (const unsigned char *) mbedtls_test_cli_crt,
|
||||
mbedtls_test_cli_crt_len);
|
||||
if (ret != 0) {
|
||||
if (verbose != 0)
|
||||
mbedtls_printf("failed\n");
|
||||
if (verbose != 0) {
|
||||
mbedtls_printf("( fail )\n");
|
||||
}
|
||||
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -986,25 +988,28 @@ int mbedtls_x509_self_test(int verbose) {
|
|||
ret = mbedtls_x509_crt_parse(&cacert, (const unsigned char *) mbedtls_test_ca_crt,
|
||||
mbedtls_test_ca_crt_len);
|
||||
if (ret != 0) {
|
||||
if (verbose != 0)
|
||||
mbedtls_printf("failed\n");
|
||||
if (verbose != 0) {
|
||||
mbedtls_printf("( fail )\n");
|
||||
}
|
||||
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (verbose != 0)
|
||||
mbedtls_printf("passed\n X.509 signature verify: ");
|
||||
if (verbose != 0) {
|
||||
mbedtls_printf("( ok )\n X.509 signature verify ");
|
||||
}
|
||||
|
||||
ret = mbedtls_x509_crt_verify(&clicert, &cacert, NULL, NULL, &flags, NULL, NULL);
|
||||
if (ret != 0) {
|
||||
if (verbose != 0)
|
||||
mbedtls_printf("failed\n");
|
||||
|
||||
if (verbose != 0) {
|
||||
mbedtls_printf("( fail )\n");
|
||||
}
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (verbose != 0)
|
||||
mbedtls_printf("passed\n\n");
|
||||
if (verbose != 0) {
|
||||
mbedtls_printf("( ok )\n\n");
|
||||
}
|
||||
|
||||
cleanup:
|
||||
mbedtls_x509_crt_free(&cacert);
|
||||
|
|
|
@ -528,13 +528,13 @@ while true; do
|
|||
if ! CheckExecute "hf mf offline text" "$CLIENTBIN -c 'hf mf'" "content from tag dump file"; then break; fi
|
||||
if ! CheckExecute slow retry ignore "hf mf hardnested long test" "$CLIENTBIN -c 'hf mf hardnested -t --tk 000000000000'" "found:"; then break; fi
|
||||
if ! CheckExecute slow "hf iclass loclass long test" "$CLIENTBIN -c 'hf iclass loclass --long'" "verified \( ok \)"; then break; fi
|
||||
if ! CheckExecute slow "emv long test" "$CLIENTBIN -c 'emv test -l'" "Test\(s\) \[ ok"; then break; fi
|
||||
if ! CheckExecute slow "emv long test" "$CLIENTBIN -c 'emv test -l'" "Tests \( ok"; then break; fi
|
||||
if ! CheckExecute "hf iclass lookup test" "$CLIENTBIN -c 'hf iclass lookup --csn 9655a400f8ff12e0 --epurse f0ffffffffffffff --macs 0000000089cb984b -f $DICPATH/iclass_default_keys.dic'" \
|
||||
"valid key AE A6 84 A6 DA B2 32 78"; then break; fi
|
||||
if ! CheckExecute "hf iclass loclass test" "$CLIENTBIN -c 'hf iclass loclass --test'" "key diversification \( ok \)"; then break; fi
|
||||
if ! CheckExecute "emv test" "$CLIENTBIN -c 'emv test'" "Test\(s\) \[ ok"; then break; fi
|
||||
if ! CheckExecute "hf cipurse test" "$CLIENTBIN -c 'hf cipurse test'" "Tests \[ ok"; then break; fi
|
||||
if ! CheckExecute "hf mfdes test" "$CLIENTBIN -c 'hf mfdes test'" "Tests \[ ok"; then break; fi
|
||||
if ! CheckExecute "emv test" "$CLIENTBIN -c 'emv test'" "Tests \( ok"; then break; fi
|
||||
if ! CheckExecute "hf cipurse test" "$CLIENTBIN -c 'hf cipurse test'" "Tests \( ok"; then break; fi
|
||||
if ! CheckExecute "hf mfdes test" "$CLIENTBIN -c 'hf mfdes test'" "Tests \( ok"; then break; fi
|
||||
if ! CheckExecute "hf waveshare load" "$CLIENTBIN -c 'hf waveshare load -m 6 -f tools/lena.bmp -s dither.bmp' && echo '34ff55fe7257876acf30dae00eb0e439 dither.bmp' | md5sum -c" "dither.bmp: OK"; then break; fi
|
||||
fi
|
||||
echo -e "\n------------------------------------------------------------"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue