define a constant for max number of rng bytes, remove unnecessary check

Este commit está contenido en:
Leon 2019-06-11 21:45:39 +02:00
padre 889a1f1e53
commit 9e3f973f56
Se han modificado 6 ficheros con 18 adiciones y 30 borrados

Ver fichero

@ -12,13 +12,10 @@
diversifier - an 8 byte diversifier diversifier - an 8 byte diversifier
maxlen - maximum number of bytes (less than 2**32) generated under this seed and diversifier maxlen - maximum number of bytes (less than 2**32) generated under this seed and diversifier
*/ */
static int seedexpander_init(AES_XOF_struct *ctx, static void seedexpander_init(AES_XOF_struct *ctx,
unsigned char *seed, unsigned char *seed,
unsigned char *diversifier, unsigned char *diversifier,
size_t maxlen) { size_t maxlen) {
if ( maxlen >= 0x100000000 ) {
return RNG_BAD_MAXLEN;
}
ctx->length_remaining = maxlen; ctx->length_remaining = maxlen;
@ -38,8 +35,6 @@ static int seedexpander_init(AES_XOF_struct *ctx,
ctx->buffer_pos = 16; ctx->buffer_pos = 16;
memset(ctx->buffer, 0x00, 16); memset(ctx->buffer, 0x00, 16);
return RNG_SUCCESS;
} }
void PQCLEAN_LEDAKEMLT12_CLEAN_seedexpander_from_trng(AES_XOF_struct *ctx, 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 /* the required seed expansion will be quite small, set the max number of
* bytes conservatively to 10 MiB*/ * bytes conservatively to 10 MiB*/
seedexpander_init(ctx, prng_buffer, diversifier, 10 * 1024 * 1024); seedexpander_init(ctx, prng_buffer, diversifier, RNG_MAXLEN);
} }
/* /*

Ver fichero

@ -8,6 +8,7 @@
#define RNG_BAD_MAXLEN (-1) #define RNG_BAD_MAXLEN (-1)
#define RNG_BAD_OUTBUF (-2) #define RNG_BAD_OUTBUF (-2)
#define RNG_BAD_REQ_LEN (-3) #define RNG_BAD_REQ_LEN (-3)
#define RNG_MAXLEN (10 * 1024 * 1024)
typedef struct { typedef struct {
unsigned char buffer[16]; unsigned char buffer[16];

Ver fichero

@ -12,13 +12,10 @@
diversifier - an 8 byte diversifier diversifier - an 8 byte diversifier
maxlen - maximum number of bytes (less than 2**32) generated under this seed and diversifier maxlen - maximum number of bytes (less than 2**32) generated under this seed and diversifier
*/ */
static int seedexpander_init(AES_XOF_struct *ctx, static void seedexpander_init(AES_XOF_struct *ctx,
unsigned char *seed, unsigned char *seed,
unsigned char *diversifier, unsigned char *diversifier,
size_t maxlen) { size_t maxlen) {
if ( maxlen >= 0x100000000 ) {
return RNG_BAD_MAXLEN;
}
ctx->length_remaining = maxlen; ctx->length_remaining = maxlen;
@ -38,8 +35,6 @@ static int seedexpander_init(AES_XOF_struct *ctx,
ctx->buffer_pos = 16; ctx->buffer_pos = 16;
memset(ctx->buffer, 0x00, 16); memset(ctx->buffer, 0x00, 16);
return RNG_SUCCESS;
} }
void PQCLEAN_LEDAKEMLT32_CLEAN_seedexpander_from_trng(AES_XOF_struct *ctx, 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 /* the required seed expansion will be quite small, set the max number of
* bytes conservatively to 10 MiB*/ * bytes conservatively to 10 MiB*/
seedexpander_init(ctx, prng_buffer, diversifier, 10 * 1024 * 1024); seedexpander_init(ctx, prng_buffer, diversifier, RNG_MAXLEN);
} }
/* /*

Ver fichero

@ -8,6 +8,7 @@
#define RNG_BAD_MAXLEN (-1) #define RNG_BAD_MAXLEN (-1)
#define RNG_BAD_OUTBUF (-2) #define RNG_BAD_OUTBUF (-2)
#define RNG_BAD_REQ_LEN (-3) #define RNG_BAD_REQ_LEN (-3)
#define RNG_MAXLEN (10 * 1024 * 1024)
typedef struct { typedef struct {
unsigned char buffer[16]; unsigned char buffer[16];

Ver fichero

@ -12,13 +12,10 @@
diversifier - an 8 byte diversifier diversifier - an 8 byte diversifier
maxlen - maximum number of bytes (less than 2**32) generated under this seed and diversifier maxlen - maximum number of bytes (less than 2**32) generated under this seed and diversifier
*/ */
static int seedexpander_init(AES_XOF_struct *ctx, static void seedexpander_init(AES_XOF_struct *ctx,
unsigned char *seed, unsigned char *seed,
unsigned char *diversifier, unsigned char *diversifier,
size_t maxlen) { size_t maxlen) {
if ( maxlen >= 0x100000000 ) {
return RNG_BAD_MAXLEN;
}
ctx->length_remaining = maxlen; ctx->length_remaining = maxlen;
@ -38,8 +35,6 @@ static int seedexpander_init(AES_XOF_struct *ctx,
ctx->buffer_pos = 16; ctx->buffer_pos = 16;
memset(ctx->buffer, 0x00, 16); memset(ctx->buffer, 0x00, 16);
return RNG_SUCCESS;
} }
void PQCLEAN_LEDAKEMLT52_CLEAN_seedexpander_from_trng(AES_XOF_struct *ctx, 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 /* the required seed expansion will be quite small, set the max number of
* bytes conservatively to 10 MiB*/ * bytes conservatively to 10 MiB*/
seedexpander_init(ctx, prng_buffer, diversifier, 10 * 1024 * 1024); seedexpander_init(ctx, prng_buffer, diversifier, RNG_MAXLEN);
} }
/* /*

Ver fichero

@ -8,6 +8,7 @@
#define RNG_BAD_MAXLEN (-1) #define RNG_BAD_MAXLEN (-1)
#define RNG_BAD_OUTBUF (-2) #define RNG_BAD_OUTBUF (-2)
#define RNG_BAD_REQ_LEN (-3) #define RNG_BAD_REQ_LEN (-3)
#define RNG_MAXLEN (10 * 1024 * 1024)
typedef struct { typedef struct {
unsigned char buffer[16]; unsigned char buffer[16];