diff --git a/client/src/crypto/libpcrypto.c b/client/src/crypto/libpcrypto.c index a00918b91..2ed0b6bc7 100644 --- a/client/src/crypto/libpcrypto.c +++ b/client/src/crypto/libpcrypto.c @@ -24,8 +24,8 @@ #include #include #include -#include - +#include "util.h" +#include "ui.h" // NIST Special Publication 800-38A — Recommendation for block cipher modes of operation: methods and techniques, 2001. int aes_encode(uint8_t *iv, uint8_t *key, uint8_t *input, uint8_t *output, int length) { uint8_t iiv[16] = {0}; @@ -416,10 +416,10 @@ int ecdsa_nist_test(bool verbose) { // NIST ecdsa test if (verbose) - printf(" ECDSA NIST test: "); + PrintAndLogEx(INFO, " ECDSA NIST test: " NOLF); // make signature res = ecdsa_signature_create_test(curveid, T_PRIVATE_KEY, T_Q_X, T_Q_Y, T_K, input, length, signature, &siglen); -// printf("res: %x signature[%x]: %s\n", (res<0)?-res:res, siglen, sprint_hex(signature, siglen)); +// PrintAndLogEx(INFO, "res: %x signature[%x]: %s", (res < 0)? -res : res, siglen, sprint_hex(signature, siglen)); if (res) goto exit; @@ -436,7 +436,7 @@ int ecdsa_nist_test(bool verbose) { uint8_t sval_s[33] = {0}; param_gethex_to_eol(T_S, 0, sval_s, sizeof(sval_s), &slen); if (strncmp((char *)rval, (char *)rval_s, 32) || strncmp((char *)sval, (char *)sval_s, 32)) { - printf("R or S check error\n"); + PrintAndLogEx(INFO, "R or S check error"); res = 100; goto exit; } @@ -449,14 +449,14 @@ int ecdsa_nist_test(bool verbose) { // verify wrong signature input[0] ^= 0xFF; res = ecdsa_signature_verify_keystr(curveid, T_Q_X, T_Q_Y, input, length, signature, siglen, true); - if (!res) { + if (res == false) { res = 1; goto exit; } if (verbose) { - printf("passed\n"); - printf(" ECDSA binary signature create/check test: "); + PrintAndLogEx(NORMAL, _GREEN_("passed")); + PrintAndLogEx(INFO, " ECDSA binary signature create/check test: " NOLF); } // random ecdsa test @@ -483,11 +483,11 @@ int ecdsa_nist_test(bool verbose) { goto exit; if (verbose) - printf("passed\n\n"); + PrintAndLogEx(NORMAL, _GREEN_("passed\n")); return 0; exit: if (verbose) - printf("failed\n\n"); + PrintAndLogEx(NORMAL, _RED_("failed\n")); return res; }