crypto: dh - Make public key test FIPS-only
The function dh_is_pubkey_valid was added to for FIPS but it was only partially conditional to fips_enabled. In particular, the first test in the function relies on the last test to work properly, but the last test is only run in FIPS mode. Fix this inconsistency by making the whole function conditional on fips_enabled. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
a24e3b583e
commit
f66a211e8c
11
crypto/dh.c
11
crypto/dh.c
|
@ -106,6 +106,12 @@ err_clear_ctx:
|
|||
*/
|
||||
static int dh_is_pubkey_valid(struct dh_ctx *ctx, MPI y)
|
||||
{
|
||||
MPI val, q;
|
||||
int ret;
|
||||
|
||||
if (!fips_enabled)
|
||||
return 0;
|
||||
|
||||
if (unlikely(!ctx->p))
|
||||
return -EINVAL;
|
||||
|
||||
|
@ -125,10 +131,6 @@ static int dh_is_pubkey_valid(struct dh_ctx *ctx, MPI y)
|
|||
*
|
||||
* For the safe-prime groups q = (p - 1)/2.
|
||||
*/
|
||||
if (fips_enabled) {
|
||||
MPI val, q;
|
||||
int ret;
|
||||
|
||||
val = mpi_alloc(0);
|
||||
if (!val)
|
||||
return -ENOMEM;
|
||||
|
@ -158,7 +160,6 @@ static int dh_is_pubkey_valid(struct dh_ctx *ctx, MPI y)
|
|||
|
||||
if (ret != 0)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue