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 @@ -227,10 +227,35 @@ static int dh_compute_value(struct kpp_request *req)
227227
228228 /* SP800-56A rev 3 5.6.2.1.3 key check */
229229 } else {
230+ MPI val_pct ;
231+
230232 if (dh_is_pubkey_valid (ctx , val )) {
231233 ret = - EAGAIN ;
232234 goto err_free_val ;
233235 }
236+
237+ /*
238+ * SP800-56Arev3, 5.6.2.1.4: ("Owner Assurance
239+ * of Pair-wise Consistency"): recompute the
240+ * public key and check if the results match.
241+ */
242+ val_pct = mpi_alloc (0 );
243+ if (!val_pct ) {
244+ ret = - ENOMEM ;
245+ goto err_free_val ;
246+ }
247+
248+ ret = _compute_val (ctx , base , val_pct );
249+ if (ret ) {
250+ mpi_free (val_pct );
251+ goto err_free_val ;
252+ }
253+
254+ if (mpi_cmp (val , val_pct ) != 0 ) {
255+ fips_fail_notify ();
256+ panic ("dh: pair-wise consistency test failed\n" );
257+ }
258+ mpi_free (val_pct );
234259 }
235260 }
236261
You can’t perform that action at this time.
0 commit comments