Skip to content

fix EVP_PKEY #55

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

Merged
merged 3 commits into from
Nov 4, 2024
Merged
Changes from 1 commit
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
9 changes: 8 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 @@ -388,7 +389,13 @@ function _M.new(_, opts)
end
end

local size = C.EVP_PKEY_size(pkey)
--local size = C.EVP_PKEY_size(pkey)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove it now

local size
if not pcall(function () return C.EVP_PKEY_size(pkey) end) then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use pcall like

if not pcall(function () return C.EVP_MD_CTX_create end) then
, so we only need to call once when loading the module.

size = C.EVP_PKEY_get_size(pkey)
else
size=C.EVP_PKEY_size(pkey)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
size=C.EVP_PKEY_size(pkey)
size = C.EVP_PKEY_size(pkey)

end
return setmetatable({
pkey = pkey,
size = size,
Expand Down
Loading