forked from wolfSSL/wolfssl
Fixes from code review
This commit is contained in:
@@ -347,7 +347,8 @@ int Base64_Encode_NoNl(const byte* in, word32 inLen, byte* out, word32* outLen)
|
||||
#endif /* defined(WOLFSSL_BASE64_ENCODE) */
|
||||
|
||||
|
||||
#if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER) || defined(HAVE_FIPS)
|
||||
#if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER) || defined(HAVE_FIPS) \
|
||||
|| defined(HAVE_ECC_CDH)
|
||||
|
||||
static
|
||||
const byte hexDecode[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
||||
|
@@ -2591,10 +2591,8 @@ static int wc_ecc_shared_secret_gen_sync(ecc_key* private_key, ecc_point* point,
|
||||
k = &k_lcl;
|
||||
if (mp_init(k) != MP_OKAY)
|
||||
return MEMORY_E;
|
||||
/* multiple cofactor times private key "k" */
|
||||
err = mp_set_int(k, cofactor);
|
||||
if (err == MP_OKAY)
|
||||
err = mp_mul(k, &private_key->k, k);
|
||||
/* multiply cofactor times private key "k" */
|
||||
err = mp_mul_d(&private_key->k, cofactor, k);
|
||||
if (err != MP_OKAY) {
|
||||
mp_clear(k);
|
||||
return err;
|
||||
@@ -2606,6 +2604,7 @@ static int wc_ecc_shared_secret_gen_sync(ecc_key* private_key, ecc_point* point,
|
||||
/* make new point */
|
||||
result = wc_ecc_new_point_h(private_key->heap);
|
||||
if (result == NULL) {
|
||||
mp_clear(k);
|
||||
return MEMORY_E;
|
||||
}
|
||||
|
||||
|
@@ -2254,6 +2254,12 @@ int mp_mul (mp_int * a, mp_int * b, mp_int * c)
|
||||
return MP_OKAY;
|
||||
}
|
||||
|
||||
int mp_mul_d (mp_int * a, mp_digit b, mp_int * c)
|
||||
{
|
||||
fp_mul_d(a, b, c);
|
||||
return MP_OKAY;
|
||||
}
|
||||
|
||||
/* d = a * b (mod c) */
|
||||
int mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
|
||||
{
|
||||
|
@@ -8204,8 +8204,7 @@ static int ecc_test_cdh_vectors(void)
|
||||
int ret;
|
||||
ecc_key pub_key, priv_key;
|
||||
byte sharedA[32] = {0}, sharedB[32] = {0};
|
||||
word32 x;
|
||||
mp_int z;
|
||||
word32 x, z;
|
||||
|
||||
const char* QCAVSx = "700c48f77f56584c5cc632ca65640db91b6bacce3a4df6b42ce7cc838833d287";
|
||||
const char* QCAVSy = "db71e509e3fd9b060ddb20ba5c51dcc5948d46fbf640dfe0441782cab85fa4ac";
|
||||
@@ -8234,13 +8233,13 @@ static int ecc_test_cdh_vectors(void)
|
||||
}
|
||||
|
||||
/* read in expected Z */
|
||||
mp_init(&z);
|
||||
mp_read_radix(&z, ZIUT, 16);
|
||||
mp_to_unsigned_bin(&z, sharedB);
|
||||
mp_clear(&z);
|
||||
z = sizeof(sharedB);
|
||||
ret = Base16_Decode((const byte*)ZIUT, (word32)XSTRLEN(ZIUT), sharedB, &z);
|
||||
if (ret != 0)
|
||||
goto done;
|
||||
|
||||
/* compare results */
|
||||
if (XMEMCMP(sharedA, sharedB, x)) {
|
||||
if (x != z || XMEMCMP(sharedA, sharedB, x)) {
|
||||
ERROR_OUT(-1007, done);
|
||||
}
|
||||
|
||||
|
@@ -61,7 +61,8 @@ WOLFSSL_API int Base64_Decode(const byte* in, word32 inLen, byte* out,
|
||||
word32* outLen);
|
||||
#endif
|
||||
|
||||
#if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER) || defined(HAVE_FIPS)
|
||||
#if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER) || defined(HAVE_FIPS) \
|
||||
|| defined(HAVE_ECC_CDH)
|
||||
WOLFSSL_API
|
||||
int Base16_Decode(const byte* in, word32 inLen, byte* out, word32* outLen);
|
||||
WOLFSSL_API
|
||||
|
@@ -622,6 +622,7 @@ int mp_sub (mp_int * a, mp_int * b, mp_int * c);
|
||||
int mp_add_d (mp_int * a, mp_digit b, mp_int * c);
|
||||
|
||||
int mp_mul (mp_int * a, mp_int * b, mp_int * c);
|
||||
int mp_mul_d (mp_int * a, mp_digit b, mp_int * c);
|
||||
int mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d);
|
||||
int mp_submod (mp_int* a, mp_int* b, mp_int* c, mp_int* d);
|
||||
int mp_addmod (mp_int* a, mp_int* b, mp_int* c, mp_int* d);
|
||||
|
Reference in New Issue
Block a user