Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Commit 9452640

Browse files
author
NIIBE Yutaka
committed
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. -- Applied the master commit of: f436bf4 GnuPG-bug-id: 5933 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
1 parent f6a67c2 commit 9452640

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

random/random-drbg.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,9 @@ enum drbg_prefixes
341341
* Global variables
342342
***************************************************************/
343343

344+
/* The instance of the DRBG, to be refereed by drbg_state. */
345+
static struct drbg_state_s drbg_instance;
346+
344347
/* Global state variable holding the current instance of the DRBG. */
345348
static drbg_state_t drbg_state;
346349

@@ -1783,9 +1786,7 @@ _drbg_init_internal (u32 flags, drbg_string_t *pers)
17831786
}
17841787
else
17851788
{
1786-
drbg_state = xtrycalloc_secure (1, sizeof *drbg_state);
1787-
if (!drbg_state)
1788-
return gpg_err_code_from_syserror ();
1789+
drbg_state = &drbg_instance;
17891790
}
17901791
if (flags & DRBG_PREDICTION_RESIST)
17911792
pr = 1;
@@ -1879,7 +1880,6 @@ _gcry_rngdrbg_close_fds (void)
18791880
if (drbg_state)
18801881
{
18811882
drbg_uninstantiate (drbg_state);
1882-
xfree (drbg_state);
18831883
drbg_state = NULL;
18841884
}
18851885
drbg_unlock ();

0 commit comments

Comments
 (0)