summaryrefslogtreecommitdiffstats
path: root/providers/fips/fipsprov.c
diff options
context:
space:
mode:
authorShane Lontis <shane.lontis@oracle.com>2020-01-15 10:48:01 +1000
committerShane Lontis <shane.lontis@oracle.com>2020-01-15 10:48:01 +1000
commit36fc5fc6bd5ca53fb30aabc38e3fefbab0005b2c (patch)
tree16e416a148ab7e40d416977ab971e315f7b034f1 /providers/fips/fipsprov.c
parent76123661a1db136b9ef368dc296a628818e7a4cc (diff)
Add FIPS Self test kats for digests
Added an API to optionally set a self test callback. The callback has the following 2 purposes (1) Output information about the KAT tests. (2) Allow the ability to corrupt one of the KAT's The fipsinstall program uses the API. Some KATS are not included in this PR since the required functionality did not yet exist in the provider. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/10374)
Diffstat (limited to 'providers/fips/fipsprov.c')
-rw-r--r--providers/fips/fipsprov.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/providers/fips/fipsprov.c b/providers/fips/fipsprov.c
index 788963911b..cf4181dd2a 100644
--- a/providers/fips/fipsprov.c
+++ b/providers/fips/fipsprov.c
@@ -31,7 +31,7 @@
#include "prov/provider_ctx.h"
#include "prov/providercommon.h"
#include "prov/provider_util.h"
-#include "selftest.h"
+#include "self_test.h"
#define ALGC(NAMES, FUNC, CHECK) { { NAMES, "fips=yes", FUNC }, CHECK }
#define ALG(NAMES, FUNC) ALGC(NAMES, FUNC, NULL)
@@ -649,9 +649,14 @@ int OSSL_provider_init(const OSSL_PROVIDER *provider,
{
FIPS_GLOBAL *fgbl;
OPENSSL_CTX *ctx;
+ OSSL_self_test_cb_fn *stcbfn = NULL;
+ OSSL_core_get_library_context_fn *c_get_libctx = NULL;
for (; in->function_id != 0; in++) {
switch (in->function_id) {
+ case OSSL_FUNC_CORE_GET_LIBRARY_CONTEXT:
+ c_get_libctx = OSSL_get_core_get_library_context(in);
+ break;
case OSSL_FUNC_CORE_GETTABLE_PARAMS:
c_gettable_params = OSSL_get_core_gettable_params(in);
break;
@@ -715,12 +720,25 @@ int OSSL_provider_init(const OSSL_PROVIDER *provider,
case OSSL_FUNC_BIO_FREE:
selftest_params.bio_free_cb = OSSL_get_BIO_free(in);
break;
+ case OSSL_FUNC_SELF_TEST_CB: {
+ stcbfn = OSSL_get_self_test_cb(in);
+ break;
+ }
default:
/* Just ignore anything we don't understand */
break;
}
}
+ if (stcbfn != NULL && c_get_libctx != NULL) {
+ stcbfn(c_get_libctx(provider), &selftest_params.event_cb,
+ &selftest_params.event_cb_arg);
+ }
+ else {
+ selftest_params.event_cb = NULL;
+ selftest_params.event_cb_arg = NULL;
+ }
+
if (!c_get_params(provider, core_params))
return 0;