From 880ac7eb95207da9e385211d31c36ffbcadcaf08 Mon Sep 17 00:00:00 2001 From: Paul Bakker Date: Sun, 27 Nov 2011 14:50:49 +0000 Subject: [PATCH] - Added handling for CTR_DRBG module --- library/error.c | 13 +++++++++++++ scripts/generate_errors.pl | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/library/error.c b/library/error.c index a792960af..afe8e4573 100644 --- a/library/error.c +++ b/library/error.c @@ -47,6 +47,10 @@ #include "polarssl/cipher.h" #endif +#if defined(POLARSSL_CTR_DRBG_C) +#include "polarssl/ctr_drbg.h" +#endif + #if defined(POLARSSL_DES_C) #include "polarssl/des.h" #endif @@ -373,6 +377,15 @@ void error_strerror( int ret, char *buf, size_t buflen ) snprintf( buf, buflen, "CAMELLIA - Invalid data input length" ); #endif /* POLARSSL_CAMELLIA_C */ +#if defined(POLARSSL_CTR_DRBG_C) + if( use_ret == -(POLARSSL_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED) ) + snprintf( buf, buflen, "CTR_DRBG - The entropy source failed" ); + if( use_ret == -(POLARSSL_ERR_CTR_DRBG_REQUEST_TOO_BIG) ) + snprintf( buf, buflen, "CTR_DRBG - Too many random requested in single call" ); + if( use_ret == -(POLARSSL_ERR_CTR_DRBG_INPUT_TOO_BIG) ) + snprintf( buf, buflen, "CTR_DRBG - Input too large (Entropy + additional)" ); +#endif /* POLARSSL_CTR_DRBG_C */ + #if defined(POLARSSL_DES_C) if( use_ret == -(POLARSSL_ERR_DES_INVALID_INPUT_LENGTH) ) snprintf( buf, buflen, "DES - The data input has an invalid length" ); diff --git a/scripts/generate_errors.pl b/scripts/generate_errors.pl index 5ea83811d..6d8b56371 100755 --- a/scripts/generate_errors.pl +++ b/scripts/generate_errors.pl @@ -9,7 +9,7 @@ my $error_file = shift or die "Missing destination file"; my $error_format_file = $data_dir.'/error.fmt'; my @low_level_modules = ( "AES", "ASN1", "CAMELLIA", "BIGNUM", "BASE64", "XTEA", - "PADLOCK", "DES", "NET" ); + "PADLOCK", "DES", "NET", "CTR_DRBG" ); my @high_level_modules = ( "PEM", "X509", "DHM", "RSA", "MD", "CIPHER", "SSL" ); my $line_separator = $/; @@ -42,6 +42,7 @@ while (my $line = ) # Fix faulty ones $module_name = "BIGNUM" if ($module_name eq "MPI"); + $module_name = "CTR_DRBG" if ($module_name eq "CTR"); my $define_name = $module_name; $define_name = "X509_PARSE" if ($define_name eq "X509");