Fix for DH so software math is used if prime is under 768 bits.

This commit is contained in:
David Garske
2017-06-09 13:02:19 -07:00
parent b778ddfea2
commit a77f9fe3e6

View File

@@ -654,6 +654,12 @@ static int wc_DhGenerateKeyPair_Async(DhKey* key, WC_RNG* rng,
int ret;
#if defined(HAVE_INTEL_QA)
word32 sz;
/* verify prime is at least 768-bits */
/* QAT HW must have prime at least 768-bits */
sz = mp_unsigned_bin_size(&key->p);
if (sz >= (768/8)) {
mp_int x;
ret = mp_init(&x);
@@ -674,9 +680,10 @@ static int wc_DhGenerateKeyPair_Async(DhKey* key, WC_RNG* rng,
&x.raw, pub, pubSz);
mp_clear(&x);
#else
return ret;
}
#if defined(HAVE_CAVIUM)
#elif defined(HAVE_CAVIUM)
/* TODO: Not implemented - use software for now */
#else /* WOLFSSL_ASYNC_CRYPT_TEST */
@@ -693,11 +700,8 @@ static int wc_DhGenerateKeyPair_Async(DhKey* key, WC_RNG* rng,
}
#endif
ret = wc_DhGenerateKeyPair_Sync(key, rng, priv, privSz, pub, pubSz);
#endif /* HAVE_INTEL_QA */
return ret;
/* otherwise use software DH */
return wc_DhGenerateKeyPair_Sync(key, rng, priv, privSz, pub, pubSz);
}
#endif /* WOLFSSL_ASYNC_CRYPT && WC_ASYNC_ENABLE_DH */