|
|
2871ff |
From 5b2ec9a54037d7b007324bf53e067e73511cdfe4 Mon Sep 17 00:00:00 2001
|
|
|
2871ff |
From: Tomas Mraz <tmraz@fedoraproject.org>
|
|
|
2871ff |
Date: Thu, 26 Nov 2020 14:00:16 +0100
|
|
|
2871ff |
Subject: Add FIPS_mode() compatibility macro
|
|
|
2871ff |
|
|
|
2871ff |
The macro calls EVP_default_properties_is_fips_enabled() on the
|
|
|
2871ff |
default context.
|
|
|
2871ff |
---
|
|
|
2871ff |
include/openssl/crypto.h.in | 1 +
|
|
|
2871ff |
include/openssl/fips.h | 25 +++++++++++++++++++++++++
|
|
|
2871ff |
test/property_test.c | 13 +++++++++++++
|
|
|
2871ff |
3 files changed, 39 insertions(+)
|
|
|
2871ff |
create mode 100644 include/openssl/fips.h
|
|
|
2871ff |
|
|
|
2871ff |
diff --git a/include/openssl/fips.h b/include/openssl/fips.h
|
|
|
2871ff |
new file mode 100644
|
|
|
2871ff |
index 0000000000..c64f0f8e8f
|
|
|
2871ff |
--- /dev/null
|
|
|
2871ff |
+++ b/include/openssl/fips.h
|
|
|
1ac26c |
@@ -0,0 +1,26 @@
|
|
|
2871ff |
+/*
|
|
|
2871ff |
+ * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
|
|
|
2871ff |
+ *
|
|
|
2871ff |
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
|
|
|
2871ff |
+ * this file except in compliance with the License. You can obtain a copy
|
|
|
2871ff |
+ * in the file LICENSE in the source distribution or at
|
|
|
2871ff |
+ * https://www.openssl.org/source/license.html
|
|
|
2871ff |
+ */
|
|
|
2871ff |
+
|
|
|
2871ff |
+#ifndef OPENSSL_FIPS_H
|
|
|
2871ff |
+# define OPENSSL_FIPS_H
|
|
|
2871ff |
+# pragma once
|
|
|
2871ff |
+
|
|
|
1ac26c |
+# include <openssl/evp.h>
|
|
|
2871ff |
+# include <openssl/macros.h>
|
|
|
2871ff |
+
|
|
|
2871ff |
+# ifdef __cplusplus
|
|
|
2871ff |
+extern "C" {
|
|
|
2871ff |
+# endif
|
|
|
2871ff |
+
|
|
|
2871ff |
+# define FIPS_mode() EVP_default_properties_is_fips_enabled(NULL)
|
|
|
2871ff |
+
|
|
|
2871ff |
+# ifdef __cplusplus
|
|
|
2871ff |
+}
|
|
|
2871ff |
+# endif
|
|
|
2871ff |
+#endif
|
|
|
2871ff |
diff -up openssl-3.0.0-beta1/test/property_test.c.fips-macro openssl-3.0.0-beta1/test/property_test.c
|
|
|
2871ff |
--- openssl-3.0.0-beta1/test/property_test.c.fips-macro 2021-06-29 12:14:58.851557698 +0200
|
|
|
2871ff |
+++ openssl-3.0.0-beta1/test/property_test.c 2021-06-29 12:17:14.630143832 +0200
|
|
|
1ac26c |
@@ -488,6 +488,19 @@ static int test_property_list_to_string(
|
|
|
2871ff |
return ret;
|
|
|
2871ff |
}
|
|
|
1ac26c |
|
|
|
1ac26c |
+#include <openssl/fips.h>
|
|
|
2871ff |
+static int test_downstream_FIPS_mode(void)
|
|
|
2871ff |
+{
|
|
|
2871ff |
+ int ret = 0;
|
|
|
2871ff |
+
|
|
|
2871ff |
+ ret = TEST_true(EVP_set_default_properties(NULL, "fips=yes"))
|
|
|
2871ff |
+ && TEST_true(FIPS_mode())
|
|
|
2871ff |
+ && TEST_true(EVP_set_default_properties(NULL, "fips=no"))
|
|
|
2871ff |
+ && TEST_false(FIPS_mode());
|
|
|
2871ff |
+
|
|
|
2871ff |
+ return ret;
|
|
|
2871ff |
+}
|
|
|
2871ff |
+
|
|
|
2871ff |
int setup_tests(void)
|
|
|
2871ff |
{
|
|
|
2871ff |
ADD_TEST(test_property_string);
|
|
|
2871ff |
@@ -500,6 +512,7 @@ int setup_tests(void)
|
|
|
2871ff |
ADD_TEST(test_property);
|
|
|
2871ff |
ADD_TEST(test_query_cache_stochastic);
|
|
|
2871ff |
ADD_TEST(test_fips_mode);
|
|
|
2871ff |
+ ADD_TEST(test_downstream_FIPS_mode);
|
|
|
2871ff |
ADD_ALL_TESTS(test_property_list_to_string, OSSL_NELEM(to_string_tests));
|
|
|
2871ff |
return 1;
|
|
|
2871ff |
}
|