Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

lib/crypto: gf128mul: Remove unused 4k_lle functions

Remove the 4k_lle multiplication functions and the associated
gf128mul_table_le data table. Their only user was the generic
implementation of GHASH, which has now been changed to use a different
implementation based on standard integer multiplication.

Acked-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20260319061723.1140720-18-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>

+4 -86
+3 -14
include/crypto/gf128mul.h
··· 215 215 r->b = cpu_to_le64((b << 1) ^ _tt); 216 216 } 217 217 218 - /* 4k table optimization */ 219 - 220 - struct gf128mul_4k { 221 - be128 t[256]; 222 - }; 223 - 224 - struct gf128mul_4k *gf128mul_init_4k_lle(const be128 *g); 225 - void gf128mul_4k_lle(be128 *a, const struct gf128mul_4k *t); 226 218 void gf128mul_x8_ble(le128 *r, const le128 *x); 227 - static inline void gf128mul_free_4k(struct gf128mul_4k *t) 228 - { 229 - kfree_sensitive(t); 230 - } 231 - 232 219 233 220 /* 64k table optimization, implemented for bbe */ 234 221 235 222 struct gf128mul_64k { 236 - struct gf128mul_4k *t[16]; 223 + struct { 224 + be128 t[256]; 225 + } *t[16]; 237 226 }; 238 227 239 228 /* First initialize with the constant factor with which you
+1 -72
lib/crypto/gf128mul.c
··· 127 127 (i & 0x02 ? 0x0384 : 0) ^ (i & 0x01 ? 0x01c2 : 0) \ 128 128 ) 129 129 130 - static const u16 gf128mul_table_le[256] = gf128mul_dat(xda_le); 131 130 static const u16 gf128mul_table_be[256] = gf128mul_dat(xda_be); 132 131 133 - /* 134 - * The following functions multiply a field element by x^8 in 135 - * the polynomial field representation. They use 64-bit word operations 136 - * to gain speed but compensate for machine endianness and hence work 137 - * correctly on both styles of machine. 138 - */ 139 - 140 - static void gf128mul_x8_lle(be128 *x) 141 - { 142 - u64 a = be64_to_cpu(x->a); 143 - u64 b = be64_to_cpu(x->b); 144 - u64 _tt = gf128mul_table_le[b & 0xff]; 145 - 146 - x->b = cpu_to_be64((b >> 8) | (a << 56)); 147 - x->a = cpu_to_be64((a >> 8) ^ (_tt << 48)); 148 - } 149 - 150 - /* time invariant version of gf128mul_x8_lle */ 132 + /* A table-less implementation of multiplying by x^8 */ 151 133 static void gf128mul_x8_lle_ti(be128 *x) 152 134 { 153 135 u64 a = be64_to_cpu(x->a); ··· 286 304 *a = *r; 287 305 } 288 306 EXPORT_SYMBOL(gf128mul_64k_bbe); 289 - 290 - /* This version uses 4k bytes of table space. 291 - A 16 byte buffer has to be multiplied by a 16 byte key 292 - value in GF(2^128). If we consider a GF(2^128) value in a 293 - single byte, we can construct a table of the 256 16 byte 294 - values that result from the 256 values of this byte. 295 - This requires 4096 bytes. If we take the highest byte in 296 - the buffer and use this table to get the result, we then 297 - have to multiply by x^120 to get the final value. For the 298 - next highest byte the result has to be multiplied by x^112 299 - and so on. But we can do this by accumulating the result 300 - in an accumulator starting with the result for the top 301 - byte. We repeatedly multiply the accumulator value by 302 - x^8 and then add in (i.e. xor) the 16 bytes of the next 303 - lower byte in the buffer, stopping when we reach the 304 - lowest byte. This requires a 4096 byte table. 305 - */ 306 - struct gf128mul_4k *gf128mul_init_4k_lle(const be128 *g) 307 - { 308 - struct gf128mul_4k *t; 309 - int j, k; 310 - 311 - t = kzalloc_obj(*t); 312 - if (!t) 313 - goto out; 314 - 315 - t->t[128] = *g; 316 - for (j = 64; j > 0; j >>= 1) 317 - gf128mul_x_lle(&t->t[j], &t->t[j+j]); 318 - 319 - for (j = 2; j < 256; j += j) 320 - for (k = 1; k < j; ++k) 321 - be128_xor(&t->t[j + k], &t->t[j], &t->t[k]); 322 - 323 - out: 324 - return t; 325 - } 326 - EXPORT_SYMBOL(gf128mul_init_4k_lle); 327 - 328 - void gf128mul_4k_lle(be128 *a, const struct gf128mul_4k *t) 329 - { 330 - u8 *ap = (u8 *)a; 331 - be128 r[1]; 332 - int i = 15; 333 - 334 - *r = t->t[ap[15]]; 335 - while (i--) { 336 - gf128mul_x8_lle(r); 337 - be128_xor(r, r, &t->t[ap[i]]); 338 - } 339 - *a = *r; 340 - } 341 - EXPORT_SYMBOL(gf128mul_4k_lle); 342 307 343 308 MODULE_LICENSE("GPL"); 344 309 MODULE_DESCRIPTION("Functions for multiplying elements of GF(2^128)");