diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2006-03-23 18:02:23 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2006-03-23 18:02:23 +0000 |
commit | e42633140e98c7c07a5bc013127e1e6a251995ed (patch) | |
tree | 512218e4d8b50fb52630ce69ee534a485e3fbb76 /crypto/asn1/ameth_lib.c | |
parent | bd50e31325516bcdd45627f5d76f96c38be89eba (diff) |
Add support for legacy PEM format private keys in EVP_PKEY_ASN1_METHOD.
Diffstat (limited to 'crypto/asn1/ameth_lib.c')
-rw-r--r-- | crypto/asn1/ameth_lib.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/crypto/asn1/ameth_lib.c b/crypto/asn1/ameth_lib.c index d7537202de..c95ccf0831 100644 --- a/crypto/asn1/ameth_lib.c +++ b/crypto/asn1/ameth_lib.c @@ -105,6 +105,25 @@ static int ameth_cmp(const EVP_PKEY_ASN1_METHOD * const *a, return ((*a)->pkey_id - (*b)->pkey_id); } +int EVP_PKEY_asn1_get_count(void) + { + int num = sizeof(standard_methods)/sizeof(EVP_PKEY_ASN1_METHOD *); + if (app_methods) + num += sk_num(app_methods); + return num; + } + +const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx) + { + int num = sizeof(standard_methods)/sizeof(EVP_PKEY_ASN1_METHOD *); + if (idx < 0) + return NULL; + if (idx < num) + return standard_methods[idx]; + idx -= num; + return (const EVP_PKEY_ASN1_METHOD *)sk_value(app_methods, idx); + } + const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(int type) { EVP_PKEY_ASN1_METHOD tmp, *t = &tmp, **ret; @@ -129,6 +148,22 @@ const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(int type) return *ret; } +const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(const char *str, int len) + { + int i; + const EVP_PKEY_ASN1_METHOD *ameth; + for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) + { + ameth = EVP_PKEY_asn1_get0(i); + if (ameth->pkey_flags & ASN1_PKEY_ALIAS) + continue; + if ((strlen(ameth->pem_str) == len) && + !strncasecmp(ameth->pem_str, str, len)) + return ameth; + } + return NULL; + } + int EVP_PKEY_asn1_add(const EVP_PKEY_ASN1_METHOD *ameth) { if (app_methods == NULL) |