mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-07-10 06:10:49 +02:00
liboqs: add RNG support for dilithium
Added a RNG argument to the wc_dilithium_sign_msg method to properly generate necessary random data using the desired WolfSSL RNG object. Signed-off-by: Tobias Frauenschläger <t.frauenschlaeger@me.com>
This commit is contained in:
+1
-1
@@ -28906,7 +28906,7 @@ static int MakeSignature(CertSignCtx* certSignCtx, const byte* buf, word32 sz,
|
||||
if (!rsaKey && !eccKey && !ed25519Key && !ed448Key && !falconKey &&
|
||||
dilithiumKey) {
|
||||
word32 outSz = sigSz;
|
||||
ret = wc_dilithium_sign_msg(buf, sz, sig, &outSz, dilithiumKey);
|
||||
ret = wc_dilithium_sign_msg(buf, sz, sig, &outSz, dilithiumKey, rng);
|
||||
if (ret == 0)
|
||||
ret = outSz;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
*/
|
||||
int wc_dilithium_sign_msg(const byte* in, word32 inLen,
|
||||
byte* out, word32 *outLen,
|
||||
dilithium_key* key)
|
||||
dilithium_key* key, WC_RNG* rng)
|
||||
{
|
||||
int ret = 0;
|
||||
#ifdef HAVE_LIBOQS
|
||||
@@ -107,6 +107,10 @@ int wc_dilithium_sign_msg(const byte* in, word32 inLen,
|
||||
localOutLen = *outLen;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
ret = wolfSSL_liboqsRngMutexLock(rng);
|
||||
}
|
||||
|
||||
if ((ret == 0) &&
|
||||
(OQS_SIG_sign(oqssig, out, &localOutLen, in, inLen, key->k)
|
||||
== OQS_ERROR)) {
|
||||
@@ -117,6 +121,8 @@ int wc_dilithium_sign_msg(const byte* in, word32 inLen,
|
||||
*outLen = (word32)localOutLen;
|
||||
}
|
||||
|
||||
wolfSSL_liboqsRngMutexUnlock();
|
||||
|
||||
if (oqssig != NULL) {
|
||||
OQS_SIG_free(oqssig);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user