diff options
Diffstat (limited to 'main/lua-ossl/0007-pkey.new-accept-option-table.patch')
-rw-r--r-- | main/lua-ossl/0007-pkey.new-accept-option-table.patch | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/main/lua-ossl/0007-pkey.new-accept-option-table.patch b/main/lua-ossl/0007-pkey.new-accept-option-table.patch new file mode 100644 index 00000000000..b78818ee6e0 --- /dev/null +++ b/main/lua-ossl/0007-pkey.new-accept-option-table.patch @@ -0,0 +1,58 @@ +From 07e298a09b20f24d7a1efede41c04f398bb1022a Mon Sep 17 00:00:00 2001 +From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> +Date: Sun, 2 Sep 2018 14:44:46 +0300 +Subject: [PATCH 07/10] pkey.new: accept option table + +--- + src/openssl.c | 15 +++++++++++---- + 1 file changed, 11 insertions(+), 4 deletions(-) + +diff --git a/src/openssl.c b/src/openssl.c +index cb38f2f..2aaa5d8 100644 +--- a/src/openssl.c ++++ b/src/openssl.c +@@ -4073,7 +4073,7 @@ static BIO *getbio(lua_State *L) { + static int pk_new(lua_State *L) { + EVP_PKEY **ud; + +- /* #1 table or key; if key, #2 format and #3 type */ ++ /* #1 table or key; if key, #2 option table or format; if format, #3 type */ + lua_settop(L, 3); + + if (lua_istable(L, 1) || lua_isnil(L, 1)) { +@@ -4307,7 +4307,7 @@ static int pk_new(lua_State *L) { + #endif + } /* switch() */ + } else if (lua_isstring(L, 1)) { +- int format = optencoding(L, 2, "*", X509_ANY|X509_PEM|X509_DER); ++ int format; + int pubonly = 0, prvtonly = 0; + const char *type, *data; + size_t len; +@@ -4315,14 +4315,21 @@ static int pk_new(lua_State *L) { + EVP_PKEY *pub = NULL, *prvt = NULL; + int goterr = 0; + ++ if (lua_istable(L, 2)) { ++ lua_getfield(L, 2, "format"); ++ lua_getfield(L, 2, "type"); ++ } ++ ++ format = optencoding(L, -2, "*", X509_ANY|X509_PEM|X509_DER); ++ + /* check if specified publickey or privatekey */ +- if ((type = luaL_optstring(L, 3, NULL))) { ++ if ((type = luaL_optstring(L, -1, NULL))) { + if (xtolower(type[0]) == 'p' && xtolower(type[1]) == 'u') { + pubonly = 1; + } else if (xtolower(type[0]) == 'p' && xtolower(type[1]) == 'r') { + prvtonly = 1; + } else { +- return luaL_argerror(L, 3, lua_pushfstring(L, "invalid type: %s", type)); ++ return luaL_error(L, "invalid key type: %s", type); + } + } + +-- +2.24.1 + |