Skip to content

Commit

Permalink
fix EVP_PKEY (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
nogolang authored Nov 4, 2024
1 parent d4e22cf commit 2f1f13c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/resty/rsa.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype,
int cmd, int p1, void *p2);

int EVP_PKEY_size(EVP_PKEY *pkey);
int EVP_PKEY_get_size(EVP_PKEY *pkey);

int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx);
int EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx,
Expand Down Expand Up @@ -156,6 +157,13 @@ else
evp_md_ctx_free = C.EVP_MD_CTX_destroy
end

local evp_pkey_size
if not pcall(function () return C.EVP_PKEY_size end) then
evp_pkey_size = C.EVP_PKEY_get_size
else
evp_pkey_size = C.EVP_PKEY_size
end

local function ssl_err()
local err_queue = {}
local i = 1
Expand Down Expand Up @@ -388,7 +396,7 @@ function _M.new(_, opts)
end
end

local size = C.EVP_PKEY_size(pkey)
local size = evp_pkey_size(pkey)
return setmetatable({
pkey = pkey,
size = size,
Expand Down

0 comments on commit 2f1f13c

Please sign in to comment.