diff --git a/client/src/cmdhffido.c b/client/src/cmdhffido.c index e196c2681..7535a5ef4 100644 --- a/client/src/cmdhffido.c +++ b/client/src/cmdhffido.c @@ -340,7 +340,7 @@ static int cmd_hf_fido_register(const char *cmd) { uint8_t rval[300] = {0}; uint8_t sval[300] = {0}; res = ecdsa_asn1_get_signature(&buf[hashp], len - hashp, rval, sval); - if (!res) { + if (res == PM3_SUCCESS) { if (verbose) { PrintAndLogEx(INFO, " r: %s", sprint_hex(rval, 32)); PrintAndLogEx(INFO, " s: %s", sprint_hex(sval, 32)); @@ -583,7 +583,7 @@ static int cmd_hf_fido_authenticate(const char *cmd) { uint8_t rval[300] = {0}; uint8_t sval[300] = {0}; res = ecdsa_asn1_get_signature(&buf[5], len - 5, rval, sval); - if (!res) { + if (res == PM3_SUCCESS) { if (verbose) { PrintAndLogEx(INFO, " r: %s", sprint_hex(rval, 32)); PrintAndLogEx(INFO, " s: %s", sprint_hex(sval, 32)); diff --git a/client/src/crypto/asn1utils.c b/client/src/crypto/asn1utils.c index eede8ef0d..40db00425 100644 --- a/client/src/crypto/asn1utils.c +++ b/client/src/crypto/asn1utils.c @@ -12,18 +12,16 @@ #include #include #include - #include "ui.h" // Print... - #include "emv/tlv.h" #include "asn1dump.h" #include "util.h" int ecdsa_asn1_get_signature(uint8_t *signature, size_t signaturelen, uint8_t *rval, uint8_t *sval) { if (!signature || !signaturelen || !rval || !sval) - return 1; + return PM3_EINVARG; - int res = 0; + int res = PM3_SUCCESS; unsigned char *p = signature; const unsigned char *end = p + signaturelen; size_t len; @@ -56,7 +54,7 @@ int ecdsa_asn1_get_signature(uint8_t *signature, size_t signaturelen, uint8_t *r // check size if (end != p) - return 2; + return PM3_ESOFT; } exit: @@ -79,10 +77,10 @@ int asn1_print(uint8_t *asn1buf, size_t asn1buflen, const char *indent) { tlvdb_free(t); } else { PrintAndLogEx(ERR, "Can't parse data as TLV tree"); - return 1; + return PM3_ESOFT; } - return 0; + return PM3_SUCCESS; } diff --git a/client/src/crypto/libpcrypto.c b/client/src/crypto/libpcrypto.c index 3d8e7ffc4..cb73b3f5c 100644 --- a/client/src/crypto/libpcrypto.c +++ b/client/src/crypto/libpcrypto.c @@ -418,7 +418,7 @@ int ecdsa_nist_test(bool verbose) { // make signature res = ecdsa_signature_create_test(curveid, T_PRIVATE_KEY, T_Q_X, T_Q_Y, T_K, input, length, signature, &siglen); // PrintAndLogEx(INFO, "res: %x signature[%x]: %s", (res < 0)? -res : res, siglen, sprint_hex(signature, siglen)); - if (res) + if (res != PM3_SUCCESS) goto exit; // check vectors @@ -483,7 +483,7 @@ int ecdsa_nist_test(bool verbose) { if (verbose) PrintAndLogEx(NORMAL, _GREEN_("passed\n")); - return 0; + return PM3_SUCCESS; exit: if (verbose) PrintAndLogEx(NORMAL, _RED_("failed\n")); diff --git a/client/src/emv/cmdemv.c b/client/src/emv/cmdemv.c index fa1e9618a..494956c51 100644 --- a/client/src/emv/cmdemv.c +++ b/client/src/emv/cmdemv.c @@ -1356,10 +1356,10 @@ static int CmdEMVExec(const char *Cmd) { // here must be AC2, but we dont make external authenticate ( /* // AC2 PRINT_INDENT(level); - if ((CID & EMVAC_AC2_MASK) == EMVAC_AAC2) fprintf(f, "\tAC2: AAC (Transaction declined)\n"); - if ((CID & EMVAC_AC2_MASK) == EMVAC_TC2) fprintf(f, "\tAC2: TC (Transaction approved)\n"); - if ((CID & EMVAC_AC2_MASK) == EMVAC_ARQC2) fprintf(f, "\tAC2: not requested (ARQC)\n"); - if ((CID & EMVAC_AC2_MASK) == EMVAC_AC2_MASK) fprintf(f, "\tAC2: RFU\n"); + if ((CID & EMVAC_AC2_MASK) == EMVAC_AAC2) PrintAndLogEx(NORMAL, "\tAC2: AAC (Transaction declined)"); + if ((CID & EMVAC_AC2_MASK) == EMVAC_TC2) PrintAndLogEx(NORMAL, "\tAC2: TC (Transaction approved)"); + if ((CID & EMVAC_AC2_MASK) == EMVAC_ARQC2) PrintAndLogEx(NORMAL, "\tAC2: not requested (ARQC)"); + if ((CID & EMVAC_AC2_MASK) == EMVAC_AC2_MASK) PrintAndLogEx(NORMAL, "\tAC2: RFU"); */ } } diff --git a/client/src/fido/fidocore.c b/client/src/fido/fidocore.c index d355779fe..abe3f28ce 100644 --- a/client/src/fido/fidocore.c +++ b/client/src/fido/fidocore.c @@ -363,7 +363,7 @@ static int FIDO2CheckSignature(json_t *root, uint8_t *publickey, uint8_t *sign, uint8_t sval[300] = {0}; int res = ecdsa_asn1_get_signature(sign, signLen, rval, sval); - if (!res) { + if (res == PM3_SUCCESS) { if (verbose) { PrintAndLogEx(INFO, " r: %s", sprint_hex(rval, 32)); PrintAndLogEx(INFO, " s: %s", sprint_hex(sval, 32)); diff --git a/client/src/mifare/ndef.c b/client/src/mifare/ndef.c index 2839933e1..bd1109e80 100644 --- a/client/src/mifare/ndef.c +++ b/client/src/mifare/ndef.c @@ -180,7 +180,7 @@ static int ndefDecodeSig1(uint8_t *sig, size_t siglen) { uint8_t rval[300] = {0}; uint8_t sval[300] = {0}; int res = ecdsa_asn1_get_signature(&sig[indx], intsiglen, rval, sval); - if (!res) { + if (res == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "\t\tr: %s", sprint_hex(rval + 32 - slen, slen)); PrintAndLogEx(SUCCESS, "\t\ts: %s", sprint_hex(sval + 32 - slen, slen)); }