summaryrefslogtreecommitdiff
path: root/crypto/evp/keymgmt_lib.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2020-05-21 11:33:53 +0100
committerMatt Caswell <matt@openssl.org>2020-06-05 11:04:11 +0100
commit11391da217b5d07dd30dd4c1890b5320fa56be18 (patch)
tree6ba1a12ac7c160013e4b5862aab0bdf738c51aea /crypto/evp/keymgmt_lib.c
parent6a9bd9298bd706e3a4a40ecfa1d89f65f8592c65 (diff)
downloadopenssl-new-11391da217b5d07dd30dd4c1890b5320fa56be18.tar.gz
Always create a key when importing
Even if there is no data to import we should still create an empty key. Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/11898)
Diffstat (limited to 'crypto/evp/keymgmt_lib.c')
-rw-r--r--crypto/evp/keymgmt_lib.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/crypto/evp/keymgmt_lib.c b/crypto/evp/keymgmt_lib.c
index a712233043..68ed74b23a 100644
--- a/crypto/evp/keymgmt_lib.c
+++ b/crypto/evp/keymgmt_lib.c
@@ -39,6 +39,13 @@ static int try_import(const OSSL_PARAM params[], void *arg)
{
struct import_data_st *data = arg;
+ /* Just in time creation of keydata */
+ if (data->keydata == NULL
+ && (data->keydata = evp_keymgmt_newdata(data->keymgmt)) == NULL) {
+ ERR_raise(ERR_LIB_EVP, ERR_R_MALLOC_FAILURE);
+ return 0;
+ }
+
/*
* It's fine if there was no data to transfer, we just end up with an
* empty destination key.
@@ -46,13 +53,6 @@ static int try_import(const OSSL_PARAM params[], void *arg)
if (params[0].key == NULL)
return 1;
- /* Just in time creation of keydata, if needed */
- if (data->keydata == NULL
- && (data->keydata = evp_keymgmt_newdata(data->keymgmt)) == NULL) {
- ERR_raise(ERR_LIB_EVP, ERR_R_MALLOC_FAILURE);
- return 0;
- }
-
return evp_keymgmt_import(data->keymgmt, data->keydata, data->selection,
params);
}