1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-30 22:43:08 +03:00

- Added internal ctr_drbg_init_entropy_len() to allow NIST determined entropy tests to work

This commit is contained in:
Paul Bakker
2011-12-10 21:42:49 +00:00
parent bd4a9d0cda
commit 18d32911c0
2 changed files with 29 additions and 5 deletions

View File

@ -38,11 +38,17 @@
#include <stdio.h>
#endif
int ctr_drbg_init( ctr_drbg_context *ctx,
/*
* Non-public function wrapped by ctr_crbg_init(). Necessary to allow NIST
* tests to succeed (which require known length fixed entropy)
*/
int ctr_drbg_init_entropy_len(
ctr_drbg_context *ctx,
int (*f_entropy)(void *, unsigned char *, size_t),
void *p_entropy,
const unsigned char *custom,
size_t len )
size_t len,
size_t entropy_len )
{
int ret;
unsigned char key[CTR_DRBG_KEYSIZE];
@ -53,7 +59,7 @@ int ctr_drbg_init( ctr_drbg_context *ctx,
ctx->f_entropy = f_entropy;
ctx->p_entropy = p_entropy;
ctx->entropy_len = CTR_DRBG_ENTROPY_LEN;
ctx->entropy_len = entropy_len;
ctx->reseed_interval = CTR_DRBG_RESEED_INTERVAL;
/*
@ -67,6 +73,16 @@ int ctr_drbg_init( ctr_drbg_context *ctx,
return( 0 );
}
int ctr_drbg_init( ctr_drbg_context *ctx,
int (*f_entropy)(void *, unsigned char *, size_t),
void *p_entropy,
const unsigned char *custom,
size_t len )
{
return( ctr_drbg_init_entropy_len( ctx, f_entropy, p_entropy, custom, len,
CTR_DRBG_ENTROPY_LEN ) );
}
void ctr_drbg_set_prediction_resistance( ctr_drbg_context *ctx, int resistance )
{
ctx->prediction_resistance = resistance;