forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
crypto: x86/serpent - drop CTR mode implementation
Serpent in CTR mode is never used by the kernel directly, and is highly unlikely to be relied upon by dm-crypt or algif_skcipher. So let's drop the accelerated CTR mode implementation, and instead, rely on the CTR template and the bare cipher. Acked-by: Eric Biggers <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
- Loading branch information
1 parent
a1f91ec
commit 2e9440a
Showing
6 changed files
with
3 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,6 @@ | |
* | ||
* CBC & ECB parts based on code (crypto/cbc.c,ecb.c) by: | ||
* Copyright (c) 2006 Herbert Xu <[email protected]> | ||
* CTR part based on code (crypto/ctr.c) by: | ||
* (C) Copyright IBM Corp. 2007 - Joy Latten <[email protected]> | ||
*/ | ||
|
||
#include <linux/module.h> | ||
|
@@ -47,38 +45,6 @@ static void serpent_decrypt_cbc_xway(const void *ctx, u8 *d, const u8 *s) | |
u128_xor(dst + (j + 1), dst + (j + 1), ivs + j); | ||
} | ||
|
||
static void serpent_crypt_ctr(const void *ctx, u8 *d, const u8 *s, le128 *iv) | ||
{ | ||
be128 ctrblk; | ||
u128 *dst = (u128 *)d; | ||
const u128 *src = (const u128 *)s; | ||
|
||
le128_to_be128(&ctrblk, iv); | ||
le128_inc(iv); | ||
|
||
__serpent_encrypt(ctx, (u8 *)&ctrblk, (u8 *)&ctrblk); | ||
u128_xor(dst, src, (u128 *)&ctrblk); | ||
} | ||
|
||
static void serpent_crypt_ctr_xway(const void *ctx, u8 *d, const u8 *s, | ||
le128 *iv) | ||
{ | ||
be128 ctrblks[SERPENT_PARALLEL_BLOCKS]; | ||
u128 *dst = (u128 *)d; | ||
const u128 *src = (const u128 *)s; | ||
unsigned int i; | ||
|
||
for (i = 0; i < SERPENT_PARALLEL_BLOCKS; i++) { | ||
if (dst != src) | ||
dst[i] = src[i]; | ||
|
||
le128_to_be128(&ctrblks[i], iv); | ||
le128_inc(iv); | ||
} | ||
|
||
serpent_enc_blk_xway_xor(ctx, (u8 *)dst, (u8 *)ctrblks); | ||
} | ||
|
||
static const struct common_glue_ctx serpent_enc = { | ||
.num_funcs = 2, | ||
.fpu_blocks_limit = SERPENT_PARALLEL_BLOCKS, | ||
|
@@ -92,19 +58,6 @@ static const struct common_glue_ctx serpent_enc = { | |
} } | ||
}; | ||
|
||
static const struct common_glue_ctx serpent_ctr = { | ||
.num_funcs = 2, | ||
.fpu_blocks_limit = SERPENT_PARALLEL_BLOCKS, | ||
|
||
.funcs = { { | ||
.num_blocks = SERPENT_PARALLEL_BLOCKS, | ||
.fn_u = { .ctr = serpent_crypt_ctr_xway } | ||
}, { | ||
.num_blocks = 1, | ||
.fn_u = { .ctr = serpent_crypt_ctr } | ||
} } | ||
}; | ||
|
||
static const struct common_glue_ctx serpent_dec = { | ||
.num_funcs = 2, | ||
.fpu_blocks_limit = SERPENT_PARALLEL_BLOCKS, | ||
|
@@ -152,11 +105,6 @@ static int cbc_decrypt(struct skcipher_request *req) | |
return glue_cbc_decrypt_req_128bit(&serpent_dec_cbc, req); | ||
} | ||
|
||
static int ctr_crypt(struct skcipher_request *req) | ||
{ | ||
return glue_ctr_req_128bit(&serpent_ctr, req); | ||
} | ||
|
||
static struct skcipher_alg serpent_algs[] = { | ||
{ | ||
.base.cra_name = "__ecb(serpent)", | ||
|
@@ -185,21 +133,6 @@ static struct skcipher_alg serpent_algs[] = { | |
.setkey = serpent_setkey_skcipher, | ||
.encrypt = cbc_encrypt, | ||
.decrypt = cbc_decrypt, | ||
}, { | ||
.base.cra_name = "__ctr(serpent)", | ||
.base.cra_driver_name = "__ctr-serpent-sse2", | ||
.base.cra_priority = 400, | ||
.base.cra_flags = CRYPTO_ALG_INTERNAL, | ||
.base.cra_blocksize = 1, | ||
.base.cra_ctxsize = sizeof(struct serpent_ctx), | ||
.base.cra_module = THIS_MODULE, | ||
.min_keysize = SERPENT_MIN_KEY_SIZE, | ||
.max_keysize = SERPENT_MAX_KEY_SIZE, | ||
.ivsize = SERPENT_BLOCK_SIZE, | ||
.chunksize = SERPENT_BLOCK_SIZE, | ||
.setkey = serpent_setkey_skcipher, | ||
.encrypt = ctr_crypt, | ||
.decrypt = ctr_crypt, | ||
}, | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters