DRBG: delay initialization of DRBG method until instantiation
authorDr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Mon, 17 Feb 2020 18:25:55 +0000 (19:25 +0100)
committerDr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Tue, 25 Feb 2020 10:30:00 +0000 (11:30 +0100)
commit75ff4f7404fe53304ad28279923760b61d6c2ace
tree6aee1f1d2ab867cdd8c8a8117b797447e5829874
parent19ded1a717b6c72c3db241f06787a353f1190755
DRBG: delay initialization of DRBG method until instantiation

Previously, the initialization was done immediately in RAND_DRBG_set(),
which is also called in RAND_DRBG_uninstantiate().

This made it difficult for the FIPS DRBG self test to verify that the
internal state had been zeroized, because it had the side effect that
the drbg->data structure was reinitialized immediately.

To solve the problem, RAND_DRBG_set() has been split in two parts

    static int rand_drbg_set(RAND_DRBG *drbg, int type, unsigned int flags);
    static int rand_drbg_init_method(RAND_DRBG *drbg);

and only the first part is called from RAND_DRBG_uninstantiate().

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11111)
crypto/err/openssl.txt
crypto/rand/drbg_lib.c
crypto/rand/rand_err.c
include/openssl/randerr.h