Skip to content

Commit

Permalink
EVP_PKEY_asn1_add0(): Check that this method isn't already registered
Browse files Browse the repository at this point in the history
No two public key ASN.1 methods with the same pkey_id can be
registered at the same time.

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from #4596)
  • Loading branch information
levitte committed Oct 30, 2017
1 parent 751148e commit d85722d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crypto/asn1/ameth_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe,

int EVP_PKEY_asn1_add0(const EVP_PKEY_ASN1_METHOD *ameth)
{
if (pkey_asn1_find(ameth->pkey_id) != NULL) {
EVPerr(EVP_F_EVP_PKEY_ASN1_ADD0,
EVP_R_PKEY_ASN1_METHOD_ALREADY_REGISTERED);
return 0;
}
if (app_methods == NULL) {
app_methods = sk_EVP_PKEY_ASN1_METHOD_new(ameth_cmp);
if (app_methods == NULL)
Expand Down

0 comments on commit d85722d

Please sign in to comment.