Skip to content

Commit

Permalink
Avoid exporting bogus (empty) data if empty selection is used
Browse files Browse the repository at this point in the history
This is already correct in the rsa_kmgmt.c but other
implementations are wrong.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from #21519)
  • Loading branch information
t8m authored and tmshort committed Aug 4, 2023
1 parent cb8e641 commit 1ae4678
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions providers/implementations/keymgmt/dh_kmgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ static int dh_export(void *keydata, int selection, OSSL_CALLBACK *param_cb,
if (!ossl_prov_is_running() || dh == NULL)
return 0;

if ((selection & DH_POSSIBLE_SELECTIONS) == 0)
return 0;

tmpl = OSSL_PARAM_BLD_new();
if (tmpl == NULL)
return 0;
Expand Down
3 changes: 3 additions & 0 deletions providers/implementations/keymgmt/dsa_kmgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ static int dsa_export(void *keydata, int selection, OSSL_CALLBACK *param_cb,
if (!ossl_prov_is_running() || dsa == NULL)
return 0;

if ((selection & DSA_POSSIBLE_SELECTIONS) == 0)
return 0;

tmpl = OSSL_PARAM_BLD_new();
if (tmpl == NULL)
return 0;
Expand Down
3 changes: 3 additions & 0 deletions providers/implementations/keymgmt/ecx_kmgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ static int ecx_export(void *keydata, int selection, OSSL_CALLBACK *param_cb,
if (!ossl_prov_is_running() || key == NULL)
return 0;

if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) == 0)
return 0;

tmpl = OSSL_PARAM_BLD_new();
if (tmpl == NULL)
return 0;
Expand Down
3 changes: 3 additions & 0 deletions providers/implementations/keymgmt/mac_legacy_kmgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ static int mac_export(void *keydata, int selection, OSSL_CALLBACK *param_cb,
if (!ossl_prov_is_running() || key == NULL)
return 0;

if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) == 0)
return 0;

tmpl = OSSL_PARAM_BLD_new();
if (tmpl == NULL)
return 0;
Expand Down

0 comments on commit 1ae4678

Please sign in to comment.