summaryrefslogtreecommitdiffstats
path: root/providers
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2023-07-21 17:40:31 +0200
committerTodd Short <todd.short@me.com>2023-08-04 10:15:51 -0400
commit52080c8bafcfd445d0d388cc93ad5d1f0d51bf39 (patch)
tree071bf2e383cec2c0cc86f22e33aa126d65e08c40 /providers
parentb5edc8d02ce0c11f39529b0fc95ae64c1c9f6c70 (diff)
When exporting/importing decoded keys do not use 0 as selection
When decoding 0 as the selection means to decode anything you get. However when exporting and then importing the key data 0 as selection is not meaningful. So we set it to OSSL_KEYMGMT_SELECT_ALL to make the export/import function export/import everything that we have decoded. Fixes #21493 Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Todd Short <todd.short@me.com> (Merged from https://github.com/openssl/openssl/pull/21519) (cherry picked from commit 2acb0d363c0032b5b97c4f6596609f40bd7d842f) (cherry picked from commit 137ba0567417441cd8b3d43cf23e27d73f7a7684)
Diffstat (limited to 'providers')
-rw-r--r--providers/implementations/encode_decode/decode_der2key.c6
-rw-r--r--providers/implementations/encode_decode/decode_msblob2key.c6
-rw-r--r--providers/implementations/encode_decode/decode_pvk2key.c6
3 files changed, 15 insertions, 3 deletions
diff --git a/providers/implementations/encode_decode/decode_der2key.c b/providers/implementations/encode_decode/decode_der2key.c
index b9cee2571b..d598f7eba1 100644
--- a/providers/implementations/encode_decode/decode_der2key.c
+++ b/providers/implementations/encode_decode/decode_der2key.c
@@ -316,10 +316,14 @@ static int der2key_export_object(void *vctx,
void *keydata;
if (reference_sz == sizeof(keydata) && export != NULL) {
+ int selection = ctx->selection;
+
+ if (selection == 0)
+ selection = OSSL_KEYMGMT_SELECT_ALL;
/* The contents of the reference is the address to our object */
keydata = *(void **)reference;
- return export(keydata, ctx->selection, export_cb, export_cbarg);
+ return export(keydata, selection, export_cb, export_cbarg);
}
return 0;
}
diff --git a/providers/implementations/encode_decode/decode_msblob2key.c b/providers/implementations/encode_decode/decode_msblob2key.c
index 91f9977b6b..80c6e0a91e 100644
--- a/providers/implementations/encode_decode/decode_msblob2key.c
+++ b/providers/implementations/encode_decode/decode_msblob2key.c
@@ -223,10 +223,14 @@ msblob2key_export_object(void *vctx,
void *keydata;
if (reference_sz == sizeof(keydata) && export != NULL) {
+ int selection = ctx->selection;
+
+ if (selection == 0)
+ selection = OSSL_KEYMGMT_SELECT_ALL;
/* The contents of the reference is the address to our object */
keydata = *(void **)reference;
- return export(keydata, ctx->selection, export_cb, export_cbarg);
+ return export(keydata, selection, export_cb, export_cbarg);
}
return 0;
}
diff --git a/providers/implementations/encode_decode/decode_pvk2key.c b/providers/implementations/encode_decode/decode_pvk2key.c
index 2975186c30..4eeeaf425a 100644
--- a/providers/implementations/encode_decode/decode_pvk2key.c
+++ b/providers/implementations/encode_decode/decode_pvk2key.c
@@ -190,10 +190,14 @@ static int pvk2key_export_object(void *vctx,
void *keydata;
if (reference_sz == sizeof(keydata) && export != NULL) {
+ int selection = ctx->selection;
+
+ if (selection == 0)
+ selection = OSSL_KEYMGMT_SELECT_ALL;
/* The contents of the reference is the address to our object */
keydata = *(void **)reference;
- return export(keydata, ctx->selection, export_cb, export_cbarg);
+ return export(keydata, selection, export_cb, export_cbarg);
}
return 0;
}