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

chore(spec): generate_keys supports EC key #14184

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
24 changes: 17 additions & 7 deletions spec/internal/misc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,25 @@ end
--- Generate asymmetric keys
-- @function generate_keys
-- @param fmt format to receive the public and private pair
-- @param typ (optional) the type of key to generate, default: RSA
-- @return `pub, priv` key tuple or `nil + err` on failure
local function generate_keys(fmt)
local function generate_keys(fmt, typ)
fmt = string.upper(fmt) or "JWK"
local key, err = pkey.new({
-- only support RSA for now
type = 'RSA',
bits = 2048,
exp = 65537
})
typ = typ or string.upper(typ) or "RSA"
local key, err
-- only support RSA and EC for now
if typ == "RSA" then
key, err = pkey.new({
type = 'RSA',
bits = 2048,
exp = 65537
})
elseif typ == "EC" then
key, err = pkey.new({
type = 'EC',
curve = 'prime256v1',
})
end
assert(key)
assert(err == nil, err)
local pub = key:tostring("public", fmt)
Expand Down
Loading