Merge pull request #2881 from dgarske/ecc_asn

Fixes for building ECC without ASN
pull/2895/head
toddouska 2020-04-07 13:09:37 -07:00 committed by GitHub
commit 77b75ef3a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 15 additions and 9 deletions

View File

@ -7319,7 +7319,6 @@ int wc_ecc_export_private_raw(ecc_key* key, byte* qx, word32* qxLen,
#endif /* HAVE_ECC_KEY_EXPORT */ #endif /* HAVE_ECC_KEY_EXPORT */
#ifndef NO_ASN
#ifdef HAVE_ECC_KEY_IMPORT #ifdef HAVE_ECC_KEY_IMPORT
/* import private key, public part optional if (pub) passed as NULL */ /* import private key, public part optional if (pub) passed as NULL */
int wc_ecc_import_private_key_ex(const byte* priv, word32 privSz, int wc_ecc_import_private_key_ex(const byte* priv, word32 privSz,
@ -7327,7 +7326,6 @@ int wc_ecc_import_private_key_ex(const byte* priv, word32 privSz,
int curve_id) int curve_id)
{ {
int ret; int ret;
word32 idx = 0;
#if defined(WOLFSSL_CRYPTOCELL) && !defined(WOLFSSL_ATECC508A) #if defined(WOLFSSL_CRYPTOCELL) && !defined(WOLFSSL_ATECC508A)
const CRYS_ECPKI_Domain_t* pDomain; const CRYS_ECPKI_Domain_t* pDomain;
CRYS_ECPKI_BUILD_TempData_t tempBuff; CRYS_ECPKI_BUILD_TempData_t tempBuff;
@ -7337,10 +7335,15 @@ int wc_ecc_import_private_key_ex(const byte* priv, word32 privSz,
/* public optional, NULL if only importing private */ /* public optional, NULL if only importing private */
if (pub != NULL) { if (pub != NULL) {
#ifndef NO_ASN
word32 idx = 0;
ret = wc_ecc_import_x963_ex(pub, pubSz, key, curve_id); ret = wc_ecc_import_x963_ex(pub, pubSz, key, curve_id);
if (ret < 0) if (ret < 0)
ret = wc_EccPublicKeyDecode(pub, &idx, key, pubSz); ret = wc_EccPublicKeyDecode(pub, &idx, key, pubSz);
key->type = ECC_PRIVATEKEY; key->type = ECC_PRIVATEKEY;
#else
ret = NOT_COMPILED_IN;
#endif
} }
else { else {
/* make sure required variables are reset */ /* make sure required variables are reset */
@ -7422,6 +7425,7 @@ int wc_ecc_import_private_key(const byte* priv, word32 privSz, const byte* pub,
} }
#endif /* HAVE_ECC_KEY_IMPORT */ #endif /* HAVE_ECC_KEY_IMPORT */
#ifndef NO_ASN
/** /**
Convert ECC R,S to signature Convert ECC R,S to signature
r R component of signature r R component of signature

View File

@ -252,7 +252,7 @@ int wc_SignatureVerify(
{ {
int ret; int ret;
word32 hash_len, hash_enc_len; word32 hash_len, hash_enc_len;
#ifdef WOLFSSL_SMALL_STACK #if defined(WOLFSSL_SMALL_STACK) || defined(NO_ASN)
byte *hash_data; byte *hash_data;
#else #else
byte hash_data[MAX_DER_DIGEST_SZ]; byte hash_data[MAX_DER_DIGEST_SZ];
@ -286,7 +286,7 @@ int wc_SignatureVerify(
} }
#endif #endif
#ifdef WOLFSSL_SMALL_STACK #if defined(WOLFSSL_SMALL_STACK) || defined(NO_ASN)
/* Allocate temporary buffer for hash data */ /* Allocate temporary buffer for hash data */
hash_data = (byte*)XMALLOC(hash_enc_len, NULL, DYNAMIC_TYPE_TMP_BUFFER); hash_data = (byte*)XMALLOC(hash_enc_len, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (hash_data == NULL) { if (hash_data == NULL) {
@ -328,7 +328,7 @@ int wc_SignatureVerify(
} }
} }
#ifdef WOLFSSL_SMALL_STACK #if defined(WOLFSSL_SMALL_STACK) || defined(NO_ASN)
XFREE(hash_data, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(hash_data, NULL, DYNAMIC_TYPE_TMP_BUFFER);
#endif #endif
@ -462,7 +462,7 @@ int wc_SignatureGenerate_ex(
{ {
int ret; int ret;
word32 hash_len, hash_enc_len; word32 hash_len, hash_enc_len;
#ifdef WOLFSSL_SMALL_STACK #if defined(WOLFSSL_SMALL_STACK) || defined(NO_ASN)
byte *hash_data; byte *hash_data;
#else #else
byte hash_data[MAX_DER_DIGEST_SZ]; byte hash_data[MAX_DER_DIGEST_SZ];
@ -496,7 +496,7 @@ int wc_SignatureGenerate_ex(
} }
#endif #endif
#ifdef WOLFSSL_SMALL_STACK #if defined(WOLFSSL_SMALL_STACK) || defined(NO_ASN)
/* Allocate temporary buffer for hash data */ /* Allocate temporary buffer for hash data */
hash_data = (byte*)XMALLOC(hash_enc_len, NULL, DYNAMIC_TYPE_TMP_BUFFER); hash_data = (byte*)XMALLOC(hash_enc_len, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (hash_data == NULL) { if (hash_data == NULL) {
@ -549,7 +549,7 @@ int wc_SignatureGenerate_ex(
} }
#endif /* WOLFSSL_CRYPTOCELL */ #endif /* WOLFSSL_CRYPTOCELL */
#ifdef WOLFSSL_SMALL_STACK #if defined(WOLFSSL_SMALL_STACK) || defined(NO_ASN)
XFREE(hash_data, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(hash_data, NULL, DYNAMIC_TYPE_TMP_BUFFER);
#endif #endif

View File

@ -10293,12 +10293,14 @@ byte GetEntropy(ENTROPY_CMD cmd, byte* out)
static const char* dsaKey = CERT_ROOT "dsa2048.der"; static const char* dsaKey = CERT_ROOT "dsa2048.der";
#endif #endif
#endif /* !USE_CERT_BUFFER_* */ #endif /* !USE_CERT_BUFFER_* */
#if !defined(USE_CERT_BUFFERS_256) && !defined(NO_ASN) #if !defined(USE_CERT_BUFFERS_256)
#ifdef HAVE_ECC #ifdef HAVE_ECC
/* cert files to be used in rsa cert gen test, check if RSA enabled */ /* cert files to be used in rsa cert gen test, check if RSA enabled */
#ifdef HAVE_ECC_KEY_IMPORT #ifdef HAVE_ECC_KEY_IMPORT
static const char* eccKeyDerFile = CERT_ROOT "ecc-key.der"; static const char* eccKeyDerFile = CERT_ROOT "ecc-key.der";
#endif #endif
#endif
#if !defined(USE_CERT_BUFFERS_256) && !defined(NO_ASN)
#ifdef WOLFSSL_CERT_GEN #ifdef WOLFSSL_CERT_GEN
#ifndef NO_RSA #ifndef NO_RSA
/* eccKeyPubFile is used in a test that requires RSA. */ /* eccKeyPubFile is used in a test that requires RSA. */

View File