diff --git a/crypto_kem/ledakemlt12/clean/rng.c b/crypto_kem/ledakemlt12/clean/rng.c index 490e7c09..913b9e67 100644 --- a/crypto_kem/ledakemlt12/clean/rng.c +++ b/crypto_kem/ledakemlt12/clean/rng.c @@ -12,13 +12,10 @@ diversifier - an 8 byte diversifier maxlen - maximum number of bytes (less than 2**32) generated under this seed and diversifier */ -static int seedexpander_init(AES_XOF_struct *ctx, - unsigned char *seed, - unsigned char *diversifier, - size_t maxlen) { - if ( maxlen >= 0x100000000 ) { - return RNG_BAD_MAXLEN; - } +static void seedexpander_init(AES_XOF_struct *ctx, + unsigned char *seed, + unsigned char *diversifier, + size_t maxlen) { ctx->length_remaining = maxlen; @@ -38,8 +35,6 @@ static int seedexpander_init(AES_XOF_struct *ctx, ctx->buffer_pos = 16; memset(ctx->buffer, 0x00, 16); - - return RNG_SUCCESS; } void PQCLEAN_LEDAKEMLT12_CLEAN_seedexpander_from_trng(AES_XOF_struct *ctx, @@ -57,7 +52,7 @@ void PQCLEAN_LEDAKEMLT12_CLEAN_seedexpander_from_trng(AES_XOF_struct *ctx, /* the required seed expansion will be quite small, set the max number of * bytes conservatively to 10 MiB*/ - seedexpander_init(ctx, prng_buffer, diversifier, 10 * 1024 * 1024); + seedexpander_init(ctx, prng_buffer, diversifier, RNG_MAXLEN); } /* diff --git a/crypto_kem/ledakemlt12/clean/rng.h b/crypto_kem/ledakemlt12/clean/rng.h index 7638f216..204e8f7b 100644 --- a/crypto_kem/ledakemlt12/clean/rng.h +++ b/crypto_kem/ledakemlt12/clean/rng.h @@ -8,6 +8,7 @@ #define RNG_BAD_MAXLEN (-1) #define RNG_BAD_OUTBUF (-2) #define RNG_BAD_REQ_LEN (-3) +#define RNG_MAXLEN (10 * 1024 * 1024) typedef struct { unsigned char buffer[16]; diff --git a/crypto_kem/ledakemlt32/clean/rng.c b/crypto_kem/ledakemlt32/clean/rng.c index 336c65e3..b0757cee 100644 --- a/crypto_kem/ledakemlt32/clean/rng.c +++ b/crypto_kem/ledakemlt32/clean/rng.c @@ -12,13 +12,10 @@ diversifier - an 8 byte diversifier maxlen - maximum number of bytes (less than 2**32) generated under this seed and diversifier */ -static int seedexpander_init(AES_XOF_struct *ctx, - unsigned char *seed, - unsigned char *diversifier, - size_t maxlen) { - if ( maxlen >= 0x100000000 ) { - return RNG_BAD_MAXLEN; - } +static void seedexpander_init(AES_XOF_struct *ctx, + unsigned char *seed, + unsigned char *diversifier, + size_t maxlen) { ctx->length_remaining = maxlen; @@ -38,8 +35,6 @@ static int seedexpander_init(AES_XOF_struct *ctx, ctx->buffer_pos = 16; memset(ctx->buffer, 0x00, 16); - - return RNG_SUCCESS; } void PQCLEAN_LEDAKEMLT32_CLEAN_seedexpander_from_trng(AES_XOF_struct *ctx, @@ -57,7 +52,7 @@ void PQCLEAN_LEDAKEMLT32_CLEAN_seedexpander_from_trng(AES_XOF_struct *ctx, /* the required seed expansion will be quite small, set the max number of * bytes conservatively to 10 MiB*/ - seedexpander_init(ctx, prng_buffer, diversifier, 10 * 1024 * 1024); + seedexpander_init(ctx, prng_buffer, diversifier, RNG_MAXLEN); } /* diff --git a/crypto_kem/ledakemlt32/clean/rng.h b/crypto_kem/ledakemlt32/clean/rng.h index c50b6daf..8d7ee8c4 100644 --- a/crypto_kem/ledakemlt32/clean/rng.h +++ b/crypto_kem/ledakemlt32/clean/rng.h @@ -8,6 +8,7 @@ #define RNG_BAD_MAXLEN (-1) #define RNG_BAD_OUTBUF (-2) #define RNG_BAD_REQ_LEN (-3) +#define RNG_MAXLEN (10 * 1024 * 1024) typedef struct { unsigned char buffer[16]; diff --git a/crypto_kem/ledakemlt52/clean/rng.c b/crypto_kem/ledakemlt52/clean/rng.c index fdbe2148..ef1a207f 100644 --- a/crypto_kem/ledakemlt52/clean/rng.c +++ b/crypto_kem/ledakemlt52/clean/rng.c @@ -12,13 +12,10 @@ diversifier - an 8 byte diversifier maxlen - maximum number of bytes (less than 2**32) generated under this seed and diversifier */ -static int seedexpander_init(AES_XOF_struct *ctx, - unsigned char *seed, - unsigned char *diversifier, - size_t maxlen) { - if ( maxlen >= 0x100000000 ) { - return RNG_BAD_MAXLEN; - } +static void seedexpander_init(AES_XOF_struct *ctx, + unsigned char *seed, + unsigned char *diversifier, + size_t maxlen) { ctx->length_remaining = maxlen; @@ -38,8 +35,6 @@ static int seedexpander_init(AES_XOF_struct *ctx, ctx->buffer_pos = 16; memset(ctx->buffer, 0x00, 16); - - return RNG_SUCCESS; } void PQCLEAN_LEDAKEMLT52_CLEAN_seedexpander_from_trng(AES_XOF_struct *ctx, @@ -57,7 +52,7 @@ void PQCLEAN_LEDAKEMLT52_CLEAN_seedexpander_from_trng(AES_XOF_struct *ctx, /* the required seed expansion will be quite small, set the max number of * bytes conservatively to 10 MiB*/ - seedexpander_init(ctx, prng_buffer, diversifier, 10 * 1024 * 1024); + seedexpander_init(ctx, prng_buffer, diversifier, RNG_MAXLEN); } /* diff --git a/crypto_kem/ledakemlt52/clean/rng.h b/crypto_kem/ledakemlt52/clean/rng.h index d6d5b302..5bfc8703 100644 --- a/crypto_kem/ledakemlt52/clean/rng.h +++ b/crypto_kem/ledakemlt52/clean/rng.h @@ -8,6 +8,7 @@ #define RNG_BAD_MAXLEN (-1) #define RNG_BAD_OUTBUF (-2) #define RNG_BAD_REQ_LEN (-3) +#define RNG_MAXLEN (10 * 1024 * 1024) typedef struct { unsigned char buffer[16];