diff --git a/src/ssl.c b/src/ssl.c index feb86736c..7f861db21 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -11750,7 +11750,6 @@ int wolfSSL_BN_print_fp(FILE *fp, const WOLFSSL_BIGNUM *bn) #endif /* defined(WOLFSSL_KEY_GEN) || defined(HAVE_COMP_KEY) */ - WOLFSSL_BIGNUM *wolfSSL_BN_CTX_get(WOLFSSL_BN_CTX *ctx) { /* ctx is not used, return new Bignum */ @@ -14275,8 +14274,6 @@ int wolfSSL_EC_GROUP_get_degree(const WOLFSSL_EC_GROUP *group) return SSL_FAILURE; break; } - - return SSL_FAILURE; } /* return code compliant with OpenSSL : @@ -14451,11 +14448,11 @@ int wolfSSL_EC_POINT_mul(const WOLFSSL_EC_GROUP *group, WOLFSSL_EC_POINT *r, const WOLFSSL_BIGNUM *n, const WOLFSSL_EC_POINT *q, const WOLFSSL_BIGNUM *m, WOLFSSL_BN_CTX *ctx) { + mp_int prime; + (void)ctx; (void)n; - mp_int prime; - WOLFSSL_ENTER("wolfSSL_EC_POINT_mul"); if (group == NULL || r == NULL || r->internal == NULL || @@ -14517,8 +14514,9 @@ int wolfSSL_EC_POINT_cmp(const WOLFSSL_EC_GROUP *group, const WOLFSSL_EC_POINT *a, const WOLFSSL_EC_POINT *b, WOLFSSL_BN_CTX *ctx) { - (void)ctx; int ret; + + (void)ctx; WOLFSSL_ENTER("wolfSSL_EC_POINT_cmp"); @@ -14778,7 +14776,9 @@ int wolfSSL_ECDH_compute_key(void *out, size_t outlen, word32 len; (void)KDF; - WOLFSSL_ENTER("wolfSSL_ECDH_compute_key"); + (void)KDF; + + WOLFSSL_ENTER("wolfSSL_ECDH_compute_key"); if (out == NULL || pub_key == NULL || pub_key->internal == NULL || ecdh == NULL || ecdh->internal == NULL) { diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 90edfc77c..c1a023a6b 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -2749,7 +2749,7 @@ WOLFSSL_LOCAL word32 SetExplicit(byte number, word32 len, byte* output) #if defined(HAVE_ECC) && (defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_KEY_GEN)) -static word32 SetCurve(ecc_key* key, byte* output) +static int SetCurve(ecc_key* key, byte* output) { /* curve types */ diff --git a/wolfcrypt/src/ecc.c b/wolfcrypt/src/ecc.c old mode 100644 new mode 100755 index f9b82f220..a14a9e08d --- a/wolfcrypt/src/ecc.c +++ b/wolfcrypt/src/ecc.c @@ -2597,26 +2597,25 @@ int wc_ecc_export_point_der(const int curve_idx, ecc_point* point, byte* out, return MEMORY_E; #endif - do { - /* pad and store x */ - XMEMSET(buf, 0, ECC_BUFSIZE); - ret = mp_to_unsigned_bin(point->x, buf + + /* pad and store x */ + XMEMSET(buf, 0, ECC_BUFSIZE); + ret = mp_to_unsigned_bin(point->x, buf + (numlen - mp_unsigned_bin_size(point->x))); - if (ret != MP_OKAY) - break; - XMEMCPY(out+1, buf, numlen); + if (ret != MP_OKAY) + goto done; + XMEMCPY(out+1, buf, numlen); - /* pad and store y */ - XMEMSET(buf, 0, ECC_BUFSIZE); - ret = mp_to_unsigned_bin(point->y, buf + + /* pad and store y */ + XMEMSET(buf, 0, ECC_BUFSIZE); + ret = mp_to_unsigned_bin(point->y, buf + (numlen - mp_unsigned_bin_size(point->y))); - if (ret != MP_OKAY) - break; - XMEMCPY(out+1+numlen, buf, numlen); + if (ret != MP_OKAY) + goto done; + XMEMCPY(out+1+numlen, buf, numlen); - *outLen = 1 + 2*numlen; - } while (0); + *outLen = 1 + 2*numlen; +done: #ifdef WOLFSSL_SMALL_STACK XFREE(buf, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -2665,26 +2664,25 @@ int wc_ecc_export_x963(ecc_key* key, byte* out, word32* outLen) return MEMORY_E; #endif - do { - /* pad and store x */ - XMEMSET(buf, 0, ECC_BUFSIZE); - ret = mp_to_unsigned_bin(key->pubkey.x, + /* pad and store x */ + XMEMSET(buf, 0, ECC_BUFSIZE); + ret = mp_to_unsigned_bin(key->pubkey.x, buf + (numlen - mp_unsigned_bin_size(key->pubkey.x))); - if (ret != MP_OKAY) - break; - XMEMCPY(out+1, buf, numlen); + if (ret != MP_OKAY) + goto done; + XMEMCPY(out+1, buf, numlen); - /* pad and store y */ - XMEMSET(buf, 0, ECC_BUFSIZE); - ret = mp_to_unsigned_bin(key->pubkey.y, + /* pad and store y */ + XMEMSET(buf, 0, ECC_BUFSIZE); + ret = mp_to_unsigned_bin(key->pubkey.y, buf + (numlen - mp_unsigned_bin_size(key->pubkey.y))); - if (ret != MP_OKAY) - break; - XMEMCPY(out+1+numlen, buf, numlen); + if (ret != MP_OKAY) + goto done; + XMEMCPY(out+1+numlen, buf, numlen); - *outLen = 1 + 2*numlen; - } while (0); + *outLen = 1 + 2*numlen; +done: #ifdef WOLFSSL_SMALL_STACK XFREE(buf, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif diff --git a/wolfssl/wolfcrypt/tfm.h b/wolfssl/wolfcrypt/tfm.h index 782dc7046..157d58da4 100644 --- a/wolfssl/wolfcrypt/tfm.h +++ b/wolfssl/wolfcrypt/tfm.h @@ -258,10 +258,10 @@ #define FP_NEG 1 /* return codes */ -#define FP_OKAY 0 -#define FP_VAL 1 -#define FP_MEM 2 -#define FP_NOT_INF 3 +#define FP_OKAY 0 +#define FP_VAL -1 +#define FP_MEM -2 +#define FP_NOT_INF -3 /* equalities */ #define FP_LT -1 /* less than */