diff options
author | David Benjamin <davidben@chromium.org> | 2016-01-03 14:02:50 +0300 |
---|---|---|
committer | Adam Langley <agl@google.com> | 2016-02-27 01:50:21 +0300 |
commit | 8ebc0f55a01539a9eef39e162c25d09303f4013b (patch) | |
tree | 4737f7fdcea7abe1a2701b7baec6de00279042dd /crypto/evp | |
parent | 3f4f7ee08fe0e36c87519befcaff073dc5a90e95 (diff) |
Decouple the EVP and PEM code.
EVP_PKEY_asn1_find can already be private. EVP_PKEY_asn1_find_str is used
only so the PEM code can get at legacy encoders. Since this is all
legacy non-PKCS8 stuff, we can just explicitly list out the three cases
in the two places that need it. If this changes, we can later add a
table in crypto/pem mapping string to EVP_PKEY type.
With this, EVP_PKEY_ASN1_METHOD is no longer exposed in the public API
and nothing outside of EVP_PKEY reaches into it. Unexport all of that.
Change-Id: Iab661014247dbdbc31e5e9887364176ec5ad2a6d
Reviewed-on: https://boringssl-review.googlesource.com/6871
Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/evp')
-rw-r--r-- | crypto/evp/evp.c | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/crypto/evp/evp.c b/crypto/evp/evp.c index 833f914f..22d262cc 100644 --- a/crypto/evp/evp.c +++ b/crypto/evp/evp.c @@ -194,8 +194,10 @@ int EVP_PKEY_id(const EVP_PKEY *pkey) { return pkey->type; } -/* TODO(fork): remove the first argument. */ -const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pengine, int nid) { +/* evp_pkey_asn1_find returns the ASN.1 method table for the given |nid|, which + * should be one of the |EVP_PKEY_*| values. It returns NULL if |nid| is + * unknown. */ +static const EVP_PKEY_ASN1_METHOD *evp_pkey_asn1_find(int nid) { switch (nid) { case EVP_PKEY_RSA: return &rsa_asn1_meth; @@ -209,7 +211,7 @@ const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pengine, int nid) { } int EVP_PKEY_type(int nid) { - const EVP_PKEY_ASN1_METHOD *meth = EVP_PKEY_asn1_find(NULL, nid); + const EVP_PKEY_ASN1_METHOD *meth = evp_pkey_asn1_find(nid); if (meth == NULL) { return NID_undef; } @@ -308,21 +310,6 @@ int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key) { return key != NULL; } -const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pengine, - const char *name, - size_t len) { - if (len == 3 && memcmp(name, "RSA", 3) == 0) { - return &rsa_asn1_meth; - } - if (len == 2 && memcmp(name, "EC", 2) == 0) { - return &ec_asn1_meth; - } - if (len == 3 && memcmp(name, "DSA", 3) == 0) { - return &dsa_asn1_meth; - } - return NULL; -} - int EVP_PKEY_set_type(EVP_PKEY *pkey, int type) { const EVP_PKEY_ASN1_METHOD *ameth; @@ -330,7 +317,7 @@ int EVP_PKEY_set_type(EVP_PKEY *pkey, int type) { free_it(pkey); } - ameth = EVP_PKEY_asn1_find(NULL, type); + ameth = evp_pkey_asn1_find(type); if (ameth == NULL) { OPENSSL_PUT_ERROR(EVP, EVP_R_UNSUPPORTED_ALGORITHM); ERR_add_error_dataf("algorithm %d (%s)", type, OBJ_nid2sn(type)); |