summaryrefslogtreecommitdiffstats
path: root/crypto
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:09:44 -0400
commit2acb0d363c0032b5b97c4f6596609f40bd7d842f (patch)
tree5ca1bcac26a1b2728d44be79f8253805a850c3e8 /crypto
parent1ae4678cebaa13604c0f31bdf2c64cd28bdaf287 (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)
Diffstat (limited to 'crypto')
-rw-r--r--crypto/encode_decode/decoder_pkey.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/crypto/encode_decode/decoder_pkey.c b/crypto/encode_decode/decoder_pkey.c
index 49c90a81a6..e3aaa44902 100644
--- a/crypto/encode_decode/decoder_pkey.c
+++ b/crypto/encode_decode/decoder_pkey.c
@@ -155,7 +155,11 @@ static int decoder_construct_pkey(OSSL_DECODER_INSTANCE *decoder_inst,
import_data.keymgmt = keymgmt;
import_data.keydata = NULL;
- import_data.selection = data->selection;
+ if (data->selection == 0)
+ /* import/export functions do not tolerate 0 selection */
+ import_data.selection = OSSL_KEYMGMT_SELECT_ALL;
+ else
+ import_data.selection = data->selection;
/*
* No need to check for errors here, the value of