Free DRBG context in self tests.

This commit is contained in:
Dr. Stephen Henson 2011-03-21 14:40:57 +00:00
parent 2d1122b802
commit beb895083c
2 changed files with 6 additions and 3 deletions

View file

@ -112,7 +112,8 @@ DRBG_CTX *FIPS_drbg_new(int type, unsigned int flags)
void FIPS_drbg_free(DRBG_CTX *dctx)
{
dctx->uninstantiate(dctx);
if (dctx->uninstantiate)
dctx->uninstantiate(dctx);
OPENSSL_cleanse(dctx, sizeof(DRBG_CTX));
OPENSSL_free(dctx);
}
@ -388,8 +389,9 @@ int FIPS_drbg_uninstantiate(DRBG_CTX *dctx)
{
int rv;
if (!dctx->uninstantiate)
return 1;
rv = dctx->uninstantiate(dctx);
rv = 1;
else
rv = dctx->uninstantiate(dctx);
/* Although we'd like to cleanse here we can't because we have to
* test the uninstantiate really zeroes the data.
*/

View file

@ -1011,6 +1011,7 @@ int FIPS_selftest_drbg(void)
if (!fips_drbg_health_check(dctx, td))
break;
}
FIPS_drbg_free(dctx);
if (td->nid == 0)
return 1;
return 0;