chg, printf

This commit is contained in:
iceman1001 2020-05-29 10:15:40 +02:00
parent fd6ac2f024
commit 54827d3ec9
5 changed files with 99 additions and 118 deletions

View file

@ -17,16 +17,16 @@
#include <config.h>
#endif
#include <string.h> // memcpy
#include <stdlib.h> // malloc
#include "cda_test.h"
#include "../emv_pk.h"
#include "../crypto.h"
#include "../dump.h"
#include "../tlv.h"
#include "../emv_pki.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "cda_test.h"
#include "ui.h" // printandlog
struct emv_pk c_mchip_05 = {
.rid = { 0xa0, 0x00, 0x00, 0x00, 0x04, },
@ -169,7 +169,7 @@ static int cda_test_raw(bool verbose) {
return 1;
if (verbose) {
printf("issuer cert:\n");
PrintAndLogEx(INFO, "issuer cert:");
dump_buffer(ipk_data, ipk_data_len, stdout, 0);
}
@ -199,7 +199,7 @@ static int cda_test_raw(bool verbose) {
}
if (verbose) {
printf("crypto hash:\n");
PrintAndLogEx(INFO, "crypto hash:");
dump_buffer(h, 20, stdout, 0);
}
@ -228,7 +228,7 @@ static int cda_test_raw(bool verbose) {
return 1;
if (verbose) {
printf("icc cert:\n");
PrintAndLogEx(INFO, "icc cert:");
dump_buffer(iccpk_data, iccpk_data_len, stdout, 0);
}
@ -257,7 +257,7 @@ static int cda_test_raw(bool verbose) {
}
if (verbose) {
printf("crypto hash1.1:\n");
PrintAndLogEx(INFO, "crypto hash1.1:");
dump_buffer(h, 20, stdout, 0);
}
@ -284,7 +284,7 @@ static int cda_test_raw(bool verbose) {
return 1;
if (verbose) {
printf("SDAD:\n");
PrintAndLogEx(INFO, "SDAD:");
dump_buffer(sdad, sdad_len, stdout, 0);
}
@ -305,7 +305,7 @@ static int cda_test_raw(bool verbose) {
}
if (verbose) {
printf("crypto hash2:\n");
PrintAndLogEx(INFO, "crypto hash2:");
dump_buffer(h2, 20, stdout, 0);
}
@ -328,7 +328,7 @@ static int cda_test_raw(bool verbose) {
}
if (verbose) {
printf("crypto hash2.1:\n");
PrintAndLogEx(INFO, "crypto hash2.1:");
dump_buffer(h, 20, stdout, 0);
}
@ -339,9 +339,7 @@ static int cda_test_raw(bool verbose) {
}
crypto_hash_close(ch);
free(sdad);
return 0;
}
@ -356,7 +354,7 @@ static int cda_test_pk(bool verbose) {
struct emv_pk *ipk = emv_pki_recover_issuer_cert(pk, db);
if (!ipk) {
fprintf(stderr, "Could not recover Issuer certificate!\n");
PrintAndLogEx(WARNING, "Could not recover Issuer certificate!");
tlvdb_free(db);
return 2;
}
@ -367,7 +365,7 @@ static int cda_test_pk(bool verbose) {
struct emv_pk *iccpk = emv_pki_recover_icc_cert(ipk, db, &ssd1_tlv);
if (!iccpk) {
fprintf(stderr, "Could not recover ICC certificate!\n");
PrintAndLogEx(WARNING, "Could not recover ICC certificate!");
emv_pk_free(ipk);
tlvdb_free(db);
return 2;
@ -387,7 +385,7 @@ static int cda_test_pk(bool verbose) {
&crm1_tlv,
NULL);
if (!idndb) {
fprintf(stderr, "Could not recover IDN!\n");
PrintAndLogEx(WARNING, "Could not recover IDN!");
tlvdb_free(cda_db);
emv_pk_free(iccpk);
emv_pk_free(ipk);
@ -397,7 +395,7 @@ static int cda_test_pk(bool verbose) {
const struct tlv *idn = tlvdb_get(idndb, 0x9f4c, NULL);
if (!idn) {
fprintf(stderr, "IDN not found!\n");
PrintAndLogEx(WARNING, "IDN not found!");
tlvdb_free(idndb);
tlvdb_free(cda_db);
emv_pk_free(iccpk);
@ -407,7 +405,7 @@ static int cda_test_pk(bool verbose) {
}
if (verbose) {
printf("IDN:\n");
PrintAndLogEx(INFO, "IDN:");
dump_buffer(idn->value, idn->len, stdout, 0);
}
@ -416,27 +414,22 @@ static int cda_test_pk(bool verbose) {
emv_pk_free(iccpk);
emv_pk_free(ipk);
tlvdb_free(db);
return 0;
}
int exec_cda_test(bool verbose) {
int ret;
fprintf(stdout, "\n");
ret = cda_test_raw(verbose);
int ret = cda_test_raw(verbose);
if (ret) {
fprintf(stderr, "CDA raw test: failed\n");
PrintAndLogEx(WARNING, "CDA raw test: failed");
return ret;
}
fprintf(stdout, "CDA raw test: passed\n");
PrintAndLogEx(INFO, "CDA raw test: passed");
ret = cda_test_pk(verbose);
if (ret) {
fprintf(stderr, "CDA test pk: failed\n");
PrintAndLogEx(WARNING, "CDA test pk: failed");
return ret;
}
fprintf(stdout, "CDA test pk: passed\n");
PrintAndLogEx(INFO, "CDA test pk: passed");
return 0;
}

View file

@ -17,16 +17,16 @@
#include <config.h>
#endif
#include "commonutil.h" // ARRAYLEN
#include <string.h> // memcpy
#include <stdlib.h> // malloc
#include <inttypes.h>
#include "crypto_test.h"
#include "commonutil.h" // ARRAYLEN
#include "../crypto.h"
#include "../dump.h"
#include "util_posix.h"
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include "crypto_test.h"
#include "ui.h" // printandlog
static int test_genkey(unsigned int keylength, unsigned char *msg, size_t msg_len, bool verbose) {
int ret = 1;
@ -34,46 +34,46 @@ static int test_genkey(unsigned int keylength, unsigned char *msg, size_t msg_le
unsigned char *tmp, *tmp2;
struct crypto_pk *pk;
printf("Testing key length %u ", keylength);
PrintAndLogEx(INFO, "Testing key length " _GREEN_("%u"), keylength);
uint64_t ms = msclock();
pk = crypto_pk_genkey(PK_RSA, 1, keylength, 3);
if (!pk) {
fprintf(stderr, "ERROR: key generation error.\n");
PrintAndLogEx(WARNING, "ERROR: key generation error");
goto out;
}
tmp_len = crypto_pk_get_nbits(pk);
if (tmp_len != keylength) {
fprintf(stderr, "ERROR: crypto_pk_get_nbits.\n");
PrintAndLogEx(WARNING, "ERROR: crypto_pk_get_nbits");
goto close;
}
tmp = crypto_pk_decrypt(pk, msg, msg_len, &tmp_len);
if (!tmp) {
fprintf(stderr, "ERROR: crypto_pk_decrypt.\n");
PrintAndLogEx(WARNING, "ERROR: crypto_pk_decrypt");
goto close;
}
tmp2 = crypto_pk_encrypt(pk, tmp, tmp_len, &tmp2_len);
if (!tmp2) {
fprintf(stderr, "ERROR: crypto_pk_encrypt.\n");
PrintAndLogEx(WARNING, "ERROR: crypto_pk_encrypt");
goto free_tmp;
}
if (tmp2_len == msg_len && !memcmp(tmp2, msg, tmp2_len)) {
ret = 0;
} else {
fprintf(stderr, "ERROR: encrypt-decrypt sequence length or data error.\n");
PrintAndLogEx(WARNING, "ERROR: encrypt-decrypt sequence length or data error");
}
free(tmp2);
printf("passed. (%"PRIu64" ms) \n", msclock() - ms);
PrintAndLogEx(SUCCESS, "passed (" _GREEN_("%" PRIu64) " ms)", msclock() - ms);
free_tmp:
free(tmp);
close:
crypto_pk_close(pk);
out:
return ret;
}
@ -202,25 +202,25 @@ static int test_pk(bool verbose) {
unsigned char *msg = message;
size_t msg_len = sizeof(pk_N);
printf("Testing public keys interfaces\n");
PrintAndLogEx(INFO, "Testing public keys interfaces");
pubk = crypto_pk_open(PK_RSA,
pk_N, sizeof(pk_N),
pk_E, sizeof(pk_E));
if (!pubk) {
fprintf(stderr, "ERROR: open public key.\n");
PrintAndLogEx(WARNING, "ERROR: open public key");
return 1;
}
tmp_len = crypto_pk_get_nbits(pubk);
if (tmp_len != sizeof(pk_N) * 8) {
fprintf(stderr, "ERROR: crypto_pk_get_nbits mismatch.\n");
PrintAndLogEx(WARNING, "ERROR: crypto_pk_get_nbits mismatch");
goto close_pub;
}
tmp = crypto_pk_get_parameter(pubk, 0, &tmp_len);
if (tmp_len != sizeof(pk_N) || memcmp(tmp, pk_N, tmp_len)) {
fprintf(stderr, "ERROR: crypto_pk_get_parameter(0) Modulus. param len %zu len %zu\n", tmp_len, sizeof(pk_N));
PrintAndLogEx(WARNING, "ERROR: crypto_pk_get_parameter(0) Modulus. param len %zu len %zu", tmp_len, sizeof(pk_N));
free(tmp);
goto close_pub;
}
@ -228,7 +228,7 @@ static int test_pk(bool verbose) {
tmp = crypto_pk_get_parameter(pubk, 1, &tmp_len);
if (tmp_len != sizeof(pk_E) || memcmp(tmp, pk_E, tmp_len)) {
fprintf(stderr, "ERROR: crypto_pk_get_parameter(1) Exponent.\n");
PrintAndLogEx(WARNING, "ERROR: crypto_pk_get_parameter(1) Exponent");
free(tmp);
goto close_pub;
}
@ -244,20 +244,20 @@ static int test_pk(bool verbose) {
pk_dQ, sizeof(pk_dQ),
pk_I, sizeof(pk_I));
if (!privk) {
fprintf(stderr, "ERROR: open private key.\n");
PrintAndLogEx(WARNING, "ERROR: open private key");
goto close_pub;
}
tmp_len = crypto_pk_get_nbits(privk);
if (tmp_len != sizeof(pk_N) * 8) {
fprintf(stderr, "ERROR: crypto_pk_get_nbits mismatch.\n");
PrintAndLogEx(WARNING, "ERROR: crypto_pk_get_nbits mismatch");
goto close_pub;
}
tmp = crypto_pk_get_parameter(privk, 0, &tmp_len);
if (tmp_len != sizeof(pk_N) || memcmp(tmp, pk_N, tmp_len)) {
fprintf(stderr, "ERROR: crypto_pk_get_parameter(0) Modulus. param len %zu len %zu\n", tmp_len, sizeof(pk_N));
PrintAndLogEx(WARNING, "ERROR: crypto_pk_get_parameter(0) Modulus. param len %zu len %zu", tmp_len, sizeof(pk_N));
free(tmp);
goto close;
}
@ -265,7 +265,7 @@ static int test_pk(bool verbose) {
tmp = crypto_pk_get_parameter(privk, 1, &tmp_len);
if (tmp_len != sizeof(pk_E) || memcmp(tmp, pk_E, tmp_len)) {
fprintf(stderr, "ERROR: crypto_pk_get_parameter(1) Exponent.\n");
PrintAndLogEx(WARNING, "ERROR: crypto_pk_get_parameter(1) Exponent");
free(tmp);
goto close;
}
@ -273,20 +273,20 @@ static int test_pk(bool verbose) {
tmp = crypto_pk_decrypt(privk, msg, msg_len, &tmp_len);
if (!tmp) {
fprintf(stderr, "ERROR: crypto_pk_decrypt.\n");
PrintAndLogEx(WARNING, "ERROR: crypto_pk_decrypt");
goto close;
}
tmp2 = crypto_pk_encrypt(pubk, tmp, tmp_len, &tmp2_len);
if (!tmp2) {
fprintf(stderr, "ERROR: crypto_pk_encrypt.\n");
PrintAndLogEx(WARNING, "ERROR: crypto_pk_encrypt");
goto free_tmp;
}
if (tmp2_len == msg_len && !memcmp(tmp2, msg, tmp2_len)) {
ret = 0;
} else {
fprintf(stderr, "ERROR: encrypt-decrypt sequence length or data error.\n");
PrintAndLogEx(WARNING, "ERROR: encrypt-decrypt sequence length or data error");
}
free(tmp2);
@ -310,16 +310,16 @@ int exec_crypto_test(bool verbose, bool include_slow_tests) {
ret = test_pk(verbose);
if (ret) {
fprintf(stderr, "Crypto raw test: failed\n");
PrintAndLogEx(WARNING, "Crypto raw test: failed");
return ret;
}
fprintf(stdout, "Crypto raw test: passed\n\n");
PrintAndLogEx(SUCCESS, "Crypto raw test (%s)", _GREEN_("passed"));
for (i = 0; i < ARRAYLEN(keylengths); i++) {
unsigned int kl = keylengths[i];
ret = test_genkey(kl, message, kl / 8, verbose);
if (ret) {
fprintf(stderr, "Crypto generate key[%u] test: failed\n", kl);
PrintAndLogEx(WARNING, "Crypto generate key[%u] test: failed", kl);
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) {
fprintf(stderr, "Crypto generate key[%u] test: failed\n", kl);
PrintAndLogEx(WARNING, "Crypto generate key[%u] test: failed", kl);
return ret;
}
}

View file

@ -10,8 +10,7 @@
#include "cryptotest.h"
#include "util.h"
#include "ui.h"
#include "ui.h" // printandlog
#include "bignum.h"
#include "aes.h"
#include "cmac.h"
@ -25,7 +24,6 @@
#include "ctr_drbg.h"
#include "entropy.h"
#include "timing.h"
#include "crypto_test.h"
#include "sda_test.h"
#include "dda_test.h"
@ -63,7 +61,7 @@ int ExecuteCryptoTests(bool verbose, bool ignore_time, bool include_slow_tests)
res = mbedtls_timing_self_test(verbose);
if (!res)
break;
PrintAndLogEx(WARNING, "Repeat timing test %d", i + 1);
PrintAndLogEx(WARNING, "Repeat timing test " _RED_("%d"), i + 1);
}
if (res && !ignore_time) TestFail = true;
@ -100,12 +98,12 @@ int ExecuteCryptoTests(bool verbose, bool ignore_time, bool include_slow_tests)
res = roca_self_test();
if (res) TestFail = true;
PrintAndLogEx(NORMAL, "\n--------------------------");
PrintAndLogEx(INFO, "--------------------------");
if (TestFail)
PrintAndLogEx(FAILED, "\tTest(s) [ %s ]", _RED_("Fail"));
PrintAndLogEx(FAILED, "\tTest(s) [ %s ]", _RED_("fail"));
else
PrintAndLogEx(SUCCESS, "\tTest(s) [ %s ]", _GREEN_("OK"));
PrintAndLogEx(SUCCESS, "\tTest(s) [ %s ]", _GREEN_("ok"));
return TestFail;
}

View file

@ -17,17 +17,17 @@
#include <config.h>
#endif
#include "dda_test.h"
#include <string.h> // memcpy
#include <stdlib.h> // malloc
#include "dda_test.h"
#include "../emv_pk.h"
#include "../crypto.h"
#include "../dump.h"
#include "../tlv.h"
#include "../emv_pki.h"
#include "ui.h" // printandlog
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct emv_pk mchip_05 = {
.rid = { 0xa0, 0x00, 0x00, 0x00, 0x04, },
@ -123,6 +123,7 @@ const unsigned char d_ssd1[] = {
0x03, 0x8d, 0x0c, 0x91, 0x0a, 0x8a, 0x02, 0x95, 0x05, 0x9f, 0x37, 0x04, 0x9f, 0x4c, 0x08,
0x39, 0x00,
};
static const struct tlv ssd1_tlv = {
.len = sizeof(d_ssd1),
.value = d_ssd1,
@ -135,6 +136,7 @@ const unsigned char d_pan[] = {
const unsigned char d_dd1[] = {
0x00, 0x00, 0x00, 0x00,
};
static const struct tlv dd1_tlv = {
.len = sizeof(d_dd1),
.value = d_dd1,
@ -158,7 +160,7 @@ static int dda_test_raw(bool verbose) {
return 1;
if (verbose) {
printf("issuer cert:\n");
PrintAndLogEx(INFO, "issuer cert:");
dump_buffer(ipk_data, ipk_data_len, stdout, 0);
}
@ -188,7 +190,7 @@ static int dda_test_raw(bool verbose) {
}
if (verbose) {
printf("crypto hash:\n");
PrintAndLogEx(INFO, "crypto hash:");
dump_buffer(h, 20, stdout, 0);
}
@ -217,7 +219,7 @@ static int dda_test_raw(bool verbose) {
return 1;
if (verbose) {
printf("icc cert:\n");
PrintAndLogEx(INFO, "icc cert:");
dump_buffer(iccpk_data, iccpk_data_len, stdout, 0);
}
@ -246,7 +248,7 @@ static int dda_test_raw(bool verbose) {
}
if (verbose) {
printf("crypto hash1.1:\n");
PrintAndLogEx(INFO, "crypto hash1.1:");
dump_buffer(h, 20, stdout, 0);
}
@ -273,7 +275,7 @@ static int dda_test_raw(bool verbose) {
return 1;
if (verbose) {
printf("sdad:\n");
PrintAndLogEx(INFO, "sdad:");
dump_buffer(sdad, sdad_len, stdout, 0);
}
@ -294,14 +296,12 @@ static int dda_test_raw(bool verbose) {
}
if (verbose) {
printf("crypto hash2:\n");
PrintAndLogEx(INFO, "crypto hash2:");
dump_buffer(h2, 20, stdout, 0);
}
crypto_hash_close(ch);
free(sdad);
return 0;
}
@ -316,7 +316,7 @@ static int dda_test_pk(bool verbose) {
struct emv_pk *ipk = emv_pki_recover_issuer_cert(pk, db);
if (!ipk) {
fprintf(stderr, "Could not recover Issuer certificate!\n");
PrintAndLogEx(WARNING, "Could not recover Issuer certificate!");
tlvdb_free(db);
return 2;
}
@ -327,7 +327,7 @@ static int dda_test_pk(bool verbose) {
struct emv_pk *iccpk = emv_pki_recover_icc_cert(ipk, db, &ssd1_tlv);
if (!iccpk) {
fprintf(stderr, "Could not recover ICC certificate!\n");
PrintAndLogEx(WARNING, "Could not recover ICC certificate!");
emv_pk_free(ipk);
tlvdb_free(db);
return 2;
@ -337,7 +337,7 @@ static int dda_test_pk(bool verbose) {
struct tlvdb *idndb = emv_pki_recover_idn(iccpk, db, &dd1_tlv);
if (!idndb) {
fprintf(stderr, "Could not recover IDN!\n");
PrintAndLogEx(WARNING, "Could not recover IDN!");
emv_pk_free(iccpk);
emv_pk_free(ipk);
tlvdb_free(db);
@ -346,7 +346,7 @@ static int dda_test_pk(bool verbose) {
const struct tlv *idn = tlvdb_get(idndb, 0x9f4c, NULL);
if (!idn) {
fprintf(stderr, "IDN not found!\n");
PrintAndLogEx(WARNING, "IDN not found!");
tlvdb_free(idndb);
emv_pk_free(iccpk);
emv_pk_free(ipk);
@ -355,7 +355,7 @@ static int dda_test_pk(bool verbose) {
}
if (verbose) {
printf("IDN:\n");
PrintAndLogEx(INFO, "IDN:");
dump_buffer(idn->value, idn->len, stdout, 0);
}
@ -363,27 +363,22 @@ static int dda_test_pk(bool verbose) {
emv_pk_free(iccpk);
emv_pk_free(ipk);
tlvdb_free(db);
return 0;
}
int exec_dda_test(bool verbose) {
int ret;
fprintf(stdout, "\n");
ret = dda_test_raw(verbose);
int ret = dda_test_raw(verbose);
if (ret) {
fprintf(stderr, "DDA raw test: failed\n");
PrintAndLogEx(WARNING, "DDA raw test: %s", _RED_("failed"));
return ret;
}
fprintf(stdout, "DDA raw test: passed\n");
PrintAndLogEx(SUCCESS, "DDA raw test: %s", _GREEN_("passed"));
ret = dda_test_pk(verbose);
if (ret) {
fprintf(stderr, "DDA test pk: failed\n");
PrintAndLogEx(WARNING, "DDA test pk: %s", _RED_("failed"));
return ret;
}
fprintf(stdout, "DDA test pk: passed\n");
PrintAndLogEx(SUCCESS, "DDA test pk: %s", _GREEN_("passed"));
return 0;
}

View file

@ -17,15 +17,16 @@
#include <config.h>
#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "../emv_pk.h"
#include "../crypto.h"
#include "../dump.h"
#include "../tlv.h"
#include "../emv_pki.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "ui.h" // printandlog
#include "sda_test.h"
struct emv_pk vsdc_01 = {
@ -92,6 +93,7 @@ const unsigned char ssd1[] = {
0x5f, 0x24, 0x03, 0x08, 0x12, 0x31, 0x5a, 0x08, 0x42, 0x76, 0x55, 0x00, 0x13, 0x23, 0x45, 0x99, 0x5f, 0x34, 0x01, 0x01, 0x9f, 0x07, 0x02, 0xff, 0x00, 0x9f, 0x0d, 0x05, 0xd0, 0x40, 0xac, 0xa8, 0x00, 0x9f, 0x0e, 0x05, 0x00, 0x10, 0x00, 0x00, 0x00, 0x9f, 0x0f, 0x05, 0xd0, 0x68, 0xbc, 0xf8, 0x00,
0x5c, 0x00,
};
static const struct tlv ssd1_tlv = {
.len = sizeof(ssd1),
.value = ssd1,
@ -119,7 +121,7 @@ static int sda_test_raw(bool verbose) {
return 1;
if (verbose) {
printf("issuer cert:\n");
PrintAndLogEx(INFO, "issuer cert:");
dump_buffer(ipk_data, ipk_data_len, stdout, 0);
}
@ -149,7 +151,7 @@ static int sda_test_raw(bool verbose) {
}
if (verbose) {
printf("crypto hash:\n");
PrintAndLogEx(INFO, "crypto hash:");
dump_buffer(h, 20, stdout, 0);
}
@ -176,7 +178,7 @@ static int sda_test_raw(bool verbose) {
return 1;
if (verbose) {
printf("ssad:\n");
PrintAndLogEx(INFO, "ssad:");
dump_buffer(ssad, ssad_len, stdout, 0);
}
@ -197,14 +199,12 @@ static int sda_test_raw(bool verbose) {
}
if (verbose) {
printf("crypto hash2:\n");
PrintAndLogEx(INFO, "crypto hash2:");
dump_buffer(h2, 20, stdout, 0);
}
crypto_hash_close(ch);
free(ssad);
return 0;
}
@ -219,7 +219,7 @@ static int sda_test_pk(bool verbose) {
struct emv_pk *ipk = emv_pki_recover_issuer_cert(pk, db);
if (!ipk) {
fprintf(stderr, "Could not recover Issuer certificate!\n");
PrintAndLogEx(WARNING, "Could not recover Issuer certificate!");
tlvdb_free(db);
return 2;
}
@ -228,7 +228,7 @@ static int sda_test_pk(bool verbose) {
struct tlvdb *dacdb = emv_pki_recover_dac(ipk, db, &ssd1_tlv);
if (!dacdb) {
fprintf(stderr, "Could not recover DAC!\n");
PrintAndLogEx(WARNING, "Could not recover DAC!");
emv_pk_free(ipk);
tlvdb_free(db);
return 2;
@ -236,7 +236,7 @@ static int sda_test_pk(bool verbose) {
const struct tlv *dac = tlvdb_get(dacdb, 0x9f45, NULL);
if (!dac) {
fprintf(stderr, "DAC not found!\n");
PrintAndLogEx(WARNING, "DAC not found!");
tlvdb_free(dacdb);
emv_pk_free(ipk);
tlvdb_free(db);
@ -244,34 +244,29 @@ static int sda_test_pk(bool verbose) {
}
if (verbose) {
printf("dac:\n");
PrintAndLogEx(INFO, "dac:");
dump_buffer(dac->value, dac->len, stdout, 0);
}
tlvdb_free(dacdb);
emv_pk_free(ipk);
tlvdb_free(db);
return 0;
}
int exec_sda_test(bool verbose) {
int ret;
fprintf(stdout, "\n");
ret = sda_test_raw(verbose);
int ret = sda_test_raw(verbose);
if (ret) {
fprintf(stderr, "SDA raw test: failed\n");
PrintAndLogEx(WARNING, "SDA raw test: %s", _RED_("failed"));
return ret;
}
fprintf(stdout, "SDA raw test: passed\n");
PrintAndLogEx(SUCCESS, "SDA raw test: %s", _GREEN_("passed"));
ret = sda_test_pk(verbose);
if (ret) {
fprintf(stderr, "SDA test pk: failed\n");
PrintAndLogEx(WARNING, "SDA test pk: %s", _RED_("failed"));
return ret;
}
fprintf(stdout, "SDA test pk: passed\n");
PrintAndLogEx(SUCCESS, "SDA test pk: %s", _GREEN_("passed"));
return 0;
}
}