From f436bf4451cb2ad0a1f56aa843bf79a58878022f Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Thu, 21 Apr 2022 10:18:03 +0900 Subject: random: Not use secure memory for DRBG instance. * random/random-drbg.c (drbg_instance): New at BSS. (_drbg_init_internal): Don't allocate at secure memory. (_gcry_rngdrbg_close_fds): Follow the change. -- GnuPG-bug-id: 5933 Signed-off-by: NIIBE Yutaka --- random/random-drbg.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'random') diff --git a/random/random-drbg.c b/random/random-drbg.c index 5a46fd92..f1cfe286 100644 --- a/random/random-drbg.c +++ b/random/random-drbg.c @@ -341,6 +341,9 @@ enum drbg_prefixes * Global variables ***************************************************************/ +/* The instance of the DRBG, to be refereed by drbg_state. */ +static struct drbg_state_s drbg_instance; + /* Global state variable holding the current instance of the DRBG. */ static drbg_state_t drbg_state; @@ -1783,9 +1786,7 @@ _drbg_init_internal (u32 flags, drbg_string_t *pers) } else { - drbg_state = xtrycalloc_secure (1, sizeof *drbg_state); - if (!drbg_state) - return gpg_err_code_from_syserror (); + drbg_state = &drbg_instance; } if (flags & DRBG_PREDICTION_RESIST) pr = 1; @@ -1879,7 +1880,6 @@ _gcry_rngdrbg_close_fds (void) if (drbg_state) { drbg_uninstantiate (drbg_state); - xfree (drbg_state); drbg_state = NULL; } drbg_unlock (); -- cgit v1.2.1