From f66aa60385edbf5e7c6c70cac6ff24a50f93fba0 Mon Sep 17 00:00:00 2001 From: David Garske Date: Mon, 18 Mar 2019 11:43:32 -0700 Subject: [PATCH] Fix for build warning with x/y always true when not building with ALT_ECC_SIZE. Fix for build error with undefined `wc_ecc_sign_hash_ex` when building ATECC and `WOLFSSL_PUBLIC_MP`. --- tests/api.c | 2 +- wolfcrypt/src/ecc.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/api.c b/tests/api.c index 0a363c167..89dc3e5e1 100644 --- a/tests/api.c +++ b/tests/api.c @@ -14924,7 +14924,7 @@ static int test_wc_ecc_verify_hash_ex (void) int ret = 0; #if defined(HAVE_ECC) && defined(HAVE_ECC_SIGN) && defined(WOLFSSL_PUBLIC_MP) \ - && !defined(WC_NO_RNG) + && !defined(WC_NO_RNG) && !defined(WOLFSSL_ATECC508A) ecc_key key; WC_RNG rng; mp_int r; diff --git a/wolfcrypt/src/ecc.c b/wolfcrypt/src/ecc.c index 4534dbfec..4cec168df 100644 --- a/wolfcrypt/src/ecc.c +++ b/wolfcrypt/src/ecc.c @@ -3979,11 +3979,19 @@ int wc_ecc_make_key_ex(WC_RNG* rng, int keysize, ecc_key* key, int curve_id) err = atmel_ecc_create_key(key->slot, key->pubkey_raw); /* populate key->pubkey */ - if (err == 0 && key->pubkey.x) { + if (err == 0 + #ifdef ALT_ECC_SIZE + && key->pubkey.x + #endif + ) { err = mp_read_unsigned_bin(key->pubkey.x, key->pubkey_raw, ECC_MAX_CRYPTO_HW_SIZE); } - if (err == 0 && key->pubkey.y) { + if (err == 0 + #ifdef ALT_ECC_SIZE + && key->pubkey.y + #endif + ) { err = mp_read_unsigned_bin(key->pubkey.y, key->pubkey_raw + ECC_MAX_CRYPTO_HW_SIZE, ECC_MAX_CRYPTO_HW_SIZE);