From nobody Sun Feb 8 15:29:15 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B3F372DF149 for ; Fri, 14 Nov 2025 13:04:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763125488; cv=none; b=RoUSBthLIX5DxPN1B2+eXeZakJRhcf4MFtXu6/6U0Bywflltj38m0q1BAwGD6EH1wIPgqFWocl6ZCCT7x83wok+0B6EtnO66RoU1U4f7do1GqO/7c5AtxL54zlO2iFIp1pn102kG/I00lw3P+ScZgkXyOk0g+1lhtXtEtYyqiY8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763125488; c=relaxed/simple; bh=k61MYFMMaFNORE143WuR8u8TMnZTQTMl3pAPZVZYr3U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L38V/wKC0MgDm7ia9tq3iVF6kJTMspGyBQekMyv0XlGGKVZRET7v3CT7QTOw1vSrpX4Xny6nYKBmXvAmJ0ImXVkd5W/sO8jVvhqY5wygM6pziB05ceikBwxWe8cT19hQOQxzQXuPyLSWlwtssq93NEq4ZXuB4QM3ADyZJ33uQaU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=UoagHA+t; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UoagHA+t" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1763125485; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OUQdQwyIqZTzeJrYIiFd0wR4yxjGopoVQGhDss0o5hs=; b=UoagHA+tWGpMCoAtsddtg7TIhl055IKV2MveOg8SDzXiZawpTZSlKSBXS/qzjoauAXoHXl 87pfKmwK8CO7Bmfhb0/Z8h67dG9qhxzo/lFysc816h2xIbULGVaMig6jNgocwRdMWQAjC8 7VQiSZ3S1U3EuLR6OCHUV6q5+KtOkaM= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-445--rPSOWjpPJeNyJV1Xdy5YQ-1; Fri, 14 Nov 2025 08:04:39 -0500 X-MC-Unique: -rPSOWjpPJeNyJV1Xdy5YQ-1 X-Mimecast-MFC-AGG-ID: -rPSOWjpPJeNyJV1Xdy5YQ_1763125474 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id ADFBF19560B7; Fri, 14 Nov 2025 13:04:33 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.87]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 56A0C1955F1B; Fri, 14 Nov 2025 13:04:28 +0000 (UTC) From: David Howells To: Herbert Xu Cc: David Howells , Eric Biggers , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , "Jason A . Donenfeld" , Ard Biesheuvel , Stephan Mueller , Lukas Wunner , Ignat Korchagin , linux-crypto@vger.kernel.org, keyrings@vger.kernel.org, linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 1/9] crypto: Add support for shake256 through crypto_shash Date: Fri, 14 Nov 2025 13:04:04 +0000 Message-ID: <20251114130417.1756230-2-dhowells@redhat.com> In-Reply-To: <20251114130417.1756230-1-dhowells@redhat.com> References: <20251114130417.1756230-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" Add shake256 support to the SHA-3 crypto_sig module so that ML-DSA can use it. Signed-off-by: David Howells cc: Stephan Mueller cc: Eric Biggers cc: Jason A. Donenfeld cc: Ard Biesheuvel cc: Herbert Xu cc: linux-crypto@vger.kernel.org --- crypto/sha3.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/crypto/sha3.c b/crypto/sha3.c index 8f364979ec89..be1d18baee8d 100644 --- a/crypto/sha3.c +++ b/crypto/sha3.c @@ -9,6 +9,7 @@ #include =20 #define SHA3_CTX(desc) ((struct sha3_ctx *)shash_desc_ctx(desc)) +#define SHAKE_CTX(desc) ((struct shake_ctx *)shash_desc_ctx(desc)) =20 static int crypto_sha3_224_init(struct shash_desc *desc) { @@ -87,6 +88,36 @@ static int crypto_sha3_import_core(struct shash_desc *de= sc, const void *in) return 0; } =20 +static int crypto_shake256_init(struct shash_desc *desc) +{ + shake256_init(SHAKE_CTX(desc)); + return 0; +} + +static int crypto_shake_update(struct shash_desc *desc, const u8 *data, + unsigned int len) +{ + shake_update(SHAKE_CTX(desc), data, len); + return 0; +} + +static int crypto_shake_final(struct shash_desc *desc, u8 *out) +{ + const struct shash_alg *alg =3D crypto_shash_alg(desc->tfm); + + shake_squeeze(SHAKE_CTX(desc), out, alg->digestsize); + return 0; +} + +static int crypto_shake256_digest(struct shash_desc *desc, + const u8 *data, unsigned int len, u8 *out) +{ + const struct shash_alg *alg =3D crypto_shash_alg(desc->tfm); + + shake256(data, len, out, alg->digestsize); + return 0; +} + static struct shash_alg algs[] =3D { { .digestsize =3D SHA3_224_DIGEST_SIZE, .init =3D crypto_sha3_224_init, @@ -139,6 +170,17 @@ static struct shash_alg algs[] =3D { { .base.cra_driver_name =3D "sha3-512-lib", .base.cra_blocksize =3D SHA3_512_BLOCK_SIZE, .base.cra_module =3D THIS_MODULE, +}, { + .digestsize =3D SHAKE256_DEFAULT_SIZE, + .init =3D crypto_shake256_init, + .update =3D crypto_shake_update, + .final =3D crypto_shake_final, + .digest =3D crypto_shake256_digest, + .descsize =3D sizeof(struct shake_ctx), + .base.cra_name =3D "shake256", + .base.cra_driver_name =3D "shake256-lib", + .base.cra_blocksize =3D SHAKE256_BLOCK_SIZE, + .base.cra_module =3D THIS_MODULE, } }; =20 static int __init crypto_sha3_mod_init(void)