200
200
if OPENSSL_30 then
201
201
require " resty.openssl.include.evp"
202
202
local provider = require " resty.openssl.provider"
203
+ local ctx_lib = require " resty.openssl.ctx"
203
204
local fips_provider_ctx
204
205
205
206
function _M .set_fips_mode (enable , self_test )
@@ -229,7 +230,7 @@ if OPENSSL_30 then
229
230
-- set algorithm in fips mode in default ctx
230
231
-- this deny/allow non-FIPS compliant algorithms to be used from EVP interface
231
232
-- and redirect/remove redirect implementation to fips provider
232
- if C .EVP_default_properties_enable_fips (nil , enable and 1 or 0 ) == 0 then
233
+ if C .EVP_default_properties_enable_fips (ctx_lib . get_libctx () , enable and 1 or 0 ) == 0 then
233
234
return false , format_error (" openssl.set_fips_mode: EVP_default_properties_enable_fips" )
234
235
end
235
236
@@ -242,7 +243,7 @@ if OPENSSL_30 then
242
243
return false
243
244
end
244
245
245
- return C .EVP_default_properties_is_fips_enabled (nil ) == 1
246
+ return C .EVP_default_properties_is_fips_enabled (ctx_lib . get_libctx () ) == 1
246
247
end
247
248
248
249
else
@@ -268,7 +269,9 @@ function _M.set_default_properties(props)
268
269
return nil , " openssl.set_default_properties is only not supported from OpenSSL 3.0"
269
270
end
270
271
271
- if C .EVP_set_default_properties (props ) == 0 then
272
+ local ctx_lib = require " resty.openssl.ctx"
273
+
274
+ if C .EVP_set_default_properties (ctx_lib .get_libctx (), props ) == 0 then
272
275
return false , format_error (" openssl.EVP_set_default_properties" )
273
276
end
274
277
@@ -298,6 +301,7 @@ local function list_provided(typ)
298
301
local typ_lower = string.lower (typ :sub (5 )) -- cut off EVP_
299
302
local typ_ptr = typ .. " *"
300
303
require (" resty.openssl.include.evp." .. typ_lower )
304
+ local ctx_lib = require " resty.openssl.ctx"
301
305
302
306
local ret = {}
303
307
@@ -310,7 +314,7 @@ local function list_provided(typ)
310
314
table.insert (ret , name .. " @ " .. prov )
311
315
end )
312
316
313
- C [typ .. " _do_all_provided" ](nil , fn , nil )
317
+ C [typ .. " _do_all_provided" ](ctx_lib . get_libctx () , fn , nil )
314
318
fn :free ()
315
319
316
320
table.sort (ret )
0 commit comments