OSDN Git Service

crypto: dh - calculate Q from P for the full public key verification
authorNicolai Stange <nstange@suse.de>
Mon, 21 Feb 2022 12:11:01 +0000 (13:11 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Wed, 2 Mar 2022 22:47:52 +0000 (10:47 +1200)
commit35d2bf20683f60288441844ab19ce671075643e6
treea4d663305324fd63e4bea9e9a145fe9928d77236
parent81771ff2411a4cd1224c4b16e0b4247e71bba0de
crypto: dh - calculate Q from P for the full public key verification

As the ->q in struct dh_ctx gets never set anywhere, the code in
dh_is_pubkey_valid() for doing the full public key validation in accordance
to SP800-56Arev3 is effectively dead.

However, for safe-prime groups Q = (P - 1)/2 by definition and
as the safe-prime groups are the only possible groups in FIPS mode (via
those ffdheXYZ() templates), this enables dh_is_pubkey_valid() to calculate
Q on the fly for these.
Implement this.

With this change, the last code accessing struct dh_ctx's ->q is now gone.
Remove this member from struct dh_ctx.

Signed-off-by: Nicolai Stange <nstange@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/dh.c