diff options
author | Shane Lontis <shane.lontis@oracle.com> | 2020-09-15 14:32:40 +1000 |
---|---|---|
committer | Shane Lontis <shane.lontis@oracle.com> | 2020-09-19 18:21:09 +1000 |
commit | f8e747471ebb5e6d65264de91e26fbc439841bc4 (patch) | |
tree | 226e22ff5e49a8807d21e06bb312ef56312741aa /providers | |
parent | 80f4fd18f72c0d3faae864da6979b83acc4f89a2 (diff) |
Add a copy of OSSL_SELF_TEST_get_callback() to the fips module.
The user can set up a self test callback that should be activated when a keygen operation (e.g ec) occurs for the fips module.
The callback information is stored inside the applications library context, but this was not being triggered since the
library context used for the key generation operation was the internal library context used by the fips module (which is not
the same as the application's library context). During the keygen operation the OSSL_SELF_TEST_get_callback() function is used
to retrieve the callback info.
By having a seperate copy of OSSL_SELF_TEST_get_callback() for the fips module we can ensure that the parent library context
is used instead.
The core OSSL_SELF_TEST_get_callback() function pointer is passed across the boundary during the fips modules entry point
such that the fips version of the function can call it after changing the libctx.
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/12877)
Diffstat (limited to 'providers')
-rw-r--r-- | providers/fips/fipsprov.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/providers/fips/fipsprov.c b/providers/fips/fipsprov.c index 9cf43eb491..d2ea505230 100644 --- a/providers/fips/fipsprov.c +++ b/providers/fips/fipsprov.c @@ -886,3 +886,20 @@ int FIPS_security_check_enabled(void) { return fips_security_checks; } + +void OSSL_SELF_TEST_get_callback(OPENSSL_CTX *libctx, OSSL_CALLBACK **cb, + void **cbarg) +{ + if (libctx == NULL) + libctx = selftest_params.libctx; + + if (c_stcbfn != NULL && c_get_libctx != NULL) { + /* Get the parent libctx */ + c_stcbfn(c_get_libctx(FIPS_get_core_handle(libctx)), cb, cbarg); + } else { + if (cb != NULL) + *cb = NULL; + if (cbarg != NULL) + *cbarg = NULL; + } +} |