Skip to contentSkip to conversation

crypto: add x86_64/avx assembler implementation of cast5 and cast6

PATCH In review Johannes Goetzfried 2 participants 8 messages Jul 11, 2012 – Jul 30, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover crypto: add x86_64/avx assembler implementation of cast5 and cast6

This patchset adds x86_64/avx assembler implementations of the Cast5 and the Cast6 cipher.

Johannes Goetzfried (6):
crypto: cast5 - prepare generic module for optimized implementations
crypto: testmgr - add larger cast5 testvectors
crypto: cast5 - add x86_64/avx assembler implementation
crypto: cast6 - prepare generic module for optimized implementations
crypto: testmgr - add larger cast6 testvectors
crypto: cast6 - add x86_64/avx assembler implementation

 arch/x86/crypto/Makefile                  |    4 +
 arch/x86/crypto/cast5-avx-x86_64-asm_64.S |  323 ++++
 arch/x86/crypto/cast5_avx_glue.c          |  530 ++++++
 arch/x86/crypto/cast6-avx-x86_64-asm_64.S |  336 ++++
 arch/x86/crypto/cast6_avx_glue.c          |  648 ++++++++
 crypto/Kconfig                            |   31 +
 crypto/Makefile                           |    4 +-
 crypto/cast5.c                            |  809 ---------
 crypto/cast5_generic.c                    |  822 ++++++++++
 crypto/cast6.c                            |  547 -------
 crypto/cast6_generic.c                    |  566 +++++++
 crypto/tcrypt.c                           |   82 +
 crypto/tcrypt.h                           |    1 +
 crypto/testmgr.c                          |  210 +++
 crypto/testmgr.h                          | 2538 +++++++++++++++++++++++++++--
 include/crypto/cast5.h                    |   22 +
 include/crypto/cast6.h                    |   23 +
 17 files changed, 5976 insertions(+), 1520 deletions(-)
 create mode 100644 arch/x86/crypto/cast5-avx-x86_64-asm_64.S
 create mode 100644 arch/x86/crypto/cast5_avx_glue.c
 create mode 100644 arch/x86/crypto/cast6-avx-x86_64-asm_64.S
 create mode 100644 arch/x86/crypto/cast6_avx_glue.c
 delete mode 100644 crypto/cast5.c
 create mode 100644 crypto/cast5_generic.c
 delete mode 100644 crypto/cast6.c
 create mode 100644 crypto/cast6_generic.c
 create mode 100644 include/crypto/cast5.h
 create mode 100644 include/crypto/cast6.h
Signature · 1 line
1.7.2.5
#1 lore raw

PATCH 1/6 crypto: cast5 - prepare generic module for optimized implementations

Rename cast5 module to cast5_generic to allow autoloading of optimized implementations. Generic functions and s-boxes are exported to be able to use them within optimized implementations.

---
 crypto/Makefile        |    2 +-
 crypto/cast5.c         |  809 -----------------------------------------------
 crypto/cast5_generic.c |  822 ++++++++++++++++++++++++++++++++++++++++++++++++
 include/crypto/cast5.h |   22 ++
 4 files changed, 845 insertions(+), 810 deletions(-)
 delete mode 100644 crypto/cast5.c
 create mode 100644 crypto/cast5_generic.c
 create mode 100644 include/crypto/cast5.h
crypto/Makefile +1 -1
index 30f33d6..a56821e 100644
@@ -68,7 +68,7 @@ obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o
 obj-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o
 obj-$(CONFIG_CRYPTO_AES) += aes_generic.o
 obj-$(CONFIG_CRYPTO_CAMELLIA) += camellia_generic.o
-obj-$(CONFIG_CRYPTO_CAST5) += cast5.o
+obj-$(CONFIG_CRYPTO_CAST5) += cast5_generic.o
 obj-$(CONFIG_CRYPTO_CAST6) += cast6.o
 obj-$(CONFIG_CRYPTO_ARC4) += arc4.o
 obj-$(CONFIG_CRYPTO_TEA) += tea.o
crypto/cast5.c deleted +0 -809

809 lines not on this page · raw message

crypto/cast5_generic.c new file +822 -0

822 lines not on this page · raw message

