@@ -931,15 +931,16 @@ plugin_t *openssl_plugin_create()
931
931
{
932
932
if (FIPS_mode () != fips_mode && !FIPS_mode_set (fips_mode ))
933
933
{
934
- DBG1 (DBG_LIB , "unable to set openssl FIPS mode(%d) from (%d)" ,
934
+ DBG1 (DBG_LIB , "unable to set OpenSSL FIPS mode(%d) from (%d)" ,
935
935
fips_mode , FIPS_mode ());
936
936
return NULL ;
937
937
}
938
938
}
939
- #else
939
+ #elif OPENSSL_VERSION_NUMBER < 0x30000000L
940
+ /* OpenSSL 3.0+ is handled below */
940
941
if (fips_mode )
941
942
{
942
- DBG1 (DBG_LIB , "openssl FIPS mode(%d) unavailable" , fips_mode );
943
+ DBG1 (DBG_LIB , "OpenSSL FIPS mode(%d) unavailable" , fips_mode );
943
944
return NULL ;
944
945
}
945
946
#endif
@@ -973,8 +974,23 @@ plugin_t *openssl_plugin_create()
973
974
#endif /* OPENSSL_VERSION_NUMBER */
974
975
975
976
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
976
- if (lib -> settings -> get_bool (lib -> settings , "%s.plugins.openssl.load_legacy" ,
977
- TRUE, lib -> ns ))
977
+ if (fips_mode )
978
+ {
979
+ OSSL_PROVIDER * fips ;
980
+
981
+ fips = OSSL_PROVIDER_load (NULL , "fips" );
982
+ if (!fips )
983
+ {
984
+ DBG1 (DBG_LIB , "unable to load OpenSSL FIPS provider" );
985
+ return NULL ;
986
+ }
987
+ array_insert_create (& this -> providers , ARRAY_TAIL , fips );
988
+ /* explicitly load the base provider containing encoding functions */
989
+ array_insert_create (& this -> providers , ARRAY_TAIL ,
990
+ OSSL_PROVIDER_load (NULL , "base" ));
991
+ }
992
+ else if (lib -> settings -> get_bool (lib -> settings , "%s.plugins.openssl.load_legacy" ,
993
+ TRUE, lib -> ns ))
978
994
{
979
995
/* load the legacy provider for algorithms like MD4, DES, BF etc. */
980
996
array_insert_create (& this -> providers , ARRAY_TAIL ,
@@ -989,7 +1005,7 @@ plugin_t *openssl_plugin_create()
989
1005
/* we do this here as it may have been enabled via openssl.conf */
990
1006
fips_mode = FIPS_mode ();
991
1007
dbg (DBG_LIB , strpfx (lib -> ns , "charon" ) ? 1 : 2 ,
992
- "openssl FIPS mode(%d) - %sabled " , fips_mode , fips_mode ? "en" : "dis" );
1008
+ "OpenSSL FIPS mode(%d) - %sabled " , fips_mode , fips_mode ? "en" : "dis" );
993
1009
#endif /* OPENSSL_FIPS */
994
1010
995
1011
#if OPENSSL_VERSION_NUMBER < 0x1010100fL
0 commit comments