summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorDmitry Belyavskiy <beldmit@gmail.com>2021-03-08 21:36:10 +0100
committerDmitry Belyavskiy <beldmit@gmail.com>2021-03-09 16:25:46 +0100
commit896dcda18bf9347deb507f1d3c1f7e17638dd745 (patch)
treeebfa6bffb4c27a88cea7cc3fb35f2d03f76a9b3f /crypto
parentc99248ea812ddc8df9194ffa2b2c8a31117bcb26 (diff)
Non-const accessor to legacy keys
Fixes #14466. Reverting the changes of the EVP_PKEY_get0 function. Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14468)
Diffstat (limited to 'crypto')
-rw-r--r--crypto/evp/p_lib.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c
index 21fbc2ea4c..30ba8d6428 100644
--- a/crypto/evp/p_lib.c
+++ b/crypto/evp/p_lib.c
@@ -740,12 +740,15 @@ int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key)
}
# endif
-const void *EVP_PKEY_get0(const EVP_PKEY *pkey)
+void *EVP_PKEY_get0(const EVP_PKEY *pkey)
{
if (pkey == NULL)
return NULL;
- return evp_pkey_get_legacy((EVP_PKEY *)pkey);
+ if (!evp_pkey_is_provided(pkey))
+ return pkey->pkey.ptr;
+
+ return NULL;
}
const unsigned char *EVP_PKEY_get0_hmac(const EVP_PKEY *pkey, size_t *len)
@@ -755,9 +758,12 @@ const unsigned char *EVP_PKEY_get0_hmac(const EVP_PKEY *pkey, size_t *len)
ERR_raise(ERR_LIB_EVP, EVP_R_EXPECTING_AN_HMAC_KEY);
return NULL;
}
- os = EVP_PKEY_get0(pkey);
- *len = os->length;
- return os->data;
+ os = evp_pkey_get_legacy((EVP_PKEY *)pkey);
+ if (os != NULL) {
+ *len = os->length;
+ return os->data;
+ }
+ return NULL;
}
# ifndef OPENSSL_NO_POLY1305
@@ -768,9 +774,12 @@ const unsigned char *EVP_PKEY_get0_poly1305(const EVP_PKEY *pkey, size_t *len)
ERR_raise(ERR_LIB_EVP, EVP_R_EXPECTING_A_POLY1305_KEY);
return NULL;
}
- os = EVP_PKEY_get0(pkey);
- *len = os->length;
- return os->data;
+ os = evp_pkey_get_legacy((EVP_PKEY *)pkey);
+ if (os != NULL) {
+ *len = os->length;
+ return os->data;
+ }
+ return NULL;
}
# endif
@@ -783,9 +792,12 @@ const unsigned char *EVP_PKEY_get0_siphash(const EVP_PKEY *pkey, size_t *len)
ERR_raise(ERR_LIB_EVP, EVP_R_EXPECTING_A_SIPHASH_KEY);
return NULL;
}
- os = EVP_PKEY_get0(pkey);
- *len = os->length;
- return os->data;
+ os = evp_pkey_get_legacy((EVP_PKEY *)pkey);
+ if (os != NULL) {
+ *len = os->length;
+ return os->data;
+ }
+ return NULL;
}
# endif