From: Nikos Mavrogiannopoulos Date: Mon, 1 Sep 2014 11:48:48 +0000 (+0200) Subject: drbg-aes: if the continuous test fails, put the library into error state X-Git-Tag: gnutls_3_4_0~1003 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d140f9a9dd5fd433cfc685317f2abedc91b19222;p=thirdparty%2Fgnutls.git drbg-aes: if the continuous test fails, put the library into error state --- diff --git a/lib/nettle/int/drbg-aes.c b/lib/nettle/int/drbg-aes.c index a8ed9d629c..5ff2484e43 100644 --- a/lib/nettle/int/drbg-aes.c +++ b/lib/nettle/int/drbg-aes.c @@ -27,6 +27,7 @@ #include #include #include +#include int drbg_aes_init(struct drbg_aes_ctx *ctx, @@ -137,8 +138,10 @@ int drbg_aes_generate(struct drbg_aes_ctx *ctx, unsigned length, uint8_t * dst, aes_encrypt(&ctx->key, AES_BLOCK_SIZE, dst, ctx->v); /* if detected loop */ - if (memcmp(dst, ctx->prev_block, AES_BLOCK_SIZE) == 0) + if (memcmp(dst, ctx->prev_block, AES_BLOCK_SIZE) == 0) { + _gnutls_switch_lib_state(LIB_STATE_ERROR); return 0; + } memcpy(ctx->prev_block, dst, AES_BLOCK_SIZE); } @@ -149,8 +152,10 @@ int drbg_aes_generate(struct drbg_aes_ctx *ctx, unsigned length, uint8_t * dst, aes_encrypt(&ctx->key, AES_BLOCK_SIZE, tmp, ctx->v); /* if detected loop */ - if (memcmp(tmp, ctx->prev_block, AES_BLOCK_SIZE) == 0) + if (memcmp(tmp, ctx->prev_block, AES_BLOCK_SIZE) == 0) { + _gnutls_switch_lib_state(LIB_STATE_ERROR); return 0; + } memcpy(ctx->prev_block, tmp, AES_BLOCK_SIZE); memcpy(dst, tmp, left);