]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commitb5df8d72f2c1d912dcffaff544182c0d06bd18c0
treea4d663305324fd63e4bea9e9a145fe9928d77236
parent17f5c70c6d10d2a4f952ecdb7070d450652e3e19
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