crypto: tcrypt - add async speed test for camellia cipher
Subsystems (3)
PATCH 1/2 crypto: tcrypt - add async speed test for camellia cipher
--- crypto/tcrypt.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
crypto/tcrypt.c +23 -0
@@ -1728,6 +1728,29 @@ static int do_test(int m) speed_template_32_64);break ; +case 508 : +test_acipher_speed ("ecb(camellia)" ,ENCRYPT , sec,NULL ,0 , + speed_template_16_32); +test_acipher_speed ("ecb(camellia)" ,DECRYPT , sec,NULL ,0 , + speed_template_16_32); +test_acipher_speed ("cbc(camellia)" ,ENCRYPT , sec,NULL ,0 , + speed_template_16_32); +test_acipher_speed ("cbc(camellia)" ,DECRYPT , sec,NULL ,0 , + speed_template_16_32); +test_acipher_speed ("ctr(camellia)" ,ENCRYPT , sec,NULL ,0 , + speed_template_16_32); +test_acipher_speed ("ctr(camellia)" ,DECRYPT , sec,NULL ,0 , + speed_template_16_32); +test_acipher_speed ("lrw(camellia)" ,ENCRYPT , sec,NULL ,0 , + speed_template_32_48); +test_acipher_speed ("lrw(camellia)" ,DECRYPT , sec,NULL ,0 , + speed_template_32_48); +test_acipher_speed ("xts(camellia)" ,ENCRYPT , sec,NULL ,0 , + speed_template_32_64); +test_acipher_speed ("xts(camellia)" ,DECRYPT , sec,NULL ,0 , + speed_template_32_64); +break ; +case 1000 :test_available ();break ;
PATCH 2/2 crypto: camellia - add AES-NI/AVX/x86_64 assembler implementation of camellia cipher
This patch adds AES-NI/AVX/x86_64 assembler implementation of Camellia block cipher. Implementation process data in sixteen block chunks, which are byte-sliced and AES SubBytes is reused for Camellia s-box with help of pre- and post-filtering.
Patch has been tested with tcrypt and automated filesystem tests.
tcrypt test results:
Intel Core i5-2450M:
camellia-aesni-avx vs camellia-asm-x86_64-2way:
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.98x 0.96x 0.99x 0.96x 0.96x 0.95x 0.95x 0.94x 0.97x 0.98x 64B 0.99x 0.98x 1.00x 0.98x 0.98x 0.99x 0.98x 0.93x 0.99x 0.98x 256B 2.28x 2.28x 1.01x 2.29x 2.25x 2.24x 1.96x 1.97x 1.91x 1.90x 1024B 2.57x 2.56x 1.00x 2.57x 2.51x 2.53x 2.19x 2.17x 2.19x 2.22x 8192B 2.49x 2.49x 1.00x 2.53x 2.48x 2.49x 2.17x 2.17x 2.22x 2.22x
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.98x 0.99x 0.97x 0.97x 0.96x 0.97x 0.98x 0.98x 0.99x 64B 1.00x 1.00x 1.01x 0.99x 0.98x 0.99x 0.99x 0.99x 0.99x 0.99x 256B 2.37x 2.37x 1.01x 2.39x 2.35x 2.33x 2.10x 2.11x 1.99x 2.02x 1024B 2.58x 2.60x 1.00x 2.58x 2.56x 2.56x 2.28x 2.29x 2.28x 2.29x 8192B 2.50x 2.52x 1.00x 2.56x 2.51x 2.51x 2.24x 2.25x 2.26x 2.29x
--- arch/x86/crypto/Makefile | 3 arch/x86/crypto/camellia-aesni-avx-asm_64.S | 1102 +++++++++++++++++++++++++++ arch/x86/crypto/camellia_aesni_avx_glue.c | 558 ++++++++++++++ crypto/Kconfig | 22 + crypto/testmgr.c | 62 ++ 5 files changed, 1747 insertions(+) create mode 100644 arch/x86/crypto/camellia-aesni-avx-asm_64.S create mode 100644 arch/x86/crypto/camellia_aesni_avx_glue.c
arch/x86/crypto/Makefile +3 -0
@@ -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_CAMELLIA_AESNI_AVX_X86_64) += camellia-aesni-avx-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
@@ -34,6 +35,8 @@ 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 +camellia-aesni-avx-x86_64-y := camellia-aesni-avx-asm_64.o \ + camellia_aesni_avx_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
arch/x86/crypto/camellia-aesni-avx-asm_64.S new file +1102 -0
1,102 lines not on this page · raw message
arch/x86/crypto/camellia_aesni_avx_glue.c new file +558 -0
558 lines not on this page · raw message
crypto/Kconfig +22 -0
@@ -803,6 +803,28 @@ config CRYPTO_CAMELLIA_X86_64 See also: <https://info.isl.ntt.co.jp/crypt/eng/camellia/index_s.html> +config CRYPTO_CAMELLIA_AESNI_AVX_X86_64 + tristate "Camellia cipher algorithm (x86_64/AES-NI/AVX)" + depends on X86 && 64BIT + depends on CRYPTO + select CRYPTO_ALGAPI + select CRYPTO_CRYPTD + select CRYPTO_ABLK_HELPER_X86 + select CRYPTO_GLUE_HELPER_X86 + select CRYPTO_CAMELLIA_X86_64 + select CRYPTO_LRW + select CRYPTO_XTS + help + Camellia cipher algorithm module (x86_64/AES-NI/AVX). + + Camellia is a symmetric key block cipher developed jointly + at NTT and Mitsubishi Electric Corporation. + + The Camellia specifies three key sizes: 128, 192 and 256 bits. + + See also: + <https://info.isl.ntt.co.jp/crypt/eng/camellia/index_s.html> + config CRYPTO_CAMELLIA_SPARC64 tristate "Camellia cipher algorithm (SPARC64)" depends on SPARC64
crypto/testmgr.c +62 -0
86 lines not on this page · raw message
Re: [PATCH 2/2] crypto: camellia - add AES-NI/AVX/x86_64 assembler implementation of camellia cipher
Please ignore this patchset, it's missing one important patch.
-Jussi
Quoting Jussi Kivilinna <[email protected]>:
Quoted 4 lines
This patch adds AES-NI/AVX/x86_64 assembler implementation of Camellia block cipher. Implementation process data in sixteen block chunks, which are byte-sliced and AES SubBytes is reused for Camellia s-box with help of pre- and post-filtering.
From: Jussi Kivilinna <[email protected]>
Date: Tue, 23 Oct 2012 20:57:55 +0300
Quoted 1 line
Signed-off-by Jussi Kivilinna <[email protected]>
Re: [PATCH 2/2] crypto: camellia - add AES-NI/AVX/x86_64 assembler implementation of camellia cipher
In reply to Jussi KivilinnaFrom: Jussi Kivilinna <[email protected]>
Date: Tue, 23 Oct 2012 20:58:01 +0300
Quoted 21 lines
This patch adds AES-NI/AVX/x86_64 assembler implementation of Camellia block cipher. Implementation process data in sixteen block chunks, which are byte-sliced and AES SubBytes is reused for Camellia s-box with help of pre- and post-filtering.
Patch has been tested with tcrypt and automated filesystem tests.
tcrypt test results:
Intel Core i5-2450M:
camellia-aesni-avx vs camellia-asm-x86_64-2way:
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.98x 0.96x 0.99x 0.96x 0.96x 0.95x 0.95x 0.94x 0.97x 0.98x 64B 0.99x 0.98x 1.00x 0.98x 0.98x 0.99x 0.98x 0.93x 0.99x 0.98x 256B 2.28x 2.28x 1.01x 2.29x 2.25x 2.24x 1.96x 1.97x 1.91x 1.90x 1024B 2.57x 2.56x 1.00x 2.57x 2.51x 2.53x 2.19x 2.17x 2.19x 2.22x 8192B 2.49x 2.49x 1.00x 2.53x 2.48x 2.49x 2.17x 2.17x 2.22x 2.22x256bit key: (lrw:384bit) (xts:512bit)
Quoted 8 lines
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.98x 0.99x 0.97x 0.97x 0.96x 0.97x 0.98x 0.98x 0.99x 64B 1.00x 1.00x 1.01x 0.99x 0.98x 0.99x 0.99x 0.99x 0.99x 0.99x 256B 2.37x 2.37x 1.01x 2.39x 2.35x 2.33x 2.10x 2.11x 1.99x 2.02x 1024B 2.58x 2.60x 1.00x 2.58x 2.56x 2.56x 2.28x 2.29x 2.28x 2.29x 8192B 2.50x 2.52x 1.00x 2.56x 2.51x 2.51x 2.24x 2.25x 2.26x 2.29xSigned-off-by Jussi Kivilinna <[email protected]>
Clever :-)