Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix EVP_PKEY #55

Merged
merged 3 commits into from
Nov 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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