diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2017-07-25 18:48:26 +0200 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2017-07-30 00:04:09 +0200 |
commit | 48ed9c23b052d3fed465967eb4193a7c87d0a24d (patch) | |
tree | bd1b4eb1c03d873e6b86c25df553c6a7a9351761 /crypto/evp | |
parent | Add some test coverage for OPENSSL_secure_clear_free (diff) | |
download | openssl-48ed9c23b052d3fed465967eb4193a7c87d0a24d.tar.xz openssl-48ed9c23b052d3fed465967eb4193a7c87d0a24d.zip |
Add public key method enumeration function.
Add functions to enumerate public key methods. Add test to ensure table
is in the correct order.
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4015)
Diffstat (limited to 'crypto/evp')
-rw-r--r-- | crypto/evp/pmeth_lib.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/crypto/evp/pmeth_lib.c b/crypto/evp/pmeth_lib.c index fd83570b1d..b317e41399 100644 --- a/crypto/evp/pmeth_lib.c +++ b/crypto/evp/pmeth_lib.c @@ -290,6 +290,27 @@ int EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth) return 1; } +size_t EVP_PKEY_meth_get_count(void) +{ + size_t rv = OSSL_NELEM(standard_methods); + + if (app_pkey_methods) + rv += sk_EVP_PKEY_METHOD_num(app_pkey_methods); + return rv; +} + +const EVP_PKEY_METHOD *EVP_PKEY_meth_get0(size_t idx) +{ + if (idx < OSSL_NELEM(standard_methods)) + return standard_methods[idx]; + if (app_pkey_methods == NULL) + return NULL; + idx -= OSSL_NELEM(standard_methods); + if (idx >= (size_t)sk_EVP_PKEY_METHOD_num(app_pkey_methods)) + return NULL; + return sk_EVP_PKEY_METHOD_value(app_pkey_methods, idx); +} + void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx) { if (ctx == NULL) |