Commit 044ab525 authored by Jussi Kivilinna's avatar Jussi Kivilinna Committed by Herbert Xu

crypto: cast5/cast6 - move lookup tables to shared module

CAST5 and CAST6 both use same lookup tables, which can be moved shared module
'cast_common'.
Signed-off-by: default avatarJussi Kivilinna <jussi.kivilinna@mbnet.fi>
Acked-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent f0fcf200
...@@ -25,10 +25,10 @@ ...@@ -25,10 +25,10 @@
.file "cast5-avx-x86_64-asm_64.S" .file "cast5-avx-x86_64-asm_64.S"
.extern cast5_s1 .extern cast_s1
.extern cast5_s2 .extern cast_s2
.extern cast5_s3 .extern cast_s3
.extern cast5_s4 .extern cast_s4
/* structure of crypto context */ /* structure of crypto context */
#define km 0 #define km 0
...@@ -36,10 +36,10 @@ ...@@ -36,10 +36,10 @@
#define rr ((16*4)+16) #define rr ((16*4)+16)
/* s-boxes */ /* s-boxes */
#define s1 cast5_s1 #define s1 cast_s1
#define s2 cast5_s2 #define s2 cast_s2
#define s3 cast5_s3 #define s3 cast_s3
#define s4 cast5_s4 #define s4 cast_s4
/********************************************************************** /**********************************************************************
16-way AVX cast5 16-way AVX cast5
......
...@@ -27,20 +27,20 @@ ...@@ -27,20 +27,20 @@
.file "cast6-avx-x86_64-asm_64.S" .file "cast6-avx-x86_64-asm_64.S"
.extern cast6_s1 .extern cast_s1
.extern cast6_s2 .extern cast_s2
.extern cast6_s3 .extern cast_s3
.extern cast6_s4 .extern cast_s4
/* structure of crypto context */ /* structure of crypto context */
#define km 0 #define km 0
#define kr (12*4*4) #define kr (12*4*4)
/* s-boxes */ /* s-boxes */
#define s1 cast6_s1 #define s1 cast_s1
#define s2 cast6_s2 #define s2 cast_s2
#define s3 cast6_s3 #define s3 cast_s3
#define s4 cast6_s4 #define s4 cast_s4
/********************************************************************** /**********************************************************************
8-way AVX cast6 8-way AVX cast6
......
...@@ -841,9 +841,16 @@ config CRYPTO_CAMELLIA_SPARC64 ...@@ -841,9 +841,16 @@ config CRYPTO_CAMELLIA_SPARC64
See also: See also:
<https://info.isl.ntt.co.jp/crypt/eng/camellia/index_s.html> <https://info.isl.ntt.co.jp/crypt/eng/camellia/index_s.html>
config CRYPTO_CAST_COMMON
tristate
help
Common parts of the CAST cipher algorithms shared by the
generic c and the assembler implementations.
config CRYPTO_CAST5 config CRYPTO_CAST5
tristate "CAST5 (CAST-128) cipher algorithm" tristate "CAST5 (CAST-128) cipher algorithm"
select CRYPTO_ALGAPI select CRYPTO_ALGAPI
select CRYPTO_CAST_COMMON
help help
The CAST5 encryption algorithm (synonymous with CAST-128) is The CAST5 encryption algorithm (synonymous with CAST-128) is
described in RFC2144. described in RFC2144.
...@@ -854,6 +861,7 @@ config CRYPTO_CAST5_AVX_X86_64 ...@@ -854,6 +861,7 @@ config CRYPTO_CAST5_AVX_X86_64
select CRYPTO_ALGAPI select CRYPTO_ALGAPI
select CRYPTO_CRYPTD select CRYPTO_CRYPTD
select CRYPTO_ABLK_HELPER_X86 select CRYPTO_ABLK_HELPER_X86
select CRYPTO_CAST_COMMON
select CRYPTO_CAST5 select CRYPTO_CAST5
help help
The CAST5 encryption algorithm (synonymous with CAST-128) is The CAST5 encryption algorithm (synonymous with CAST-128) is
...@@ -865,6 +873,7 @@ config CRYPTO_CAST5_AVX_X86_64 ...@@ -865,6 +873,7 @@ config CRYPTO_CAST5_AVX_X86_64
config CRYPTO_CAST6 config CRYPTO_CAST6
tristate "CAST6 (CAST-256) cipher algorithm" tristate "CAST6 (CAST-256) cipher algorithm"
select CRYPTO_ALGAPI select CRYPTO_ALGAPI
select CRYPTO_CAST_COMMON
help help
The CAST6 encryption algorithm (synonymous with CAST-256) is The CAST6 encryption algorithm (synonymous with CAST-256) is
described in RFC2612. described in RFC2612.
...@@ -876,6 +885,7 @@ config CRYPTO_CAST6_AVX_X86_64 ...@@ -876,6 +885,7 @@ config CRYPTO_CAST6_AVX_X86_64
select CRYPTO_CRYPTD select CRYPTO_CRYPTD
select CRYPTO_ABLK_HELPER_X86 select CRYPTO_ABLK_HELPER_X86
select CRYPTO_GLUE_HELPER_X86 select CRYPTO_GLUE_HELPER_X86
select CRYPTO_CAST_COMMON
select CRYPTO_CAST6 select CRYPTO_CAST6
select CRYPTO_LRW select CRYPTO_LRW
select CRYPTO_XTS select CRYPTO_XTS
......
...@@ -68,6 +68,7 @@ obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o ...@@ -68,6 +68,7 @@ obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o
obj-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o obj-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o
obj-$(CONFIG_CRYPTO_AES) += aes_generic.o obj-$(CONFIG_CRYPTO_AES) += aes_generic.o
obj-$(CONFIG_CRYPTO_CAMELLIA) += camellia_generic.o obj-$(CONFIG_CRYPTO_CAMELLIA) += camellia_generic.o
obj-$(CONFIG_CRYPTO_CAST_COMMON) += cast_common.o
obj-$(CONFIG_CRYPTO_CAST5) += cast5_generic.o obj-$(CONFIG_CRYPTO_CAST5) += cast5_generic.o
obj-$(CONFIG_CRYPTO_CAST6) += cast6_generic.o obj-$(CONFIG_CRYPTO_CAST6) += cast6_generic.o
obj-$(CONFIG_CRYPTO_ARC4) += arc4.o obj-$(CONFIG_CRYPTO_ARC4) += arc4.o
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/crypto.h> #include <linux/crypto.h>
#include <crypto/cast_common.h>
#define CAST5_BLOCK_SIZE 8 #define CAST5_BLOCK_SIZE 8
#define CAST5_MIN_KEY_SIZE 5 #define CAST5_MIN_KEY_SIZE 5
...@@ -19,9 +20,4 @@ int cast5_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen); ...@@ -19,9 +20,4 @@ int cast5_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen);
void __cast5_encrypt(struct cast5_ctx *ctx, u8 *dst, const u8 *src); void __cast5_encrypt(struct cast5_ctx *ctx, u8 *dst, const u8 *src);
void __cast5_decrypt(struct cast5_ctx *ctx, u8 *dst, const u8 *src); void __cast5_decrypt(struct cast5_ctx *ctx, u8 *dst, const u8 *src);
extern const u32 cast5_s1[256];
extern const u32 cast5_s2[256];
extern const u32 cast5_s3[256];
extern const u32 cast5_s4[256];
#endif #endif
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/crypto.h> #include <linux/crypto.h>
#include <crypto/cast_common.h>
#define CAST6_BLOCK_SIZE 16 #define CAST6_BLOCK_SIZE 16
#define CAST6_MIN_KEY_SIZE 16 #define CAST6_MIN_KEY_SIZE 16
...@@ -20,9 +21,4 @@ int cast6_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen); ...@@ -20,9 +21,4 @@ int cast6_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen);
void __cast6_encrypt(struct cast6_ctx *ctx, u8 *dst, const u8 *src); void __cast6_encrypt(struct cast6_ctx *ctx, u8 *dst, const u8 *src);
void __cast6_decrypt(struct cast6_ctx *ctx, u8 *dst, const u8 *src); void __cast6_decrypt(struct cast6_ctx *ctx, u8 *dst, const u8 *src);
extern const u32 cast6_s1[256];
extern const u32 cast6_s2[256];
extern const u32 cast6_s3[256];
extern const u32 cast6_s4[256];
#endif #endif
#ifndef _CRYPTO_CAST_COMMON_H
#define _CRYPTO_CAST_COMMON_H
extern const u32 cast_s1[256];
extern const u32 cast_s2[256];
extern const u32 cast_s3[256];
extern const u32 cast_s4[256];
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment