Skip to content

Commit 2d65faa

Browse files
committed
Update replace default patch to error on FIPS builds, and allow attempts to fetch provider fips by name
1 parent 935e104 commit 2d65faa

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

patches/openssl3-replace-default.patch

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/crypto/provider_predefined.c b/crypto/provider_predefined.c
2-
index 068e0b7..7bc4ddb 100644
2+
index 068e0b7..e9ae469 100644
33
--- a/crypto/provider_predefined.c
44
+++ b/crypto/provider_predefined.c
5-
@@ -5,23 +5,56 @@
5+
@@ -5,28 +5,67 @@
66
* this file except in compliance with the License. You can obtain a copy
77
* in the file LICENSE in the source distribution or at
88
* https://www.openssl.org/source/license.html
@@ -16,6 +16,13 @@ index 068e0b7..7bc4ddb 100644
1616
#include "provider_local.h"
1717

1818
-OSSL_provider_init_fn ossl_default_provider_init;
19+
+/* For the replace default model we actually do not want OpenSSL built with FIPS.
20+
+ * It pushes FIPS related logic into OpenSSL itself, when that should really be
21+
+ * handled by wolfCrypt. */
22+
+#ifdef FIPS_MODULE
23+
+#error "For wolfProvider replace default mode, do not build OpenSSL with FIPS"
24+
+#endif
25+
+
1926
+static DSO *d = NULL;
2027
+
2128
+/* Common function to dynamically load libwolfprov and call wolfssl_provider_init */
@@ -26,12 +33,12 @@ index 068e0b7..7bc4ddb 100644
2633
+ OSSL_provider_init_fn *wolfssl_provider_init_fn = NULL;
2734
+
2835
+ d = DSO_new();
29-
+ if (!d) {
36+
+ if (!d) {
3037
+ fprintf(stderr, "DSO_new() failed\n");
3138
+ return 1;
3239
+ }
3340
+
34-
+ if (!DSO_load(d, "wolfprov", NULL, 0)) {
41+
+ if (!DSO_load(d, "wolfprov", NULL, 0)) {
3542
+ fprintf(stderr, "Could not load libwolfprov.so. Is the libwolfprov package installed?\n");
3643
+ DSO_free(d);
3744
+ return 1;
@@ -57,13 +64,21 @@ index 068e0b7..7bc4ddb 100644
5764
-OSSL_provider_init_fn ossl_legacy_provider_init;
5865
-#endif
5966
+
67+
+/* For replace default mode, we will always be the selected provider for attempts
68+
+ * to load either the "fips" or "default" providers by name.*/
6069
const OSSL_PROVIDER_INFO ossl_predefined_providers[] = {
61-
#ifdef FIPS_MODULE
70+
-#ifdef FIPS_MODULE
6271
- { "fips", NULL, ossl_fips_intern_provider_init, NULL, 1 },
63-
+ { "fips", NULL, load_wolfprov_and_init, NULL, 1 },
64-
#else
72+
-#else
6573
- { "default", NULL, ossl_default_provider_init, NULL, 1 },
74+
+ { "fips", NULL, load_wolfprov_and_init, NULL, 0 },
6675
+ { "default", NULL, load_wolfprov_and_init, NULL, 1 },
6776
# ifdef STATIC_LEGACY
68-
{ "legacy", NULL, ossl_legacy_provider_init, NULL, 0 },
77+
- { "legacy", NULL, ossl_legacy_provider_init, NULL, 0 },
78+
+ { "legacy", NULL, load_wolfprov_and_init, NULL, 0 },
6979
# endif
80+
{ "base", NULL, ossl_base_provider_init, NULL, 0 },
81+
{ "null", NULL, ossl_null_provider_init, NULL, 0 },
82+
-#endif
83+
{ NULL, NULL, NULL, NULL, 0 }
84+
};

0 commit comments

Comments
 (0)