no printf

This commit is contained in:
iceman1001 2020-08-29 15:03:56 +02:00
commit ab3e9983f8

View file

@ -24,8 +24,8 @@
#include <mbedtls/ctr_drbg.h> #include <mbedtls/ctr_drbg.h>
#include <mbedtls/entropy.h> #include <mbedtls/entropy.h>
#include <mbedtls/error.h> #include <mbedtls/error.h>
#include <util.h> #include "util.h"
#include "ui.h"
// NIST Special Publication 800-38A — Recommendation for block cipher modes of operation: methods and techniques, 2001. // 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) { int aes_encode(uint8_t *iv, uint8_t *key, uint8_t *input, uint8_t *output, int length) {
uint8_t iiv[16] = {0}; uint8_t iiv[16] = {0};
@ -416,10 +416,10 @@ int ecdsa_nist_test(bool verbose) {
// NIST ecdsa test // NIST ecdsa test
if (verbose) if (verbose)
printf(" ECDSA NIST test: "); PrintAndLogEx(INFO, " ECDSA NIST test: " NOLF);
// make signature // make signature
res = ecdsa_signature_create_test(curveid, T_PRIVATE_KEY, T_Q_X, T_Q_Y, T_K, input, length, signature, &siglen); 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) if (res)
goto exit; goto exit;
@ -436,7 +436,7 @@ int ecdsa_nist_test(bool verbose) {
uint8_t sval_s[33] = {0}; uint8_t sval_s[33] = {0};
param_gethex_to_eol(T_S, 0, sval_s, sizeof(sval_s), &slen); 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)) { 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; res = 100;
goto exit; goto exit;
} }
@ -449,14 +449,14 @@ int ecdsa_nist_test(bool verbose) {
// verify wrong signature // verify wrong signature
input[0] ^= 0xFF; input[0] ^= 0xFF;
res = ecdsa_signature_verify_keystr(curveid, T_Q_X, T_Q_Y, input, length, signature, siglen, true); res = ecdsa_signature_verify_keystr(curveid, T_Q_X, T_Q_Y, input, length, signature, siglen, true);
if (!res) { if (res == false) {
res = 1; res = 1;
goto exit; goto exit;
} }
if (verbose) { if (verbose) {
printf("passed\n"); PrintAndLogEx(NORMAL, _GREEN_("passed"));
printf(" ECDSA binary signature create/check test: "); PrintAndLogEx(INFO, " ECDSA binary signature create/check test: " NOLF);
} }
// random ecdsa test // random ecdsa test
@ -483,11 +483,11 @@ int ecdsa_nist_test(bool verbose) {
goto exit; goto exit;
if (verbose) if (verbose)
printf("passed\n\n"); PrintAndLogEx(NORMAL, _GREEN_("passed\n"));
return 0; return 0;
exit: exit:
if (verbose) if (verbose)
printf("failed\n\n"); PrintAndLogEx(NORMAL, _RED_("failed\n"));
return res; return res;
} }