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: serpent - get rid of obsolete tnepres variant
It is not trivial to trace back why exactly the tnepres variant of serpent was added ~17 years ago - Google searches come up mostly empty, but it seems to be related with the 'kerneli' version, which was based on an incorrect interpretation of the serpent spec. In other words, nobody is likely to care anymore today, so let's get rid of it. Signed-off-by: Ard Biesheuvel <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
- Loading branch information
1 parent
e1b2d98
commit 784506a
Showing
5 changed files
with
7 additions
and
169 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,11 +5,6 @@ | |
* Serpent Cipher Algorithm. | ||
* | ||
* Copyright (C) 2002 Dag Arne Osvik <[email protected]> | ||
* 2003 Herbert Valerio Riedel <[email protected]> | ||
* | ||
* Added tnepres support: | ||
* Ruben Jesus Garcia Hernandez <[email protected]>, 18.10.2004 | ||
* Based on code by hvr | ||
*/ | ||
|
||
#include <linux/init.h> | ||
|
@@ -576,59 +571,7 @@ static void serpent_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) | |
__serpent_decrypt(ctx, dst, src); | ||
} | ||
|
||
static int tnepres_setkey(struct crypto_tfm *tfm, const u8 *key, | ||
unsigned int keylen) | ||
{ | ||
u8 rev_key[SERPENT_MAX_KEY_SIZE]; | ||
int i; | ||
|
||
for (i = 0; i < keylen; ++i) | ||
rev_key[keylen - i - 1] = key[i]; | ||
|
||
return serpent_setkey(tfm, rev_key, keylen); | ||
} | ||
|
||
static void tnepres_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) | ||
{ | ||
const u32 * const s = (const u32 * const)src; | ||
u32 * const d = (u32 * const)dst; | ||
|
||
u32 rs[4], rd[4]; | ||
|
||
rs[0] = swab32(s[3]); | ||
rs[1] = swab32(s[2]); | ||
rs[2] = swab32(s[1]); | ||
rs[3] = swab32(s[0]); | ||
|
||
serpent_encrypt(tfm, (u8 *)rd, (u8 *)rs); | ||
|
||
d[0] = swab32(rd[3]); | ||
d[1] = swab32(rd[2]); | ||
d[2] = swab32(rd[1]); | ||
d[3] = swab32(rd[0]); | ||
} | ||
|
||
static void tnepres_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) | ||
{ | ||
const u32 * const s = (const u32 * const)src; | ||
u32 * const d = (u32 * const)dst; | ||
|
||
u32 rs[4], rd[4]; | ||
|
||
rs[0] = swab32(s[3]); | ||
rs[1] = swab32(s[2]); | ||
rs[2] = swab32(s[1]); | ||
rs[3] = swab32(s[0]); | ||
|
||
serpent_decrypt(tfm, (u8 *)rd, (u8 *)rs); | ||
|
||
d[0] = swab32(rd[3]); | ||
d[1] = swab32(rd[2]); | ||
d[2] = swab32(rd[1]); | ||
d[3] = swab32(rd[0]); | ||
} | ||
|
||
static struct crypto_alg srp_algs[2] = { { | ||
static struct crypto_alg srp_alg = { | ||
.cra_name = "serpent", | ||
.cra_driver_name = "serpent-generic", | ||
.cra_priority = 100, | ||
|
@@ -643,38 +586,23 @@ static struct crypto_alg srp_algs[2] = { { | |
.cia_setkey = serpent_setkey, | ||
.cia_encrypt = serpent_encrypt, | ||
.cia_decrypt = serpent_decrypt } } | ||
}, { | ||
.cra_name = "tnepres", | ||
.cra_driver_name = "tnepres-generic", | ||
.cra_flags = CRYPTO_ALG_TYPE_CIPHER, | ||
.cra_blocksize = SERPENT_BLOCK_SIZE, | ||
.cra_ctxsize = sizeof(struct serpent_ctx), | ||
.cra_alignmask = 3, | ||
.cra_module = THIS_MODULE, | ||
.cra_u = { .cipher = { | ||
.cia_min_keysize = SERPENT_MIN_KEY_SIZE, | ||
.cia_max_keysize = SERPENT_MAX_KEY_SIZE, | ||
.cia_setkey = tnepres_setkey, | ||
.cia_encrypt = tnepres_encrypt, | ||
.cia_decrypt = tnepres_decrypt } } | ||
} }; | ||
}; | ||
|
||
static int __init serpent_mod_init(void) | ||
{ | ||
return crypto_register_algs(srp_algs, ARRAY_SIZE(srp_algs)); | ||
return crypto_register_alg(&srp_alg); | ||
} | ||
|
||
static void __exit serpent_mod_fini(void) | ||
{ | ||
crypto_unregister_algs(srp_algs, ARRAY_SIZE(srp_algs)); | ||
crypto_unregister_alg(&srp_alg); | ||
} | ||
|
||
subsys_initcall(serpent_mod_init); | ||
module_exit(serpent_mod_fini); | ||
|
||
MODULE_LICENSE("GPL"); | ||
MODULE_DESCRIPTION("Serpent and tnepres (kerneli compatible serpent reversed) Cipher Algorithm"); | ||
MODULE_DESCRIPTION("Serpent Cipher Algorithm"); | ||
MODULE_AUTHOR("Dag Arne Osvik <[email protected]>"); | ||
MODULE_ALIAS_CRYPTO("tnepres"); | ||
MODULE_ALIAS_CRYPTO("serpent"); | ||
MODULE_ALIAS_CRYPTO("serpent-generic"); |
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