include/crypto/cast5.h new file +22 -0
new file mode 100644
index 0000000..dcb90c1
@@ -0,0 +1,22 @@
+#ifndef _CRYPTO_CAST5_H
+#define _CRYPTO_CAST5_H
+
+#include <linux/types.h>
+#include <linux/crypto.h>
+
+#define CAST5_BLOCK_SIZE 8
+#define CAST5_MIN_KEY_SIZE 5
+#define CAST5_MAX_KEY_SIZE 16
+
+struct cast5_ctx {
+	u32 Km[16];
+	u8 Kr[16];
+	int rr;	/* rr ? rounds = 12 : rounds = 16; (rfc 2144) */
+};
+
+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_decrypt(struct cast5_ctx *ctx, u8 *dst, const u8 *src);
+
+#endif
Signature · 1 line
1.7.2.5
#2 lore raw

PATCH 2/6 crypto: testmgr - add larger cast5 testvectors

In reply to Johannes Goetzfried

New ECB, CBC and CTR testvectors for cast5. We need larger testvectors to check parallel code paths in the optimized implementation. Tests have also been added to the tcrypt module.

---
 crypto/tcrypt.c  |   32 +++
 crypto/tcrypt.h  |    1 +
 crypto/testmgr.c |   30 ++
 crypto/testmgr.h |  810 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 871 insertions(+), 2 deletions(-)
crypto/tcrypt.c +32 -0
index 5cf2ccb..a94bbd7 100644
@@ -1037,6 +1037,8 @@ static int do_test(int m)
 
 	case 14:
 		ret += tcrypt_test("ecb(cast5)");
+		ret += tcrypt_test("cbc(cast5)");
+		ret += tcrypt_test("ctr(cast5)");
 		break;
 
 	case 15:
@@ -1359,6 +1361,21 @@ static int do_test(int m)
 				  speed_template_8);
 		break;
 
+	case 209:
+		test_cipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0,
+				  speed_template_8_16);
+		test_cipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0,
+				  speed_template_8_16);
+		test_cipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0,
+				  speed_template_8_16);
+		test_cipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0,
+				  speed_template_8_16);
+		test_cipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0,
+				  speed_template_8_16);
+		test_cipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0,
+				  speed_template_8_16);
+		break;
+
 	case 300:
 		/* fall through */
 
@@ -1639,6 +1656,21 @@ static int do_test(int m)
 				   speed_template_8);
 		break;
 
+	case 506:
+		test_acipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0,
+				   speed_template_8_16);
+		test_acipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0,
+				   speed_template_8_16);
+		test_acipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0,
+				   speed_template_8_16);
+		test_acipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0,
+				   speed_template_8_16);
+		test_acipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0,
+				   speed_template_8_16);
+		test_acipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0,
+				   speed_template_8_16);
+		break;
+
 	case 1000:
 		test_available();
 		break;
crypto/tcrypt.h +1 -0
index 5be1fc8..cd20685 100644
@@ -47,6 +47,7 @@ static struct cipher_speed_template des3_speed_template[] = {
  */
 static u8 speed_template_8[] = {8, 0};
 static u8 speed_template_24[] = {24, 0};
+static u8 speed_template_8_16[] = {8, 16, 0};
 static u8 speed_template_8_32[] = {8, 32, 0};
 static u8 speed_template_16_32[] = {16, 32, 0};
 static u8 speed_template_16_24_32[] = {16, 24, 32, 0};
crypto/testmgr.c +30 -0
index a2ca743..7a91e54 100644
@@ -1818,6 +1818,21 @@ static const struct alg_test_desc alg_test_descs[] = {
 			}
 		}
 	}, {
+		.alg = "cbc(cast5)",
+		.test = alg_test_skcipher,
+		.suite = {
+			.cipher = {
+				.enc = {
+					.vecs = cast5_cbc_enc_tv_template,
+					.count = CAST5_CBC_ENC_TEST_VECTORS
+				},
+				.dec = {
+					.vecs = cast5_cbc_dec_tv_template,
+					.count = CAST5_CBC_DEC_TEST_VECTORS
+				}
+			}
+		}
+	}, {
 		.alg = "cbc(des)",
 		.test = alg_test_skcipher,
 		.suite = {
@@ -2054,6 +2069,21 @@ static const struct alg_test_desc alg_test_descs[] = {
 			}
 		}
 	}, {
+		.alg = "ctr(cast5)",
+		.test = alg_test_skcipher,
+		.suite = {
+			.cipher = {
+				.enc = {
+					.vecs = cast5_ctr_enc_tv_template,
+					.count = CAST5_CTR_ENC_TEST_VECTORS
+				},
+				.dec = {
+					.vecs = cast5_ctr_dec_tv_template,
+					.count = CAST5_CTR_DEC_TEST_VECTORS
+				}
+			}
+		}
+	}, {
 		.alg = "ctr(serpent)",
 		.test = alg_test_skcipher,
 		.suite = {
crypto/testmgr.h +808 -2

828 lines not on this page · raw message

Signature · 1 line
1.7.2.5
#3 lore raw

PATCH 3/6 crypto: cast5 - add x86_64/avx assembler implementation

In reply to Johannes Goetzfried

This patch adds a x86_64/avx assembler implementation of the Cast5 block cipher. The implementation processes sixteen blocks in parallel (four 4 block chunk AVX operations). The table-lookups are done in general-purpose registers. For small blocksizes the functions from the generic module are called. A good performance increase is provided for blocksizes greater or equal to 128B.

Patch has been tested with tcrypt and automated filesystem tests.

Tcrypt benchmark results:

Intel Core i5-2500 CPU (fam:6, model:42, step:7)

cast5-avx-x86_64 vs. cast5-generic
64bit key:

size    ecb-enc ecb-dec cbc-enc cbc-dec ctr-enc ctr-dec
16B     0.99x   0.99x   1.00x   1.00x   1.02x   1.01x
64B     1.00x   1.00x   0.98x   1.00x   1.01x   1.02x
256B    2.03x   2.01x   0.95x   2.11x   2.12x   2.13x
1024B   2.30x   2.24x   0.95x   2.29x   2.35x   2.35x
8192B   2.31x   2.27x   0.95x   2.31x   2.39x   2.39x

128bit key:

size    ecb-enc ecb-dec cbc-enc cbc-dec ctr-enc ctr-dec
16B     0.99x   0.99x   1.00x   1.00x   1.01x   1.01x
64B     1.00x   1.00x   0.98x   1.01x   1.02x   1.01x
256B    2.17x   2.13x   0.96x   2.19x   2.19x   2.19x
1024B   2.29x   2.32x   0.95x   2.34x   2.37x   2.38x
8192B   2.35x   2.32x   0.95x   2.35x   2.39x   2.39x
---
 arch/x86/crypto/Makefile                  |    2 +
 arch/x86/crypto/cast5-avx-x86_64-asm_64.S |  323 ++++++++++++++++++
 arch/x86/crypto/cast5_avx_glue.c          |  530 +++++++++++++++++++++++++++++
 crypto/Kconfig                            |   14 +
 crypto/testmgr.c                          |   60 ++++
 5 files changed, 929 insertions(+), 0 deletions(-)
 create mode 100644 arch/x86/crypto/cast5-avx-x86_64-asm_64.S
 create mode 100644 arch/x86/crypto/cast5_avx_glue.c
arch/x86/crypto/Makefile +2 -0
index e908e5d..565e82b 100644
@@ -12,6 +12,7 @@ obj-$(CONFIG_CRYPTO_SERPENT_SSE2_586) += serpent-sse2-i586.o
 
 obj-$(CONFIG_CRYPTO_AES_X86_64) += aes-x86_64.o
 obj-$(CONFIG_CRYPTO_CAMELLIA_X86_64) += camellia-x86_64.o
+obj-$(CONFIG_CRYPTO_CAST5_AVX_X86_64) += cast5-avx-x86_64.o
 obj-$(CONFIG_CRYPTO_BLOWFISH_X86_64) += blowfish-x86_64.o
 obj-$(CONFIG_CRYPTO_TWOFISH_X86_64) += twofish-x86_64.o
 obj-$(CONFIG_CRYPTO_TWOFISH_X86_64_3WAY) += twofish-x86_64-3way.o
@@ -32,6 +33,7 @@ serpent-sse2-i586-y := serpent-sse2-i586-asm_32.o serpent_sse2_glue.o
 
 aes-x86_64-y := aes-x86_64-asm_64.o aes_glue.o
 camellia-x86_64-y := camellia-x86_64-asm_64.o camellia_glue.o
+cast5-avx-x86_64-y := cast5-avx-x86_64-asm_64.o cast5_avx_glue.o
 blowfish-x86_64-y := blowfish-x86_64-asm_64.o blowfish_glue.o
 twofish-x86_64-y := twofish-x86_64-asm_64.o twofish_glue.o
 twofish-x86_64-3way-y := twofish-x86_64-asm_64-3way.o twofish_glue_3way.o
arch/x86/crypto/cast5-avx-x86_64-asm_64.S new file +323 -0

323 lines not on this page · raw message

arch/x86/crypto/cast5_avx_glue.c new file +530 -0

530 lines not on this page · raw message

crypto/Kconfig +14 -0
index a323805..cda97fc 100644
@@ -692,6 +692,20 @@ config CRYPTO_CAST5
 	  The CAST5 encryption algorithm (synonymous with CAST-128) is
 	  described in RFC2144.
 
+config CRYPTO_CAST5_AVX_X86_64
+	tristate "CAST5 (CAST-128) cipher algorithm (x86_64/AVX)"
+	depends on X86 && 64BIT
+	select CRYPTO_ALGAPI
+	select CRYPTO_CRYPTD
+	select CRYPTO_ABLK_HELPER_X86
+	select CRYPTO_CAST5
+	help
+	  The CAST5 encryption algorithm (synonymous with CAST-128) is
+	  described in RFC2144.
+
+	  This module provides the Cast5 cipher algorithm that processes
+	  sixteen blocks parallel using the AVX instruction set.
+
 config CRYPTO_CAST6
 	tristate "CAST6 (CAST-256) cipher algorithm"
 	select CRYPTO_ALGAPI
crypto/testmgr.c +60 -0

84 lines not on this page · raw message

Signature · 1 line
1.7.2.5
#4 lore raw

PATCH 4/6 crypto: cast6 - prepare generic module for optimized implementations

In reply to Johannes Goetzfried

Rename cast6 module to cast6_generic to allow autoloading of optimized implementations. Generic functions and s-boxes are exported to be able to use them within optimized implementations.

---
 crypto/Makefile        |    2 +-
 crypto/cast6.c         |  547 ----------------------------------------------
 crypto/cast6_generic.c |  566 ++++++++++++++++++++++++++++++++++++++++++++++++
 include/crypto/cast6.h |   23 ++
 4 files changed, 590 insertions(+), 548 deletions(-)
 delete mode 100644 crypto/cast6.c
 create mode 100644 crypto/cast6_generic.c
 create mode 100644 include/crypto/cast6.h
crypto/Makefile +1 -1
index a56821e..396966d 100644
@@ -69,7 +69,7 @@ obj-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o
 obj-$(CONFIG_CRYPTO_AES) += aes_generic.o
 obj-$(CONFIG_CRYPTO_CAMELLIA) += camellia_generic.o
 obj-$(CONFIG_CRYPTO_CAST5) += cast5_generic.o
-obj-$(CONFIG_CRYPTO_CAST6) += cast6.o
+obj-$(CONFIG_CRYPTO_CAST6) += cast6_generic.o
 obj-$(CONFIG_CRYPTO_ARC4) += arc4.o
 obj-$(CONFIG_CRYPTO_TEA) += tea.o
 obj-$(CONFIG_CRYPTO_KHAZAD) += khazad.o
crypto/cast6.c deleted +0 -547

547 lines not on this page · raw message

crypto/cast6_generic.c new file +566 -0

566 lines not on this page · raw message

include/crypto/cast6.h new file +23 -0
new file mode 100644
index 0000000..02dde6b
@@ -0,0 +1,23 @@
+#ifndef _CRYPTO_CAST6_H
+#define _CRYPTO_CAST6_H
+
+#include <linux/types.h>
+#include <linux/crypto.h>
+
+#define CAST6_BLOCK_SIZE 16
+#define CAST6_MIN_KEY_SIZE 16
+#define CAST6_MAX_KEY_SIZE 32
+
+struct cast6_ctx {
+	u32 Km[12][4];
+	u8 Kr[12][4];
+};
+
+int __cast6_setkey(struct cast6_ctx *ctx, const u8 *key,
+		   unsigned int keylen, u32 *flags);
+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_decrypt(struct cast6_ctx *ctx, u8 *dst, const u8 *src);
+
+#endif
Signature · 1 line
1.7.2.5
#5 lore raw

PATCH 5/6 crypto: testmgr - add larger cast6 testvectors

In reply to Johannes Goetzfried

New ECB, CBC, CTR, LRW and XTS testvectors for cast6. We need larger testvectors to check parallel code paths in the optimized implementation. Tests have also been added to the tcrypt module.

---
 crypto/tcrypt.c  |   50 ++
 crypto/testmgr.c |   60 +++
 crypto/testmgr.h | 1412 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 1520 insertions(+), 2 deletions(-)
crypto/tcrypt.c +50 -0
index a94bbd7..871076b 100644
@@ -1043,6 +1043,10 @@ static int do_test(int m)
 
 	case 15:
 		ret += tcrypt_test("ecb(cast6)");
+		ret += tcrypt_test("cbc(cast6)");
+		ret += tcrypt_test("ctr(cast6)");
+		ret += tcrypt_test("lrw(cast6)");
+		ret += tcrypt_test("xts(cast6)");
 		break;
 
 	case 16:
@@ -1376,6 +1380,29 @@ static int do_test(int m)
 				  speed_template_8_16);
 		break;
 
+	case 210:
+		test_cipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0,
+				  speed_template_16_32);
+		test_cipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0,
+				  speed_template_16_32);
+		test_cipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0,
+				  speed_template_16_32);
+		test_cipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0,
+				  speed_template_16_32);
+		test_cipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0,
+				  speed_template_16_32);
+		test_cipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0,
+				  speed_template_16_32);
+		test_cipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0,
+				  speed_template_32_48);
+		test_cipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0,
+				  speed_template_32_48);
+		test_cipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0,
+				  speed_template_32_64);
+		test_cipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0,
+				  speed_template_32_64);
+		break;
+
 	case 300:
 		/* fall through */
 
