From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796328729; b=SOZXVbUXsIIylmKULAp+jKhL6YI/u0lq4IT+5BA6IokNyKBrWrJdeMcxAtKh02fvjE/p lL3/Y+vWtBpvekwxGpCAncpbb6zN7Xh9AYCccpUpkE3973orBQqBnGoGbljx1e8H02MVC B1poVp59u57N7uuc16eYClw/WIBGfRmRGvIOAJA+SjrB1nTCeq3NISp8fx2sTOgcj8jFj WGNFoJJvKFYVPWjWd+QGSrCKhiSgLM65BKh9CD1iEl9efHPgHvKX6N9CzKUqn6fisNGul G9YSS8BFB9Y2iD36X8DzYSDpUOJLhjzzEtMeDkmes2s7/R+ZfEjwiwWHoOno9RHks5g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796328729; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=yQMUbikVcfi5sLJ7fLEW9TGo7Sz5k2PpqEwNiOfZZHQ=; b=a9CKr3nKZQSUscSFMCHa3xMni/8sOgngsI5YrV8f43uvnTdSAIO2Jr/iCUt+U6moJ/XI V3qMPE/oWMC3t8O7HO59HLJJC9vTYwjkgblj1PlD3ruukWecPfTDQyJnqFwwbytmebyli zVkZp/Kq1jIkY1h+ShOoX39XpELKKX3LIBMC8NZNAnXUCDCylnRYLjteOeSTU2ttz/ojy smFggL+9WdVpgfG4ncHDVh/lHqARXW7B7MbicymNa2sRsQT7AlgJGO86nQ9zJG8+8H5Re OZn3nhFoMp9kUVyXCjT5P+0HRUZQNuJqNKMpfMK/iJ8sTm3IbqchoFWdNewhvly8ssQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=I6vAUUd6; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A944606A334 for ; Thu, 3 Dec 2026 20:12:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=I6vAUUd6 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 429281F000C2; Thu, 3 Dec 2026 20:12:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796328729; bh=yQMUbikVcfi5sLJ7fLEW9TGo7Sz5k2PpqEwNiOfZZHQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=I6vAUUd6qh2R7liSwyirF58FBZYJS07mW6LGV7FPUa04nueG3VfmjrMF1pleYFobO PFjqJiZ9MpL6c1ACj22X4tFI/LuGTJGDboEtZgTtZSman5EYRtG9YJQpVRjDLysuA/ 39NUXJF2T8pyPhP/mq9GVmyp2b2YcnefH5Osbh4t6vyxXhW9kTRUqGsbKsYmvvY3eV 6dwulBowQLbdSz9XMIYCfiYyNdFSw1yGrciUW14gyWUeGoNBLGWwgLNG/llwcFfUk0 c9KJMcC30k/5+fXHUIqhsbItWtNCXHWiZFx63bXmM8Dqd6CxBhdJUU6jFdUd9UyaRD Ik7QEHXk/B7FQ== From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: Ard Biesheuvel , "Jason A . Donenfeld" , Herbert Xu , Eric Biggers Subject: [PATCH 2/2] lib/crypto: gf128mul: Remove unused 64k bbe table functions Date: Thu, 3 Dec 2026 12:11:52 -0800 Message-ID: <20261203201152.76224-3-ebiggers@kernel.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261203201152.76224-1-ebiggers@kernel.org> References: <20261203201152.76224-1-ebiggers@kernel.org> X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Now that lrw.c no longer uses them, remove the unused 'struct gf128mul_64k', gf128mul_init_64k_bbe(), gf128mul_free_64k(), and gf128mul_64k_bbe(). Then remove gf128mul_x8_bbe() (which was called only by gf128mul_init_64k_bbe()) and the now-unneeded include. Signed-off-by: Eric Biggers --- include/crypto/gf128mul.h | 17 -------- lib/crypto/gf128mul.c | 90 --------------------------------------- 2 files changed, 107 deletions(-) diff --git a/include/crypto/gf128mul.h b/include/crypto/gf128mul.h index 8fb6f8dbbfa9e..2bdd0ed63d05e 100644 --- a/include/crypto/gf128mul.h +++ b/include/crypto/gf128mul.h @@ -210,21 +210,4 @@ static inline void gf128mul_x_ble(le128 *r, const le128 *x) void gf128mul_x8_ble(le128 *r, const le128 *x); -/* 64k table optimization, implemented for bbe */ - -struct gf128mul_64k { - struct { - be128 t[256]; - } *t[16]; -}; - -/* First initialize with the constant factor with which you - * want to multiply and then call gf128mul_64k_bbe with the other - * factor in the first argument, and the table in the second. - * Afterwards, the result is stored in *a. - */ -struct gf128mul_64k *gf128mul_init_64k_bbe(const be128 *g); -void gf128mul_free_64k(struct gf128mul_64k *t); -void gf128mul_64k_bbe(be128 *a, const struct gf128mul_64k *t); - #endif /* _CRYPTO_GF128MUL_H */ diff --git a/lib/crypto/gf128mul.c b/lib/crypto/gf128mul.c index 7ebf07ce11683..bd57d31791256 100644 --- a/lib/crypto/gf128mul.c +++ b/lib/crypto/gf128mul.c @@ -52,7 +52,6 @@ #include #include #include -#include #define gf128mul_dat(q) { \ q(0x00), q(0x01), q(0x02), q(0x03), q(0x04), q(0x05), q(0x06), q(0x07),\ @@ -140,16 +139,6 @@ static void gf128mul_x8_lle_ti(be128 *x) x->a = cpu_to_be64((a >> 8) ^ (_tt << 48)); } -static void gf128mul_x8_bbe(be128 *x) -{ - u64 a = be64_to_cpu(x->a); - u64 b = be64_to_cpu(x->b); - u64 _tt = gf128mul_table_be[a >> 56]; - - x->a = cpu_to_be64((a << 8) | (b >> 56)); - x->b = cpu_to_be64((b << 8) ^ _tt); -} - void gf128mul_x8_ble(le128 *r, const le128 *x) { u64 a = le64_to_cpu(x->a); @@ -208,84 +197,5 @@ void gf128mul_lle(be128 *r, const be128 *b) } EXPORT_SYMBOL(gf128mul_lle); -/* This version uses 64k bytes of table space. - A 16 byte buffer has to be multiplied by a 16 byte key - value in GF(2^128). If we consider a GF(2^128) value in - the buffer's lowest byte, we can construct a table of - the 256 16 byte values that result from the 256 values - of this byte. This requires 4096 bytes. But we also - need tables for each of the 16 higher bytes in the - buffer as well, which makes 64 kbytes in total. -*/ -/* additional explanation - * t[0][BYTE] contains g*BYTE - * t[1][BYTE] contains g*x^8*BYTE - * .. - * t[15][BYTE] contains g*x^120*BYTE */ -struct gf128mul_64k *gf128mul_init_64k_bbe(const be128 *g) -{ - struct gf128mul_64k *t; - int i, j, k; - - t = kzalloc_obj(*t); - if (!t) - goto out; - - for (i = 0; i < 16; i++) { - t->t[i] = kzalloc_obj(*t->t[i]); - if (!t->t[i]) { - gf128mul_free_64k(t); - t = NULL; - goto out; - } - } - - t->t[0]->t[1] = *g; - for (j = 1; j <= 64; j <<= 1) - gf128mul_x_bbe(&t->t[0]->t[j + j], &t->t[0]->t[j]); - - for (i = 0;;) { - for (j = 2; j < 256; j += j) - for (k = 1; k < j; ++k) - be128_xor(&t->t[i]->t[j + k], - &t->t[i]->t[j], &t->t[i]->t[k]); - - if (++i >= 16) - break; - - for (j = 128; j > 0; j >>= 1) { - t->t[i]->t[j] = t->t[i - 1]->t[j]; - gf128mul_x8_bbe(&t->t[i]->t[j]); - } - } - -out: - return t; -} -EXPORT_SYMBOL(gf128mul_init_64k_bbe); - -void gf128mul_free_64k(struct gf128mul_64k *t) -{ - int i; - - for (i = 0; i < 16; i++) - kfree_sensitive(t->t[i]); - kfree_sensitive(t); -} -EXPORT_SYMBOL(gf128mul_free_64k); - -void gf128mul_64k_bbe(be128 *a, const struct gf128mul_64k *t) -{ - u8 *ap = (u8 *)a; - be128 r[1]; - int i; - - *r = t->t[0]->t[ap[15]]; - for (i = 1; i < 16; ++i) - be128_xor(r, r, &t->t[i]->t[ap[15 - i]]); - *a = *r; -} -EXPORT_SYMBOL(gf128mul_64k_bbe); - MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Functions for multiplying elements of GF(2^128)"); -- 2.56.1