From: Eric Biggers <ebiggers@kernel.org>
To: linux-crypto@vger.kernel.org
Cc: Ard Biesheuvel <ardb@kernel.org>,
"Jason A . Donenfeld" <Jason@zx2c4.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
Eric Biggers <ebiggers@kernel.org>
Subject: [PATCH 2/2] lib/crypto: gf128mul: Remove unused 64k bbe table functions
Date: Thu, 3 Dec 2026 12:11:52 -0800 [thread overview]
Message-ID: <20261203201152.76224-3-ebiggers@kernel.org> (raw)
In-Reply-To: <20261203201152.76224-1-ebiggers@kernel.org>
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 <linux/slab.h> include.
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
---
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 <linux/export.h>
#include <linux/kernel.h>
#include <linux/module.h>
-#include <linux/slab.h>
#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
prev parent reply other threads:[~2026-12-03 20:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 20:11 [PATCH 0/2] lib/crypto: gf128mul: Remove 64 KiB table support Eric Biggers
2026-12-03 20:11 ` [PATCH 1/2] crypto: lrw - Implement field multiplication without gf128mul_64k Eric Biggers
2026-12-03 20:11 ` Eric Biggers [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261203201152.76224-3-ebiggers@kernel.org \
--to=ebiggers@kernel.org \
--cc=Jason@zx2c4.com \
--cc=ardb@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox