[PATCH v2 REPOST] nvme-auth: Hash DH shared secret to create session key
Keith Busch
kbusch at kernel.org
Wed Apr 22 13:04:25 PDT 2026
On Wed, Apr 22, 2026 at 12:06:36PM -0700, Chris Leech wrote:
> The NVMe Base Specification 8.3.5.5.9 states that the session key Ks
> shall be computed from the ephemeral DH key by applying the hash
> function selected by the HashID parameter.
>
> The current implementation stores the raw DH shared secret as the
> session key without hashing it. This causes redundant hash operations:
>
> 1. Augmented challenge computation (section 8.3.5.5.4) requires
> Ca = HMAC(H(g^xy mod p), C). The code compensates by hashing the
> unhashed session key in nvme_auth_augmented_challenge() to produce
> the correct result.
>
> 2. PSK generation (section 8.3.5.5.9) requires PSK = HMAC(Ks, C1 || C2)
> where Ks should already be H(g^xy mod p). As the DH shared secret
> is always larger than the HMAC block size, HMAC internally hashes
> it before use, accidentally producing the correct result.
Thanks, applied to nvme-7.1.
More information about the Linux-nvme
mailing list