mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 11:17:29 +02:00
liboqs: add RNG support for falcon
Added a RNG argument to the wc_falcon_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:
@ -8887,7 +8887,7 @@ static int SendTls13CertificateVerify(WOLFSSL* ssl)
|
|||||||
ret = wc_falcon_sign_msg(args->sigData, args->sigDataSz,
|
ret = wc_falcon_sign_msg(args->sigData, args->sigDataSz,
|
||||||
args->verify + HASH_SIG_SIZE +
|
args->verify + HASH_SIG_SIZE +
|
||||||
VERIFY_HEADER, (word32*)&sig->length,
|
VERIFY_HEADER, (word32*)&sig->length,
|
||||||
(falcon_key*)ssl->hsKey);
|
(falcon_key*)ssl->hsKey, ssl->rng);
|
||||||
args->length = (word16)sig->length;
|
args->length = (word16)sig->length;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -11788,7 +11788,7 @@ void bench_falconKeySign(byte level)
|
|||||||
x = FALCON_LEVEL5_SIG_SIZE;
|
x = FALCON_LEVEL5_SIG_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = wc_falcon_sign_msg(msg, sizeof(msg), sig, &x, &key);
|
ret = wc_falcon_sign_msg(msg, sizeof(msg), sig, &x, &key, GLOBAL_RNG);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
printf("wc_falcon_sign_msg failed\n");
|
printf("wc_falcon_sign_msg failed\n");
|
||||||
}
|
}
|
||||||
|
@ -28897,7 +28897,7 @@ static int MakeSignature(CertSignCtx* certSignCtx, const byte* buf, word32 sz,
|
|||||||
#if defined(HAVE_FALCON)
|
#if defined(HAVE_FALCON)
|
||||||
if (!rsaKey && !eccKey && !ed25519Key && !ed448Key && falconKey) {
|
if (!rsaKey && !eccKey && !ed25519Key && !ed448Key && falconKey) {
|
||||||
word32 outSz = sigSz;
|
word32 outSz = sigSz;
|
||||||
ret = wc_falcon_sign_msg(buf, sz, sig, &outSz, falconKey);
|
ret = wc_falcon_sign_msg(buf, sz, sig, &outSz, falconKey, rng);
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
ret = outSz;
|
ret = outSz;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
*/
|
*/
|
||||||
int wc_falcon_sign_msg(const byte* in, word32 inLen,
|
int wc_falcon_sign_msg(const byte* in, word32 inLen,
|
||||||
byte* out, word32 *outLen,
|
byte* out, word32 *outLen,
|
||||||
falcon_key* key)
|
falcon_key* key, WC_RNG* rng)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
#ifdef HAVE_LIBOQS
|
#ifdef HAVE_LIBOQS
|
||||||
@ -101,6 +101,10 @@ int wc_falcon_sign_msg(const byte* in, word32 inLen,
|
|||||||
localOutLen = *outLen;
|
localOutLen = *outLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ret == 0) {
|
||||||
|
ret = wolfSSL_liboqsRngMutexLock(rng);
|
||||||
|
}
|
||||||
|
|
||||||
if ((ret == 0) &&
|
if ((ret == 0) &&
|
||||||
(OQS_SIG_sign(oqssig, out, &localOutLen, in, inLen, key->k)
|
(OQS_SIG_sign(oqssig, out, &localOutLen, in, inLen, key->k)
|
||||||
== OQS_ERROR)) {
|
== OQS_ERROR)) {
|
||||||
@ -111,6 +115,8 @@ int wc_falcon_sign_msg(const byte* in, word32 inLen,
|
|||||||
*outLen = (word32)localOutLen;
|
*outLen = (word32)localOutLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wolfSSL_liboqsRngMutexUnlock();
|
||||||
|
|
||||||
if (oqssig != NULL) {
|
if (oqssig != NULL) {
|
||||||
OQS_SIG_free(oqssig);
|
OQS_SIG_free(oqssig);
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
#ifdef HAVE_LIBOQS
|
#ifdef HAVE_LIBOQS
|
||||||
#include <oqs/oqs.h>
|
#include <oqs/oqs.h>
|
||||||
|
#include <wolfssl/wolfcrypt/port/liboqs/liboqs.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -79,7 +80,7 @@ struct falcon_key {
|
|||||||
|
|
||||||
WOLFSSL_API
|
WOLFSSL_API
|
||||||
int wc_falcon_sign_msg(const byte* in, word32 inLen, byte* out, word32 *outLen,
|
int wc_falcon_sign_msg(const byte* in, word32 inLen, byte* out, word32 *outLen,
|
||||||
falcon_key* key);
|
falcon_key* key, WC_RNG* rng);
|
||||||
WOLFSSL_API
|
WOLFSSL_API
|
||||||
int wc_falcon_verify_msg(const byte* sig, word32 sigLen, const byte* msg,
|
int wc_falcon_verify_msg(const byte* sig, word32 sigLen, const byte* msg,
|
||||||
word32 msgLen, int* res, falcon_key* key);
|
word32 msgLen, int* res, falcon_key* key);
|
||||||
|
Reference in New Issue
Block a user