From 4e669c614db6f827764b25414a61c23f44d39339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Thu, 30 Jan 2014 18:06:08 +0100 Subject: [PATCH] Add hmac_drbg_set_entropy_len() --- include/polarssl/hmac_drbg.h | 12 +++++++++++- library/hmac_drbg.c | 8 ++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/polarssl/hmac_drbg.h b/include/polarssl/hmac_drbg.h index 54aa9a408..a8bb39a4a 100644 --- a/include/polarssl/hmac_drbg.h +++ b/include/polarssl/hmac_drbg.h @@ -96,7 +96,7 @@ int hmac_drbg_init( hmac_drbg_context *ctx, size_t len ); /** - * \brief Simplified HMAC_DRBG initialisation. + * \brief Initilisation of simpified HMAC_DRBG (never reseeds). * (For use with deterministic ECDSA.) * * \param ctx HMAC_DRBG context to be initialised @@ -112,6 +112,16 @@ int hmac_drbg_init_buf( hmac_drbg_context *ctx, const md_info_t * md_info, const unsigned char *data, size_t data_len ); +/** + * \brief Set the amount of entropy grabbed on each reseed + * (Default: HMAC_DRBG_ENTROPY_LEN) + * + * \param ctx HMAC_DRBG context + * \param len Amount of entropy to grab + */ +void hmac_drbg_set_entropy_len( hmac_drbg_context *ctx, + size_t len ); + /** * \brief HMAC_DRBG update state * diff --git a/library/hmac_drbg.c b/library/hmac_drbg.c index a8fe486c8..a322b483e 100644 --- a/library/hmac_drbg.c +++ b/library/hmac_drbg.c @@ -156,6 +156,14 @@ int hmac_drbg_init( hmac_drbg_context *ctx, return( 0 ); } +/* + * Set entropy length grabbed for reseeds + */ +void hmac_drbg_set_entropy_len( hmac_drbg_context *ctx, size_t len ) +{ + ctx->entropy_len = len; +} + /* * HMAC_DRBG random function with optional additional data (10.1.2.5) */