@@ -1671,6 +1698,29 @@ static int do_test(int m)
 				   speed_template_8_16);
 		break;
 
+	case 507:
+		test_acipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0,
+				   speed_template_16_32);
+		test_acipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0,
+				   speed_template_16_32);
+		test_acipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0,
+				   speed_template_16_32);
+		test_acipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0,
+				   speed_template_16_32);
+		test_acipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0,
+				   speed_template_16_32);
+		test_acipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0,
+				   speed_template_16_32);
+		test_acipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0,
+				   speed_template_32_48);
+		test_acipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0,
+				   speed_template_32_48);
+		test_acipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0,
+				   speed_template_32_64);
+		test_acipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0,
+				   speed_template_32_64);
+		break;
+
 	case 1000:
 		test_available();
 		break;
crypto/testmgr.c +60 -0

84 lines not on this page · raw message

crypto/testmgr.h +1410 -2

1,430 lines not on this page · raw message

Signature · 1 line
1.7.2.5
#6 lore raw

PATCH 6/6 crypto: cast6 - add x86_64/avx assembler implementation

In reply to Johannes Goetzfried

This patch adds a x86_64/avx assembler implementation of the Cast6 block cipher. The implementation processes eight blocks in parallel (two 4 block chunk AVX operations). The table-lookups are done in general-purpose registers. For small blocksizes the functions from the generic module are called. A good performance increase is provided for blocksizes greater or equal to 128B.

