diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2006-03-23 11:54:51 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2006-03-23 11:54:51 +0000 |
commit | d82e2718e2a1346b231abda31a102b144ac21090 (patch) | |
tree | 7ed221e66f158732f34c4b024cfffd2043d83926 /crypto/asn1/ameth_lib.c | |
parent | 18e377b4ffa6d15572d7283f1eb1743ce5875804 (diff) |
Add information and pem strings. Update dependencies.
Diffstat (limited to 'crypto/asn1/ameth_lib.c')
-rw-r--r-- | crypto/asn1/ameth_lib.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/crypto/asn1/ameth_lib.c b/crypto/asn1/ameth_lib.c index aeadaf7e6a..d7537202de 100644 --- a/crypto/asn1/ameth_lib.c +++ b/crypto/asn1/ameth_lib.c @@ -143,7 +143,8 @@ int EVP_PKEY_asn1_add(const EVP_PKEY_ASN1_METHOD *ameth) return 1; } -EVP_PKEY_ASN1_METHOD* EVP_PKEY_asn1_new(int id) +EVP_PKEY_ASN1_METHOD* EVP_PKEY_asn1_new(int id, + const char *pem_str, const char *info) { EVP_PKEY_ASN1_METHOD *ameth; ameth = OPENSSL_malloc(sizeof(EVP_PKEY_ASN1_METHOD)); @@ -153,6 +154,20 @@ EVP_PKEY_ASN1_METHOD* EVP_PKEY_asn1_new(int id) ameth->pkey_id = id; ameth->pkey_base_id = id; ameth->pkey_flags = ASN1_PKEY_DYNAMIC; + + if (info) + { + ameth->info = BUF_strdup(info); + if (!ameth->info) + goto err; + } + + if (pem_str) + { + ameth->pem_str = BUF_strdup(pem_str); + if (!ameth->pem_str) + goto err; + } ameth->pub_decode = 0; ameth->pub_encode = 0; @@ -180,6 +195,24 @@ EVP_PKEY_ASN1_METHOD* EVP_PKEY_asn1_new(int id) ameth->pkey_ctrl = 0; return ameth; + + err: + + EVP_PKEY_asn1_free(ameth); + return NULL; + + } + +void EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth) + { + if (ameth && (ameth->pkey_flags & ASN1_PKEY_DYNAMIC)) + { + if (ameth->pem_str) + OPENSSL_free(ameth->pem_str); + if (ameth->info) + OPENSSL_free(ameth->info); + OPENSSL_free(ameth); + } } void EVP_PKEY_asn1_set_public(EVP_PKEY_ASN1_METHOD *ameth, |