From 5a80c1106230f4308fe330eb9b881a349a3f9278 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 21 Feb 2012 12:40:27 +0000 Subject: [PATCH] [crypto] Use ANS X9.82 Approved get_random_nz() for RSA Signed-off-by: Michael Brown --- src/crypto/axtls/crypto.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/crypto/axtls/crypto.h b/src/crypto/axtls/crypto.h index a9893cf3..b7af7c41 100644 --- a/src/crypto/axtls/crypto.h +++ b/src/crypto/axtls/crypto.h @@ -130,9 +130,16 @@ void RNG_terminate(void); void get_random(int num_rand_bytes, uint8_t *rand_data); //void get_random_NZ(int num_rand_bytes, uint8_t *rand_data); -#include +#include static inline void get_random_NZ(int num_rand_bytes, uint8_t *rand_data) { - memset ( rand_data, 0x01, num_rand_bytes ); + /* AXTLS does not check for failures when generating random + * data. Rely on the fact that get_random_nz() does not + * request prediction resistance (and so cannot introduce new + * failures) and therefore any potential failure must already + * have been encountered by e.g. tls_generate_random(), which + * does check for failures. + */ + get_random_nz ( rand_data, num_rand_bytes ); } /**************************************************************************