diff options
author | Jack Lloyd <jack.lloyd@ribose.com> | 2018-06-18 21:49:15 +0200 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2018-06-19 12:29:44 +0200 |
commit | 2f2e6b6278bc4cbf670e42ae9f4ff818529df37c (patch) | |
tree | 6b7fb6ea46a74d909bf48da979ecd209b45625c7 /crypto/evp/p_lib.c | |
parent | Convert our own check of OPENSSL_NO_DEPRECATED (diff) | |
download | openssl-2f2e6b6278bc4cbf670e42ae9f4ff818529df37c.tar.xz openssl-2f2e6b6278bc4cbf670e42ae9f4ff818529df37c.zip |
Add EVP_PKEY_set_alias_type
Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6443)
Diffstat (limited to 'crypto/evp/p_lib.c')
-rw-r--r-- | crypto/evp/p_lib.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c index d78f1d2d84..9429be97e3 100644 --- a/crypto/evp/p_lib.c +++ b/crypto/evp/p_lib.c @@ -356,6 +356,26 @@ int EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len) { return pkey_set_type(pkey, NULL, EVP_PKEY_NONE, str, len); } + +int EVP_PKEY_set_alias_type(EVP_PKEY *pkey, int type) +{ + if (pkey->type == type) { + return 1; /* it already is that type */ + } + + /* + * The application is requesting to alias this to a different pkey type, + * but not one that resolves to the base type. + */ + if (EVP_PKEY_type(type) != EVP_PKEY_base_id(pkey)) { + EVPerr(EVP_F_EVP_PKEY_SET_ALIAS_TYPE, EVP_R_UNSUPPORTED_ALGORITHM); + return 0; + } + + pkey->type = type; + return 1; +} + #ifndef OPENSSL_NO_ENGINE int EVP_PKEY_set1_engine(EVP_PKEY *pkey, ENGINE *e) { |