diff options
| -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) { | |||
| 2470 | 2470 | ||
| 2471 | static int pk_getParameters(lua_State *L) { | 2471 | static int pk_getParameters(lua_State *L) { |
| 2472 | EVP_PKEY *key = checksimple(L, 1, PKEY_CLASS); | 2472 | EVP_PKEY *key = checksimple(L, 1, PKEY_CLASS); |
| 2473 | _Bool public_only = lua_toboolean(L, 2); | ||
| 2474 | |||
| 2473 | void *tmp; | 2475 | void *tmp; |
| 2474 | const EC_GROUP *group; | 2476 | const EC_GROUP *group; |
| 2475 | const EC_POINT *public_key; | 2477 | const EC_POINT *public_key; |
| @@ -2491,6 +2493,8 @@ static int pk_getParameters(lua_State *L) { | |||
| 2491 | return auxL_error(L, auxL_EOPENSSL, "pkey:getParameters"); | 2493 | return auxL_error(L, auxL_EOPENSSL, "pkey:getParameters"); |
| 2492 | lua_setfield(L, -2, "e"); | 2494 | lua_setfield(L, -2, "e"); |
| 2493 | 2495 | ||
| 2496 | if (public_only) break; | ||
| 2497 | |||
| 2494 | /* RSA secret exponent d */ | 2498 | /* RSA secret exponent d */ |
| 2495 | if (!bn_dup(L, ((RSA*)tmp)->d)) | 2499 | if (!bn_dup(L, ((RSA*)tmp)->d)) |
| 2496 | return auxL_error(L, auxL_EOPENSSL, "pkey:getParameters"); | 2500 | return auxL_error(L, auxL_EOPENSSL, "pkey:getParameters"); |
| @@ -2538,6 +2542,8 @@ static int pk_getParameters(lua_State *L) { | |||
| 2538 | return auxL_error(L, auxL_EOPENSSL, "pkey:getParameters"); | 2542 | return auxL_error(L, auxL_EOPENSSL, "pkey:getParameters"); |
| 2539 | lua_setfield(L, -2, "pub_key"); | 2543 | lua_setfield(L, -2, "pub_key"); |
| 2540 | 2544 | ||
| 2545 | if (public_only) break; | ||
| 2546 | |||
| 2541 | /* priv_key */ | 2547 | /* priv_key */ |
| 2542 | if (!bn_dup(L, ((DH*)tmp)->priv_key)) | 2548 | if (!bn_dup(L, ((DH*)tmp)->priv_key)) |
| 2543 | return auxL_error(L, auxL_EOPENSSL, "pkey:getParameters"); | 2549 | return auxL_error(L, auxL_EOPENSSL, "pkey:getParameters"); |
| @@ -2552,6 +2558,8 @@ static int pk_getParameters(lua_State *L) { | |||
| 2552 | return auxL_error(L, auxL_EOPENSSL, "pkey:getParameters"); | 2558 | return auxL_error(L, auxL_EOPENSSL, "pkey:getParameters"); |
| 2553 | lua_setfield(L, -2, "pub_key"); | 2559 | lua_setfield(L, -2, "pub_key"); |
| 2554 | 2560 | ||
| 2561 | if (public_only) break; | ||
| 2562 | |||
| 2555 | /* priv_key */ | 2563 | /* priv_key */ |
| 2556 | if (!bn_dup(L, EC_KEY_get0_private_key(tmp))) | 2564 | if (!bn_dup(L, EC_KEY_get0_private_key(tmp))) |
| 2557 | return auxL_error(L, auxL_EOPENSSL, "pkey:getParameters"); | 2565 | return auxL_error(L, auxL_EOPENSSL, "pkey:getParameters"); |
