Skip to content

Commit

Permalink
Prevent creating DSA and DH keys without parameters through import
Browse files Browse the repository at this point in the history
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
  • Loading branch information
t8m committed Feb 7, 2023
1 parent 6e07603 commit 9ce4369
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions providers/implementations/keymgmt/dh_kmgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ static int dh_import(void *keydata, int selection, const OSSL_PARAM params[])
if ((selection & DH_POSSIBLE_SELECTIONS) == 0)
return 0;

if ((selection & OSSL_KEYMGMT_SELECT_ALL_PARAMETERS) != 0)
ok = ok && ossl_dh_params_fromdata(dh, params);
/* a key without parameters is meaningless */
ok = ok && ossl_dh_params_fromdata(dh, params);

if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) {
int include_private =
Expand Down
5 changes: 3 additions & 2 deletions providers/implementations/keymgmt/dsa_kmgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,9 @@ static int dsa_import(void *keydata, int selection, const OSSL_PARAM params[])
if ((selection & DSA_POSSIBLE_SELECTIONS) == 0)
return 0;

if ((selection & OSSL_KEYMGMT_SELECT_ALL_PARAMETERS) != 0)
ok = ok && ossl_dsa_ffc_params_fromdata(dsa, params);
/* a key without parameters is meaningless */
ok = ok && ossl_dsa_ffc_params_fromdata(dsa, params);

if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) {
int include_private =
selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY ? 1 : 0;
Expand Down

0 comments on commit 9ce4369

Please sign in to comment.