From: Nikos Mavrogiannopoulos Date: Tue, 19 Nov 2013 13:21:53 +0000 (+0100) Subject: removed the initialized static variable. X-Git-Tag: gnutls_3_3_0pre0~520^2~65 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=22aeb7e90fc4072cb5ba4b66e3a2133e7f616118;p=thirdparty%2Fgnutls.git removed the initialized static variable. --- diff --git a/lib/nettle/rnd-fips.c b/lib/nettle/rnd-fips.c index 692d012684..20d86b1540 100644 --- a/lib/nettle/rnd-fips.c +++ b/lib/nettle/rnd-fips.c @@ -386,7 +386,7 @@ int ret; return gnutls_assert_val(ret); ctx->pid = getpid(); - + return 0; } @@ -395,14 +395,9 @@ static int _rngfips_init(void** _ctx) { /* Basic initialization is required to initialize mutexes and do a few checks on the implementation. */ - static int initialized = 0; struct fips_ctx* ctx; int ret; - if (initialized != 0) - return 0; - initialized = 1; - ret = gnutls_mutex_init(&rnd_mutex); if (ret < 0) return gnutls_assert_val(ret); @@ -452,6 +447,22 @@ int ret; return ret; } +static void _rngfips_deinit(void * _ctx) +{ +struct fips_ctx* ctx = _ctx; + zeroize_key(ctx, sizeof(*ctx)); + free(ctx); + gnutls_mutex_deinit(&rnd_mutex); + rnd_mutex = NULL; +} + +static void _rngfips_refresh(void *_ctx) +{ + /* this is predictable RNG. Don't refresh */ + return; +} + + /* Run a Know-Answer-Test using a dedicated test context. Note that we can't use the samples from the NISR RNGVS document because they don't take the requirement to throw away the first block and use @@ -579,22 +590,6 @@ leave: return ret; } -static void _rngfips_deinit(void * _ctx) -{ -struct fips_ctx* ctx = _ctx; - - zeroize_key(ctx, sizeof(*ctx)); - free(ctx); - gnutls_mutex_deinit(&rnd_mutex); - rnd_mutex = NULL; -} - -static void _rngfips_refresh(void *_ctx) -{ - /* this is predictable RNG. Don't refresh */ - return; -} - int crypto_rnd_prio = INT_MAX;