Skip to content

Commit eb66ecd

Browse files
ebiggersherbertx
authored andcommitted
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>
1 parent 44893bc commit eb66ecd

2 files changed

Lines changed: 0 additions & 89 deletions

File tree

‎crypto/xts.c‎

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -357,78 +357,6 @@ static int decrypt(struct skcipher_request *req)
357357
return do_decrypt(req, init_crypt(req, decrypt_done));
358358
}
359359

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-
432360
static int init_tfm(struct crypto_skcipher *tfm)
433361
{
434362
struct skcipher_instance *inst = skcipher_alg_instance(tfm);

‎include/crypto/xts.h‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,10 @@
66
#include <crypto/internal/skcipher.h>
77
#include <linux/fips.h>
88

9-
struct scatterlist;
10-
struct blkcipher_desc;
11-
129
#define XTS_BLOCK_SIZE 16
1310

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-
2411
#define XTS_TWEAK_CAST(x) ((void (*)(void *, u8*, const u8*))(x))
2512

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-
3013
static inline int xts_check_key(struct crypto_tfm *tfm,
3114
const u8 *key, unsigned int keylen)
3215
{

0 commit comments

Comments
 (0)