mingw-openssl/0008-Add-FIPS_mode-compatibility-macro.patch
2022-07-08 10:35:39 +02:00

71 lines
2.3 KiB
Diff

diff -rupN --no-dereference openssl-3.0.5/include/openssl/crypto.h.in openssl-3.0.5-new/include/openssl/crypto.h.in
--- openssl-3.0.5/include/openssl/crypto.h.in 2022-07-05 10:57:04.000000000 +0200
+++ openssl-3.0.5-new/include/openssl/crypto.h.in 2022-07-08 10:09:53.638097973 +0200
@@ -38,6 +38,7 @@ use OpenSSL::stackhash qw(generate_stack
# include <openssl/opensslconf.h>
# include <openssl/cryptoerr.h>
# include <openssl/core.h>
+# include <openssl/fips.h>
# ifdef CHARSET_EBCDIC
# include <openssl/ebcdic.h>
diff -rupN --no-dereference openssl-3.0.5/include/openssl/fips.h openssl-3.0.5-new/include/openssl/fips.h
--- openssl-3.0.5/include/openssl/fips.h 1970-01-01 01:00:00.000000000 +0100
+++ openssl-3.0.5-new/include/openssl/fips.h 2022-07-08 10:09:53.638097973 +0200
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#ifndef OPENSSL_FIPS_H
+# define OPENSSL_FIPS_H
+# pragma once
+
+# include <openssl/macros.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+# define FIPS_mode() EVP_default_properties_is_fips_enabled(NULL)
+
+# ifdef __cplusplus
+}
+# endif
+#endif
diff -rupN --no-dereference openssl-3.0.5/test/property_test.c openssl-3.0.5-new/test/property_test.c
--- openssl-3.0.5/test/property_test.c 2022-07-05 10:57:04.000000000 +0200
+++ openssl-3.0.5-new/test/property_test.c 2022-07-08 10:09:53.638097973 +0200
@@ -624,6 +624,18 @@ static int test_property_list_to_string(
return ret;
}
+static int test_downstream_FIPS_mode(void)
+{
+ int ret = 0;
+
+ ret = TEST_true(EVP_set_default_properties(NULL, "fips=yes"))
+ && TEST_true(FIPS_mode())
+ && TEST_true(EVP_set_default_properties(NULL, "fips=no"))
+ && TEST_false(FIPS_mode());
+
+ return ret;
+}
+
int setup_tests(void)
{
ADD_TEST(test_property_string);
@@ -637,6 +649,7 @@ int setup_tests(void)
ADD_TEST(test_property);
ADD_TEST(test_query_cache_stochastic);
ADD_TEST(test_fips_mode);
+ ADD_TEST(test_downstream_FIPS_mode);
ADD_ALL_TESTS(test_property_list_to_string, OSSL_NELEM(to_string_tests));
return 1;
}