summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-09-03 21:27:20 +1000
committerdaurnimator <quae@daurnimator.com>2017-09-03 21:28:24 +1000
commitf7bd2dec109730b20073ce82d976b026b6e84474 (patch)
treee6b8f9681c03876d06452c9700b2a87bfe4d608c
parentdbe9317aed79bb65f16e5cb680971760dbe5f6a6 (diff)
downloadluaossl-f7bd2dec109730b20073ce82d976b026b6e84474.tar.gz
luaossl-f7bd2dec109730b20073ce82d976b026b6e84474.tar.bz2
luaossl-f7bd2dec109730b20073ce82d976b026b6e84474.zip
Fix pkey.new failing when generating RSA keys
-rw-r--r--src/openssl.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/openssl.c b/src/openssl.c
index f0d2a38..0d0208e 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -3212,8 +3212,6 @@ static int pk_new(lua_State *L) {
3212 /* #1 table or key; if key, #2 format and #3 type */ 3212 /* #1 table or key; if key, #2 format and #3 type */
3213 lua_settop(L, 3); 3213 lua_settop(L, 3);
3214 3214
3215 ud = prepsimple(L, PKEY_CLASS);
3216
3217 if (lua_istable(L, 1) || lua_isnil(L, 1)) { 3215 if (lua_istable(L, 1) || lua_isnil(L, 1)) {
3218 int type = EVP_PKEY_RSA; 3216 int type = EVP_PKEY_RSA;
3219 unsigned bits = 1024; 3217 unsigned bits = 1024;
@@ -3255,7 +3253,7 @@ static int pk_new(lua_State *L) {
3255 bits = (unsigned)n; 3253 bits = (unsigned)n;
3256 } 3254 }
3257 3255
3258 if (!getfield(L, 1, "exp")) { 3256 if (getfield(L, 1, "exp")) {
3259 exp = checkbig(L, -1); 3257 exp = checkbig(L, -1);
3260 } else { 3258 } else {
3261 /* default to 65537 */ 3259 /* default to 65537 */
@@ -3290,6 +3288,8 @@ static int pk_new(lua_State *L) {
3290 } 3288 }
3291 3289
3292creat: 3290creat:
3291 ud = prepsimple(L, PKEY_CLASS);
3292
3293 if (!(*ud = EVP_PKEY_new())) 3293 if (!(*ud = EVP_PKEY_new()))
3294 return auxL_error(L, auxL_EOPENSSL, "pkey.new"); 3294 return auxL_error(L, auxL_EOPENSSL, "pkey.new");
3295 3295
@@ -3430,6 +3430,8 @@ creat:
3430 3430
3431 data = luaL_checklstring(L, 1, &len); 3431 data = luaL_checklstring(L, 1, &len);
3432 3432
3433 ud = prepsimple(L, PKEY_CLASS);
3434
3433 if (!(bio = BIO_new_mem_buf((void *)data, len))) 3435 if (!(bio = BIO_new_mem_buf((void *)data, len)))
3434 return auxL_error(L, auxL_EOPENSSL, "pkey.new"); 3436 return auxL_error(L, auxL_EOPENSSL, "pkey.new");
3435 3437