Re: [PATCH v2] crypto: qat - fix missing DH public key validation

From: Giovanni Cabiddu

Date: Wed Nov 25 2026 - 13:04:47 EST


On Tue, Nov 24, 2026 at 02:12:54PM +0000, Ryan Prinz wrote:
> qat_dh_compute_value() passes the peer's DH public value into the
> hardware queue without checking it. The only checks on req->src are
> on length (req->src_len > ctx->p_size); never on the value itself.
>
> crypto/dh.c's dh_is_pubkey_valid() is the generic software check for
> this: it rejects a value outside [2, p-2], but only when FIPS mode
> is enabled, and only for callers using the software implementation.
> QAT's hardware path has no equivalent check in either mode.
>
> QAT registers "dh" at cra_priority 1000, versus the generic software
> implementation's 100, so any caller requesting "dh" gets this
> unvalidated path whenever a QAT device is present and the requested
> modulus size (1536/2048/3072/4096 bits) is one QAT supports;
> qat_dh_set_secret() only falls back to software for sizes outside
> that set.
Would it make sense to have a provider-independent check for the public
key in crypto/dh_helper.c instead?

This way, software DH, QAT and HiSilicon HPRE, which all register "dh",
could use the same check (regardless of FIPS mode).

Thanks,

--
Giovanni