diff options
author | daurnimator <quae@daurnimator.com> | 2015-12-10 23:11:35 +1100 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2015-12-10 23:11:35 +1100 |
commit | fcd7076005e7e81e37e31df9e5b712214cead2c6 (patch) | |
tree | ddbd58ae801608ffae536ec4fae4772c945bc2f7 /src | |
parent | ecff1f7b08466cc1d1c28f009f0e483fa4ab2a8e (diff) | |
download | luaossl-fcd7076005e7e81e37e31df9e5b712214cead2c6.tar.gz luaossl-fcd7076005e7e81e37e31df9e5b712214cead2c6.tar.bz2 luaossl-fcd7076005e7e81e37e31df9e5b712214cead2c6.zip |
pk_getParameters: Add 'public_only' flag to only export the public key parameters
Should possibly a string/table instead?
Diffstat (limited to 'src')
-rw-r--r-- | src/openssl.c | 8 |
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"); |