aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/openssl.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/openssl.c b/src/openssl.c
index 41262c5..82483af 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -2470,6 +2470,8 @@ static int pk_toPEM(lua_State *L) {
static int pk_getParameters(lua_State *L) {
EVP_PKEY *key = checksimple(L, 1, PKEY_CLASS);
+ _Bool public_only = lua_toboolean(L, 2);
+
void *tmp;
const EC_GROUP *group;
const EC_POINT *public_key;
@@ -2491,6 +2493,8 @@ static int pk_getParameters(lua_State *L) {
return auxL_error(L, auxL_EOPENSSL, "pkey:getParameters");
lua_setfield(L, -2, "e");
+ if (public_only) break;
+
/* RSA secret exponent d */
if (!bn_dup(L, ((RSA*)tmp)->d))
return auxL_error(L, auxL_EOPENSSL, "pkey:getParameters");
@@ -2538,6 +2542,8 @@ static int pk_getParameters(lua_State *L) {
return auxL_error(L, auxL_EOPENSSL, "pkey:getParameters");
lua_setfield(L, -2, "pub_key");
+ if (public_only) break;
+
/* priv_key */
if (!bn_dup(L, ((DH*)tmp)->priv_key))
return auxL_error(L, auxL_EOPENSSL, "pkey:getParameters");
@@ -2552,6 +2558,8 @@ static int pk_getParameters(lua_State *L) {
return auxL_error(L, auxL_EOPENSSL, "pkey:getParameters");
lua_setfield(L, -2, "pub_key");
+ if (public_only) break;
+
/* priv_key */
if (!bn_dup(L, EC_KEY_get0_private_key(tmp)))
return auxL_error(L, auxL_EOPENSSL, "pkey:getParameters");