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

crypto: xts - remove xts_crypt()

Now that all users of xts_crypt() have been removed in favor of the XTS
template wrapping an ECB mode algorithm, remove xts_crypt().

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Eric Biggers and committed by
Herbert Xu
eb66ecd5 44893bc2

-89
-72
crypto/xts.c
··· 357 357 return do_decrypt(req, init_crypt(req, decrypt_done)); 358 358 } 359 359 360 - int xts_crypt(struct blkcipher_desc *desc, struct scatterlist *sdst, 361 - struct scatterlist *ssrc, unsigned int nbytes, 362 - struct xts_crypt_req *req) 363 - { 364 - const unsigned int bsize = XTS_BLOCK_SIZE; 365 - const unsigned int max_blks = req->tbuflen / bsize; 366 - struct blkcipher_walk walk; 367 - unsigned int nblocks; 368 - le128 *src, *dst, *t; 369 - le128 *t_buf = req->tbuf; 370 - int err, i; 371 - 372 - BUG_ON(max_blks < 1); 373 - 374 - blkcipher_walk_init(&walk, sdst, ssrc, nbytes); 375 - 376 - err = blkcipher_walk_virt(desc, &walk); 377 - nbytes = walk.nbytes; 378 - if (!nbytes) 379 - return err; 380 - 381 - nblocks = min(nbytes / bsize, max_blks); 382 - src = (le128 *)walk.src.virt.addr; 383 - dst = (le128 *)walk.dst.virt.addr; 384 - 385 - /* calculate first value of T */ 386 - req->tweak_fn(req->tweak_ctx, (u8 *)&t_buf[0], walk.iv); 387 - 388 - i = 0; 389 - goto first; 390 - 391 - for (;;) { 392 - do { 393 - for (i = 0; i < nblocks; i++) { 394 - gf128mul_x_ble(&t_buf[i], t); 395 - first: 396 - t = &t_buf[i]; 397 - 398 - /* PP <- T xor P */ 399 - le128_xor(dst + i, t, src + i); 400 - } 401 - 402 - /* CC <- E(Key2,PP) */ 403 - req->crypt_fn(req->crypt_ctx, (u8 *)dst, 404 - nblocks * bsize); 405 - 406 - /* C <- T xor CC */ 407 - for (i = 0; i < nblocks; i++) 408 - le128_xor(dst + i, dst + i, &t_buf[i]); 409 - 410 - src += nblocks; 411 - dst += nblocks; 412 - nbytes -= nblocks * bsize; 413 - nblocks = min(nbytes / bsize, max_blks); 414 - } while (nblocks > 0); 415 - 416 - *(le128 *)walk.iv = *t; 417 - 418 - err = blkcipher_walk_done(desc, &walk, nbytes); 419 - nbytes = walk.nbytes; 420 - if (!nbytes) 421 - break; 422 - 423 - nblocks = min(nbytes / bsize, max_blks); 424 - src = (le128 *)walk.src.virt.addr; 425 - dst = (le128 *)walk.dst.virt.addr; 426 - } 427 - 428 - return err; 429 - } 430 - EXPORT_SYMBOL_GPL(xts_crypt); 431 - 432 360 static int init_tfm(struct crypto_skcipher *tfm) 433 361 { 434 362 struct skcipher_instance *inst = skcipher_alg_instance(tfm);
-17
include/crypto/xts.h
··· 6 6 #include <crypto/internal/skcipher.h> 7 7 #include <linux/fips.h> 8 8 9 - struct scatterlist; 10 - struct blkcipher_desc; 11 - 12 9 #define XTS_BLOCK_SIZE 16 13 10 14 - struct xts_crypt_req { 15 - le128 *tbuf; 16 - unsigned int tbuflen; 17 - 18 - void *tweak_ctx; 19 - void (*tweak_fn)(void *ctx, u8* dst, const u8* src); 20 - void *crypt_ctx; 21 - void (*crypt_fn)(void *ctx, u8 *blks, unsigned int nbytes); 22 - }; 23 - 24 11 #define XTS_TWEAK_CAST(x) ((void (*)(void *, u8*, const u8*))(x)) 25 - 26 - int xts_crypt(struct blkcipher_desc *desc, struct scatterlist *dst, 27 - struct scatterlist *src, unsigned int nbytes, 28 - struct xts_crypt_req *req); 29 12 30 13 static inline int xts_check_key(struct crypto_tfm *tfm, 31 14 const u8 *key, unsigned int keylen)