Patch has been tested with tcrypt and automated filesystem tests.

Tcrypt benchmark results:

Intel Core i5-2500 CPU (fam:6, model:42, step:7)

cast6-avx-x86_64 vs. cast6-generic
128bit key: (lrw:256bit) (xts:256bit)

size    ecb-enc ecb-dec cbc-enc cbc-dec ctr-enc ctr-dec lrw-enc lrw-dec xts-enc xts-dec
16B     0.97x   1.00x   1.01x   1.01x   0.99x   0.97x   0.98x   1.01x   0.96x   0.98x
64B     0.98x   0.99x   1.02x   1.01x   0.99x   1.00x   1.01x   0.99x   1.00x   0.99x
256B    1.77x   1.84x   0.99x   1.85x   1.77x   1.77x   1.70x   1.74x   1.69x   1.72x
1024B   1.93x   1.95x   0.99x   1.96x   1.93x   1.93x   1.84x   1.85x   1.89x   1.87x
8192B   1.91x   1.95x   0.99x   1.97x   1.95x   1.91x   1.86x   1.87x   1.93x   1.90x

256bit key: (lrw:384bit) (xts:512bit)

size    ecb-enc ecb-dec cbc-enc cbc-dec ctr-enc ctr-dec lrw-enc lrw-dec xts-enc xts-dec
16B     0.97x   0.99x   1.02x   1.01x   0.98x   0.99x   1.00x   1.00x   0.98x   0.98x
64B     0.98x   0.99x   1.01x   1.00x   1.00x   1.00x   1.01x   1.01x   0.97x   1.00x
256B    1.77x   1.83x   1.00x   1.86x   1.79x   1.78x   1.70x   1.76x   1.71x   1.69x
1024B   1.92x   1.95x   0.99x   1.96x   1.93x   1.93x   1.83x   1.86x   1.89x   1.87x
8192B   1.94x   1.95x   0.99x   1.97x   1.95x   1.95x   1.87x   1.87x   1.93x   1.91x
---
 arch/x86/crypto/Makefile                  |    2 +
 arch/x86/crypto/cast6-avx-x86_64-asm_64.S |  336 +++++++++++++++
 arch/x86/crypto/cast6_avx_glue.c          |  648 +++++++++++++++++++++++++++++
 crypto/Kconfig                            |   17 +
 crypto/testmgr.c                          |   60 +++
 5 files changed, 1063 insertions(+), 0 deletions(-)
 create mode 100644 arch/x86/crypto/cast6-avx-x86_64-asm_64.S
 create mode 100644 arch/x86/crypto/cast6_avx_glue.c
