forked from wolfSSL/wolfssl
Merge pull request #3585 from dgarske/async_rel
Fixes in preparation for release
This commit is contained in:
@@ -3920,7 +3920,10 @@ static int wc_ecc_shared_secret_gen_async(ecc_key* private_key,
|
|||||||
int err;
|
int err;
|
||||||
|
|
||||||
#if defined(HAVE_CAVIUM_V) || defined(HAVE_INTEL_QA)
|
#if defined(HAVE_CAVIUM_V) || defined(HAVE_INTEL_QA)
|
||||||
if (private_key->dp && private_key->dp->id != ECC_CURVE_CUSTOM
|
if (private_key->dp
|
||||||
|
#ifdef WOLFSSL_CUSTOM_CURVES
|
||||||
|
&& private_key->dp->id != ECC_CURVE_CUSTOM
|
||||||
|
#endif
|
||||||
#ifdef HAVE_CAVIUM_V
|
#ifdef HAVE_CAVIUM_V
|
||||||
/* verify the curve is supported by hardware */
|
/* verify the curve is supported by hardware */
|
||||||
&& NitroxEccIsCurveSupported(private_key)
|
&& NitroxEccIsCurveSupported(private_key)
|
||||||
@@ -5573,31 +5576,31 @@ int wc_ecc_sign_hash_ex(const byte* in, word32 inlen, WC_RNG* rng,
|
|||||||
#ifdef WOLFSSL_ECDSA_SET_K
|
#ifdef WOLFSSL_ECDSA_SET_K
|
||||||
int wc_ecc_sign_set_k(const byte* k, word32 klen, ecc_key* key)
|
int wc_ecc_sign_set_k(const byte* k, word32 klen, ecc_key* key)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret;
|
||||||
DECLARE_CURVE_SPECS(curve, 1);
|
DECLARE_CURVE_SPECS(curve, 1);
|
||||||
|
|
||||||
if (k == NULL || klen == 0 || key == NULL) {
|
if (k == NULL || klen == 0 || key == NULL) {
|
||||||
ret = BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == 0) {
|
ALLOC_CURVE_SPECS(1);
|
||||||
ALLOC_CURVE_SPECS(1);
|
ret = wc_ecc_curve_load(key->dp, &curve, ECC_CURVE_FIELD_ORDER);
|
||||||
ret = wc_ecc_curve_load(key->dp, &curve, ECC_CURVE_FIELD_ORDER);
|
if (ret != 0) {
|
||||||
|
FREE_CURVE_SPECS();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == 0) {
|
if (key->sign_k == NULL) {
|
||||||
if (key->sign_k == NULL) {
|
key->sign_k = (mp_int*)XMALLOC(sizeof(mp_int), key->heap,
|
||||||
key->sign_k = (mp_int*)XMALLOC(sizeof(mp_int), key->heap,
|
DYNAMIC_TYPE_ECC);
|
||||||
DYNAMIC_TYPE_ECC);
|
if (key->sign_k) {
|
||||||
if (key->sign_k == NULL) {
|
ret = mp_init(key->sign_k);
|
||||||
ret = MEMORY_E;
|
}
|
||||||
}
|
else {
|
||||||
|
ret = MEMORY_E;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == 0) {
|
|
||||||
ret = mp_init(key->sign_k);
|
|
||||||
}
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = mp_read_unsigned_bin(key->sign_k, k, klen);
|
ret = mp_read_unsigned_bin(key->sign_k, k, klen);
|
||||||
}
|
}
|
||||||
@@ -5605,11 +5608,12 @@ int wc_ecc_sign_set_k(const byte* k, word32 klen, ecc_key* key)
|
|||||||
ret = MP_VAL;
|
ret = MP_VAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wc_ecc_curve_free(curve);
|
||||||
FREE_CURVE_SPECS();
|
FREE_CURVE_SPECS();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif /* WOLFSSL_ECDSA_SET_K */
|
#endif /* WOLFSSL_ECDSA_SET_K */
|
||||||
#endif /* WOLFSSL_ATECC508A && WOLFSSL_CRYPTOCELL*/
|
#endif /* WOLFSSL_ATECC508A && WOLFSSL_CRYPTOCELL */
|
||||||
|
|
||||||
#endif /* !HAVE_ECC_SIGN */
|
#endif /* !HAVE_ECC_SIGN */
|
||||||
|
|
||||||
|
@@ -5256,7 +5256,10 @@ int mp_radix_size (mp_int *a, int radix, int *size)
|
|||||||
|
|
||||||
/* special case for binary */
|
/* special case for binary */
|
||||||
if (radix == MP_RADIX_BIN) {
|
if (radix == MP_RADIX_BIN) {
|
||||||
*size = mp_count_bits (a) + (a->sign == MP_NEG ? 1 : 0) + 1;
|
*size = mp_count_bits(a);
|
||||||
|
if (*size == 0)
|
||||||
|
*size = 1;
|
||||||
|
*size += (a->sign == MP_NEG ? 1 : 0) + 1; /* "-" sign + null term */
|
||||||
return MP_OKAY;
|
return MP_OKAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1779,6 +1779,8 @@ int wc_RsaUnPad_ex(byte* pkcsBlock, word32 pkcsBlockLen, byte** out,
|
|||||||
int wc_hash2mgf(enum wc_HashType hType)
|
int wc_hash2mgf(enum wc_HashType hType)
|
||||||
{
|
{
|
||||||
switch (hType) {
|
switch (hType) {
|
||||||
|
case WC_HASH_TYPE_NONE:
|
||||||
|
return WC_MGF1NONE;
|
||||||
case WC_HASH_TYPE_SHA:
|
case WC_HASH_TYPE_SHA:
|
||||||
#ifndef NO_SHA
|
#ifndef NO_SHA
|
||||||
return WC_MGF1SHA1;
|
return WC_MGF1SHA1;
|
||||||
@@ -1809,7 +1811,6 @@ int wc_hash2mgf(enum wc_HashType hType)
|
|||||||
#else
|
#else
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case WC_HASH_TYPE_NONE:
|
|
||||||
case WC_HASH_TYPE_MD2:
|
case WC_HASH_TYPE_MD2:
|
||||||
case WC_HASH_TYPE_MD4:
|
case WC_HASH_TYPE_MD4:
|
||||||
case WC_HASH_TYPE_MD5:
|
case WC_HASH_TYPE_MD5:
|
||||||
|
@@ -5550,8 +5550,11 @@ int mp_radix_size (mp_int *a, int radix, int *size)
|
|||||||
|
|
||||||
/* special case for binary */
|
/* special case for binary */
|
||||||
if (radix == 2) {
|
if (radix == 2) {
|
||||||
*size = fp_count_bits (a) + (a->sign == FP_NEG ? 1 : 0) + 1;
|
*size = fp_count_bits(a);
|
||||||
return FP_YES;
|
if (*size == 0)
|
||||||
|
*size = 1;
|
||||||
|
*size += (a->sign == FP_NEG ? 1 : 0) + 1; /* "-" sign + null term */
|
||||||
|
return FP_OKAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make sure the radix is in range */
|
/* make sure the radix is in range */
|
||||||
|
Reference in New Issue
Block a user