spacewander / lua-resty-rsa

RSA encrypt/decrypt & sign/verify for OpenResty/LuaJIT

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PATCH: add PKCS#8 key generation

tarkin000 opened this issue · comments

patch:
rsa.lua.patch

API update:

  rsa:generate_rsa_keys(bits,pkcs8)

test:

local rsa = require("resty.rsa")
local pub, prv, err = rsa:generate_rsa_keys(512, true)
print(pub)
print(prv)
print(err)

@tarkin000
https://gist.github.com/tarkin000/d8524946c2b0793ab10accb41a37087b#file-rsa-lua-patch-L66
You should use pkcs8 directly instead of do8. The result of type(nil) is "nil" but not nil.

Moreover, the code should be indented with space, with trailing whitespace removed. luacheck grumbles about this.

I will fix and resubmit

fixed whitespace issues (no tab chars, 4 space indent)
pkcs8 is used directly, now must be boolean AND true
https://gist.github.com/tarkin000/d8524946c2b0793ab10accb41a37087b#file-rsa-lua-patch

When I use resty cli, I sometimes get garbage printed after the keys
a newline + 1-4 random chars, do you?

-----BEGIN RSA PUBLIC KEY-----
MEgCQQDDkojZSa395IHJAQB1KlRulY8lTDqVnO7KKwPRQ4a05v4dxiqz40gxrOpP
UxacY0HAtlN4BO3JknrCvyRzHua5AgMBAAE=
-----END RSA PUBLIC KEY-----
AA

@tarkin000
Not sure... I will investigate it.

@tarkin000
Your patch has been applied as 943e1c5. Thanks for your contribution!

Thanks for the great project!