File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments