Skip to content

Support pkcs8 format public key #13

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

Open
wants to merge 1 commit 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
10 changes: 5 additions & 5 deletions lib/resty/rsa.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ RSA *RSA_new(void);
void RSA_free(RSA *rsa);
typedef int pem_password_cb(char *buf, int size, int rwflag, void *userdata);
RSA * PEM_read_bio_RSAPrivateKey(BIO *bp, RSA **rsa, pem_password_cb *cb,
void *u);
RSA * PEM_read_bio_RSAPublicKey(BIO *bp, RSA **rsa, pem_password_cb *cb,
void *u);
RSA * PEM_read_bio_RSA_PUBKEY(BIO *bp, RSA **rsa, pem_password_cb *cb,
void *u);

unsigned long ERR_get_error(void);
Expand All @@ -57,7 +57,7 @@ typedef struct evp_cipher_st EVP_CIPHER;
int PEM_write_bio_RSAPrivateKey(BIO *bp, RSA *x, const EVP_CIPHER *enc,
unsigned char *kstr, int klen,
pem_password_cb *cb, void *u);
int PEM_write_bio_RSAPublicKey(BIO *bp, RSA *x);
int PEM_write_bio_RSA_PUBKEY(BIO *bp, RSA *x);

long BIO_ctrl(BIO *bp, int cmd, long larg, void *parg);
int BIO_read(BIO *b, void *data, int len);
Expand Down Expand Up @@ -151,7 +151,7 @@ function _M.generate_rsa_keys(_, bits)

local pub_key_bio = C.BIO_new(C.BIO_s_mem())
ffi_gc(pub_key_bio, C.BIO_vfree)
if C.PEM_write_bio_RSAPublicKey(pub_key_bio, rsa) ~= 1 then
if C.PEM_write_bio_RSA_PUBKEY(pub_key_bio, rsa) ~= 1 then
return nil, err()
end
local public_key, err = read_bio(pub_key_bio)
Expand All @@ -177,7 +177,7 @@ function _M.new(self, opts)

if opts.public_key then
key = opts.public_key
read_func = C.PEM_read_bio_RSAPublicKey
read_func = C.PEM_read_bio_RSA_PUBKEY
is_pub = true

elseif opts.private_key then
Expand Down