Skip to content

Commit 575eae3

Browse files
committed
Fix DH priv key size query
1 parent 7728cf8 commit 575eae3

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

src/wp_dh_kmgmt.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -826,9 +826,15 @@ static int wp_dh_get_params(wp_Dh* dh, OSSL_PARAM params[])
826826
}
827827
}
828828
}
829-
if (ok && (!wp_params_set_octet_string_be(params, OSSL_PKEY_PARAM_PRIV_KEY,
830-
dh->priv, dh->privSz))) {
831-
ok = 0;
829+
if (ok) {
830+
/* Only call if we haven't already handled OSSL_PKEY_PARAM_PRIV_KEY */
831+
p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_PRIV_KEY);
832+
if (p == NULL || p->data != NULL) {
833+
if (!wp_params_set_octet_string_be(params, OSSL_PKEY_PARAM_PRIV_KEY,
834+
dh->priv, dh->privSz)) {
835+
ok = 0;
836+
}
837+
}
832838
}
833839
if (ok && (!wp_dh_get_params_encoded_public_key(dh, params))) {
834840
ok = 0;

test/test_dh.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,9 @@ int test_dh_get_params(void *data)
508508
for (int j = 0; j < 2; j++) {
509509
if (j == 0) {
510510
mode = "Null data";
511+
paramsWolfProvider[0] = gettableParams[i];
512+
paramsWolfProvider[0].data = NULL;
513+
paramsWolfProvider[0].data_size = 0;
511514
}
512515
else {
513516
mode = "Buffer data";

0 commit comments

Comments
 (0)