arch/x86/crypto/Makefile +2 -0
index 565e82b..5bacb4a 100644
@@ -13,6 +13,7 @@ obj-$(CONFIG_CRYPTO_SERPENT_SSE2_586) += serpent-sse2-i586.o
 obj-$(CONFIG_CRYPTO_AES_X86_64) += aes-x86_64.o
 obj-$(CONFIG_CRYPTO_CAMELLIA_X86_64) += camellia-x86_64.o
 obj-$(CONFIG_CRYPTO_CAST5_AVX_X86_64) += cast5-avx-x86_64.o
+obj-$(CONFIG_CRYPTO_CAST6_AVX_X86_64) += cast6-avx-x86_64.o
 obj-$(CONFIG_CRYPTO_BLOWFISH_X86_64) += blowfish-x86_64.o
 obj-$(CONFIG_CRYPTO_TWOFISH_X86_64) += twofish-x86_64.o
 obj-$(CONFIG_CRYPTO_TWOFISH_X86_64_3WAY) += twofish-x86_64-3way.o
@@ -34,6 +35,7 @@ serpent-sse2-i586-y := serpent-sse2-i586-asm_32.o serpent_sse2_glue.o
 aes-x86_64-y := aes-x86_64-asm_64.o aes_glue.o
 camellia-x86_64-y := camellia-x86_64-asm_64.o camellia_glue.o
 cast5-avx-x86_64-y := cast5-avx-x86_64-asm_64.o cast5_avx_glue.o
+cast6-avx-x86_64-y := cast6-avx-x86_64-asm_64.o cast6_avx_glue.o
 blowfish-x86_64-y := blowfish-x86_64-asm_64.o blowfish_glue.o
 twofish-x86_64-y := twofish-x86_64-asm_64.o twofish_glue.o
 twofish-x86_64-3way-y := twofish-x86_64-asm_64-3way.o twofish_glue_3way.o
arch/x86/crypto/cast6-avx-x86_64-asm_64.S new file +336 -0

336 lines not on this page · raw message

arch/x86/crypto/cast6_avx_glue.c new file +648 -0

648 lines not on this page · raw message

crypto/Kconfig +17 -0
index cda97fc..fe8ed62 100644
@@ -713,6 +713,23 @@ config CRYPTO_CAST6
 	  The CAST6 encryption algorithm (synonymous with CAST-256) is
 	  described in RFC2612.
 
+config CRYPTO_CAST6_AVX_X86_64
+	tristate "CAST6 (CAST-256) cipher algorithm (x86_64/AVX)"
+	depends on X86 && 64BIT
+	select CRYPTO_ALGAPI
+	select CRYPTO_CRYPTD
+	select CRYPTO_ABLK_HELPER_X86
+	select CRYPTO_GLUE_HELPER_X86
+	select CRYPTO_CAST6
+	select CRYPTO_LRW
+	select CRYPTO_XTS
+	help
+	  The CAST6 encryption algorithm (synonymous with CAST-256) is
+	  described in RFC2612.
+
+	  This module provides the Cast6 cipher algorithm that processes
+	  eight blocks parallel using the AVX instruction set.
+
 config CRYPTO_DES
 	tristate "DES and Triple DES EDE cipher algorithms"
 	select CRYPTO_ALGAPI
crypto/testmgr.c +60 -0

84 lines not on this page · raw message

Signature · 1 line
1.7.2.5
#7 lore raw
In reply to Johannes Goetzfried
Quoted 10 lines · Johannes Goetzfried

This patchset adds x86_64/avx assembler implementations of the Cast5 and the Cast6 cipher.

Johannes Goetzfried (6):
crypto: cast5 - prepare generic module for optimized implementations
crypto: testmgr - add larger cast5 testvectors
crypto: cast5 - add x86_64/avx assembler implementation
crypto: cast6 - prepare generic module for optimized implementations
crypto: testmgr - add larger cast6 testvectors
crypto: cast6 - add x86_64/avx assembler implementation

Nice work. All applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt