From 1e49bc2e824cb498762624b018afa1e105dde0f3 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Wed, 13 Jan 2021 13:55:06 -0600 Subject: [PATCH] asn.c/asn.h: fix --disable-ecc --enable-dsa. --- wolfcrypt/src/asn.c | 9 ++++++++- wolfssl/wolfcrypt/asn.h | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 12ada17af..3515b3cd0 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -2919,6 +2919,7 @@ int wc_CheckPrivateKey(const byte* privKey, word32 privKeySz, int ret; (void)privKeySz; (void)pubKeySz; + (void)ks; if (privKey == NULL || pubKey == NULL) { return BAD_FUNC_ARG; @@ -7293,7 +7294,6 @@ static int ConfirmSignature(SignatureCtx* sigCtx, case DSAk: { word32 idx = 0; - mp_int r, s; if (sigSz < DSA_SIG_SIZE) { WOLFSSL_MSG("Verify Signature is too small"); @@ -7316,7 +7316,9 @@ static int ConfirmSignature(SignatureCtx* sigCtx, goto exit_cs; } if (sigSz != DSA_SIG_SIZE) { + #ifdef HAVE_ECC /* Try to parse it as the contents of a bitstring */ + mp_int r, s; idx = 0; if (DecodeECC_DSA_Sig(sig + idx, sigSz - idx, &r, &s) != 0) { @@ -7335,6 +7337,11 @@ static int ConfirmSignature(SignatureCtx* sigCtx, } mp_free(&r); mp_free(&s); + #else + WOLFSSL_MSG("DSA Sig is in unrecognized or " + "incorrect format"); + ERROR_OUT(ASN_SIG_CONFIRM_E, exit_cs); + #endif } else { XMEMCPY(sigCtx->sigCpy, sig, DSA_SIG_SIZE); diff --git a/wolfssl/wolfcrypt/asn.h b/wolfssl/wolfcrypt/asn.h index 1537ccc7e..90350ea0e 100644 --- a/wolfssl/wolfcrypt/asn.h +++ b/wolfssl/wolfcrypt/asn.h @@ -682,7 +682,7 @@ struct SignatureCtx { #if !(defined(NO_RSA) && defined(NO_DSA)) byte* sigCpy; #endif -#if defined(HAVE_ECC) || defined(HAVE_ED25519) || defined(HAVE_ED448) +#if defined(HAVE_ECC) || defined(HAVE_ED25519) || defined(HAVE_ED448) || !defined(NO_DSA) int verify; #endif union {