Skip to content

Commit 7d657e1

Browse files
jallisonciqPlaidCat
authored andcommitted
SUSE: patch: crypto-dh-implement-FIPS-PCT.patch
Signed-off-by: Jeremy Allison <jallison@ciq.com>
1 parent 0be9f27 commit 7d657e1

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

crypto/dh.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,35 @@ static int dh_compute_value(struct kpp_request *req)
218218

219219
/* SP800-56A rev 3 5.6.2.1.3 key check */
220220
} else {
221+
MPI val_pct;
222+
221223
if (dh_is_pubkey_valid(ctx, val)) {
222224
ret = -EAGAIN;
223225
goto err_free_val;
224226
}
227+
228+
/*
229+
* SP800-56Arev3, 5.6.2.1.4: ("Owner Assurance
230+
* of Pair-wise Consistency"): recompute the
231+
* public key and check if the results match.
232+
*/
233+
val_pct = mpi_alloc(0);
234+
if (!val_pct) {
235+
ret = -ENOMEM;
236+
goto err_free_val;
237+
}
238+
239+
ret = _compute_val(ctx, base, val_pct);
240+
if (ret) {
241+
mpi_free(val_pct);
242+
goto err_free_val;
243+
}
244+
245+
if (mpi_cmp(val, val_pct) != 0) {
246+
mpi_free(val_pct);
247+
panic("DH PCT failed in FIPS mode");
248+
}
249+
mpi_free(val_pct);
225250
}
226251
}
227252

0 commit comments

Comments
 (0)