tests/drbgtest: use new RAND_DRBG callback_data API instead of ex_data
authorDr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Fri, 31 Jan 2020 12:32:11 +0000 (13:32 +0100)
committerDr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Fri, 7 Feb 2020 10:38:57 +0000 (11:38 +0100)
commit09066cf2a1f9f3d13ea2898304250f5916d6de70
treeecc7135b1ae7189ee28a822374e3a3e48336535b
parent30a9d5d1a72149c4eb2b8e5aa83f509344c80232
tests/drbgtest: use new RAND_DRBG callback_data API instead of ex_data

It took me a little while to realize why the test_rand_drbg_reseed test
kept crashing after replacing the RAND_DRBG_{gs}et_ex_data() calls by
RAND_DRBG_{gs}et_callback_data().

The reason was that the ex_data API prohibits modifying the callbacks
or callback data of chained DRBGs and returned an error which was
ignored by the `test_rand_drbg_reseed` test, for good reasons.

The `test_rand_drbg_reseed` test is special in this respect, because
it needs to install callbacks for all DRBGs, in order to intercept
and count the reseeding events.

Since the drbgtest module has access to the internal structures of
the DRBG anyway, the problem could be solved by accessing the members
directly. I added a warning comment in hook_drbg().

[extended tests]

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10950)
doc/man3/RAND_DRBG_set_callbacks.pod
test/drbgtest.c