diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-04 12:06:34 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-04 12:06:34 -0400 |
commit | d66e6737d454553e1e62109d8298ede5351178a4 (patch) | |
tree | c28b205045935b111527f461d2b114daa26e4fb8 | |
parent | 612a9aab56a93533e76e3ad91642db7033e03b69 (diff) | |
parent | c9f97a27ceee84998999bf3341e6d5d207b05539 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto update from Herbert Xu:
- Optimised AES/SHA1 for ARM.
- IPsec ESN support in talitos and caam.
- x86_64/avx implementation of cast5/cast6.
- Add/use multi-algorithm registration helpers where possible.
- Added IBM Power7+ in-Nest support.
- Misc fixes.
Fix up trivial conflicts in crypto/Kconfig due to the sparc64 crypto
config options being added next to the new ARM ones.
[ Side note: cut-and-paste duplicate help texts make those conflicts
harder to read than necessary, thanks to git being smart about
minimizing conflicts and maximizing the common parts... ]
* git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (71 commits)
crypto: x86/glue_helper - fix storing of new IV in CBC encryption
crypto: cast5/avx - fix storing of new IV in CBC encryption
crypto: tcrypt - add missing tests for camellia and ghash
crypto: testmgr - make test_aead also test 'dst != src' code paths
crypto: testmgr - make test_skcipher also test 'dst != src' code paths
crypto: testmgr - add test vectors for CTR mode IV increasement
crypto: testmgr - add test vectors for partial ctr(cast5) and ctr(cast6)
crypto: testmgr - allow non-multi page and multi page skcipher tests from same test template
crypto: caam - increase TRNG clocks per sample
crypto, tcrypt: remove local_bh_disable/enable() around local_irq_disable/enable()
crypto: tegra-aes - fix error return code
crypto: crypto4xx - fix error return code
crypto: hifn_795x - fix error return code
crypto: ux500 - fix error return code
crypto: caam - fix error IDs for SEC v5.x RNG4
hwrng: mxc-rnga - Access data via structure
hwrng: mxc-rnga - Adapt clocks to new i.mx clock framework
crypto: caam - add IPsec ESN support
crypto: 842 - remove .cra_list initialization
Revert "[CRYPTO] cast6: inline bloat--"
...
100 files changed, 11457 insertions, 1737 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index d919e3d4a0db..f883fc1b1b46 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -3438,6 +3438,18 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux.git | |||
3438 | S: Maintained | 3438 | S: Maintained |
3439 | F: arch/ia64/ | 3439 | F: arch/ia64/ |
3440 | 3440 | ||
3441 | IBM Power in-Nest Crypto Acceleration | ||
3442 | M: Kent Yoder <key@linux.vnet.ibm.com> | ||
3443 | L: linux-crypto@vger.kernel.org | ||
3444 | S: Supported | ||
3445 | F: drivers/crypto/nx/ | ||
3446 | |||
3447 | IBM Power 842 compression accelerator | ||
3448 | M: Robert Jennings <rcj@linux.vnet.ibm.com> | ||
3449 | S: Supported | ||
3450 | F: drivers/crypto/nx/nx-842.c | ||
3451 | F: include/linux/nx842.h | ||
3452 | |||
3441 | IBM Power Linux RAID adapter | 3453 | IBM Power Linux RAID adapter |
3442 | M: Brian King <brking@us.ibm.com> | 3454 | M: Brian King <brking@us.ibm.com> |
3443 | S: Supported | 3455 | S: Supported |
diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 770da51242c4..b86e57ef146b 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile | |||
@@ -254,6 +254,7 @@ core-$(CONFIG_VFP) += arch/arm/vfp/ | |||
254 | # If we have a machine-specific directory, then include it in the build. | 254 | # If we have a machine-specific directory, then include it in the build. |
255 | core-y += arch/arm/kernel/ arch/arm/mm/ arch/arm/common/ | 255 | core-y += arch/arm/kernel/ arch/arm/mm/ arch/arm/common/ |
256 | core-y += arch/arm/net/ | 256 | core-y += arch/arm/net/ |
257 | core-y += arch/arm/crypto/ | ||
257 | core-y += $(machdirs) $(platdirs) | 258 | core-y += $(machdirs) $(platdirs) |
258 | 259 | ||
259 | drivers-$(CONFIG_OPROFILE) += arch/arm/oprofile/ | 260 | drivers-$(CONFIG_OPROFILE) += arch/arm/oprofile/ |
diff --git a/arch/arm/crypto/Makefile b/arch/arm/crypto/Makefile new file mode 100644 index 000000000000..a2c83851bc90 --- /dev/null +++ b/arch/arm/crypto/Makefile | |||
@@ -0,0 +1,9 @@ | |||
1 | # | ||
2 | # Arch-specific CryptoAPI modules. | ||
3 | # | ||
4 | |||
5 | obj-$(CONFIG_CRYPTO_AES_ARM) += aes-arm.o | ||
6 | obj-$(CONFIG_CRYPTO_SHA1_ARM) += sha1-arm.o | ||
7 | |||
8 | aes-arm-y := aes-armv4.o aes_glue.o | ||
9 | sha1-arm-y := sha1-armv4-large.o sha1_glue.o | ||
diff --git a/arch/arm/crypto/aes-armv4.S b/arch/arm/crypto/aes-armv4.S new file mode 100644 index 000000000000..e59b1d505d6c --- /dev/null +++ b/arch/arm/crypto/aes-armv4.S | |||
@@ -0,0 +1,1112 @@ | |||
1 | #define __ARM_ARCH__ __LINUX_ARM_ARCH__ | ||
2 | @ ==================================================================== | ||
3 | @ Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL | ||
4 | @ project. The module is, however, dual licensed under OpenSSL and | ||
5 | @ CRYPTOGAMS licenses depending on where you obtain it. For further | ||
6 | @ details see http://www.openssl.org/~appro/cryptogams/. | ||
7 | @ ==================================================================== | ||
8 | |||
9 | @ AES for ARMv4 | ||
10 | |||
11 | @ January 2007. | ||
12 | @ | ||
13 | @ Code uses single 1K S-box and is >2 times faster than code generated | ||
14 | @ by gcc-3.4.1. This is thanks to unique feature of ARMv4 ISA, which | ||
15 | @ allows to merge logical or arithmetic operation with shift or rotate | ||
16 | @ in one instruction and emit combined result every cycle. The module | ||
17 | @ is endian-neutral. The performance is ~42 cycles/byte for 128-bit | ||
18 | @ key [on single-issue Xscale PXA250 core]. | ||
19 | |||
20 | @ May 2007. | ||
21 | @ | ||
22 | @ AES_set_[en|de]crypt_key is added. | ||
23 | |||
24 | @ July 2010. | ||
25 | @ | ||
26 | @ Rescheduling for dual-issue pipeline resulted in 12% improvement on | ||
27 | @ Cortex A8 core and ~25 cycles per byte processed with 128-bit key. | ||
28 | |||
29 | @ February 2011. | ||
30 | @ | ||
31 | @ Profiler-assisted and platform-specific optimization resulted in 16% | ||
32 | @ improvement on Cortex A8 core and ~21.5 cycles per byte. | ||
33 | |||
34 | @ A little glue here to select the correct code below for the ARM CPU | ||
35 | @ that is being targetted. | ||
36 | |||
37 | .text | ||
38 | .code 32 | ||
39 | |||
40 | .type AES_Te,%object | ||
41 | .align 5 | ||
42 | AES_Te: | ||
43 | .word 0xc66363a5, 0xf87c7c84, 0xee777799, 0xf67b7b8d | ||
44 | .word 0xfff2f20d, 0xd66b6bbd, 0xde6f6fb1, 0x91c5c554 | ||
45 | .word 0x60303050, 0x02010103, 0xce6767a9, 0x562b2b7d | ||
46 | .word 0xe7fefe19, 0xb5d7d762, 0x4dababe6, 0xec76769a | ||
47 | .word 0x8fcaca45, 0x1f82829d, 0x89c9c940, 0xfa7d7d87 | ||
48 | .word 0xeffafa15, 0xb25959eb, 0x8e4747c9, 0xfbf0f00b | ||
49 | .word 0x41adadec, 0xb3d4d467, 0x5fa2a2fd, 0x45afafea | ||
50 | .word 0x239c9cbf, 0x53a4a4f7, 0xe4727296, 0x9bc0c05b | ||
51 | .word 0x75b7b7c2, 0xe1fdfd1c, 0x3d9393ae, 0x4c26266a | ||
52 | .word 0x6c36365a, 0x7e3f3f41, 0xf5f7f702, 0x83cccc4f | ||
53 | .word 0x6834345c, 0x51a5a5f4, 0xd1e5e534, 0xf9f1f108 | ||
54 | .word 0xe2717193, 0xabd8d873, 0x62313153, 0x2a15153f | ||
55 | .word 0x0804040c, 0x95c7c752, 0x46232365, 0x9dc3c35e | ||
56 | .word 0x30181828, 0x379696a1, 0x0a05050f, 0x2f9a9ab5 | ||
57 | .word 0x0e070709, 0x24121236, 0x1b80809b, 0xdfe2e23d | ||
58 | .word 0xcdebeb26, 0x4e272769, 0x7fb2b2cd, 0xea75759f | ||
59 | .word 0x1209091b, 0x1d83839e, 0x582c2c74, 0x341a1a2e | ||
60 | .word 0x361b1b2d, 0xdc6e6eb2, 0xb45a5aee, 0x5ba0a0fb | ||
61 | .word 0xa45252f6, 0x763b3b4d, 0xb7d6d661, 0x7db3b3ce | ||
62 | .word 0x5229297b, 0xdde3e33e, 0x5e2f2f71, 0x13848497 | ||
63 | .word 0xa65353f5, 0xb9d1d168, 0x00000000, 0xc1eded2c | ||
64 | .word 0x40202060, 0xe3fcfc1f, 0x79b1b1c8, 0xb65b5bed | ||
65 | .word 0xd46a6abe, 0x8dcbcb46, 0x67bebed9, 0x7239394b | ||
66 | .word 0x944a4ade, 0x984c4cd4, 0xb05858e8, 0x85cfcf4a | ||
67 | .word 0xbbd0d06b, 0xc5efef2a, 0x4faaaae5, 0xedfbfb16 | ||
68 | .word 0x864343c5, 0x9a4d4dd7, 0x66333355, 0x11858594 | ||
69 | .word 0x8a4545cf, 0xe9f9f910, 0x04020206, 0xfe7f7f81 | ||
70 | .word 0xa05050f0, 0x783c3c44, 0x259f9fba, 0x4ba8a8e3 | ||
71 | .word 0xa25151f3, 0x5da3a3fe, 0x804040c0, 0x058f8f8a | ||
72 | .word 0x3f9292ad, 0x219d9dbc, 0x70383848, 0xf1f5f504 | ||
73 | .word 0x63bcbcdf, 0x77b6b6c1, 0xafdada75, 0x42212163 | ||
74 | .word 0x20101030, 0xe5ffff1a, 0xfdf3f30e, 0xbfd2d26d | ||
75 | .word 0x81cdcd4c, 0x180c0c14, 0x26131335, 0xc3ecec2f | ||
76 | .word 0xbe5f5fe1, 0x359797a2, 0x884444cc, 0x2e171739 | ||
77 | .word 0x93c4c457, 0x55a7a7f2, 0xfc7e7e82, 0x7a3d3d47 | ||
78 | .word 0xc86464ac, 0xba5d5de7, 0x3219192b, 0xe6737395 | ||
79 | .word 0xc06060a0, 0x19818198, 0x9e4f4fd1, 0xa3dcdc7f | ||
80 | .word 0x44222266, 0x542a2a7e, 0x3b9090ab, 0x0b888883 | ||
81 | .word 0x8c4646ca, 0xc7eeee29, 0x6bb8b8d3, 0x2814143c | ||
82 | .word 0xa7dede79, 0xbc5e5ee2, 0x160b0b1d, 0xaddbdb76 | ||
83 | .word 0xdbe0e03b, 0x64323256, 0x743a3a4e, 0x140a0a1e | ||
84 | .word 0x924949db, 0x0c06060a, 0x4824246c, 0xb85c5ce4 | ||
85 | .word 0x9fc2c25d, 0xbdd3d36e, 0x43acacef, 0xc46262a6 | ||
86 | .word 0x399191a8, 0x319595a4, 0xd3e4e437, 0xf279798b | ||
87 | .word 0xd5e7e732, 0x8bc8c843, 0x6e373759, 0xda6d6db7 | ||
88 | .word 0x018d8d8c, 0xb1d5d564, 0x9c4e4ed2, 0x49a9a9e0 | ||
89 | .word 0xd86c6cb4, 0xac5656fa, 0xf3f4f407, 0xcfeaea25 | ||
90 | .word 0xca6565af, 0xf47a7a8e, 0x47aeaee9, 0x10080818 | ||
91 | .word 0x6fbabad5, 0xf0787888, 0x4a25256f, 0x5c2e2e72 | ||
92 | .word 0x381c1c24, 0x57a6a6f1, 0x73b4b4c7, 0x97c6c651 | ||
93 | .word 0xcbe8e823, 0xa1dddd7c, 0xe874749c, 0x3e1f1f21 | ||
94 | .word 0x964b4bdd, 0x61bdbddc, 0x0d8b8b86, 0x0f8a8a85 | ||
95 | .word 0xe0707090, 0x7c3e3e42, 0x71b5b5c4, 0xcc6666aa | ||
96 | .word 0x904848d8, 0x06030305, 0xf7f6f601, 0x1c0e0e12 | ||
97 | .word 0xc26161a3, 0x6a35355f, 0xae5757f9, 0x69b9b9d0 | ||
98 | .word 0x17868691, 0x99c1c158, 0x3a1d1d27, 0x279e9eb9 | ||
99 | .word 0xd9e1e138, 0xebf8f813, 0x2b9898b3, 0x22111133 | ||
100 | .word 0xd26969bb, 0xa9d9d970, 0x078e8e89, 0x339494a7 | ||
101 | .word 0x2d9b9bb6, 0x3c1e1e22, 0x15878792, 0xc9e9e920 | ||
102 | .word 0x87cece49, 0xaa5555ff, 0x50282878, 0xa5dfdf7a | ||
103 | .word 0x038c8c8f, 0x59a1a1f8, 0x09898980, 0x1a0d0d17 | ||
104 | .word 0x65bfbfda, 0xd7e6e631, 0x844242c6, 0xd06868b8 | ||
105 | .word 0x824141c3, 0x299999b0, 0x5a2d2d77, 0x1e0f0f11 | ||
106 | .word 0x7bb0b0cb, 0xa85454fc, 0x6dbbbbd6, 0x2c16163a | ||
107 | @ Te4[256] | ||
108 | .byte 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5 | ||
109 | .byte 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76 | ||
110 | .byte 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0 | ||
111 | .byte 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0 | ||
112 | .byte 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc | ||
113 | .byte 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15 | ||
114 | .byte 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a | ||
115 | .byte 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75 | ||
116 | .byte 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0 | ||
117 | .byte 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84 | ||
118 | .byte 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b | ||
119 | .byte 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf | ||
120 | .byte 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85 | ||
121 | .byte 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8 | ||
122 | .byte 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5 | ||
123 | .byte 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2 | ||
124 | .byte 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17 | ||
125 | .byte 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73 | ||
126 | .byte 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88 | ||
127 | .byte 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb | ||
128 | .byte 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c | ||
129 | .byte 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79 | ||
130 | .byte 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9 | ||
131 | .byte 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08 | ||
132 | .byte 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6 | ||
133 | .byte 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a | ||
134 | .byte 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e | ||
135 | .byte 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e | ||
136 | .byte 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94 | ||
137 | .byte 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf | ||
138 | .byte 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68 | ||
139 | .byte 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 | ||
140 | @ rcon[] | ||
141 | .word 0x01000000, 0x02000000, 0x04000000, 0x08000000 | ||
142 | .word 0x10000000, 0x20000000, 0x40000000, 0x80000000 | ||
143 | .word 0x1B000000, 0x36000000, 0, 0, 0, 0, 0, 0 | ||
144 | .size AES_Te,.-AES_Te | ||
145 | |||
146 | @ void AES_encrypt(const unsigned char *in, unsigned char *out, | ||
147 | @ const AES_KEY *key) { | ||
148 | .global AES_encrypt | ||
149 | .type AES_encrypt,%function | ||
150 | .align 5 | ||
151 | AES_encrypt: | ||
152 | sub r3,pc,#8 @ AES_encrypt | ||
153 | stmdb sp!,{r1,r4-r12,lr} | ||
154 | mov r12,r0 @ inp | ||
155 | mov r11,r2 | ||
156 | sub r10,r3,#AES_encrypt-AES_Te @ Te | ||
157 | #if __ARM_ARCH__<7 | ||
158 | ldrb r0,[r12,#3] @ load input data in endian-neutral | ||
159 | ldrb r4,[r12,#2] @ manner... | ||
160 | ldrb r5,[r12,#1] | ||
161 | ldrb r6,[r12,#0] | ||
162 | orr r0,r0,r4,lsl#8 | ||
163 | ldrb r1,[r12,#7] | ||
164 | orr r0,r0,r5,lsl#16 | ||
165 | ldrb r4,[r12,#6] | ||
166 | orr r0,r0,r6,lsl#24 | ||
167 | ldrb r5,[r12,#5] | ||
168 | ldrb r6,[r12,#4] | ||
169 | orr r1,r1,r4,lsl#8 | ||
170 | ldrb r2,[r12,#11] | ||
171 | orr r1,r1,r5,lsl#16 | ||
172 | ldrb r4,[r12,#10] | ||
173 | orr r1,r1,r6,lsl#24 | ||
174 | ldrb r5,[r12,#9] | ||
175 | ldrb r6,[r12,#8] | ||
176 | orr r2,r2,r4,lsl#8 | ||
177 | ldrb r3,[r12,#15] | ||
178 | orr r2,r2,r5,lsl#16 | ||
179 | ldrb r4,[r12,#14] | ||
180 | orr r2,r2,r6,lsl#24 | ||
181 | ldrb r5,[r12,#13] | ||
182 | ldrb r6,[r12,#12] | ||
183 | orr r3,r3,r4,lsl#8 | ||
184 | orr r3,r3,r5,lsl#16 | ||
185 | orr r3,r3,r6,lsl#24 | ||
186 | #else | ||
187 | ldr r0,[r12,#0] | ||
188 | ldr r1,[r12,#4] | ||
189 | ldr r2,[r12,#8] | ||
190 | ldr r3,[r12,#12] | ||
191 | #ifdef __ARMEL__ | ||
192 | rev r0,r0 | ||
193 | rev r1,r1 | ||
194 | rev r2,r2 | ||
195 | rev r3,r3 | ||
196 | #endif | ||
197 | #endif | ||
198 | bl _armv4_AES_encrypt | ||
199 | |||
200 | ldr r12,[sp],#4 @ pop out | ||
201 | #if __ARM_ARCH__>=7 | ||
202 | #ifdef __ARMEL__ | ||
203 | rev r0,r0 | ||
204 | rev r1,r1 | ||
205 | rev r2,r2 | ||
206 | rev r3,r3 | ||
207 | #endif | ||
208 | str r0,[r12,#0] | ||
209 | str r1,[r12,#4] | ||
210 | str r2,[r12,#8] | ||
211 | str r3,[r12,#12] | ||
212 | #else | ||
213 | mov r4,r0,lsr#24 @ write output in endian-neutral | ||
214 | mov r5,r0,lsr#16 @ manner... | ||
215 | mov r6,r0,lsr#8 | ||
216 | strb r4,[r12,#0] | ||
217 | strb r5,[r12,#1] | ||
218 | mov r4,r1,lsr#24 | ||
219 | strb r6,[r12,#2] | ||
220 | mov r5,r1,lsr#16 | ||
221 | strb r0,[r12,#3] | ||
222 | mov r6,r1,lsr#8 | ||
223 | strb r4,[r12,#4] | ||
224 | strb r5,[r12,#5] | ||
225 | mov r4,r2,lsr#24 | ||
226 | strb r6,[r12,#6] | ||
227 | mov r5,r2,lsr#16 | ||
228 | strb r1,[r12,#7] | ||
229 | mov r6,r2,lsr#8 | ||
230 | strb r4,[r12,#8] | ||
231 | strb r5,[r12,#9] | ||
232 | mov r4,r3,lsr#24 | ||
233 | strb r6,[r12,#10] | ||
234 | mov r5,r3,lsr#16 | ||
235 | strb r2,[r12,#11] | ||
236 | mov r6,r3,lsr#8 | ||
237 | strb r4,[r12,#12] | ||
238 | strb r5,[r12,#13] | ||
239 | strb r6,[r12,#14] | ||
240 | strb r3,[r12,#15] | ||
241 | #endif | ||
242 | #if __ARM_ARCH__>=5 | ||
243 | ldmia sp!,{r4-r12,pc} | ||
244 | #else | ||
245 | ldmia sp!,{r4-r12,lr} | ||
246 | tst lr,#1 | ||
247 | moveq pc,lr @ be binary compatible with V4, yet | ||
248 | .word 0xe12fff1e @ interoperable with Thumb ISA:-) | ||
249 | #endif | ||
250 | .size AES_encrypt,.-AES_encrypt | ||
251 | |||
252 | .type _armv4_AES_encrypt,%function | ||
253 | .align 2 | ||
254 | _armv4_AES_encrypt: | ||
255 | str lr,[sp,#-4]! @ push lr | ||
256 | ldmia r11!,{r4-r7} | ||
257 | eor r0,r0,r4 | ||
258 | ldr r12,[r11,#240-16] | ||
259 | eor r1,r1,r5 | ||
260 | eor r2,r2,r6 | ||
261 | eor r3,r3,r7 | ||
262 | sub r12,r12,#1 | ||
263 | mov lr,#255 | ||
264 | |||
265 | and r7,lr,r0 | ||
266 | and r8,lr,r0,lsr#8 | ||
267 | and r9,lr,r0,lsr#16 | ||
268 | mov r0,r0,lsr#24 | ||
269 | .Lenc_loop: | ||
270 | ldr r4,[r10,r7,lsl#2] @ Te3[s0>>0] | ||
271 | and r7,lr,r1,lsr#16 @ i0 | ||
272 | ldr r5,[r10,r8,lsl#2] @ Te2[s0>>8] | ||
273 | and r8,lr,r1 | ||
274 | ldr r6,[r10,r9,lsl#2] @ Te1[s0>>16] | ||
275 | and r9,lr,r1,lsr#8 | ||
276 | ldr r0,[r10,r0,lsl#2] @ Te0[s0>>24] | ||
277 | mov r1,r1,lsr#24 | ||
278 | |||
279 | ldr r7,[r10,r7,lsl#2] @ Te1[s1>>16] | ||
280 | ldr r8,[r10,r8,lsl#2] @ Te3[s1>>0] | ||
281 | ldr r9,[r10,r9,lsl#2] @ Te2[s1>>8] | ||
282 | eor r0,r0,r7,ror#8 | ||
283 | ldr r1,[r10,r1,lsl#2] @ Te0[s1>>24] | ||
284 | and r7,lr,r2,lsr#8 @ i0 | ||
285 | eor r5,r5,r8,ror#8 | ||
286 | and r8,lr,r2,lsr#16 @ i1 | ||
287 | eor r6,r6,r9,ror#8 | ||
288 | and r9,lr,r2 | ||
289 | ldr r7,[r10,r7,lsl#2] @ Te2[s2>>8] | ||
290 | eor r1,r1,r4,ror#24 | ||
291 | ldr r8,[r10,r8,lsl#2] @ Te1[s2>>16] | ||
292 | mov r2,r2,lsr#24 | ||
293 | |||
294 | ldr r9,[r10,r9,lsl#2] @ Te3[s2>>0] | ||
295 | eor r0,r0,r7,ror#16 | ||
296 | ldr r2,[r10,r2,lsl#2] @ Te0[s2>>24] | ||
297 | and r7,lr,r3 @ i0 | ||
298 | eor r1,r1,r8,ror#8 | ||
299 | and r8,lr,r3,lsr#8 @ i1 | ||
300 | eor r6,r6,r9,ror#16 | ||
301 | and r9,lr,r3,lsr#16 @ i2 | ||
302 | ldr r7,[r10,r7,lsl#2] @ Te3[s3>>0] | ||
303 | eor r2,r2,r5,ror#16 | ||
304 | ldr r8,[r10,r8,lsl#2] @ Te2[s3>>8] | ||
305 | mov r3,r3,lsr#24 | ||
306 | |||
307 | ldr r9,[r10,r9,lsl#2] @ Te1[s3>>16] | ||
308 | eor r0,r0,r7,ror#24 | ||
309 | ldr r7,[r11],#16 | ||
310 | eor r1,r1,r8,ror#16 | ||
311 | ldr r3,[r10,r3,lsl#2] @ Te0[s3>>24] | ||
312 | eor r2,r2,r9,ror#8 | ||
313 | ldr r4,[r11,#-12] | ||
314 | eor r3,r3,r6,ror#8 | ||
315 | |||
316 | ldr r5,[r11,#-8] | ||
317 | eor r0,r0,r7 | ||
318 | ldr r6,[r11,#-4] | ||
319 | and r7,lr,r0 | ||
320 | eor r1,r1,r4 | ||
321 | and r8,lr,r0,lsr#8 | ||
322 | eor r2,r2,r5 | ||
323 | and r9,lr,r0,lsr#16 | ||
324 | eor r3,r3,r6 | ||
325 | mov r0,r0,lsr#24 | ||
326 | |||
327 | subs r12,r12,#1 | ||
328 | bne .Lenc_loop | ||
329 | |||
330 | add r10,r10,#2 | ||
331 | |||
332 | ldrb r4,[r10,r7,lsl#2] @ Te4[s0>>0] | ||
333 | and r7,lr,r1,lsr#16 @ i0 | ||
334 | ldrb r5,[r10,r8,lsl#2] @ Te4[s0>>8] | ||
335 | and r8,lr,r1 | ||
336 | ldrb r6,[r10,r9,lsl#2] @ Te4[s0>>16] | ||
337 | and r9,lr,r1,lsr#8 | ||
338 | ldrb r0,[r10,r0,lsl#2] @ Te4[s0>>24] | ||
339 | mov r1,r1,lsr#24 | ||
340 | |||
341 | ldrb r7,[r10,r7,lsl#2] @ Te4[s1>>16] | ||
342 | ldrb r8,[r10,r8,lsl#2] @ Te4[s1>>0] | ||
343 | ldrb r9,[r10,r9,lsl#2] @ Te4[s1>>8] | ||
344 | eor r0,r7,r0,lsl#8 | ||
345 | ldrb r1,[r10,r1,lsl#2] @ Te4[s1>>24] | ||
346 | and r7,lr,r2,lsr#8 @ i0 | ||
347 | eor r5,r8,r5,lsl#8 | ||
348 | and r8,lr,r2,lsr#16 @ i1 | ||
349 | eor r6,r9,r6,lsl#8 | ||
350 | and r9,lr,r2 | ||
351 | ldrb r7,[r10,r7,lsl#2] @ Te4[s2>>8] | ||
352 | eor r1,r4,r1,lsl#24 | ||
353 | ldrb r8,[r10,r8,lsl#2] @ Te4[s2>>16] | ||
354 | mov r2,r2,lsr#24 | ||
355 | |||
356 | ldrb r9,[r10,r9,lsl#2] @ Te4[s2>>0] | ||
357 | eor r0,r7,r0,lsl#8 | ||
358 | ldrb r2,[r10,r2,lsl#2] @ Te4[s2>>24] | ||
359 | and r7,lr,r3 @ i0 | ||
360 | eor r1,r1,r8,lsl#16 | ||
361 | and r8,lr,r3,lsr#8 @ i1 | ||
362 | eor r6,r9,r6,lsl#8 | ||
363 | and r9,lr,r3,lsr#16 @ i2 | ||
364 | ldrb r7,[r10,r7,lsl#2] @ Te4[s3>>0] | ||
365 | eor r2,r5,r2,lsl#24 | ||
366 | ldrb r8,[r10,r8,lsl#2] @ Te4[s3>>8] | ||
367 | mov r3,r3,lsr#24 | ||
368 | |||
369 | ldrb r9,[r10,r9,lsl#2] @ Te4[s3>>16] | ||
370 | eor r0,r7,r0,lsl#8 | ||
371 | ldr r7,[r11,#0] | ||
372 | ldrb r3,[r10,r3,lsl#2] @ Te4[s3>>24] | ||
373 | eor r1,r1,r8,lsl#8 | ||
374 | ldr r4,[r11,#4] | ||
375 | eor r2,r2,r9,lsl#16 | ||
376 | ldr r5,[r11,#8] | ||
377 | eor r3,r6,r3,lsl#24 | ||
378 | ldr r6,[r11,#12] | ||
379 | |||
380 | eor r0,r0,r7 | ||
381 | eor r1,r1,r4 | ||
382 | eor r2,r2,r5 | ||
383 | eor r3,r3,r6 | ||
384 | |||
385 | sub r10,r10,#2 | ||
386 | ldr pc,[sp],#4 @ pop and return | ||
387 | .size _armv4_AES_encrypt,.-_armv4_AES_encrypt | ||
388 | |||
389 | .global private_AES_set_encrypt_key | ||
390 | .type private_AES_set_encrypt_key,%function | ||
391 | .align 5 | ||
392 | private_AES_set_encrypt_key: | ||
393 | _armv4_AES_set_encrypt_key: | ||
394 | sub r3,pc,#8 @ AES_set_encrypt_key | ||
395 | teq r0,#0 | ||
396 | moveq r0,#-1 | ||
397 | beq .Labrt | ||
398 | teq r2,#0 | ||
399 | moveq r0,#-1 | ||
400 | beq .Labrt | ||
401 | |||
402 | teq r1,#128 | ||
403 | beq .Lok | ||
404 | teq r1,#192 | ||
405 | beq .Lok | ||
406 | teq r1,#256 | ||
407 | movne r0,#-1 | ||
408 | bne .Labrt | ||
409 | |||
410 | .Lok: stmdb sp!,{r4-r12,lr} | ||
411 | sub r10,r3,#_armv4_AES_set_encrypt_key-AES_Te-1024 @ Te4 | ||
412 | |||
413 | mov r12,r0 @ inp | ||
414 | mov lr,r1 @ bits | ||
415 | mov r11,r2 @ key | ||
416 | |||
417 | #if __ARM_ARCH__<7 | ||
418 | ldrb r0,[r12,#3] @ load input data in endian-neutral | ||
419 | ldrb r4,[r12,#2] @ manner... | ||
420 | ldrb r5,[r12,#1] | ||
421 | ldrb r6,[r12,#0] | ||
422 | orr r0,r0,r4,lsl#8 | ||
423 | ldrb r1,[r12,#7] | ||
424 | orr r0,r0,r5,lsl#16 | ||
425 | ldrb r4,[r12,#6] | ||
426 | orr r0,r0,r6,lsl#24 | ||
427 | ldrb r5,[r12,#5] | ||
428 | ldrb r6,[r12,#4] | ||
429 | orr r1,r1,r4,lsl#8 | ||
430 | ldrb r2,[r12,#11] | ||
431 | orr r1,r1,r5,lsl#16 | ||
432 | ldrb r4,[r12,#10] | ||
433 | orr r1,r1,r6,lsl#24 | ||
434 | ldrb r5,[r12,#9] | ||
435 | ldrb r6,[r12,#8] | ||
436 | orr r2,r2,r4,lsl#8 | ||
437 | ldrb r3,[r12,#15] | ||
438 | orr r2,r2,r5,lsl#16 | ||
439 | ldrb r4,[r12,#14] | ||
440 | orr r2,r2,r6,lsl#24 | ||
441 | ldrb r5,[r12,#13] | ||
442 | ldrb r6,[r12,#12] | ||
443 | orr r3,r3,r4,lsl#8 | ||
444 | str r0,[r11],#16 | ||
445 | orr r3,r3,r5,lsl#16 | ||
446 | str r1,[r11,#-12] | ||
447 | orr r3,r3,r6,lsl#24 | ||
448 | str r2,[r11,#-8] | ||
449 | str r3,[r11,#-4] | ||
450 | #else | ||
451 | ldr r0,[r12,#0] | ||
452 | ldr r1,[r12,#4] | ||
453 | ldr r2,[r12,#8] | ||
454 | ldr r3,[r12,#12] | ||
455 | #ifdef __ARMEL__ | ||
456 | rev r0,r0 | ||
457 | rev r1,r1 | ||
458 | rev r2,r2 | ||
459 | rev r3,r3 | ||
460 | #endif | ||
461 | str r0,[r11],#16 | ||
462 | str r1,[r11,#-12] | ||
463 | str r2,[r11,#-8] | ||
464 | str r3,[r11,#-4] | ||
465 | #endif | ||
466 | |||
467 | teq lr,#128 | ||
468 | bne .Lnot128 | ||
469 | mov r12,#10 | ||
470 | str r12,[r11,#240-16] | ||
471 | add r6,r10,#256 @ rcon | ||
472 | mov lr,#255 | ||
473 | |||
474 | .L128_loop: | ||
475 | and r5,lr,r3,lsr#24 | ||
476 | and r7,lr,r3,lsr#16 | ||
477 | ldrb r5,[r10,r5] | ||
478 | and r8,lr,r3,lsr#8 | ||
479 | ldrb r7,[r10,r7] | ||
480 | and r9,lr,r3 | ||
481 | ldrb r8,[r10,r8] | ||
482 | orr r5,r5,r7,lsl#24 | ||
483 | ldrb r9,[r10,r9] | ||
484 | orr r5,r5,r8,lsl#16 | ||
485 | ldr r4,[r6],#4 @ rcon[i++] | ||
486 | orr r5,r5,r9,lsl#8 | ||
487 | eor r5,r5,r4 | ||
488 | eor r0,r0,r5 @ rk[4]=rk[0]^... | ||
489 | eor r1,r1,r0 @ rk[5]=rk[1]^rk[4] | ||
490 | str r0,[r11],#16 | ||
491 | eor r2,r2,r1 @ rk[6]=rk[2]^rk[5] | ||
492 | str r1,[r11,#-12] | ||
493 | eor r3,r3,r2 @ rk[7]=rk[3]^rk[6] | ||
494 | str r2,[r11,#-8] | ||
495 | subs r12,r12,#1 | ||
496 | str r3,[r11,#-4] | ||
497 | bne .L128_loop | ||
498 | sub r2,r11,#176 | ||
499 | b .Ldone | ||
500 | |||
501 | .Lnot128: | ||
502 | #if __ARM_ARCH__<7 | ||
503 | ldrb r8,[r12,#19] | ||
504 | ldrb r4,[r12,#18] | ||
505 | ldrb r5,[r12,#17] | ||
506 | ldrb r6,[r12,#16] | ||
507 | orr r8,r8,r4,lsl#8 | ||
508 | ldrb r9,[r12,#23] | ||
509 | orr r8,r8,r5,lsl#16 | ||
510 | ldrb r4,[r12,#22] | ||
511 | orr r8,r8,r6,lsl#24 | ||
512 | ldrb r5,[r12,#21] | ||
513 | ldrb r6,[r12,#20] | ||
514 | orr r9,r9,r4,lsl#8 | ||
515 | orr r9,r9,r5,lsl#16 | ||
516 | str r8,[r11],#8 | ||
517 | orr r9,r9,r6,lsl#24 | ||
518 | str r9,[r11,#-4] | ||
519 | #else | ||
520 | ldr r8,[r12,#16] | ||
521 | ldr r9,[r12,#20] | ||
522 | #ifdef __ARMEL__ | ||
523 | rev r8,r8 | ||
524 | rev r9,r9 | ||
525 | #endif | ||
526 | str r8,[r11],#8 | ||
527 | str r9,[r11,#-4] | ||
528 | #endif | ||
529 | |||
530 | teq lr,#192 | ||
531 | bne .Lnot192 | ||
532 | mov r12,#12 | ||
533 | str r12,[r11,#240-24] | ||
534 | add r6,r10,#256 @ rcon | ||
535 | mov lr,#255 | ||
536 | mov r12,#8 | ||
537 | |||
538 | .L192_loop: | ||
539 | and r5,lr,r9,lsr#24 | ||
540 | and r7,lr,r9,lsr#16 | ||
541 | ldrb r5,[r10,r5] | ||
542 | and r8,lr,r9,lsr#8 | ||
543 | ldrb r7,[r10,r7] | ||
544 | and r9,lr,r9 | ||
545 | ldrb r8,[r10,r8] | ||
546 | orr r5,r5,r7,lsl#24 | ||
547 | ldrb r9,[r10,r9] | ||
548 | orr r5,r5,r8,lsl#16 | ||
549 | ldr r4,[r6],#4 @ rcon[i++] | ||
550 | orr r5,r5,r9,lsl#8 | ||
551 | eor r9,r5,r4 | ||
552 | eor r0,r0,r9 @ rk[6]=rk[0]^... | ||
553 | eor r1,r1,r0 @ rk[7]=rk[1]^rk[6] | ||
554 | str r0,[r11],#24 | ||
555 | eor r2,r2,r1 @ rk[8]=rk[2]^rk[7] | ||
556 | str r1,[r11,#-20] | ||
557 | eor r3,r3,r2 @ rk[9]=rk[3]^rk[8] | ||
558 | str r2,[r11,#-16] | ||
559 | subs r12,r12,#1 | ||
560 | str r3,[r11,#-12] | ||
561 | subeq r2,r11,#216 | ||
562 | beq .Ldone | ||
563 | |||
564 | ldr r7,[r11,#-32] | ||
565 | ldr r8,[r11,#-28] | ||
566 | eor r7,r7,r3 @ rk[10]=rk[4]^rk[9] | ||
567 | eor r9,r8,r7 @ rk[11]=rk[5]^rk[10] | ||
568 | str r7,[r11,#-8] | ||
569 | str r9,[r11,#-4] | ||
570 | b .L192_loop | ||
571 | |||
572 | .Lnot192: | ||
573 | #if __ARM_ARCH__<7 | ||
574 | ldrb r8,[r12,#27] | ||
575 | ldrb r4,[r12,#26] | ||
576 | ldrb r5,[r12,#25] | ||
577 | ldrb r6,[r12,#24] | ||
578 | orr r8,r8,r4,lsl#8 | ||
579 | ldrb r9,[r12,#31] | ||
580 | orr r8,r8,r5,lsl#16 | ||
581 | ldrb r4,[r12,#30] | ||
582 | orr r8,r8,r6,lsl#24 | ||
583 | ldrb r5,[r12,#29] | ||
584 | ldrb r6,[r12,#28] | ||
585 | orr r9,r9,r4,lsl#8 | ||
586 | orr r9,r9,r5,lsl#16 | ||
587 | str r8,[r11],#8 | ||
588 | orr r9,r9,r6,lsl#24 | ||
589 | str r9,[r11,#-4] | ||
590 | #else | ||
591 | ldr r8,[r12,#24] | ||
592 | ldr r9,[r12,#28] | ||
593 | #ifdef __ARMEL__ | ||
594 | rev r8,r8 | ||
595 | rev r9,r9 | ||
596 | #endif | ||
597 | str r8,[r11],#8 | ||
598 | str r9,[r11,#-4] | ||
599 | #endif | ||
600 | |||
601 | mov r12,#14 | ||
602 | str r12,[r11,#240-32] | ||
603 | add r6,r10,#256 @ rcon | ||
604 | mov lr,#255 | ||
605 | mov r12,#7 | ||
606 | |||
607 | .L256_loop: | ||
608 | and r5,lr,r9,lsr#24 | ||
609 | and r7,lr,r9,lsr#16 | ||
610 | ldrb r5,[r10,r5] | ||
611 | and r8,lr,r9,lsr#8 | ||
612 | ldrb r7,[r10,r7] | ||
613 | and r9,lr,r9 | ||
614 | ldrb r8,[r10,r8] | ||
615 | orr r5,r5,r7,lsl#24 | ||
616 | ldrb r9,[r10,r9] | ||
617 | orr r5,r5,r8,lsl#16 | ||
618 | ldr r4,[r6],#4 @ rcon[i++] | ||
619 | orr r5,r5,r9,lsl#8 | ||
620 | eor r9,r5,r4 | ||
621 | eor r0,r0,r9 @ rk[8]=rk[0]^... | ||
622 | eor r1,r1,r0 @ rk[9]=rk[1]^rk[8] | ||
623 | str r0,[r11],#32 | ||
624 | eor r2,r2,r1 @ rk[10]=rk[2]^rk[9] | ||
625 | str r1,[r11,#-28] | ||
626 | eor r3,r3,r2 @ rk[11]=rk[3]^rk[10] | ||
627 | str r2,[r11,#-24] | ||
628 | subs r12,r12,#1 | ||
629 | str r3,[r11,#-20] | ||
630 | subeq r2,r11,#256 | ||
631 | beq .Ldone | ||
632 | |||
633 | and r5,lr,r3 | ||
634 | and r7,lr,r3,lsr#8 | ||
635 | ldrb r5,[r10,r5] | ||
636 | and r8,lr,r3,lsr#16 | ||
637 | ldrb r7,[r10,r7] | ||
638 | and r9,lr,r3,lsr#24 | ||
639 | ldrb r8,[r10,r8] | ||
640 | orr r5,r5,r7,lsl#8 | ||
641 | ldrb r9,[r10,r9] | ||
642 | orr r5,r5,r8,lsl#16 | ||
643 | ldr r4,[r11,#-48] | ||
644 | orr r5,r5,r9,lsl#24 | ||
645 | |||
646 | ldr r7,[r11,#-44] | ||
647 | ldr r8,[r11,#-40] | ||
648 | eor r4,r4,r5 @ rk[12]=rk[4]^... | ||
649 | ldr r9,[r11,#-36] | ||
650 | eor r7,r7,r4 @ rk[13]=rk[5]^rk[12] | ||
651 | str r4,[r11,#-16] | ||
652 | eor r8,r8,r7 @ rk[14]=rk[6]^rk[13] | ||
653 | str r7,[r11,#-12] | ||
654 | eor r9,r9,r8 @ rk[15]=rk[7]^rk[14] | ||
655 | str r8,[r11,#-8] | ||
656 | str r9,[r11,#-4] | ||
657 | b .L256_loop | ||
658 | |||
659 | .Ldone: mov r0,#0 | ||
660 | ldmia sp!,{r4-r12,lr} | ||
661 | .Labrt: tst lr,#1 | ||
662 | moveq pc,lr @ be binary compatible with V4, yet | ||
663 | .word 0xe12fff1e @ interoperable with Thumb ISA:-) | ||
664 | .size private_AES_set_encrypt_key,.-private_AES_set_encrypt_key | ||
665 | |||
666 | .global private_AES_set_decrypt_key | ||
667 | .type private_AES_set_decrypt_key,%function | ||
668 | .align 5 | ||
669 | private_AES_set_decrypt_key: | ||
670 | str lr,[sp,#-4]! @ push lr | ||
671 | #if 0 | ||
672 | @ kernel does both of these in setkey so optimise this bit out by | ||
673 | @ expecting the key to already have the enc_key work done (see aes_glue.c) | ||
674 | bl _armv4_AES_set_encrypt_key | ||
675 | #else | ||
676 | mov r0,#0 | ||
677 | #endif | ||
678 | teq r0,#0 | ||
679 | ldrne lr,[sp],#4 @ pop lr | ||
680 | bne .Labrt | ||
681 | |||
682 | stmdb sp!,{r4-r12} | ||
683 | |||
684 | ldr r12,[r2,#240] @ AES_set_encrypt_key preserves r2, | ||
685 | mov r11,r2 @ which is AES_KEY *key | ||
686 | mov r7,r2 | ||
687 | add r8,r2,r12,lsl#4 | ||
688 | |||
689 | .Linv: ldr r0,[r7] | ||
690 | ldr r1,[r7,#4] | ||
691 | ldr r2,[r7,#8] | ||
692 | ldr r3,[r7,#12] | ||
693 | ldr r4,[r8] | ||
694 | ldr r5,[r8,#4] | ||
695 | ldr r6,[r8,#8] | ||
696 | ldr r9,[r8,#12] | ||
697 | str r0,[r8],#-16 | ||
698 | str r1,[r8,#16+4] | ||
699 | str r2,[r8,#16+8] | ||
700 | str r3,[r8,#16+12] | ||
701 | str r4,[r7],#16 | ||
702 | str r5,[r7,#-12] | ||
703 | str r6,[r7,#-8] | ||
704 | str r9,[r7,#-4] | ||
705 | teq r7,r8 | ||
706 | bne .Linv | ||
707 | ldr r0,[r11,#16]! @ prefetch tp1 | ||
708 | mov r7,#0x80 | ||
709 | mov r8,#0x1b | ||
710 | orr r7,r7,#0x8000 | ||
711 | orr r8,r8,#0x1b00 | ||
712 | orr r7,r7,r7,lsl#16 | ||
713 | orr r8,r8,r8,lsl#16 | ||
714 | sub r12,r12,#1 | ||
715 | mvn r9,r7 | ||
716 | mov r12,r12,lsl#2 @ (rounds-1)*4 | ||
717 | |||
718 | .Lmix: and r4,r0,r7 | ||
719 | and r1,r0,r9 | ||
720 | sub r4,r4,r4,lsr#7 | ||
721 | and r4,r4,r8 | ||
722 | eor r1,r4,r1,lsl#1 @ tp2 | ||
723 | |||
724 | and r4,r1,r7 | ||
725 | and r2,r1,r9 | ||
726 | sub r4,r4,r4,lsr#7 | ||
727 | and r4,r4,r8 | ||
728 | eor r2,r4,r2,lsl#1 @ tp4 | ||
729 | |||
730 | and r4,r2,r7 | ||
731 | and r3,r2,r9 | ||
732 | sub r4,r4,r4,lsr#7 | ||
733 | and r4,r4,r8 | ||
734 | eor r3,r4,r3,lsl#1 @ tp8 | ||
735 | |||
736 | eor r4,r1,r2 | ||
737 | eor r5,r0,r3 @ tp9 | ||
738 | eor r4,r4,r3 @ tpe | ||
739 | eor r4,r4,r1,ror#24 | ||
740 | eor r4,r4,r5,ror#24 @ ^= ROTATE(tpb=tp9^tp2,8) | ||
741 | eor r4,r4,r2,ror#16 | ||
742 | eor r4,r4,r5,ror#16 @ ^= ROTATE(tpd=tp9^tp4,16) | ||
743 | eor r4,r4,r5,ror#8 @ ^= ROTATE(tp9,24) | ||
744 | |||
745 | ldr r0,[r11,#4] @ prefetch tp1 | ||
746 | str r4,[r11],#4 | ||
747 | subs r12,r12,#1 | ||
748 | bne .Lmix | ||
749 | |||
750 | mov r0,#0 | ||
751 | #if __ARM_ARCH__>=5 | ||
752 | ldmia sp!,{r4-r12,pc} | ||
753 | #else | ||
754 | ldmia sp!,{r4-r12,lr} | ||
755 | tst lr,#1 | ||
756 | moveq pc,lr @ be binary compatible with V4, yet | ||
757 | .word 0xe12fff1e @ interoperable with Thumb ISA:-) | ||
758 | #endif | ||
759 | .size private_AES_set_decrypt_key,.-private_AES_set_decrypt_key | ||
760 | |||
761 | .type AES_Td,%object | ||
762 | .align 5 | ||
763 | AES_Td: | ||
764 | .word 0x51f4a750, 0x7e416553, 0x1a17a4c3, 0x3a275e96 | ||
765 | .word 0x3bab6bcb, 0x1f9d45f1, 0xacfa58ab, 0x4be30393 | ||
766 | .word 0x2030fa55, 0xad766df6, 0x88cc7691, 0xf5024c25 | ||
767 | .word 0x4fe5d7fc, 0xc52acbd7, 0x26354480, 0xb562a38f | ||
768 | .word 0xdeb15a49, 0x25ba1b67, 0x45ea0e98, 0x5dfec0e1 | ||
769 | .word 0xc32f7502, 0x814cf012, 0x8d4697a3, 0x6bd3f9c6 | ||
770 | .word 0x038f5fe7, 0x15929c95, 0xbf6d7aeb, 0x955259da | ||
771 | .word 0xd4be832d, 0x587421d3, 0x49e06929, 0x8ec9c844 | ||
772 | .word 0x75c2896a, 0xf48e7978, 0x99583e6b, 0x27b971dd | ||
773 | .word 0xbee14fb6, 0xf088ad17, 0xc920ac66, 0x7dce3ab4 | ||
774 | .word 0x63df4a18, 0xe51a3182, 0x97513360, 0x62537f45 | ||
775 | .word 0xb16477e0, 0xbb6bae84, 0xfe81a01c, 0xf9082b94 | ||
776 | .word 0x70486858, 0x8f45fd19, 0x94de6c87, 0x527bf8b7 | ||
777 | .word 0xab73d323, 0x724b02e2, 0xe31f8f57, 0x6655ab2a | ||
778 | .word 0xb2eb2807, 0x2fb5c203, 0x86c57b9a, 0xd33708a5 | ||
779 | .word 0x302887f2, 0x23bfa5b2, 0x02036aba, 0xed16825c | ||
780 | .word 0x8acf1c2b, 0xa779b492, 0xf307f2f0, 0x4e69e2a1 | ||
781 | .word 0x65daf4cd, 0x0605bed5, 0xd134621f, 0xc4a6fe8a | ||
782 | .word 0x342e539d, 0xa2f355a0, 0x058ae132, 0xa4f6eb75 | ||
783 | .word 0x0b83ec39, 0x4060efaa, 0x5e719f06, 0xbd6e1051 | ||
784 | .word 0x3e218af9, 0x96dd063d, 0xdd3e05ae, 0x4de6bd46 | ||
785 | .word 0x91548db5, 0x71c45d05, 0x0406d46f, 0x605015ff | ||
786 | .word 0x1998fb24, 0xd6bde997, 0x894043cc, 0x67d99e77 | ||
787 | .word 0xb0e842bd, 0x07898b88, 0xe7195b38, 0x79c8eedb | ||
788 | .word 0xa17c0a47, 0x7c420fe9, 0xf8841ec9, 0x00000000 | ||
789 | .word 0x09808683, 0x322bed48, 0x1e1170ac, 0x6c5a724e | ||
790 | .word 0xfd0efffb, 0x0f853856, 0x3daed51e, 0x362d3927 | ||
791 | .word 0x0a0fd964, 0x685ca621, 0x9b5b54d1, 0x24362e3a | ||
792 | .word 0x0c0a67b1, 0x9357e70f, 0xb4ee96d2, 0x1b9b919e | ||
793 | .word 0x80c0c54f, 0x61dc20a2, 0x5a774b69, 0x1c121a16 | ||
794 | .word 0xe293ba0a, 0xc0a02ae5, 0x3c22e043, 0x121b171d | ||
795 | .word 0x0e090d0b, 0xf28bc7ad, 0x2db6a8b9, 0x141ea9c8 | ||
796 | .word 0x57f11985, 0xaf75074c, 0xee99ddbb, 0xa37f60fd | ||
797 | .word 0xf701269f, 0x5c72f5bc, 0x44663bc5, 0x5bfb7e34 | ||
798 | .word 0x8b432976, 0xcb23c6dc, 0xb6edfc68, 0xb8e4f163 | ||
799 | .word 0xd731dcca, 0x42638510, 0x13972240, 0x84c61120 | ||
800 | .word 0x854a247d, 0xd2bb3df8, 0xaef93211, 0xc729a16d | ||
801 | .word 0x1d9e2f4b, 0xdcb230f3, 0x0d8652ec, 0x77c1e3d0 | ||
802 | .word 0x2bb3166c, 0xa970b999, 0x119448fa, 0x47e96422 | ||
803 | .word 0xa8fc8cc4, 0xa0f03f1a, 0x567d2cd8, 0x223390ef | ||
804 | .word 0x87494ec7, 0xd938d1c1, 0x8ccaa2fe, 0x98d40b36 | ||
805 | .word 0xa6f581cf, 0xa57ade28, 0xdab78e26, 0x3fadbfa4 | ||
806 | .word 0x2c3a9de4, 0x5078920d, 0x6a5fcc9b, 0x547e4662 | ||
807 | .word 0xf68d13c2, 0x90d8b8e8, 0x2e39f75e, 0x82c3aff5 | ||
808 | .word 0x9f5d80be, 0x69d0937c, 0x6fd52da9, 0xcf2512b3 | ||
809 | .word 0xc8ac993b, 0x10187da7, 0xe89c636e, 0xdb3bbb7b | ||
810 | .word 0xcd267809, 0x6e5918f4, 0xec9ab701, 0x834f9aa8 | ||
811 | .word 0xe6956e65, 0xaaffe67e, 0x21bccf08, 0xef15e8e6 | ||
812 | .word 0xbae79bd9, 0x4a6f36ce, 0xea9f09d4, 0x29b07cd6 | ||
813 | .word 0x31a4b2af, 0x2a3f2331, 0xc6a59430, 0x35a266c0 | ||
814 | .word 0x744ebc37, 0xfc82caa6, 0xe090d0b0, 0x33a7d815 | ||
815 | .word 0xf104984a, 0x41ecdaf7, 0x7fcd500e, 0x1791f62f | ||
816 | .word 0x764dd68d, 0x43efb04d, 0xccaa4d54, 0xe49604df | ||
817 | .word 0x9ed1b5e3, 0x4c6a881b, 0xc12c1fb8, 0x4665517f | ||
818 | .word 0x9d5eea04, 0x018c355d, 0xfa877473, 0xfb0b412e | ||
819 | .word 0xb3671d5a, 0x92dbd252, 0xe9105633, 0x6dd64713 | ||
820 | .word 0x9ad7618c, 0x37a10c7a, 0x59f8148e, 0xeb133c89 | ||
821 | .word 0xcea927ee, 0xb761c935, 0xe11ce5ed, 0x7a47b13c | ||
822 | .word 0x9cd2df59, 0x55f2733f, 0x1814ce79, 0x73c737bf | ||
823 | .word 0x53f7cdea, 0x5ffdaa5b, 0xdf3d6f14, 0x7844db86 | ||
824 | .word 0xcaaff381, 0xb968c43e, 0x3824342c, 0xc2a3405f | ||
825 | .word 0x161dc372, 0xbce2250c, 0x283c498b, 0xff0d9541 | ||
826 | .word 0x39a80171, 0x080cb3de, 0xd8b4e49c, 0x6456c190 | ||
827 | .word 0x7bcb8461, 0xd532b670, 0x486c5c74, 0xd0b85742 | ||
828 | @ Td4[256] | ||
829 | .byte 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38 | ||
830 | .byte 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb | ||
831 | .byte 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87 | ||
832 | .byte 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb | ||
833 | .byte 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d | ||
834 | .byte 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e | ||
835 | .byte 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2 | ||
836 | .byte 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25 | ||
837 | .byte 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16 | ||
838 | .byte 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92 | ||
839 | .byte 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda | ||
840 | .byte 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84 | ||
841 | .byte 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a | ||
842 | .byte 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06 | ||
843 | .byte 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02 | ||
844 | .byte 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b | ||
845 | .byte 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea | ||
846 | .byte 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73 | ||
847 | .byte 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85 | ||
848 | .byte 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e | ||
849 | .byte 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89 | ||
850 | .byte 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b | ||
851 | .byte 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20 | ||
852 | .byte 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4 | ||
853 | .byte 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31 | ||
854 | .byte 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f | ||
855 | .byte 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d | ||
856 | .byte 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef | ||
857 | .byte 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0 | ||
858 | .byte 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61 | ||
859 | .byte 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26 | ||
860 | .byte 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d | ||
861 | .size AES_Td,.-AES_Td | ||
862 | |||
863 | @ void AES_decrypt(const unsigned char *in, unsigned char *out, | ||
864 | @ const AES_KEY *key) { | ||
865 | .global AES_decrypt | ||
866 | .type AES_decrypt,%function | ||
867 | .align 5 | ||
868 | AES_decrypt: | ||
869 | sub r3,pc,#8 @ AES_decrypt | ||
870 | stmdb sp!,{r1,r4-r12,lr} | ||
871 | mov r12,r0 @ inp | ||
872 | mov r11,r2 | ||
873 | sub r10,r3,#AES_decrypt-AES_Td @ Td | ||
874 | #if __ARM_ARCH__<7 | ||
875 | ldrb r0,[r12,#3] @ load input data in endian-neutral | ||
876 | ldrb r4,[r12,#2] @ manner... | ||
877 | ldrb r5,[r12,#1] | ||
878 | ldrb r6,[r12,#0] | ||
879 | orr r0,r0,r4,lsl#8 | ||
880 | ldrb r1,[r12,#7] | ||
881 | orr r0,r0,r5,lsl#16 | ||
882 | ldrb r4,[r12,#6] | ||
883 | orr r0,r0,r6,lsl#24 | ||
884 | ldrb r5,[r12,#5] | ||
885 | ldrb r6,[r12,#4] | ||
886 | orr r1,r1,r4,lsl#8 | ||
887 | ldrb r2,[r12,#11] | ||
888 | orr r1,r1,r5,lsl#16 | ||
889 | ldrb r4,[r12,#10] | ||
890 | orr r1,r1,r6,lsl#24 | ||
891 | ldrb r5,[r12,#9] | ||
892 | ldrb r6,[r12,#8] | ||
893 | orr r2,r2,r4,lsl#8 | ||
894 | ldrb r3,[r12,#15] | ||
895 | orr r2,r2,r5,lsl#16 | ||
896 | ldrb r4,[r12,#14] | ||
897 | orr r2,r2,r6,lsl#24 | ||
898 | ldrb r5,[r12,#13] | ||
899 | ldrb r6,[r12,#12] | ||
900 | orr r3,r3,r4,lsl#8 | ||
901 | orr r3,r3,r5,lsl#16 | ||
902 | orr r3,r3,r6,lsl#24 | ||
903 | #else | ||
904 | ldr r0,[r12,#0] | ||
905 | ldr r1,[r12,#4] | ||
906 | ldr r2,[r12,#8] | ||
907 | ldr r3,[r12,#12] | ||
908 | #ifdef __ARMEL__ | ||
909 | rev r0,r0 | ||
910 | rev r1,r1 | ||
911 | rev r2,r2 | ||
912 | rev r3,r3 | ||
913 | #endif | ||
914 | #endif | ||
915 | bl _armv4_AES_decrypt | ||
916 | |||
917 | ldr r12,[sp],#4 @ pop out | ||
918 | #if __ARM_ARCH__>=7 | ||
919 | #ifdef __ARMEL__ | ||
920 | rev r0,r0 | ||
921 | rev r1,r1 | ||
922 | rev r2,r2 | ||
923 | rev r3,r3 | ||
924 | #endif | ||
925 | str r0,[r12,#0] | ||
926 | str r1,[r12,#4] | ||
927 | str r2,[r12,#8] | ||
928 | str r3,[r12,#12] | ||
929 | #else | ||
930 | mov r4,r0,lsr#24 @ write output in endian-neutral | ||
931 | mov r5,r0,lsr#16 @ manner... | ||
932 | mov r6,r0,lsr#8 | ||
933 | strb r4,[r12,#0] | ||
934 | strb r5,[r12,#1] | ||
935 | mov r4,r1,lsr#24 | ||
936 | strb r6,[r12,#2] | ||
937 | mov r5,r1,lsr#16 | ||
938 | strb r0,[r12,#3] | ||
939 | mov r6,r1,lsr#8 | ||
940 | strb r4,[r12,#4] | ||
941 | strb r5,[r12,#5] | ||
942 | mov r4,r2,lsr#24 | ||
943 | strb r6,[r12,#6] | ||
944 | mov r5,r2,lsr#16 | ||
945 | strb r1,[r12,#7] | ||
946 | mov r6,r2,lsr#8 | ||
947 | strb r4,[r12,#8] | ||
948 | strb r5,[r12,#9] | ||
949 | mov r4,r3,lsr#24 | ||
950 | strb r6,[r12,#10] | ||
951 | mov r5,r3,lsr#16 | ||
952 | strb r2,[r12,#11] | ||
953 | mov r6,r3,lsr#8 | ||
954 | strb r4,[r12,#12] | ||
955 | strb r5,[r12,#13] | ||
956 | strb r6,[r12,#14] | ||
957 | strb r3,[r12,#15] | ||
958 | #endif | ||
959 | #if __ARM_ARCH__>=5 | ||
960 | ldmia sp!,{r4-r12,pc} | ||
961 | #else | ||
962 | ldmia sp!,{r4-r12,lr} | ||
963 | tst lr,#1 | ||
964 | moveq pc,lr @ be binary compatible with V4, yet | ||
965 | .word 0xe12fff1e @ interoperable with Thumb ISA:-) | ||
966 | #endif | ||
967 | .size AES_decrypt,.-AES_decrypt | ||
968 | |||
969 | .type _armv4_AES_decrypt,%function | ||
970 | .align 2 | ||
971 | _armv4_AES_decrypt: | ||
972 | str lr,[sp,#-4]! @ push lr | ||
973 | ldmia r11!,{r4-r7} | ||
974 | eor r0,r0,r4 | ||
975 | ldr r12,[r11,#240-16] | ||
976 | eor r1,r1,r5 | ||
977 | eor r2,r2,r6 | ||
978 | eor r3,r3,r7 | ||
979 | sub r12,r12,#1 | ||
980 | mov lr,#255 | ||
981 | |||
982 | and r7,lr,r0,lsr#16 | ||
983 | and r8,lr,r0,lsr#8 | ||
984 | and r9,lr,r0 | ||
985 | mov r0,r0,lsr#24 | ||
986 | .Ldec_loop: | ||
987 | ldr r4,[r10,r7,lsl#2] @ Td1[s0>>16] | ||
988 | and r7,lr,r1 @ i0 | ||
989 | ldr r5,[r10,r8,lsl#2] @ Td2[s0>>8] | ||
990 | and r8,lr,r1,lsr#16 | ||
991 | ldr r6,[r10,r9,lsl#2] @ Td3[s0>>0] | ||
992 | and r9,lr,r1,lsr#8 | ||
993 | ldr r0,[r10,r0,lsl#2] @ Td0[s0>>24] | ||
994 | mov r1,r1,lsr#24 | ||
995 | |||
996 | ldr r7,[r10,r7,lsl#2] @ Td3[s1>>0] | ||
997 | ldr r8,[r10,r8,lsl#2] @ Td1[s1>>16] | ||
998 | ldr r9,[r10,r9,lsl#2] @ Td2[s1>>8] | ||
999 | eor r0,r0,r7,ror#24 | ||
1000 | ldr r1,[r10,r1,lsl#2] @ Td0[s1>>24] | ||
1001 | and r7,lr,r2,lsr#8 @ i0 | ||
1002 | eor r5,r8,r5,ror#8 | ||
1003 | and r8,lr,r2 @ i1 | ||
1004 | eor r6,r9,r6,ror#8 | ||
1005 | and r9,lr,r2,lsr#16 | ||
1006 | ldr r7,[r10,r7,lsl#2] @ Td2[s2>>8] | ||
1007 | eor r1,r1,r4,ror#8 | ||
1008 | ldr r8,[r10,r8,lsl#2] @ Td3[s2>>0] | ||
1009 | mov r2,r2,lsr#24 | ||
1010 | |||
1011 | ldr r9,[r10,r9,lsl#2] @ Td1[s2>>16] | ||
1012 | eor r0,r0,r7,ror#16 | ||
1013 | ldr r2,[r10,r2,lsl#2] @ Td0[s2>>24] | ||
1014 | and r7,lr,r3,lsr#16 @ i0 | ||
1015 | eor r1,r1,r8,ror#24 | ||
1016 | and r8,lr,r3,lsr#8 @ i1 | ||
1017 | eor r6,r9,r6,ror#8 | ||
1018 | and r9,lr,r3 @ i2 | ||
1019 | ldr r7,[r10,r7,lsl#2] @ Td1[s3>>16] | ||
1020 | eor r2,r2,r5,ror#8 | ||
1021 | ldr r8,[r10,r8,lsl#2] @ Td2[s3>>8] | ||
1022 | mov r3,r3,lsr#24 | ||
1023 | |||
1024 | ldr r9,[r10,r9,lsl#2] @ Td3[s3>>0] | ||
1025 | eor r0,r0,r7,ror#8 | ||
1026 | ldr r7,[r11],#16 | ||
1027 | eor r1,r1,r8,ror#16 | ||
1028 | ldr r3,[r10,r3,lsl#2] @ Td0[s3>>24] | ||
1029 | eor r2,r2,r9,ror#24 | ||
1030 | |||
1031 | ldr r4,[r11,#-12] | ||
1032 | eor r0,r0,r7 | ||
1033 | ldr r5,[r11,#-8] | ||
1034 | eor r3,r3,r6,ror#8 | ||
1035 | ldr r6,[r11,#-4] | ||
1036 | and r7,lr,r0,lsr#16 | ||
1037 | eor r1,r1,r4 | ||
1038 | and r8,lr,r0,lsr#8 | ||
1039 | eor r2,r2,r5 | ||
1040 | and r9,lr,r0 | ||
1041 | eor r3,r3,r6 | ||
1042 | mov r0,r0,lsr#24 | ||
1043 | |||
1044 | subs r12,r12,#1 | ||
1045 | bne .Ldec_loop | ||
1046 | |||
1047 | add r10,r10,#1024 | ||
1048 | |||
1049 | ldr r5,[r10,#0] @ prefetch Td4 | ||
1050 | ldr r6,[r10,#32] | ||
1051 | ldr r4,[r10,#64] | ||
1052 | ldr r5,[r10,#96] | ||
1053 | ldr r6,[r10,#128] | ||
1054 | ldr r4,[r10,#160] | ||
1055 | ldr r5,[r10,#192] | ||
1056 | ldr r6,[r10,#224] | ||
1057 | |||
1058 | ldrb r0,[r10,r0] @ Td4[s0>>24] | ||
1059 | ldrb r4,[r10,r7] @ Td4[s0>>16] | ||
1060 | and r7,lr,r1 @ i0 | ||
1061 | ldrb r5,[r10,r8] @ Td4[s0>>8] | ||
1062 | and r8,lr,r1,lsr#16 | ||
1063 | ldrb r6,[r10,r9] @ Td4[s0>>0] | ||
1064 | and r9,lr,r1,lsr#8 | ||
1065 | |||
1066 | ldrb r7,[r10,r7] @ Td4[s1>>0] | ||
1067 | ldrb r1,[r10,r1,lsr#24] @ Td4[s1>>24] | ||
1068 | ldrb r8,[r10,r8] @ Td4[s1>>16] | ||
1069 | eor r0,r7,r0,lsl#24 | ||
1070 | ldrb r9,[r10,r9] @ Td4[s1>>8] | ||
1071 | eor r1,r4,r1,lsl#8 | ||
1072 | and r7,lr,r2,lsr#8 @ i0 | ||
1073 | eor r5,r5,r8,lsl#8 | ||
1074 | and r8,lr,r2 @ i1 | ||
1075 | ldrb r7,[r10,r7] @ Td4[s2>>8] | ||
1076 | eor r6,r6,r9,lsl#8 | ||
1077 | ldrb r8,[r10,r8] @ Td4[s2>>0] | ||
1078 | and r9,lr,r2,lsr#16 | ||
1079 | |||
1080 | ldrb r2,[r10,r2,lsr#24] @ Td4[s2>>24] | ||
1081 | eor r0,r0,r7,lsl#8 | ||
1082 | ldrb r9,[r10,r9] @ Td4[s2>>16] | ||
1083 | eor r1,r8,r1,lsl#16 | ||
1084 | and r7,lr,r3,lsr#16 @ i0 | ||
1085 | eor r2,r5,r2,lsl#16 | ||
1086 | and r8,lr,r3,lsr#8 @ i1 | ||
1087 | ldrb r7,[r10,r7] @ Td4[s3>>16] | ||
1088 | eor r6,r6,r9,lsl#16 | ||
1089 | ldrb r8,[r10,r8] @ Td4[s3>>8] | ||
1090 | and r9,lr,r3 @ i2 | ||
1091 | |||
1092 | ldrb r9,[r10,r9] @ Td4[s3>>0] | ||
1093 | ldrb r3,[r10,r3,lsr#24] @ Td4[s3>>24] | ||
1094 | eor r0,r0,r7,lsl#16 | ||
1095 | ldr r7,[r11,#0] | ||
1096 | eor r1,r1,r8,lsl#8 | ||
1097 | ldr r4,[r11,#4] | ||
1098 | eor r2,r9,r2,lsl#8 | ||
1099 | ldr r5,[r11,#8] | ||
1100 | eor r3,r6,r3,lsl#24 | ||
1101 | ldr r6,[r11,#12] | ||
1102 | |||
1103 | eor r0,r0,r7 | ||
1104 | eor r1,r1,r4 | ||
1105 | eor r2,r2,r5 | ||
1106 | eor r3,r3,r6 | ||
1107 | |||
1108 | sub r10,r10,#1024 | ||
1109 | ldr pc,[sp],#4 @ pop and return | ||
1110 | .size _armv4_AES_decrypt,.-_armv4_AES_decrypt | ||
1111 | .asciz "AES for ARMv4, CRYPTOGAMS by <appro@openssl.org>" | ||
1112 | .align 2 | ||
diff --git a/arch/arm/crypto/aes_glue.c b/arch/arm/crypto/aes_glue.c new file mode 100644 index 000000000000..59f7877ead6a --- /dev/null +++ b/arch/arm/crypto/aes_glue.c | |||
@@ -0,0 +1,108 @@ | |||
1 | /* | ||
2 | * Glue Code for the asm optimized version of the AES Cipher Algorithm | ||
3 | */ | ||
4 | |||
5 | #include <linux/module.h> | ||
6 | #include <linux/crypto.h> | ||
7 | #include <crypto/aes.h> | ||
8 | |||
9 | #define AES_MAXNR 14 | ||
10 | |||
11 | typedef struct { | ||
12 | unsigned int rd_key[4 *(AES_MAXNR + 1)]; | ||
13 | int rounds; | ||
14 | } AES_KEY; | ||
15 | |||
16 | struct AES_CTX { | ||
17 | AES_KEY enc_key; | ||
18 | AES_KEY dec_key; | ||
19 | }; | ||
20 | |||
21 | asmlinkage void AES_encrypt(const u8 *in, u8 *out, AES_KEY *ctx); | ||
22 | asmlinkage void AES_decrypt(const u8 *in, u8 *out, AES_KEY *ctx); | ||
23 | asmlinkage int private_AES_set_decrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key); | ||
24 | asmlinkage int private_AES_set_encrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key); | ||
25 | |||
26 | static void aes_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) | ||
27 | { | ||
28 | struct AES_CTX *ctx = crypto_tfm_ctx(tfm); | ||
29 | AES_encrypt(src, dst, &ctx->enc_key); | ||
30 | } | ||
31 | |||
32 | static void aes_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) | ||
33 | { | ||
34 | struct AES_CTX *ctx = crypto_tfm_ctx(tfm); | ||
35 | AES_decrypt(src, dst, &ctx->dec_key); | ||
36 | } | ||
37 | |||
38 | static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key, | ||
39 | unsigned int key_len) | ||
40 | { | ||
41 | struct AES_CTX *ctx = crypto_tfm_ctx(tfm); | ||
42 | |||
43 | switch (key_len) { | ||
44 | case AES_KEYSIZE_128: | ||
45 | key_len = 128; | ||
46 | break; | ||
47 | case AES_KEYSIZE_192: | ||
48 | key_len = 192; | ||
49 | break; | ||
50 | case AES_KEYSIZE_256: | ||
51 | key_len = 256; | ||
52 | break; | ||
53 | default: | ||
54 | tfm->crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; | ||
55 | return -EINVAL; | ||
56 | } | ||
57 | |||
58 | if (private_AES_set_encrypt_key(in_key, key_len, &ctx->enc_key) == -1) { | ||
59 | tfm->crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; | ||
60 | return -EINVAL; | ||
61 | } | ||
62 | /* private_AES_set_decrypt_key expects an encryption key as input */ | ||
63 | ctx->dec_key = ctx->enc_key; | ||
64 | if (private_AES_set_decrypt_key(in_key, key_len, &ctx->dec_key) == -1) { | ||
65 | tfm->crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; | ||
66 | return -EINVAL; | ||
67 | } | ||
68 | return 0; | ||
69 | } | ||
70 | |||
71 | static struct crypto_alg aes_alg = { | ||
72 | .cra_name = "aes", | ||
73 | .cra_driver_name = "aes-asm", | ||
74 | .cra_priority = 200, | ||
75 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, | ||
76 | .cra_blocksize = AES_BLOCK_SIZE, | ||
77 | .cra_ctxsize = sizeof(struct AES_CTX), | ||
78 | .cra_module = THIS_MODULE, | ||
79 | .cra_list = LIST_HEAD_INIT(aes_alg.cra_list), | ||
80 | .cra_u = { | ||
81 | .cipher = { | ||
82 | .cia_min_keysize = AES_MIN_KEY_SIZE, | ||
83 | .cia_max_keysize = AES_MAX_KEY_SIZE, | ||
84 | .cia_setkey = aes_set_key, | ||
85 | .cia_encrypt = aes_encrypt, | ||
86 | .cia_decrypt = aes_decrypt | ||
87 | } | ||
88 | } | ||
89 | }; | ||
90 | |||
91 | static int __init aes_init(void) | ||
92 | { | ||
93 | return crypto_register_alg(&aes_alg); | ||
94 | } | ||
95 | |||
96 | static void __exit aes_fini(void) | ||
97 | { | ||
98 | crypto_unregister_alg(&aes_alg); | ||
99 | } | ||
100 | |||
101 | module_init(aes_init); | ||
102 | module_exit(aes_fini); | ||
103 | |||
104 | MODULE_DESCRIPTION("Rijndael (AES) Cipher Algorithm (ASM)"); | ||
105 | MODULE_LICENSE("GPL"); | ||
106 | MODULE_ALIAS("aes"); | ||
107 | MODULE_ALIAS("aes-asm"); | ||
108 | MODULE_AUTHOR("David McCullough <ucdevel@gmail.com>"); | ||
diff --git a/arch/arm/crypto/sha1-armv4-large.S b/arch/arm/crypto/sha1-armv4-large.S new file mode 100644 index 000000000000..7050ab133b9d --- /dev/null +++ b/arch/arm/crypto/sha1-armv4-large.S | |||
@@ -0,0 +1,503 @@ | |||
1 | #define __ARM_ARCH__ __LINUX_ARM_ARCH__ | ||
2 | @ ==================================================================== | ||
3 | @ Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL | ||
4 | @ project. The module is, however, dual licensed under OpenSSL and | ||
5 | @ CRYPTOGAMS licenses depending on where you obtain it. For further | ||
6 | @ details see http://www.openssl.org/~appro/cryptogams/. | ||
7 | @ ==================================================================== | ||
8 | |||
9 | @ sha1_block procedure for ARMv4. | ||
10 | @ | ||
11 | @ January 2007. | ||
12 | |||
13 | @ Size/performance trade-off | ||
14 | @ ==================================================================== | ||
15 | @ impl size in bytes comp cycles[*] measured performance | ||
16 | @ ==================================================================== | ||
17 | @ thumb 304 3212 4420 | ||
18 | @ armv4-small 392/+29% 1958/+64% 2250/+96% | ||
19 | @ armv4-compact 740/+89% 1552/+26% 1840/+22% | ||
20 | @ armv4-large 1420/+92% 1307/+19% 1370/+34%[***] | ||
21 | @ full unroll ~5100/+260% ~1260/+4% ~1300/+5% | ||
22 | @ ==================================================================== | ||
23 | @ thumb = same as 'small' but in Thumb instructions[**] and | ||
24 | @ with recurring code in two private functions; | ||
25 | @ small = detached Xload/update, loops are folded; | ||
26 | @ compact = detached Xload/update, 5x unroll; | ||
27 | @ large = interleaved Xload/update, 5x unroll; | ||
28 | @ full unroll = interleaved Xload/update, full unroll, estimated[!]; | ||
29 | @ | ||
30 | @ [*] Manually counted instructions in "grand" loop body. Measured | ||
31 | @ performance is affected by prologue and epilogue overhead, | ||
32 | @ i-cache availability, branch penalties, etc. | ||
33 | @ [**] While each Thumb instruction is twice smaller, they are not as | ||
34 | @ diverse as ARM ones: e.g., there are only two arithmetic | ||
35 | @ instructions with 3 arguments, no [fixed] rotate, addressing | ||
36 | @ modes are limited. As result it takes more instructions to do | ||
37 | @ the same job in Thumb, therefore the code is never twice as | ||
38 | @ small and always slower. | ||
39 | @ [***] which is also ~35% better than compiler generated code. Dual- | ||
40 | @ issue Cortex A8 core was measured to process input block in | ||
41 | @ ~990 cycles. | ||
42 | |||
43 | @ August 2010. | ||
44 | @ | ||
45 | @ Rescheduling for dual-issue pipeline resulted in 13% improvement on | ||
46 | @ Cortex A8 core and in absolute terms ~870 cycles per input block | ||
47 | @ [or 13.6 cycles per byte]. | ||
48 | |||
49 | @ February 2011. | ||
50 | @ | ||
51 | @ Profiler-assisted and platform-specific optimization resulted in 10% | ||
52 | @ improvement on Cortex A8 core and 12.2 cycles per byte. | ||
53 | |||
54 | .text | ||
55 | |||
56 | .global sha1_block_data_order | ||
57 | .type sha1_block_data_order,%function | ||
58 | |||
59 | .align 2 | ||
60 | sha1_block_data_order: | ||
61 | stmdb sp!,{r4-r12,lr} | ||
62 | add r2,r1,r2,lsl#6 @ r2 to point at the end of r1 | ||
63 | ldmia r0,{r3,r4,r5,r6,r7} | ||
64 | .Lloop: | ||
65 | ldr r8,.LK_00_19 | ||
66 | mov r14,sp | ||
67 | sub sp,sp,#15*4 | ||
68 | mov r5,r5,ror#30 | ||
69 | mov r6,r6,ror#30 | ||
70 | mov r7,r7,ror#30 @ [6] | ||
71 | .L_00_15: | ||
72 | #if __ARM_ARCH__<7 | ||
73 | ldrb r10,[r1,#2] | ||
74 | ldrb r9,[r1,#3] | ||
75 | ldrb r11,[r1,#1] | ||
76 | add r7,r8,r7,ror#2 @ E+=K_00_19 | ||
77 | ldrb r12,[r1],#4 | ||
78 | orr r9,r9,r10,lsl#8 | ||
79 | eor r10,r5,r6 @ F_xx_xx | ||
80 | orr r9,r9,r11,lsl#16 | ||
81 | add r7,r7,r3,ror#27 @ E+=ROR(A,27) | ||
82 | orr r9,r9,r12,lsl#24 | ||
83 | #else | ||
84 | ldr r9,[r1],#4 @ handles unaligned | ||
85 | add r7,r8,r7,ror#2 @ E+=K_00_19 | ||
86 | eor r10,r5,r6 @ F_xx_xx | ||
87 | add r7,r7,r3,ror#27 @ E+=ROR(A,27) | ||
88 | #ifdef __ARMEL__ | ||
89 | rev r9,r9 @ byte swap | ||
90 | #endif | ||
91 | #endif | ||
92 | and r10,r4,r10,ror#2 | ||
93 | add r7,r7,r9 @ E+=X[i] | ||
94 | eor r10,r10,r6,ror#2 @ F_00_19(B,C,D) | ||
95 | str r9,[r14,#-4]! | ||
96 | add r7,r7,r10 @ E+=F_00_19(B,C,D) | ||
97 | #if __ARM_ARCH__<7 | ||
98 | ldrb r10,[r1,#2] | ||
99 | ldrb r9,[r1,#3] | ||
100 | ldrb r11,[r1,#1] | ||
101 | add r6,r8,r6,ror#2 @ E+=K_00_19 | ||
102 | ldrb r12,[r1],#4 | ||
103 | orr r9,r9,r10,lsl#8 | ||
104 | eor r10,r4,r5 @ F_xx_xx | ||
105 | orr r9,r9,r11,lsl#16 | ||
106 | add r6,r6,r7,ror#27 @ E+=ROR(A,27) | ||
107 | orr r9,r9,r12,lsl#24 | ||
108 | #else | ||
109 | ldr r9,[r1],#4 @ handles unaligned | ||
110 | add r6,r8,r6,ror#2 @ E+=K_00_19 | ||
111 | eor r10,r4,r5 @ F_xx_xx | ||
112 | add r6,r6,r7,ror#27 @ E+=ROR(A,27) | ||
113 | #ifdef __ARMEL__ | ||
114 | rev r9,r9 @ byte swap | ||
115 | #endif | ||
116 | #endif | ||
117 | and r10,r3,r10,ror#2 | ||
118 | add r6,r6,r9 @ E+=X[i] | ||
119 | eor r10,r10,r5,ror#2 @ F_00_19(B,C,D) | ||
120 | str r9,[r14,#-4]! | ||
121 | add r6,r6,r10 @ E+=F_00_19(B,C,D) | ||
122 | #if __ARM_ARCH__<7 | ||
123 | ldrb r10,[r1,#2] | ||
124 | ldrb r9,[r1,#3] | ||
125 | ldrb r11,[r1,#1] | ||
126 | add r5,r8,r5,ror#2 @ E+=K_00_19 | ||
127 | ldrb r12,[r1],#4 | ||
128 | orr r9,r9,r10,lsl#8 | ||
129 | eor r10,r3,r4 @ F_xx_xx | ||
130 | orr r9,r9,r11,lsl#16 | ||
131 | add r5,r5,r6,ror#27 @ E+=ROR(A,27) | ||
132 | orr r9,r9,r12,lsl#24 | ||
133 | #else | ||
134 | ldr r9,[r1],#4 @ handles unaligned | ||
135 | add r5,r8,r5,ror#2 @ E+=K_00_19 | ||
136 | eor r10,r3,r4 @ F_xx_xx | ||
137 | add r5,r5,r6,ror#27 @ E+=ROR(A,27) | ||
138 | #ifdef __ARMEL__ | ||
139 | rev r9,r9 @ byte swap | ||
140 | #endif | ||
141 | #endif | ||
142 | and r10,r7,r10,ror#2 | ||
143 | add r5,r5,r9 @ E+=X[i] | ||
144 | eor r10,r10,r4,ror#2 @ F_00_19(B,C,D) | ||
145 | str r9,[r14,#-4]! | ||
146 | add r5,r5,r10 @ E+=F_00_19(B,C,D) | ||
147 | #if __ARM_ARCH__<7 | ||
148 | ldrb r10,[r1,#2] | ||
149 | ldrb r9,[r1,#3] | ||
150 | ldrb r11,[r1,#1] | ||
151 | add r4,r8,r4,ror#2 @ E+=K_00_19 | ||
152 | ldrb r12,[r1],#4 | ||
153 | orr r9,r9,r10,lsl#8 | ||
154 | eor r10,r7,r3 @ F_xx_xx | ||
155 | orr r9,r9,r11,lsl#16 | ||
156 | add r4,r4,r5,ror#27 @ E+=ROR(A,27) | ||
157 | orr r9,r9,r12,lsl#24 | ||
158 | #else | ||
159 | ldr r9,[r1],#4 @ handles unaligned | ||
160 | add r4,r8,r4,ror#2 @ E+=K_00_19 | ||
161 | eor r10,r7,r3 @ F_xx_xx | ||
162 | add r4,r4,r5,ror#27 @ E+=ROR(A,27) | ||
163 | #ifdef __ARMEL__ | ||
164 | rev r9,r9 @ byte swap | ||
165 | #endif | ||
166 | #endif | ||
167 | and r10,r6,r10,ror#2 | ||
168 | add r4,r4,r9 @ E+=X[i] | ||
169 | eor r10,r10,r3,ror#2 @ F_00_19(B,C,D) | ||
170 | str r9,[r14,#-4]! | ||
171 | add r4,r4,r10 @ E+=F_00_19(B,C,D) | ||
172 | #if __ARM_ARCH__<7 | ||
173 | ldrb r10,[r1,#2] | ||
174 | ldrb r9,[r1,#3] | ||
175 | ldrb r11,[r1,#1] | ||
176 | add r3,r8,r3,ror#2 @ E+=K_00_19 | ||
177 | ldrb r12,[r1],#4 | ||
178 | orr r9,r9,r10,lsl#8 | ||
179 | eor r10,r6,r7 @ F_xx_xx | ||
180 | orr r9,r9,r11,lsl#16 | ||
181 | add r3,r3,r4,ror#27 @ E+=ROR(A,27) | ||
182 | orr r9,r9,r12,lsl#24 | ||
183 | #else | ||
184 | ldr r9,[r1],#4 @ handles unaligned | ||
185 | add r3,r8,r3,ror#2 @ E+=K_00_19 | ||
186 | eor r10,r6,r7 @ F_xx_xx | ||
187 | add r3,r3,r4,ror#27 @ E+=ROR(A,27) | ||
188 | #ifdef __ARMEL__ | ||
189 | rev r9,r9 @ byte swap | ||
190 | #endif | ||
191 | #endif | ||
192 | and r10,r5,r10,ror#2 | ||
193 | add r3,r3,r9 @ E+=X[i] | ||
194 | eor r10,r10,r7,ror#2 @ F_00_19(B,C,D) | ||
195 | str r9,[r14,#-4]! | ||
196 | add r3,r3,r10 @ E+=F_00_19(B,C,D) | ||
197 | teq r14,sp | ||
198 | bne .L_00_15 @ [((11+4)*5+2)*3] | ||
199 | #if __ARM_ARCH__<7 | ||
200 | ldrb r10,[r1,#2] | ||
201 | ldrb r9,[r1,#3] | ||
202 | ldrb r11,[r1,#1] | ||
203 | add r7,r8,r7,ror#2 @ E+=K_00_19 | ||
204 | ldrb r12,[r1],#4 | ||
205 | orr r9,r9,r10,lsl#8 | ||
206 | eor r10,r5,r6 @ F_xx_xx | ||
207 | orr r9,r9,r11,lsl#16 | ||
208 | add r7,r7,r3,ror#27 @ E+=ROR(A,27) | ||
209 | orr r9,r9,r12,lsl#24 | ||
210 | #else | ||
211 | ldr r9,[r1],#4 @ handles unaligned | ||
212 | add r7,r8,r7,ror#2 @ E+=K_00_19 | ||
213 | eor r10,r5,r6 @ F_xx_xx | ||
214 | add r7,r7,r3,ror#27 @ E+=ROR(A,27) | ||
215 | #ifdef __ARMEL__ | ||
216 | rev r9,r9 @ byte swap | ||
217 | #endif | ||
218 | #endif | ||
219 | and r10,r4,r10,ror#2 | ||
220 | add r7,r7,r9 @ E+=X[i] | ||
221 | eor r10,r10,r6,ror#2 @ F_00_19(B,C,D) | ||
222 | str r9,[r14,#-4]! | ||
223 | add r7,r7,r10 @ E+=F_00_19(B,C,D) | ||
224 | ldr r9,[r14,#15*4] | ||
225 | ldr r10,[r14,#13*4] | ||
226 | ldr r11,[r14,#7*4] | ||
227 | add r6,r8,r6,ror#2 @ E+=K_xx_xx | ||
228 | ldr r12,[r14,#2*4] | ||
229 | eor r9,r9,r10 | ||
230 | eor r11,r11,r12 @ 1 cycle stall | ||
231 | eor r10,r4,r5 @ F_xx_xx | ||
232 | mov r9,r9,ror#31 | ||
233 | add r6,r6,r7,ror#27 @ E+=ROR(A,27) | ||
234 | eor r9,r9,r11,ror#31 | ||
235 | str r9,[r14,#-4]! | ||
236 | and r10,r3,r10,ror#2 @ F_xx_xx | ||
237 | @ F_xx_xx | ||
238 | add r6,r6,r9 @ E+=X[i] | ||
239 | eor r10,r10,r5,ror#2 @ F_00_19(B,C,D) | ||
240 | add r6,r6,r10 @ E+=F_00_19(B,C,D) | ||
241 | ldr r9,[r14,#15*4] | ||
242 | ldr r10,[r14,#13*4] | ||
243 | ldr r11,[r14,#7*4] | ||
244 | add r5,r8,r5,ror#2 @ E+=K_xx_xx | ||
245 | ldr r12,[r14,#2*4] | ||
246 | eor r9,r9,r10 | ||
247 | eor r11,r11,r12 @ 1 cycle stall | ||
248 | eor r10,r3,r4 @ F_xx_xx | ||
249 | mov r9,r9,ror#31 | ||
250 | add r5,r5,r6,ror#27 @ E+=ROR(A,27) | ||
251 | eor r9,r9,r11,ror#31 | ||
252 | str r9,[r14,#-4]! | ||
253 | and r10,r7,r10,ror#2 @ F_xx_xx | ||
254 | @ F_xx_xx | ||
255 | add r5,r5,r9 @ E+=X[i] | ||
256 | eor r10,r10,r4,ror#2 @ F_00_19(B,C,D) | ||
257 | add r5,r5,r10 @ E+=F_00_19(B,C,D) | ||
258 | ldr r9,[r14,#15*4] | ||
259 | ldr r10,[r14,#13*4] | ||
260 | ldr r11,[r14,#7*4] | ||
261 | add r4,r8,r4,ror#2 @ E+=K_xx_xx | ||
262 | ldr r12,[r14,#2*4] | ||
263 | eor r9,r9,r10 | ||
264 | eor r11,r11,r12 @ 1 cycle stall | ||
265 | eor r10,r7,r3 @ F_xx_xx | ||
266 | mov r9,r9,ror#31 | ||
267 | add r4,r4,r5,ror#27 @ E+=ROR(A,27) | ||
268 | eor r9,r9,r11,ror#31 | ||
269 | str r9,[r14,#-4]! | ||
270 | and r10,r6,r10,ror#2 @ F_xx_xx | ||
271 | @ F_xx_xx | ||
272 | add r4,r4,r9 @ E+=X[i] | ||
273 | eor r10,r10,r3,ror#2 @ F_00_19(B,C,D) | ||
274 | add r4,r4,r10 @ E+=F_00_19(B,C,D) | ||
275 | ldr r9,[r14,#15*4] | ||
276 | ldr r10,[r14,#13*4] | ||
277 | ldr r11,[r14,#7*4] | ||
278 | add r3,r8,r3,ror#2 @ E+=K_xx_xx | ||
279 | ldr r12,[r14,#2*4] | ||
280 | eor r9,r9,r10 | ||
281 | eor r11,r11,r12 @ 1 cycle stall | ||
282 | eor r10,r6,r7 @ F_xx_xx | ||
283 | mov r9,r9,ror#31 | ||
284 | add r3,r3,r4,ror#27 @ E+=ROR(A,27) | ||
285 | eor r9,r9,r11,ror#31 | ||
286 | str r9,[r14,#-4]! | ||
287 | and r10,r5,r10,ror#2 @ F_xx_xx | ||
288 | @ F_xx_xx | ||
289 | add r3,r3,r9 @ E+=X[i] | ||
290 | eor r10,r10,r7,ror#2 @ F_00_19(B,C,D) | ||
291 | add r3,r3,r10 @ E+=F_00_19(B,C,D) | ||
292 | |||
293 | ldr r8,.LK_20_39 @ [+15+16*4] | ||
294 | sub sp,sp,#25*4 | ||
295 | cmn sp,#0 @ [+3], clear carry to denote 20_39 | ||
296 | .L_20_39_or_60_79: | ||
297 | ldr r9,[r14,#15*4] | ||
298 | ldr r10,[r14,#13*4] | ||
299 | ldr r11,[r14,#7*4] | ||
300 | add r7,r8,r7,ror#2 @ E+=K_xx_xx | ||
301 | ldr r12,[r14,#2*4] | ||
302 | eor r9,r9,r10 | ||
303 | eor r11,r11,r12 @ 1 cycle stall | ||
304 | eor r10,r5,r6 @ F_xx_xx | ||
305 | mov r9,r9,ror#31 | ||
306 | add r7,r7,r3,ror#27 @ E+=ROR(A,27) | ||
307 | eor r9,r9,r11,ror#31 | ||
308 | str r9,[r14,#-4]! | ||
309 | eor r10,r4,r10,ror#2 @ F_xx_xx | ||
310 | @ F_xx_xx | ||
311 | add r7,r7,r9 @ E+=X[i] | ||
312 | add r7,r7,r10 @ E+=F_20_39(B,C,D) | ||
313 | ldr r9,[r14,#15*4] | ||
314 | ldr r10,[r14,#13*4] | ||
315 | ldr r11,[r14,#7*4] | ||
316 | add r6,r8,r6,ror#2 @ E+=K_xx_xx | ||
317 | ldr r12,[r14,#2*4] | ||
318 | eor r9,r9,r10 | ||
319 | eor r11,r11,r12 @ 1 cycle stall | ||
320 | eor r10,r4,r5 @ F_xx_xx | ||
321 | mov r9,r9,ror#31 | ||
322 | add r6,r6,r7,ror#27 @ E+=ROR(A,27) | ||
323 | eor r9,r9,r11,ror#31 | ||
324 | str r9,[r14,#-4]! | ||
325 | eor r10,r3,r10,ror#2 @ F_xx_xx | ||
326 | @ F_xx_xx | ||
327 | add r6,r6,r9 @ E+=X[i] | ||
328 | add r6,r6,r10 @ E+=F_20_39(B,C,D) | ||
329 | ldr r9,[r14,#15*4] | ||
330 | ldr r10,[r14,#13*4] | ||
331 | ldr r11,[r14,#7*4] | ||
332 | add r5,r8,r5,ror#2 @ E+=K_xx_xx | ||
333 | ldr r12,[r14,#2*4] | ||
334 | eor r9,r9,r10 | ||
335 | eor r11,r11,r12 @ 1 cycle stall | ||
336 | eor r10,r3,r4 @ F_xx_xx | ||
337 | mov r9,r9,ror#31 | ||
338 | add r5,r5,r6,ror#27 @ E+=ROR(A,27) | ||
339 | eor r9,r9,r11,ror#31 | ||
340 | str r9,[r14,#-4]! | ||
341 | eor r10,r7,r10,ror#2 @ F_xx_xx | ||
342 | @ F_xx_xx | ||
343 | add r5,r5,r9 @ E+=X[i] | ||
344 | add r5,r5,r10 @ E+=F_20_39(B,C,D) | ||
345 | ldr r9,[r14,#15*4] | ||
346 | ldr r10,[r14,#13*4] | ||
347 | ldr r11,[r14,#7*4] | ||
348 | add r4,r8,r4,ror#2 @ E+=K_xx_xx | ||
349 | ldr r12,[r14,#2*4] | ||
350 | eor r9,r9,r10 | ||
351 | eor r11,r11,r12 @ 1 cycle stall | ||
352 | eor r10,r7,r3 @ F_xx_xx | ||
353 | mov r9,r9,ror#31 | ||
354 | add r4,r4,r5,ror#27 @ E+=ROR(A,27) | ||
355 | eor r9,r9,r11,ror#31 | ||
356 | str r9,[r14,#-4]! | ||
357 | eor r10,r6,r10,ror#2 @ F_xx_xx | ||
358 | @ F_xx_xx | ||
359 | add r4,r4,r9 @ E+=X[i] | ||
360 | add r4,r4,r10 @ E+=F_20_39(B,C,D) | ||
361 | ldr r9,[r14,#15*4] | ||
362 | ldr r10,[r14,#13*4] | ||
363 | ldr r11,[r14,#7*4] | ||
364 | add r3,r8,r3,ror#2 @ E+=K_xx_xx | ||
365 | ldr r12,[r14,#2*4] | ||
366 | eor r9,r9,r10 | ||
367 | eor r11,r11,r12 @ 1 cycle stall | ||
368 | eor r10,r6,r7 @ F_xx_xx | ||
369 | mov r9,r9,ror#31 | ||
370 | add r3,r3,r4,ror#27 @ E+=ROR(A,27) | ||
371 | eor r9,r9,r11,ror#31 | ||
372 | str r9,[r14,#-4]! | ||
373 | eor r10,r5,r10,ror#2 @ F_xx_xx | ||
374 | @ F_xx_xx | ||
375 | add r3,r3,r9 @ E+=X[i] | ||
376 | add r3,r3,r10 @ E+=F_20_39(B,C,D) | ||
377 | teq r14,sp @ preserve carry | ||
378 | bne .L_20_39_or_60_79 @ [+((12+3)*5+2)*4] | ||
379 | bcs .L_done @ [+((12+3)*5+2)*4], spare 300 bytes | ||
380 | |||
381 | ldr r8,.LK_40_59 | ||
382 | sub sp,sp,#20*4 @ [+2] | ||
383 | .L_40_59: | ||
384 | ldr r9,[r14,#15*4] | ||
385 | ldr r10,[r14,#13*4] | ||
386 | ldr r11,[r14,#7*4] | ||
387 | add r7,r8,r7,ror#2 @ E+=K_xx_xx | ||
388 | ldr r12,[r14,#2*4] | ||
389 | eor r9,r9,r10 | ||
390 | eor r11,r11,r12 @ 1 cycle stall | ||
391 | eor r10,r5,r6 @ F_xx_xx | ||
392 | mov r9,r9,ror#31 | ||
393 | add r7,r7,r3,ror#27 @ E+=ROR(A,27) | ||
394 | eor r9,r9,r11,ror#31 | ||
395 | str r9,[r14,#-4]! | ||
396 | and r10,r4,r10,ror#2 @ F_xx_xx | ||
397 | and r11,r5,r6 @ F_xx_xx | ||
398 | add r7,r7,r9 @ E+=X[i] | ||
399 | add r7,r7,r10 @ E+=F_40_59(B,C,D) | ||
400 | add r7,r7,r11,ror#2 | ||
401 | ldr r9,[r14,#15*4] | ||
402 | ldr r10,[r14,#13*4] | ||
403 | ldr r11,[r14,#7*4] | ||
404 | add r6,r8,r6,ror#2 @ E+=K_xx_xx | ||
405 | ldr r12,[r14,#2*4] | ||
406 | eor r9,r9,r10 | ||
407 | eor r11,r11,r12 @ 1 cycle stall | ||
408 | eor r10,r4,r5 @ F_xx_xx | ||
409 | mov r9,r9,ror#31 | ||
410 | add r6,r6,r7,ror#27 @ E+=ROR(A,27) | ||
411 | eor r9,r9,r11,ror#31 | ||
412 | str r9,[r14,#-4]! | ||
413 | and r10,r3,r10,ror#2 @ F_xx_xx | ||
414 | and r11,r4,r5 @ F_xx_xx | ||
415 | add r6,r6,r9 @ E+=X[i] | ||
416 | add r6,r6,r10 @ E+=F_40_59(B,C,D) | ||
417 | add r6,r6,r11,ror#2 | ||
418 | ldr r9,[r14,#15*4] | ||
419 | ldr r10,[r14,#13*4] | ||
420 | ldr r11,[r14,#7*4] | ||
421 | add r5,r8,r5,ror#2 @ E+=K_xx_xx | ||
422 | ldr r12,[r14,#2*4] | ||
423 | eor r9,r9,r10 | ||
424 | eor r11,r11,r12 @ 1 cycle stall | ||
425 | eor r10,r3,r4 @ F_xx_xx | ||
426 | mov r9,r9,ror#31 | ||
427 | add r5,r5,r6,ror#27 @ E+=ROR(A,27) | ||
428 | eor r9,r9,r11,ror#31 | ||
429 | str r9,[r14,#-4]! | ||
430 | and r10,r7,r10,ror#2 @ F_xx_xx | ||
431 | and r11,r3,r4 @ F_xx_xx | ||
432 | add r5,r5,r9 @ E+=X[i] | ||
433 | add r5,r5,r10 @ E+=F_40_59(B,C,D) | ||
434 | add r5,r5,r11,ror#2 | ||
435 | ldr r9,[r14,#15*4] | ||
436 | ldr r10,[r14,#13*4] | ||
437 | ldr r11,[r14,#7*4] | ||
438 | add r4,r8,r4,ror#2 @ E+=K_xx_xx | ||
439 | ldr r12,[r14,#2*4] | ||
440 | eor r9,r9,r10 | ||
441 | eor r11,r11,r12 @ 1 cycle stall | ||
442 | eor r10,r7,r3 @ F_xx_xx | ||
443 | mov r9,r9,ror#31 | ||
444 | add r4,r4,r5,ror#27 @ E+=ROR(A,27) | ||
445 | eor r9,r9,r11,ror#31 | ||
446 | str r9,[r14,#-4]! | ||
447 | and r10,r6,r10,ror#2 @ F_xx_xx | ||
448 | and r11,r7,r3 @ F_xx_xx | ||
449 | add r4,r4,r9 @ E+=X[i] | ||
450 | add r4,r4,r10 @ E+=F_40_59(B,C,D) | ||
451 | add r4,r4,r11,ror#2 | ||
452 | ldr r9,[r14,#15*4] | ||
453 | ldr r10,[r14,#13*4] | ||
454 | ldr r11,[r14,#7*4] | ||
455 | add r3,r8,r3,ror#2 @ E+=K_xx_xx | ||
456 | ldr r12,[r14,#2*4] | ||
457 | eor r9,r9,r10 | ||
458 | eor r11,r11,r12 @ 1 cycle stall | ||
459 | eor r10,r6,r7 @ F_xx_xx | ||
460 | mov r9,r9,ror#31 | ||
461 | add r3,r3,r4,ror#27 @ E+=ROR(A,27) | ||
462 | eor r9,r9,r11,ror#31 | ||
463 | str r9,[r14,#-4]! | ||
464 | and r10,r5,r10,ror#2 @ F_xx_xx | ||
465 | and r11,r6,r7 @ F_xx_xx | ||
466 | add r3,r3,r9 @ E+=X[i] | ||
467 | add r3,r3,r10 @ E+=F_40_59(B,C,D) | ||
468 | add r3,r3,r11,ror#2 | ||
469 | teq r14,sp | ||
470 | bne .L_40_59 @ [+((12+5)*5+2)*4] | ||
471 | |||
472 | ldr r8,.LK_60_79 | ||
473 | sub sp,sp,#20*4 | ||
474 | cmp sp,#0 @ set carry to denote 60_79 | ||
475 | b .L_20_39_or_60_79 @ [+4], spare 300 bytes | ||
476 | .L_done: | ||
477 | add sp,sp,#80*4 @ "deallocate" stack frame | ||
478 | ldmia r0,{r8,r9,r10,r11,r12} | ||
479 | add r3,r8,r3 | ||
480 | add r4,r9,r4 | ||
481 | add r5,r10,r5,ror#2 | ||
482 | add r6,r11,r6,ror#2 | ||
483 | add r7,r12,r7,ror#2 | ||
484 | stmia r0,{r3,r4,r5,r6,r7} | ||
485 | teq r1,r2 | ||
486 | bne .Lloop @ [+18], total 1307 | ||
487 | |||
488 | #if __ARM_ARCH__>=5 | ||
489 | ldmia sp!,{r4-r12,pc} | ||
490 | #else | ||
491 | ldmia sp!,{r4-r12,lr} | ||
492 | tst lr,#1 | ||
493 | moveq pc,lr @ be binary compatible with V4, yet | ||
494 | .word 0xe12fff1e @ interoperable with Thumb ISA:-) | ||
495 | #endif | ||
496 | .align 2 | ||
497 | .LK_00_19: .word 0x5a827999 | ||
498 | .LK_20_39: .word 0x6ed9eba1 | ||
499 | .LK_40_59: .word 0x8f1bbcdc | ||
500 | .LK_60_79: .word 0xca62c1d6 | ||
501 | .size sha1_block_data_order,.-sha1_block_data_order | ||
502 | .asciz "SHA1 block transform for ARMv4, CRYPTOGAMS by <appro@openssl.org>" | ||
503 | .align 2 | ||
diff --git a/arch/arm/crypto/sha1_glue.c b/arch/arm/crypto/sha1_glue.c new file mode 100644 index 000000000000..76cd976230bc --- /dev/null +++ b/arch/arm/crypto/sha1_glue.c | |||
@@ -0,0 +1,179 @@ | |||
1 | /* | ||
2 | * Cryptographic API. | ||
3 | * Glue code for the SHA1 Secure Hash Algorithm assembler implementation | ||
4 | * | ||
5 | * This file is based on sha1_generic.c and sha1_ssse3_glue.c | ||
6 | * | ||
7 | * Copyright (c) Alan Smithee. | ||
8 | * Copyright (c) Andrew McDonald <andrew@mcdonald.org.uk> | ||
9 | * Copyright (c) Jean-Francois Dive <jef@linuxbe.org> | ||
10 | * Copyright (c) Mathias Krause <minipli@googlemail.com> | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify it | ||
13 | * under the terms of the GNU General Public License as published by the Free | ||
14 | * Software Foundation; either version 2 of the License, or (at your option) | ||
15 | * any later version. | ||
16 | * | ||
17 | */ | ||
18 | |||
19 | #include <crypto/internal/hash.h> | ||
20 | #include <linux/init.h> | ||
21 | #include <linux/module.h> | ||
22 | #include <linux/cryptohash.h> | ||
23 | #include <linux/types.h> | ||
24 | #include <crypto/sha.h> | ||
25 | #include <asm/byteorder.h> | ||
26 | |||
27 | struct SHA1_CTX { | ||
28 | uint32_t h0,h1,h2,h3,h4; | ||
29 | u64 count; | ||
30 | u8 data[SHA1_BLOCK_SIZE]; | ||
31 | }; | ||
32 | |||
33 | asmlinkage void sha1_block_data_order(struct SHA1_CTX *digest, | ||
34 | const unsigned char *data, unsigned int rounds); | ||
35 | |||
36 | |||
37 | static int sha1_init(struct shash_desc *desc) | ||
38 | { | ||
39 | struct SHA1_CTX *sctx = shash_desc_ctx(desc); | ||
40 | memset(sctx, 0, sizeof(*sctx)); | ||
41 | sctx->h0 = SHA1_H0; | ||
42 | sctx->h1 = SHA1_H1; | ||
43 | sctx->h2 = SHA1_H2; | ||
44 | sctx->h3 = SHA1_H3; | ||
45 | sctx->h4 = SHA1_H4; | ||
46 | return 0; | ||
47 | } | ||
48 | |||
49 | |||
50 | static int __sha1_update(struct SHA1_CTX *sctx, const u8 *data, | ||
51 | unsigned int len, unsigned int partial) | ||
52 | { | ||
53 | unsigned int done = 0; | ||
54 | |||
55 | sctx->count += len; | ||
56 | |||
57 | if (partial) { | ||
58 | done = SHA1_BLOCK_SIZE - partial; | ||
59 | memcpy(sctx->data + partial, data, done); | ||
60 | sha1_block_data_order(sctx, sctx->data, 1); | ||
61 | } | ||
62 | |||
63 | if (len - done >= SHA1_BLOCK_SIZE) { | ||
64 | const unsigned int rounds = (len - done) / SHA1_BLOCK_SIZE; | ||
65 | sha1_block_data_order(sctx, data + done, rounds); | ||
66 | done += rounds * SHA1_BLOCK_SIZE; | ||
67 | } | ||
68 | |||
69 | memcpy(sctx->data, data + done, len - done); | ||
70 | return 0; | ||
71 | } | ||
72 | |||
73 | |||
74 | static int sha1_update(struct shash_desc *desc, const u8 *data, | ||
75 | unsigned int len) | ||
76 | { | ||
77 | struct SHA1_CTX *sctx = shash_desc_ctx(desc); | ||
78 | unsigned int partial = sctx->count % SHA1_BLOCK_SIZE; | ||
79 | int res; | ||
80 | |||
81 | /* Handle the fast case right here */ | ||
82 | if (partial + len < SHA1_BLOCK_SIZE) { | ||
83 | sctx->count += len; | ||
84 | memcpy(sctx->data + partial, data, len); | ||
85 | return 0; | ||
86 | } | ||
87 | res = __sha1_update(sctx, data, len, partial); | ||
88 | return res; | ||
89 | } | ||
90 | |||
91 | |||
92 | /* Add padding and return the message digest. */ | ||
93 | static int sha1_final(struct shash_desc *desc, u8 *out) | ||
94 | { | ||
95 | struct SHA1_CTX *sctx = shash_desc_ctx(desc); | ||
96 | unsigned int i, index, padlen; | ||
97 | __be32 *dst = (__be32 *)out; | ||
98 | __be64 bits; | ||
99 | static const u8 padding[SHA1_BLOCK_SIZE] = { 0x80, }; | ||
100 | |||
101 | bits = cpu_to_be64(sctx->count << 3); | ||
102 | |||
103 | /* Pad out to 56 mod 64 and append length */ | ||
104 | index = sctx->count % SHA1_BLOCK_SIZE; | ||
105 | padlen = (index < 56) ? (56 - index) : ((SHA1_BLOCK_SIZE+56) - index); | ||
106 | /* We need to fill a whole block for __sha1_update() */ | ||
107 | if (padlen <= 56) { | ||
108 | sctx->count += padlen; | ||
109 | memcpy(sctx->data + index, padding, padlen); | ||
110 | } else { | ||
111 | __sha1_update(sctx, padding, padlen, index); | ||
112 | } | ||
113 | __sha1_update(sctx, (const u8 *)&bits, sizeof(bits), 56); | ||
114 | |||
115 | /* Store state in digest */ | ||
116 | for (i = 0; i < 5; i++) | ||
117 | dst[i] = cpu_to_be32(((u32 *)sctx)[i]); | ||
118 | |||
119 | /* Wipe context */ | ||
120 | memset(sctx, 0, sizeof(*sctx)); | ||
121 | return 0; | ||
122 | } | ||
123 | |||
124 | |||
125 | static int sha1_export(struct shash_desc *desc, void *out) | ||
126 | { | ||
127 | struct SHA1_CTX *sctx = shash_desc_ctx(desc); | ||
128 | memcpy(out, sctx, sizeof(*sctx)); | ||
129 | return 0; | ||
130 | } | ||
131 | |||
132 | |||
133 | static int sha1_import(struct shash_desc *desc, const void *in) | ||
134 | { | ||
135 | struct SHA1_CTX *sctx = shash_desc_ctx(desc); | ||
136 | memcpy(sctx, in, sizeof(*sctx)); | ||
137 | return 0; | ||
138 | } | ||
139 | |||
140 | |||
141 | static struct shash_alg alg = { | ||
142 | .digestsize = SHA1_DIGEST_SIZE, | ||
143 | .init = sha1_init, | ||
144 | .update = sha1_update, | ||
145 | .final = sha1_final, | ||
146 | .export = sha1_export, | ||
147 | .import = sha1_import, | ||
148 | .descsize = sizeof(struct SHA1_CTX), | ||
149 | .statesize = sizeof(struct SHA1_CTX), | ||
150 | .base = { | ||
151 | .cra_name = "sha1", | ||
152 | .cra_driver_name= "sha1-asm", | ||
153 | .cra_priority = 150, | ||
154 | .cra_flags = CRYPTO_ALG_TYPE_SHASH, | ||
155 | .cra_blocksize = SHA1_BLOCK_SIZE, | ||
156 | .cra_module = THIS_MODULE, | ||
157 | } | ||
158 | }; | ||
159 | |||
160 | |||
161 | static int __init sha1_mod_init(void) | ||
162 | { | ||
163 | return crypto_register_shash(&alg); | ||
164 | } | ||
165 | |||
166 | |||
167 | static void __exit sha1_mod_fini(void) | ||
168 | { | ||
169 | crypto_unregister_shash(&alg); | ||
170 | } | ||
171 | |||
172 | |||
173 | module_init(sha1_mod_init); | ||
174 | module_exit(sha1_mod_fini); | ||
175 | |||
176 | MODULE_LICENSE("GPL"); | ||
177 | MODULE_DESCRIPTION("SHA1 Secure Hash Algorithm (ARM)"); | ||
178 | MODULE_ALIAS("sha1"); | ||
179 | MODULE_AUTHOR("David McCullough <ucdevel@gmail.com>"); | ||
diff --git a/arch/powerpc/configs/ppc64_defconfig b/arch/powerpc/configs/ppc64_defconfig index 06b56245d78c..de7c4c53f5cf 100644 --- a/arch/powerpc/configs/ppc64_defconfig +++ b/arch/powerpc/configs/ppc64_defconfig | |||
@@ -486,7 +486,8 @@ CONFIG_CRYPTO_TWOFISH=m | |||
486 | CONFIG_CRYPTO_LZO=m | 486 | CONFIG_CRYPTO_LZO=m |
487 | # CONFIG_CRYPTO_ANSI_CPRNG is not set | 487 | # CONFIG_CRYPTO_ANSI_CPRNG is not set |
488 | CONFIG_CRYPTO_HW=y | 488 | CONFIG_CRYPTO_HW=y |
489 | CONFIG_CRYPTO_DEV_NX=m | 489 | CONFIG_CRYPTO_DEV_NX=y |
490 | CONFIG_CRYPTO_DEV_NX_ENCRYPT=m | ||
490 | CONFIG_VIRTUALIZATION=y | 491 | CONFIG_VIRTUALIZATION=y |
491 | CONFIG_KVM_BOOK3S_64=m | 492 | CONFIG_KVM_BOOK3S_64=m |
492 | CONFIG_KVM_BOOK3S_64_HV=y | 493 | CONFIG_KVM_BOOK3S_64_HV=y |
diff --git a/arch/powerpc/configs/pseries_defconfig b/arch/powerpc/configs/pseries_defconfig index 1f65b3c9b59a..9f4a9368f51b 100644 --- a/arch/powerpc/configs/pseries_defconfig +++ b/arch/powerpc/configs/pseries_defconfig | |||
@@ -369,7 +369,8 @@ CONFIG_CRYPTO_TWOFISH=m | |||
369 | CONFIG_CRYPTO_LZO=m | 369 | CONFIG_CRYPTO_LZO=m |
370 | # CONFIG_CRYPTO_ANSI_CPRNG is not set | 370 | # CONFIG_CRYPTO_ANSI_CPRNG is not set |
371 | CONFIG_CRYPTO_HW=y | 371 | CONFIG_CRYPTO_HW=y |
372 | CONFIG_CRYPTO_DEV_NX=m | 372 | CONFIG_CRYPTO_DEV_NX=y |
373 | CONFIG_CRYPTO_DEV_NX_ENCRYPT=m | ||
373 | CONFIG_VIRTUALIZATION=y | 374 | CONFIG_VIRTUALIZATION=y |
374 | CONFIG_KVM_BOOK3S_64=m | 375 | CONFIG_KVM_BOOK3S_64=m |
375 | CONFIG_KVM_BOOK3S_64_HV=y | 376 | CONFIG_KVM_BOOK3S_64_HV=y |
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c index e144498bcddd..47834a3f4938 100644 --- a/arch/powerpc/kernel/prom_init.c +++ b/arch/powerpc/kernel/prom_init.c | |||
@@ -705,6 +705,7 @@ static void __init early_cmdline_parse(void) | |||
705 | #endif | 705 | #endif |
706 | #define OV5_TYPE1_AFFINITY 0x80 /* Type 1 NUMA affinity */ | 706 | #define OV5_TYPE1_AFFINITY 0x80 /* Type 1 NUMA affinity */ |
707 | #define OV5_PFO_HW_RNG 0x80 /* PFO Random Number Generator */ | 707 | #define OV5_PFO_HW_RNG 0x80 /* PFO Random Number Generator */ |
708 | #define OV5_PFO_HW_842 0x40 /* PFO Compression Accelerator */ | ||
708 | #define OV5_PFO_HW_ENCR 0x20 /* PFO Encryption Accelerator */ | 709 | #define OV5_PFO_HW_ENCR 0x20 /* PFO Encryption Accelerator */ |
709 | 710 | ||
710 | /* Option Vector 6: IBM PAPR hints */ | 711 | /* Option Vector 6: IBM PAPR hints */ |
@@ -774,8 +775,7 @@ static unsigned char ibm_architecture_vec[] = { | |||
774 | 0, | 775 | 0, |
775 | 0, | 776 | 0, |
776 | 0, | 777 | 0, |
777 | OV5_PFO_HW_RNG | OV5_PFO_HW_ENCR, | 778 | OV5_PFO_HW_RNG | OV5_PFO_HW_ENCR | OV5_PFO_HW_842, |
778 | |||
779 | /* option vector 6: IBM PAPR hints */ | 779 | /* option vector 6: IBM PAPR hints */ |
780 | 4 - 2, /* length */ | 780 | 4 - 2, /* length */ |
781 | 0, | 781 | 0, |
diff --git a/arch/s390/crypto/aes_s390.c b/arch/s390/crypto/aes_s390.c index e402a9dd4eda..da3c1a7dcd8e 100644 --- a/arch/s390/crypto/aes_s390.c +++ b/arch/s390/crypto/aes_s390.c | |||
@@ -216,7 +216,6 @@ static struct crypto_alg aes_alg = { | |||
216 | .cra_blocksize = AES_BLOCK_SIZE, | 216 | .cra_blocksize = AES_BLOCK_SIZE, |
217 | .cra_ctxsize = sizeof(struct s390_aes_ctx), | 217 | .cra_ctxsize = sizeof(struct s390_aes_ctx), |
218 | .cra_module = THIS_MODULE, | 218 | .cra_module = THIS_MODULE, |
219 | .cra_list = LIST_HEAD_INIT(aes_alg.cra_list), | ||
220 | .cra_init = fallback_init_cip, | 219 | .cra_init = fallback_init_cip, |
221 | .cra_exit = fallback_exit_cip, | 220 | .cra_exit = fallback_exit_cip, |
222 | .cra_u = { | 221 | .cra_u = { |
@@ -398,7 +397,6 @@ static struct crypto_alg ecb_aes_alg = { | |||
398 | .cra_ctxsize = sizeof(struct s390_aes_ctx), | 397 | .cra_ctxsize = sizeof(struct s390_aes_ctx), |
399 | .cra_type = &crypto_blkcipher_type, | 398 | .cra_type = &crypto_blkcipher_type, |
400 | .cra_module = THIS_MODULE, | 399 | .cra_module = THIS_MODULE, |
401 | .cra_list = LIST_HEAD_INIT(ecb_aes_alg.cra_list), | ||
402 | .cra_init = fallback_init_blk, | 400 | .cra_init = fallback_init_blk, |
403 | .cra_exit = fallback_exit_blk, | 401 | .cra_exit = fallback_exit_blk, |
404 | .cra_u = { | 402 | .cra_u = { |
@@ -508,7 +506,6 @@ static struct crypto_alg cbc_aes_alg = { | |||
508 | .cra_ctxsize = sizeof(struct s390_aes_ctx), | 506 | .cra_ctxsize = sizeof(struct s390_aes_ctx), |
509 | .cra_type = &crypto_blkcipher_type, | 507 | .cra_type = &crypto_blkcipher_type, |
510 | .cra_module = THIS_MODULE, | 508 | .cra_module = THIS_MODULE, |
511 | .cra_list = LIST_HEAD_INIT(cbc_aes_alg.cra_list), | ||
512 | .cra_init = fallback_init_blk, | 509 | .cra_init = fallback_init_blk, |
513 | .cra_exit = fallback_exit_blk, | 510 | .cra_exit = fallback_exit_blk, |
514 | .cra_u = { | 511 | .cra_u = { |
@@ -710,7 +707,6 @@ static struct crypto_alg xts_aes_alg = { | |||
710 | .cra_ctxsize = sizeof(struct s390_xts_ctx), | 707 | .cra_ctxsize = sizeof(struct s390_xts_ctx), |
711 | .cra_type = &crypto_blkcipher_type, | 708 | .cra_type = &crypto_blkcipher_type, |
712 | .cra_module = THIS_MODULE, | 709 | .cra_module = THIS_MODULE, |
713 | .cra_list = LIST_HEAD_INIT(xts_aes_alg.cra_list), | ||
714 | .cra_init = xts_fallback_init, | 710 | .cra_init = xts_fallback_init, |
715 | .cra_exit = xts_fallback_exit, | 711 | .cra_exit = xts_fallback_exit, |
716 | .cra_u = { | 712 | .cra_u = { |
@@ -832,7 +828,6 @@ static struct crypto_alg ctr_aes_alg = { | |||
832 | .cra_ctxsize = sizeof(struct s390_aes_ctx), | 828 | .cra_ctxsize = sizeof(struct s390_aes_ctx), |
833 | .cra_type = &crypto_blkcipher_type, | 829 | .cra_type = &crypto_blkcipher_type, |
834 | .cra_module = THIS_MODULE, | 830 | .cra_module = THIS_MODULE, |
835 | .cra_list = LIST_HEAD_INIT(ctr_aes_alg.cra_list), | ||
836 | .cra_u = { | 831 | .cra_u = { |
837 | .blkcipher = { | 832 | .blkcipher = { |
838 | .min_keysize = AES_MIN_KEY_SIZE, | 833 | .min_keysize = AES_MIN_KEY_SIZE, |
diff --git a/arch/s390/crypto/des_s390.c b/arch/s390/crypto/des_s390.c index 1eaa371ca3ee..b49fb96f4207 100644 --- a/arch/s390/crypto/des_s390.c +++ b/arch/s390/crypto/des_s390.c | |||
@@ -70,7 +70,6 @@ static struct crypto_alg des_alg = { | |||
70 | .cra_blocksize = DES_BLOCK_SIZE, | 70 | .cra_blocksize = DES_BLOCK_SIZE, |
71 | .cra_ctxsize = sizeof(struct s390_des_ctx), | 71 | .cra_ctxsize = sizeof(struct s390_des_ctx), |
72 | .cra_module = THIS_MODULE, | 72 | .cra_module = THIS_MODULE, |
73 | .cra_list = LIST_HEAD_INIT(des_alg.cra_list), | ||
74 | .cra_u = { | 73 | .cra_u = { |
75 | .cipher = { | 74 | .cipher = { |
76 | .cia_min_keysize = DES_KEY_SIZE, | 75 | .cia_min_keysize = DES_KEY_SIZE, |
@@ -163,7 +162,6 @@ static struct crypto_alg ecb_des_alg = { | |||
163 | .cra_ctxsize = sizeof(struct s390_des_ctx), | 162 | .cra_ctxsize = sizeof(struct s390_des_ctx), |
164 | .cra_type = &crypto_blkcipher_type, | 163 | .cra_type = &crypto_blkcipher_type, |
165 | .cra_module = THIS_MODULE, | 164 | .cra_module = THIS_MODULE, |
166 | .cra_list = LIST_HEAD_INIT(ecb_des_alg.cra_list), | ||
167 | .cra_u = { | 165 | .cra_u = { |
168 | .blkcipher = { | 166 | .blkcipher = { |
169 | .min_keysize = DES_KEY_SIZE, | 167 | .min_keysize = DES_KEY_SIZE, |
@@ -206,7 +204,6 @@ static struct crypto_alg cbc_des_alg = { | |||
206 | .cra_ctxsize = sizeof(struct s390_des_ctx), | 204 | .cra_ctxsize = sizeof(struct s390_des_ctx), |
207 | .cra_type = &crypto_blkcipher_type, | 205 | .cra_type = &crypto_blkcipher_type, |
208 | .cra_module = THIS_MODULE, | 206 | .cra_module = THIS_MODULE, |
209 | .cra_list = LIST_HEAD_INIT(cbc_des_alg.cra_list), | ||
210 | .cra_u = { | 207 | .cra_u = { |
211 | .blkcipher = { | 208 | .blkcipher = { |
212 | .min_keysize = DES_KEY_SIZE, | 209 | .min_keysize = DES_KEY_SIZE, |
@@ -271,7 +268,6 @@ static struct crypto_alg des3_alg = { | |||
271 | .cra_blocksize = DES_BLOCK_SIZE, | 268 | .cra_blocksize = DES_BLOCK_SIZE, |
272 | .cra_ctxsize = sizeof(struct s390_des_ctx), | 269 | .cra_ctxsize = sizeof(struct s390_des_ctx), |
273 | .cra_module = THIS_MODULE, | 270 | .cra_module = THIS_MODULE, |
274 | .cra_list = LIST_HEAD_INIT(des3_alg.cra_list), | ||
275 | .cra_u = { | 271 | .cra_u = { |
276 | .cipher = { | 272 | .cipher = { |
277 | .cia_min_keysize = DES3_KEY_SIZE, | 273 | .cia_min_keysize = DES3_KEY_SIZE, |
@@ -314,8 +310,6 @@ static struct crypto_alg ecb_des3_alg = { | |||
314 | .cra_ctxsize = sizeof(struct s390_des_ctx), | 310 | .cra_ctxsize = sizeof(struct s390_des_ctx), |
315 | .cra_type = &crypto_blkcipher_type, | 311 | .cra_type = &crypto_blkcipher_type, |
316 | .cra_module = THIS_MODULE, | 312 | .cra_module = THIS_MODULE, |
317 | .cra_list = LIST_HEAD_INIT( | ||
318 | ecb_des3_alg.cra_list), | ||
319 | .cra_u = { | 313 | .cra_u = { |
320 | .blkcipher = { | 314 | .blkcipher = { |
321 | .min_keysize = DES3_KEY_SIZE, | 315 | .min_keysize = DES3_KEY_SIZE, |
@@ -358,8 +352,6 @@ static struct crypto_alg cbc_des3_alg = { | |||
358 | .cra_ctxsize = sizeof(struct s390_des_ctx), | 352 | .cra_ctxsize = sizeof(struct s390_des_ctx), |
359 | .cra_type = &crypto_blkcipher_type, | 353 | .cra_type = &crypto_blkcipher_type, |
360 | .cra_module = THIS_MODULE, | 354 | .cra_module = THIS_MODULE, |
361 | .cra_list = LIST_HEAD_INIT( | ||
362 | cbc_des3_alg.cra_list), | ||
363 | .cra_u = { | 355 | .cra_u = { |
364 | .blkcipher = { | 356 | .blkcipher = { |
365 | .min_keysize = DES3_KEY_SIZE, | 357 | .min_keysize = DES3_KEY_SIZE, |
@@ -452,7 +444,6 @@ static struct crypto_alg ctr_des_alg = { | |||
452 | .cra_ctxsize = sizeof(struct s390_des_ctx), | 444 | .cra_ctxsize = sizeof(struct s390_des_ctx), |
453 | .cra_type = &crypto_blkcipher_type, | 445 | .cra_type = &crypto_blkcipher_type, |
454 | .cra_module = THIS_MODULE, | 446 | .cra_module = THIS_MODULE, |
455 | .cra_list = LIST_HEAD_INIT(ctr_des_alg.cra_list), | ||
456 | .cra_u = { | 447 | .cra_u = { |
457 | .blkcipher = { | 448 | .blkcipher = { |
458 | .min_keysize = DES_KEY_SIZE, | 449 | .min_keysize = DES_KEY_SIZE, |
@@ -496,7 +487,6 @@ static struct crypto_alg ctr_des3_alg = { | |||
496 | .cra_ctxsize = sizeof(struct s390_des_ctx), | 487 | .cra_ctxsize = sizeof(struct s390_des_ctx), |
497 | .cra_type = &crypto_blkcipher_type, | 488 | .cra_type = &crypto_blkcipher_type, |
498 | .cra_module = THIS_MODULE, | 489 | .cra_module = THIS_MODULE, |
499 | .cra_list = LIST_HEAD_INIT(ctr_des3_alg.cra_list), | ||
500 | .cra_u = { | 490 | .cra_u = { |
501 | .blkcipher = { | 491 | .blkcipher = { |
502 | .min_keysize = DES3_KEY_SIZE, | 492 | .min_keysize = DES3_KEY_SIZE, |
diff --git a/arch/s390/crypto/ghash_s390.c b/arch/s390/crypto/ghash_s390.c index b1bd170f24b1..1ebd3a15cca4 100644 --- a/arch/s390/crypto/ghash_s390.c +++ b/arch/s390/crypto/ghash_s390.c | |||
@@ -135,7 +135,6 @@ static struct shash_alg ghash_alg = { | |||
135 | .cra_blocksize = GHASH_BLOCK_SIZE, | 135 | .cra_blocksize = GHASH_BLOCK_SIZE, |
136 | .cra_ctxsize = sizeof(struct ghash_ctx), | 136 | .cra_ctxsize = sizeof(struct ghash_ctx), |
137 | .cra_module = THIS_MODULE, | 137 | .cra_module = THIS_MODULE, |
138 | .cra_list = LIST_HEAD_INIT(ghash_alg.base.cra_list), | ||
139 | }, | 138 | }, |
140 | }; | 139 | }; |
141 | 140 | ||
diff --git a/arch/x86/crypto/Makefile b/arch/x86/crypto/Makefile index e908e5de82d3..5bacb4a226ac 100644 --- a/arch/x86/crypto/Makefile +++ b/arch/x86/crypto/Makefile | |||
@@ -12,6 +12,8 @@ obj-$(CONFIG_CRYPTO_SERPENT_SSE2_586) += serpent-sse2-i586.o | |||
12 | 12 | ||
13 | obj-$(CONFIG_CRYPTO_AES_X86_64) += aes-x86_64.o | 13 | obj-$(CONFIG_CRYPTO_AES_X86_64) += aes-x86_64.o |
14 | obj-$(CONFIG_CRYPTO_CAMELLIA_X86_64) += camellia-x86_64.o | 14 | obj-$(CONFIG_CRYPTO_CAMELLIA_X86_64) += camellia-x86_64.o |
15 | obj-$(CONFIG_CRYPTO_CAST5_AVX_X86_64) += cast5-avx-x86_64.o | ||
16 | obj-$(CONFIG_CRYPTO_CAST6_AVX_X86_64) += cast6-avx-x86_64.o | ||
15 | obj-$(CONFIG_CRYPTO_BLOWFISH_X86_64) += blowfish-x86_64.o | 17 | obj-$(CONFIG_CRYPTO_BLOWFISH_X86_64) += blowfish-x86_64.o |
16 | obj-$(CONFIG_CRYPTO_TWOFISH_X86_64) += twofish-x86_64.o | 18 | obj-$(CONFIG_CRYPTO_TWOFISH_X86_64) += twofish-x86_64.o |
17 | obj-$(CONFIG_CRYPTO_TWOFISH_X86_64_3WAY) += twofish-x86_64-3way.o | 19 | obj-$(CONFIG_CRYPTO_TWOFISH_X86_64_3WAY) += twofish-x86_64-3way.o |
@@ -32,6 +34,8 @@ serpent-sse2-i586-y := serpent-sse2-i586-asm_32.o serpent_sse2_glue.o | |||
32 | 34 | ||
33 | aes-x86_64-y := aes-x86_64-asm_64.o aes_glue.o | 35 | aes-x86_64-y := aes-x86_64-asm_64.o aes_glue.o |
34 | camellia-x86_64-y := camellia-x86_64-asm_64.o camellia_glue.o | 36 | camellia-x86_64-y := camellia-x86_64-asm_64.o camellia_glue.o |
37 | cast5-avx-x86_64-y := cast5-avx-x86_64-asm_64.o cast5_avx_glue.o | ||
38 | cast6-avx-x86_64-y := cast6-avx-x86_64-asm_64.o cast6_avx_glue.o | ||
35 | blowfish-x86_64-y := blowfish-x86_64-asm_64.o blowfish_glue.o | 39 | blowfish-x86_64-y := blowfish-x86_64-asm_64.o blowfish_glue.o |
36 | twofish-x86_64-y := twofish-x86_64-asm_64.o twofish_glue.o | 40 | twofish-x86_64-y := twofish-x86_64-asm_64.o twofish_glue.o |
37 | twofish-x86_64-3way-y := twofish-x86_64-asm_64-3way.o twofish_glue_3way.o | 41 | twofish-x86_64-3way-y := twofish-x86_64-asm_64-3way.o twofish_glue_3way.o |
diff --git a/arch/x86/crypto/aes_glue.c b/arch/x86/crypto/aes_glue.c index 59b37deb8c8d..aafe8ce0d65d 100644 --- a/arch/x86/crypto/aes_glue.c +++ b/arch/x86/crypto/aes_glue.c | |||
@@ -40,7 +40,6 @@ static struct crypto_alg aes_alg = { | |||
40 | .cra_blocksize = AES_BLOCK_SIZE, | 40 | .cra_blocksize = AES_BLOCK_SIZE, |
41 | .cra_ctxsize = sizeof(struct crypto_aes_ctx), | 41 | .cra_ctxsize = sizeof(struct crypto_aes_ctx), |
42 | .cra_module = THIS_MODULE, | 42 | .cra_module = THIS_MODULE, |
43 | .cra_list = LIST_HEAD_INIT(aes_alg.cra_list), | ||
44 | .cra_u = { | 43 | .cra_u = { |
45 | .cipher = { | 44 | .cipher = { |
46 | .cia_min_keysize = AES_MIN_KEY_SIZE, | 45 | .cia_min_keysize = AES_MIN_KEY_SIZE, |
diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c index 34fdcff4d2c8..7c04d0da709b 100644 --- a/arch/x86/crypto/aesni-intel_glue.c +++ b/arch/x86/crypto/aesni-intel_glue.c | |||
@@ -28,6 +28,9 @@ | |||
28 | #include <crypto/aes.h> | 28 | #include <crypto/aes.h> |
29 | #include <crypto/cryptd.h> | 29 | #include <crypto/cryptd.h> |
30 | #include <crypto/ctr.h> | 30 | #include <crypto/ctr.h> |
31 | #include <crypto/b128ops.h> | ||
32 | #include <crypto/lrw.h> | ||
33 | #include <crypto/xts.h> | ||
31 | #include <asm/cpu_device_id.h> | 34 | #include <asm/cpu_device_id.h> |
32 | #include <asm/i387.h> | 35 | #include <asm/i387.h> |
33 | #include <asm/crypto/aes.h> | 36 | #include <asm/crypto/aes.h> |
@@ -41,18 +44,10 @@ | |||
41 | #define HAS_CTR | 44 | #define HAS_CTR |
42 | #endif | 45 | #endif |
43 | 46 | ||
44 | #if defined(CONFIG_CRYPTO_LRW) || defined(CONFIG_CRYPTO_LRW_MODULE) | ||
45 | #define HAS_LRW | ||
46 | #endif | ||
47 | |||
48 | #if defined(CONFIG_CRYPTO_PCBC) || defined(CONFIG_CRYPTO_PCBC_MODULE) | 47 | #if defined(CONFIG_CRYPTO_PCBC) || defined(CONFIG_CRYPTO_PCBC_MODULE) |
49 | #define HAS_PCBC | 48 | #define HAS_PCBC |
50 | #endif | 49 | #endif |
51 | 50 | ||
52 | #if defined(CONFIG_CRYPTO_XTS) || defined(CONFIG_CRYPTO_XTS_MODULE) | ||
53 | #define HAS_XTS | ||
54 | #endif | ||
55 | |||
56 | /* This data is stored at the end of the crypto_tfm struct. | 51 | /* This data is stored at the end of the crypto_tfm struct. |
57 | * It's a type of per "session" data storage location. | 52 | * It's a type of per "session" data storage location. |
58 | * This needs to be 16 byte aligned. | 53 | * This needs to be 16 byte aligned. |
@@ -79,6 +74,16 @@ struct aesni_hash_subkey_req_data { | |||
79 | #define AES_BLOCK_MASK (~(AES_BLOCK_SIZE-1)) | 74 | #define AES_BLOCK_MASK (~(AES_BLOCK_SIZE-1)) |
80 | #define RFC4106_HASH_SUBKEY_SIZE 16 | 75 | #define RFC4106_HASH_SUBKEY_SIZE 16 |
81 | 76 | ||
77 | struct aesni_lrw_ctx { | ||
78 | struct lrw_table_ctx lrw_table; | ||
79 | u8 raw_aes_ctx[sizeof(struct crypto_aes_ctx) + AESNI_ALIGN - 1]; | ||
80 | }; | ||
81 | |||
82 | struct aesni_xts_ctx { | ||
83 | u8 raw_tweak_ctx[sizeof(struct crypto_aes_ctx) + AESNI_ALIGN - 1]; | ||
84 | u8 raw_crypt_ctx[sizeof(struct crypto_aes_ctx) + AESNI_ALIGN - 1]; | ||
85 | }; | ||
86 | |||
82 | asmlinkage int aesni_set_key(struct crypto_aes_ctx *ctx, const u8 *in_key, | 87 | asmlinkage int aesni_set_key(struct crypto_aes_ctx *ctx, const u8 *in_key, |
83 | unsigned int key_len); | 88 | unsigned int key_len); |
84 | asmlinkage void aesni_enc(struct crypto_aes_ctx *ctx, u8 *out, | 89 | asmlinkage void aesni_enc(struct crypto_aes_ctx *ctx, u8 *out, |
@@ -398,13 +403,6 @@ static int ablk_rfc3686_ctr_init(struct crypto_tfm *tfm) | |||
398 | #endif | 403 | #endif |
399 | #endif | 404 | #endif |
400 | 405 | ||
401 | #ifdef HAS_LRW | ||
402 | static int ablk_lrw_init(struct crypto_tfm *tfm) | ||
403 | { | ||
404 | return ablk_init_common(tfm, "fpu(lrw(__driver-aes-aesni))"); | ||
405 | } | ||
406 | #endif | ||
407 | |||
408 | #ifdef HAS_PCBC | 406 | #ifdef HAS_PCBC |
409 | static int ablk_pcbc_init(struct crypto_tfm *tfm) | 407 | static int ablk_pcbc_init(struct crypto_tfm *tfm) |
410 | { | 408 | { |
@@ -412,12 +410,160 @@ static int ablk_pcbc_init(struct crypto_tfm *tfm) | |||
412 | } | 410 | } |
413 | #endif | 411 | #endif |
414 | 412 | ||
415 | #ifdef HAS_XTS | 413 | static void lrw_xts_encrypt_callback(void *ctx, u8 *blks, unsigned int nbytes) |
416 | static int ablk_xts_init(struct crypto_tfm *tfm) | ||
417 | { | 414 | { |
418 | return ablk_init_common(tfm, "fpu(xts(__driver-aes-aesni))"); | 415 | aesni_ecb_enc(ctx, blks, blks, nbytes); |
416 | } | ||
417 | |||
418 | static void lrw_xts_decrypt_callback(void *ctx, u8 *blks, unsigned int nbytes) | ||
419 | { | ||
420 | aesni_ecb_dec(ctx, blks, blks, nbytes); | ||
421 | } | ||
422 | |||
423 | static int lrw_aesni_setkey(struct crypto_tfm *tfm, const u8 *key, | ||
424 | unsigned int keylen) | ||
425 | { | ||
426 | struct aesni_lrw_ctx *ctx = crypto_tfm_ctx(tfm); | ||
427 | int err; | ||
428 | |||
429 | err = aes_set_key_common(tfm, ctx->raw_aes_ctx, key, | ||
430 | keylen - AES_BLOCK_SIZE); | ||
431 | if (err) | ||
432 | return err; | ||
433 | |||
434 | return lrw_init_table(&ctx->lrw_table, key + keylen - AES_BLOCK_SIZE); | ||
435 | } | ||
436 | |||
437 | static void lrw_aesni_exit_tfm(struct crypto_tfm *tfm) | ||
438 | { | ||
439 | struct aesni_lrw_ctx *ctx = crypto_tfm_ctx(tfm); | ||
440 | |||
441 | lrw_free_table(&ctx->lrw_table); | ||
442 | } | ||
443 | |||
444 | static int lrw_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, | ||
445 | struct scatterlist *src, unsigned int nbytes) | ||
446 | { | ||
447 | struct aesni_lrw_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); | ||
448 | be128 buf[8]; | ||
449 | struct lrw_crypt_req req = { | ||
450 | .tbuf = buf, | ||
451 | .tbuflen = sizeof(buf), | ||
452 | |||
453 | .table_ctx = &ctx->lrw_table, | ||
454 | .crypt_ctx = aes_ctx(ctx->raw_aes_ctx), | ||
455 | .crypt_fn = lrw_xts_encrypt_callback, | ||
456 | }; | ||
457 | int ret; | ||
458 | |||
459 | desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; | ||
460 | |||
461 | kernel_fpu_begin(); | ||
462 | ret = lrw_crypt(desc, dst, src, nbytes, &req); | ||
463 | kernel_fpu_end(); | ||
464 | |||
465 | return ret; | ||
466 | } | ||
467 | |||
468 | static int lrw_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, | ||
469 | struct scatterlist *src, unsigned int nbytes) | ||
470 | { | ||
471 | struct aesni_lrw_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); | ||
472 | be128 buf[8]; | ||
473 | struct lrw_crypt_req req = { | ||
474 | .tbuf = buf, | ||
475 | .tbuflen = sizeof(buf), | ||
476 | |||
477 | .table_ctx = &ctx->lrw_table, | ||
478 | .crypt_ctx = aes_ctx(ctx->raw_aes_ctx), | ||
479 | .crypt_fn = lrw_xts_decrypt_callback, | ||
480 | }; | ||
481 | int ret; | ||
482 | |||
483 | desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; | ||
484 | |||
485 | kernel_fpu_begin(); | ||
486 | ret = lrw_crypt(desc, dst, src, nbytes, &req); | ||
487 | kernel_fpu_end(); | ||
488 | |||
489 | return ret; | ||
490 | } | ||
491 | |||
492 | static int xts_aesni_setkey(struct crypto_tfm *tfm, const u8 *key, | ||
493 | unsigned int keylen) | ||
494 | { | ||
495 | struct aesni_xts_ctx *ctx = crypto_tfm_ctx(tfm); | ||
496 | u32 *flags = &tfm->crt_flags; | ||
497 | int err; | ||
498 | |||
499 | /* key consists of keys of equal size concatenated, therefore | ||
500 | * the length must be even | ||
501 | */ | ||
502 | if (keylen % 2) { | ||
503 | *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; | ||
504 | return -EINVAL; | ||
505 | } | ||
506 | |||
507 | /* first half of xts-key is for crypt */ | ||
508 | err = aes_set_key_common(tfm, ctx->raw_crypt_ctx, key, keylen / 2); | ||
509 | if (err) | ||
510 | return err; | ||
511 | |||
512 | /* second half of xts-key is for tweak */ | ||
513 | return aes_set_key_common(tfm, ctx->raw_tweak_ctx, key + keylen / 2, | ||
514 | keylen / 2); | ||
515 | } | ||
516 | |||
517 | |||
518 | static int xts_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, | ||
519 | struct scatterlist *src, unsigned int nbytes) | ||
520 | { | ||
521 | struct aesni_xts_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); | ||
522 | be128 buf[8]; | ||
523 | struct xts_crypt_req req = { | ||
524 | .tbuf = buf, | ||
525 | .tbuflen = sizeof(buf), | ||
526 | |||
527 | .tweak_ctx = aes_ctx(ctx->raw_tweak_ctx), | ||
528 | .tweak_fn = XTS_TWEAK_CAST(aesni_enc), | ||
529 | .crypt_ctx = aes_ctx(ctx->raw_crypt_ctx), | ||
530 | .crypt_fn = lrw_xts_encrypt_callback, | ||
531 | }; | ||
532 | int ret; | ||
533 | |||
534 | desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; | ||
535 | |||
536 | kernel_fpu_begin(); | ||
537 | ret = xts_crypt(desc, dst, src, nbytes, &req); | ||
538 | kernel_fpu_end(); | ||
539 | |||
540 | return ret; | ||
541 | } | ||
542 | |||
543 | static int xts_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, | ||
544 | struct scatterlist *src, unsigned int nbytes) | ||
545 | { | ||
546 | struct aesni_xts_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); | ||
547 | be128 buf[8]; | ||
548 | struct xts_crypt_req req = { | ||
549 | .tbuf = buf, | ||
550 | .tbuflen = sizeof(buf), | ||
551 | |||
552 | .tweak_ctx = aes_ctx(ctx->raw_tweak_ctx), | ||
553 | .tweak_fn = XTS_TWEAK_CAST(aesni_enc), | ||
554 | .crypt_ctx = aes_ctx(ctx->raw_crypt_ctx), | ||
555 | .crypt_fn = lrw_xts_decrypt_callback, | ||
556 | }; | ||
557 | int ret; | ||
558 | |||
559 | desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; | ||
560 | |||
561 | kernel_fpu_begin(); | ||
562 | ret = xts_crypt(desc, dst, src, nbytes, &req); | ||
563 | kernel_fpu_end(); | ||
564 | |||
565 | return ret; | ||
419 | } | 566 | } |
420 | #endif | ||
421 | 567 | ||
422 | #ifdef CONFIG_X86_64 | 568 | #ifdef CONFIG_X86_64 |
423 | static int rfc4106_init(struct crypto_tfm *tfm) | 569 | static int rfc4106_init(struct crypto_tfm *tfm) |
@@ -1035,10 +1181,10 @@ static struct crypto_alg aesni_algs[] = { { | |||
1035 | }, | 1181 | }, |
1036 | #endif | 1182 | #endif |
1037 | #endif | 1183 | #endif |
1038 | #ifdef HAS_LRW | 1184 | #ifdef HAS_PCBC |
1039 | }, { | 1185 | }, { |
1040 | .cra_name = "lrw(aes)", | 1186 | .cra_name = "pcbc(aes)", |
1041 | .cra_driver_name = "lrw-aes-aesni", | 1187 | .cra_driver_name = "pcbc-aes-aesni", |
1042 | .cra_priority = 400, | 1188 | .cra_priority = 400, |
1043 | .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, | 1189 | .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, |
1044 | .cra_blocksize = AES_BLOCK_SIZE, | 1190 | .cra_blocksize = AES_BLOCK_SIZE, |
@@ -1046,12 +1192,12 @@ static struct crypto_alg aesni_algs[] = { { | |||
1046 | .cra_alignmask = 0, | 1192 | .cra_alignmask = 0, |
1047 | .cra_type = &crypto_ablkcipher_type, | 1193 | .cra_type = &crypto_ablkcipher_type, |
1048 | .cra_module = THIS_MODULE, | 1194 | .cra_module = THIS_MODULE, |
1049 | .cra_init = ablk_lrw_init, | 1195 | .cra_init = ablk_pcbc_init, |
1050 | .cra_exit = ablk_exit, | 1196 | .cra_exit = ablk_exit, |
1051 | .cra_u = { | 1197 | .cra_u = { |
1052 | .ablkcipher = { | 1198 | .ablkcipher = { |
1053 | .min_keysize = AES_MIN_KEY_SIZE + AES_BLOCK_SIZE, | 1199 | .min_keysize = AES_MIN_KEY_SIZE, |
1054 | .max_keysize = AES_MAX_KEY_SIZE + AES_BLOCK_SIZE, | 1200 | .max_keysize = AES_MAX_KEY_SIZE, |
1055 | .ivsize = AES_BLOCK_SIZE, | 1201 | .ivsize = AES_BLOCK_SIZE, |
1056 | .setkey = ablk_set_key, | 1202 | .setkey = ablk_set_key, |
1057 | .encrypt = ablk_encrypt, | 1203 | .encrypt = ablk_encrypt, |
@@ -1059,10 +1205,50 @@ static struct crypto_alg aesni_algs[] = { { | |||
1059 | }, | 1205 | }, |
1060 | }, | 1206 | }, |
1061 | #endif | 1207 | #endif |
1062 | #ifdef HAS_PCBC | ||
1063 | }, { | 1208 | }, { |
1064 | .cra_name = "pcbc(aes)", | 1209 | .cra_name = "__lrw-aes-aesni", |
1065 | .cra_driver_name = "pcbc-aes-aesni", | 1210 | .cra_driver_name = "__driver-lrw-aes-aesni", |
1211 | .cra_priority = 0, | ||
1212 | .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, | ||
1213 | .cra_blocksize = AES_BLOCK_SIZE, | ||
1214 | .cra_ctxsize = sizeof(struct aesni_lrw_ctx), | ||
1215 | .cra_alignmask = 0, | ||
1216 | .cra_type = &crypto_blkcipher_type, | ||
1217 | .cra_module = THIS_MODULE, | ||
1218 | .cra_exit = lrw_aesni_exit_tfm, | ||
1219 | .cra_u = { | ||
1220 | .blkcipher = { | ||
1221 | .min_keysize = AES_MIN_KEY_SIZE + AES_BLOCK_SIZE, | ||
1222 | .max_keysize = AES_MAX_KEY_SIZE + AES_BLOCK_SIZE, | ||
1223 | .ivsize = AES_BLOCK_SIZE, | ||
1224 | .setkey = lrw_aesni_setkey, | ||
1225 | .encrypt = lrw_encrypt, | ||
1226 | .decrypt = lrw_decrypt, | ||
1227 | }, | ||
1228 | }, | ||
1229 | }, { | ||
1230 | .cra_name = "__xts-aes-aesni", | ||
1231 | .cra_driver_name = "__driver-xts-aes-aesni", | ||
1232 | .cra_priority = 0, | ||
1233 | .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, | ||
1234 | .cra_blocksize = AES_BLOCK_SIZE, | ||
1235 | .cra_ctxsize = sizeof(struct aesni_xts_ctx), | ||
1236 | .cra_alignmask = 0, | ||
1237 | .cra_type = &crypto_blkcipher_type, | ||
1238 | .cra_module = THIS_MODULE, | ||
1239 | .cra_u = { | ||
1240 | .blkcipher = { | ||
1241 | .min_keysize = 2 * AES_MIN_KEY_SIZE, | ||
1242 | .max_keysize = 2 * AES_MAX_KEY_SIZE, | ||
1243 | .ivsize = AES_BLOCK_SIZE, | ||
1244 | .setkey = xts_aesni_setkey, | ||
1245 | .encrypt = xts_encrypt, | ||
1246 | .decrypt = xts_decrypt, | ||
1247 | }, | ||
1248 | }, | ||
1249 | }, { | ||
1250 | .cra_name = "lrw(aes)", | ||
1251 | .cra_driver_name = "lrw-aes-aesni", | ||
1066 | .cra_priority = 400, | 1252 | .cra_priority = 400, |
1067 | .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, | 1253 | .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, |
1068 | .cra_blocksize = AES_BLOCK_SIZE, | 1254 | .cra_blocksize = AES_BLOCK_SIZE, |
@@ -1070,20 +1256,18 @@ static struct crypto_alg aesni_algs[] = { { | |||
1070 | .cra_alignmask = 0, | 1256 | .cra_alignmask = 0, |
1071 | .cra_type = &crypto_ablkcipher_type, | 1257 | .cra_type = &crypto_ablkcipher_type, |
1072 | .cra_module = THIS_MODULE, | 1258 | .cra_module = THIS_MODULE, |
1073 | .cra_init = ablk_pcbc_init, | 1259 | .cra_init = ablk_init, |
1074 | .cra_exit = ablk_exit, | 1260 | .cra_exit = ablk_exit, |
1075 | .cra_u = { | 1261 | .cra_u = { |
1076 | .ablkcipher = { | 1262 | .ablkcipher = { |
1077 | .min_keysize = AES_MIN_KEY_SIZE, | 1263 | .min_keysize = AES_MIN_KEY_SIZE + AES_BLOCK_SIZE, |
1078 | .max_keysize = AES_MAX_KEY_SIZE, | 1264 | .max_keysize = AES_MAX_KEY_SIZE + AES_BLOCK_SIZE, |
1079 | .ivsize = AES_BLOCK_SIZE, | 1265 | .ivsize = AES_BLOCK_SIZE, |
1080 | .setkey = ablk_set_key, | 1266 | .setkey = ablk_set_key, |
1081 | .encrypt = ablk_encrypt, | 1267 | .encrypt = ablk_encrypt, |
1082 | .decrypt = ablk_decrypt, | 1268 | .decrypt = ablk_decrypt, |
1083 | }, | 1269 | }, |
1084 | }, | 1270 | }, |
1085 | #endif | ||
1086 | #ifdef HAS_XTS | ||
1087 | }, { | 1271 | }, { |
1088 | .cra_name = "xts(aes)", | 1272 | .cra_name = "xts(aes)", |
1089 | .cra_driver_name = "xts-aes-aesni", | 1273 | .cra_driver_name = "xts-aes-aesni", |
@@ -1094,7 +1278,7 @@ static struct crypto_alg aesni_algs[] = { { | |||
1094 | .cra_alignmask = 0, | 1278 | .cra_alignmask = 0, |
1095 | .cra_type = &crypto_ablkcipher_type, | 1279 | .cra_type = &crypto_ablkcipher_type, |
1096 | .cra_module = THIS_MODULE, | 1280 | .cra_module = THIS_MODULE, |
1097 | .cra_init = ablk_xts_init, | 1281 | .cra_init = ablk_init, |
1098 | .cra_exit = ablk_exit, | 1282 | .cra_exit = ablk_exit, |
1099 | .cra_u = { | 1283 | .cra_u = { |
1100 | .ablkcipher = { | 1284 | .ablkcipher = { |
@@ -1106,7 +1290,6 @@ static struct crypto_alg aesni_algs[] = { { | |||
1106 | .decrypt = ablk_decrypt, | 1290 | .decrypt = ablk_decrypt, |
1107 | }, | 1291 | }, |
1108 | }, | 1292 | }, |
1109 | #endif | ||
1110 | } }; | 1293 | } }; |
1111 | 1294 | ||
1112 | 1295 | ||
@@ -1118,7 +1301,7 @@ MODULE_DEVICE_TABLE(x86cpu, aesni_cpu_id); | |||
1118 | 1301 | ||
1119 | static int __init aesni_init(void) | 1302 | static int __init aesni_init(void) |
1120 | { | 1303 | { |
1121 | int err, i; | 1304 | int err; |
1122 | 1305 | ||
1123 | if (!x86_match_cpu(aesni_cpu_id)) | 1306 | if (!x86_match_cpu(aesni_cpu_id)) |
1124 | return -ENODEV; | 1307 | return -ENODEV; |
@@ -1127,9 +1310,6 @@ static int __init aesni_init(void) | |||
1127 | if (err) | 1310 | if (err) |
1128 | return err; | 1311 | return err; |
1129 | 1312 | ||
1130 | for (i = 0; i < ARRAY_SIZE(aesni_algs); i++) | ||
1131 | INIT_LIST_HEAD(&aesni_algs[i].cra_list); | ||
1132 | |||
1133 | return crypto_register_algs(aesni_algs, ARRAY_SIZE(aesni_algs)); | 1313 | return crypto_register_algs(aesni_algs, ARRAY_SIZE(aesni_algs)); |
1134 | } | 1314 | } |
1135 | 1315 | ||
diff --git a/arch/x86/crypto/blowfish_glue.c b/arch/x86/crypto/blowfish_glue.c index 7967474de8f7..50ec333b70e6 100644 --- a/arch/x86/crypto/blowfish_glue.c +++ b/arch/x86/crypto/blowfish_glue.c | |||
@@ -367,7 +367,6 @@ static struct crypto_alg bf_algs[4] = { { | |||
367 | .cra_ctxsize = sizeof(struct bf_ctx), | 367 | .cra_ctxsize = sizeof(struct bf_ctx), |
368 | .cra_alignmask = 0, | 368 | .cra_alignmask = 0, |
369 | .cra_module = THIS_MODULE, | 369 | .cra_module = THIS_MODULE, |
370 | .cra_list = LIST_HEAD_INIT(bf_algs[0].cra_list), | ||
371 | .cra_u = { | 370 | .cra_u = { |
372 | .cipher = { | 371 | .cipher = { |
373 | .cia_min_keysize = BF_MIN_KEY_SIZE, | 372 | .cia_min_keysize = BF_MIN_KEY_SIZE, |
@@ -387,7 +386,6 @@ static struct crypto_alg bf_algs[4] = { { | |||
387 | .cra_alignmask = 0, | 386 | .cra_alignmask = 0, |
388 | .cra_type = &crypto_blkcipher_type, | 387 | .cra_type = &crypto_blkcipher_type, |
389 | .cra_module = THIS_MODULE, | 388 | .cra_module = THIS_MODULE, |
390 | .cra_list = LIST_HEAD_INIT(bf_algs[1].cra_list), | ||
391 | .cra_u = { | 389 | .cra_u = { |
392 | .blkcipher = { | 390 | .blkcipher = { |
393 | .min_keysize = BF_MIN_KEY_SIZE, | 391 | .min_keysize = BF_MIN_KEY_SIZE, |
@@ -407,7 +405,6 @@ static struct crypto_alg bf_algs[4] = { { | |||
407 | .cra_alignmask = 0, | 405 | .cra_alignmask = 0, |
408 | .cra_type = &crypto_blkcipher_type, | 406 | .cra_type = &crypto_blkcipher_type, |
409 | .cra_module = THIS_MODULE, | 407 | .cra_module = THIS_MODULE, |
410 | .cra_list = LIST_HEAD_INIT(bf_algs[2].cra_list), | ||
411 | .cra_u = { | 408 | .cra_u = { |
412 | .blkcipher = { | 409 | .blkcipher = { |
413 | .min_keysize = BF_MIN_KEY_SIZE, | 410 | .min_keysize = BF_MIN_KEY_SIZE, |
@@ -428,7 +425,6 @@ static struct crypto_alg bf_algs[4] = { { | |||
428 | .cra_alignmask = 0, | 425 | .cra_alignmask = 0, |
429 | .cra_type = &crypto_blkcipher_type, | 426 | .cra_type = &crypto_blkcipher_type, |
430 | .cra_module = THIS_MODULE, | 427 | .cra_module = THIS_MODULE, |
431 | .cra_list = LIST_HEAD_INIT(bf_algs[3].cra_list), | ||
432 | .cra_u = { | 428 | .cra_u = { |
433 | .blkcipher = { | 429 | .blkcipher = { |
434 | .min_keysize = BF_MIN_KEY_SIZE, | 430 | .min_keysize = BF_MIN_KEY_SIZE, |
diff --git a/arch/x86/crypto/camellia_glue.c b/arch/x86/crypto/camellia_glue.c index eeb2b3b743e9..42ffd2bbab5b 100644 --- a/arch/x86/crypto/camellia_glue.c +++ b/arch/x86/crypto/camellia_glue.c | |||
@@ -92,715 +92,715 @@ static void camellia_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) | |||
92 | 92 | ||
93 | /* camellia sboxes */ | 93 | /* camellia sboxes */ |
94 | const u64 camellia_sp10011110[256] = { | 94 | const u64 camellia_sp10011110[256] = { |
95 | 0x7000007070707000, 0x8200008282828200, 0x2c00002c2c2c2c00, | 95 | 0x7000007070707000ULL, 0x8200008282828200ULL, 0x2c00002c2c2c2c00ULL, |
96 | 0xec0000ecececec00, 0xb30000b3b3b3b300, 0x2700002727272700, | 96 | 0xec0000ecececec00ULL, 0xb30000b3b3b3b300ULL, 0x2700002727272700ULL, |
97 | 0xc00000c0c0c0c000, 0xe50000e5e5e5e500, 0xe40000e4e4e4e400, | 97 | 0xc00000c0c0c0c000ULL, 0xe50000e5e5e5e500ULL, 0xe40000e4e4e4e400ULL, |
98 | 0x8500008585858500, 0x5700005757575700, 0x3500003535353500, | 98 | 0x8500008585858500ULL, 0x5700005757575700ULL, 0x3500003535353500ULL, |
99 | 0xea0000eaeaeaea00, 0x0c00000c0c0c0c00, 0xae0000aeaeaeae00, | 99 | 0xea0000eaeaeaea00ULL, 0x0c00000c0c0c0c00ULL, 0xae0000aeaeaeae00ULL, |
100 | 0x4100004141414100, 0x2300002323232300, 0xef0000efefefef00, | 100 | 0x4100004141414100ULL, 0x2300002323232300ULL, 0xef0000efefefef00ULL, |
101 | 0x6b00006b6b6b6b00, 0x9300009393939300, 0x4500004545454500, | 101 | 0x6b00006b6b6b6b00ULL, 0x9300009393939300ULL, 0x4500004545454500ULL, |
102 | 0x1900001919191900, 0xa50000a5a5a5a500, 0x2100002121212100, | 102 | 0x1900001919191900ULL, 0xa50000a5a5a5a500ULL, 0x2100002121212100ULL, |
103 | 0xed0000edededed00, 0x0e00000e0e0e0e00, 0x4f00004f4f4f4f00, | 103 | 0xed0000edededed00ULL, 0x0e00000e0e0e0e00ULL, 0x4f00004f4f4f4f00ULL, |
104 | 0x4e00004e4e4e4e00, 0x1d00001d1d1d1d00, 0x6500006565656500, | 104 | 0x4e00004e4e4e4e00ULL, 0x1d00001d1d1d1d00ULL, 0x6500006565656500ULL, |
105 | 0x9200009292929200, 0xbd0000bdbdbdbd00, 0x8600008686868600, | 105 | 0x9200009292929200ULL, 0xbd0000bdbdbdbd00ULL, 0x8600008686868600ULL, |
106 | 0xb80000b8b8b8b800, 0xaf0000afafafaf00, 0x8f00008f8f8f8f00, | 106 | 0xb80000b8b8b8b800ULL, 0xaf0000afafafaf00ULL, 0x8f00008f8f8f8f00ULL, |
107 | 0x7c00007c7c7c7c00, 0xeb0000ebebebeb00, 0x1f00001f1f1f1f00, | 107 | 0x7c00007c7c7c7c00ULL, 0xeb0000ebebebeb00ULL, 0x1f00001f1f1f1f00ULL, |
108 | 0xce0000cececece00, 0x3e00003e3e3e3e00, 0x3000003030303000, | 108 | 0xce0000cececece00ULL, 0x3e00003e3e3e3e00ULL, 0x3000003030303000ULL, |
109 | 0xdc0000dcdcdcdc00, 0x5f00005f5f5f5f00, 0x5e00005e5e5e5e00, | 109 | 0xdc0000dcdcdcdc00ULL, 0x5f00005f5f5f5f00ULL, 0x5e00005e5e5e5e00ULL, |
110 | 0xc50000c5c5c5c500, 0x0b00000b0b0b0b00, 0x1a00001a1a1a1a00, | 110 | 0xc50000c5c5c5c500ULL, 0x0b00000b0b0b0b00ULL, 0x1a00001a1a1a1a00ULL, |
111 | 0xa60000a6a6a6a600, 0xe10000e1e1e1e100, 0x3900003939393900, | 111 | 0xa60000a6a6a6a600ULL, 0xe10000e1e1e1e100ULL, 0x3900003939393900ULL, |
112 | 0xca0000cacacaca00, 0xd50000d5d5d5d500, 0x4700004747474700, | 112 | 0xca0000cacacaca00ULL, 0xd50000d5d5d5d500ULL, 0x4700004747474700ULL, |
113 | 0x5d00005d5d5d5d00, 0x3d00003d3d3d3d00, 0xd90000d9d9d9d900, | 113 | 0x5d00005d5d5d5d00ULL, 0x3d00003d3d3d3d00ULL, 0xd90000d9d9d9d900ULL, |
114 | 0x0100000101010100, 0x5a00005a5a5a5a00, 0xd60000d6d6d6d600, | 114 | 0x0100000101010100ULL, 0x5a00005a5a5a5a00ULL, 0xd60000d6d6d6d600ULL, |
115 | 0x5100005151515100, 0x5600005656565600, 0x6c00006c6c6c6c00, | 115 | 0x5100005151515100ULL, 0x5600005656565600ULL, 0x6c00006c6c6c6c00ULL, |
116 | 0x4d00004d4d4d4d00, 0x8b00008b8b8b8b00, 0x0d00000d0d0d0d00, | 116 | 0x4d00004d4d4d4d00ULL, 0x8b00008b8b8b8b00ULL, 0x0d00000d0d0d0d00ULL, |
117 | 0x9a00009a9a9a9a00, 0x6600006666666600, 0xfb0000fbfbfbfb00, | 117 | 0x9a00009a9a9a9a00ULL, 0x6600006666666600ULL, 0xfb0000fbfbfbfb00ULL, |
118 | 0xcc0000cccccccc00, 0xb00000b0b0b0b000, 0x2d00002d2d2d2d00, | 118 | 0xcc0000cccccccc00ULL, 0xb00000b0b0b0b000ULL, 0x2d00002d2d2d2d00ULL, |
119 | 0x7400007474747400, 0x1200001212121200, 0x2b00002b2b2b2b00, | 119 | 0x7400007474747400ULL, 0x1200001212121200ULL, 0x2b00002b2b2b2b00ULL, |
120 | 0x2000002020202000, 0xf00000f0f0f0f000, 0xb10000b1b1b1b100, | 120 | 0x2000002020202000ULL, 0xf00000f0f0f0f000ULL, 0xb10000b1b1b1b100ULL, |
121 | 0x8400008484848400, 0x9900009999999900, 0xdf0000dfdfdfdf00, | 121 | 0x8400008484848400ULL, 0x9900009999999900ULL, 0xdf0000dfdfdfdf00ULL, |
122 | 0x4c00004c4c4c4c00, 0xcb0000cbcbcbcb00, 0xc20000c2c2c2c200, | 122 | 0x4c00004c4c4c4c00ULL, 0xcb0000cbcbcbcb00ULL, 0xc20000c2c2c2c200ULL, |
123 | 0x3400003434343400, 0x7e00007e7e7e7e00, 0x7600007676767600, | 123 | 0x3400003434343400ULL, 0x7e00007e7e7e7e00ULL, 0x7600007676767600ULL, |
124 | 0x0500000505050500, 0x6d00006d6d6d6d00, 0xb70000b7b7b7b700, | 124 | 0x0500000505050500ULL, 0x6d00006d6d6d6d00ULL, 0xb70000b7b7b7b700ULL, |
125 | 0xa90000a9a9a9a900, 0x3100003131313100, 0xd10000d1d1d1d100, | 125 | 0xa90000a9a9a9a900ULL, 0x3100003131313100ULL, 0xd10000d1d1d1d100ULL, |
126 | 0x1700001717171700, 0x0400000404040400, 0xd70000d7d7d7d700, | 126 | 0x1700001717171700ULL, 0x0400000404040400ULL, 0xd70000d7d7d7d700ULL, |
127 | 0x1400001414141400, 0x5800005858585800, 0x3a00003a3a3a3a00, | 127 | 0x1400001414141400ULL, 0x5800005858585800ULL, 0x3a00003a3a3a3a00ULL, |
128 | 0x6100006161616100, 0xde0000dededede00, 0x1b00001b1b1b1b00, | 128 | 0x6100006161616100ULL, 0xde0000dededede00ULL, 0x1b00001b1b1b1b00ULL, |
129 | 0x1100001111111100, 0x1c00001c1c1c1c00, 0x3200003232323200, | 129 | 0x1100001111111100ULL, 0x1c00001c1c1c1c00ULL, 0x3200003232323200ULL, |
130 | 0x0f00000f0f0f0f00, 0x9c00009c9c9c9c00, 0x1600001616161600, | 130 | 0x0f00000f0f0f0f00ULL, 0x9c00009c9c9c9c00ULL, 0x1600001616161600ULL, |
131 | 0x5300005353535300, 0x1800001818181800, 0xf20000f2f2f2f200, | 131 | 0x5300005353535300ULL, 0x1800001818181800ULL, 0xf20000f2f2f2f200ULL, |
132 | 0x2200002222222200, 0xfe0000fefefefe00, 0x4400004444444400, | 132 | 0x2200002222222200ULL, 0xfe0000fefefefe00ULL, 0x4400004444444400ULL, |
133 | 0xcf0000cfcfcfcf00, 0xb20000b2b2b2b200, 0xc30000c3c3c3c300, | 133 | 0xcf0000cfcfcfcf00ULL, 0xb20000b2b2b2b200ULL, 0xc30000c3c3c3c300ULL, |
134 | 0xb50000b5b5b5b500, 0x7a00007a7a7a7a00, 0x9100009191919100, | 134 | 0xb50000b5b5b5b500ULL, 0x7a00007a7a7a7a00ULL, 0x9100009191919100ULL, |
135 | 0x2400002424242400, 0x0800000808080800, 0xe80000e8e8e8e800, | 135 | 0x2400002424242400ULL, 0x0800000808080800ULL, 0xe80000e8e8e8e800ULL, |
136 | 0xa80000a8a8a8a800, 0x6000006060606000, 0xfc0000fcfcfcfc00, | 136 | 0xa80000a8a8a8a800ULL, 0x6000006060606000ULL, 0xfc0000fcfcfcfc00ULL, |
137 | 0x6900006969696900, 0x5000005050505000, 0xaa0000aaaaaaaa00, | 137 | 0x6900006969696900ULL, 0x5000005050505000ULL, 0xaa0000aaaaaaaa00ULL, |
138 | 0xd00000d0d0d0d000, 0xa00000a0a0a0a000, 0x7d00007d7d7d7d00, | 138 | 0xd00000d0d0d0d000ULL, 0xa00000a0a0a0a000ULL, 0x7d00007d7d7d7d00ULL, |
139 | 0xa10000a1a1a1a100, 0x8900008989898900, 0x6200006262626200, | 139 | 0xa10000a1a1a1a100ULL, 0x8900008989898900ULL, 0x6200006262626200ULL, |
140 | 0x9700009797979700, 0x5400005454545400, 0x5b00005b5b5b5b00, | 140 | 0x9700009797979700ULL, 0x5400005454545400ULL, 0x5b00005b5b5b5b00ULL, |
141 | 0x1e00001e1e1e1e00, 0x9500009595959500, 0xe00000e0e0e0e000, | 141 | 0x1e00001e1e1e1e00ULL, 0x9500009595959500ULL, 0xe00000e0e0e0e000ULL, |
142 | 0xff0000ffffffff00, 0x6400006464646400, 0xd20000d2d2d2d200, | 142 | 0xff0000ffffffff00ULL, 0x6400006464646400ULL, 0xd20000d2d2d2d200ULL, |
143 | 0x1000001010101000, 0xc40000c4c4c4c400, 0x0000000000000000, | 143 | 0x1000001010101000ULL, 0xc40000c4c4c4c400ULL, 0x0000000000000000ULL, |
144 | 0x4800004848484800, 0xa30000a3a3a3a300, 0xf70000f7f7f7f700, | 144 | 0x4800004848484800ULL, 0xa30000a3a3a3a300ULL, 0xf70000f7f7f7f700ULL, |
145 | 0x7500007575757500, 0xdb0000dbdbdbdb00, 0x8a00008a8a8a8a00, | 145 | 0x7500007575757500ULL, 0xdb0000dbdbdbdb00ULL, 0x8a00008a8a8a8a00ULL, |
146 | 0x0300000303030300, 0xe60000e6e6e6e600, 0xda0000dadadada00, | 146 | 0x0300000303030300ULL, 0xe60000e6e6e6e600ULL, 0xda0000dadadada00ULL, |
147 | 0x0900000909090900, 0x3f00003f3f3f3f00, 0xdd0000dddddddd00, | 147 | 0x0900000909090900ULL, 0x3f00003f3f3f3f00ULL, 0xdd0000dddddddd00ULL, |
148 | 0x9400009494949400, 0x8700008787878700, 0x5c00005c5c5c5c00, | 148 | 0x9400009494949400ULL, 0x8700008787878700ULL, 0x5c00005c5c5c5c00ULL, |
149 | 0x8300008383838300, 0x0200000202020200, 0xcd0000cdcdcdcd00, | 149 | 0x8300008383838300ULL, 0x0200000202020200ULL, 0xcd0000cdcdcdcd00ULL, |
150 | 0x4a00004a4a4a4a00, 0x9000009090909000, 0x3300003333333300, | 150 | 0x4a00004a4a4a4a00ULL, 0x9000009090909000ULL, 0x3300003333333300ULL, |
151 | 0x7300007373737300, 0x6700006767676700, 0xf60000f6f6f6f600, | 151 | 0x7300007373737300ULL, 0x6700006767676700ULL, 0xf60000f6f6f6f600ULL, |
152 | 0xf30000f3f3f3f300, 0x9d00009d9d9d9d00, 0x7f00007f7f7f7f00, | 152 | 0xf30000f3f3f3f300ULL, 0x9d00009d9d9d9d00ULL, 0x7f00007f7f7f7f00ULL, |
153 | 0xbf0000bfbfbfbf00, 0xe20000e2e2e2e200, 0x5200005252525200, | 153 | 0xbf0000bfbfbfbf00ULL, 0xe20000e2e2e2e200ULL, 0x5200005252525200ULL, |
154 | 0x9b00009b9b9b9b00, 0xd80000d8d8d8d800, 0x2600002626262600, | 154 | 0x9b00009b9b9b9b00ULL, 0xd80000d8d8d8d800ULL, 0x2600002626262600ULL, |
155 | 0xc80000c8c8c8c800, 0x3700003737373700, 0xc60000c6c6c6c600, | 155 | 0xc80000c8c8c8c800ULL, 0x3700003737373700ULL, 0xc60000c6c6c6c600ULL, |
156 | 0x3b00003b3b3b3b00, 0x8100008181818100, 0x9600009696969600, | 156 | 0x3b00003b3b3b3b00ULL, 0x8100008181818100ULL, 0x9600009696969600ULL, |
157 | 0x6f00006f6f6f6f00, 0x4b00004b4b4b4b00, 0x1300001313131300, | 157 | 0x6f00006f6f6f6f00ULL, 0x4b00004b4b4b4b00ULL, 0x1300001313131300ULL, |
158 | 0xbe0000bebebebe00, 0x6300006363636300, 0x2e00002e2e2e2e00, | 158 | 0xbe0000bebebebe00ULL, 0x6300006363636300ULL, 0x2e00002e2e2e2e00ULL, |
159 | 0xe90000e9e9e9e900, 0x7900007979797900, 0xa70000a7a7a7a700, | 159 | 0xe90000e9e9e9e900ULL, 0x7900007979797900ULL, 0xa70000a7a7a7a700ULL, |
160 | 0x8c00008c8c8c8c00, 0x9f00009f9f9f9f00, 0x6e00006e6e6e6e00, | 160 | 0x8c00008c8c8c8c00ULL, 0x9f00009f9f9f9f00ULL, 0x6e00006e6e6e6e00ULL, |
161 | 0xbc0000bcbcbcbc00, 0x8e00008e8e8e8e00, 0x2900002929292900, | 161 | 0xbc0000bcbcbcbc00ULL, 0x8e00008e8e8e8e00ULL, 0x2900002929292900ULL, |
162 | 0xf50000f5f5f5f500, 0xf90000f9f9f9f900, 0xb60000b6b6b6b600, | 162 | 0xf50000f5f5f5f500ULL, 0xf90000f9f9f9f900ULL, 0xb60000b6b6b6b600ULL, |
163 | 0x2f00002f2f2f2f00, 0xfd0000fdfdfdfd00, 0xb40000b4b4b4b400, | 163 | 0x2f00002f2f2f2f00ULL, 0xfd0000fdfdfdfd00ULL, 0xb40000b4b4b4b400ULL, |
164 | 0x5900005959595900, 0x7800007878787800, 0x9800009898989800, | 164 | 0x5900005959595900ULL, 0x7800007878787800ULL, 0x9800009898989800ULL, |
165 | 0x0600000606060600, 0x6a00006a6a6a6a00, 0xe70000e7e7e7e700, | 165 | 0x0600000606060600ULL, 0x6a00006a6a6a6a00ULL, 0xe70000e7e7e7e700ULL, |
166 | 0x4600004646464600, 0x7100007171717100, 0xba0000babababa00, | 166 | 0x4600004646464600ULL, 0x7100007171717100ULL, 0xba0000babababa00ULL, |
167 | 0xd40000d4d4d4d400, 0x2500002525252500, 0xab0000abababab00, | 167 | 0xd40000d4d4d4d400ULL, 0x2500002525252500ULL, 0xab0000abababab00ULL, |
168 | 0x4200004242424200, 0x8800008888888800, 0xa20000a2a2a2a200, | 168 | 0x4200004242424200ULL, 0x8800008888888800ULL, 0xa20000a2a2a2a200ULL, |
169 | 0x8d00008d8d8d8d00, 0xfa0000fafafafa00, 0x7200007272727200, | 169 | 0x8d00008d8d8d8d00ULL, 0xfa0000fafafafa00ULL, 0x7200007272727200ULL, |
170 | 0x0700000707070700, 0xb90000b9b9b9b900, 0x5500005555555500, | 170 | 0x0700000707070700ULL, 0xb90000b9b9b9b900ULL, 0x5500005555555500ULL, |
171 | 0xf80000f8f8f8f800, 0xee0000eeeeeeee00, 0xac0000acacacac00, | 171 | 0xf80000f8f8f8f800ULL, 0xee0000eeeeeeee00ULL, 0xac0000acacacac00ULL, |
172 | 0x0a00000a0a0a0a00, 0x3600003636363600, 0x4900004949494900, | 172 | 0x0a00000a0a0a0a00ULL, 0x3600003636363600ULL, 0x4900004949494900ULL, |
173 | 0x2a00002a2a2a2a00, 0x6800006868686800, 0x3c00003c3c3c3c00, | 173 | 0x2a00002a2a2a2a00ULL, 0x6800006868686800ULL, 0x3c00003c3c3c3c00ULL, |
174 | 0x3800003838383800, 0xf10000f1f1f1f100, 0xa40000a4a4a4a400, | 174 | 0x3800003838383800ULL, 0xf10000f1f1f1f100ULL, 0xa40000a4a4a4a400ULL, |
175 | 0x4000004040404000, 0x2800002828282800, 0xd30000d3d3d3d300, | 175 | 0x4000004040404000ULL, 0x2800002828282800ULL, 0xd30000d3d3d3d300ULL, |
176 | 0x7b00007b7b7b7b00, 0xbb0000bbbbbbbb00, 0xc90000c9c9c9c900, | 176 | 0x7b00007b7b7b7b00ULL, 0xbb0000bbbbbbbb00ULL, 0xc90000c9c9c9c900ULL, |
177 | 0x4300004343434300, 0xc10000c1c1c1c100, 0x1500001515151500, | 177 | 0x4300004343434300ULL, 0xc10000c1c1c1c100ULL, 0x1500001515151500ULL, |
178 | 0xe30000e3e3e3e300, 0xad0000adadadad00, 0xf40000f4f4f4f400, | 178 | 0xe30000e3e3e3e300ULL, 0xad0000adadadad00ULL, 0xf40000f4f4f4f400ULL, |
179 | 0x7700007777777700, 0xc70000c7c7c7c700, 0x8000008080808000, | 179 | 0x7700007777777700ULL, 0xc70000c7c7c7c700ULL, 0x8000008080808000ULL, |
180 | 0x9e00009e9e9e9e00, | 180 | 0x9e00009e9e9e9e00ULL, |
181 | }; | 181 | }; |
182 | 182 | ||
183 | const u64 camellia_sp22000222[256] = { | 183 | const u64 camellia_sp22000222[256] = { |
184 | 0xe0e0000000e0e0e0, 0x0505000000050505, 0x5858000000585858, | 184 | 0xe0e0000000e0e0e0ULL, 0x0505000000050505ULL, 0x5858000000585858ULL, |
185 | 0xd9d9000000d9d9d9, 0x6767000000676767, 0x4e4e0000004e4e4e, | 185 | 0xd9d9000000d9d9d9ULL, 0x6767000000676767ULL, 0x4e4e0000004e4e4eULL, |
186 | 0x8181000000818181, 0xcbcb000000cbcbcb, 0xc9c9000000c9c9c9, | 186 | 0x8181000000818181ULL, 0xcbcb000000cbcbcbULL, 0xc9c9000000c9c9c9ULL, |
187 | 0x0b0b0000000b0b0b, 0xaeae000000aeaeae, 0x6a6a0000006a6a6a, | 187 | 0x0b0b0000000b0b0bULL, 0xaeae000000aeaeaeULL, 0x6a6a0000006a6a6aULL, |
188 | 0xd5d5000000d5d5d5, 0x1818000000181818, 0x5d5d0000005d5d5d, | 188 | 0xd5d5000000d5d5d5ULL, 0x1818000000181818ULL, 0x5d5d0000005d5d5dULL, |
189 | 0x8282000000828282, 0x4646000000464646, 0xdfdf000000dfdfdf, | 189 | 0x8282000000828282ULL, 0x4646000000464646ULL, 0xdfdf000000dfdfdfULL, |
190 | 0xd6d6000000d6d6d6, 0x2727000000272727, 0x8a8a0000008a8a8a, | 190 | 0xd6d6000000d6d6d6ULL, 0x2727000000272727ULL, 0x8a8a0000008a8a8aULL, |
191 | 0x3232000000323232, 0x4b4b0000004b4b4b, 0x4242000000424242, | 191 | 0x3232000000323232ULL, 0x4b4b0000004b4b4bULL, 0x4242000000424242ULL, |
192 | 0xdbdb000000dbdbdb, 0x1c1c0000001c1c1c, 0x9e9e0000009e9e9e, | 192 | 0xdbdb000000dbdbdbULL, 0x1c1c0000001c1c1cULL, 0x9e9e0000009e9e9eULL, |
193 | 0x9c9c0000009c9c9c, 0x3a3a0000003a3a3a, 0xcaca000000cacaca, | 193 | 0x9c9c0000009c9c9cULL, 0x3a3a0000003a3a3aULL, 0xcaca000000cacacaULL, |
194 | 0x2525000000252525, 0x7b7b0000007b7b7b, 0x0d0d0000000d0d0d, | 194 | 0x2525000000252525ULL, 0x7b7b0000007b7b7bULL, 0x0d0d0000000d0d0dULL, |
195 | 0x7171000000717171, 0x5f5f0000005f5f5f, 0x1f1f0000001f1f1f, | 195 | 0x7171000000717171ULL, 0x5f5f0000005f5f5fULL, 0x1f1f0000001f1f1fULL, |
196 | 0xf8f8000000f8f8f8, 0xd7d7000000d7d7d7, 0x3e3e0000003e3e3e, | 196 | 0xf8f8000000f8f8f8ULL, 0xd7d7000000d7d7d7ULL, 0x3e3e0000003e3e3eULL, |
197 | 0x9d9d0000009d9d9d, 0x7c7c0000007c7c7c, 0x6060000000606060, | 197 | 0x9d9d0000009d9d9dULL, 0x7c7c0000007c7c7cULL, 0x6060000000606060ULL, |
198 | 0xb9b9000000b9b9b9, 0xbebe000000bebebe, 0xbcbc000000bcbcbc, | 198 | 0xb9b9000000b9b9b9ULL, 0xbebe000000bebebeULL, 0xbcbc000000bcbcbcULL, |
199 | 0x8b8b0000008b8b8b, 0x1616000000161616, 0x3434000000343434, | 199 | 0x8b8b0000008b8b8bULL, 0x1616000000161616ULL, 0x3434000000343434ULL, |
200 | 0x4d4d0000004d4d4d, 0xc3c3000000c3c3c3, 0x7272000000727272, | 200 | 0x4d4d0000004d4d4dULL, 0xc3c3000000c3c3c3ULL, 0x7272000000727272ULL, |
201 | 0x9595000000959595, 0xabab000000ababab, 0x8e8e0000008e8e8e, | 201 | 0x9595000000959595ULL, 0xabab000000abababULL, 0x8e8e0000008e8e8eULL, |
202 | 0xbaba000000bababa, 0x7a7a0000007a7a7a, 0xb3b3000000b3b3b3, | 202 | 0xbaba000000bababaULL, 0x7a7a0000007a7a7aULL, 0xb3b3000000b3b3b3ULL, |
203 | 0x0202000000020202, 0xb4b4000000b4b4b4, 0xadad000000adadad, | 203 | 0x0202000000020202ULL, 0xb4b4000000b4b4b4ULL, 0xadad000000adadadULL, |
204 | 0xa2a2000000a2a2a2, 0xacac000000acacac, 0xd8d8000000d8d8d8, | 204 | 0xa2a2000000a2a2a2ULL, 0xacac000000acacacULL, 0xd8d8000000d8d8d8ULL, |
205 | 0x9a9a0000009a9a9a, 0x1717000000171717, 0x1a1a0000001a1a1a, | 205 | 0x9a9a0000009a9a9aULL, 0x1717000000171717ULL, 0x1a1a0000001a1a1aULL, |
206 | 0x3535000000353535, 0xcccc000000cccccc, 0xf7f7000000f7f7f7, | 206 | 0x3535000000353535ULL, 0xcccc000000ccccccULL, 0xf7f7000000f7f7f7ULL, |
207 | 0x9999000000999999, 0x6161000000616161, 0x5a5a0000005a5a5a, | 207 | 0x9999000000999999ULL, 0x6161000000616161ULL, 0x5a5a0000005a5a5aULL, |
208 | 0xe8e8000000e8e8e8, 0x2424000000242424, 0x5656000000565656, | 208 | 0xe8e8000000e8e8e8ULL, 0x2424000000242424ULL, 0x5656000000565656ULL, |
209 | 0x4040000000404040, 0xe1e1000000e1e1e1, 0x6363000000636363, | 209 | 0x4040000000404040ULL, 0xe1e1000000e1e1e1ULL, 0x6363000000636363ULL, |
210 | 0x0909000000090909, 0x3333000000333333, 0xbfbf000000bfbfbf, | 210 | 0x0909000000090909ULL, 0x3333000000333333ULL, 0xbfbf000000bfbfbfULL, |
211 | 0x9898000000989898, 0x9797000000979797, 0x8585000000858585, | 211 | 0x9898000000989898ULL, 0x9797000000979797ULL, 0x8585000000858585ULL, |
212 | 0x6868000000686868, 0xfcfc000000fcfcfc, 0xecec000000ececec, | 212 | 0x6868000000686868ULL, 0xfcfc000000fcfcfcULL, 0xecec000000ecececULL, |
213 | 0x0a0a0000000a0a0a, 0xdada000000dadada, 0x6f6f0000006f6f6f, | 213 | 0x0a0a0000000a0a0aULL, 0xdada000000dadadaULL, 0x6f6f0000006f6f6fULL, |
214 | 0x5353000000535353, 0x6262000000626262, 0xa3a3000000a3a3a3, | 214 | 0x5353000000535353ULL, 0x6262000000626262ULL, 0xa3a3000000a3a3a3ULL, |
215 | 0x2e2e0000002e2e2e, 0x0808000000080808, 0xafaf000000afafaf, | 215 | 0x2e2e0000002e2e2eULL, 0x0808000000080808ULL, 0xafaf000000afafafULL, |
216 | 0x2828000000282828, 0xb0b0000000b0b0b0, 0x7474000000747474, | 216 | 0x2828000000282828ULL, 0xb0b0000000b0b0b0ULL, 0x7474000000747474ULL, |
217 | 0xc2c2000000c2c2c2, 0xbdbd000000bdbdbd, 0x3636000000363636, | 217 | 0xc2c2000000c2c2c2ULL, 0xbdbd000000bdbdbdULL, 0x3636000000363636ULL, |
218 | 0x2222000000222222, 0x3838000000383838, 0x6464000000646464, | 218 | 0x2222000000222222ULL, 0x3838000000383838ULL, 0x6464000000646464ULL, |
219 | 0x1e1e0000001e1e1e, 0x3939000000393939, 0x2c2c0000002c2c2c, | 219 | 0x1e1e0000001e1e1eULL, 0x3939000000393939ULL, 0x2c2c0000002c2c2cULL, |
220 | 0xa6a6000000a6a6a6, 0x3030000000303030, 0xe5e5000000e5e5e5, | 220 | 0xa6a6000000a6a6a6ULL, 0x3030000000303030ULL, 0xe5e5000000e5e5e5ULL, |
221 | 0x4444000000444444, 0xfdfd000000fdfdfd, 0x8888000000888888, | 221 | 0x4444000000444444ULL, 0xfdfd000000fdfdfdULL, 0x8888000000888888ULL, |
222 | 0x9f9f0000009f9f9f, 0x6565000000656565, 0x8787000000878787, | 222 | 0x9f9f0000009f9f9fULL, 0x6565000000656565ULL, 0x8787000000878787ULL, |
223 | 0x6b6b0000006b6b6b, 0xf4f4000000f4f4f4, 0x2323000000232323, | 223 | 0x6b6b0000006b6b6bULL, 0xf4f4000000f4f4f4ULL, 0x2323000000232323ULL, |
224 | 0x4848000000484848, 0x1010000000101010, 0xd1d1000000d1d1d1, | 224 | 0x4848000000484848ULL, 0x1010000000101010ULL, 0xd1d1000000d1d1d1ULL, |
225 | 0x5151000000515151, 0xc0c0000000c0c0c0, 0xf9f9000000f9f9f9, | 225 | 0x5151000000515151ULL, 0xc0c0000000c0c0c0ULL, 0xf9f9000000f9f9f9ULL, |
226 | 0xd2d2000000d2d2d2, 0xa0a0000000a0a0a0, 0x5555000000555555, | 226 | 0xd2d2000000d2d2d2ULL, 0xa0a0000000a0a0a0ULL, 0x5555000000555555ULL, |
227 | 0xa1a1000000a1a1a1, 0x4141000000414141, 0xfafa000000fafafa, | 227 | 0xa1a1000000a1a1a1ULL, 0x4141000000414141ULL, 0xfafa000000fafafaULL, |
228 | 0x4343000000434343, 0x1313000000131313, 0xc4c4000000c4c4c4, | 228 | 0x4343000000434343ULL, 0x1313000000131313ULL, 0xc4c4000000c4c4c4ULL, |
229 | 0x2f2f0000002f2f2f, 0xa8a8000000a8a8a8, 0xb6b6000000b6b6b6, | 229 | 0x2f2f0000002f2f2fULL, 0xa8a8000000a8a8a8ULL, 0xb6b6000000b6b6b6ULL, |
230 | 0x3c3c0000003c3c3c, 0x2b2b0000002b2b2b, 0xc1c1000000c1c1c1, | 230 | 0x3c3c0000003c3c3cULL, 0x2b2b0000002b2b2bULL, 0xc1c1000000c1c1c1ULL, |
231 | 0xffff000000ffffff, 0xc8c8000000c8c8c8, 0xa5a5000000a5a5a5, | 231 | 0xffff000000ffffffULL, 0xc8c8000000c8c8c8ULL, 0xa5a5000000a5a5a5ULL, |
232 | 0x2020000000202020, 0x8989000000898989, 0x0000000000000000, | 232 | 0x2020000000202020ULL, 0x8989000000898989ULL, 0x0000000000000000ULL, |
233 | 0x9090000000909090, 0x4747000000474747, 0xefef000000efefef, | 233 | 0x9090000000909090ULL, 0x4747000000474747ULL, 0xefef000000efefefULL, |
234 | 0xeaea000000eaeaea, 0xb7b7000000b7b7b7, 0x1515000000151515, | 234 | 0xeaea000000eaeaeaULL, 0xb7b7000000b7b7b7ULL, 0x1515000000151515ULL, |
235 | 0x0606000000060606, 0xcdcd000000cdcdcd, 0xb5b5000000b5b5b5, | 235 | 0x0606000000060606ULL, 0xcdcd000000cdcdcdULL, 0xb5b5000000b5b5b5ULL, |
236 | 0x1212000000121212, 0x7e7e0000007e7e7e, 0xbbbb000000bbbbbb, | 236 | 0x1212000000121212ULL, 0x7e7e0000007e7e7eULL, 0xbbbb000000bbbbbbULL, |
237 | 0x2929000000292929, 0x0f0f0000000f0f0f, 0xb8b8000000b8b8b8, | 237 | 0x2929000000292929ULL, 0x0f0f0000000f0f0fULL, 0xb8b8000000b8b8b8ULL, |
238 | 0x0707000000070707, 0x0404000000040404, 0x9b9b0000009b9b9b, | 238 | 0x0707000000070707ULL, 0x0404000000040404ULL, 0x9b9b0000009b9b9bULL, |
239 | 0x9494000000949494, 0x2121000000212121, 0x6666000000666666, | 239 | 0x9494000000949494ULL, 0x2121000000212121ULL, 0x6666000000666666ULL, |
240 | 0xe6e6000000e6e6e6, 0xcece000000cecece, 0xeded000000ededed, | 240 | 0xe6e6000000e6e6e6ULL, 0xcece000000cececeULL, 0xeded000000edededULL, |
241 | 0xe7e7000000e7e7e7, 0x3b3b0000003b3b3b, 0xfefe000000fefefe, | 241 | 0xe7e7000000e7e7e7ULL, 0x3b3b0000003b3b3bULL, 0xfefe000000fefefeULL, |
242 | 0x7f7f0000007f7f7f, 0xc5c5000000c5c5c5, 0xa4a4000000a4a4a4, | 242 | 0x7f7f0000007f7f7fULL, 0xc5c5000000c5c5c5ULL, 0xa4a4000000a4a4a4ULL, |
243 | 0x3737000000373737, 0xb1b1000000b1b1b1, 0x4c4c0000004c4c4c, | 243 | 0x3737000000373737ULL, 0xb1b1000000b1b1b1ULL, 0x4c4c0000004c4c4cULL, |
244 | 0x9191000000919191, 0x6e6e0000006e6e6e, 0x8d8d0000008d8d8d, | 244 | 0x9191000000919191ULL, 0x6e6e0000006e6e6eULL, 0x8d8d0000008d8d8dULL, |
245 | 0x7676000000767676, 0x0303000000030303, 0x2d2d0000002d2d2d, | 245 | 0x7676000000767676ULL, 0x0303000000030303ULL, 0x2d2d0000002d2d2dULL, |
246 | 0xdede000000dedede, 0x9696000000969696, 0x2626000000262626, | 246 | 0xdede000000dededeULL, 0x9696000000969696ULL, 0x2626000000262626ULL, |
247 | 0x7d7d0000007d7d7d, 0xc6c6000000c6c6c6, 0x5c5c0000005c5c5c, | 247 | 0x7d7d0000007d7d7dULL, 0xc6c6000000c6c6c6ULL, 0x5c5c0000005c5c5cULL, |
248 | 0xd3d3000000d3d3d3, 0xf2f2000000f2f2f2, 0x4f4f0000004f4f4f, | 248 | 0xd3d3000000d3d3d3ULL, 0xf2f2000000f2f2f2ULL, 0x4f4f0000004f4f4fULL, |
249 | 0x1919000000191919, 0x3f3f0000003f3f3f, 0xdcdc000000dcdcdc, | 249 | 0x1919000000191919ULL, 0x3f3f0000003f3f3fULL, 0xdcdc000000dcdcdcULL, |
250 | 0x7979000000797979, 0x1d1d0000001d1d1d, 0x5252000000525252, | 250 | 0x7979000000797979ULL, 0x1d1d0000001d1d1dULL, 0x5252000000525252ULL, |
251 | 0xebeb000000ebebeb, 0xf3f3000000f3f3f3, 0x6d6d0000006d6d6d, | 251 | 0xebeb000000ebebebULL, 0xf3f3000000f3f3f3ULL, 0x6d6d0000006d6d6dULL, |
252 | 0x5e5e0000005e5e5e, 0xfbfb000000fbfbfb, 0x6969000000696969, | 252 | 0x5e5e0000005e5e5eULL, 0xfbfb000000fbfbfbULL, 0x6969000000696969ULL, |
253 | 0xb2b2000000b2b2b2, 0xf0f0000000f0f0f0, 0x3131000000313131, | 253 | 0xb2b2000000b2b2b2ULL, 0xf0f0000000f0f0f0ULL, 0x3131000000313131ULL, |
254 | 0x0c0c0000000c0c0c, 0xd4d4000000d4d4d4, 0xcfcf000000cfcfcf, | 254 | 0x0c0c0000000c0c0cULL, 0xd4d4000000d4d4d4ULL, 0xcfcf000000cfcfcfULL, |
255 | 0x8c8c0000008c8c8c, 0xe2e2000000e2e2e2, 0x7575000000757575, | 255 | 0x8c8c0000008c8c8cULL, 0xe2e2000000e2e2e2ULL, 0x7575000000757575ULL, |
256 | 0xa9a9000000a9a9a9, 0x4a4a0000004a4a4a, 0x5757000000575757, | 256 | 0xa9a9000000a9a9a9ULL, 0x4a4a0000004a4a4aULL, 0x5757000000575757ULL, |
257 | 0x8484000000848484, 0x1111000000111111, 0x4545000000454545, | 257 | 0x8484000000848484ULL, 0x1111000000111111ULL, 0x4545000000454545ULL, |
258 | 0x1b1b0000001b1b1b, 0xf5f5000000f5f5f5, 0xe4e4000000e4e4e4, | 258 | 0x1b1b0000001b1b1bULL, 0xf5f5000000f5f5f5ULL, 0xe4e4000000e4e4e4ULL, |
259 | 0x0e0e0000000e0e0e, 0x7373000000737373, 0xaaaa000000aaaaaa, | 259 | 0x0e0e0000000e0e0eULL, 0x7373000000737373ULL, 0xaaaa000000aaaaaaULL, |
260 | 0xf1f1000000f1f1f1, 0xdddd000000dddddd, 0x5959000000595959, | 260 | 0xf1f1000000f1f1f1ULL, 0xdddd000000ddddddULL, 0x5959000000595959ULL, |
261 | 0x1414000000141414, 0x6c6c0000006c6c6c, 0x9292000000929292, | 261 | 0x1414000000141414ULL, 0x6c6c0000006c6c6cULL, 0x9292000000929292ULL, |
262 | 0x5454000000545454, 0xd0d0000000d0d0d0, 0x7878000000787878, | 262 | 0x5454000000545454ULL, 0xd0d0000000d0d0d0ULL, 0x7878000000787878ULL, |
263 | 0x7070000000707070, 0xe3e3000000e3e3e3, 0x4949000000494949, | 263 | 0x7070000000707070ULL, 0xe3e3000000e3e3e3ULL, 0x4949000000494949ULL, |
264 | 0x8080000000808080, 0x5050000000505050, 0xa7a7000000a7a7a7, | 264 | 0x8080000000808080ULL, 0x5050000000505050ULL, 0xa7a7000000a7a7a7ULL, |
265 | 0xf6f6000000f6f6f6, 0x7777000000777777, 0x9393000000939393, | 265 | 0xf6f6000000f6f6f6ULL, 0x7777000000777777ULL, 0x9393000000939393ULL, |
266 | 0x8686000000868686, 0x8383000000838383, 0x2a2a0000002a2a2a, | 266 | 0x8686000000868686ULL, 0x8383000000838383ULL, 0x2a2a0000002a2a2aULL, |
267 | 0xc7c7000000c7c7c7, 0x5b5b0000005b5b5b, 0xe9e9000000e9e9e9, | 267 | 0xc7c7000000c7c7c7ULL, 0x5b5b0000005b5b5bULL, 0xe9e9000000e9e9e9ULL, |
268 | 0xeeee000000eeeeee, 0x8f8f0000008f8f8f, 0x0101000000010101, | 268 | 0xeeee000000eeeeeeULL, 0x8f8f0000008f8f8fULL, 0x0101000000010101ULL, |
269 | 0x3d3d0000003d3d3d, | 269 | 0x3d3d0000003d3d3dULL, |
270 | }; | 270 | }; |
271 | 271 | ||
272 | const u64 camellia_sp03303033[256] = { | 272 | const u64 camellia_sp03303033[256] = { |
273 | 0x0038380038003838, 0x0041410041004141, 0x0016160016001616, | 273 | 0x0038380038003838ULL, 0x0041410041004141ULL, 0x0016160016001616ULL, |
274 | 0x0076760076007676, 0x00d9d900d900d9d9, 0x0093930093009393, | 274 | 0x0076760076007676ULL, 0x00d9d900d900d9d9ULL, 0x0093930093009393ULL, |
275 | 0x0060600060006060, 0x00f2f200f200f2f2, 0x0072720072007272, | 275 | 0x0060600060006060ULL, 0x00f2f200f200f2f2ULL, 0x0072720072007272ULL, |
276 | 0x00c2c200c200c2c2, 0x00abab00ab00abab, 0x009a9a009a009a9a, | 276 | 0x00c2c200c200c2c2ULL, 0x00abab00ab00ababULL, 0x009a9a009a009a9aULL, |
277 | 0x0075750075007575, 0x0006060006000606, 0x0057570057005757, | 277 | 0x0075750075007575ULL, 0x0006060006000606ULL, 0x0057570057005757ULL, |
278 | 0x00a0a000a000a0a0, 0x0091910091009191, 0x00f7f700f700f7f7, | 278 | 0x00a0a000a000a0a0ULL, 0x0091910091009191ULL, 0x00f7f700f700f7f7ULL, |
279 | 0x00b5b500b500b5b5, 0x00c9c900c900c9c9, 0x00a2a200a200a2a2, | 279 | 0x00b5b500b500b5b5ULL, 0x00c9c900c900c9c9ULL, 0x00a2a200a200a2a2ULL, |
280 | 0x008c8c008c008c8c, 0x00d2d200d200d2d2, 0x0090900090009090, | 280 | 0x008c8c008c008c8cULL, 0x00d2d200d200d2d2ULL, 0x0090900090009090ULL, |
281 | 0x00f6f600f600f6f6, 0x0007070007000707, 0x00a7a700a700a7a7, | 281 | 0x00f6f600f600f6f6ULL, 0x0007070007000707ULL, 0x00a7a700a700a7a7ULL, |
282 | 0x0027270027002727, 0x008e8e008e008e8e, 0x00b2b200b200b2b2, | 282 | 0x0027270027002727ULL, 0x008e8e008e008e8eULL, 0x00b2b200b200b2b2ULL, |
283 | 0x0049490049004949, 0x00dede00de00dede, 0x0043430043004343, | 283 | 0x0049490049004949ULL, 0x00dede00de00dedeULL, 0x0043430043004343ULL, |
284 | 0x005c5c005c005c5c, 0x00d7d700d700d7d7, 0x00c7c700c700c7c7, | 284 | 0x005c5c005c005c5cULL, 0x00d7d700d700d7d7ULL, 0x00c7c700c700c7c7ULL, |
285 | 0x003e3e003e003e3e, 0x00f5f500f500f5f5, 0x008f8f008f008f8f, | 285 | 0x003e3e003e003e3eULL, 0x00f5f500f500f5f5ULL, 0x008f8f008f008f8fULL, |
286 | 0x0067670067006767, 0x001f1f001f001f1f, 0x0018180018001818, | 286 | 0x0067670067006767ULL, 0x001f1f001f001f1fULL, 0x0018180018001818ULL, |
287 | 0x006e6e006e006e6e, 0x00afaf00af00afaf, 0x002f2f002f002f2f, | 287 | 0x006e6e006e006e6eULL, 0x00afaf00af00afafULL, 0x002f2f002f002f2fULL, |
288 | 0x00e2e200e200e2e2, 0x0085850085008585, 0x000d0d000d000d0d, | 288 | 0x00e2e200e200e2e2ULL, 0x0085850085008585ULL, 0x000d0d000d000d0dULL, |
289 | 0x0053530053005353, 0x00f0f000f000f0f0, 0x009c9c009c009c9c, | 289 | 0x0053530053005353ULL, 0x00f0f000f000f0f0ULL, 0x009c9c009c009c9cULL, |
290 | 0x0065650065006565, 0x00eaea00ea00eaea, 0x00a3a300a300a3a3, | 290 | 0x0065650065006565ULL, 0x00eaea00ea00eaeaULL, 0x00a3a300a300a3a3ULL, |
291 | 0x00aeae00ae00aeae, 0x009e9e009e009e9e, 0x00ecec00ec00ecec, | 291 | 0x00aeae00ae00aeaeULL, 0x009e9e009e009e9eULL, 0x00ecec00ec00ececULL, |
292 | 0x0080800080008080, 0x002d2d002d002d2d, 0x006b6b006b006b6b, | 292 | 0x0080800080008080ULL, 0x002d2d002d002d2dULL, 0x006b6b006b006b6bULL, |
293 | 0x00a8a800a800a8a8, 0x002b2b002b002b2b, 0x0036360036003636, | 293 | 0x00a8a800a800a8a8ULL, 0x002b2b002b002b2bULL, 0x0036360036003636ULL, |
294 | 0x00a6a600a600a6a6, 0x00c5c500c500c5c5, 0x0086860086008686, | 294 | 0x00a6a600a600a6a6ULL, 0x00c5c500c500c5c5ULL, 0x0086860086008686ULL, |
295 | 0x004d4d004d004d4d, 0x0033330033003333, 0x00fdfd00fd00fdfd, | 295 | 0x004d4d004d004d4dULL, 0x0033330033003333ULL, 0x00fdfd00fd00fdfdULL, |
296 | 0x0066660066006666, 0x0058580058005858, 0x0096960096009696, | 296 | 0x0066660066006666ULL, 0x0058580058005858ULL, 0x0096960096009696ULL, |
297 | 0x003a3a003a003a3a, 0x0009090009000909, 0x0095950095009595, | 297 | 0x003a3a003a003a3aULL, 0x0009090009000909ULL, 0x0095950095009595ULL, |
298 | 0x0010100010001010, 0x0078780078007878, 0x00d8d800d800d8d8, | 298 | 0x0010100010001010ULL, 0x0078780078007878ULL, 0x00d8d800d800d8d8ULL, |
299 | 0x0042420042004242, 0x00cccc00cc00cccc, 0x00efef00ef00efef, | 299 | 0x0042420042004242ULL, 0x00cccc00cc00ccccULL, 0x00efef00ef00efefULL, |
300 | 0x0026260026002626, 0x00e5e500e500e5e5, 0x0061610061006161, | 300 | 0x0026260026002626ULL, 0x00e5e500e500e5e5ULL, 0x0061610061006161ULL, |
301 | 0x001a1a001a001a1a, 0x003f3f003f003f3f, 0x003b3b003b003b3b, | 301 | 0x001a1a001a001a1aULL, 0x003f3f003f003f3fULL, 0x003b3b003b003b3bULL, |
302 | 0x0082820082008282, 0x00b6b600b600b6b6, 0x00dbdb00db00dbdb, | 302 | 0x0082820082008282ULL, 0x00b6b600b600b6b6ULL, 0x00dbdb00db00dbdbULL, |
303 | 0x00d4d400d400d4d4, 0x0098980098009898, 0x00e8e800e800e8e8, | 303 | 0x00d4d400d400d4d4ULL, 0x0098980098009898ULL, 0x00e8e800e800e8e8ULL, |
304 | 0x008b8b008b008b8b, 0x0002020002000202, 0x00ebeb00eb00ebeb, | 304 | 0x008b8b008b008b8bULL, 0x0002020002000202ULL, 0x00ebeb00eb00ebebULL, |
305 | 0x000a0a000a000a0a, 0x002c2c002c002c2c, 0x001d1d001d001d1d, | 305 | 0x000a0a000a000a0aULL, 0x002c2c002c002c2cULL, 0x001d1d001d001d1dULL, |
306 | 0x00b0b000b000b0b0, 0x006f6f006f006f6f, 0x008d8d008d008d8d, | 306 | 0x00b0b000b000b0b0ULL, 0x006f6f006f006f6fULL, 0x008d8d008d008d8dULL, |
307 | 0x0088880088008888, 0x000e0e000e000e0e, 0x0019190019001919, | 307 | 0x0088880088008888ULL, 0x000e0e000e000e0eULL, 0x0019190019001919ULL, |
308 | 0x0087870087008787, 0x004e4e004e004e4e, 0x000b0b000b000b0b, | 308 | 0x0087870087008787ULL, 0x004e4e004e004e4eULL, 0x000b0b000b000b0bULL, |
309 | 0x00a9a900a900a9a9, 0x000c0c000c000c0c, 0x0079790079007979, | 309 | 0x00a9a900a900a9a9ULL, 0x000c0c000c000c0cULL, 0x0079790079007979ULL, |
310 | 0x0011110011001111, 0x007f7f007f007f7f, 0x0022220022002222, | 310 | 0x0011110011001111ULL, 0x007f7f007f007f7fULL, 0x0022220022002222ULL, |
311 | 0x00e7e700e700e7e7, 0x0059590059005959, 0x00e1e100e100e1e1, | 311 | 0x00e7e700e700e7e7ULL, 0x0059590059005959ULL, 0x00e1e100e100e1e1ULL, |
312 | 0x00dada00da00dada, 0x003d3d003d003d3d, 0x00c8c800c800c8c8, | 312 | 0x00dada00da00dadaULL, 0x003d3d003d003d3dULL, 0x00c8c800c800c8c8ULL, |
313 | 0x0012120012001212, 0x0004040004000404, 0x0074740074007474, | 313 | 0x0012120012001212ULL, 0x0004040004000404ULL, 0x0074740074007474ULL, |
314 | 0x0054540054005454, 0x0030300030003030, 0x007e7e007e007e7e, | 314 | 0x0054540054005454ULL, 0x0030300030003030ULL, 0x007e7e007e007e7eULL, |
315 | 0x00b4b400b400b4b4, 0x0028280028002828, 0x0055550055005555, | 315 | 0x00b4b400b400b4b4ULL, 0x0028280028002828ULL, 0x0055550055005555ULL, |
316 | 0x0068680068006868, 0x0050500050005050, 0x00bebe00be00bebe, | 316 | 0x0068680068006868ULL, 0x0050500050005050ULL, 0x00bebe00be00bebeULL, |
317 | 0x00d0d000d000d0d0, 0x00c4c400c400c4c4, 0x0031310031003131, | 317 | 0x00d0d000d000d0d0ULL, 0x00c4c400c400c4c4ULL, 0x0031310031003131ULL, |
318 | 0x00cbcb00cb00cbcb, 0x002a2a002a002a2a, 0x00adad00ad00adad, | 318 | 0x00cbcb00cb00cbcbULL, 0x002a2a002a002a2aULL, 0x00adad00ad00adadULL, |
319 | 0x000f0f000f000f0f, 0x00caca00ca00caca, 0x0070700070007070, | 319 | 0x000f0f000f000f0fULL, 0x00caca00ca00cacaULL, 0x0070700070007070ULL, |
320 | 0x00ffff00ff00ffff, 0x0032320032003232, 0x0069690069006969, | 320 | 0x00ffff00ff00ffffULL, 0x0032320032003232ULL, 0x0069690069006969ULL, |
321 | 0x0008080008000808, 0x0062620062006262, 0x0000000000000000, | 321 | 0x0008080008000808ULL, 0x0062620062006262ULL, 0x0000000000000000ULL, |
322 | 0x0024240024002424, 0x00d1d100d100d1d1, 0x00fbfb00fb00fbfb, | 322 | 0x0024240024002424ULL, 0x00d1d100d100d1d1ULL, 0x00fbfb00fb00fbfbULL, |
323 | 0x00baba00ba00baba, 0x00eded00ed00eded, 0x0045450045004545, | 323 | 0x00baba00ba00babaULL, 0x00eded00ed00ededULL, 0x0045450045004545ULL, |
324 | 0x0081810081008181, 0x0073730073007373, 0x006d6d006d006d6d, | 324 | 0x0081810081008181ULL, 0x0073730073007373ULL, 0x006d6d006d006d6dULL, |
325 | 0x0084840084008484, 0x009f9f009f009f9f, 0x00eeee00ee00eeee, | 325 | 0x0084840084008484ULL, 0x009f9f009f009f9fULL, 0x00eeee00ee00eeeeULL, |
326 | 0x004a4a004a004a4a, 0x00c3c300c300c3c3, 0x002e2e002e002e2e, | 326 | 0x004a4a004a004a4aULL, 0x00c3c300c300c3c3ULL, 0x002e2e002e002e2eULL, |
327 | 0x00c1c100c100c1c1, 0x0001010001000101, 0x00e6e600e600e6e6, | 327 | 0x00c1c100c100c1c1ULL, 0x0001010001000101ULL, 0x00e6e600e600e6e6ULL, |
328 | 0x0025250025002525, 0x0048480048004848, 0x0099990099009999, | 328 | 0x0025250025002525ULL, 0x0048480048004848ULL, 0x0099990099009999ULL, |
329 | 0x00b9b900b900b9b9, 0x00b3b300b300b3b3, 0x007b7b007b007b7b, | 329 | 0x00b9b900b900b9b9ULL, 0x00b3b300b300b3b3ULL, 0x007b7b007b007b7bULL, |
330 | 0x00f9f900f900f9f9, 0x00cece00ce00cece, 0x00bfbf00bf00bfbf, | 330 | 0x00f9f900f900f9f9ULL, 0x00cece00ce00ceceULL, 0x00bfbf00bf00bfbfULL, |
331 | 0x00dfdf00df00dfdf, 0x0071710071007171, 0x0029290029002929, | 331 | 0x00dfdf00df00dfdfULL, 0x0071710071007171ULL, 0x0029290029002929ULL, |
332 | 0x00cdcd00cd00cdcd, 0x006c6c006c006c6c, 0x0013130013001313, | 332 | 0x00cdcd00cd00cdcdULL, 0x006c6c006c006c6cULL, 0x0013130013001313ULL, |
333 | 0x0064640064006464, 0x009b9b009b009b9b, 0x0063630063006363, | 333 | 0x0064640064006464ULL, 0x009b9b009b009b9bULL, 0x0063630063006363ULL, |
334 | 0x009d9d009d009d9d, 0x00c0c000c000c0c0, 0x004b4b004b004b4b, | 334 | 0x009d9d009d009d9dULL, 0x00c0c000c000c0c0ULL, 0x004b4b004b004b4bULL, |
335 | 0x00b7b700b700b7b7, 0x00a5a500a500a5a5, 0x0089890089008989, | 335 | 0x00b7b700b700b7b7ULL, 0x00a5a500a500a5a5ULL, 0x0089890089008989ULL, |
336 | 0x005f5f005f005f5f, 0x00b1b100b100b1b1, 0x0017170017001717, | 336 | 0x005f5f005f005f5fULL, 0x00b1b100b100b1b1ULL, 0x0017170017001717ULL, |
337 | 0x00f4f400f400f4f4, 0x00bcbc00bc00bcbc, 0x00d3d300d300d3d3, | 337 | 0x00f4f400f400f4f4ULL, 0x00bcbc00bc00bcbcULL, 0x00d3d300d300d3d3ULL, |
338 | 0x0046460046004646, 0x00cfcf00cf00cfcf, 0x0037370037003737, | 338 | 0x0046460046004646ULL, 0x00cfcf00cf00cfcfULL, 0x0037370037003737ULL, |
339 | 0x005e5e005e005e5e, 0x0047470047004747, 0x0094940094009494, | 339 | 0x005e5e005e005e5eULL, 0x0047470047004747ULL, 0x0094940094009494ULL, |
340 | 0x00fafa00fa00fafa, 0x00fcfc00fc00fcfc, 0x005b5b005b005b5b, | 340 | 0x00fafa00fa00fafaULL, 0x00fcfc00fc00fcfcULL, 0x005b5b005b005b5bULL, |
341 | 0x0097970097009797, 0x00fefe00fe00fefe, 0x005a5a005a005a5a, | 341 | 0x0097970097009797ULL, 0x00fefe00fe00fefeULL, 0x005a5a005a005a5aULL, |
342 | 0x00acac00ac00acac, 0x003c3c003c003c3c, 0x004c4c004c004c4c, | 342 | 0x00acac00ac00acacULL, 0x003c3c003c003c3cULL, 0x004c4c004c004c4cULL, |
343 | 0x0003030003000303, 0x0035350035003535, 0x00f3f300f300f3f3, | 343 | 0x0003030003000303ULL, 0x0035350035003535ULL, 0x00f3f300f300f3f3ULL, |
344 | 0x0023230023002323, 0x00b8b800b800b8b8, 0x005d5d005d005d5d, | 344 | 0x0023230023002323ULL, 0x00b8b800b800b8b8ULL, 0x005d5d005d005d5dULL, |
345 | 0x006a6a006a006a6a, 0x0092920092009292, 0x00d5d500d500d5d5, | 345 | 0x006a6a006a006a6aULL, 0x0092920092009292ULL, 0x00d5d500d500d5d5ULL, |
346 | 0x0021210021002121, 0x0044440044004444, 0x0051510051005151, | 346 | 0x0021210021002121ULL, 0x0044440044004444ULL, 0x0051510051005151ULL, |
347 | 0x00c6c600c600c6c6, 0x007d7d007d007d7d, 0x0039390039003939, | 347 | 0x00c6c600c600c6c6ULL, 0x007d7d007d007d7dULL, 0x0039390039003939ULL, |
348 | 0x0083830083008383, 0x00dcdc00dc00dcdc, 0x00aaaa00aa00aaaa, | 348 | 0x0083830083008383ULL, 0x00dcdc00dc00dcdcULL, 0x00aaaa00aa00aaaaULL, |
349 | 0x007c7c007c007c7c, 0x0077770077007777, 0x0056560056005656, | 349 | 0x007c7c007c007c7cULL, 0x0077770077007777ULL, 0x0056560056005656ULL, |
350 | 0x0005050005000505, 0x001b1b001b001b1b, 0x00a4a400a400a4a4, | 350 | 0x0005050005000505ULL, 0x001b1b001b001b1bULL, 0x00a4a400a400a4a4ULL, |
351 | 0x0015150015001515, 0x0034340034003434, 0x001e1e001e001e1e, | 351 | 0x0015150015001515ULL, 0x0034340034003434ULL, 0x001e1e001e001e1eULL, |
352 | 0x001c1c001c001c1c, 0x00f8f800f800f8f8, 0x0052520052005252, | 352 | 0x001c1c001c001c1cULL, 0x00f8f800f800f8f8ULL, 0x0052520052005252ULL, |
353 | 0x0020200020002020, 0x0014140014001414, 0x00e9e900e900e9e9, | 353 | 0x0020200020002020ULL, 0x0014140014001414ULL, 0x00e9e900e900e9e9ULL, |
354 | 0x00bdbd00bd00bdbd, 0x00dddd00dd00dddd, 0x00e4e400e400e4e4, | 354 | 0x00bdbd00bd00bdbdULL, 0x00dddd00dd00ddddULL, 0x00e4e400e400e4e4ULL, |
355 | 0x00a1a100a100a1a1, 0x00e0e000e000e0e0, 0x008a8a008a008a8a, | 355 | 0x00a1a100a100a1a1ULL, 0x00e0e000e000e0e0ULL, 0x008a8a008a008a8aULL, |
356 | 0x00f1f100f100f1f1, 0x00d6d600d600d6d6, 0x007a7a007a007a7a, | 356 | 0x00f1f100f100f1f1ULL, 0x00d6d600d600d6d6ULL, 0x007a7a007a007a7aULL, |
357 | 0x00bbbb00bb00bbbb, 0x00e3e300e300e3e3, 0x0040400040004040, | 357 | 0x00bbbb00bb00bbbbULL, 0x00e3e300e300e3e3ULL, 0x0040400040004040ULL, |
358 | 0x004f4f004f004f4f, | 358 | 0x004f4f004f004f4fULL, |
359 | }; | 359 | }; |
360 | 360 | ||
361 | const u64 camellia_sp00444404[256] = { | 361 | const u64 camellia_sp00444404[256] = { |
362 | 0x0000707070700070, 0x00002c2c2c2c002c, 0x0000b3b3b3b300b3, | 362 | 0x0000707070700070ULL, 0x00002c2c2c2c002cULL, 0x0000b3b3b3b300b3ULL, |
363 | 0x0000c0c0c0c000c0, 0x0000e4e4e4e400e4, 0x0000575757570057, | 363 | 0x0000c0c0c0c000c0ULL, 0x0000e4e4e4e400e4ULL, 0x0000575757570057ULL, |
364 | 0x0000eaeaeaea00ea, 0x0000aeaeaeae00ae, 0x0000232323230023, | 364 | 0x0000eaeaeaea00eaULL, 0x0000aeaeaeae00aeULL, 0x0000232323230023ULL, |
365 | 0x00006b6b6b6b006b, 0x0000454545450045, 0x0000a5a5a5a500a5, | 365 | 0x00006b6b6b6b006bULL, 0x0000454545450045ULL, 0x0000a5a5a5a500a5ULL, |
366 | 0x0000edededed00ed, 0x00004f4f4f4f004f, 0x00001d1d1d1d001d, | 366 | 0x0000edededed00edULL, 0x00004f4f4f4f004fULL, 0x00001d1d1d1d001dULL, |
367 | 0x0000929292920092, 0x0000868686860086, 0x0000afafafaf00af, | 367 | 0x0000929292920092ULL, 0x0000868686860086ULL, 0x0000afafafaf00afULL, |
368 | 0x00007c7c7c7c007c, 0x00001f1f1f1f001f, 0x00003e3e3e3e003e, | 368 | 0x00007c7c7c7c007cULL, 0x00001f1f1f1f001fULL, 0x00003e3e3e3e003eULL, |
369 | 0x0000dcdcdcdc00dc, 0x00005e5e5e5e005e, 0x00000b0b0b0b000b, | 369 | 0x0000dcdcdcdc00dcULL, 0x00005e5e5e5e005eULL, 0x00000b0b0b0b000bULL, |
370 | 0x0000a6a6a6a600a6, 0x0000393939390039, 0x0000d5d5d5d500d5, | 370 | 0x0000a6a6a6a600a6ULL, 0x0000393939390039ULL, 0x0000d5d5d5d500d5ULL, |
371 | 0x00005d5d5d5d005d, 0x0000d9d9d9d900d9, 0x00005a5a5a5a005a, | 371 | 0x00005d5d5d5d005dULL, 0x0000d9d9d9d900d9ULL, 0x00005a5a5a5a005aULL, |
372 | 0x0000515151510051, 0x00006c6c6c6c006c, 0x00008b8b8b8b008b, | 372 | 0x0000515151510051ULL, 0x00006c6c6c6c006cULL, 0x00008b8b8b8b008bULL, |
373 | 0x00009a9a9a9a009a, 0x0000fbfbfbfb00fb, 0x0000b0b0b0b000b0, | 373 | 0x00009a9a9a9a009aULL, 0x0000fbfbfbfb00fbULL, 0x0000b0b0b0b000b0ULL, |
374 | 0x0000747474740074, 0x00002b2b2b2b002b, 0x0000f0f0f0f000f0, | 374 | 0x0000747474740074ULL, 0x00002b2b2b2b002bULL, 0x0000f0f0f0f000f0ULL, |
375 | 0x0000848484840084, 0x0000dfdfdfdf00df, 0x0000cbcbcbcb00cb, | 375 | 0x0000848484840084ULL, 0x0000dfdfdfdf00dfULL, 0x0000cbcbcbcb00cbULL, |
376 | 0x0000343434340034, 0x0000767676760076, 0x00006d6d6d6d006d, | 376 | 0x0000343434340034ULL, 0x0000767676760076ULL, 0x00006d6d6d6d006dULL, |
377 | 0x0000a9a9a9a900a9, 0x0000d1d1d1d100d1, 0x0000040404040004, | 377 | 0x0000a9a9a9a900a9ULL, 0x0000d1d1d1d100d1ULL, 0x0000040404040004ULL, |
378 | 0x0000141414140014, 0x00003a3a3a3a003a, 0x0000dededede00de, | 378 | 0x0000141414140014ULL, 0x00003a3a3a3a003aULL, 0x0000dededede00deULL, |
379 | 0x0000111111110011, 0x0000323232320032, 0x00009c9c9c9c009c, | 379 | 0x0000111111110011ULL, 0x0000323232320032ULL, 0x00009c9c9c9c009cULL, |
380 | 0x0000535353530053, 0x0000f2f2f2f200f2, 0x0000fefefefe00fe, | 380 | 0x0000535353530053ULL, 0x0000f2f2f2f200f2ULL, 0x0000fefefefe00feULL, |
381 | 0x0000cfcfcfcf00cf, 0x0000c3c3c3c300c3, 0x00007a7a7a7a007a, | 381 | 0x0000cfcfcfcf00cfULL, 0x0000c3c3c3c300c3ULL, 0x00007a7a7a7a007aULL, |
382 | 0x0000242424240024, 0x0000e8e8e8e800e8, 0x0000606060600060, | 382 | 0x0000242424240024ULL, 0x0000e8e8e8e800e8ULL, 0x0000606060600060ULL, |
383 | 0x0000696969690069, 0x0000aaaaaaaa00aa, 0x0000a0a0a0a000a0, | 383 | 0x0000696969690069ULL, 0x0000aaaaaaaa00aaULL, 0x0000a0a0a0a000a0ULL, |
384 | 0x0000a1a1a1a100a1, 0x0000626262620062, 0x0000545454540054, | 384 | 0x0000a1a1a1a100a1ULL, 0x0000626262620062ULL, 0x0000545454540054ULL, |
385 | 0x00001e1e1e1e001e, 0x0000e0e0e0e000e0, 0x0000646464640064, | 385 | 0x00001e1e1e1e001eULL, 0x0000e0e0e0e000e0ULL, 0x0000646464640064ULL, |
386 | 0x0000101010100010, 0x0000000000000000, 0x0000a3a3a3a300a3, | 386 | 0x0000101010100010ULL, 0x0000000000000000ULL, 0x0000a3a3a3a300a3ULL, |
387 | 0x0000757575750075, 0x00008a8a8a8a008a, 0x0000e6e6e6e600e6, | 387 | 0x0000757575750075ULL, 0x00008a8a8a8a008aULL, 0x0000e6e6e6e600e6ULL, |
388 | 0x0000090909090009, 0x0000dddddddd00dd, 0x0000878787870087, | 388 | 0x0000090909090009ULL, 0x0000dddddddd00ddULL, 0x0000878787870087ULL, |
389 | 0x0000838383830083, 0x0000cdcdcdcd00cd, 0x0000909090900090, | 389 | 0x0000838383830083ULL, 0x0000cdcdcdcd00cdULL, 0x0000909090900090ULL, |
390 | 0x0000737373730073, 0x0000f6f6f6f600f6, 0x00009d9d9d9d009d, | 390 | 0x0000737373730073ULL, 0x0000f6f6f6f600f6ULL, 0x00009d9d9d9d009dULL, |
391 | 0x0000bfbfbfbf00bf, 0x0000525252520052, 0x0000d8d8d8d800d8, | 391 | 0x0000bfbfbfbf00bfULL, 0x0000525252520052ULL, 0x0000d8d8d8d800d8ULL, |
392 | 0x0000c8c8c8c800c8, 0x0000c6c6c6c600c6, 0x0000818181810081, | 392 | 0x0000c8c8c8c800c8ULL, 0x0000c6c6c6c600c6ULL, 0x0000818181810081ULL, |
393 | 0x00006f6f6f6f006f, 0x0000131313130013, 0x0000636363630063, | 393 | 0x00006f6f6f6f006fULL, 0x0000131313130013ULL, 0x0000636363630063ULL, |
394 | 0x0000e9e9e9e900e9, 0x0000a7a7a7a700a7, 0x00009f9f9f9f009f, | 394 | 0x0000e9e9e9e900e9ULL, 0x0000a7a7a7a700a7ULL, 0x00009f9f9f9f009fULL, |
395 | 0x0000bcbcbcbc00bc, 0x0000292929290029, 0x0000f9f9f9f900f9, | 395 | 0x0000bcbcbcbc00bcULL, 0x0000292929290029ULL, 0x0000f9f9f9f900f9ULL, |
396 | 0x00002f2f2f2f002f, 0x0000b4b4b4b400b4, 0x0000787878780078, | 396 | 0x00002f2f2f2f002fULL, 0x0000b4b4b4b400b4ULL, 0x0000787878780078ULL, |
397 | 0x0000060606060006, 0x0000e7e7e7e700e7, 0x0000717171710071, | 397 | 0x0000060606060006ULL, 0x0000e7e7e7e700e7ULL, 0x0000717171710071ULL, |
398 | 0x0000d4d4d4d400d4, 0x0000abababab00ab, 0x0000888888880088, | 398 | 0x0000d4d4d4d400d4ULL, 0x0000abababab00abULL, 0x0000888888880088ULL, |
399 | 0x00008d8d8d8d008d, 0x0000727272720072, 0x0000b9b9b9b900b9, | 399 | 0x00008d8d8d8d008dULL, 0x0000727272720072ULL, 0x0000b9b9b9b900b9ULL, |
400 | 0x0000f8f8f8f800f8, 0x0000acacacac00ac, 0x0000363636360036, | 400 | 0x0000f8f8f8f800f8ULL, 0x0000acacacac00acULL, 0x0000363636360036ULL, |
401 | 0x00002a2a2a2a002a, 0x00003c3c3c3c003c, 0x0000f1f1f1f100f1, | 401 | 0x00002a2a2a2a002aULL, 0x00003c3c3c3c003cULL, 0x0000f1f1f1f100f1ULL, |
402 | 0x0000404040400040, 0x0000d3d3d3d300d3, 0x0000bbbbbbbb00bb, | 402 | 0x0000404040400040ULL, 0x0000d3d3d3d300d3ULL, 0x0000bbbbbbbb00bbULL, |
403 | 0x0000434343430043, 0x0000151515150015, 0x0000adadadad00ad, | 403 | 0x0000434343430043ULL, 0x0000151515150015ULL, 0x0000adadadad00adULL, |
404 | 0x0000777777770077, 0x0000808080800080, 0x0000828282820082, | 404 | 0x0000777777770077ULL, 0x0000808080800080ULL, 0x0000828282820082ULL, |
405 | 0x0000ecececec00ec, 0x0000272727270027, 0x0000e5e5e5e500e5, | 405 | 0x0000ecececec00ecULL, 0x0000272727270027ULL, 0x0000e5e5e5e500e5ULL, |
406 | 0x0000858585850085, 0x0000353535350035, 0x00000c0c0c0c000c, | 406 | 0x0000858585850085ULL, 0x0000353535350035ULL, 0x00000c0c0c0c000cULL, |
407 | 0x0000414141410041, 0x0000efefefef00ef, 0x0000939393930093, | 407 | 0x0000414141410041ULL, 0x0000efefefef00efULL, 0x0000939393930093ULL, |
408 | 0x0000191919190019, 0x0000212121210021, 0x00000e0e0e0e000e, | 408 | 0x0000191919190019ULL, 0x0000212121210021ULL, 0x00000e0e0e0e000eULL, |
409 | 0x00004e4e4e4e004e, 0x0000656565650065, 0x0000bdbdbdbd00bd, | 409 | 0x00004e4e4e4e004eULL, 0x0000656565650065ULL, 0x0000bdbdbdbd00bdULL, |
410 | 0x0000b8b8b8b800b8, 0x00008f8f8f8f008f, 0x0000ebebebeb00eb, | 410 | 0x0000b8b8b8b800b8ULL, 0x00008f8f8f8f008fULL, 0x0000ebebebeb00ebULL, |
411 | 0x0000cececece00ce, 0x0000303030300030, 0x00005f5f5f5f005f, | 411 | 0x0000cececece00ceULL, 0x0000303030300030ULL, 0x00005f5f5f5f005fULL, |
412 | 0x0000c5c5c5c500c5, 0x00001a1a1a1a001a, 0x0000e1e1e1e100e1, | 412 | 0x0000c5c5c5c500c5ULL, 0x00001a1a1a1a001aULL, 0x0000e1e1e1e100e1ULL, |
413 | 0x0000cacacaca00ca, 0x0000474747470047, 0x00003d3d3d3d003d, | 413 | 0x0000cacacaca00caULL, 0x0000474747470047ULL, 0x00003d3d3d3d003dULL, |
414 | 0x0000010101010001, 0x0000d6d6d6d600d6, 0x0000565656560056, | 414 | 0x0000010101010001ULL, 0x0000d6d6d6d600d6ULL, 0x0000565656560056ULL, |
415 | 0x00004d4d4d4d004d, 0x00000d0d0d0d000d, 0x0000666666660066, | 415 | 0x00004d4d4d4d004dULL, 0x00000d0d0d0d000dULL, 0x0000666666660066ULL, |
416 | 0x0000cccccccc00cc, 0x00002d2d2d2d002d, 0x0000121212120012, | 416 | 0x0000cccccccc00ccULL, 0x00002d2d2d2d002dULL, 0x0000121212120012ULL, |
417 | 0x0000202020200020, 0x0000b1b1b1b100b1, 0x0000999999990099, | 417 | 0x0000202020200020ULL, 0x0000b1b1b1b100b1ULL, 0x0000999999990099ULL, |
418 | 0x00004c4c4c4c004c, 0x0000c2c2c2c200c2, 0x00007e7e7e7e007e, | 418 | 0x00004c4c4c4c004cULL, 0x0000c2c2c2c200c2ULL, 0x00007e7e7e7e007eULL, |
419 | 0x0000050505050005, 0x0000b7b7b7b700b7, 0x0000313131310031, | 419 | 0x0000050505050005ULL, 0x0000b7b7b7b700b7ULL, 0x0000313131310031ULL, |
420 | 0x0000171717170017, 0x0000d7d7d7d700d7, 0x0000585858580058, | 420 | 0x0000171717170017ULL, 0x0000d7d7d7d700d7ULL, 0x0000585858580058ULL, |
421 | 0x0000616161610061, 0x00001b1b1b1b001b, 0x00001c1c1c1c001c, | 421 | 0x0000616161610061ULL, 0x00001b1b1b1b001bULL, 0x00001c1c1c1c001cULL, |
422 | 0x00000f0f0f0f000f, 0x0000161616160016, 0x0000181818180018, | 422 | 0x00000f0f0f0f000fULL, 0x0000161616160016ULL, 0x0000181818180018ULL, |
423 | 0x0000222222220022, 0x0000444444440044, 0x0000b2b2b2b200b2, | 423 | 0x0000222222220022ULL, 0x0000444444440044ULL, 0x0000b2b2b2b200b2ULL, |
424 | 0x0000b5b5b5b500b5, 0x0000919191910091, 0x0000080808080008, | 424 | 0x0000b5b5b5b500b5ULL, 0x0000919191910091ULL, 0x0000080808080008ULL, |
425 | 0x0000a8a8a8a800a8, 0x0000fcfcfcfc00fc, 0x0000505050500050, | 425 | 0x0000a8a8a8a800a8ULL, 0x0000fcfcfcfc00fcULL, 0x0000505050500050ULL, |
426 | 0x0000d0d0d0d000d0, 0x00007d7d7d7d007d, 0x0000898989890089, | 426 | 0x0000d0d0d0d000d0ULL, 0x00007d7d7d7d007dULL, 0x0000898989890089ULL, |
427 | 0x0000979797970097, 0x00005b5b5b5b005b, 0x0000959595950095, | 427 | 0x0000979797970097ULL, 0x00005b5b5b5b005bULL, 0x0000959595950095ULL, |
428 | 0x0000ffffffff00ff, 0x0000d2d2d2d200d2, 0x0000c4c4c4c400c4, | 428 | 0x0000ffffffff00ffULL, 0x0000d2d2d2d200d2ULL, 0x0000c4c4c4c400c4ULL, |
429 | 0x0000484848480048, 0x0000f7f7f7f700f7, 0x0000dbdbdbdb00db, | 429 | 0x0000484848480048ULL, 0x0000f7f7f7f700f7ULL, 0x0000dbdbdbdb00dbULL, |
430 | 0x0000030303030003, 0x0000dadadada00da, 0x00003f3f3f3f003f, | 430 | 0x0000030303030003ULL, 0x0000dadadada00daULL, 0x00003f3f3f3f003fULL, |
431 | 0x0000949494940094, 0x00005c5c5c5c005c, 0x0000020202020002, | 431 | 0x0000949494940094ULL, 0x00005c5c5c5c005cULL, 0x0000020202020002ULL, |
432 | 0x00004a4a4a4a004a, 0x0000333333330033, 0x0000676767670067, | 432 | 0x00004a4a4a4a004aULL, 0x0000333333330033ULL, 0x0000676767670067ULL, |
433 | 0x0000f3f3f3f300f3, 0x00007f7f7f7f007f, 0x0000e2e2e2e200e2, | 433 | 0x0000f3f3f3f300f3ULL, 0x00007f7f7f7f007fULL, 0x0000e2e2e2e200e2ULL, |
434 | 0x00009b9b9b9b009b, 0x0000262626260026, 0x0000373737370037, | 434 | 0x00009b9b9b9b009bULL, 0x0000262626260026ULL, 0x0000373737370037ULL, |
435 | 0x00003b3b3b3b003b, 0x0000969696960096, 0x00004b4b4b4b004b, | 435 | 0x00003b3b3b3b003bULL, 0x0000969696960096ULL, 0x00004b4b4b4b004bULL, |
436 | 0x0000bebebebe00be, 0x00002e2e2e2e002e, 0x0000797979790079, | 436 | 0x0000bebebebe00beULL, 0x00002e2e2e2e002eULL, 0x0000797979790079ULL, |
437 | 0x00008c8c8c8c008c, 0x00006e6e6e6e006e, 0x00008e8e8e8e008e, | 437 | 0x00008c8c8c8c008cULL, 0x00006e6e6e6e006eULL, 0x00008e8e8e8e008eULL, |
438 | 0x0000f5f5f5f500f5, 0x0000b6b6b6b600b6, 0x0000fdfdfdfd00fd, | 438 | 0x0000f5f5f5f500f5ULL, 0x0000b6b6b6b600b6ULL, 0x0000fdfdfdfd00fdULL, |
439 | 0x0000595959590059, 0x0000989898980098, 0x00006a6a6a6a006a, | 439 | 0x0000595959590059ULL, 0x0000989898980098ULL, 0x00006a6a6a6a006aULL, |
440 | 0x0000464646460046, 0x0000babababa00ba, 0x0000252525250025, | 440 | 0x0000464646460046ULL, 0x0000babababa00baULL, 0x0000252525250025ULL, |
441 | 0x0000424242420042, 0x0000a2a2a2a200a2, 0x0000fafafafa00fa, | 441 | 0x0000424242420042ULL, 0x0000a2a2a2a200a2ULL, 0x0000fafafafa00faULL, |
442 | 0x0000070707070007, 0x0000555555550055, 0x0000eeeeeeee00ee, | 442 | 0x0000070707070007ULL, 0x0000555555550055ULL, 0x0000eeeeeeee00eeULL, |
443 | 0x00000a0a0a0a000a, 0x0000494949490049, 0x0000686868680068, | 443 | 0x00000a0a0a0a000aULL, 0x0000494949490049ULL, 0x0000686868680068ULL, |
444 | 0x0000383838380038, 0x0000a4a4a4a400a4, 0x0000282828280028, | 444 | 0x0000383838380038ULL, 0x0000a4a4a4a400a4ULL, 0x0000282828280028ULL, |
445 | 0x00007b7b7b7b007b, 0x0000c9c9c9c900c9, 0x0000c1c1c1c100c1, | 445 | 0x00007b7b7b7b007bULL, 0x0000c9c9c9c900c9ULL, 0x0000c1c1c1c100c1ULL, |
446 | 0x0000e3e3e3e300e3, 0x0000f4f4f4f400f4, 0x0000c7c7c7c700c7, | 446 | 0x0000e3e3e3e300e3ULL, 0x0000f4f4f4f400f4ULL, 0x0000c7c7c7c700c7ULL, |
447 | 0x00009e9e9e9e009e, | 447 | 0x00009e9e9e9e009eULL, |
448 | }; | 448 | }; |
449 | 449 | ||
450 | const u64 camellia_sp02220222[256] = { | 450 | const u64 camellia_sp02220222[256] = { |
451 | 0x00e0e0e000e0e0e0, 0x0005050500050505, 0x0058585800585858, | 451 | 0x00e0e0e000e0e0e0ULL, 0x0005050500050505ULL, 0x0058585800585858ULL, |
452 | 0x00d9d9d900d9d9d9, 0x0067676700676767, 0x004e4e4e004e4e4e, | 452 | 0x00d9d9d900d9d9d9ULL, 0x0067676700676767ULL, 0x004e4e4e004e4e4eULL, |
453 | 0x0081818100818181, 0x00cbcbcb00cbcbcb, 0x00c9c9c900c9c9c9, | 453 | 0x0081818100818181ULL, 0x00cbcbcb00cbcbcbULL, 0x00c9c9c900c9c9c9ULL, |
454 | 0x000b0b0b000b0b0b, 0x00aeaeae00aeaeae, 0x006a6a6a006a6a6a, | 454 | 0x000b0b0b000b0b0bULL, 0x00aeaeae00aeaeaeULL, 0x006a6a6a006a6a6aULL, |
455 | 0x00d5d5d500d5d5d5, 0x0018181800181818, 0x005d5d5d005d5d5d, | 455 | 0x00d5d5d500d5d5d5ULL, 0x0018181800181818ULL, 0x005d5d5d005d5d5dULL, |
456 | 0x0082828200828282, 0x0046464600464646, 0x00dfdfdf00dfdfdf, | 456 | 0x0082828200828282ULL, 0x0046464600464646ULL, 0x00dfdfdf00dfdfdfULL, |
457 | 0x00d6d6d600d6d6d6, 0x0027272700272727, 0x008a8a8a008a8a8a, | 457 | 0x00d6d6d600d6d6d6ULL, 0x0027272700272727ULL, 0x008a8a8a008a8a8aULL, |
458 | 0x0032323200323232, 0x004b4b4b004b4b4b, 0x0042424200424242, | 458 | 0x0032323200323232ULL, 0x004b4b4b004b4b4bULL, 0x0042424200424242ULL, |
459 | 0x00dbdbdb00dbdbdb, 0x001c1c1c001c1c1c, 0x009e9e9e009e9e9e, | 459 | 0x00dbdbdb00dbdbdbULL, 0x001c1c1c001c1c1cULL, 0x009e9e9e009e9e9eULL, |
460 | 0x009c9c9c009c9c9c, 0x003a3a3a003a3a3a, 0x00cacaca00cacaca, | 460 | 0x009c9c9c009c9c9cULL, 0x003a3a3a003a3a3aULL, 0x00cacaca00cacacaULL, |
461 | 0x0025252500252525, 0x007b7b7b007b7b7b, 0x000d0d0d000d0d0d, | 461 | 0x0025252500252525ULL, 0x007b7b7b007b7b7bULL, 0x000d0d0d000d0d0dULL, |
462 | 0x0071717100717171, 0x005f5f5f005f5f5f, 0x001f1f1f001f1f1f, | 462 | 0x0071717100717171ULL, 0x005f5f5f005f5f5fULL, 0x001f1f1f001f1f1fULL, |
463 | 0x00f8f8f800f8f8f8, 0x00d7d7d700d7d7d7, 0x003e3e3e003e3e3e, | 463 | 0x00f8f8f800f8f8f8ULL, 0x00d7d7d700d7d7d7ULL, 0x003e3e3e003e3e3eULL, |
464 | 0x009d9d9d009d9d9d, 0x007c7c7c007c7c7c, 0x0060606000606060, | 464 | 0x009d9d9d009d9d9dULL, 0x007c7c7c007c7c7cULL, 0x0060606000606060ULL, |
465 | 0x00b9b9b900b9b9b9, 0x00bebebe00bebebe, 0x00bcbcbc00bcbcbc, | 465 | 0x00b9b9b900b9b9b9ULL, 0x00bebebe00bebebeULL, 0x00bcbcbc00bcbcbcULL, |
466 | 0x008b8b8b008b8b8b, 0x0016161600161616, 0x0034343400343434, | 466 | 0x008b8b8b008b8b8bULL, 0x0016161600161616ULL, 0x0034343400343434ULL, |
467 | 0x004d4d4d004d4d4d, 0x00c3c3c300c3c3c3, 0x0072727200727272, | 467 | 0x004d4d4d004d4d4dULL, 0x00c3c3c300c3c3c3ULL, 0x0072727200727272ULL, |
468 | 0x0095959500959595, 0x00ababab00ababab, 0x008e8e8e008e8e8e, | 468 | 0x0095959500959595ULL, 0x00ababab00abababULL, 0x008e8e8e008e8e8eULL, |
469 | 0x00bababa00bababa, 0x007a7a7a007a7a7a, 0x00b3b3b300b3b3b3, | 469 | 0x00bababa00bababaULL, 0x007a7a7a007a7a7aULL, 0x00b3b3b300b3b3b3ULL, |
470 | 0x0002020200020202, 0x00b4b4b400b4b4b4, 0x00adadad00adadad, | 470 | 0x0002020200020202ULL, 0x00b4b4b400b4b4b4ULL, 0x00adadad00adadadULL, |
471 | 0x00a2a2a200a2a2a2, 0x00acacac00acacac, 0x00d8d8d800d8d8d8, | 471 | 0x00a2a2a200a2a2a2ULL, 0x00acacac00acacacULL, 0x00d8d8d800d8d8d8ULL, |
472 | 0x009a9a9a009a9a9a, 0x0017171700171717, 0x001a1a1a001a1a1a, | 472 | 0x009a9a9a009a9a9aULL, 0x0017171700171717ULL, 0x001a1a1a001a1a1aULL, |
473 | 0x0035353500353535, 0x00cccccc00cccccc, 0x00f7f7f700f7f7f7, | 473 | 0x0035353500353535ULL, 0x00cccccc00ccccccULL, 0x00f7f7f700f7f7f7ULL, |
474 | 0x0099999900999999, 0x0061616100616161, 0x005a5a5a005a5a5a, | 474 | 0x0099999900999999ULL, 0x0061616100616161ULL, 0x005a5a5a005a5a5aULL, |
475 | 0x00e8e8e800e8e8e8, 0x0024242400242424, 0x0056565600565656, | 475 | 0x00e8e8e800e8e8e8ULL, 0x0024242400242424ULL, 0x0056565600565656ULL, |
476 | 0x0040404000404040, 0x00e1e1e100e1e1e1, 0x0063636300636363, | 476 | 0x0040404000404040ULL, 0x00e1e1e100e1e1e1ULL, 0x0063636300636363ULL, |
477 | 0x0009090900090909, 0x0033333300333333, 0x00bfbfbf00bfbfbf, | 477 | 0x0009090900090909ULL, 0x0033333300333333ULL, 0x00bfbfbf00bfbfbfULL, |
478 | 0x0098989800989898, 0x0097979700979797, 0x0085858500858585, | 478 | 0x0098989800989898ULL, 0x0097979700979797ULL, 0x0085858500858585ULL, |
479 | 0x0068686800686868, 0x00fcfcfc00fcfcfc, 0x00ececec00ececec, | 479 | 0x0068686800686868ULL, 0x00fcfcfc00fcfcfcULL, 0x00ececec00ecececULL, |
480 | 0x000a0a0a000a0a0a, 0x00dadada00dadada, 0x006f6f6f006f6f6f, | 480 | 0x000a0a0a000a0a0aULL, 0x00dadada00dadadaULL, 0x006f6f6f006f6f6fULL, |
481 | 0x0053535300535353, 0x0062626200626262, 0x00a3a3a300a3a3a3, | 481 | 0x0053535300535353ULL, 0x0062626200626262ULL, 0x00a3a3a300a3a3a3ULL, |
482 | 0x002e2e2e002e2e2e, 0x0008080800080808, 0x00afafaf00afafaf, | 482 | 0x002e2e2e002e2e2eULL, 0x0008080800080808ULL, 0x00afafaf00afafafULL, |
483 | 0x0028282800282828, 0x00b0b0b000b0b0b0, 0x0074747400747474, | 483 | 0x0028282800282828ULL, 0x00b0b0b000b0b0b0ULL, 0x0074747400747474ULL, |
484 | 0x00c2c2c200c2c2c2, 0x00bdbdbd00bdbdbd, 0x0036363600363636, | 484 | 0x00c2c2c200c2c2c2ULL, 0x00bdbdbd00bdbdbdULL, 0x0036363600363636ULL, |
485 | 0x0022222200222222, 0x0038383800383838, 0x0064646400646464, | 485 | 0x0022222200222222ULL, 0x0038383800383838ULL, 0x0064646400646464ULL, |
486 | 0x001e1e1e001e1e1e, 0x0039393900393939, 0x002c2c2c002c2c2c, | 486 | 0x001e1e1e001e1e1eULL, 0x0039393900393939ULL, 0x002c2c2c002c2c2cULL, |
487 | 0x00a6a6a600a6a6a6, 0x0030303000303030, 0x00e5e5e500e5e5e5, | 487 | 0x00a6a6a600a6a6a6ULL, 0x0030303000303030ULL, 0x00e5e5e500e5e5e5ULL, |
488 | 0x0044444400444444, 0x00fdfdfd00fdfdfd, 0x0088888800888888, | 488 | 0x0044444400444444ULL, 0x00fdfdfd00fdfdfdULL, 0x0088888800888888ULL, |
489 | 0x009f9f9f009f9f9f, 0x0065656500656565, 0x0087878700878787, | 489 | 0x009f9f9f009f9f9fULL, 0x0065656500656565ULL, 0x0087878700878787ULL, |
490 | 0x006b6b6b006b6b6b, 0x00f4f4f400f4f4f4, 0x0023232300232323, | 490 | 0x006b6b6b006b6b6bULL, 0x00f4f4f400f4f4f4ULL, 0x0023232300232323ULL, |
491 | 0x0048484800484848, 0x0010101000101010, 0x00d1d1d100d1d1d1, | 491 | 0x0048484800484848ULL, 0x0010101000101010ULL, 0x00d1d1d100d1d1d1ULL, |
492 | 0x0051515100515151, 0x00c0c0c000c0c0c0, 0x00f9f9f900f9f9f9, | 492 | 0x0051515100515151ULL, 0x00c0c0c000c0c0c0ULL, 0x00f9f9f900f9f9f9ULL, |
493 | 0x00d2d2d200d2d2d2, 0x00a0a0a000a0a0a0, 0x0055555500555555, | 493 | 0x00d2d2d200d2d2d2ULL, 0x00a0a0a000a0a0a0ULL, 0x0055555500555555ULL, |
494 | 0x00a1a1a100a1a1a1, 0x0041414100414141, 0x00fafafa00fafafa, | 494 | 0x00a1a1a100a1a1a1ULL, 0x0041414100414141ULL, 0x00fafafa00fafafaULL, |
495 | 0x0043434300434343, 0x0013131300131313, 0x00c4c4c400c4c4c4, | 495 | 0x0043434300434343ULL, 0x0013131300131313ULL, 0x00c4c4c400c4c4c4ULL, |
496 | 0x002f2f2f002f2f2f, 0x00a8a8a800a8a8a8, 0x00b6b6b600b6b6b6, | 496 | 0x002f2f2f002f2f2fULL, 0x00a8a8a800a8a8a8ULL, 0x00b6b6b600b6b6b6ULL, |
497 | 0x003c3c3c003c3c3c, 0x002b2b2b002b2b2b, 0x00c1c1c100c1c1c1, | 497 | 0x003c3c3c003c3c3cULL, 0x002b2b2b002b2b2bULL, 0x00c1c1c100c1c1c1ULL, |
498 | 0x00ffffff00ffffff, 0x00c8c8c800c8c8c8, 0x00a5a5a500a5a5a5, | 498 | 0x00ffffff00ffffffULL, 0x00c8c8c800c8c8c8ULL, 0x00a5a5a500a5a5a5ULL, |
499 | 0x0020202000202020, 0x0089898900898989, 0x0000000000000000, | 499 | 0x0020202000202020ULL, 0x0089898900898989ULL, 0x0000000000000000ULL, |
500 | 0x0090909000909090, 0x0047474700474747, 0x00efefef00efefef, | 500 | 0x0090909000909090ULL, 0x0047474700474747ULL, 0x00efefef00efefefULL, |
501 | 0x00eaeaea00eaeaea, 0x00b7b7b700b7b7b7, 0x0015151500151515, | 501 | 0x00eaeaea00eaeaeaULL, 0x00b7b7b700b7b7b7ULL, 0x0015151500151515ULL, |
502 | 0x0006060600060606, 0x00cdcdcd00cdcdcd, 0x00b5b5b500b5b5b5, | 502 | 0x0006060600060606ULL, 0x00cdcdcd00cdcdcdULL, 0x00b5b5b500b5b5b5ULL, |
503 | 0x0012121200121212, 0x007e7e7e007e7e7e, 0x00bbbbbb00bbbbbb, | 503 | 0x0012121200121212ULL, 0x007e7e7e007e7e7eULL, 0x00bbbbbb00bbbbbbULL, |
504 | 0x0029292900292929, 0x000f0f0f000f0f0f, 0x00b8b8b800b8b8b8, | 504 | 0x0029292900292929ULL, 0x000f0f0f000f0f0fULL, 0x00b8b8b800b8b8b8ULL, |
505 | 0x0007070700070707, 0x0004040400040404, 0x009b9b9b009b9b9b, | 505 | 0x0007070700070707ULL, 0x0004040400040404ULL, 0x009b9b9b009b9b9bULL, |
506 | 0x0094949400949494, 0x0021212100212121, 0x0066666600666666, | 506 | 0x0094949400949494ULL, 0x0021212100212121ULL, 0x0066666600666666ULL, |
507 | 0x00e6e6e600e6e6e6, 0x00cecece00cecece, 0x00ededed00ededed, | 507 | 0x00e6e6e600e6e6e6ULL, 0x00cecece00cececeULL, 0x00ededed00edededULL, |
508 | 0x00e7e7e700e7e7e7, 0x003b3b3b003b3b3b, 0x00fefefe00fefefe, | 508 | 0x00e7e7e700e7e7e7ULL, 0x003b3b3b003b3b3bULL, 0x00fefefe00fefefeULL, |
509 | 0x007f7f7f007f7f7f, 0x00c5c5c500c5c5c5, 0x00a4a4a400a4a4a4, | 509 | 0x007f7f7f007f7f7fULL, 0x00c5c5c500c5c5c5ULL, 0x00a4a4a400a4a4a4ULL, |
510 | 0x0037373700373737, 0x00b1b1b100b1b1b1, 0x004c4c4c004c4c4c, | 510 | 0x0037373700373737ULL, 0x00b1b1b100b1b1b1ULL, 0x004c4c4c004c4c4cULL, |
511 | 0x0091919100919191, 0x006e6e6e006e6e6e, 0x008d8d8d008d8d8d, | 511 | 0x0091919100919191ULL, 0x006e6e6e006e6e6eULL, 0x008d8d8d008d8d8dULL, |
512 | 0x0076767600767676, 0x0003030300030303, 0x002d2d2d002d2d2d, | 512 | 0x0076767600767676ULL, 0x0003030300030303ULL, 0x002d2d2d002d2d2dULL, |
513 | 0x00dedede00dedede, 0x0096969600969696, 0x0026262600262626, | 513 | 0x00dedede00dededeULL, 0x0096969600969696ULL, 0x0026262600262626ULL, |
514 | 0x007d7d7d007d7d7d, 0x00c6c6c600c6c6c6, 0x005c5c5c005c5c5c, | 514 | 0x007d7d7d007d7d7dULL, 0x00c6c6c600c6c6c6ULL, 0x005c5c5c005c5c5cULL, |
515 | 0x00d3d3d300d3d3d3, 0x00f2f2f200f2f2f2, 0x004f4f4f004f4f4f, | 515 | 0x00d3d3d300d3d3d3ULL, 0x00f2f2f200f2f2f2ULL, 0x004f4f4f004f4f4fULL, |
516 | 0x0019191900191919, 0x003f3f3f003f3f3f, 0x00dcdcdc00dcdcdc, | 516 | 0x0019191900191919ULL, 0x003f3f3f003f3f3fULL, 0x00dcdcdc00dcdcdcULL, |
517 | 0x0079797900797979, 0x001d1d1d001d1d1d, 0x0052525200525252, | 517 | 0x0079797900797979ULL, 0x001d1d1d001d1d1dULL, 0x0052525200525252ULL, |
518 | 0x00ebebeb00ebebeb, 0x00f3f3f300f3f3f3, 0x006d6d6d006d6d6d, | 518 | 0x00ebebeb00ebebebULL, 0x00f3f3f300f3f3f3ULL, 0x006d6d6d006d6d6dULL, |
519 | 0x005e5e5e005e5e5e, 0x00fbfbfb00fbfbfb, 0x0069696900696969, | 519 | 0x005e5e5e005e5e5eULL, 0x00fbfbfb00fbfbfbULL, 0x0069696900696969ULL, |
520 | 0x00b2b2b200b2b2b2, 0x00f0f0f000f0f0f0, 0x0031313100313131, | 520 | 0x00b2b2b200b2b2b2ULL, 0x00f0f0f000f0f0f0ULL, 0x0031313100313131ULL, |
521 | 0x000c0c0c000c0c0c, 0x00d4d4d400d4d4d4, 0x00cfcfcf00cfcfcf, | 521 | 0x000c0c0c000c0c0cULL, 0x00d4d4d400d4d4d4ULL, 0x00cfcfcf00cfcfcfULL, |
522 | 0x008c8c8c008c8c8c, 0x00e2e2e200e2e2e2, 0x0075757500757575, | 522 | 0x008c8c8c008c8c8cULL, 0x00e2e2e200e2e2e2ULL, 0x0075757500757575ULL, |
523 | 0x00a9a9a900a9a9a9, 0x004a4a4a004a4a4a, 0x0057575700575757, | 523 | 0x00a9a9a900a9a9a9ULL, 0x004a4a4a004a4a4aULL, 0x0057575700575757ULL, |
524 | 0x0084848400848484, 0x0011111100111111, 0x0045454500454545, | 524 | 0x0084848400848484ULL, 0x0011111100111111ULL, 0x0045454500454545ULL, |
525 | 0x001b1b1b001b1b1b, 0x00f5f5f500f5f5f5, 0x00e4e4e400e4e4e4, | 525 | 0x001b1b1b001b1b1bULL, 0x00f5f5f500f5f5f5ULL, 0x00e4e4e400e4e4e4ULL, |
526 | 0x000e0e0e000e0e0e, 0x0073737300737373, 0x00aaaaaa00aaaaaa, | 526 | 0x000e0e0e000e0e0eULL, 0x0073737300737373ULL, 0x00aaaaaa00aaaaaaULL, |
527 | 0x00f1f1f100f1f1f1, 0x00dddddd00dddddd, 0x0059595900595959, | 527 | 0x00f1f1f100f1f1f1ULL, 0x00dddddd00ddddddULL, 0x0059595900595959ULL, |
528 | 0x0014141400141414, 0x006c6c6c006c6c6c, 0x0092929200929292, | 528 | 0x0014141400141414ULL, 0x006c6c6c006c6c6cULL, 0x0092929200929292ULL, |
529 | 0x0054545400545454, 0x00d0d0d000d0d0d0, 0x0078787800787878, | 529 | 0x0054545400545454ULL, 0x00d0d0d000d0d0d0ULL, 0x0078787800787878ULL, |
530 | 0x0070707000707070, 0x00e3e3e300e3e3e3, 0x0049494900494949, | 530 | 0x0070707000707070ULL, 0x00e3e3e300e3e3e3ULL, 0x0049494900494949ULL, |
531 | 0x0080808000808080, 0x0050505000505050, 0x00a7a7a700a7a7a7, | 531 | 0x0080808000808080ULL, 0x0050505000505050ULL, 0x00a7a7a700a7a7a7ULL, |
532 | 0x00f6f6f600f6f6f6, 0x0077777700777777, 0x0093939300939393, | 532 | 0x00f6f6f600f6f6f6ULL, 0x0077777700777777ULL, 0x0093939300939393ULL, |
533 | 0x0086868600868686, 0x0083838300838383, 0x002a2a2a002a2a2a, | 533 | 0x0086868600868686ULL, 0x0083838300838383ULL, 0x002a2a2a002a2a2aULL, |
534 | 0x00c7c7c700c7c7c7, 0x005b5b5b005b5b5b, 0x00e9e9e900e9e9e9, | 534 | 0x00c7c7c700c7c7c7ULL, 0x005b5b5b005b5b5bULL, 0x00e9e9e900e9e9e9ULL, |
535 | 0x00eeeeee00eeeeee, 0x008f8f8f008f8f8f, 0x0001010100010101, | 535 | 0x00eeeeee00eeeeeeULL, 0x008f8f8f008f8f8fULL, 0x0001010100010101ULL, |
536 | 0x003d3d3d003d3d3d, | 536 | 0x003d3d3d003d3d3dULL, |
537 | }; | 537 | }; |
538 | 538 | ||
539 | const u64 camellia_sp30333033[256] = { | 539 | const u64 camellia_sp30333033[256] = { |
540 | 0x3800383838003838, 0x4100414141004141, 0x1600161616001616, | 540 | 0x3800383838003838ULL, 0x4100414141004141ULL, 0x1600161616001616ULL, |
541 | 0x7600767676007676, 0xd900d9d9d900d9d9, 0x9300939393009393, | 541 | 0x7600767676007676ULL, 0xd900d9d9d900d9d9ULL, 0x9300939393009393ULL, |
542 | 0x6000606060006060, 0xf200f2f2f200f2f2, 0x7200727272007272, | 542 | 0x6000606060006060ULL, 0xf200f2f2f200f2f2ULL, 0x7200727272007272ULL, |
543 | 0xc200c2c2c200c2c2, 0xab00ababab00abab, 0x9a009a9a9a009a9a, | 543 | 0xc200c2c2c200c2c2ULL, 0xab00ababab00ababULL, 0x9a009a9a9a009a9aULL, |
544 | 0x7500757575007575, 0x0600060606000606, 0x5700575757005757, | 544 | 0x7500757575007575ULL, 0x0600060606000606ULL, 0x5700575757005757ULL, |
545 | 0xa000a0a0a000a0a0, 0x9100919191009191, 0xf700f7f7f700f7f7, | 545 | 0xa000a0a0a000a0a0ULL, 0x9100919191009191ULL, 0xf700f7f7f700f7f7ULL, |
546 | 0xb500b5b5b500b5b5, 0xc900c9c9c900c9c9, 0xa200a2a2a200a2a2, | 546 | 0xb500b5b5b500b5b5ULL, 0xc900c9c9c900c9c9ULL, 0xa200a2a2a200a2a2ULL, |
547 | 0x8c008c8c8c008c8c, 0xd200d2d2d200d2d2, 0x9000909090009090, | 547 | 0x8c008c8c8c008c8cULL, 0xd200d2d2d200d2d2ULL, 0x9000909090009090ULL, |
548 | 0xf600f6f6f600f6f6, 0x0700070707000707, 0xa700a7a7a700a7a7, | 548 | 0xf600f6f6f600f6f6ULL, 0x0700070707000707ULL, 0xa700a7a7a700a7a7ULL, |
549 | 0x2700272727002727, 0x8e008e8e8e008e8e, 0xb200b2b2b200b2b2, | 549 | 0x2700272727002727ULL, 0x8e008e8e8e008e8eULL, 0xb200b2b2b200b2b2ULL, |
550 | 0x4900494949004949, 0xde00dedede00dede, 0x4300434343004343, | 550 | 0x4900494949004949ULL, 0xde00dedede00dedeULL, 0x4300434343004343ULL, |
551 | 0x5c005c5c5c005c5c, 0xd700d7d7d700d7d7, 0xc700c7c7c700c7c7, | 551 | 0x5c005c5c5c005c5cULL, 0xd700d7d7d700d7d7ULL, 0xc700c7c7c700c7c7ULL, |
552 | 0x3e003e3e3e003e3e, 0xf500f5f5f500f5f5, 0x8f008f8f8f008f8f, | 552 | 0x3e003e3e3e003e3eULL, 0xf500f5f5f500f5f5ULL, 0x8f008f8f8f008f8fULL, |
553 | 0x6700676767006767, 0x1f001f1f1f001f1f, 0x1800181818001818, | 553 | 0x6700676767006767ULL, 0x1f001f1f1f001f1fULL, 0x1800181818001818ULL, |
554 | 0x6e006e6e6e006e6e, 0xaf00afafaf00afaf, 0x2f002f2f2f002f2f, | 554 | 0x6e006e6e6e006e6eULL, 0xaf00afafaf00afafULL, 0x2f002f2f2f002f2fULL, |
555 | 0xe200e2e2e200e2e2, 0x8500858585008585, 0x0d000d0d0d000d0d, | 555 | 0xe200e2e2e200e2e2ULL, 0x8500858585008585ULL, 0x0d000d0d0d000d0dULL, |
556 | 0x5300535353005353, 0xf000f0f0f000f0f0, 0x9c009c9c9c009c9c, | 556 | 0x5300535353005353ULL, 0xf000f0f0f000f0f0ULL, 0x9c009c9c9c009c9cULL, |
557 | 0x6500656565006565, 0xea00eaeaea00eaea, 0xa300a3a3a300a3a3, | 557 | 0x6500656565006565ULL, 0xea00eaeaea00eaeaULL, 0xa300a3a3a300a3a3ULL, |
558 | 0xae00aeaeae00aeae, 0x9e009e9e9e009e9e, 0xec00ececec00ecec, | 558 | 0xae00aeaeae00aeaeULL, 0x9e009e9e9e009e9eULL, 0xec00ececec00ececULL, |
559 | 0x8000808080008080, 0x2d002d2d2d002d2d, 0x6b006b6b6b006b6b, | 559 | 0x8000808080008080ULL, 0x2d002d2d2d002d2dULL, 0x6b006b6b6b006b6bULL, |
560 | 0xa800a8a8a800a8a8, 0x2b002b2b2b002b2b, 0x3600363636003636, | 560 | 0xa800a8a8a800a8a8ULL, 0x2b002b2b2b002b2bULL, 0x3600363636003636ULL, |
561 | 0xa600a6a6a600a6a6, 0xc500c5c5c500c5c5, 0x8600868686008686, | 561 | 0xa600a6a6a600a6a6ULL, 0xc500c5c5c500c5c5ULL, 0x8600868686008686ULL, |
562 | 0x4d004d4d4d004d4d, 0x3300333333003333, 0xfd00fdfdfd00fdfd, | 562 | 0x4d004d4d4d004d4dULL, 0x3300333333003333ULL, 0xfd00fdfdfd00fdfdULL, |
563 | 0x6600666666006666, 0x5800585858005858, 0x9600969696009696, | 563 | 0x6600666666006666ULL, 0x5800585858005858ULL, 0x9600969696009696ULL, |
564 | 0x3a003a3a3a003a3a, 0x0900090909000909, 0x9500959595009595, | 564 | 0x3a003a3a3a003a3aULL, 0x0900090909000909ULL, 0x9500959595009595ULL, |
565 | 0x1000101010001010, 0x7800787878007878, 0xd800d8d8d800d8d8, | 565 | 0x1000101010001010ULL, 0x7800787878007878ULL, 0xd800d8d8d800d8d8ULL, |
566 | 0x4200424242004242, 0xcc00cccccc00cccc, 0xef00efefef00efef, | 566 | 0x4200424242004242ULL, 0xcc00cccccc00ccccULL, 0xef00efefef00efefULL, |
567 | 0x2600262626002626, 0xe500e5e5e500e5e5, 0x6100616161006161, | 567 | 0x2600262626002626ULL, 0xe500e5e5e500e5e5ULL, 0x6100616161006161ULL, |
568 | 0x1a001a1a1a001a1a, 0x3f003f3f3f003f3f, 0x3b003b3b3b003b3b, | 568 | 0x1a001a1a1a001a1aULL, 0x3f003f3f3f003f3fULL, 0x3b003b3b3b003b3bULL, |
569 | 0x8200828282008282, 0xb600b6b6b600b6b6, 0xdb00dbdbdb00dbdb, | 569 | 0x8200828282008282ULL, 0xb600b6b6b600b6b6ULL, 0xdb00dbdbdb00dbdbULL, |
570 | 0xd400d4d4d400d4d4, 0x9800989898009898, 0xe800e8e8e800e8e8, | 570 | 0xd400d4d4d400d4d4ULL, 0x9800989898009898ULL, 0xe800e8e8e800e8e8ULL, |
571 | 0x8b008b8b8b008b8b, 0x0200020202000202, 0xeb00ebebeb00ebeb, | 571 | 0x8b008b8b8b008b8bULL, 0x0200020202000202ULL, 0xeb00ebebeb00ebebULL, |
572 | 0x0a000a0a0a000a0a, 0x2c002c2c2c002c2c, 0x1d001d1d1d001d1d, | 572 | 0x0a000a0a0a000a0aULL, 0x2c002c2c2c002c2cULL, 0x1d001d1d1d001d1dULL, |
573 | 0xb000b0b0b000b0b0, 0x6f006f6f6f006f6f, 0x8d008d8d8d008d8d, | 573 | 0xb000b0b0b000b0b0ULL, 0x6f006f6f6f006f6fULL, 0x8d008d8d8d008d8dULL, |
574 | 0x8800888888008888, 0x0e000e0e0e000e0e, 0x1900191919001919, | 574 | 0x8800888888008888ULL, 0x0e000e0e0e000e0eULL, 0x1900191919001919ULL, |
575 | 0x8700878787008787, 0x4e004e4e4e004e4e, 0x0b000b0b0b000b0b, | 575 | 0x8700878787008787ULL, 0x4e004e4e4e004e4eULL, 0x0b000b0b0b000b0bULL, |
576 | 0xa900a9a9a900a9a9, 0x0c000c0c0c000c0c, 0x7900797979007979, | 576 | 0xa900a9a9a900a9a9ULL, 0x0c000c0c0c000c0cULL, 0x7900797979007979ULL, |
577 | 0x1100111111001111, 0x7f007f7f7f007f7f, 0x2200222222002222, | 577 | 0x1100111111001111ULL, 0x7f007f7f7f007f7fULL, 0x2200222222002222ULL, |
578 | 0xe700e7e7e700e7e7, 0x5900595959005959, 0xe100e1e1e100e1e1, | 578 | 0xe700e7e7e700e7e7ULL, 0x5900595959005959ULL, 0xe100e1e1e100e1e1ULL, |
579 | 0xda00dadada00dada, 0x3d003d3d3d003d3d, 0xc800c8c8c800c8c8, | 579 | 0xda00dadada00dadaULL, 0x3d003d3d3d003d3dULL, 0xc800c8c8c800c8c8ULL, |
580 | 0x1200121212001212, 0x0400040404000404, 0x7400747474007474, | 580 | 0x1200121212001212ULL, 0x0400040404000404ULL, 0x7400747474007474ULL, |
581 | 0x5400545454005454, 0x3000303030003030, 0x7e007e7e7e007e7e, | 581 | 0x5400545454005454ULL, 0x3000303030003030ULL, 0x7e007e7e7e007e7eULL, |
582 | 0xb400b4b4b400b4b4, 0x2800282828002828, 0x5500555555005555, | 582 | 0xb400b4b4b400b4b4ULL, 0x2800282828002828ULL, 0x5500555555005555ULL, |
583 | 0x6800686868006868, 0x5000505050005050, 0xbe00bebebe00bebe, | 583 | 0x6800686868006868ULL, 0x5000505050005050ULL, 0xbe00bebebe00bebeULL, |
584 | 0xd000d0d0d000d0d0, 0xc400c4c4c400c4c4, 0x3100313131003131, | 584 | 0xd000d0d0d000d0d0ULL, 0xc400c4c4c400c4c4ULL, 0x3100313131003131ULL, |
585 | 0xcb00cbcbcb00cbcb, 0x2a002a2a2a002a2a, 0xad00adadad00adad, | 585 | 0xcb00cbcbcb00cbcbULL, 0x2a002a2a2a002a2aULL, 0xad00adadad00adadULL, |
586 | 0x0f000f0f0f000f0f, 0xca00cacaca00caca, 0x7000707070007070, | 586 | 0x0f000f0f0f000f0fULL, 0xca00cacaca00cacaULL, 0x7000707070007070ULL, |
587 | 0xff00ffffff00ffff, 0x3200323232003232, 0x6900696969006969, | 587 | 0xff00ffffff00ffffULL, 0x3200323232003232ULL, 0x6900696969006969ULL, |
588 | 0x0800080808000808, 0x6200626262006262, 0x0000000000000000, | 588 | 0x0800080808000808ULL, 0x6200626262006262ULL, 0x0000000000000000ULL, |
589 | 0x2400242424002424, 0xd100d1d1d100d1d1, 0xfb00fbfbfb00fbfb, | 589 | 0x2400242424002424ULL, 0xd100d1d1d100d1d1ULL, 0xfb00fbfbfb00fbfbULL, |
590 | 0xba00bababa00baba, 0xed00ededed00eded, 0x4500454545004545, | 590 | 0xba00bababa00babaULL, 0xed00ededed00ededULL, 0x4500454545004545ULL, |
591 | 0x8100818181008181, 0x7300737373007373, 0x6d006d6d6d006d6d, | 591 | 0x8100818181008181ULL, 0x7300737373007373ULL, 0x6d006d6d6d006d6dULL, |
592 | 0x8400848484008484, 0x9f009f9f9f009f9f, 0xee00eeeeee00eeee, | 592 | 0x8400848484008484ULL, 0x9f009f9f9f009f9fULL, 0xee00eeeeee00eeeeULL, |
593 | 0x4a004a4a4a004a4a, 0xc300c3c3c300c3c3, 0x2e002e2e2e002e2e, | 593 | 0x4a004a4a4a004a4aULL, 0xc300c3c3c300c3c3ULL, 0x2e002e2e2e002e2eULL, |
594 | 0xc100c1c1c100c1c1, 0x0100010101000101, 0xe600e6e6e600e6e6, | 594 | 0xc100c1c1c100c1c1ULL, 0x0100010101000101ULL, 0xe600e6e6e600e6e6ULL, |
595 | 0x2500252525002525, 0x4800484848004848, 0x9900999999009999, | 595 | 0x2500252525002525ULL, 0x4800484848004848ULL, 0x9900999999009999ULL, |
596 | 0xb900b9b9b900b9b9, 0xb300b3b3b300b3b3, 0x7b007b7b7b007b7b, | 596 | 0xb900b9b9b900b9b9ULL, 0xb300b3b3b300b3b3ULL, 0x7b007b7b7b007b7bULL, |
597 | 0xf900f9f9f900f9f9, 0xce00cecece00cece, 0xbf00bfbfbf00bfbf, | 597 | 0xf900f9f9f900f9f9ULL, 0xce00cecece00ceceULL, 0xbf00bfbfbf00bfbfULL, |
598 | 0xdf00dfdfdf00dfdf, 0x7100717171007171, 0x2900292929002929, | 598 | 0xdf00dfdfdf00dfdfULL, 0x7100717171007171ULL, 0x2900292929002929ULL, |
599 | 0xcd00cdcdcd00cdcd, 0x6c006c6c6c006c6c, 0x1300131313001313, | 599 | 0xcd00cdcdcd00cdcdULL, 0x6c006c6c6c006c6cULL, 0x1300131313001313ULL, |
600 | 0x6400646464006464, 0x9b009b9b9b009b9b, 0x6300636363006363, | 600 | 0x6400646464006464ULL, 0x9b009b9b9b009b9bULL, 0x6300636363006363ULL, |
601 | 0x9d009d9d9d009d9d, 0xc000c0c0c000c0c0, 0x4b004b4b4b004b4b, | 601 | 0x9d009d9d9d009d9dULL, 0xc000c0c0c000c0c0ULL, 0x4b004b4b4b004b4bULL, |
602 | 0xb700b7b7b700b7b7, 0xa500a5a5a500a5a5, 0x8900898989008989, | 602 | 0xb700b7b7b700b7b7ULL, 0xa500a5a5a500a5a5ULL, 0x8900898989008989ULL, |
603 | 0x5f005f5f5f005f5f, 0xb100b1b1b100b1b1, 0x1700171717001717, | 603 | 0x5f005f5f5f005f5fULL, 0xb100b1b1b100b1b1ULL, 0x1700171717001717ULL, |
604 | 0xf400f4f4f400f4f4, 0xbc00bcbcbc00bcbc, 0xd300d3d3d300d3d3, | 604 | 0xf400f4f4f400f4f4ULL, 0xbc00bcbcbc00bcbcULL, 0xd300d3d3d300d3d3ULL, |
605 | 0x4600464646004646, 0xcf00cfcfcf00cfcf, 0x3700373737003737, | 605 | 0x4600464646004646ULL, 0xcf00cfcfcf00cfcfULL, 0x3700373737003737ULL, |
606 | 0x5e005e5e5e005e5e, 0x4700474747004747, 0x9400949494009494, | 606 | 0x5e005e5e5e005e5eULL, 0x4700474747004747ULL, 0x9400949494009494ULL, |
607 | 0xfa00fafafa00fafa, 0xfc00fcfcfc00fcfc, 0x5b005b5b5b005b5b, | 607 | 0xfa00fafafa00fafaULL, 0xfc00fcfcfc00fcfcULL, 0x5b005b5b5b005b5bULL, |
608 | 0x9700979797009797, 0xfe00fefefe00fefe, 0x5a005a5a5a005a5a, | 608 | 0x9700979797009797ULL, 0xfe00fefefe00fefeULL, 0x5a005a5a5a005a5aULL, |
609 | 0xac00acacac00acac, 0x3c003c3c3c003c3c, 0x4c004c4c4c004c4c, | 609 | 0xac00acacac00acacULL, 0x3c003c3c3c003c3cULL, 0x4c004c4c4c004c4cULL, |
610 | 0x0300030303000303, 0x3500353535003535, 0xf300f3f3f300f3f3, | 610 | 0x0300030303000303ULL, 0x3500353535003535ULL, 0xf300f3f3f300f3f3ULL, |
611 | 0x2300232323002323, 0xb800b8b8b800b8b8, 0x5d005d5d5d005d5d, | 611 | 0x2300232323002323ULL, 0xb800b8b8b800b8b8ULL, 0x5d005d5d5d005d5dULL, |
612 | 0x6a006a6a6a006a6a, 0x9200929292009292, 0xd500d5d5d500d5d5, | 612 | 0x6a006a6a6a006a6aULL, 0x9200929292009292ULL, 0xd500d5d5d500d5d5ULL, |
613 | 0x2100212121002121, 0x4400444444004444, 0x5100515151005151, | 613 | 0x2100212121002121ULL, 0x4400444444004444ULL, 0x5100515151005151ULL, |
614 | 0xc600c6c6c600c6c6, 0x7d007d7d7d007d7d, 0x3900393939003939, | 614 | 0xc600c6c6c600c6c6ULL, 0x7d007d7d7d007d7dULL, 0x3900393939003939ULL, |
615 | 0x8300838383008383, 0xdc00dcdcdc00dcdc, 0xaa00aaaaaa00aaaa, | 615 | 0x8300838383008383ULL, 0xdc00dcdcdc00dcdcULL, 0xaa00aaaaaa00aaaaULL, |
616 | 0x7c007c7c7c007c7c, 0x7700777777007777, 0x5600565656005656, | 616 | 0x7c007c7c7c007c7cULL, 0x7700777777007777ULL, 0x5600565656005656ULL, |
617 | 0x0500050505000505, 0x1b001b1b1b001b1b, 0xa400a4a4a400a4a4, | 617 | 0x0500050505000505ULL, 0x1b001b1b1b001b1bULL, 0xa400a4a4a400a4a4ULL, |
618 | 0x1500151515001515, 0x3400343434003434, 0x1e001e1e1e001e1e, | 618 | 0x1500151515001515ULL, 0x3400343434003434ULL, 0x1e001e1e1e001e1eULL, |
619 | 0x1c001c1c1c001c1c, 0xf800f8f8f800f8f8, 0x5200525252005252, | 619 | 0x1c001c1c1c001c1cULL, 0xf800f8f8f800f8f8ULL, 0x5200525252005252ULL, |
620 | 0x2000202020002020, 0x1400141414001414, 0xe900e9e9e900e9e9, | 620 | 0x2000202020002020ULL, 0x1400141414001414ULL, 0xe900e9e9e900e9e9ULL, |
621 | 0xbd00bdbdbd00bdbd, 0xdd00dddddd00dddd, 0xe400e4e4e400e4e4, | 621 | 0xbd00bdbdbd00bdbdULL, 0xdd00dddddd00ddddULL, 0xe400e4e4e400e4e4ULL, |
622 | 0xa100a1a1a100a1a1, 0xe000e0e0e000e0e0, 0x8a008a8a8a008a8a, | 622 | 0xa100a1a1a100a1a1ULL, 0xe000e0e0e000e0e0ULL, 0x8a008a8a8a008a8aULL, |
623 | 0xf100f1f1f100f1f1, 0xd600d6d6d600d6d6, 0x7a007a7a7a007a7a, | 623 | 0xf100f1f1f100f1f1ULL, 0xd600d6d6d600d6d6ULL, 0x7a007a7a7a007a7aULL, |
624 | 0xbb00bbbbbb00bbbb, 0xe300e3e3e300e3e3, 0x4000404040004040, | 624 | 0xbb00bbbbbb00bbbbULL, 0xe300e3e3e300e3e3ULL, 0x4000404040004040ULL, |
625 | 0x4f004f4f4f004f4f, | 625 | 0x4f004f4f4f004f4fULL, |
626 | }; | 626 | }; |
627 | 627 | ||
628 | const u64 camellia_sp44044404[256] = { | 628 | const u64 camellia_sp44044404[256] = { |
629 | 0x7070007070700070, 0x2c2c002c2c2c002c, 0xb3b300b3b3b300b3, | 629 | 0x7070007070700070ULL, 0x2c2c002c2c2c002cULL, 0xb3b300b3b3b300b3ULL, |
630 | 0xc0c000c0c0c000c0, 0xe4e400e4e4e400e4, 0x5757005757570057, | 630 | 0xc0c000c0c0c000c0ULL, 0xe4e400e4e4e400e4ULL, 0x5757005757570057ULL, |
631 | 0xeaea00eaeaea00ea, 0xaeae00aeaeae00ae, 0x2323002323230023, | 631 | 0xeaea00eaeaea00eaULL, 0xaeae00aeaeae00aeULL, 0x2323002323230023ULL, |
632 | 0x6b6b006b6b6b006b, 0x4545004545450045, 0xa5a500a5a5a500a5, | 632 | 0x6b6b006b6b6b006bULL, 0x4545004545450045ULL, 0xa5a500a5a5a500a5ULL, |
633 | 0xeded00ededed00ed, 0x4f4f004f4f4f004f, 0x1d1d001d1d1d001d, | 633 | 0xeded00ededed00edULL, 0x4f4f004f4f4f004fULL, 0x1d1d001d1d1d001dULL, |
634 | 0x9292009292920092, 0x8686008686860086, 0xafaf00afafaf00af, | 634 | 0x9292009292920092ULL, 0x8686008686860086ULL, 0xafaf00afafaf00afULL, |
635 | 0x7c7c007c7c7c007c, 0x1f1f001f1f1f001f, 0x3e3e003e3e3e003e, | 635 | 0x7c7c007c7c7c007cULL, 0x1f1f001f1f1f001fULL, 0x3e3e003e3e3e003eULL, |
636 | 0xdcdc00dcdcdc00dc, 0x5e5e005e5e5e005e, 0x0b0b000b0b0b000b, | 636 | 0xdcdc00dcdcdc00dcULL, 0x5e5e005e5e5e005eULL, 0x0b0b000b0b0b000bULL, |
637 | 0xa6a600a6a6a600a6, 0x3939003939390039, 0xd5d500d5d5d500d5, | 637 | 0xa6a600a6a6a600a6ULL, 0x3939003939390039ULL, 0xd5d500d5d5d500d5ULL, |
638 | 0x5d5d005d5d5d005d, 0xd9d900d9d9d900d9, 0x5a5a005a5a5a005a, | 638 | 0x5d5d005d5d5d005dULL, 0xd9d900d9d9d900d9ULL, 0x5a5a005a5a5a005aULL, |
639 | 0x5151005151510051, 0x6c6c006c6c6c006c, 0x8b8b008b8b8b008b, | 639 | 0x5151005151510051ULL, 0x6c6c006c6c6c006cULL, 0x8b8b008b8b8b008bULL, |
640 | 0x9a9a009a9a9a009a, 0xfbfb00fbfbfb00fb, 0xb0b000b0b0b000b0, | 640 | 0x9a9a009a9a9a009aULL, 0xfbfb00fbfbfb00fbULL, 0xb0b000b0b0b000b0ULL, |
641 | 0x7474007474740074, 0x2b2b002b2b2b002b, 0xf0f000f0f0f000f0, | 641 | 0x7474007474740074ULL, 0x2b2b002b2b2b002bULL, 0xf0f000f0f0f000f0ULL, |
642 | 0x8484008484840084, 0xdfdf00dfdfdf00df, 0xcbcb00cbcbcb00cb, | 642 | 0x8484008484840084ULL, 0xdfdf00dfdfdf00dfULL, 0xcbcb00cbcbcb00cbULL, |
643 | 0x3434003434340034, 0x7676007676760076, 0x6d6d006d6d6d006d, | 643 | 0x3434003434340034ULL, 0x7676007676760076ULL, 0x6d6d006d6d6d006dULL, |
644 | 0xa9a900a9a9a900a9, 0xd1d100d1d1d100d1, 0x0404000404040004, | 644 | 0xa9a900a9a9a900a9ULL, 0xd1d100d1d1d100d1ULL, 0x0404000404040004ULL, |
645 | 0x1414001414140014, 0x3a3a003a3a3a003a, 0xdede00dedede00de, | 645 | 0x1414001414140014ULL, 0x3a3a003a3a3a003aULL, 0xdede00dedede00deULL, |
646 | 0x1111001111110011, 0x3232003232320032, 0x9c9c009c9c9c009c, | 646 | 0x1111001111110011ULL, 0x3232003232320032ULL, 0x9c9c009c9c9c009cULL, |
647 | 0x5353005353530053, 0xf2f200f2f2f200f2, 0xfefe00fefefe00fe, | 647 | 0x5353005353530053ULL, 0xf2f200f2f2f200f2ULL, 0xfefe00fefefe00feULL, |
648 | 0xcfcf00cfcfcf00cf, 0xc3c300c3c3c300c3, 0x7a7a007a7a7a007a, | 648 | 0xcfcf00cfcfcf00cfULL, 0xc3c300c3c3c300c3ULL, 0x7a7a007a7a7a007aULL, |
649 | 0x2424002424240024, 0xe8e800e8e8e800e8, 0x6060006060600060, | 649 | 0x2424002424240024ULL, 0xe8e800e8e8e800e8ULL, 0x6060006060600060ULL, |
650 | 0x6969006969690069, 0xaaaa00aaaaaa00aa, 0xa0a000a0a0a000a0, | 650 | 0x6969006969690069ULL, 0xaaaa00aaaaaa00aaULL, 0xa0a000a0a0a000a0ULL, |
651 | 0xa1a100a1a1a100a1, 0x6262006262620062, 0x5454005454540054, | 651 | 0xa1a100a1a1a100a1ULL, 0x6262006262620062ULL, 0x5454005454540054ULL, |
652 | 0x1e1e001e1e1e001e, 0xe0e000e0e0e000e0, 0x6464006464640064, | 652 | 0x1e1e001e1e1e001eULL, 0xe0e000e0e0e000e0ULL, 0x6464006464640064ULL, |
653 | 0x1010001010100010, 0x0000000000000000, 0xa3a300a3a3a300a3, | 653 | 0x1010001010100010ULL, 0x0000000000000000ULL, 0xa3a300a3a3a300a3ULL, |
654 | 0x7575007575750075, 0x8a8a008a8a8a008a, 0xe6e600e6e6e600e6, | 654 | 0x7575007575750075ULL, 0x8a8a008a8a8a008aULL, 0xe6e600e6e6e600e6ULL, |
655 | 0x0909000909090009, 0xdddd00dddddd00dd, 0x8787008787870087, | 655 | 0x0909000909090009ULL, 0xdddd00dddddd00ddULL, 0x8787008787870087ULL, |
656 | 0x8383008383830083, 0xcdcd00cdcdcd00cd, 0x9090009090900090, | 656 | 0x8383008383830083ULL, 0xcdcd00cdcdcd00cdULL, 0x9090009090900090ULL, |
657 | 0x7373007373730073, 0xf6f600f6f6f600f6, 0x9d9d009d9d9d009d, | 657 | 0x7373007373730073ULL, 0xf6f600f6f6f600f6ULL, 0x9d9d009d9d9d009dULL, |
658 | 0xbfbf00bfbfbf00bf, 0x5252005252520052, 0xd8d800d8d8d800d8, | 658 | 0xbfbf00bfbfbf00bfULL, 0x5252005252520052ULL, 0xd8d800d8d8d800d8ULL, |
659 | 0xc8c800c8c8c800c8, 0xc6c600c6c6c600c6, 0x8181008181810081, | 659 | 0xc8c800c8c8c800c8ULL, 0xc6c600c6c6c600c6ULL, 0x8181008181810081ULL, |
660 | 0x6f6f006f6f6f006f, 0x1313001313130013, 0x6363006363630063, | 660 | 0x6f6f006f6f6f006fULL, 0x1313001313130013ULL, 0x6363006363630063ULL, |
661 | 0xe9e900e9e9e900e9, 0xa7a700a7a7a700a7, 0x9f9f009f9f9f009f, | 661 | 0xe9e900e9e9e900e9ULL, 0xa7a700a7a7a700a7ULL, 0x9f9f009f9f9f009fULL, |
662 | 0xbcbc00bcbcbc00bc, 0x2929002929290029, 0xf9f900f9f9f900f9, | 662 | 0xbcbc00bcbcbc00bcULL, 0x2929002929290029ULL, 0xf9f900f9f9f900f9ULL, |
663 | 0x2f2f002f2f2f002f, 0xb4b400b4b4b400b4, 0x7878007878780078, | 663 | 0x2f2f002f2f2f002fULL, 0xb4b400b4b4b400b4ULL, 0x7878007878780078ULL, |
664 | 0x0606000606060006, 0xe7e700e7e7e700e7, 0x7171007171710071, | 664 | 0x0606000606060006ULL, 0xe7e700e7e7e700e7ULL, 0x7171007171710071ULL, |
665 | 0xd4d400d4d4d400d4, 0xabab00ababab00ab, 0x8888008888880088, | 665 | 0xd4d400d4d4d400d4ULL, 0xabab00ababab00abULL, 0x8888008888880088ULL, |
666 | 0x8d8d008d8d8d008d, 0x7272007272720072, 0xb9b900b9b9b900b9, | 666 | 0x8d8d008d8d8d008dULL, 0x7272007272720072ULL, 0xb9b900b9b9b900b9ULL, |
667 | 0xf8f800f8f8f800f8, 0xacac00acacac00ac, 0x3636003636360036, | 667 | 0xf8f800f8f8f800f8ULL, 0xacac00acacac00acULL, 0x3636003636360036ULL, |
668 | 0x2a2a002a2a2a002a, 0x3c3c003c3c3c003c, 0xf1f100f1f1f100f1, | 668 | 0x2a2a002a2a2a002aULL, 0x3c3c003c3c3c003cULL, 0xf1f100f1f1f100f1ULL, |
669 | 0x4040004040400040, 0xd3d300d3d3d300d3, 0xbbbb00bbbbbb00bb, | 669 | 0x4040004040400040ULL, 0xd3d300d3d3d300d3ULL, 0xbbbb00bbbbbb00bbULL, |
670 | 0x4343004343430043, 0x1515001515150015, 0xadad00adadad00ad, | 670 | 0x4343004343430043ULL, 0x1515001515150015ULL, 0xadad00adadad00adULL, |
671 | 0x7777007777770077, 0x8080008080800080, 0x8282008282820082, | 671 | 0x7777007777770077ULL, 0x8080008080800080ULL, 0x8282008282820082ULL, |
672 | 0xecec00ececec00ec, 0x2727002727270027, 0xe5e500e5e5e500e5, | 672 | 0xecec00ececec00ecULL, 0x2727002727270027ULL, 0xe5e500e5e5e500e5ULL, |
673 | 0x8585008585850085, 0x3535003535350035, 0x0c0c000c0c0c000c, | 673 | 0x8585008585850085ULL, 0x3535003535350035ULL, 0x0c0c000c0c0c000cULL, |
674 | 0x4141004141410041, 0xefef00efefef00ef, 0x9393009393930093, | 674 | 0x4141004141410041ULL, 0xefef00efefef00efULL, 0x9393009393930093ULL, |
675 | 0x1919001919190019, 0x2121002121210021, 0x0e0e000e0e0e000e, | 675 | 0x1919001919190019ULL, 0x2121002121210021ULL, 0x0e0e000e0e0e000eULL, |
676 | 0x4e4e004e4e4e004e, 0x6565006565650065, 0xbdbd00bdbdbd00bd, | 676 | 0x4e4e004e4e4e004eULL, 0x6565006565650065ULL, 0xbdbd00bdbdbd00bdULL, |
677 | 0xb8b800b8b8b800b8, 0x8f8f008f8f8f008f, 0xebeb00ebebeb00eb, | 677 | 0xb8b800b8b8b800b8ULL, 0x8f8f008f8f8f008fULL, 0xebeb00ebebeb00ebULL, |
678 | 0xcece00cecece00ce, 0x3030003030300030, 0x5f5f005f5f5f005f, | 678 | 0xcece00cecece00ceULL, 0x3030003030300030ULL, 0x5f5f005f5f5f005fULL, |
679 | 0xc5c500c5c5c500c5, 0x1a1a001a1a1a001a, 0xe1e100e1e1e100e1, | 679 | 0xc5c500c5c5c500c5ULL, 0x1a1a001a1a1a001aULL, 0xe1e100e1e1e100e1ULL, |
680 | 0xcaca00cacaca00ca, 0x4747004747470047, 0x3d3d003d3d3d003d, | 680 | 0xcaca00cacaca00caULL, 0x4747004747470047ULL, 0x3d3d003d3d3d003dULL, |
681 | 0x0101000101010001, 0xd6d600d6d6d600d6, 0x5656005656560056, | 681 | 0x0101000101010001ULL, 0xd6d600d6d6d600d6ULL, 0x5656005656560056ULL, |
682 | 0x4d4d004d4d4d004d, 0x0d0d000d0d0d000d, 0x6666006666660066, | 682 | 0x4d4d004d4d4d004dULL, 0x0d0d000d0d0d000dULL, 0x6666006666660066ULL, |
683 | 0xcccc00cccccc00cc, 0x2d2d002d2d2d002d, 0x1212001212120012, | 683 | 0xcccc00cccccc00ccULL, 0x2d2d002d2d2d002dULL, 0x1212001212120012ULL, |
684 | 0x2020002020200020, 0xb1b100b1b1b100b1, 0x9999009999990099, | 684 | 0x2020002020200020ULL, 0xb1b100b1b1b100b1ULL, 0x9999009999990099ULL, |
685 | 0x4c4c004c4c4c004c, 0xc2c200c2c2c200c2, 0x7e7e007e7e7e007e, | 685 | 0x4c4c004c4c4c004cULL, 0xc2c200c2c2c200c2ULL, 0x7e7e007e7e7e007eULL, |
686 | 0x0505000505050005, 0xb7b700b7b7b700b7, 0x3131003131310031, | 686 | 0x0505000505050005ULL, 0xb7b700b7b7b700b7ULL, 0x3131003131310031ULL, |
687 | 0x1717001717170017, 0xd7d700d7d7d700d7, 0x5858005858580058, | 687 | 0x1717001717170017ULL, 0xd7d700d7d7d700d7ULL, 0x5858005858580058ULL, |
688 | 0x6161006161610061, 0x1b1b001b1b1b001b, 0x1c1c001c1c1c001c, | 688 | 0x6161006161610061ULL, 0x1b1b001b1b1b001bULL, 0x1c1c001c1c1c001cULL, |
689 | 0x0f0f000f0f0f000f, 0x1616001616160016, 0x1818001818180018, | 689 | 0x0f0f000f0f0f000fULL, 0x1616001616160016ULL, 0x1818001818180018ULL, |
690 | 0x2222002222220022, 0x4444004444440044, 0xb2b200b2b2b200b2, | 690 | 0x2222002222220022ULL, 0x4444004444440044ULL, 0xb2b200b2b2b200b2ULL, |
691 | 0xb5b500b5b5b500b5, 0x9191009191910091, 0x0808000808080008, | 691 | 0xb5b500b5b5b500b5ULL, 0x9191009191910091ULL, 0x0808000808080008ULL, |
692 | 0xa8a800a8a8a800a8, 0xfcfc00fcfcfc00fc, 0x5050005050500050, | 692 | 0xa8a800a8a8a800a8ULL, 0xfcfc00fcfcfc00fcULL, 0x5050005050500050ULL, |
693 | 0xd0d000d0d0d000d0, 0x7d7d007d7d7d007d, 0x8989008989890089, | 693 | 0xd0d000d0d0d000d0ULL, 0x7d7d007d7d7d007dULL, 0x8989008989890089ULL, |
694 | 0x9797009797970097, 0x5b5b005b5b5b005b, 0x9595009595950095, | 694 | 0x9797009797970097ULL, 0x5b5b005b5b5b005bULL, 0x9595009595950095ULL, |
695 | 0xffff00ffffff00ff, 0xd2d200d2d2d200d2, 0xc4c400c4c4c400c4, | 695 | 0xffff00ffffff00ffULL, 0xd2d200d2d2d200d2ULL, 0xc4c400c4c4c400c4ULL, |
696 | 0x4848004848480048, 0xf7f700f7f7f700f7, 0xdbdb00dbdbdb00db, | 696 | 0x4848004848480048ULL, 0xf7f700f7f7f700f7ULL, 0xdbdb00dbdbdb00dbULL, |
697 | 0x0303000303030003, 0xdada00dadada00da, 0x3f3f003f3f3f003f, | 697 | 0x0303000303030003ULL, 0xdada00dadada00daULL, 0x3f3f003f3f3f003fULL, |
698 | 0x9494009494940094, 0x5c5c005c5c5c005c, 0x0202000202020002, | 698 | 0x9494009494940094ULL, 0x5c5c005c5c5c005cULL, 0x0202000202020002ULL, |
699 | 0x4a4a004a4a4a004a, 0x3333003333330033, 0x6767006767670067, | 699 | 0x4a4a004a4a4a004aULL, 0x3333003333330033ULL, 0x6767006767670067ULL, |
700 | 0xf3f300f3f3f300f3, 0x7f7f007f7f7f007f, 0xe2e200e2e2e200e2, | 700 | 0xf3f300f3f3f300f3ULL, 0x7f7f007f7f7f007fULL, 0xe2e200e2e2e200e2ULL, |
701 | 0x9b9b009b9b9b009b, 0x2626002626260026, 0x3737003737370037, | 701 | 0x9b9b009b9b9b009bULL, 0x2626002626260026ULL, 0x3737003737370037ULL, |
702 | 0x3b3b003b3b3b003b, 0x9696009696960096, 0x4b4b004b4b4b004b, | 702 | 0x3b3b003b3b3b003bULL, 0x9696009696960096ULL, 0x4b4b004b4b4b004bULL, |
703 | 0xbebe00bebebe00be, 0x2e2e002e2e2e002e, 0x7979007979790079, | 703 | 0xbebe00bebebe00beULL, 0x2e2e002e2e2e002eULL, 0x7979007979790079ULL, |
704 | 0x8c8c008c8c8c008c, 0x6e6e006e6e6e006e, 0x8e8e008e8e8e008e, | 704 | 0x8c8c008c8c8c008cULL, 0x6e6e006e6e6e006eULL, 0x8e8e008e8e8e008eULL, |
705 | 0xf5f500f5f5f500f5, 0xb6b600b6b6b600b6, 0xfdfd00fdfdfd00fd, | 705 | 0xf5f500f5f5f500f5ULL, 0xb6b600b6b6b600b6ULL, 0xfdfd00fdfdfd00fdULL, |
706 | 0x5959005959590059, 0x9898009898980098, 0x6a6a006a6a6a006a, | 706 | 0x5959005959590059ULL, 0x9898009898980098ULL, 0x6a6a006a6a6a006aULL, |
707 | 0x4646004646460046, 0xbaba00bababa00ba, 0x2525002525250025, | 707 | 0x4646004646460046ULL, 0xbaba00bababa00baULL, 0x2525002525250025ULL, |
708 | 0x4242004242420042, 0xa2a200a2a2a200a2, 0xfafa00fafafa00fa, | 708 | 0x4242004242420042ULL, 0xa2a200a2a2a200a2ULL, 0xfafa00fafafa00faULL, |
709 | 0x0707000707070007, 0x5555005555550055, 0xeeee00eeeeee00ee, | 709 | 0x0707000707070007ULL, 0x5555005555550055ULL, 0xeeee00eeeeee00eeULL, |
710 | 0x0a0a000a0a0a000a, 0x4949004949490049, 0x6868006868680068, | 710 | 0x0a0a000a0a0a000aULL, 0x4949004949490049ULL, 0x6868006868680068ULL, |
711 | 0x3838003838380038, 0xa4a400a4a4a400a4, 0x2828002828280028, | 711 | 0x3838003838380038ULL, 0xa4a400a4a4a400a4ULL, 0x2828002828280028ULL, |
712 | 0x7b7b007b7b7b007b, 0xc9c900c9c9c900c9, 0xc1c100c1c1c100c1, | 712 | 0x7b7b007b7b7b007bULL, 0xc9c900c9c9c900c9ULL, 0xc1c100c1c1c100c1ULL, |
713 | 0xe3e300e3e3e300e3, 0xf4f400f4f4f400f4, 0xc7c700c7c7c700c7, | 713 | 0xe3e300e3e3e300e3ULL, 0xf4f400f4f4f400f4ULL, 0xc7c700c7c7c700c7ULL, |
714 | 0x9e9e009e9e9e009e, | 714 | 0x9e9e009e9e9e009eULL, |
715 | }; | 715 | }; |
716 | 716 | ||
717 | const u64 camellia_sp11101110[256] = { | 717 | const u64 camellia_sp11101110[256] = { |
718 | 0x7070700070707000, 0x8282820082828200, 0x2c2c2c002c2c2c00, | 718 | 0x7070700070707000ULL, 0x8282820082828200ULL, 0x2c2c2c002c2c2c00ULL, |
719 | 0xececec00ececec00, 0xb3b3b300b3b3b300, 0x2727270027272700, | 719 | 0xececec00ececec00ULL, 0xb3b3b300b3b3b300ULL, 0x2727270027272700ULL, |
720 | 0xc0c0c000c0c0c000, 0xe5e5e500e5e5e500, 0xe4e4e400e4e4e400, | 720 | 0xc0c0c000c0c0c000ULL, 0xe5e5e500e5e5e500ULL, 0xe4e4e400e4e4e400ULL, |
721 | 0x8585850085858500, 0x5757570057575700, 0x3535350035353500, | 721 | 0x8585850085858500ULL, 0x5757570057575700ULL, 0x3535350035353500ULL, |
722 | 0xeaeaea00eaeaea00, 0x0c0c0c000c0c0c00, 0xaeaeae00aeaeae00, | 722 | 0xeaeaea00eaeaea00ULL, 0x0c0c0c000c0c0c00ULL, 0xaeaeae00aeaeae00ULL, |
723 | 0x4141410041414100, 0x2323230023232300, 0xefefef00efefef00, | 723 | 0x4141410041414100ULL, 0x2323230023232300ULL, 0xefefef00efefef00ULL, |
724 | 0x6b6b6b006b6b6b00, 0x9393930093939300, 0x4545450045454500, | 724 | 0x6b6b6b006b6b6b00ULL, 0x9393930093939300ULL, 0x4545450045454500ULL, |
725 | 0x1919190019191900, 0xa5a5a500a5a5a500, 0x2121210021212100, | 725 | 0x1919190019191900ULL, 0xa5a5a500a5a5a500ULL, 0x2121210021212100ULL, |
726 | 0xededed00ededed00, 0x0e0e0e000e0e0e00, 0x4f4f4f004f4f4f00, | 726 | 0xededed00ededed00ULL, 0x0e0e0e000e0e0e00ULL, 0x4f4f4f004f4f4f00ULL, |
727 | 0x4e4e4e004e4e4e00, 0x1d1d1d001d1d1d00, 0x6565650065656500, | 727 | 0x4e4e4e004e4e4e00ULL, 0x1d1d1d001d1d1d00ULL, 0x6565650065656500ULL, |
728 | 0x9292920092929200, 0xbdbdbd00bdbdbd00, 0x8686860086868600, | 728 | 0x9292920092929200ULL, 0xbdbdbd00bdbdbd00ULL, 0x8686860086868600ULL, |
729 | 0xb8b8b800b8b8b800, 0xafafaf00afafaf00, 0x8f8f8f008f8f8f00, | 729 | 0xb8b8b800b8b8b800ULL, 0xafafaf00afafaf00ULL, 0x8f8f8f008f8f8f00ULL, |
730 | 0x7c7c7c007c7c7c00, 0xebebeb00ebebeb00, 0x1f1f1f001f1f1f00, | 730 | 0x7c7c7c007c7c7c00ULL, 0xebebeb00ebebeb00ULL, 0x1f1f1f001f1f1f00ULL, |
731 | 0xcecece00cecece00, 0x3e3e3e003e3e3e00, 0x3030300030303000, | 731 | 0xcecece00cecece00ULL, 0x3e3e3e003e3e3e00ULL, 0x3030300030303000ULL, |
732 | 0xdcdcdc00dcdcdc00, 0x5f5f5f005f5f5f00, 0x5e5e5e005e5e5e00, | 732 | 0xdcdcdc00dcdcdc00ULL, 0x5f5f5f005f5f5f00ULL, 0x5e5e5e005e5e5e00ULL, |
733 | 0xc5c5c500c5c5c500, 0x0b0b0b000b0b0b00, 0x1a1a1a001a1a1a00, | 733 | 0xc5c5c500c5c5c500ULL, 0x0b0b0b000b0b0b00ULL, 0x1a1a1a001a1a1a00ULL, |
734 | 0xa6a6a600a6a6a600, 0xe1e1e100e1e1e100, 0x3939390039393900, | 734 | 0xa6a6a600a6a6a600ULL, 0xe1e1e100e1e1e100ULL, 0x3939390039393900ULL, |
735 | 0xcacaca00cacaca00, 0xd5d5d500d5d5d500, 0x4747470047474700, | 735 | 0xcacaca00cacaca00ULL, 0xd5d5d500d5d5d500ULL, 0x4747470047474700ULL, |
736 | 0x5d5d5d005d5d5d00, 0x3d3d3d003d3d3d00, 0xd9d9d900d9d9d900, | 736 | 0x5d5d5d005d5d5d00ULL, 0x3d3d3d003d3d3d00ULL, 0xd9d9d900d9d9d900ULL, |
737 | 0x0101010001010100, 0x5a5a5a005a5a5a00, 0xd6d6d600d6d6d600, | 737 | 0x0101010001010100ULL, 0x5a5a5a005a5a5a00ULL, 0xd6d6d600d6d6d600ULL, |
738 | 0x5151510051515100, 0x5656560056565600, 0x6c6c6c006c6c6c00, | 738 | 0x5151510051515100ULL, 0x5656560056565600ULL, 0x6c6c6c006c6c6c00ULL, |
739 | 0x4d4d4d004d4d4d00, 0x8b8b8b008b8b8b00, 0x0d0d0d000d0d0d00, | 739 | 0x4d4d4d004d4d4d00ULL, 0x8b8b8b008b8b8b00ULL, 0x0d0d0d000d0d0d00ULL, |
740 | 0x9a9a9a009a9a9a00, 0x6666660066666600, 0xfbfbfb00fbfbfb00, | 740 | 0x9a9a9a009a9a9a00ULL, 0x6666660066666600ULL, 0xfbfbfb00fbfbfb00ULL, |
741 | 0xcccccc00cccccc00, 0xb0b0b000b0b0b000, 0x2d2d2d002d2d2d00, | 741 | 0xcccccc00cccccc00ULL, 0xb0b0b000b0b0b000ULL, 0x2d2d2d002d2d2d00ULL, |
742 | 0x7474740074747400, 0x1212120012121200, 0x2b2b2b002b2b2b00, | 742 | 0x7474740074747400ULL, 0x1212120012121200ULL, 0x2b2b2b002b2b2b00ULL, |
743 | 0x2020200020202000, 0xf0f0f000f0f0f000, 0xb1b1b100b1b1b100, | 743 | 0x2020200020202000ULL, 0xf0f0f000f0f0f000ULL, 0xb1b1b100b1b1b100ULL, |
744 | 0x8484840084848400, 0x9999990099999900, 0xdfdfdf00dfdfdf00, | 744 | 0x8484840084848400ULL, 0x9999990099999900ULL, 0xdfdfdf00dfdfdf00ULL, |
745 | 0x4c4c4c004c4c4c00, 0xcbcbcb00cbcbcb00, 0xc2c2c200c2c2c200, | 745 | 0x4c4c4c004c4c4c00ULL, 0xcbcbcb00cbcbcb00ULL, 0xc2c2c200c2c2c200ULL, |
746 | 0x3434340034343400, 0x7e7e7e007e7e7e00, 0x7676760076767600, | 746 | 0x3434340034343400ULL, 0x7e7e7e007e7e7e00ULL, 0x7676760076767600ULL, |
747 | 0x0505050005050500, 0x6d6d6d006d6d6d00, 0xb7b7b700b7b7b700, | 747 | 0x0505050005050500ULL, 0x6d6d6d006d6d6d00ULL, 0xb7b7b700b7b7b700ULL, |
748 | 0xa9a9a900a9a9a900, 0x3131310031313100, 0xd1d1d100d1d1d100, | 748 | 0xa9a9a900a9a9a900ULL, 0x3131310031313100ULL, 0xd1d1d100d1d1d100ULL, |
749 | 0x1717170017171700, 0x0404040004040400, 0xd7d7d700d7d7d700, | 749 | 0x1717170017171700ULL, 0x0404040004040400ULL, 0xd7d7d700d7d7d700ULL, |
750 | 0x1414140014141400, 0x5858580058585800, 0x3a3a3a003a3a3a00, | 750 | 0x1414140014141400ULL, 0x5858580058585800ULL, 0x3a3a3a003a3a3a00ULL, |
751 | 0x6161610061616100, 0xdedede00dedede00, 0x1b1b1b001b1b1b00, | 751 | 0x6161610061616100ULL, 0xdedede00dedede00ULL, 0x1b1b1b001b1b1b00ULL, |
752 | 0x1111110011111100, 0x1c1c1c001c1c1c00, 0x3232320032323200, | 752 | 0x1111110011111100ULL, 0x1c1c1c001c1c1c00ULL, 0x3232320032323200ULL, |
753 | 0x0f0f0f000f0f0f00, 0x9c9c9c009c9c9c00, 0x1616160016161600, | 753 | 0x0f0f0f000f0f0f00ULL, 0x9c9c9c009c9c9c00ULL, 0x1616160016161600ULL, |
754 | 0x5353530053535300, 0x1818180018181800, 0xf2f2f200f2f2f200, | 754 | 0x5353530053535300ULL, 0x1818180018181800ULL, 0xf2f2f200f2f2f200ULL, |
755 | 0x2222220022222200, 0xfefefe00fefefe00, 0x4444440044444400, | 755 | 0x2222220022222200ULL, 0xfefefe00fefefe00ULL, 0x4444440044444400ULL, |
756 | 0xcfcfcf00cfcfcf00, 0xb2b2b200b2b2b200, 0xc3c3c300c3c3c300, | 756 | 0xcfcfcf00cfcfcf00ULL, 0xb2b2b200b2b2b200ULL, 0xc3c3c300c3c3c300ULL, |
757 | 0xb5b5b500b5b5b500, 0x7a7a7a007a7a7a00, 0x9191910091919100, | 757 | 0xb5b5b500b5b5b500ULL, 0x7a7a7a007a7a7a00ULL, 0x9191910091919100ULL, |
758 | 0x2424240024242400, 0x0808080008080800, 0xe8e8e800e8e8e800, | 758 | 0x2424240024242400ULL, 0x0808080008080800ULL, 0xe8e8e800e8e8e800ULL, |
759 | 0xa8a8a800a8a8a800, 0x6060600060606000, 0xfcfcfc00fcfcfc00, | 759 | 0xa8a8a800a8a8a800ULL, 0x6060600060606000ULL, 0xfcfcfc00fcfcfc00ULL, |
760 | 0x6969690069696900, 0x5050500050505000, 0xaaaaaa00aaaaaa00, | 760 | 0x6969690069696900ULL, 0x5050500050505000ULL, 0xaaaaaa00aaaaaa00ULL, |
761 | 0xd0d0d000d0d0d000, 0xa0a0a000a0a0a000, 0x7d7d7d007d7d7d00, | 761 | 0xd0d0d000d0d0d000ULL, 0xa0a0a000a0a0a000ULL, 0x7d7d7d007d7d7d00ULL, |
762 | 0xa1a1a100a1a1a100, 0x8989890089898900, 0x6262620062626200, | 762 | 0xa1a1a100a1a1a100ULL, 0x8989890089898900ULL, 0x6262620062626200ULL, |
763 | 0x9797970097979700, 0x5454540054545400, 0x5b5b5b005b5b5b00, | 763 | 0x9797970097979700ULL, 0x5454540054545400ULL, 0x5b5b5b005b5b5b00ULL, |
764 | 0x1e1e1e001e1e1e00, 0x9595950095959500, 0xe0e0e000e0e0e000, | 764 | 0x1e1e1e001e1e1e00ULL, 0x9595950095959500ULL, 0xe0e0e000e0e0e000ULL, |
765 | 0xffffff00ffffff00, 0x6464640064646400, 0xd2d2d200d2d2d200, | 765 | 0xffffff00ffffff00ULL, 0x6464640064646400ULL, 0xd2d2d200d2d2d200ULL, |
766 | 0x1010100010101000, 0xc4c4c400c4c4c400, 0x0000000000000000, | 766 | 0x1010100010101000ULL, 0xc4c4c400c4c4c400ULL, 0x0000000000000000ULL, |
767 | 0x4848480048484800, 0xa3a3a300a3a3a300, 0xf7f7f700f7f7f700, | 767 | 0x4848480048484800ULL, 0xa3a3a300a3a3a300ULL, 0xf7f7f700f7f7f700ULL, |
768 | 0x7575750075757500, 0xdbdbdb00dbdbdb00, 0x8a8a8a008a8a8a00, | 768 | 0x7575750075757500ULL, 0xdbdbdb00dbdbdb00ULL, 0x8a8a8a008a8a8a00ULL, |
769 | 0x0303030003030300, 0xe6e6e600e6e6e600, 0xdadada00dadada00, | 769 | 0x0303030003030300ULL, 0xe6e6e600e6e6e600ULL, 0xdadada00dadada00ULL, |
770 | 0x0909090009090900, 0x3f3f3f003f3f3f00, 0xdddddd00dddddd00, | 770 | 0x0909090009090900ULL, 0x3f3f3f003f3f3f00ULL, 0xdddddd00dddddd00ULL, |
771 | 0x9494940094949400, 0x8787870087878700, 0x5c5c5c005c5c5c00, | 771 | 0x9494940094949400ULL, 0x8787870087878700ULL, 0x5c5c5c005c5c5c00ULL, |
772 | 0x8383830083838300, 0x0202020002020200, 0xcdcdcd00cdcdcd00, | 772 | 0x8383830083838300ULL, 0x0202020002020200ULL, 0xcdcdcd00cdcdcd00ULL, |
773 | 0x4a4a4a004a4a4a00, 0x9090900090909000, 0x3333330033333300, | 773 | 0x4a4a4a004a4a4a00ULL, 0x9090900090909000ULL, 0x3333330033333300ULL, |
774 | 0x7373730073737300, 0x6767670067676700, 0xf6f6f600f6f6f600, | 774 | 0x7373730073737300ULL, 0x6767670067676700ULL, 0xf6f6f600f6f6f600ULL, |
775 | 0xf3f3f300f3f3f300, 0x9d9d9d009d9d9d00, 0x7f7f7f007f7f7f00, | 775 | 0xf3f3f300f3f3f300ULL, 0x9d9d9d009d9d9d00ULL, 0x7f7f7f007f7f7f00ULL, |
776 | 0xbfbfbf00bfbfbf00, 0xe2e2e200e2e2e200, 0x5252520052525200, | 776 | 0xbfbfbf00bfbfbf00ULL, 0xe2e2e200e2e2e200ULL, 0x5252520052525200ULL, |
777 | 0x9b9b9b009b9b9b00, 0xd8d8d800d8d8d800, 0x2626260026262600, | 777 | 0x9b9b9b009b9b9b00ULL, 0xd8d8d800d8d8d800ULL, 0x2626260026262600ULL, |
778 | 0xc8c8c800c8c8c800, 0x3737370037373700, 0xc6c6c600c6c6c600, | 778 | 0xc8c8c800c8c8c800ULL, 0x3737370037373700ULL, 0xc6c6c600c6c6c600ULL, |
779 | 0x3b3b3b003b3b3b00, 0x8181810081818100, 0x9696960096969600, | 779 | 0x3b3b3b003b3b3b00ULL, 0x8181810081818100ULL, 0x9696960096969600ULL, |
780 | 0x6f6f6f006f6f6f00, 0x4b4b4b004b4b4b00, 0x1313130013131300, | 780 | 0x6f6f6f006f6f6f00ULL, 0x4b4b4b004b4b4b00ULL, 0x1313130013131300ULL, |
781 | 0xbebebe00bebebe00, 0x6363630063636300, 0x2e2e2e002e2e2e00, | 781 | 0xbebebe00bebebe00ULL, 0x6363630063636300ULL, 0x2e2e2e002e2e2e00ULL, |
782 | 0xe9e9e900e9e9e900, 0x7979790079797900, 0xa7a7a700a7a7a700, | 782 | 0xe9e9e900e9e9e900ULL, 0x7979790079797900ULL, 0xa7a7a700a7a7a700ULL, |
783 | 0x8c8c8c008c8c8c00, 0x9f9f9f009f9f9f00, 0x6e6e6e006e6e6e00, | 783 | 0x8c8c8c008c8c8c00ULL, 0x9f9f9f009f9f9f00ULL, 0x6e6e6e006e6e6e00ULL, |
784 | 0xbcbcbc00bcbcbc00, 0x8e8e8e008e8e8e00, 0x2929290029292900, | 784 | 0xbcbcbc00bcbcbc00ULL, 0x8e8e8e008e8e8e00ULL, 0x2929290029292900ULL, |
785 | 0xf5f5f500f5f5f500, 0xf9f9f900f9f9f900, 0xb6b6b600b6b6b600, | 785 | 0xf5f5f500f5f5f500ULL, 0xf9f9f900f9f9f900ULL, 0xb6b6b600b6b6b600ULL, |
786 | 0x2f2f2f002f2f2f00, 0xfdfdfd00fdfdfd00, 0xb4b4b400b4b4b400, | 786 | 0x2f2f2f002f2f2f00ULL, 0xfdfdfd00fdfdfd00ULL, 0xb4b4b400b4b4b400ULL, |
787 | 0x5959590059595900, 0x7878780078787800, 0x9898980098989800, | 787 | 0x5959590059595900ULL, 0x7878780078787800ULL, 0x9898980098989800ULL, |
788 | 0x0606060006060600, 0x6a6a6a006a6a6a00, 0xe7e7e700e7e7e700, | 788 | 0x0606060006060600ULL, 0x6a6a6a006a6a6a00ULL, 0xe7e7e700e7e7e700ULL, |
789 | 0x4646460046464600, 0x7171710071717100, 0xbababa00bababa00, | 789 | 0x4646460046464600ULL, 0x7171710071717100ULL, 0xbababa00bababa00ULL, |
790 | 0xd4d4d400d4d4d400, 0x2525250025252500, 0xababab00ababab00, | 790 | 0xd4d4d400d4d4d400ULL, 0x2525250025252500ULL, 0xababab00ababab00ULL, |
791 | 0x4242420042424200, 0x8888880088888800, 0xa2a2a200a2a2a200, | 791 | 0x4242420042424200ULL, 0x8888880088888800ULL, 0xa2a2a200a2a2a200ULL, |
792 | 0x8d8d8d008d8d8d00, 0xfafafa00fafafa00, 0x7272720072727200, | 792 | 0x8d8d8d008d8d8d00ULL, 0xfafafa00fafafa00ULL, 0x7272720072727200ULL, |
793 | 0x0707070007070700, 0xb9b9b900b9b9b900, 0x5555550055555500, | 793 | 0x0707070007070700ULL, 0xb9b9b900b9b9b900ULL, 0x5555550055555500ULL, |
794 | 0xf8f8f800f8f8f800, 0xeeeeee00eeeeee00, 0xacacac00acacac00, | 794 | 0xf8f8f800f8f8f800ULL, 0xeeeeee00eeeeee00ULL, 0xacacac00acacac00ULL, |
795 | 0x0a0a0a000a0a0a00, 0x3636360036363600, 0x4949490049494900, | 795 | 0x0a0a0a000a0a0a00ULL, 0x3636360036363600ULL, 0x4949490049494900ULL, |
796 | 0x2a2a2a002a2a2a00, 0x6868680068686800, 0x3c3c3c003c3c3c00, | 796 | 0x2a2a2a002a2a2a00ULL, 0x6868680068686800ULL, 0x3c3c3c003c3c3c00ULL, |
797 | 0x3838380038383800, 0xf1f1f100f1f1f100, 0xa4a4a400a4a4a400, | 797 | 0x3838380038383800ULL, 0xf1f1f100f1f1f100ULL, 0xa4a4a400a4a4a400ULL, |
798 | 0x4040400040404000, 0x2828280028282800, 0xd3d3d300d3d3d300, | 798 | 0x4040400040404000ULL, 0x2828280028282800ULL, 0xd3d3d300d3d3d300ULL, |
799 | 0x7b7b7b007b7b7b00, 0xbbbbbb00bbbbbb00, 0xc9c9c900c9c9c900, | 799 | 0x7b7b7b007b7b7b00ULL, 0xbbbbbb00bbbbbb00ULL, 0xc9c9c900c9c9c900ULL, |
800 | 0x4343430043434300, 0xc1c1c100c1c1c100, 0x1515150015151500, | 800 | 0x4343430043434300ULL, 0xc1c1c100c1c1c100ULL, 0x1515150015151500ULL, |
801 | 0xe3e3e300e3e3e300, 0xadadad00adadad00, 0xf4f4f400f4f4f400, | 801 | 0xe3e3e300e3e3e300ULL, 0xadadad00adadad00ULL, 0xf4f4f400f4f4f400ULL, |
802 | 0x7777770077777700, 0xc7c7c700c7c7c700, 0x8080800080808000, | 802 | 0x7777770077777700ULL, 0xc7c7c700c7c7c700ULL, 0x8080800080808000ULL, |
803 | 0x9e9e9e009e9e9e00, | 803 | 0x9e9e9e009e9e9e00ULL, |
804 | }; | 804 | }; |
805 | 805 | ||
806 | /* key constants */ | 806 | /* key constants */ |
@@ -1601,7 +1601,6 @@ static struct crypto_alg camellia_algs[6] = { { | |||
1601 | .cra_ctxsize = sizeof(struct camellia_ctx), | 1601 | .cra_ctxsize = sizeof(struct camellia_ctx), |
1602 | .cra_alignmask = 0, | 1602 | .cra_alignmask = 0, |
1603 | .cra_module = THIS_MODULE, | 1603 | .cra_module = THIS_MODULE, |
1604 | .cra_list = LIST_HEAD_INIT(camellia_algs[0].cra_list), | ||
1605 | .cra_u = { | 1604 | .cra_u = { |
1606 | .cipher = { | 1605 | .cipher = { |
1607 | .cia_min_keysize = CAMELLIA_MIN_KEY_SIZE, | 1606 | .cia_min_keysize = CAMELLIA_MIN_KEY_SIZE, |
@@ -1621,7 +1620,6 @@ static struct crypto_alg camellia_algs[6] = { { | |||
1621 | .cra_alignmask = 0, | 1620 | .cra_alignmask = 0, |
1622 | .cra_type = &crypto_blkcipher_type, | 1621 | .cra_type = &crypto_blkcipher_type, |
1623 | .cra_module = THIS_MODULE, | 1622 | .cra_module = THIS_MODULE, |
1624 | .cra_list = LIST_HEAD_INIT(camellia_algs[1].cra_list), | ||
1625 | .cra_u = { | 1623 | .cra_u = { |
1626 | .blkcipher = { | 1624 | .blkcipher = { |
1627 | .min_keysize = CAMELLIA_MIN_KEY_SIZE, | 1625 | .min_keysize = CAMELLIA_MIN_KEY_SIZE, |
@@ -1641,7 +1639,6 @@ static struct crypto_alg camellia_algs[6] = { { | |||
1641 | .cra_alignmask = 0, | 1639 | .cra_alignmask = 0, |
1642 | .cra_type = &crypto_blkcipher_type, | 1640 | .cra_type = &crypto_blkcipher_type, |
1643 | .cra_module = THIS_MODULE, | 1641 | .cra_module = THIS_MODULE, |
1644 | .cra_list = LIST_HEAD_INIT(camellia_algs[2].cra_list), | ||
1645 | .cra_u = { | 1642 | .cra_u = { |
1646 | .blkcipher = { | 1643 | .blkcipher = { |
1647 | .min_keysize = CAMELLIA_MIN_KEY_SIZE, | 1644 | .min_keysize = CAMELLIA_MIN_KEY_SIZE, |
@@ -1662,7 +1659,6 @@ static struct crypto_alg camellia_algs[6] = { { | |||
1662 | .cra_alignmask = 0, | 1659 | .cra_alignmask = 0, |
1663 | .cra_type = &crypto_blkcipher_type, | 1660 | .cra_type = &crypto_blkcipher_type, |
1664 | .cra_module = THIS_MODULE, | 1661 | .cra_module = THIS_MODULE, |
1665 | .cra_list = LIST_HEAD_INIT(camellia_algs[3].cra_list), | ||
1666 | .cra_u = { | 1662 | .cra_u = { |
1667 | .blkcipher = { | 1663 | .blkcipher = { |
1668 | .min_keysize = CAMELLIA_MIN_KEY_SIZE, | 1664 | .min_keysize = CAMELLIA_MIN_KEY_SIZE, |
@@ -1683,7 +1679,6 @@ static struct crypto_alg camellia_algs[6] = { { | |||
1683 | .cra_alignmask = 0, | 1679 | .cra_alignmask = 0, |
1684 | .cra_type = &crypto_blkcipher_type, | 1680 | .cra_type = &crypto_blkcipher_type, |
1685 | .cra_module = THIS_MODULE, | 1681 | .cra_module = THIS_MODULE, |
1686 | .cra_list = LIST_HEAD_INIT(camellia_algs[4].cra_list), | ||
1687 | .cra_exit = lrw_exit_tfm, | 1682 | .cra_exit = lrw_exit_tfm, |
1688 | .cra_u = { | 1683 | .cra_u = { |
1689 | .blkcipher = { | 1684 | .blkcipher = { |
@@ -1707,7 +1702,6 @@ static struct crypto_alg camellia_algs[6] = { { | |||
1707 | .cra_alignmask = 0, | 1702 | .cra_alignmask = 0, |
1708 | .cra_type = &crypto_blkcipher_type, | 1703 | .cra_type = &crypto_blkcipher_type, |
1709 | .cra_module = THIS_MODULE, | 1704 | .cra_module = THIS_MODULE, |
1710 | .cra_list = LIST_HEAD_INIT(camellia_algs[5].cra_list), | ||
1711 | .cra_u = { | 1705 | .cra_u = { |
1712 | .blkcipher = { | 1706 | .blkcipher = { |
1713 | .min_keysize = CAMELLIA_MIN_KEY_SIZE * 2, | 1707 | .min_keysize = CAMELLIA_MIN_KEY_SIZE * 2, |
diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S new file mode 100644 index 000000000000..a41a3aaba220 --- /dev/null +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S | |||
@@ -0,0 +1,376 @@ | |||
1 | /* | ||
2 | * Cast5 Cipher 16-way parallel algorithm (AVX/x86_64) | ||
3 | * | ||
4 | * Copyright (C) 2012 Johannes Goetzfried | ||
5 | * <Johannes.Goetzfried@informatik.stud.uni-erlangen.de> | ||
6 | * | ||
7 | * Copyright © 2012 Jussi Kivilinna <jussi.kivilinna@mbnet.fi> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | ||
22 | * USA | ||
23 | * | ||
24 | */ | ||
25 | |||
26 | .file "cast5-avx-x86_64-asm_64.S" | ||
27 | |||
28 | .extern cast5_s1 | ||
29 | .extern cast5_s2 | ||
30 | .extern cast5_s3 | ||
31 | .extern cast5_s4 | ||
32 | |||
33 | /* structure of crypto context */ | ||
34 | #define km 0 | ||
35 | #define kr (16*4) | ||
36 | #define rr ((16*4)+16) | ||
37 | |||
38 | /* s-boxes */ | ||
39 | #define s1 cast5_s1 | ||
40 | #define s2 cast5_s2 | ||
41 | #define s3 cast5_s3 | ||
42 | #define s4 cast5_s4 | ||
43 | |||
44 | /********************************************************************** | ||
45 | 16-way AVX cast5 | ||
46 | **********************************************************************/ | ||
47 | #define CTX %rdi | ||
48 | |||
49 | #define RL1 %xmm0 | ||
50 | #define RR1 %xmm1 | ||
51 | #define RL2 %xmm2 | ||
52 | #define RR2 %xmm3 | ||
53 | #define RL3 %xmm4 | ||
54 | #define RR3 %xmm5 | ||
55 | #define RL4 %xmm6 | ||
56 | #define RR4 %xmm7 | ||
57 | |||
58 | #define RX %xmm8 | ||
59 | |||
60 | #define RKM %xmm9 | ||
61 | #define RKR %xmm10 | ||
62 | #define RKRF %xmm11 | ||
63 | #define RKRR %xmm12 | ||
64 | |||
65 | #define R32 %xmm13 | ||
66 | #define R1ST %xmm14 | ||
67 | |||
68 | #define RTMP %xmm15 | ||
69 | |||
70 | #define RID1 %rbp | ||
71 | #define RID1d %ebp | ||
72 | #define RID2 %rsi | ||
73 | #define RID2d %esi | ||
74 | |||
75 | #define RGI1 %rdx | ||
76 | #define RGI1bl %dl | ||
77 | #define RGI1bh %dh | ||
78 | #define RGI2 %rcx | ||
79 | #define RGI2bl %cl | ||
80 | #define RGI2bh %ch | ||
81 | |||
82 | #define RGI3 %rax | ||
83 | #define RGI3bl %al | ||
84 | #define RGI3bh %ah | ||
85 | #define RGI4 %rbx | ||
86 | #define RGI4bl %bl | ||
87 | #define RGI4bh %bh | ||
88 | |||
89 | #define RFS1 %r8 | ||
90 | #define RFS1d %r8d | ||
91 | #define RFS2 %r9 | ||
92 | #define RFS2d %r9d | ||
93 | #define RFS3 %r10 | ||
94 | #define RFS3d %r10d | ||
95 | |||
96 | |||
97 | #define lookup_32bit(src, dst, op1, op2, op3, interleave_op, il_reg) \ | ||
98 | movzbl src ## bh, RID1d; \ | ||
99 | movzbl src ## bl, RID2d; \ | ||
100 | shrq $16, src; \ | ||
101 | movl s1(, RID1, 4), dst ## d; \ | ||
102 | op1 s2(, RID2, 4), dst ## d; \ | ||
103 | movzbl src ## bh, RID1d; \ | ||
104 | movzbl src ## bl, RID2d; \ | ||
105 | interleave_op(il_reg); \ | ||
106 | op2 s3(, RID1, 4), dst ## d; \ | ||
107 | op3 s4(, RID2, 4), dst ## d; | ||
108 | |||
109 | #define dummy(d) /* do nothing */ | ||
110 | |||
111 | #define shr_next(reg) \ | ||
112 | shrq $16, reg; | ||
113 | |||
114 | #define F_head(a, x, gi1, gi2, op0) \ | ||
115 | op0 a, RKM, x; \ | ||
116 | vpslld RKRF, x, RTMP; \ | ||
117 | vpsrld RKRR, x, x; \ | ||
118 | vpor RTMP, x, x; \ | ||
119 | \ | ||
120 | vmovq x, gi1; \ | ||
121 | vpextrq $1, x, gi2; | ||
122 | |||
123 | #define F_tail(a, x, gi1, gi2, op1, op2, op3) \ | ||
124 | lookup_32bit(##gi1, RFS1, op1, op2, op3, shr_next, ##gi1); \ | ||
125 | lookup_32bit(##gi2, RFS3, op1, op2, op3, shr_next, ##gi2); \ | ||
126 | \ | ||
127 | lookup_32bit(##gi1, RFS2, op1, op2, op3, dummy, none); \ | ||
128 | shlq $32, RFS2; \ | ||
129 | orq RFS1, RFS2; \ | ||
130 | lookup_32bit(##gi2, RFS1, op1, op2, op3, dummy, none); \ | ||
131 | shlq $32, RFS1; \ | ||
132 | orq RFS1, RFS3; \ | ||
133 | \ | ||
134 | vmovq RFS2, x; \ | ||
135 | vpinsrq $1, RFS3, x, x; | ||
136 | |||
137 | #define F_2(a1, b1, a2, b2, op0, op1, op2, op3) \ | ||
138 | F_head(b1, RX, RGI1, RGI2, op0); \ | ||
139 | F_head(b2, RX, RGI3, RGI4, op0); \ | ||
140 | \ | ||
141 | F_tail(b1, RX, RGI1, RGI2, op1, op2, op3); \ | ||
142 | F_tail(b2, RTMP, RGI3, RGI4, op1, op2, op3); \ | ||
143 | \ | ||
144 | vpxor a1, RX, a1; \ | ||
145 | vpxor a2, RTMP, a2; | ||
146 | |||
147 | #define F1_2(a1, b1, a2, b2) \ | ||
148 | F_2(a1, b1, a2, b2, vpaddd, xorl, subl, addl) | ||
149 | #define F2_2(a1, b1, a2, b2) \ | ||
150 | F_2(a1, b1, a2, b2, vpxor, subl, addl, xorl) | ||
151 | #define F3_2(a1, b1, a2, b2) \ | ||
152 | F_2(a1, b1, a2, b2, vpsubd, addl, xorl, subl) | ||
153 | |||
154 | #define subround(a1, b1, a2, b2, f) \ | ||
155 | F ## f ## _2(a1, b1, a2, b2); | ||
156 | |||
157 | #define round(l, r, n, f) \ | ||
158 | vbroadcastss (km+(4*n))(CTX), RKM; \ | ||
159 | vpand R1ST, RKR, RKRF; \ | ||
160 | vpsubq RKRF, R32, RKRR; \ | ||
161 | vpsrldq $1, RKR, RKR; \ | ||
162 | subround(l ## 1, r ## 1, l ## 2, r ## 2, f); \ | ||
163 | subround(l ## 3, r ## 3, l ## 4, r ## 4, f); | ||
164 | |||
165 | #define enc_preload_rkr() \ | ||
166 | vbroadcastss .L16_mask, RKR; \ | ||
167 | /* add 16-bit rotation to key rotations (mod 32) */ \ | ||
168 | vpxor kr(CTX), RKR, RKR; | ||
169 | |||
170 | #define dec_preload_rkr() \ | ||
171 | vbroadcastss .L16_mask, RKR; \ | ||
172 | /* add 16-bit rotation to key rotations (mod 32) */ \ | ||
173 | vpxor kr(CTX), RKR, RKR; \ | ||
174 | vpshufb .Lbswap128_mask, RKR, RKR; | ||
175 | |||
176 | #define transpose_2x4(x0, x1, t0, t1) \ | ||
177 | vpunpckldq x1, x0, t0; \ | ||
178 | vpunpckhdq x1, x0, t1; \ | ||
179 | \ | ||
180 | vpunpcklqdq t1, t0, x0; \ | ||
181 | vpunpckhqdq t1, t0, x1; | ||
182 | |||
183 | #define inpack_blocks(in, x0, x1, t0, t1, rmask) \ | ||
184 | vmovdqu (0*4*4)(in), x0; \ | ||
185 | vmovdqu (1*4*4)(in), x1; \ | ||
186 | vpshufb rmask, x0, x0; \ | ||
187 | vpshufb rmask, x1, x1; \ | ||
188 | \ | ||
189 | transpose_2x4(x0, x1, t0, t1) | ||
190 | |||
191 | #define outunpack_blocks(out, x0, x1, t0, t1, rmask) \ | ||
192 | transpose_2x4(x0, x1, t0, t1) \ | ||
193 | \ | ||
194 | vpshufb rmask, x0, x0; \ | ||
195 | vpshufb rmask, x1, x1; \ | ||
196 | vmovdqu x0, (0*4*4)(out); \ | ||
197 | vmovdqu x1, (1*4*4)(out); | ||
198 | |||
199 | #define outunpack_xor_blocks(out, x0, x1, t0, t1, rmask) \ | ||
200 | transpose_2x4(x0, x1, t0, t1) \ | ||
201 | \ | ||
202 | vpshufb rmask, x0, x0; \ | ||
203 | vpshufb rmask, x1, x1; \ | ||
204 | vpxor (0*4*4)(out), x0, x0; \ | ||
205 | vmovdqu x0, (0*4*4)(out); \ | ||
206 | vpxor (1*4*4)(out), x1, x1; \ | ||
207 | vmovdqu x1, (1*4*4)(out); | ||
208 | |||
209 | .data | ||
210 | |||
211 | .align 16 | ||
212 | .Lbswap_mask: | ||
213 | .byte 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12 | ||
214 | .Lbswap128_mask: | ||
215 | .byte 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 | ||
216 | .L16_mask: | ||
217 | .byte 16, 16, 16, 16 | ||
218 | .L32_mask: | ||
219 | .byte 32, 0, 0, 0 | ||
220 | .Lfirst_mask: | ||
221 | .byte 0x1f, 0, 0, 0 | ||
222 | |||
223 | .text | ||
224 | |||
225 | .align 16 | ||
226 | .global __cast5_enc_blk_16way | ||
227 | .type __cast5_enc_blk_16way,@function; | ||
228 | |||
229 | __cast5_enc_blk_16way: | ||
230 | /* input: | ||
231 | * %rdi: ctx, CTX | ||
232 | * %rsi: dst | ||
233 | * %rdx: src | ||
234 | * %rcx: bool, if true: xor output | ||
235 | */ | ||
236 | |||
237 | pushq %rbp; | ||
238 | pushq %rbx; | ||
239 | pushq %rcx; | ||
240 | |||
241 | vmovdqa .Lbswap_mask, RKM; | ||
242 | vmovd .Lfirst_mask, R1ST; | ||
243 | vmovd .L32_mask, R32; | ||
244 | enc_preload_rkr(); | ||
245 | |||
246 | leaq 1*(2*4*4)(%rdx), %rax; | ||
247 | inpack_blocks(%rdx, RL1, RR1, RTMP, RX, RKM); | ||
248 | inpack_blocks(%rax, RL2, RR2, RTMP, RX, RKM); | ||
249 | leaq 2*(2*4*4)(%rdx), %rax; | ||
250 | inpack_blocks(%rax, RL3, RR3, RTMP, RX, RKM); | ||
251 | leaq 3*(2*4*4)(%rdx), %rax; | ||
252 | inpack_blocks(%rax, RL4, RR4, RTMP, RX, RKM); | ||
253 | |||
254 | movq %rsi, %r11; | ||
255 | |||
256 | round(RL, RR, 0, 1); | ||
257 | round(RR, RL, 1, 2); | ||
258 | round(RL, RR, 2, 3); | ||
259 | round(RR, RL, 3, 1); | ||
260 | round(RL, RR, 4, 2); | ||
261 | round(RR, RL, 5, 3); | ||
262 | round(RL, RR, 6, 1); | ||
263 | round(RR, RL, 7, 2); | ||
264 | round(RL, RR, 8, 3); | ||
265 | round(RR, RL, 9, 1); | ||
266 | round(RL, RR, 10, 2); | ||
267 | round(RR, RL, 11, 3); | ||
268 | |||
269 | movzbl rr(CTX), %eax; | ||
270 | testl %eax, %eax; | ||
271 | jnz __skip_enc; | ||
272 | |||
273 | round(RL, RR, 12, 1); | ||
274 | round(RR, RL, 13, 2); | ||
275 | round(RL, RR, 14, 3); | ||
276 | round(RR, RL, 15, 1); | ||
277 | |||
278 | __skip_enc: | ||
279 | popq %rcx; | ||
280 | popq %rbx; | ||
281 | popq %rbp; | ||
282 | |||
283 | vmovdqa .Lbswap_mask, RKM; | ||
284 | leaq 1*(2*4*4)(%r11), %rax; | ||
285 | |||
286 | testb %cl, %cl; | ||
287 | jnz __enc_xor16; | ||
288 | |||
289 | outunpack_blocks(%r11, RR1, RL1, RTMP, RX, RKM); | ||
290 | outunpack_blocks(%rax, RR2, RL2, RTMP, RX, RKM); | ||
291 | leaq 2*(2*4*4)(%r11), %rax; | ||
292 | outunpack_blocks(%rax, RR3, RL3, RTMP, RX, RKM); | ||
293 | leaq 3*(2*4*4)(%r11), %rax; | ||
294 | outunpack_blocks(%rax, RR4, RL4, RTMP, RX, RKM); | ||
295 | |||
296 | ret; | ||
297 | |||
298 | __enc_xor16: | ||
299 | outunpack_xor_blocks(%r11, RR1, RL1, RTMP, RX, RKM); | ||
300 | outunpack_xor_blocks(%rax, RR2, RL2, RTMP, RX, RKM); | ||
301 | leaq 2*(2*4*4)(%r11), %rax; | ||
302 | outunpack_xor_blocks(%rax, RR3, RL3, RTMP, RX, RKM); | ||
303 | leaq 3*(2*4*4)(%r11), %rax; | ||
304 | outunpack_xor_blocks(%rax, RR4, RL4, RTMP, RX, RKM); | ||
305 | |||
306 | ret; | ||
307 | |||
308 | .align 16 | ||
309 | .global cast5_dec_blk_16way | ||
310 | .type cast5_dec_blk_16way,@function; | ||
311 | |||
312 | cast5_dec_blk_16way: | ||
313 | /* input: | ||
314 | * %rdi: ctx, CTX | ||
315 | * %rsi: dst | ||
316 | * %rdx: src | ||
317 | */ | ||
318 | |||
319 | pushq %rbp; | ||
320 | pushq %rbx; | ||
321 | |||
322 | vmovdqa .Lbswap_mask, RKM; | ||
323 | vmovd .Lfirst_mask, R1ST; | ||
324 | vmovd .L32_mask, R32; | ||
325 | dec_preload_rkr(); | ||
326 | |||
327 | leaq 1*(2*4*4)(%rdx), %rax; | ||
328 | inpack_blocks(%rdx, RL1, RR1, RTMP, RX, RKM); | ||
329 | inpack_blocks(%rax, RL2, RR2, RTMP, RX, RKM); | ||
330 | leaq 2*(2*4*4)(%rdx), %rax; | ||
331 | inpack_blocks(%rax, RL3, RR3, RTMP, RX, RKM); | ||
332 | leaq 3*(2*4*4)(%rdx), %rax; | ||
333 | inpack_blocks(%rax, RL4, RR4, RTMP, RX, RKM); | ||
334 | |||
335 | movq %rsi, %r11; | ||
336 | |||
337 | movzbl rr(CTX), %eax; | ||
338 | testl %eax, %eax; | ||
339 | jnz __skip_dec; | ||
340 | |||
341 | round(RL, RR, 15, 1); | ||
342 | round(RR, RL, 14, 3); | ||
343 | round(RL, RR, 13, 2); | ||
344 | round(RR, RL, 12, 1); | ||
345 | |||
346 | __dec_tail: | ||
347 | round(RL, RR, 11, 3); | ||
348 | round(RR, RL, 10, 2); | ||
349 | round(RL, RR, 9, 1); | ||
350 | round(RR, RL, 8, 3); | ||
351 | round(RL, RR, 7, 2); | ||
352 | round(RR, RL, 6, 1); | ||
353 | round(RL, RR, 5, 3); | ||
354 | round(RR, RL, 4, 2); | ||
355 | round(RL, RR, 3, 1); | ||
356 | round(RR, RL, 2, 3); | ||
357 | round(RL, RR, 1, 2); | ||
358 | round(RR, RL, 0, 1); | ||
359 | |||
360 | vmovdqa .Lbswap_mask, RKM; | ||
361 | popq %rbx; | ||
362 | popq %rbp; | ||
363 | |||
364 | leaq 1*(2*4*4)(%r11), %rax; | ||
365 | outunpack_blocks(%r11, RR1, RL1, RTMP, RX, RKM); | ||
366 | outunpack_blocks(%rax, RR2, RL2, RTMP, RX, RKM); | ||
367 | leaq 2*(2*4*4)(%r11), %rax; | ||
368 | outunpack_blocks(%rax, RR3, RL3, RTMP, RX, RKM); | ||
369 | leaq 3*(2*4*4)(%r11), %rax; | ||
370 | outunpack_blocks(%rax, RR4, RL4, RTMP, RX, RKM); | ||
371 | |||
372 | ret; | ||
373 | |||
374 | __skip_dec: | ||
375 | vpsrldq $4, RKR, RKR; | ||
376 | jmp __dec_tail; | ||
diff --git a/arch/x86/crypto/cast5_avx_glue.c b/arch/x86/crypto/cast5_avx_glue.c new file mode 100644 index 000000000000..e0ea14f9547f --- /dev/null +++ b/arch/x86/crypto/cast5_avx_glue.c | |||
@@ -0,0 +1,530 @@ | |||
1 | /* | ||
2 | * Glue Code for the AVX assembler implemention of the Cast5 Cipher | ||
3 | * | ||
4 | * Copyright (C) 2012 Johannes Goetzfried | ||
5 | * <Johannes.Goetzfried@informatik.stud.uni-erlangen.de> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | ||
20 | * USA | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #include <linux/module.h> | ||
25 | #include <linux/hardirq.h> | ||
26 | #include <linux/types.h> | ||
27 | #include <linux/crypto.h> | ||
28 | #include <linux/err.h> | ||
29 | #include <crypto/algapi.h> | ||
30 | #include <crypto/cast5.h> | ||
31 | #include <crypto/cryptd.h> | ||
32 | #include <crypto/ctr.h> | ||
33 | #include <asm/xcr.h> | ||
34 | #include <asm/xsave.h> | ||
35 | #include <asm/crypto/ablk_helper.h> | ||
36 | #include <asm/crypto/glue_helper.h> | ||
37 | |||
38 | #define CAST5_PARALLEL_BLOCKS 16 | ||
39 | |||
40 | asmlinkage void __cast5_enc_blk_16way(struct cast5_ctx *ctx, u8 *dst, | ||
41 | const u8 *src, bool xor); | ||
42 | asmlinkage void cast5_dec_blk_16way(struct cast5_ctx *ctx, u8 *dst, | ||
43 | const u8 *src); | ||
44 | |||
45 | static inline void cast5_enc_blk_xway(struct cast5_ctx *ctx, u8 *dst, | ||
46 | const u8 *src) | ||
47 | { | ||
48 | __cast5_enc_blk_16way(ctx, dst, src, false); | ||
49 | } | ||
50 | |||
51 | static inline void cast5_enc_blk_xway_xor(struct cast5_ctx *ctx, u8 *dst, | ||
52 | const u8 *src) | ||
53 | { | ||
54 | __cast5_enc_blk_16way(ctx, dst, src, true); | ||
55 | } | ||
56 | |||
57 | static inline void cast5_dec_blk_xway(struct cast5_ctx *ctx, u8 *dst, | ||
58 | const u8 *src) | ||
59 | { | ||
60 | cast5_dec_blk_16way(ctx, dst, src); | ||
61 | } | ||
62 | |||
63 | |||
64 | static inline bool cast5_fpu_begin(bool fpu_enabled, unsigned int nbytes) | ||
65 | { | ||
66 | return glue_fpu_begin(CAST5_BLOCK_SIZE, CAST5_PARALLEL_BLOCKS, | ||
67 | NULL, fpu_enabled, nbytes); | ||
68 | } | ||
69 | |||
70 | static inline void cast5_fpu_end(bool fpu_enabled) | ||
71 | { | ||
72 | return glue_fpu_end(fpu_enabled); | ||
73 | } | ||
74 | |||
75 | static int ecb_crypt(struct blkcipher_desc *desc, struct blkcipher_walk *walk, | ||
76 | bool enc) | ||
77 | { | ||
78 | bool fpu_enabled = false; | ||
79 | struct cast5_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); | ||
80 | const unsigned int bsize = CAST5_BLOCK_SIZE; | ||
81 | unsigned int nbytes; | ||
82 | int err; | ||
83 | |||
84 | err = blkcipher_walk_virt(desc, walk); | ||
85 | desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; | ||
86 | |||
87 | while ((nbytes = walk->nbytes)) { | ||
88 | u8 *wsrc = walk->src.virt.addr; | ||
89 | u8 *wdst = walk->dst.virt.addr; | ||
90 | |||
91 | fpu_enabled = cast5_fpu_begin(fpu_enabled, nbytes); | ||
92 | |||
93 | /* Process multi-block batch */ | ||
94 | if (nbytes >= bsize * CAST5_PARALLEL_BLOCKS) { | ||
95 | do { | ||
96 | if (enc) | ||
97 | cast5_enc_blk_xway(ctx, wdst, wsrc); | ||
98 | else | ||
99 | cast5_dec_blk_xway(ctx, wdst, wsrc); | ||
100 | |||
101 | wsrc += bsize * CAST5_PARALLEL_BLOCKS; | ||
102 | wdst += bsize * CAST5_PARALLEL_BLOCKS; | ||
103 | nbytes -= bsize * CAST5_PARALLEL_BLOCKS; | ||
104 | } while (nbytes >= bsize * CAST5_PARALLEL_BLOCKS); | ||
105 | |||
106 | if (nbytes < bsize) | ||
107 | goto done; | ||
108 | } | ||
109 | |||
110 | /* Handle leftovers */ | ||
111 | do { | ||
112 | if (enc) | ||
113 | __cast5_encrypt(ctx, wdst, wsrc); | ||
114 | else | ||
115 | __cast5_decrypt(ctx, wdst, wsrc); | ||
116 | |||
117 | wsrc += bsize; | ||
118 | wdst += bsize; | ||
119 | nbytes -= bsize; | ||
120 | } while (nbytes >= bsize); | ||
121 | |||
122 | done: | ||
123 | err = blkcipher_walk_done(desc, walk, nbytes); | ||
124 | } | ||
125 | |||
126 | cast5_fpu_end(fpu_enabled); | ||
127 | return err; | ||
128 | } | ||
129 | |||
130 | static int ecb_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, | ||
131 | struct scatterlist *src, unsigned int nbytes) | ||
132 | { | ||
133 | struct blkcipher_walk walk; | ||
134 | |||
135 | blkcipher_walk_init(&walk, dst, src, nbytes); | ||
136 | return ecb_crypt(desc, &walk, true); | ||
137 | } | ||
138 | |||
139 | static int ecb_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, | ||
140 | struct scatterlist *src, unsigned int nbytes) | ||
141 | { | ||
142 | struct blkcipher_walk walk; | ||
143 | |||
144 | blkcipher_walk_init(&walk, dst, src, nbytes); | ||
145 | return ecb_crypt(desc, &walk, false); | ||
146 | } | ||
147 | |||
148 | static unsigned int __cbc_encrypt(struct blkcipher_desc *desc, | ||
149 | struct blkcipher_walk *walk) | ||
150 | { | ||
151 | struct cast5_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); | ||
152 | const unsigned int bsize = CAST5_BLOCK_SIZE; | ||
153 | unsigned int nbytes = walk->nbytes; | ||
154 | u64 *src = (u64 *)walk->src.virt.addr; | ||
155 | u64 *dst = (u64 *)walk->dst.virt.addr; | ||
156 | u64 *iv = (u64 *)walk->iv; | ||
157 | |||
158 | do { | ||
159 | *dst = *src ^ *iv; | ||
160 | __cast5_encrypt(ctx, (u8 *)dst, (u8 *)dst); | ||
161 | iv = dst; | ||
162 | |||
163 | src += 1; | ||
164 | dst += 1; | ||
165 | nbytes -= bsize; | ||
166 | } while (nbytes >= bsize); | ||
167 | |||
168 | *(u64 *)walk->iv = *iv; | ||
169 | return nbytes; | ||
170 | } | ||
171 | |||
172 | static int cbc_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, | ||
173 | struct scatterlist *src, unsigned int nbytes) | ||
174 | { | ||
175 | struct blkcipher_walk walk; | ||
176 | int err; | ||
177 | |||
178 | blkcipher_walk_init(&walk, dst, src, nbytes); | ||
179 | err = blkcipher_walk_virt(desc, &walk); | ||
180 | |||
181 | while ((nbytes = walk.nbytes)) { | ||
182 | nbytes = __cbc_encrypt(desc, &walk); | ||
183 | err = blkcipher_walk_done(desc, &walk, nbytes); | ||
184 | } | ||
185 | |||
186 | return err; | ||
187 | } | ||
188 | |||
189 | static unsigned int __cbc_decrypt(struct blkcipher_desc *desc, | ||
190 | struct blkcipher_walk *walk) | ||
191 | { | ||
192 | struct cast5_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); | ||
193 | const unsigned int bsize = CAST5_BLOCK_SIZE; | ||
194 | unsigned int nbytes = walk->nbytes; | ||
195 | u64 *src = (u64 *)walk->src.virt.addr; | ||
196 | u64 *dst = (u64 *)walk->dst.virt.addr; | ||
197 | u64 ivs[CAST5_PARALLEL_BLOCKS - 1]; | ||
198 | u64 last_iv; | ||
199 | int i; | ||
200 | |||
201 | /* Start of the last block. */ | ||
202 | src += nbytes / bsize - 1; | ||
203 | dst += nbytes / bsize - 1; | ||
204 | |||
205 | last_iv = *src; | ||
206 | |||
207 | /* Process multi-block batch */ | ||
208 | if (nbytes >= bsize * CAST5_PARALLEL_BLOCKS) { | ||
209 | do { | ||
210 | nbytes -= bsize * (CAST5_PARALLEL_BLOCKS - 1); | ||
211 | src -= CAST5_PARALLEL_BLOCKS - 1; | ||
212 | dst -= CAST5_PARALLEL_BLOCKS - 1; | ||
213 | |||
214 | for (i = 0; i < CAST5_PARALLEL_BLOCKS - 1; i++) | ||
215 | ivs[i] = src[i]; | ||
216 | |||
217 | cast5_dec_blk_xway(ctx, (u8 *)dst, (u8 *)src); | ||
218 | |||
219 | for (i = 0; i < CAST5_PARALLEL_BLOCKS - 1; i++) | ||
220 | *(dst + (i + 1)) ^= *(ivs + i); | ||
221 | |||
222 | nbytes -= bsize; | ||
223 | if (nbytes < bsize) | ||
224 | goto done; | ||
225 | |||
226 | *dst ^= *(src - 1); | ||
227 | src -= 1; | ||
228 | dst -= 1; | ||
229 | } while (nbytes >= bsize * CAST5_PARALLEL_BLOCKS); | ||
230 | |||
231 | if (nbytes < bsize) | ||
232 | goto done; | ||
233 | } | ||
234 | |||
235 | /* Handle leftovers */ | ||
236 | for (;;) { | ||
237 | __cast5_decrypt(ctx, (u8 *)dst, (u8 *)src); | ||
238 | |||
239 | nbytes -= bsize; | ||
240 | if (nbytes < bsize) | ||
241 | break; | ||
242 | |||
243 | *dst ^= *(src - 1); | ||
244 | src -= 1; | ||
245 | dst -= 1; | ||
246 | } | ||
247 | |||
248 | done: | ||
249 | *dst ^= *(u64 *)walk->iv; | ||
250 | *(u64 *)walk->iv = last_iv; | ||
251 | |||
252 | return nbytes; | ||
253 | } | ||
254 | |||
255 | static int cbc_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, | ||
256 | struct scatterlist *src, unsigned int nbytes) | ||
257 | { | ||
258 | bool fpu_enabled = false; | ||
259 | struct blkcipher_walk walk; | ||
260 | int err; | ||
261 | |||
262 | blkcipher_walk_init(&walk, dst, src, nbytes); | ||
263 | err = blkcipher_walk_virt(desc, &walk); | ||
264 | desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; | ||
265 | |||
266 | while ((nbytes = walk.nbytes)) { | ||
267 | fpu_enabled = cast5_fpu_begin(fpu_enabled, nbytes); | ||
268 | nbytes = __cbc_decrypt(desc, &walk); | ||
269 | err = blkcipher_walk_done(desc, &walk, nbytes); | ||
270 | } | ||
271 | |||
272 | cast5_fpu_end(fpu_enabled); | ||
273 | return err; | ||
274 | } | ||
275 | |||
276 | static void ctr_crypt_final(struct blkcipher_desc *desc, | ||
277 | struct blkcipher_walk *walk) | ||
278 | { | ||
279 | struct cast5_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); | ||
280 | u8 *ctrblk = walk->iv; | ||
281 | u8 keystream[CAST5_BLOCK_SIZE]; | ||
282 | u8 *src = walk->src.virt.addr; | ||
283 | u8 *dst = walk->dst.virt.addr; | ||
284 | unsigned int nbytes = walk->nbytes; | ||
285 | |||
286 | __cast5_encrypt(ctx, keystream, ctrblk); | ||
287 | crypto_xor(keystream, src, nbytes); | ||
288 | memcpy(dst, keystream, nbytes); | ||
289 | |||
290 | crypto_inc(ctrblk, CAST5_BLOCK_SIZE); | ||
291 | } | ||
292 | |||
293 | static unsigned int __ctr_crypt(struct blkcipher_desc *desc, | ||
294 | struct blkcipher_walk *walk) | ||
295 | { | ||
296 | struct cast5_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); | ||
297 | const unsigned int bsize = CAST5_BLOCK_SIZE; | ||
298 | unsigned int nbytes = walk->nbytes; | ||
299 | u64 *src = (u64 *)walk->src.virt.addr; | ||
300 | u64 *dst = (u64 *)walk->dst.virt.addr; | ||
301 | u64 ctrblk = be64_to_cpu(*(__be64 *)walk->iv); | ||
302 | __be64 ctrblocks[CAST5_PARALLEL_BLOCKS]; | ||
303 | int i; | ||
304 | |||
305 | /* Process multi-block batch */ | ||
306 | if (nbytes >= bsize * CAST5_PARALLEL_BLOCKS) { | ||
307 | do { | ||
308 | /* create ctrblks for parallel encrypt */ | ||
309 | for (i = 0; i < CAST5_PARALLEL_BLOCKS; i++) { | ||
310 | if (dst != src) | ||
311 | dst[i] = src[i]; | ||
312 | |||
313 | ctrblocks[i] = cpu_to_be64(ctrblk++); | ||
314 | } | ||
315 | |||
316 | cast5_enc_blk_xway_xor(ctx, (u8 *)dst, | ||
317 | (u8 *)ctrblocks); | ||
318 | |||
319 | src += CAST5_PARALLEL_BLOCKS; | ||
320 | dst += CAST5_PARALLEL_BLOCKS; | ||
321 | nbytes -= bsize * CAST5_PARALLEL_BLOCKS; | ||
322 | } while (nbytes >= bsize * CAST5_PARALLEL_BLOCKS); | ||
323 | |||
324 | if (nbytes < bsize) | ||
325 | goto done; | ||
326 | } | ||
327 | |||
328 | /* Handle leftovers */ | ||
329 | do { | ||
330 | if (dst != src) | ||
331 | *dst = *src; | ||
332 | |||
333 | ctrblocks[0] = cpu_to_be64(ctrblk++); | ||
334 | |||
335 | __cast5_encrypt(ctx, (u8 *)ctrblocks, (u8 *)ctrblocks); | ||
336 | *dst ^= ctrblocks[0]; | ||
337 | |||
338 | src += 1; | ||
339 | dst += 1; | ||
340 | nbytes -= bsize; | ||
341 | } while (nbytes >= bsize); | ||
342 | |||
343 | done: | ||
344 | *(__be64 *)walk->iv = cpu_to_be64(ctrblk); | ||
345 | return nbytes; | ||
346 | } | ||
347 | |||
348 | static int ctr_crypt(struct blkcipher_desc *desc, struct scatterlist *dst, | ||
349 | struct scatterlist *src, unsigned int nbytes) | ||
350 | { | ||
351 | bool fpu_enabled = false; | ||
352 | struct blkcipher_walk walk; | ||
353 | int err; | ||
354 | |||
355 | blkcipher_walk_init(&walk, dst, src, nbytes); | ||
356 | err = blkcipher_walk_virt_block(desc, &walk, CAST5_BLOCK_SIZE); | ||
357 | desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; | ||
358 | |||
359 | while ((nbytes = walk.nbytes) >= CAST5_BLOCK_SIZE) { | ||
360 | fpu_enabled = cast5_fpu_begin(fpu_enabled, nbytes); | ||
361 | nbytes = __ctr_crypt(desc, &walk); | ||
362 | err = blkcipher_walk_done(desc, &walk, nbytes); | ||
363 | } | ||
364 | |||
365 | cast5_fpu_end(fpu_enabled); | ||
366 | |||
367 | if (walk.nbytes) { | ||
368 | ctr_crypt_final(desc, &walk); | ||
369 | err = blkcipher_walk_done(desc, &walk, 0); | ||
370 | } | ||
371 | |||
372 | return err; | ||
373 | } | ||
374 | |||
375 | |||
376 | static struct crypto_alg cast5_algs[6] = { { | ||
377 | .cra_name = "__ecb-cast5-avx", | ||
378 | .cra_driver_name = "__driver-ecb-cast5-avx", | ||
379 | .cra_priority = 0, | ||
380 | .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, | ||
381 | .cra_blocksize = CAST5_BLOCK_SIZE, | ||
382 | .cra_ctxsize = sizeof(struct cast5_ctx), | ||
383 | .cra_alignmask = 0, | ||
384 | .cra_type = &crypto_blkcipher_type, | ||
385 | .cra_module = THIS_MODULE, | ||
386 | .cra_u = { | ||
387 | .blkcipher = { | ||
388 | .min_keysize = CAST5_MIN_KEY_SIZE, | ||
389 | .max_keysize = CAST5_MAX_KEY_SIZE, | ||
390 | .setkey = cast5_setkey, | ||
391 | .encrypt = ecb_encrypt, | ||
392 | .decrypt = ecb_decrypt, | ||
393 | }, | ||
394 | }, | ||
395 | }, { | ||
396 | .cra_name = "__cbc-cast5-avx", | ||
397 | .cra_driver_name = "__driver-cbc-cast5-avx", | ||
398 | .cra_priority = 0, | ||
399 | .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, | ||
400 | .cra_blocksize = CAST5_BLOCK_SIZE, | ||
401 | .cra_ctxsize = sizeof(struct cast5_ctx), | ||
402 | .cra_alignmask = 0, | ||
403 | .cra_type = &crypto_blkcipher_type, | ||
404 | .cra_module = THIS_MODULE, | ||
405 | .cra_u = { | ||
406 | .blkcipher = { | ||
407 | .min_keysize = CAST5_MIN_KEY_SIZE, | ||
408 | .max_keysize = CAST5_MAX_KEY_SIZE, | ||
409 | .setkey = cast5_setkey, | ||
410 | .encrypt = cbc_encrypt, | ||
411 | .decrypt = cbc_decrypt, | ||
412 | }, | ||
413 | }, | ||
414 | }, { | ||
415 | .cra_name = "__ctr-cast5-avx", | ||
416 | .cra_driver_name = "__driver-ctr-cast5-avx", | ||
417 | .cra_priority = 0, | ||
418 | .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, | ||
419 | .cra_blocksize = 1, | ||
420 | .cra_ctxsize = sizeof(struct cast5_ctx), | ||
421 | .cra_alignmask = 0, | ||
422 | .cra_type = &crypto_blkcipher_type, | ||
423 | .cra_module = THIS_MODULE, | ||
424 | .cra_u = { | ||
425 | .blkcipher = { | ||
426 | .min_keysize = CAST5_MIN_KEY_SIZE, | ||
427 | .max_keysize = CAST5_MAX_KEY_SIZE, | ||
428 | .ivsize = CAST5_BLOCK_SIZE, | ||
429 | .setkey = cast5_setkey, | ||
430 | .encrypt = ctr_crypt, | ||
431 | .decrypt = ctr_crypt, | ||
432 | }, | ||
433 | }, | ||
434 | }, { | ||
435 | .cra_name = "ecb(cast5)", | ||
436 | .cra_driver_name = "ecb-cast5-avx", | ||
437 | .cra_priority = 200, | ||
438 | .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, | ||
439 | .cra_blocksize = CAST5_BLOCK_SIZE, | ||
440 | .cra_ctxsize = sizeof(struct async_helper_ctx), | ||
441 | .cra_alignmask = 0, | ||
442 | .cra_type = &crypto_ablkcipher_type, | ||
443 | .cra_module = THIS_MODULE, | ||
444 | .cra_init = ablk_init, | ||
445 | .cra_exit = ablk_exit, | ||
446 | .cra_u = { | ||
447 | .ablkcipher = { | ||
448 | .min_keysize = CAST5_MIN_KEY_SIZE, | ||
449 | .max_keysize = CAST5_MAX_KEY_SIZE, | ||
450 | .setkey = ablk_set_key, | ||
451 | .encrypt = ablk_encrypt, | ||
452 | .decrypt = ablk_decrypt, | ||
453 | }, | ||
454 | }, | ||
455 | }, { | ||
456 | .cra_name = "cbc(cast5)", | ||
457 | .cra_driver_name = "cbc-cast5-avx", | ||
458 | .cra_priority = 200, | ||
459 | .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, | ||
460 | .cra_blocksize = CAST5_BLOCK_SIZE, | ||
461 | .cra_ctxsize = sizeof(struct async_helper_ctx), | ||
462 | .cra_alignmask = 0, | ||
463 | .cra_type = &crypto_ablkcipher_type, | ||
464 | .cra_module = THIS_MODULE, | ||
465 | .cra_init = ablk_init, | ||
466 | .cra_exit = ablk_exit, | ||
467 | .cra_u = { | ||
468 | .ablkcipher = { | ||
469 | .min_keysize = CAST5_MIN_KEY_SIZE, | ||
470 | .max_keysize = CAST5_MAX_KEY_SIZE, | ||
471 | .ivsize = CAST5_BLOCK_SIZE, | ||
472 | .setkey = ablk_set_key, | ||
473 | .encrypt = __ablk_encrypt, | ||
474 | .decrypt = ablk_decrypt, | ||
475 | }, | ||
476 | }, | ||
477 | }, { | ||
478 | .cra_name = "ctr(cast5)", | ||
479 | .cra_driver_name = "ctr-cast5-avx", | ||
480 | .cra_priority = 200, | ||
481 | .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, | ||
482 | .cra_blocksize = 1, | ||
483 | .cra_ctxsize = sizeof(struct async_helper_ctx), | ||
484 | .cra_alignmask = 0, | ||
485 | .cra_type = &crypto_ablkcipher_type, | ||
486 | .cra_module = THIS_MODULE, | ||
487 | .cra_init = ablk_init, | ||
488 | .cra_exit = ablk_exit, | ||
489 | .cra_u = { | ||
490 | .ablkcipher = { | ||
491 | .min_keysize = CAST5_MIN_KEY_SIZE, | ||
492 | .max_keysize = CAST5_MAX_KEY_SIZE, | ||
493 | .ivsize = CAST5_BLOCK_SIZE, | ||
494 | .setkey = ablk_set_key, | ||
495 | .encrypt = ablk_encrypt, | ||
496 | .decrypt = ablk_encrypt, | ||
497 | .geniv = "chainiv", | ||
498 | }, | ||
499 | }, | ||
500 | } }; | ||
501 | |||
502 | static int __init cast5_init(void) | ||
503 | { | ||
504 | u64 xcr0; | ||
505 | |||
506 | if (!cpu_has_avx || !cpu_has_osxsave) { | ||
507 | pr_info("AVX instructions are not detected.\n"); | ||
508 | return -ENODEV; | ||
509 | } | ||
510 | |||
511 | xcr0 = xgetbv(XCR_XFEATURE_ENABLED_MASK); | ||
512 | if ((xcr0 & (XSTATE_SSE | XSTATE_YMM)) != (XSTATE_SSE | XSTATE_YMM)) { | ||
513 | pr_info("AVX detected but unusable.\n"); | ||
514 | return -ENODEV; | ||
515 | } | ||
516 | |||
517 | return crypto_register_algs(cast5_algs, ARRAY_SIZE(cast5_algs)); | ||
518 | } | ||
519 | |||
520 | static void __exit cast5_exit(void) | ||
521 | { | ||
522 | crypto_unregister_algs(cast5_algs, ARRAY_SIZE(cast5_algs)); | ||
523 | } | ||
524 | |||
525 | module_init(cast5_init); | ||
526 | module_exit(cast5_exit); | ||
527 | |||
528 | MODULE_DESCRIPTION("Cast5 Cipher Algorithm, AVX optimized"); | ||
529 | MODULE_LICENSE("GPL"); | ||
530 | MODULE_ALIAS("cast5"); | ||
diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S new file mode 100644 index 000000000000..218d283772f4 --- /dev/null +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S | |||
@@ -0,0 +1,383 @@ | |||
1 | /* | ||
2 | * Cast6 Cipher 8-way parallel algorithm (AVX/x86_64) | ||
3 | * | ||
4 | * Copyright (C) 2012 Johannes Goetzfried | ||
5 | * <Johannes.Goetzfried@informatik.stud.uni-erlangen.de> | ||
6 | * | ||
7 | * Copyright © 2012 Jussi Kivilinna <jussi.kivilinna@mbnet.fi> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | ||
22 | * USA | ||
23 | * | ||
24 | */ | ||
25 | |||
26 | .file "cast6-avx-x86_64-asm_64.S" | ||
27 | |||
28 | .extern cast6_s1 | ||
29 | .extern cast6_s2 | ||
30 | .extern cast6_s3 | ||
31 | .extern cast6_s4 | ||
32 | |||
33 | /* structure of crypto context */ | ||
34 | #define km 0 | ||
35 | #define kr (12*4*4) | ||
36 | |||
37 | /* s-boxes */ | ||
38 | #define s1 cast6_s1 | ||
39 | #define s2 cast6_s2 | ||
40 | #define s3 cast6_s3 | ||
41 | #define s4 cast6_s4 | ||
42 | |||
43 | /********************************************************************** | ||
44 | 8-way AVX cast6 | ||
45 | **********************************************************************/ | ||
46 | #define CTX %rdi | ||
47 | |||
48 | #define RA1 %xmm0 | ||
49 | #define RB1 %xmm1 | ||
50 | #define RC1 %xmm2 | ||
51 | #define RD1 %xmm3 | ||
52 | |||
53 | #define RA2 %xmm4 | ||
54 | #define RB2 %xmm5 | ||
55 | #define RC2 %xmm6 | ||
56 | #define RD2 %xmm7 | ||
57 | |||
58 | #define RX %xmm8 | ||
59 | |||
60 | #define RKM %xmm9 | ||
61 | #define RKR %xmm10 | ||
62 | #define RKRF %xmm11 | ||
63 | #define RKRR %xmm12 | ||
64 | #define R32 %xmm13 | ||
65 | #define R1ST %xmm14 | ||
66 | |||
67 | #define RTMP %xmm15 | ||
68 | |||
69 | #define RID1 %rbp | ||
70 | #define RID1d %ebp | ||
71 | #define RID2 %rsi | ||
72 | #define RID2d %esi | ||
73 | |||
74 | #define RGI1 %rdx | ||
75 | #define RGI1bl %dl | ||
76 | #define RGI1bh %dh | ||
77 | #define RGI2 %rcx | ||
78 | #define RGI2bl %cl | ||
79 | #define RGI2bh %ch | ||
80 | |||
81 | #define RGI3 %rax | ||
82 | #define RGI3bl %al | ||
83 | #define RGI3bh %ah | ||
84 | #define RGI4 %rbx | ||
85 | #define RGI4bl %bl | ||
86 | #define RGI4bh %bh | ||
87 | |||
88 | #define RFS1 %r8 | ||
89 | #define RFS1d %r8d | ||
90 | #define RFS2 %r9 | ||
91 | #define RFS2d %r9d | ||
92 | #define RFS3 %r10 | ||
93 | #define RFS3d %r10d | ||
94 | |||
95 | |||
96 | #define lookup_32bit(src, dst, op1, op2, op3, interleave_op, il_reg) \ | ||
97 | movzbl src ## bh, RID1d; \ | ||
98 | movzbl src ## bl, RID2d; \ | ||
99 | shrq $16, src; \ | ||
100 | movl s1(, RID1, 4), dst ## d; \ | ||
101 | op1 s2(, RID2, 4), dst ## d; \ | ||
102 | movzbl src ## bh, RID1d; \ | ||
103 | movzbl src ## bl, RID2d; \ | ||
104 | interleave_op(il_reg); \ | ||
105 | op2 s3(, RID1, 4), dst ## d; \ | ||
106 | op3 s4(, RID2, 4), dst ## d; | ||
107 | |||
108 | #define dummy(d) /* do nothing */ | ||
109 | |||
110 | #define shr_next(reg) \ | ||
111 | shrq $16, reg; | ||
112 | |||
113 | #define F_head(a, x, gi1, gi2, op0) \ | ||
114 | op0 a, RKM, x; \ | ||
115 | vpslld RKRF, x, RTMP; \ | ||
116 | vpsrld RKRR, x, x; \ | ||
117 | vpor RTMP, x, x; \ | ||
118 | \ | ||
119 | vmovq x, gi1; \ | ||
120 | vpextrq $1, x, gi2; | ||
121 | |||
122 | #define F_tail(a, x, gi1, gi2, op1, op2, op3) \ | ||
123 | lookup_32bit(##gi1, RFS1, op1, op2, op3, shr_next, ##gi1); \ | ||
124 | lookup_32bit(##gi2, RFS3, op1, op2, op3, shr_next, ##gi2); \ | ||
125 | \ | ||
126 | lookup_32bit(##gi1, RFS2, op1, op2, op3, dummy, none); \ | ||
127 | shlq $32, RFS2; \ | ||
128 | orq RFS1, RFS2; \ | ||
129 | lookup_32bit(##gi2, RFS1, op1, op2, op3, dummy, none); \ | ||
130 | shlq $32, RFS1; \ | ||
131 | orq RFS1, RFS3; \ | ||
132 | \ | ||
133 | vmovq RFS2, x; \ | ||
134 | vpinsrq $1, RFS3, x, x; | ||
135 | |||
136 | #define F_2(a1, b1, a2, b2, op0, op1, op2, op3) \ | ||
137 | F_head(b1, RX, RGI1, RGI2, op0); \ | ||
138 | F_head(b2, RX, RGI3, RGI4, op0); \ | ||
139 | \ | ||
140 | F_tail(b1, RX, RGI1, RGI2, op1, op2, op3); \ | ||
141 | F_tail(b2, RTMP, RGI3, RGI4, op1, op2, op3); \ | ||
142 | \ | ||
143 | vpxor a1, RX, a1; \ | ||
144 | vpxor a2, RTMP, a2; | ||
145 | |||
146 | #define F1_2(a1, b1, a2, b2) \ | ||
147 | F_2(a1, b1, a2, b2, vpaddd, xorl, subl, addl) | ||
148 | #define F2_2(a1, b1, a2, b2) \ | ||
149 | F_2(a1, b1, a2, b2, vpxor, subl, addl, xorl) | ||
150 | #define F3_2(a1, b1, a2, b2) \ | ||
151 | F_2(a1, b1, a2, b2, vpsubd, addl, xorl, subl) | ||
152 | |||
153 | #define qop(in, out, f) \ | ||
154 | F ## f ## _2(out ## 1, in ## 1, out ## 2, in ## 2); | ||
155 | |||
156 | #define get_round_keys(nn) \ | ||
157 | vbroadcastss (km+(4*(nn)))(CTX), RKM; \ | ||
158 | vpand R1ST, RKR, RKRF; \ | ||
159 | vpsubq RKRF, R32, RKRR; \ | ||
160 | vpsrldq $1, RKR, RKR; | ||
161 | |||
162 | #define Q(n) \ | ||
163 | get_round_keys(4*n+0); \ | ||
164 | qop(RD, RC, 1); \ | ||
165 | \ | ||
166 | get_round_keys(4*n+1); \ | ||
167 | qop(RC, RB, 2); \ | ||
168 | \ | ||
169 | get_round_keys(4*n+2); \ | ||
170 | qop(RB, RA, 3); \ | ||
171 | \ | ||
172 | get_round_keys(4*n+3); \ | ||
173 | qop(RA, RD, 1); | ||
174 | |||
175 | #define QBAR(n) \ | ||
176 | get_round_keys(4*n+3); \ | ||
177 | qop(RA, RD, 1); \ | ||
178 | \ | ||
179 | get_round_keys(4*n+2); \ | ||
180 | qop(RB, RA, 3); \ | ||
181 | \ | ||
182 | get_round_keys(4*n+1); \ | ||
183 | qop(RC, RB, 2); \ | ||
184 | \ | ||
185 | get_round_keys(4*n+0); \ | ||
186 | qop(RD, RC, 1); | ||
187 | |||
188 | #define shuffle(mask) \ | ||
189 | vpshufb mask, RKR, RKR; | ||
190 | |||
191 | #define preload_rkr(n, do_mask, mask) \ | ||
192 | vbroadcastss .L16_mask, RKR; \ | ||
193 | /* add 16-bit rotation to key rotations (mod 32) */ \ | ||
194 | vpxor (kr+n*16)(CTX), RKR, RKR; \ | ||
195 | do_mask(mask); | ||
196 | |||
197 | #define transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \ | ||
198 | vpunpckldq x1, x0, t0; \ | ||
199 | vpunpckhdq x1, x0, t2; \ | ||
200 | vpunpckldq x3, x2, t1; \ | ||
201 | vpunpckhdq x3, x2, x3; \ | ||
202 | \ | ||
203 | vpunpcklqdq t1, t0, x0; \ | ||
204 | vpunpckhqdq t1, t0, x1; \ | ||
205 | vpunpcklqdq x3, t2, x2; \ | ||
206 | vpunpckhqdq x3, t2, x3; | ||
207 | |||
208 | #define inpack_blocks(in, x0, x1, x2, x3, t0, t1, t2, rmask) \ | ||
209 | vmovdqu (0*4*4)(in), x0; \ | ||
210 | vmovdqu (1*4*4)(in), x1; \ | ||
211 | vmovdqu (2*4*4)(in), x2; \ | ||
212 | vmovdqu (3*4*4)(in), x3; \ | ||
213 | vpshufb rmask, x0, x0; \ | ||
214 | vpshufb rmask, x1, x1; \ | ||
215 | vpshufb rmask, x2, x2; \ | ||
216 | vpshufb rmask, x3, x3; \ | ||
217 | \ | ||
218 | transpose_4x4(x0, x1, x2, x3, t0, t1, t2) | ||
219 | |||
220 | #define outunpack_blocks(out, x0, x1, x2, x3, t0, t1, t2, rmask) \ | ||
221 | transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \ | ||
222 | \ | ||
223 | vpshufb rmask, x0, x0; \ | ||
224 | vpshufb rmask, x1, x1; \ | ||
225 | vpshufb rmask, x2, x2; \ | ||
226 | vpshufb rmask, x3, x3; \ | ||
227 | vmovdqu x0, (0*4*4)(out); \ | ||
228 | vmovdqu x1, (1*4*4)(out); \ | ||
229 | vmovdqu x2, (2*4*4)(out); \ | ||
230 | vmovdqu x3, (3*4*4)(out); | ||
231 | |||
232 | #define outunpack_xor_blocks(out, x0, x1, x2, x3, t0, t1, t2, rmask) \ | ||
233 | transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \ | ||
234 | \ | ||
235 | vpshufb rmask, x0, x0; \ | ||
236 | vpshufb rmask, x1, x1; \ | ||
237 | vpshufb rmask, x2, x2; \ | ||
238 | vpshufb rmask, x3, x3; \ | ||
239 | vpxor (0*4*4)(out), x0, x0; \ | ||
240 | vmovdqu x0, (0*4*4)(out); \ | ||
241 | vpxor (1*4*4)(out), x1, x1; \ | ||
242 | vmovdqu x1, (1*4*4)(out); \ | ||
243 | vpxor (2*4*4)(out), x2, x2; \ | ||
244 | vmovdqu x2, (2*4*4)(out); \ | ||
245 | vpxor (3*4*4)(out), x3, x3; \ | ||
246 | vmovdqu x3, (3*4*4)(out); | ||
247 | |||
248 | .data | ||
249 | |||
250 | .align 16 | ||
251 | .Lbswap_mask: | ||
252 | .byte 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12 | ||
253 | .Lrkr_enc_Q_Q_QBAR_QBAR: | ||
254 | .byte 0, 1, 2, 3, 4, 5, 6, 7, 11, 10, 9, 8, 15, 14, 13, 12 | ||
255 | .Lrkr_enc_QBAR_QBAR_QBAR_QBAR: | ||
256 | .byte 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12 | ||
257 | .Lrkr_dec_Q_Q_Q_Q: | ||
258 | .byte 12, 13, 14, 15, 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3 | ||
259 | .Lrkr_dec_Q_Q_QBAR_QBAR: | ||
260 | .byte 12, 13, 14, 15, 8, 9, 10, 11, 7, 6, 5, 4, 3, 2, 1, 0 | ||
261 | .Lrkr_dec_QBAR_QBAR_QBAR_QBAR: | ||
262 | .byte 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 | ||
263 | .L16_mask: | ||
264 | .byte 16, 16, 16, 16 | ||
265 | .L32_mask: | ||
266 | .byte 32, 0, 0, 0 | ||
267 | .Lfirst_mask: | ||
268 | .byte 0x1f, 0, 0, 0 | ||
269 | |||
270 | .text | ||
271 | |||
272 | .align 16 | ||
273 | .global __cast6_enc_blk_8way | ||
274 | .type __cast6_enc_blk_8way,@function; | ||
275 | |||
276 | __cast6_enc_blk_8way: | ||
277 | /* input: | ||
278 | * %rdi: ctx, CTX | ||
279 | * %rsi: dst | ||
280 | * %rdx: src | ||
281 | * %rcx: bool, if true: xor output | ||
282 | */ | ||
283 | |||
284 | pushq %rbp; | ||
285 | pushq %rbx; | ||
286 | pushq %rcx; | ||
287 | |||
288 | vmovdqa .Lbswap_mask, RKM; | ||
289 | vmovd .Lfirst_mask, R1ST; | ||
290 | vmovd .L32_mask, R32; | ||
291 | |||
292 | leaq (4*4*4)(%rdx), %rax; | ||
293 | inpack_blocks(%rdx, RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM); | ||
294 | inpack_blocks(%rax, RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM); | ||
295 | |||
296 | movq %rsi, %r11; | ||
297 | |||
298 | preload_rkr(0, dummy, none); | ||
299 | Q(0); | ||
300 | Q(1); | ||
301 | Q(2); | ||
302 | Q(3); | ||
303 | preload_rkr(1, shuffle, .Lrkr_enc_Q_Q_QBAR_QBAR); | ||
304 | Q(4); | ||
305 | Q(5); | ||
306 | QBAR(6); | ||
307 | QBAR(7); | ||
308 | preload_rkr(2, shuffle, .Lrkr_enc_QBAR_QBAR_QBAR_QBAR); | ||
309 | QBAR(8); | ||
310 | QBAR(9); | ||
311 | QBAR(10); | ||
312 | QBAR(11); | ||
313 | |||
314 | popq %rcx; | ||
315 | popq %rbx; | ||
316 | popq %rbp; | ||
317 | |||
318 | vmovdqa .Lbswap_mask, RKM; | ||
319 | leaq (4*4*4)(%r11), %rax; | ||
320 | |||
321 | testb %cl, %cl; | ||
322 | jnz __enc_xor8; | ||
323 | |||
324 | outunpack_blocks(%r11, RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM); | ||
325 | outunpack_blocks(%rax, RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM); | ||
326 | |||
327 | ret; | ||
328 | |||
329 | __enc_xor8: | ||
330 | outunpack_xor_blocks(%r11, RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM); | ||
331 | outunpack_xor_blocks(%rax, RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM); | ||
332 | |||
333 | ret; | ||
334 | |||
335 | .align 16 | ||
336 | .global cast6_dec_blk_8way | ||
337 | .type cast6_dec_blk_8way,@function; | ||
338 | |||
339 | cast6_dec_blk_8way: | ||
340 | /* input: | ||
341 | * %rdi: ctx, CTX | ||
342 | * %rsi: dst | ||
343 | * %rdx: src | ||
344 | */ | ||
345 | |||
346 | pushq %rbp; | ||
347 | pushq %rbx; | ||
348 | |||
349 | vmovdqa .Lbswap_mask, RKM; | ||
350 | vmovd .Lfirst_mask, R1ST; | ||
351 | vmovd .L32_mask, R32; | ||
352 | |||
353 | leaq (4*4*4)(%rdx), %rax; | ||
354 | inpack_blocks(%rdx, RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM); | ||
355 | inpack_blocks(%rax, RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM); | ||
356 | |||
357 | movq %rsi, %r11; | ||
358 | |||
359 | preload_rkr(2, shuffle, .Lrkr_dec_Q_Q_Q_Q); | ||
360 | Q(11); | ||
361 | Q(10); | ||
362 | Q(9); | ||
363 | Q(8); | ||
364 | preload_rkr(1, shuffle, .Lrkr_dec_Q_Q_QBAR_QBAR); | ||
365 | Q(7); | ||
366 | Q(6); | ||
367 | QBAR(5); | ||
368 | QBAR(4); | ||
369 | preload_rkr(0, shuffle, .Lrkr_dec_QBAR_QBAR_QBAR_QBAR); | ||
370 | QBAR(3); | ||
371 | QBAR(2); | ||
372 | QBAR(1); | ||
373 | QBAR(0); | ||
374 | |||
375 | popq %rbx; | ||
376 | popq %rbp; | ||
377 | |||
378 | vmovdqa .Lbswap_mask, RKM; | ||
379 | leaq (4*4*4)(%r11), %rax; | ||
380 | outunpack_blocks(%r11, RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM); | ||
381 | outunpack_blocks(%rax, RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM); | ||
382 | |||
383 | ret; | ||
diff --git a/arch/x86/crypto/cast6_avx_glue.c b/arch/x86/crypto/cast6_avx_glue.c new file mode 100644 index 000000000000..15e5f85a5011 --- /dev/null +++ b/arch/x86/crypto/cast6_avx_glue.c | |||
@@ -0,0 +1,648 @@ | |||
1 | /* | ||
2 | * Glue Code for the AVX assembler implemention of the Cast6 Cipher | ||
3 | * | ||
4 | * Copyright (C) 2012 Johannes Goetzfried | ||
5 | * <Johannes.Goetzfried@informatik.stud.uni-erlangen.de> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | ||
20 | * USA | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #include <linux/module.h> | ||
25 | #include <linux/hardirq.h> | ||
26 | #include <linux/types.h> | ||
27 | #include <linux/crypto.h> | ||
28 | #include <linux/err.h> | ||
29 | #include <crypto/algapi.h> | ||
30 | #include <crypto/cast6.h> | ||
31 | #include <crypto/cryptd.h> | ||
32 | #include <crypto/b128ops.h> | ||
33 | #include <crypto/ctr.h> | ||
34 | #include <crypto/lrw.h> | ||
35 | #include <crypto/xts.h> | ||
36 | #include <asm/xcr.h> | ||
37 | #include <asm/xsave.h> | ||
38 | #include <asm/crypto/ablk_helper.h> | ||
39 | #include <asm/crypto/glue_helper.h> | ||
40 | |||
41 | #define CAST6_PARALLEL_BLOCKS 8 | ||
42 | |||
43 | asmlinkage void __cast6_enc_blk_8way(struct cast6_ctx *ctx, u8 *dst, | ||
44 | const u8 *src, bool xor); | ||
45 | asmlinkage void cast6_dec_blk_8way(struct cast6_ctx *ctx, u8 *dst, | ||
46 | const u8 *src); | ||
47 | |||
48 | static inline void cast6_enc_blk_xway(struct cast6_ctx *ctx, u8 *dst, | ||
49 | const u8 *src) | ||
50 | { | ||
51 | __cast6_enc_blk_8way(ctx, dst, src, false); | ||
52 | } | ||
53 | |||
54 | static inline void cast6_enc_blk_xway_xor(struct cast6_ctx *ctx, u8 *dst, | ||
55 | const u8 *src) | ||
56 | { | ||
57 | __cast6_enc_blk_8way(ctx, dst, src, true); | ||
58 | } | ||
59 | |||
60 | static inline void cast6_dec_blk_xway(struct cast6_ctx *ctx, u8 *dst, | ||
61 | const u8 *src) | ||
62 | { | ||
63 | cast6_dec_blk_8way(ctx, dst, src); | ||
64 | } | ||
65 | |||
66 | |||
67 | static void cast6_decrypt_cbc_xway(void *ctx, u128 *dst, const u128 *src) | ||
68 | { | ||
69 | u128 ivs[CAST6_PARALLEL_BLOCKS - 1]; | ||
70 | unsigned int j; | ||
71 | |||
72 | for (j = 0; j < CAST6_PARALLEL_BLOCKS - 1; j++) | ||
73 | ivs[j] = src[j]; | ||
74 | |||
75 | cast6_dec_blk_xway(ctx, (u8 *)dst, (u8 *)src); | ||
76 | |||
77 | for (j = 0; j < CAST6_PARALLEL_BLOCKS - 1; j++) | ||
78 | u128_xor(dst + (j + 1), dst + (j + 1), ivs + j); | ||
79 | } | ||
80 | |||
81 | static void cast6_crypt_ctr(void *ctx, u128 *dst, const u128 *src, u128 *iv) | ||
82 | { | ||
83 | be128 ctrblk; | ||
84 | |||
85 | u128_to_be128(&ctrblk, iv); | ||
86 | u128_inc(iv); | ||
87 | |||
88 | __cast6_encrypt(ctx, (u8 *)&ctrblk, (u8 *)&ctrblk); | ||
89 | u128_xor(dst, src, (u128 *)&ctrblk); | ||
90 | } | ||
91 | |||
92 | static void cast6_crypt_ctr_xway(void *ctx, u128 *dst, const u128 *src, | ||
93 | u128 *iv) | ||
94 | { | ||
95 | be128 ctrblks[CAST6_PARALLEL_BLOCKS]; | ||
96 | unsigned int i; | ||
97 | |||
98 | for (i = 0; i < CAST6_PARALLEL_BLOCKS; i++) { | ||
99 | if (dst != src) | ||
100 | dst[i] = src[i]; | ||
101 | |||
102 | u128_to_be128(&ctrblks[i], iv); | ||
103 | u128_inc(iv); | ||
104 | } | ||
105 | |||
106 | cast6_enc_blk_xway_xor(ctx, (u8 *)dst, (u8 *)ctrblks); | ||
107 | } | ||
108 | |||
109 | static const struct common_glue_ctx cast6_enc = { | ||
110 | .num_funcs = 2, | ||
111 | .fpu_blocks_limit = CAST6_PARALLEL_BLOCKS, | ||
112 | |||
113 | .funcs = { { | ||
114 | .num_blocks = CAST6_PARALLEL_BLOCKS, | ||
115 | .fn_u = { .ecb = GLUE_FUNC_CAST(cast6_enc_blk_xway) } | ||
116 | }, { | ||
117 | .num_blocks = 1, | ||
118 | .fn_u = { .ecb = GLUE_FUNC_CAST(__cast6_encrypt) } | ||
119 | } } | ||
120 | }; | ||
121 | |||
122 | static const struct common_glue_ctx cast6_ctr = { | ||
123 | .num_funcs = 2, | ||
124 | .fpu_blocks_limit = CAST6_PARALLEL_BLOCKS, | ||
125 | |||
126 | .funcs = { { | ||
127 | .num_blocks = CAST6_PARALLEL_BLOCKS, | ||
128 | .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(cast6_crypt_ctr_xway) } | ||
129 | }, { | ||
130 | .num_blocks = 1, | ||
131 | .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(cast6_crypt_ctr) } | ||
132 | } } | ||
133 | }; | ||
134 | |||
135 | static const struct common_glue_ctx cast6_dec = { | ||
136 | .num_funcs = 2, | ||
137 | .fpu_blocks_limit = CAST6_PARALLEL_BLOCKS, | ||
138 | |||
139 | .funcs = { { | ||
140 | .num_blocks = CAST6_PARALLEL_BLOCKS, | ||
141 | .fn_u = { .ecb = GLUE_FUNC_CAST(cast6_dec_blk_xway) } | ||
142 | }, { | ||
143 | .num_blocks = 1, | ||
144 | .fn_u = { .ecb = GLUE_FUNC_CAST(__cast6_decrypt) } | ||
145 | } } | ||
146 | }; | ||
147 | |||
148 | static const struct common_glue_ctx cast6_dec_cbc = { | ||
149 | .num_funcs = 2, | ||
150 | .fpu_blocks_limit = CAST6_PARALLEL_BLOCKS, | ||
151 | |||
152 | .funcs = { { | ||
153 | .num_blocks = CAST6_PARALLEL_BLOCKS, | ||
154 | .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(cast6_decrypt_cbc_xway) } | ||
155 | }, { | ||
156 | .num_blocks = 1, | ||
157 | .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(__cast6_decrypt) } | ||
158 | } } | ||
159 | }; | ||
160 | |||
161 | static int ecb_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, | ||
162 | struct scatterlist *src, unsigned int nbytes) | ||
163 | { | ||
164 | return glue_ecb_crypt_128bit(&cast6_enc, desc, dst, src, nbytes); | ||
165 | } | ||
166 | |||
167 | static int ecb_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, | ||
168 | struct scatterlist *src, unsigned int nbytes) | ||
169 | { | ||
170 | return glue_ecb_crypt_128bit(&cast6_dec, desc, dst, src, nbytes); | ||
171 | } | ||
172 | |||
173 | static int cbc_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, | ||
174 | struct scatterlist *src, unsigned int nbytes) | ||
175 | { | ||
176 | return glue_cbc_encrypt_128bit(GLUE_FUNC_CAST(__cast6_encrypt), desc, | ||
177 | dst, src, nbytes); | ||
178 | } | ||
179 | |||
180 | static int cbc_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, | ||
181 | struct scatterlist *src, unsigned int nbytes) | ||
182 | { | ||
183 | return glue_cbc_decrypt_128bit(&cast6_dec_cbc, desc, dst, src, | ||
184 | nbytes); | ||
185 | } | ||
186 | |||
187 | static int ctr_crypt(struct blkcipher_desc *desc, struct scatterlist *dst, | ||
188 | struct scatterlist *src, unsigned int nbytes) | ||
189 | { | ||
190 | return glue_ctr_crypt_128bit(&cast6_ctr, desc, dst, src, nbytes); | ||
191 | } | ||
192 | |||
193 | static inline bool cast6_fpu_begin(bool fpu_enabled, unsigned int nbytes) | ||
194 | { | ||
195 | return glue_fpu_begin(CAST6_BLOCK_SIZE, CAST6_PARALLEL_BLOCKS, | ||
196 | NULL, fpu_enabled, nbytes); | ||
197 | } | ||
198 | |||
199 | static inline void cast6_fpu_end(bool fpu_enabled) | ||
200 | { | ||
201 | glue_fpu_end(fpu_enabled); | ||
202 | } | ||
203 | |||
204 | struct crypt_priv { | ||
205 | struct cast6_ctx *ctx; | ||
206 | bool fpu_enabled; | ||
207 | }; | ||
208 | |||
209 | static void encrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes) | ||
210 | { | ||
211 | const unsigned int bsize = CAST6_BLOCK_SIZE; | ||
212 | struct crypt_priv *ctx = priv; | ||
213 | int i; | ||
214 | |||
215 | ctx->fpu_enabled = cast6_fpu_begin(ctx->fpu_enabled, nbytes); | ||
216 | |||
217 | if (nbytes == bsize * CAST6_PARALLEL_BLOCKS) { | ||
218 | cast6_enc_blk_xway(ctx->ctx, srcdst, srcdst); | ||
219 | return; | ||
220 | } | ||
221 | |||
222 | for (i = 0; i < nbytes / bsize; i++, srcdst += bsize) | ||
223 | __cast6_encrypt(ctx->ctx, srcdst, srcdst); | ||
224 | } | ||
225 | |||
226 | static void decrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes) | ||
227 | { | ||
228 | const unsigned int bsize = CAST6_BLOCK_SIZE; | ||
229 | struct crypt_priv *ctx = priv; | ||
230 | int i; | ||
231 | |||
232 | ctx->fpu_enabled = cast6_fpu_begin(ctx->fpu_enabled, nbytes); | ||
233 | |||
234 | if (nbytes == bsize * CAST6_PARALLEL_BLOCKS) { | ||
235 | cast6_dec_blk_xway(ctx->ctx, srcdst, srcdst); | ||
236 | return; | ||
237 | } | ||
238 | |||
239 | for (i = 0; i < nbytes / bsize; i++, srcdst += bsize) | ||
240 | __cast6_decrypt(ctx->ctx, srcdst, srcdst); | ||
241 | } | ||
242 | |||
243 | struct cast6_lrw_ctx { | ||
244 | struct lrw_table_ctx lrw_table; | ||
245 | struct cast6_ctx cast6_ctx; | ||
246 | }; | ||
247 | |||
248 | static int lrw_cast6_setkey(struct crypto_tfm *tfm, const u8 *key, | ||
249 | unsigned int keylen) | ||
250 | { | ||
251 | struct cast6_lrw_ctx *ctx = crypto_tfm_ctx(tfm); | ||
252 | int err; | ||
253 | |||
254 | err = __cast6_setkey(&ctx->cast6_ctx, key, keylen - CAST6_BLOCK_SIZE, | ||
255 | &tfm->crt_flags); | ||
256 | if (err) | ||
257 | return err; | ||
258 | |||
259 | return lrw_init_table(&ctx->lrw_table, key + keylen - CAST6_BLOCK_SIZE); | ||
260 | } | ||
261 | |||
262 | static int lrw_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, | ||
263 | struct scatterlist *src, unsigned int nbytes) | ||
264 | { | ||
265 | struct cast6_lrw_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); | ||
266 | be128 buf[CAST6_PARALLEL_BLOCKS]; | ||
267 | struct crypt_priv crypt_ctx = { | ||
268 | .ctx = &ctx->cast6_ctx, | ||
269 | .fpu_enabled = false, | ||
270 | }; | ||
271 | struct lrw_crypt_req req = { | ||
272 | .tbuf = buf, | ||
273 | .tbuflen = sizeof(buf), | ||
274 | |||
275 | .table_ctx = &ctx->lrw_table, | ||
276 | .crypt_ctx = &crypt_ctx, | ||
277 | .crypt_fn = encrypt_callback, | ||
278 | }; | ||
279 | int ret; | ||
280 | |||
281 | desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; | ||
282 | ret = lrw_crypt(desc, dst, src, nbytes, &req); | ||
283 | cast6_fpu_end(crypt_ctx.fpu_enabled); | ||
284 | |||
285 | return ret; | ||
286 | } | ||
287 | |||
288 | static int lrw_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, | ||
289 | struct scatterlist *src, unsigned int nbytes) | ||
290 | { | ||
291 | struct cast6_lrw_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); | ||
292 | be128 buf[CAST6_PARALLEL_BLOCKS]; | ||
293 | struct crypt_priv crypt_ctx = { | ||
294 | .ctx = &ctx->cast6_ctx, | ||
295 | .fpu_enabled = false, | ||
296 | }; | ||
297 | struct lrw_crypt_req req = { | ||
298 | .tbuf = buf, | ||
299 | .tbuflen = sizeof(buf), | ||
300 | |||
301 | .table_ctx = &ctx->lrw_table, | ||
302 | .crypt_ctx = &crypt_ctx, | ||
303 | .crypt_fn = decrypt_callback, | ||
304 | }; | ||
305 | int ret; | ||
306 | |||
307 | desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; | ||
308 | ret = lrw_crypt(desc, dst, src, nbytes, &req); | ||
309 | cast6_fpu_end(crypt_ctx.fpu_enabled); | ||
310 | |||
311 | return ret; | ||
312 | } | ||
313 | |||
314 | static void lrw_exit_tfm(struct crypto_tfm *tfm) | ||
315 | { | ||
316 | struct cast6_lrw_ctx *ctx = crypto_tfm_ctx(tfm); | ||
317 | |||
318 | lrw_free_table(&ctx->lrw_table); | ||
319 | } | ||
320 | |||
321 | struct cast6_xts_ctx { | ||
322 | struct cast6_ctx tweak_ctx; | ||
323 | struct cast6_ctx crypt_ctx; | ||
324 | }; | ||
325 | |||
326 | static int xts_cast6_setkey(struct crypto_tfm *tfm, const u8 *key, | ||
327 | unsigned int keylen) | ||
328 | { | ||
329 | struct cast6_xts_ctx *ctx = crypto_tfm_ctx(tfm); | ||
330 | u32 *flags = &tfm->crt_flags; | ||
331 | int err; | ||
332 | |||
333 | /* key consists of keys of equal size concatenated, therefore | ||
334 | * the length must be even | ||
335 | */ | ||
336 | if (keylen % 2) { | ||
337 | *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; | ||
338 | return -EINVAL; | ||
339 | } | ||
340 | |||
341 | /* first half of xts-key is for crypt */ | ||
342 | err = __cast6_setkey(&ctx->crypt_ctx, key, keylen / 2, flags); | ||
343 | if (err) | ||
344 | return err; | ||
345 | |||
346 | /* second half of xts-key is for tweak */ | ||
347 | return __cast6_setkey(&ctx->tweak_ctx, key + keylen / 2, keylen / 2, | ||
348 | flags); | ||
349 | } | ||
350 | |||
351 | static int xts_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, | ||
352 | struct scatterlist *src, unsigned int nbytes) | ||
353 | { | ||
354 | struct cast6_xts_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); | ||
355 | be128 buf[CAST6_PARALLEL_BLOCKS]; | ||
356 | struct crypt_priv crypt_ctx = { | ||
357 | .ctx = &ctx->crypt_ctx, | ||
358 | .fpu_enabled = false, | ||
359 | }; | ||
360 | struct xts_crypt_req req = { | ||
361 | .tbuf = buf, | ||
362 | .tbuflen = sizeof(buf), | ||
363 | |||
364 | .tweak_ctx = &ctx->tweak_ctx, | ||
365 | .tweak_fn = XTS_TWEAK_CAST(__cast6_encrypt), | ||
366 | .crypt_ctx = &crypt_ctx, | ||
367 | .crypt_fn = encrypt_callback, | ||
368 | }; | ||
369 | int ret; | ||
370 | |||
371 | desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; | ||
372 | ret = xts_crypt(desc, dst, src, nbytes, &req); | ||
373 | cast6_fpu_end(crypt_ctx.fpu_enabled); | ||
374 | |||
375 | return ret; | ||
376 | } | ||
377 | |||
378 | static int xts_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, | ||
379 | struct scatterlist *src, unsigned int nbytes) | ||
380 | { | ||
381 | struct cast6_xts_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); | ||
382 | be128 buf[CAST6_PARALLEL_BLOCKS]; | ||
383 | struct crypt_priv crypt_ctx = { | ||
384 | .ctx = &ctx->crypt_ctx, | ||
385 | .fpu_enabled = false, | ||
386 | }; | ||
387 | struct xts_crypt_req req = { | ||
388 | .tbuf = buf, | ||
389 | .tbuflen = sizeof(buf), | ||
390 | |||
391 | .tweak_ctx = &ctx->tweak_ctx, | ||
392 | .tweak_fn = XTS_TWEAK_CAST(__cast6_encrypt), | ||
393 | .crypt_ctx = &crypt_ctx, | ||
394 | .crypt_fn = decrypt_callback, | ||
395 | }; | ||
396 | int ret; | ||
397 | |||
398 | desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; | ||
399 | ret = xts_crypt(desc, dst, src, nbytes, &req); | ||
400 | cast6_fpu_end(crypt_ctx.fpu_enabled); | ||
401 | |||
402 | return ret; | ||
403 | } | ||
404 | |||
405 | static struct crypto_alg cast6_algs[10] = { { | ||
406 | .cra_name = "__ecb-cast6-avx", | ||
407 | .cra_driver_name = "__driver-ecb-cast6-avx", | ||
408 | .cra_priority = 0, | ||
409 | .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, | ||
410 | .cra_blocksize = CAST6_BLOCK_SIZE, | ||
411 | .cra_ctxsize = sizeof(struct cast6_ctx), | ||
412 | .cra_alignmask = 0, | ||
413 | .cra_type = &crypto_blkcipher_type, | ||
414 | .cra_module = THIS_MODULE, | ||
415 | .cra_u = { | ||
416 | .blkcipher = { | ||
417 | .min_keysize = CAST6_MIN_KEY_SIZE, | ||
418 | .max_keysize = CAST6_MAX_KEY_SIZE, | ||
419 | .setkey = cast6_setkey, | ||
420 | .encrypt = ecb_encrypt, | ||
421 | .decrypt = ecb_decrypt, | ||
422 | }, | ||
423 | }, | ||
424 | }, { | ||
425 | .cra_name = "__cbc-cast6-avx", | ||
426 | .cra_driver_name = "__driver-cbc-cast6-avx", | ||
427 | .cra_priority = 0, | ||
428 | .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, | ||
429 | .cra_blocksize = CAST6_BLOCK_SIZE, | ||
430 | .cra_ctxsize = sizeof(struct cast6_ctx), | ||
431 | .cra_alignmask = 0, | ||
432 | .cra_type = &crypto_blkcipher_type, | ||
433 | .cra_module = THIS_MODULE, | ||
434 | .cra_u = { | ||
435 | .blkcipher = { | ||
436 | .min_keysize = CAST6_MIN_KEY_SIZE, | ||
437 | .max_keysize = CAST6_MAX_KEY_SIZE, | ||
438 | .setkey = cast6_setkey, | ||
439 | .encrypt = cbc_encrypt, | ||
440 | .decrypt = cbc_decrypt, | ||
441 | }, | ||
442 | }, | ||
443 | }, { | ||
444 | .cra_name = "__ctr-cast6-avx", | ||
445 | .cra_driver_name = "__driver-ctr-cast6-avx", | ||
446 | .cra_priority = 0, | ||
447 | .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, | ||
448 | .cra_blocksize = 1, | ||
449 | .cra_ctxsize = sizeof(struct cast6_ctx), | ||
450 | .cra_alignmask = 0, | ||
451 | .cra_type = &crypto_blkcipher_type, | ||
452 | .cra_module = THIS_MODULE, | ||
453 | .cra_u = { | ||
454 | .blkcipher = { | ||
455 | .min_keysize = CAST6_MIN_KEY_SIZE, | ||
456 | .max_keysize = CAST6_MAX_KEY_SIZE, | ||
457 | .ivsize = CAST6_BLOCK_SIZE, | ||
458 | .setkey = cast6_setkey, | ||
459 | .encrypt = ctr_crypt, | ||
460 | .decrypt = ctr_crypt, | ||
461 | }, | ||
462 | }, | ||
463 | }, { | ||
464 | .cra_name = "__lrw-cast6-avx", | ||
465 | .cra_driver_name = "__driver-lrw-cast6-avx", | ||
466 | .cra_priority = 0, | ||
467 | .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, | ||
468 | .cra_blocksize = CAST6_BLOCK_SIZE, | ||
469 | .cra_ctxsize = sizeof(struct cast6_lrw_ctx), | ||
470 | .cra_alignmask = 0, | ||
471 | .cra_type = &crypto_blkcipher_type, | ||
472 | .cra_module = THIS_MODULE, | ||
473 | .cra_exit = lrw_exit_tfm, | ||
474 | .cra_u = { | ||
475 | .blkcipher = { | ||
476 | .min_keysize = CAST6_MIN_KEY_SIZE + | ||
477 | CAST6_BLOCK_SIZE, | ||
478 | .max_keysize = CAST6_MAX_KEY_SIZE + | ||
479 | CAST6_BLOCK_SIZE, | ||
480 | .ivsize = CAST6_BLOCK_SIZE, | ||
481 | .setkey = lrw_cast6_setkey, | ||
482 | .encrypt = lrw_encrypt, | ||
483 | .decrypt = lrw_decrypt, | ||
484 | }, | ||
485 | }, | ||
486 | }, { | ||
487 | .cra_name = "__xts-cast6-avx", | ||
488 | .cra_driver_name = "__driver-xts-cast6-avx", | ||
489 | .cra_priority = 0, | ||
490 | .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, | ||
491 | .cra_blocksize = CAST6_BLOCK_SIZE, | ||
492 | .cra_ctxsize = sizeof(struct cast6_xts_ctx), | ||
493 | .cra_alignmask = 0, | ||
494 | .cra_type = &crypto_blkcipher_type, | ||
495 | .cra_module = THIS_MODULE, | ||
496 | .cra_u = { | ||
497 | .blkcipher = { | ||
498 | .min_keysize = CAST6_MIN_KEY_SIZE * 2, | ||
499 | .max_keysize = CAST6_MAX_KEY_SIZE * 2, | ||
500 | .ivsize = CAST6_BLOCK_SIZE, | ||
501 | .setkey = xts_cast6_setkey, | ||
502 | .encrypt = xts_encrypt, | ||
503 | .decrypt = xts_decrypt, | ||
504 | }, | ||
505 | }, | ||
506 | }, { | ||
507 | .cra_name = "ecb(cast6)", | ||
508 | .cra_driver_name = "ecb-cast6-avx", | ||
509 | .cra_priority = 200, | ||
510 | .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, | ||
511 | .cra_blocksize = CAST6_BLOCK_SIZE, | ||
512 | .cra_ctxsize = sizeof(struct async_helper_ctx), | ||
513 | .cra_alignmask = 0, | ||
514 | .cra_type = &crypto_ablkcipher_type, | ||
515 | .cra_module = THIS_MODULE, | ||
516 | .cra_init = ablk_init, | ||
517 | .cra_exit = ablk_exit, | ||
518 | .cra_u = { | ||
519 | .ablkcipher = { | ||
520 | .min_keysize = CAST6_MIN_KEY_SIZE, | ||
521 | .max_keysize = CAST6_MAX_KEY_SIZE, | ||
522 | .setkey = ablk_set_key, | ||
523 | .encrypt = ablk_encrypt, | ||
524 | .decrypt = ablk_decrypt, | ||
525 | }, | ||
526 | }, | ||
527 | }, { | ||
528 | .cra_name = "cbc(cast6)", | ||
529 | .cra_driver_name = "cbc-cast6-avx", | ||
530 | .cra_priority = 200, | ||
531 | .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, | ||
532 | .cra_blocksize = CAST6_BLOCK_SIZE, | ||
533 | .cra_ctxsize = sizeof(struct async_helper_ctx), | ||
534 | .cra_alignmask = 0, | ||
535 | .cra_type = &crypto_ablkcipher_type, | ||
536 | .cra_module = THIS_MODULE, | ||
537 | .cra_init = ablk_init, | ||
538 | .cra_exit = ablk_exit, | ||
539 | .cra_u = { | ||
540 | .ablkcipher = { | ||
541 | .min_keysize = CAST6_MIN_KEY_SIZE, | ||
542 | .max_keysize = CAST6_MAX_KEY_SIZE, | ||
543 | .ivsize = CAST6_BLOCK_SIZE, | ||
544 | .setkey = ablk_set_key, | ||
545 | .encrypt = __ablk_encrypt, | ||
546 | .decrypt = ablk_decrypt, | ||
547 | }, | ||
548 | }, | ||
549 | }, { | ||
550 | .cra_name = "ctr(cast6)", | ||
551 | .cra_driver_name = "ctr-cast6-avx", | ||
552 | .cra_priority = 200, | ||
553 | .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, | ||
554 | .cra_blocksize = 1, | ||
555 | .cra_ctxsize = sizeof(struct async_helper_ctx), | ||
556 | .cra_alignmask = 0, | ||
557 | .cra_type = &crypto_ablkcipher_type, | ||
558 | .cra_module = THIS_MODULE, | ||
559 | .cra_init = ablk_init, | ||
560 | .cra_exit = ablk_exit, | ||
561 | .cra_u = { | ||
562 | .ablkcipher = { | ||
563 | .min_keysize = CAST6_MIN_KEY_SIZE, | ||
564 | .max_keysize = CAST6_MAX_KEY_SIZE, | ||
565 | .ivsize = CAST6_BLOCK_SIZE, | ||
566 | .setkey = ablk_set_key, | ||
567 | .encrypt = ablk_encrypt, | ||
568 | .decrypt = ablk_encrypt, | ||
569 | .geniv = "chainiv", | ||
570 | }, | ||
571 | }, | ||
572 | }, { | ||
573 | .cra_name = "lrw(cast6)", | ||
574 | .cra_driver_name = "lrw-cast6-avx", | ||
575 | .cra_priority = 200, | ||
576 | .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, | ||
577 | .cra_blocksize = CAST6_BLOCK_SIZE, | ||
578 | .cra_ctxsize = sizeof(struct async_helper_ctx), | ||
579 | .cra_alignmask = 0, | ||
580 | .cra_type = &crypto_ablkcipher_type, | ||
581 | .cra_module = THIS_MODULE, | ||
582 | .cra_init = ablk_init, | ||
583 | .cra_exit = ablk_exit, | ||
584 | .cra_u = { | ||
585 | .ablkcipher = { | ||
586 | .min_keysize = CAST6_MIN_KEY_SIZE + | ||
587 | CAST6_BLOCK_SIZE, | ||
588 | .max_keysize = CAST6_MAX_KEY_SIZE + | ||
589 | CAST6_BLOCK_SIZE, | ||
590 | .ivsize = CAST6_BLOCK_SIZE, | ||
591 | .setkey = ablk_set_key, | ||
592 | .encrypt = ablk_encrypt, | ||
593 | .decrypt = ablk_decrypt, | ||
594 | }, | ||
595 | }, | ||
596 | }, { | ||
597 | .cra_name = "xts(cast6)", | ||
598 | .cra_driver_name = "xts-cast6-avx", | ||
599 | .cra_priority = 200, | ||
600 | .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, | ||
601 | .cra_blocksize = CAST6_BLOCK_SIZE, | ||
602 | .cra_ctxsize = sizeof(struct async_helper_ctx), | ||
603 | .cra_alignmask = 0, | ||
604 | .cra_type = &crypto_ablkcipher_type, | ||
605 | .cra_module = THIS_MODULE, | ||
606 | .cra_init = ablk_init, | ||
607 | .cra_exit = ablk_exit, | ||
608 | .cra_u = { | ||
609 | .ablkcipher = { | ||
610 | .min_keysize = CAST6_MIN_KEY_SIZE * 2, | ||
611 | .max_keysize = CAST6_MAX_KEY_SIZE * 2, | ||
612 | .ivsize = CAST6_BLOCK_SIZE, | ||
613 | .setkey = ablk_set_key, | ||
614 | .encrypt = ablk_encrypt, | ||
615 | .decrypt = ablk_decrypt, | ||
616 | }, | ||
617 | }, | ||
618 | } }; | ||
619 | |||
620 | static int __init cast6_init(void) | ||
621 | { | ||
622 | u64 xcr0; | ||
623 | |||
624 | if (!cpu_has_avx || !cpu_has_osxsave) { | ||
625 | pr_info("AVX instructions are not detected.\n"); | ||
626 | return -ENODEV; | ||
627 | } | ||
628 | |||
629 | xcr0 = xgetbv(XCR_XFEATURE_ENABLED_MASK); | ||
630 | if ((xcr0 & (XSTATE_SSE | XSTATE_YMM)) != (XSTATE_SSE | XSTATE_YMM)) { | ||
631 | pr_info("AVX detected but unusable.\n"); | ||
632 | return -ENODEV; | ||
633 | } | ||
634 | |||
635 | return crypto_register_algs(cast6_algs, ARRAY_SIZE(cast6_algs)); | ||
636 | } | ||
637 | |||
638 | static void __exit cast6_exit(void) | ||
639 | { | ||
640 | crypto_unregister_algs(cast6_algs, ARRAY_SIZE(cast6_algs)); | ||
641 | } | ||
642 | |||
643 | module_init(cast6_init); | ||
644 | module_exit(cast6_exit); | ||
645 | |||
646 | MODULE_DESCRIPTION("Cast6 Cipher Algorithm, AVX optimized"); | ||
647 | MODULE_LICENSE("GPL"); | ||
648 | MODULE_ALIAS("cast6"); | ||
diff --git a/arch/x86/crypto/ghash-clmulni-intel_glue.c b/arch/x86/crypto/ghash-clmulni-intel_glue.c index b4bf0a63b520..6759dd1135be 100644 --- a/arch/x86/crypto/ghash-clmulni-intel_glue.c +++ b/arch/x86/crypto/ghash-clmulni-intel_glue.c | |||
@@ -150,7 +150,6 @@ static struct shash_alg ghash_alg = { | |||
150 | .cra_blocksize = GHASH_BLOCK_SIZE, | 150 | .cra_blocksize = GHASH_BLOCK_SIZE, |
151 | .cra_ctxsize = sizeof(struct ghash_ctx), | 151 | .cra_ctxsize = sizeof(struct ghash_ctx), |
152 | .cra_module = THIS_MODULE, | 152 | .cra_module = THIS_MODULE, |
153 | .cra_list = LIST_HEAD_INIT(ghash_alg.base.cra_list), | ||
154 | }, | 153 | }, |
155 | }; | 154 | }; |
156 | 155 | ||
@@ -288,7 +287,6 @@ static struct ahash_alg ghash_async_alg = { | |||
288 | .cra_blocksize = GHASH_BLOCK_SIZE, | 287 | .cra_blocksize = GHASH_BLOCK_SIZE, |
289 | .cra_type = &crypto_ahash_type, | 288 | .cra_type = &crypto_ahash_type, |
290 | .cra_module = THIS_MODULE, | 289 | .cra_module = THIS_MODULE, |
291 | .cra_list = LIST_HEAD_INIT(ghash_async_alg.halg.base.cra_list), | ||
292 | .cra_init = ghash_async_init_tfm, | 290 | .cra_init = ghash_async_init_tfm, |
293 | .cra_exit = ghash_async_exit_tfm, | 291 | .cra_exit = ghash_async_exit_tfm, |
294 | }, | 292 | }, |
diff --git a/arch/x86/crypto/glue_helper.c b/arch/x86/crypto/glue_helper.c index 4854f0f31e4f..30b3927bd733 100644 --- a/arch/x86/crypto/glue_helper.c +++ b/arch/x86/crypto/glue_helper.c | |||
@@ -110,7 +110,7 @@ static unsigned int __glue_cbc_encrypt_128bit(const common_glue_func_t fn, | |||
110 | nbytes -= bsize; | 110 | nbytes -= bsize; |
111 | } while (nbytes >= bsize); | 111 | } while (nbytes >= bsize); |
112 | 112 | ||
113 | u128_xor((u128 *)walk->iv, (u128 *)walk->iv, iv); | 113 | *(u128 *)walk->iv = *iv; |
114 | return nbytes; | 114 | return nbytes; |
115 | } | 115 | } |
116 | 116 | ||
diff --git a/arch/x86/crypto/salsa20_glue.c b/arch/x86/crypto/salsa20_glue.c index bccb76d80987..a3a3c0205c16 100644 --- a/arch/x86/crypto/salsa20_glue.c +++ b/arch/x86/crypto/salsa20_glue.c | |||
@@ -97,7 +97,6 @@ static struct crypto_alg alg = { | |||
97 | .cra_ctxsize = sizeof(struct salsa20_ctx), | 97 | .cra_ctxsize = sizeof(struct salsa20_ctx), |
98 | .cra_alignmask = 3, | 98 | .cra_alignmask = 3, |
99 | .cra_module = THIS_MODULE, | 99 | .cra_module = THIS_MODULE, |
100 | .cra_list = LIST_HEAD_INIT(alg.cra_list), | ||
101 | .cra_u = { | 100 | .cra_u = { |
102 | .blkcipher = { | 101 | .blkcipher = { |
103 | .setkey = setkey, | 102 | .setkey = setkey, |
diff --git a/arch/x86/crypto/serpent_avx_glue.c b/arch/x86/crypto/serpent_avx_glue.c index b36bdac237eb..3f543a04cf1e 100644 --- a/arch/x86/crypto/serpent_avx_glue.c +++ b/arch/x86/crypto/serpent_avx_glue.c | |||
@@ -390,7 +390,6 @@ static struct crypto_alg serpent_algs[10] = { { | |||
390 | .cra_alignmask = 0, | 390 | .cra_alignmask = 0, |
391 | .cra_type = &crypto_blkcipher_type, | 391 | .cra_type = &crypto_blkcipher_type, |
392 | .cra_module = THIS_MODULE, | 392 | .cra_module = THIS_MODULE, |
393 | .cra_list = LIST_HEAD_INIT(serpent_algs[0].cra_list), | ||
394 | .cra_u = { | 393 | .cra_u = { |
395 | .blkcipher = { | 394 | .blkcipher = { |
396 | .min_keysize = SERPENT_MIN_KEY_SIZE, | 395 | .min_keysize = SERPENT_MIN_KEY_SIZE, |
@@ -410,7 +409,6 @@ static struct crypto_alg serpent_algs[10] = { { | |||
410 | .cra_alignmask = 0, | 409 | .cra_alignmask = 0, |
411 | .cra_type = &crypto_blkcipher_type, | 410 | .cra_type = &crypto_blkcipher_type, |
412 | .cra_module = THIS_MODULE, | 411 | .cra_module = THIS_MODULE, |
413 | .cra_list = LIST_HEAD_INIT(serpent_algs[1].cra_list), | ||
414 | .cra_u = { | 412 | .cra_u = { |
415 | .blkcipher = { | 413 | .blkcipher = { |
416 | .min_keysize = SERPENT_MIN_KEY_SIZE, | 414 | .min_keysize = SERPENT_MIN_KEY_SIZE, |
@@ -430,7 +428,6 @@ static struct crypto_alg serpent_algs[10] = { { | |||
430 | .cra_alignmask = 0, | 428 | .cra_alignmask = 0, |
431 | .cra_type = &crypto_blkcipher_type, | 429 | .cra_type = &crypto_blkcipher_type, |
432 | .cra_module = THIS_MODULE, | 430 | .cra_module = THIS_MODULE, |
433 | .cra_list = LIST_HEAD_INIT(serpent_algs[2].cra_list), | ||
434 | .cra_u = { | 431 | .cra_u = { |
435 | .blkcipher = { | 432 | .blkcipher = { |
436 | .min_keysize = SERPENT_MIN_KEY_SIZE, | 433 | .min_keysize = SERPENT_MIN_KEY_SIZE, |
@@ -451,7 +448,6 @@ static struct crypto_alg serpent_algs[10] = { { | |||
451 | .cra_alignmask = 0, | 448 | .cra_alignmask = 0, |
452 | .cra_type = &crypto_blkcipher_type, | 449 | .cra_type = &crypto_blkcipher_type, |
453 | .cra_module = THIS_MODULE, | 450 | .cra_module = THIS_MODULE, |
454 | .cra_list = LIST_HEAD_INIT(serpent_algs[3].cra_list), | ||
455 | .cra_exit = lrw_exit_tfm, | 451 | .cra_exit = lrw_exit_tfm, |
456 | .cra_u = { | 452 | .cra_u = { |
457 | .blkcipher = { | 453 | .blkcipher = { |
@@ -475,7 +471,6 @@ static struct crypto_alg serpent_algs[10] = { { | |||
475 | .cra_alignmask = 0, | 471 | .cra_alignmask = 0, |
476 | .cra_type = &crypto_blkcipher_type, | 472 | .cra_type = &crypto_blkcipher_type, |
477 | .cra_module = THIS_MODULE, | 473 | .cra_module = THIS_MODULE, |
478 | .cra_list = LIST_HEAD_INIT(serpent_algs[4].cra_list), | ||
479 | .cra_u = { | 474 | .cra_u = { |
480 | .blkcipher = { | 475 | .blkcipher = { |
481 | .min_keysize = SERPENT_MIN_KEY_SIZE * 2, | 476 | .min_keysize = SERPENT_MIN_KEY_SIZE * 2, |
@@ -496,7 +491,6 @@ static struct crypto_alg serpent_algs[10] = { { | |||
496 | .cra_alignmask = 0, | 491 | .cra_alignmask = 0, |
497 | .cra_type = &crypto_ablkcipher_type, | 492 | .cra_type = &crypto_ablkcipher_type, |
498 | .cra_module = THIS_MODULE, | 493 | .cra_module = THIS_MODULE, |
499 | .cra_list = LIST_HEAD_INIT(serpent_algs[5].cra_list), | ||
500 | .cra_init = ablk_init, | 494 | .cra_init = ablk_init, |
501 | .cra_exit = ablk_exit, | 495 | .cra_exit = ablk_exit, |
502 | .cra_u = { | 496 | .cra_u = { |
@@ -518,7 +512,6 @@ static struct crypto_alg serpent_algs[10] = { { | |||
518 | .cra_alignmask = 0, | 512 | .cra_alignmask = 0, |
519 | .cra_type = &crypto_ablkcipher_type, | 513 | .cra_type = &crypto_ablkcipher_type, |
520 | .cra_module = THIS_MODULE, | 514 | .cra_module = THIS_MODULE, |
521 | .cra_list = LIST_HEAD_INIT(serpent_algs[6].cra_list), | ||
522 | .cra_init = ablk_init, | 515 | .cra_init = ablk_init, |
523 | .cra_exit = ablk_exit, | 516 | .cra_exit = ablk_exit, |
524 | .cra_u = { | 517 | .cra_u = { |
@@ -541,7 +534,6 @@ static struct crypto_alg serpent_algs[10] = { { | |||
541 | .cra_alignmask = 0, | 534 | .cra_alignmask = 0, |
542 | .cra_type = &crypto_ablkcipher_type, | 535 | .cra_type = &crypto_ablkcipher_type, |
543 | .cra_module = THIS_MODULE, | 536 | .cra_module = THIS_MODULE, |
544 | .cra_list = LIST_HEAD_INIT(serpent_algs[7].cra_list), | ||
545 | .cra_init = ablk_init, | 537 | .cra_init = ablk_init, |
546 | .cra_exit = ablk_exit, | 538 | .cra_exit = ablk_exit, |
547 | .cra_u = { | 539 | .cra_u = { |
@@ -565,7 +557,6 @@ static struct crypto_alg serpent_algs[10] = { { | |||
565 | .cra_alignmask = 0, | 557 | .cra_alignmask = 0, |
566 | .cra_type = &crypto_ablkcipher_type, | 558 | .cra_type = &crypto_ablkcipher_type, |
567 | .cra_module = THIS_MODULE, | 559 | .cra_module = THIS_MODULE, |
568 | .cra_list = LIST_HEAD_INIT(serpent_algs[8].cra_list), | ||
569 | .cra_init = ablk_init, | 560 | .cra_init = ablk_init, |
570 | .cra_exit = ablk_exit, | 561 | .cra_exit = ablk_exit, |
571 | .cra_u = { | 562 | .cra_u = { |
@@ -590,7 +581,6 @@ static struct crypto_alg serpent_algs[10] = { { | |||
590 | .cra_alignmask = 0, | 581 | .cra_alignmask = 0, |
591 | .cra_type = &crypto_ablkcipher_type, | 582 | .cra_type = &crypto_ablkcipher_type, |
592 | .cra_module = THIS_MODULE, | 583 | .cra_module = THIS_MODULE, |
593 | .cra_list = LIST_HEAD_INIT(serpent_algs[9].cra_list), | ||
594 | .cra_init = ablk_init, | 584 | .cra_init = ablk_init, |
595 | .cra_exit = ablk_exit, | 585 | .cra_exit = ablk_exit, |
596 | .cra_u = { | 586 | .cra_u = { |
diff --git a/arch/x86/crypto/serpent_sse2_glue.c b/arch/x86/crypto/serpent_sse2_glue.c index d679c8675f4a..9107a9908c41 100644 --- a/arch/x86/crypto/serpent_sse2_glue.c +++ b/arch/x86/crypto/serpent_sse2_glue.c | |||
@@ -393,7 +393,6 @@ static struct crypto_alg serpent_algs[10] = { { | |||
393 | .cra_alignmask = 0, | 393 | .cra_alignmask = 0, |
394 | .cra_type = &crypto_blkcipher_type, | 394 | .cra_type = &crypto_blkcipher_type, |
395 | .cra_module = THIS_MODULE, | 395 | .cra_module = THIS_MODULE, |
396 | .cra_list = LIST_HEAD_INIT(serpent_algs[0].cra_list), | ||
397 | .cra_u = { | 396 | .cra_u = { |
398 | .blkcipher = { | 397 | .blkcipher = { |
399 | .min_keysize = SERPENT_MIN_KEY_SIZE, | 398 | .min_keysize = SERPENT_MIN_KEY_SIZE, |
@@ -413,7 +412,6 @@ static struct crypto_alg serpent_algs[10] = { { | |||
413 | .cra_alignmask = 0, | 412 | .cra_alignmask = 0, |
414 | .cra_type = &crypto_blkcipher_type, | 413 | .cra_type = &crypto_blkcipher_type, |
415 | .cra_module = THIS_MODULE, | 414 | .cra_module = THIS_MODULE, |
416 | .cra_list = LIST_HEAD_INIT(serpent_algs[1].cra_list), | ||
417 | .cra_u = { | 415 | .cra_u = { |
418 | .blkcipher = { | 416 | .blkcipher = { |
419 | .min_keysize = SERPENT_MIN_KEY_SIZE, | 417 | .min_keysize = SERPENT_MIN_KEY_SIZE, |
@@ -433,7 +431,6 @@ static struct crypto_alg serpent_algs[10] = { { | |||
433 | .cra_alignmask = 0, | 431 | .cra_alignmask = 0, |
434 | .cra_type = &crypto_blkcipher_type, | 432 | .cra_type = &crypto_blkcipher_type, |
435 | .cra_module = THIS_MODULE, | 433 | .cra_module = THIS_MODULE, |
436 | .cra_list = LIST_HEAD_INIT(serpent_algs[2].cra_list), | ||
437 | .cra_u = { | 434 | .cra_u = { |
438 | .blkcipher = { | 435 | .blkcipher = { |
439 | .min_keysize = SERPENT_MIN_KEY_SIZE, | 436 | .min_keysize = SERPENT_MIN_KEY_SIZE, |
@@ -454,7 +451,6 @@ static struct crypto_alg serpent_algs[10] = { { | |||
454 | .cra_alignmask = 0, | 451 | .cra_alignmask = 0, |
455 | .cra_type = &crypto_blkcipher_type, | 452 | .cra_type = &crypto_blkcipher_type, |
456 | .cra_module = THIS_MODULE, | 453 | .cra_module = THIS_MODULE, |
457 | .cra_list = LIST_HEAD_INIT(serpent_algs[3].cra_list), | ||
458 | .cra_exit = lrw_exit_tfm, | 454 | .cra_exit = lrw_exit_tfm, |
459 | .cra_u = { | 455 | .cra_u = { |
460 | .blkcipher = { | 456 | .blkcipher = { |
@@ -478,7 +474,6 @@ static struct crypto_alg serpent_algs[10] = { { | |||
478 | .cra_alignmask = 0, | 474 | .cra_alignmask = 0, |
479 | .cra_type = &crypto_blkcipher_type, | 475 | .cra_type = &crypto_blkcipher_type, |
480 | .cra_module = THIS_MODULE, | 476 | .cra_module = THIS_MODULE, |
481 | .cra_list = LIST_HEAD_INIT(serpent_algs[4].cra_list), | ||
482 | .cra_u = { | 477 | .cra_u = { |
483 | .blkcipher = { | 478 | .blkcipher = { |
484 | .min_keysize = SERPENT_MIN_KEY_SIZE * 2, | 479 | .min_keysize = SERPENT_MIN_KEY_SIZE * 2, |
@@ -499,7 +494,6 @@ static struct crypto_alg serpent_algs[10] = { { | |||
499 | .cra_alignmask = 0, | 494 | .cra_alignmask = 0, |
500 | .cra_type = &crypto_ablkcipher_type, | 495 | .cra_type = &crypto_ablkcipher_type, |
501 | .cra_module = THIS_MODULE, | 496 | .cra_module = THIS_MODULE, |
502 | .cra_list = LIST_HEAD_INIT(serpent_algs[5].cra_list), | ||
503 | .cra_init = ablk_init, | 497 | .cra_init = ablk_init, |
504 | .cra_exit = ablk_exit, | 498 | .cra_exit = ablk_exit, |
505 | .cra_u = { | 499 | .cra_u = { |
@@ -521,7 +515,6 @@ static struct crypto_alg serpent_algs[10] = { { | |||
521 | .cra_alignmask = 0, | 515 | .cra_alignmask = 0, |
522 | .cra_type = &crypto_ablkcipher_type, | 516 | .cra_type = &crypto_ablkcipher_type, |
523 | .cra_module = THIS_MODULE, | 517 | .cra_module = THIS_MODULE, |
524 | .cra_list = LIST_HEAD_INIT(serpent_algs[6].cra_list), | ||
525 | .cra_init = ablk_init, | 518 | .cra_init = ablk_init, |
526 | .cra_exit = ablk_exit, | 519 | .cra_exit = ablk_exit, |
527 | .cra_u = { | 520 | .cra_u = { |
@@ -544,7 +537,6 @@ static struct crypto_alg serpent_algs[10] = { { | |||
544 | .cra_alignmask = 0, | 537 | .cra_alignmask = 0, |
545 | .cra_type = &crypto_ablkcipher_type, | 538 | .cra_type = &crypto_ablkcipher_type, |
546 | .cra_module = THIS_MODULE, | 539 | .cra_module = THIS_MODULE, |
547 | .cra_list = LIST_HEAD_INIT(serpent_algs[7].cra_list), | ||
548 | .cra_init = ablk_init, | 540 | .cra_init = ablk_init, |
549 | .cra_exit = ablk_exit, | 541 | .cra_exit = ablk_exit, |
550 | .cra_u = { | 542 | .cra_u = { |
@@ -568,7 +560,6 @@ static struct crypto_alg serpent_algs[10] = { { | |||
568 | .cra_alignmask = 0, | 560 | .cra_alignmask = 0, |
569 | .cra_type = &crypto_ablkcipher_type, | 561 | .cra_type = &crypto_ablkcipher_type, |
570 | .cra_module = THIS_MODULE, | 562 | .cra_module = THIS_MODULE, |
571 | .cra_list = LIST_HEAD_INIT(serpent_algs[8].cra_list), | ||
572 | .cra_init = ablk_init, | 563 | .cra_init = ablk_init, |
573 | .cra_exit = ablk_exit, | 564 | .cra_exit = ablk_exit, |
574 | .cra_u = { | 565 | .cra_u = { |
@@ -593,7 +584,6 @@ static struct crypto_alg serpent_algs[10] = { { | |||
593 | .cra_alignmask = 0, | 584 | .cra_alignmask = 0, |
594 | .cra_type = &crypto_ablkcipher_type, | 585 | .cra_type = &crypto_ablkcipher_type, |
595 | .cra_module = THIS_MODULE, | 586 | .cra_module = THIS_MODULE, |
596 | .cra_list = LIST_HEAD_INIT(serpent_algs[9].cra_list), | ||
597 | .cra_init = ablk_init, | 587 | .cra_init = ablk_init, |
598 | .cra_exit = ablk_exit, | 588 | .cra_exit = ablk_exit, |
599 | .cra_u = { | 589 | .cra_u = { |
diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S index 35f45574390d..1585abb13dde 100644 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S | |||
@@ -4,6 +4,8 @@ | |||
4 | * Copyright (C) 2012 Johannes Goetzfried | 4 | * Copyright (C) 2012 Johannes Goetzfried |
5 | * <Johannes.Goetzfried@informatik.stud.uni-erlangen.de> | 5 | * <Johannes.Goetzfried@informatik.stud.uni-erlangen.de> |
6 | * | 6 | * |
7 | * Copyright © 2012 Jussi Kivilinna <jussi.kivilinna@mbnet.fi> | ||
8 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | 9 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
9 | * the Free Software Foundation; either version 2 of the License, or | 11 | * the Free Software Foundation; either version 2 of the License, or |
@@ -47,16 +49,22 @@ | |||
47 | #define RC2 %xmm6 | 49 | #define RC2 %xmm6 |
48 | #define RD2 %xmm7 | 50 | #define RD2 %xmm7 |
49 | 51 | ||
50 | #define RX %xmm8 | 52 | #define RX0 %xmm8 |
51 | #define RY %xmm9 | 53 | #define RY0 %xmm9 |
54 | |||
55 | #define RX1 %xmm10 | ||
56 | #define RY1 %xmm11 | ||
52 | 57 | ||
53 | #define RK1 %xmm10 | 58 | #define RK1 %xmm12 |
54 | #define RK2 %xmm11 | 59 | #define RK2 %xmm13 |
55 | 60 | ||
56 | #define RID1 %rax | 61 | #define RT %xmm14 |
57 | #define RID1b %al | 62 | #define RR %xmm15 |
58 | #define RID2 %rbx | 63 | |
59 | #define RID2b %bl | 64 | #define RID1 %rbp |
65 | #define RID1d %ebp | ||
66 | #define RID2 %rsi | ||
67 | #define RID2d %esi | ||
60 | 68 | ||
61 | #define RGI1 %rdx | 69 | #define RGI1 %rdx |
62 | #define RGI1bl %dl | 70 | #define RGI1bl %dl |
@@ -65,6 +73,13 @@ | |||
65 | #define RGI2bl %cl | 73 | #define RGI2bl %cl |
66 | #define RGI2bh %ch | 74 | #define RGI2bh %ch |
67 | 75 | ||
76 | #define RGI3 %rax | ||
77 | #define RGI3bl %al | ||
78 | #define RGI3bh %ah | ||
79 | #define RGI4 %rbx | ||
80 | #define RGI4bl %bl | ||
81 | #define RGI4bh %bh | ||
82 | |||
68 | #define RGS1 %r8 | 83 | #define RGS1 %r8 |
69 | #define RGS1d %r8d | 84 | #define RGS1d %r8d |
70 | #define RGS2 %r9 | 85 | #define RGS2 %r9 |
@@ -73,89 +88,123 @@ | |||
73 | #define RGS3d %r10d | 88 | #define RGS3d %r10d |
74 | 89 | ||
75 | 90 | ||
76 | #define lookup_32bit(t0, t1, t2, t3, src, dst) \ | 91 | #define lookup_32bit(t0, t1, t2, t3, src, dst, interleave_op, il_reg) \ |
77 | movb src ## bl, RID1b; \ | 92 | movzbl src ## bl, RID1d; \ |
78 | movb src ## bh, RID2b; \ | 93 | movzbl src ## bh, RID2d; \ |
79 | movl t0(CTX, RID1, 4), dst ## d; \ | ||
80 | xorl t1(CTX, RID2, 4), dst ## d; \ | ||
81 | shrq $16, src; \ | 94 | shrq $16, src; \ |
82 | movb src ## bl, RID1b; \ | 95 | movl t0(CTX, RID1, 4), dst ## d; \ |
83 | movb src ## bh, RID2b; \ | 96 | movl t1(CTX, RID2, 4), RID2d; \ |
97 | movzbl src ## bl, RID1d; \ | ||
98 | xorl RID2d, dst ## d; \ | ||
99 | movzbl src ## bh, RID2d; \ | ||
100 | interleave_op(il_reg); \ | ||
84 | xorl t2(CTX, RID1, 4), dst ## d; \ | 101 | xorl t2(CTX, RID1, 4), dst ## d; \ |
85 | xorl t3(CTX, RID2, 4), dst ## d; | 102 | xorl t3(CTX, RID2, 4), dst ## d; |
86 | 103 | ||
87 | #define G(a, x, t0, t1, t2, t3) \ | 104 | #define dummy(d) /* do nothing */ |
88 | vmovq a, RGI1; \ | 105 | |
89 | vpsrldq $8, a, x; \ | 106 | #define shr_next(reg) \ |
90 | vmovq x, RGI2; \ | 107 | shrq $16, reg; |
108 | |||
109 | #define G(gi1, gi2, x, t0, t1, t2, t3) \ | ||
110 | lookup_32bit(t0, t1, t2, t3, ##gi1, RGS1, shr_next, ##gi1); \ | ||
111 | lookup_32bit(t0, t1, t2, t3, ##gi2, RGS3, shr_next, ##gi2); \ | ||
112 | \ | ||
113 | lookup_32bit(t0, t1, t2, t3, ##gi1, RGS2, dummy, none); \ | ||
114 | shlq $32, RGS2; \ | ||
115 | orq RGS1, RGS2; \ | ||
116 | lookup_32bit(t0, t1, t2, t3, ##gi2, RGS1, dummy, none); \ | ||
117 | shlq $32, RGS1; \ | ||
118 | orq RGS1, RGS3; | ||
119 | |||
120 | #define round_head_2(a, b, x1, y1, x2, y2) \ | ||
121 | vmovq b ## 1, RGI3; \ | ||
122 | vpextrq $1, b ## 1, RGI4; \ | ||
91 | \ | 123 | \ |
92 | lookup_32bit(t0, t1, t2, t3, RGI1, RGS1); \ | 124 | G(RGI1, RGI2, x1, s0, s1, s2, s3); \ |
93 | shrq $16, RGI1; \ | 125 | vmovq a ## 2, RGI1; \ |
94 | lookup_32bit(t0, t1, t2, t3, RGI1, RGS2); \ | 126 | vpextrq $1, a ## 2, RGI2; \ |
95 | shlq $32, RGS2; \ | 127 | vmovq RGS2, x1; \ |
96 | orq RGS1, RGS2; \ | 128 | vpinsrq $1, RGS3, x1, x1; \ |
97 | \ | 129 | \ |
98 | lookup_32bit(t0, t1, t2, t3, RGI2, RGS1); \ | 130 | G(RGI3, RGI4, y1, s1, s2, s3, s0); \ |
99 | shrq $16, RGI2; \ | 131 | vmovq b ## 2, RGI3; \ |
100 | lookup_32bit(t0, t1, t2, t3, RGI2, RGS3); \ | 132 | vpextrq $1, b ## 2, RGI4; \ |
101 | shlq $32, RGS3; \ | 133 | vmovq RGS2, y1; \ |
102 | orq RGS1, RGS3; \ | 134 | vpinsrq $1, RGS3, y1, y1; \ |
103 | \ | 135 | \ |
104 | vmovq RGS2, x; \ | 136 | G(RGI1, RGI2, x2, s0, s1, s2, s3); \ |
105 | vpinsrq $1, RGS3, x, x; | 137 | vmovq RGS2, x2; \ |
138 | vpinsrq $1, RGS3, x2, x2; \ | ||
139 | \ | ||
140 | G(RGI3, RGI4, y2, s1, s2, s3, s0); \ | ||
141 | vmovq RGS2, y2; \ | ||
142 | vpinsrq $1, RGS3, y2, y2; | ||
106 | 143 | ||
107 | #define encround(a, b, c, d, x, y) \ | 144 | #define encround_tail(a, b, c, d, x, y, prerotate) \ |
108 | G(a, x, s0, s1, s2, s3); \ | ||
109 | G(b, y, s1, s2, s3, s0); \ | ||
110 | vpaddd x, y, x; \ | 145 | vpaddd x, y, x; \ |
146 | vpaddd x, RK1, RT;\ | ||
147 | prerotate(b); \ | ||
148 | vpxor RT, c, c; \ | ||
111 | vpaddd y, x, y; \ | 149 | vpaddd y, x, y; \ |
112 | vpaddd x, RK1, x; \ | ||
113 | vpaddd y, RK2, y; \ | 150 | vpaddd y, RK2, y; \ |
114 | vpxor x, c, c; \ | 151 | vpsrld $1, c, RT; \ |
115 | vpsrld $1, c, x; \ | ||
116 | vpslld $(32 - 1), c, c; \ | 152 | vpslld $(32 - 1), c, c; \ |
117 | vpor c, x, c; \ | 153 | vpor c, RT, c; \ |
118 | vpslld $1, d, x; \ | 154 | vpxor d, y, d; \ |
119 | vpsrld $(32 - 1), d, d; \ | 155 | |
120 | vpor d, x, d; \ | 156 | #define decround_tail(a, b, c, d, x, y, prerotate) \ |
121 | vpxor d, y, d; | ||
122 | |||
123 | #define decround(a, b, c, d, x, y) \ | ||
124 | G(a, x, s0, s1, s2, s3); \ | ||
125 | G(b, y, s1, s2, s3, s0); \ | ||
126 | vpaddd x, y, x; \ | 157 | vpaddd x, y, x; \ |
158 | vpaddd x, RK1, RT;\ | ||
159 | prerotate(a); \ | ||
160 | vpxor RT, c, c; \ | ||
127 | vpaddd y, x, y; \ | 161 | vpaddd y, x, y; \ |
128 | vpaddd y, RK2, y; \ | 162 | vpaddd y, RK2, y; \ |
129 | vpxor d, y, d; \ | 163 | vpxor d, y, d; \ |
130 | vpsrld $1, d, y; \ | 164 | vpsrld $1, d, y; \ |
131 | vpslld $(32 - 1), d, d; \ | 165 | vpslld $(32 - 1), d, d; \ |
132 | vpor d, y, d; \ | 166 | vpor d, y, d; \ |
133 | vpslld $1, c, y; \ | 167 | |
134 | vpsrld $(32 - 1), c, c; \ | 168 | #define rotate_1l(x) \ |
135 | vpor c, y, c; \ | 169 | vpslld $1, x, RR; \ |
136 | vpaddd x, RK1, x; \ | 170 | vpsrld $(32 - 1), x, x; \ |
137 | vpxor x, c, c; | 171 | vpor x, RR, x; |
138 | 172 | ||
139 | #define encrypt_round(n, a, b, c, d) \ | 173 | #define preload_rgi(c) \ |
140 | vbroadcastss (k+4*(2*(n)))(CTX), RK1; \ | 174 | vmovq c, RGI1; \ |
141 | vbroadcastss (k+4*(2*(n)+1))(CTX), RK2; \ | 175 | vpextrq $1, c, RGI2; |
142 | encround(a ## 1, b ## 1, c ## 1, d ## 1, RX, RY); \ | 176 | |
143 | encround(a ## 2, b ## 2, c ## 2, d ## 2, RX, RY); | 177 | #define encrypt_round(n, a, b, c, d, preload, prerotate) \ |
144 | 178 | vbroadcastss (k+4*(2*(n)))(CTX), RK1; \ | |
145 | #define decrypt_round(n, a, b, c, d) \ | 179 | vbroadcastss (k+4*(2*(n)+1))(CTX), RK2; \ |
146 | vbroadcastss (k+4*(2*(n)))(CTX), RK1; \ | 180 | round_head_2(a, b, RX0, RY0, RX1, RY1); \ |
147 | vbroadcastss (k+4*(2*(n)+1))(CTX), RK2; \ | 181 | encround_tail(a ## 1, b ## 1, c ## 1, d ## 1, RX0, RY0, prerotate); \ |
148 | decround(a ## 1, b ## 1, c ## 1, d ## 1, RX, RY); \ | 182 | preload(c ## 1); \ |
149 | decround(a ## 2, b ## 2, c ## 2, d ## 2, RX, RY); | 183 | encround_tail(a ## 2, b ## 2, c ## 2, d ## 2, RX1, RY1, prerotate); |
184 | |||
185 | #define decrypt_round(n, a, b, c, d, preload, prerotate) \ | ||
186 | vbroadcastss (k+4*(2*(n)))(CTX), RK1; \ | ||
187 | vbroadcastss (k+4*(2*(n)+1))(CTX), RK2; \ | ||
188 | round_head_2(a, b, RX0, RY0, RX1, RY1); \ | ||
189 | decround_tail(a ## 1, b ## 1, c ## 1, d ## 1, RX0, RY0, prerotate); \ | ||
190 | preload(c ## 1); \ | ||
191 | decround_tail(a ## 2, b ## 2, c ## 2, d ## 2, RX1, RY1, prerotate); | ||
150 | 192 | ||
151 | #define encrypt_cycle(n) \ | 193 | #define encrypt_cycle(n) \ |
152 | encrypt_round((2*n), RA, RB, RC, RD); \ | 194 | encrypt_round((2*n), RA, RB, RC, RD, preload_rgi, rotate_1l); \ |
153 | encrypt_round(((2*n) + 1), RC, RD, RA, RB); | 195 | encrypt_round(((2*n) + 1), RC, RD, RA, RB, preload_rgi, rotate_1l); |
196 | |||
197 | #define encrypt_cycle_last(n) \ | ||
198 | encrypt_round((2*n), RA, RB, RC, RD, preload_rgi, rotate_1l); \ | ||
199 | encrypt_round(((2*n) + 1), RC, RD, RA, RB, dummy, dummy); | ||
154 | 200 | ||
155 | #define decrypt_cycle(n) \ | 201 | #define decrypt_cycle(n) \ |
156 | decrypt_round(((2*n) + 1), RC, RD, RA, RB); \ | 202 | decrypt_round(((2*n) + 1), RC, RD, RA, RB, preload_rgi, rotate_1l); \ |
157 | decrypt_round((2*n), RA, RB, RC, RD); | 203 | decrypt_round((2*n), RA, RB, RC, RD, preload_rgi, rotate_1l); |
158 | 204 | ||
205 | #define decrypt_cycle_last(n) \ | ||
206 | decrypt_round(((2*n) + 1), RC, RD, RA, RB, preload_rgi, rotate_1l); \ | ||
207 | decrypt_round((2*n), RA, RB, RC, RD, dummy, dummy); | ||
159 | 208 | ||
160 | #define transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \ | 209 | #define transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \ |
161 | vpunpckldq x1, x0, t0; \ | 210 | vpunpckldq x1, x0, t0; \ |
@@ -216,17 +265,20 @@ __twofish_enc_blk_8way: | |||
216 | * %rcx: bool, if true: xor output | 265 | * %rcx: bool, if true: xor output |
217 | */ | 266 | */ |
218 | 267 | ||
268 | pushq %rbp; | ||
219 | pushq %rbx; | 269 | pushq %rbx; |
220 | pushq %rcx; | 270 | pushq %rcx; |
221 | 271 | ||
222 | vmovdqu w(CTX), RK1; | 272 | vmovdqu w(CTX), RK1; |
223 | 273 | ||
224 | leaq (4*4*4)(%rdx), %rax; | 274 | leaq (4*4*4)(%rdx), %rax; |
225 | inpack_blocks(%rdx, RA1, RB1, RC1, RD1, RK1, RX, RY, RK2); | 275 | inpack_blocks(%rdx, RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2); |
226 | inpack_blocks(%rax, RA2, RB2, RC2, RD2, RK1, RX, RY, RK2); | 276 | preload_rgi(RA1); |
277 | rotate_1l(RD1); | ||
278 | inpack_blocks(%rax, RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2); | ||
279 | rotate_1l(RD2); | ||
227 | 280 | ||
228 | xorq RID1, RID1; | 281 | movq %rsi, %r11; |
229 | xorq RID2, RID2; | ||
230 | 282 | ||
231 | encrypt_cycle(0); | 283 | encrypt_cycle(0); |
232 | encrypt_cycle(1); | 284 | encrypt_cycle(1); |
@@ -235,26 +287,27 @@ __twofish_enc_blk_8way: | |||
235 | encrypt_cycle(4); | 287 | encrypt_cycle(4); |
236 | encrypt_cycle(5); | 288 | encrypt_cycle(5); |
237 | encrypt_cycle(6); | 289 | encrypt_cycle(6); |
238 | encrypt_cycle(7); | 290 | encrypt_cycle_last(7); |
239 | 291 | ||
240 | vmovdqu (w+4*4)(CTX), RK1; | 292 | vmovdqu (w+4*4)(CTX), RK1; |
241 | 293 | ||
242 | popq %rcx; | 294 | popq %rcx; |
243 | popq %rbx; | 295 | popq %rbx; |
296 | popq %rbp; | ||
244 | 297 | ||
245 | leaq (4*4*4)(%rsi), %rax; | 298 | leaq (4*4*4)(%r11), %rax; |
246 | 299 | ||
247 | testb %cl, %cl; | 300 | testb %cl, %cl; |
248 | jnz __enc_xor8; | 301 | jnz __enc_xor8; |
249 | 302 | ||
250 | outunpack_blocks(%rsi, RC1, RD1, RA1, RB1, RK1, RX, RY, RK2); | 303 | outunpack_blocks(%r11, RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2); |
251 | outunpack_blocks(%rax, RC2, RD2, RA2, RB2, RK1, RX, RY, RK2); | 304 | outunpack_blocks(%rax, RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2); |
252 | 305 | ||
253 | ret; | 306 | ret; |
254 | 307 | ||
255 | __enc_xor8: | 308 | __enc_xor8: |
256 | outunpack_xor_blocks(%rsi, RC1, RD1, RA1, RB1, RK1, RX, RY, RK2); | 309 | outunpack_xor_blocks(%r11, RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2); |
257 | outunpack_xor_blocks(%rax, RC2, RD2, RA2, RB2, RK1, RX, RY, RK2); | 310 | outunpack_xor_blocks(%rax, RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2); |
258 | 311 | ||
259 | ret; | 312 | ret; |
260 | 313 | ||
@@ -269,16 +322,19 @@ twofish_dec_blk_8way: | |||
269 | * %rdx: src | 322 | * %rdx: src |
270 | */ | 323 | */ |
271 | 324 | ||
325 | pushq %rbp; | ||
272 | pushq %rbx; | 326 | pushq %rbx; |
273 | 327 | ||
274 | vmovdqu (w+4*4)(CTX), RK1; | 328 | vmovdqu (w+4*4)(CTX), RK1; |
275 | 329 | ||
276 | leaq (4*4*4)(%rdx), %rax; | 330 | leaq (4*4*4)(%rdx), %rax; |
277 | inpack_blocks(%rdx, RC1, RD1, RA1, RB1, RK1, RX, RY, RK2); | 331 | inpack_blocks(%rdx, RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2); |
278 | inpack_blocks(%rax, RC2, RD2, RA2, RB2, RK1, RX, RY, RK2); | 332 | preload_rgi(RC1); |
333 | rotate_1l(RA1); | ||
334 | inpack_blocks(%rax, RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2); | ||
335 | rotate_1l(RA2); | ||
279 | 336 | ||
280 | xorq RID1, RID1; | 337 | movq %rsi, %r11; |
281 | xorq RID2, RID2; | ||
282 | 338 | ||
283 | decrypt_cycle(7); | 339 | decrypt_cycle(7); |
284 | decrypt_cycle(6); | 340 | decrypt_cycle(6); |
@@ -287,14 +343,15 @@ twofish_dec_blk_8way: | |||
287 | decrypt_cycle(3); | 343 | decrypt_cycle(3); |
288 | decrypt_cycle(2); | 344 | decrypt_cycle(2); |
289 | decrypt_cycle(1); | 345 | decrypt_cycle(1); |
290 | decrypt_cycle(0); | 346 | decrypt_cycle_last(0); |
291 | 347 | ||
292 | vmovdqu (w)(CTX), RK1; | 348 | vmovdqu (w)(CTX), RK1; |
293 | 349 | ||
294 | popq %rbx; | 350 | popq %rbx; |
351 | popq %rbp; | ||
295 | 352 | ||
296 | leaq (4*4*4)(%rsi), %rax; | 353 | leaq (4*4*4)(%r11), %rax; |
297 | outunpack_blocks(%rsi, RA1, RB1, RC1, RD1, RK1, RX, RY, RK2); | 354 | outunpack_blocks(%r11, RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2); |
298 | outunpack_blocks(%rax, RA2, RB2, RC2, RD2, RK1, RX, RY, RK2); | 355 | outunpack_blocks(%rax, RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2); |
299 | 356 | ||
300 | ret; | 357 | ret; |
diff --git a/arch/x86/crypto/twofish_avx_glue.c b/arch/x86/crypto/twofish_avx_glue.c index 782b67ddaf6a..e7708b5442e0 100644 --- a/arch/x86/crypto/twofish_avx_glue.c +++ b/arch/x86/crypto/twofish_avx_glue.c | |||
@@ -378,7 +378,6 @@ static struct crypto_alg twofish_algs[10] = { { | |||
378 | .cra_alignmask = 0, | 378 | .cra_alignmask = 0, |
379 | .cra_type = &crypto_blkcipher_type, | 379 | .cra_type = &crypto_blkcipher_type, |
380 | .cra_module = THIS_MODULE, | 380 | .cra_module = THIS_MODULE, |
381 | .cra_list = LIST_HEAD_INIT(twofish_algs[0].cra_list), | ||
382 | .cra_u = { | 381 | .cra_u = { |
383 | .blkcipher = { | 382 | .blkcipher = { |
384 | .min_keysize = TF_MIN_KEY_SIZE, | 383 | .min_keysize = TF_MIN_KEY_SIZE, |
@@ -398,7 +397,6 @@ static struct crypto_alg twofish_algs[10] = { { | |||
398 | .cra_alignmask = 0, | 397 | .cra_alignmask = 0, |
399 | .cra_type = &crypto_blkcipher_type, | 398 | .cra_type = &crypto_blkcipher_type, |
400 | .cra_module = THIS_MODULE, | 399 | .cra_module = THIS_MODULE, |
401 | .cra_list = LIST_HEAD_INIT(twofish_algs[1].cra_list), | ||
402 | .cra_u = { | 400 | .cra_u = { |
403 | .blkcipher = { | 401 | .blkcipher = { |
404 | .min_keysize = TF_MIN_KEY_SIZE, | 402 | .min_keysize = TF_MIN_KEY_SIZE, |
@@ -418,7 +416,6 @@ static struct crypto_alg twofish_algs[10] = { { | |||
418 | .cra_alignmask = 0, | 416 | .cra_alignmask = 0, |
419 | .cra_type = &crypto_blkcipher_type, | 417 | .cra_type = &crypto_blkcipher_type, |
420 | .cra_module = THIS_MODULE, | 418 | .cra_module = THIS_MODULE, |
421 | .cra_list = LIST_HEAD_INIT(twofish_algs[2].cra_list), | ||
422 | .cra_u = { | 419 | .cra_u = { |
423 | .blkcipher = { | 420 | .blkcipher = { |
424 | .min_keysize = TF_MIN_KEY_SIZE, | 421 | .min_keysize = TF_MIN_KEY_SIZE, |
@@ -439,7 +436,6 @@ static struct crypto_alg twofish_algs[10] = { { | |||
439 | .cra_alignmask = 0, | 436 | .cra_alignmask = 0, |
440 | .cra_type = &crypto_blkcipher_type, | 437 | .cra_type = &crypto_blkcipher_type, |
441 | .cra_module = THIS_MODULE, | 438 | .cra_module = THIS_MODULE, |
442 | .cra_list = LIST_HEAD_INIT(twofish_algs[3].cra_list), | ||
443 | .cra_exit = lrw_twofish_exit_tfm, | 439 | .cra_exit = lrw_twofish_exit_tfm, |
444 | .cra_u = { | 440 | .cra_u = { |
445 | .blkcipher = { | 441 | .blkcipher = { |
@@ -463,7 +459,6 @@ static struct crypto_alg twofish_algs[10] = { { | |||
463 | .cra_alignmask = 0, | 459 | .cra_alignmask = 0, |
464 | .cra_type = &crypto_blkcipher_type, | 460 | .cra_type = &crypto_blkcipher_type, |
465 | .cra_module = THIS_MODULE, | 461 | .cra_module = THIS_MODULE, |
466 | .cra_list = LIST_HEAD_INIT(twofish_algs[4].cra_list), | ||
467 | .cra_u = { | 462 | .cra_u = { |
468 | .blkcipher = { | 463 | .blkcipher = { |
469 | .min_keysize = TF_MIN_KEY_SIZE * 2, | 464 | .min_keysize = TF_MIN_KEY_SIZE * 2, |
@@ -484,7 +479,6 @@ static struct crypto_alg twofish_algs[10] = { { | |||
484 | .cra_alignmask = 0, | 479 | .cra_alignmask = 0, |
485 | .cra_type = &crypto_ablkcipher_type, | 480 | .cra_type = &crypto_ablkcipher_type, |
486 | .cra_module = THIS_MODULE, | 481 | .cra_module = THIS_MODULE, |
487 | .cra_list = LIST_HEAD_INIT(twofish_algs[5].cra_list), | ||
488 | .cra_init = ablk_init, | 482 | .cra_init = ablk_init, |
489 | .cra_exit = ablk_exit, | 483 | .cra_exit = ablk_exit, |
490 | .cra_u = { | 484 | .cra_u = { |
@@ -506,7 +500,6 @@ static struct crypto_alg twofish_algs[10] = { { | |||
506 | .cra_alignmask = 0, | 500 | .cra_alignmask = 0, |
507 | .cra_type = &crypto_ablkcipher_type, | 501 | .cra_type = &crypto_ablkcipher_type, |
508 | .cra_module = THIS_MODULE, | 502 | .cra_module = THIS_MODULE, |
509 | .cra_list = LIST_HEAD_INIT(twofish_algs[6].cra_list), | ||
510 | .cra_init = ablk_init, | 503 | .cra_init = ablk_init, |
511 | .cra_exit = ablk_exit, | 504 | .cra_exit = ablk_exit, |
512 | .cra_u = { | 505 | .cra_u = { |
@@ -529,7 +522,6 @@ static struct crypto_alg twofish_algs[10] = { { | |||
529 | .cra_alignmask = 0, | 522 | .cra_alignmask = 0, |
530 | .cra_type = &crypto_ablkcipher_type, | 523 | .cra_type = &crypto_ablkcipher_type, |
531 | .cra_module = THIS_MODULE, | 524 | .cra_module = THIS_MODULE, |
532 | .cra_list = LIST_HEAD_INIT(twofish_algs[7].cra_list), | ||
533 | .cra_init = ablk_init, | 525 | .cra_init = ablk_init, |
534 | .cra_exit = ablk_exit, | 526 | .cra_exit = ablk_exit, |
535 | .cra_u = { | 527 | .cra_u = { |
@@ -553,7 +545,6 @@ static struct crypto_alg twofish_algs[10] = { { | |||
553 | .cra_alignmask = 0, | 545 | .cra_alignmask = 0, |
554 | .cra_type = &crypto_ablkcipher_type, | 546 | .cra_type = &crypto_ablkcipher_type, |
555 | .cra_module = THIS_MODULE, | 547 | .cra_module = THIS_MODULE, |
556 | .cra_list = LIST_HEAD_INIT(twofish_algs[8].cra_list), | ||
557 | .cra_init = ablk_init, | 548 | .cra_init = ablk_init, |
558 | .cra_exit = ablk_exit, | 549 | .cra_exit = ablk_exit, |
559 | .cra_u = { | 550 | .cra_u = { |
@@ -578,7 +569,6 @@ static struct crypto_alg twofish_algs[10] = { { | |||
578 | .cra_alignmask = 0, | 569 | .cra_alignmask = 0, |
579 | .cra_type = &crypto_ablkcipher_type, | 570 | .cra_type = &crypto_ablkcipher_type, |
580 | .cra_module = THIS_MODULE, | 571 | .cra_module = THIS_MODULE, |
581 | .cra_list = LIST_HEAD_INIT(twofish_algs[9].cra_list), | ||
582 | .cra_init = ablk_init, | 572 | .cra_init = ablk_init, |
583 | .cra_exit = ablk_exit, | 573 | .cra_exit = ablk_exit, |
584 | .cra_u = { | 574 | .cra_u = { |
diff --git a/arch/x86/crypto/twofish_glue.c b/arch/x86/crypto/twofish_glue.c index 359ae084275c..0a5202303501 100644 --- a/arch/x86/crypto/twofish_glue.c +++ b/arch/x86/crypto/twofish_glue.c | |||
@@ -70,7 +70,6 @@ static struct crypto_alg alg = { | |||
70 | .cra_ctxsize = sizeof(struct twofish_ctx), | 70 | .cra_ctxsize = sizeof(struct twofish_ctx), |
71 | .cra_alignmask = 0, | 71 | .cra_alignmask = 0, |
72 | .cra_module = THIS_MODULE, | 72 | .cra_module = THIS_MODULE, |
73 | .cra_list = LIST_HEAD_INIT(alg.cra_list), | ||
74 | .cra_u = { | 73 | .cra_u = { |
75 | .cipher = { | 74 | .cipher = { |
76 | .cia_min_keysize = TF_MIN_KEY_SIZE, | 75 | .cia_min_keysize = TF_MIN_KEY_SIZE, |
diff --git a/arch/x86/crypto/twofish_glue_3way.c b/arch/x86/crypto/twofish_glue_3way.c index 15f9347316c8..aa3eb358b7e8 100644 --- a/arch/x86/crypto/twofish_glue_3way.c +++ b/arch/x86/crypto/twofish_glue_3way.c | |||
@@ -342,7 +342,6 @@ static struct crypto_alg tf_algs[5] = { { | |||
342 | .cra_alignmask = 0, | 342 | .cra_alignmask = 0, |
343 | .cra_type = &crypto_blkcipher_type, | 343 | .cra_type = &crypto_blkcipher_type, |
344 | .cra_module = THIS_MODULE, | 344 | .cra_module = THIS_MODULE, |
345 | .cra_list = LIST_HEAD_INIT(tf_algs[0].cra_list), | ||
346 | .cra_u = { | 345 | .cra_u = { |
347 | .blkcipher = { | 346 | .blkcipher = { |
348 | .min_keysize = TF_MIN_KEY_SIZE, | 347 | .min_keysize = TF_MIN_KEY_SIZE, |
@@ -362,7 +361,6 @@ static struct crypto_alg tf_algs[5] = { { | |||
362 | .cra_alignmask = 0, | 361 | .cra_alignmask = 0, |
363 | .cra_type = &crypto_blkcipher_type, | 362 | .cra_type = &crypto_blkcipher_type, |
364 | .cra_module = THIS_MODULE, | 363 | .cra_module = THIS_MODULE, |
365 | .cra_list = LIST_HEAD_INIT(tf_algs[1].cra_list), | ||
366 | .cra_u = { | 364 | .cra_u = { |
367 | .blkcipher = { | 365 | .blkcipher = { |
368 | .min_keysize = TF_MIN_KEY_SIZE, | 366 | .min_keysize = TF_MIN_KEY_SIZE, |
@@ -383,7 +381,6 @@ static struct crypto_alg tf_algs[5] = { { | |||
383 | .cra_alignmask = 0, | 381 | .cra_alignmask = 0, |
384 | .cra_type = &crypto_blkcipher_type, | 382 | .cra_type = &crypto_blkcipher_type, |
385 | .cra_module = THIS_MODULE, | 383 | .cra_module = THIS_MODULE, |
386 | .cra_list = LIST_HEAD_INIT(tf_algs[2].cra_list), | ||
387 | .cra_u = { | 384 | .cra_u = { |
388 | .blkcipher = { | 385 | .blkcipher = { |
389 | .min_keysize = TF_MIN_KEY_SIZE, | 386 | .min_keysize = TF_MIN_KEY_SIZE, |
@@ -404,7 +401,6 @@ static struct crypto_alg tf_algs[5] = { { | |||
404 | .cra_alignmask = 0, | 401 | .cra_alignmask = 0, |
405 | .cra_type = &crypto_blkcipher_type, | 402 | .cra_type = &crypto_blkcipher_type, |
406 | .cra_module = THIS_MODULE, | 403 | .cra_module = THIS_MODULE, |
407 | .cra_list = LIST_HEAD_INIT(tf_algs[3].cra_list), | ||
408 | .cra_exit = lrw_twofish_exit_tfm, | 404 | .cra_exit = lrw_twofish_exit_tfm, |
409 | .cra_u = { | 405 | .cra_u = { |
410 | .blkcipher = { | 406 | .blkcipher = { |
@@ -426,7 +422,6 @@ static struct crypto_alg tf_algs[5] = { { | |||
426 | .cra_alignmask = 0, | 422 | .cra_alignmask = 0, |
427 | .cra_type = &crypto_blkcipher_type, | 423 | .cra_type = &crypto_blkcipher_type, |
428 | .cra_module = THIS_MODULE, | 424 | .cra_module = THIS_MODULE, |
429 | .cra_list = LIST_HEAD_INIT(tf_algs[4].cra_list), | ||
430 | .cra_u = { | 425 | .cra_u = { |
431 | .blkcipher = { | 426 | .blkcipher = { |
432 | .min_keysize = TF_MIN_KEY_SIZE * 2, | 427 | .min_keysize = TF_MIN_KEY_SIZE * 2, |
diff --git a/crypto/842.c b/crypto/842.c new file mode 100644 index 000000000000..65c7a89cfa09 --- /dev/null +++ b/crypto/842.c | |||
@@ -0,0 +1,182 @@ | |||
1 | /* | ||
2 | * Cryptographic API for the 842 compression algorithm. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | * | ||
18 | * Copyright (C) IBM Corporation, 2011 | ||
19 | * | ||
20 | * Authors: Robert Jennings <rcj@linux.vnet.ibm.com> | ||
21 | * Seth Jennings <sjenning@linux.vnet.ibm.com> | ||
22 | */ | ||
23 | |||
24 | #include <linux/init.h> | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/crypto.h> | ||
27 | #include <linux/vmalloc.h> | ||
28 | #include <linux/nx842.h> | ||
29 | #include <linux/lzo.h> | ||
30 | #include <linux/timer.h> | ||
31 | |||
32 | static int nx842_uselzo; | ||
33 | |||
34 | struct nx842_ctx { | ||
35 | void *nx842_wmem; /* working memory for 842/lzo */ | ||
36 | }; | ||
37 | |||
38 | enum nx842_crypto_type { | ||
39 | NX842_CRYPTO_TYPE_842, | ||
40 | NX842_CRYPTO_TYPE_LZO | ||
41 | }; | ||
42 | |||
43 | #define NX842_SENTINEL 0xdeadbeef | ||
44 | |||
45 | struct nx842_crypto_header { | ||
46 | unsigned int sentinel; /* debug */ | ||
47 | enum nx842_crypto_type type; | ||
48 | }; | ||
49 | |||
50 | static int nx842_init(struct crypto_tfm *tfm) | ||
51 | { | ||
52 | struct nx842_ctx *ctx = crypto_tfm_ctx(tfm); | ||
53 | int wmemsize; | ||
54 | |||
55 | wmemsize = max_t(int, nx842_get_workmem_size(), LZO1X_MEM_COMPRESS); | ||
56 | ctx->nx842_wmem = kmalloc(wmemsize, GFP_NOFS); | ||
57 | if (!ctx->nx842_wmem) | ||
58 | return -ENOMEM; | ||
59 | |||
60 | return 0; | ||
61 | } | ||
62 | |||
63 | static void nx842_exit(struct crypto_tfm *tfm) | ||
64 | { | ||
65 | struct nx842_ctx *ctx = crypto_tfm_ctx(tfm); | ||
66 | |||
67 | kfree(ctx->nx842_wmem); | ||
68 | } | ||
69 | |||
70 | static void nx842_reset_uselzo(unsigned long data) | ||
71 | { | ||
72 | nx842_uselzo = 0; | ||
73 | } | ||
74 | |||
75 | static DEFINE_TIMER(failover_timer, nx842_reset_uselzo, 0, 0); | ||
76 | |||
77 | static int nx842_crypto_compress(struct crypto_tfm *tfm, const u8 *src, | ||
78 | unsigned int slen, u8 *dst, unsigned int *dlen) | ||
79 | { | ||
80 | struct nx842_ctx *ctx = crypto_tfm_ctx(tfm); | ||
81 | struct nx842_crypto_header *hdr; | ||
82 | unsigned int tmp_len = *dlen; | ||
83 | size_t lzodlen; /* needed for lzo */ | ||
84 | int err; | ||
85 | |||
86 | *dlen = 0; | ||
87 | hdr = (struct nx842_crypto_header *)dst; | ||
88 | hdr->sentinel = NX842_SENTINEL; /* debug */ | ||
89 | dst += sizeof(struct nx842_crypto_header); | ||
90 | tmp_len -= sizeof(struct nx842_crypto_header); | ||
91 | lzodlen = tmp_len; | ||
92 | |||
93 | if (likely(!nx842_uselzo)) { | ||
94 | err = nx842_compress(src, slen, dst, &tmp_len, ctx->nx842_wmem); | ||
95 | |||
96 | if (likely(!err)) { | ||
97 | hdr->type = NX842_CRYPTO_TYPE_842; | ||
98 | *dlen = tmp_len + sizeof(struct nx842_crypto_header); | ||
99 | return 0; | ||
100 | } | ||
101 | |||
102 | /* hardware failed */ | ||
103 | nx842_uselzo = 1; | ||
104 | |||
105 | /* set timer to check for hardware again in 1 second */ | ||
106 | mod_timer(&failover_timer, jiffies + msecs_to_jiffies(1000)); | ||
107 | } | ||
108 | |||
109 | /* no hardware, use lzo */ | ||
110 | err = lzo1x_1_compress(src, slen, dst, &lzodlen, ctx->nx842_wmem); | ||
111 | if (err != LZO_E_OK) | ||
112 | return -EINVAL; | ||
113 | |||
114 | hdr->type = NX842_CRYPTO_TYPE_LZO; | ||
115 | *dlen = lzodlen + sizeof(struct nx842_crypto_header); | ||
116 | return 0; | ||
117 | } | ||
118 | |||
119 | static int nx842_crypto_decompress(struct crypto_tfm *tfm, const u8 *src, | ||
120 | unsigned int slen, u8 *dst, unsigned int *dlen) | ||
121 | { | ||
122 | struct nx842_ctx *ctx = crypto_tfm_ctx(tfm); | ||
123 | struct nx842_crypto_header *hdr; | ||
124 | unsigned int tmp_len = *dlen; | ||
125 | size_t lzodlen; /* needed for lzo */ | ||
126 | int err; | ||
127 | |||
128 | *dlen = 0; | ||
129 | hdr = (struct nx842_crypto_header *)src; | ||
130 | |||
131 | if (unlikely(hdr->sentinel != NX842_SENTINEL)) | ||
132 | return -EINVAL; | ||
133 | |||
134 | src += sizeof(struct nx842_crypto_header); | ||
135 | slen -= sizeof(struct nx842_crypto_header); | ||
136 | |||
137 | if (likely(hdr->type == NX842_CRYPTO_TYPE_842)) { | ||
138 | err = nx842_decompress(src, slen, dst, &tmp_len, | ||
139 | ctx->nx842_wmem); | ||
140 | if (err) | ||
141 | return -EINVAL; | ||
142 | *dlen = tmp_len; | ||
143 | } else if (hdr->type == NX842_CRYPTO_TYPE_LZO) { | ||
144 | lzodlen = tmp_len; | ||
145 | err = lzo1x_decompress_safe(src, slen, dst, &lzodlen); | ||
146 | if (err != LZO_E_OK) | ||
147 | return -EINVAL; | ||
148 | *dlen = lzodlen; | ||
149 | } else | ||
150 | return -EINVAL; | ||
151 | |||
152 | return 0; | ||
153 | } | ||
154 | |||
155 | static struct crypto_alg alg = { | ||
156 | .cra_name = "842", | ||
157 | .cra_flags = CRYPTO_ALG_TYPE_COMPRESS, | ||
158 | .cra_ctxsize = sizeof(struct nx842_ctx), | ||
159 | .cra_module = THIS_MODULE, | ||
160 | .cra_init = nx842_init, | ||
161 | .cra_exit = nx842_exit, | ||
162 | .cra_u = { .compress = { | ||
163 | .coa_compress = nx842_crypto_compress, | ||
164 | .coa_decompress = nx842_crypto_decompress } } | ||
165 | }; | ||
166 | |||
167 | static int __init nx842_mod_init(void) | ||
168 | { | ||
169 | del_timer(&failover_timer); | ||
170 | return crypto_register_alg(&alg); | ||
171 | } | ||
172 | |||
173 | static void __exit nx842_mod_exit(void) | ||
174 | { | ||
175 | crypto_unregister_alg(&alg); | ||
176 | } | ||
177 | |||
178 | module_init(nx842_mod_init); | ||
179 | module_exit(nx842_mod_exit); | ||
180 | |||
181 | MODULE_LICENSE("GPL"); | ||
182 | MODULE_DESCRIPTION("842 Compression Algorithm"); | ||
diff --git a/crypto/Kconfig b/crypto/Kconfig index 957cc56ce4b9..50402dc0ea35 100644 --- a/crypto/Kconfig +++ b/crypto/Kconfig | |||
@@ -460,6 +460,15 @@ config CRYPTO_SHA1_SPARC64 | |||
460 | SHA-1 secure hash standard (FIPS 180-1/DFIPS 180-2) implemented | 460 | SHA-1 secure hash standard (FIPS 180-1/DFIPS 180-2) implemented |
461 | using sparc64 crypto instructions, when available. | 461 | using sparc64 crypto instructions, when available. |
462 | 462 | ||
463 | config CRYPTO_SHA1_ARM | ||
464 | tristate "SHA1 digest algorithm (ARM-asm)" | ||
465 | depends on ARM | ||
466 | select CRYPTO_SHA1 | ||
467 | select CRYPTO_HASH | ||
468 | help | ||
469 | SHA-1 secure hash standard (FIPS 180-1/DFIPS 180-2) implemented | ||
470 | using optimized ARM assembler. | ||
471 | |||
463 | config CRYPTO_SHA256 | 472 | config CRYPTO_SHA256 |
464 | tristate "SHA224 and SHA256 digest algorithm" | 473 | tristate "SHA224 and SHA256 digest algorithm" |
465 | select CRYPTO_HASH | 474 | select CRYPTO_HASH |
@@ -609,6 +618,8 @@ config CRYPTO_AES_NI_INTEL | |||
609 | select CRYPTO_CRYPTD | 618 | select CRYPTO_CRYPTD |
610 | select CRYPTO_ABLK_HELPER_X86 | 619 | select CRYPTO_ABLK_HELPER_X86 |
611 | select CRYPTO_ALGAPI | 620 | select CRYPTO_ALGAPI |
621 | select CRYPTO_LRW | ||
622 | select CRYPTO_XTS | ||
612 | help | 623 | help |
613 | Use Intel AES-NI instructions for AES algorithm. | 624 | Use Intel AES-NI instructions for AES algorithm. |
614 | 625 | ||
@@ -661,6 +672,30 @@ config CRYPTO_AES_SPARC64 | |||
661 | for some popular block cipher mode is supported too, including | 672 | for some popular block cipher mode is supported too, including |
662 | ECB and CBC. | 673 | ECB and CBC. |
663 | 674 | ||
675 | config CRYPTO_AES_ARM | ||
676 | tristate "AES cipher algorithms (ARM-asm)" | ||
677 | depends on ARM | ||
678 | select CRYPTO_ALGAPI | ||
679 | select CRYPTO_AES | ||
680 | help | ||
681 | Use optimized AES assembler routines for ARM platforms. | ||
682 | |||
683 | AES cipher algorithms (FIPS-197). AES uses the Rijndael | ||
684 | algorithm. | ||
685 | |||
686 | Rijndael appears to be consistently a very good performer in | ||
687 | both hardware and software across a wide range of computing | ||
688 | environments regardless of its use in feedback or non-feedback | ||
689 | modes. Its key setup time is excellent, and its key agility is | ||
690 | good. Rijndael's very low memory requirements make it very well | ||
691 | suited for restricted-space environments, in which it also | ||
692 | demonstrates excellent performance. Rijndael's operations are | ||
693 | among the easiest to defend against power and timing attacks. | ||
694 | |||
695 | The AES specifies three key sizes: 128, 192 and 256 bits | ||
696 | |||
697 | See <http://csrc.nist.gov/encryption/aes/> for more information. | ||
698 | |||
664 | config CRYPTO_ANUBIS | 699 | config CRYPTO_ANUBIS |
665 | tristate "Anubis cipher algorithm" | 700 | tristate "Anubis cipher algorithm" |
666 | select CRYPTO_ALGAPI | 701 | select CRYPTO_ALGAPI |
@@ -781,6 +816,20 @@ config CRYPTO_CAST5 | |||
781 | The CAST5 encryption algorithm (synonymous with CAST-128) is | 816 | The CAST5 encryption algorithm (synonymous with CAST-128) is |
782 | described in RFC2144. | 817 | described in RFC2144. |
783 | 818 | ||
819 | config CRYPTO_CAST5_AVX_X86_64 | ||
820 | tristate "CAST5 (CAST-128) cipher algorithm (x86_64/AVX)" | ||
821 | depends on X86 && 64BIT | ||
822 | select CRYPTO_ALGAPI | ||
823 | select CRYPTO_CRYPTD | ||
824 | select CRYPTO_ABLK_HELPER_X86 | ||
825 | select CRYPTO_CAST5 | ||
826 | help | ||
827 | The CAST5 encryption algorithm (synonymous with CAST-128) is | ||
828 | described in RFC2144. | ||
829 | |||
830 | This module provides the Cast5 cipher algorithm that processes | ||
831 | sixteen blocks parallel using the AVX instruction set. | ||
832 | |||
784 | config CRYPTO_CAST6 | 833 | config CRYPTO_CAST6 |
785 | tristate "CAST6 (CAST-256) cipher algorithm" | 834 | tristate "CAST6 (CAST-256) cipher algorithm" |
786 | select CRYPTO_ALGAPI | 835 | select CRYPTO_ALGAPI |
@@ -788,6 +837,23 @@ config CRYPTO_CAST6 | |||
788 | The CAST6 encryption algorithm (synonymous with CAST-256) is | 837 | The CAST6 encryption algorithm (synonymous with CAST-256) is |
789 | described in RFC2612. | 838 | described in RFC2612. |
790 | 839 | ||
840 | config CRYPTO_CAST6_AVX_X86_64 | ||
841 | tristate "CAST6 (CAST-256) cipher algorithm (x86_64/AVX)" | ||
842 | depends on X86 && 64BIT | ||
843 | select CRYPTO_ALGAPI | ||
844 | select CRYPTO_CRYPTD | ||
845 | select CRYPTO_ABLK_HELPER_X86 | ||
846 | select CRYPTO_GLUE_HELPER_X86 | ||
847 | select CRYPTO_CAST6 | ||
848 | select CRYPTO_LRW | ||
849 | select CRYPTO_XTS | ||
850 | help | ||
851 | The CAST6 encryption algorithm (synonymous with CAST-256) is | ||
852 | described in RFC2612. | ||
853 | |||
854 | This module provides the Cast6 cipher algorithm that processes | ||
855 | eight blocks parallel using the AVX instruction set. | ||
856 | |||
791 | config CRYPTO_DES | 857 | config CRYPTO_DES |
792 | tristate "DES and Triple DES EDE cipher algorithms" | 858 | tristate "DES and Triple DES EDE cipher algorithms" |
793 | select CRYPTO_ALGAPI | 859 | select CRYPTO_ALGAPI |
@@ -1106,6 +1172,15 @@ config CRYPTO_LZO | |||
1106 | help | 1172 | help |
1107 | This is the LZO algorithm. | 1173 | This is the LZO algorithm. |
1108 | 1174 | ||
1175 | config CRYPTO_842 | ||
1176 | tristate "842 compression algorithm" | ||
1177 | depends on CRYPTO_DEV_NX_COMPRESS | ||
1178 | # 842 uses lzo if the hardware becomes unavailable | ||
1179 | select LZO_COMPRESS | ||
1180 | select LZO_DECOMPRESS | ||
1181 | help | ||
1182 | This is the 842 algorithm. | ||
1183 | |||
1109 | comment "Random Number Generation" | 1184 | comment "Random Number Generation" |
1110 | 1185 | ||
1111 | config CRYPTO_ANSI_CPRNG | 1186 | config CRYPTO_ANSI_CPRNG |
diff --git a/crypto/Makefile b/crypto/Makefile index 30f33d675330..a301ad2b258c 100644 --- a/crypto/Makefile +++ b/crypto/Makefile | |||
@@ -68,8 +68,8 @@ obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o | |||
68 | obj-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o | 68 | obj-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o |
69 | obj-$(CONFIG_CRYPTO_AES) += aes_generic.o | 69 | obj-$(CONFIG_CRYPTO_AES) += aes_generic.o |
70 | obj-$(CONFIG_CRYPTO_CAMELLIA) += camellia_generic.o | 70 | obj-$(CONFIG_CRYPTO_CAMELLIA) += camellia_generic.o |
71 | obj-$(CONFIG_CRYPTO_CAST5) += cast5.o | 71 | obj-$(CONFIG_CRYPTO_CAST5) += cast5_generic.o |
72 | obj-$(CONFIG_CRYPTO_CAST6) += cast6.o | 72 | obj-$(CONFIG_CRYPTO_CAST6) += cast6_generic.o |
73 | obj-$(CONFIG_CRYPTO_ARC4) += arc4.o | 73 | obj-$(CONFIG_CRYPTO_ARC4) += arc4.o |
74 | obj-$(CONFIG_CRYPTO_TEA) += tea.o | 74 | obj-$(CONFIG_CRYPTO_TEA) += tea.o |
75 | obj-$(CONFIG_CRYPTO_KHAZAD) += khazad.o | 75 | obj-$(CONFIG_CRYPTO_KHAZAD) += khazad.o |
@@ -82,6 +82,7 @@ obj-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o | |||
82 | obj-$(CONFIG_CRYPTO_CRC32C) += crc32c.o | 82 | obj-$(CONFIG_CRYPTO_CRC32C) += crc32c.o |
83 | obj-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o | 83 | obj-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o |
84 | obj-$(CONFIG_CRYPTO_LZO) += lzo.o | 84 | obj-$(CONFIG_CRYPTO_LZO) += lzo.o |
85 | obj-$(CONFIG_CRYPTO_842) += 842.o | ||
85 | obj-$(CONFIG_CRYPTO_RNG2) += rng.o | 86 | obj-$(CONFIG_CRYPTO_RNG2) += rng.o |
86 | obj-$(CONFIG_CRYPTO_RNG2) += krng.o | 87 | obj-$(CONFIG_CRYPTO_RNG2) += krng.o |
87 | obj-$(CONFIG_CRYPTO_ANSI_CPRNG) += ansi_cprng.o | 88 | obj-$(CONFIG_CRYPTO_ANSI_CPRNG) += ansi_cprng.o |
diff --git a/crypto/aes_generic.c b/crypto/aes_generic.c index a68c73dae15a..47f2e5c71759 100644 --- a/crypto/aes_generic.c +++ b/crypto/aes_generic.c | |||
@@ -1448,7 +1448,6 @@ static struct crypto_alg aes_alg = { | |||
1448 | .cra_ctxsize = sizeof(struct crypto_aes_ctx), | 1448 | .cra_ctxsize = sizeof(struct crypto_aes_ctx), |
1449 | .cra_alignmask = 3, | 1449 | .cra_alignmask = 3, |
1450 | .cra_module = THIS_MODULE, | 1450 | .cra_module = THIS_MODULE, |
1451 | .cra_list = LIST_HEAD_INIT(aes_alg.cra_list), | ||
1452 | .cra_u = { | 1451 | .cra_u = { |
1453 | .cipher = { | 1452 | .cipher = { |
1454 | .cia_min_keysize = AES_MIN_KEY_SIZE, | 1453 | .cia_min_keysize = AES_MIN_KEY_SIZE, |
diff --git a/crypto/ansi_cprng.c b/crypto/ansi_cprng.c index 6ddd99e6114b..c0bb3778f1ae 100644 --- a/crypto/ansi_cprng.c +++ b/crypto/ansi_cprng.c | |||
@@ -382,26 +382,6 @@ static int cprng_reset(struct crypto_rng *tfm, u8 *seed, unsigned int slen) | |||
382 | return 0; | 382 | return 0; |
383 | } | 383 | } |
384 | 384 | ||
385 | static struct crypto_alg rng_alg = { | ||
386 | .cra_name = "stdrng", | ||
387 | .cra_driver_name = "ansi_cprng", | ||
388 | .cra_priority = 100, | ||
389 | .cra_flags = CRYPTO_ALG_TYPE_RNG, | ||
390 | .cra_ctxsize = sizeof(struct prng_context), | ||
391 | .cra_type = &crypto_rng_type, | ||
392 | .cra_module = THIS_MODULE, | ||
393 | .cra_list = LIST_HEAD_INIT(rng_alg.cra_list), | ||
394 | .cra_init = cprng_init, | ||
395 | .cra_exit = cprng_exit, | ||
396 | .cra_u = { | ||
397 | .rng = { | ||
398 | .rng_make_random = cprng_get_random, | ||
399 | .rng_reset = cprng_reset, | ||
400 | .seedsize = DEFAULT_PRNG_KSZ + 2*DEFAULT_BLK_SZ, | ||
401 | } | ||
402 | } | ||
403 | }; | ||
404 | |||
405 | #ifdef CONFIG_CRYPTO_FIPS | 385 | #ifdef CONFIG_CRYPTO_FIPS |
406 | static int fips_cprng_get_random(struct crypto_rng *tfm, u8 *rdata, | 386 | static int fips_cprng_get_random(struct crypto_rng *tfm, u8 *rdata, |
407 | unsigned int dlen) | 387 | unsigned int dlen) |
@@ -438,8 +418,27 @@ static int fips_cprng_reset(struct crypto_rng *tfm, u8 *seed, unsigned int slen) | |||
438 | out: | 418 | out: |
439 | return rc; | 419 | return rc; |
440 | } | 420 | } |
421 | #endif | ||
441 | 422 | ||
442 | static struct crypto_alg fips_rng_alg = { | 423 | static struct crypto_alg rng_algs[] = { { |
424 | .cra_name = "stdrng", | ||
425 | .cra_driver_name = "ansi_cprng", | ||
426 | .cra_priority = 100, | ||
427 | .cra_flags = CRYPTO_ALG_TYPE_RNG, | ||
428 | .cra_ctxsize = sizeof(struct prng_context), | ||
429 | .cra_type = &crypto_rng_type, | ||
430 | .cra_module = THIS_MODULE, | ||
431 | .cra_init = cprng_init, | ||
432 | .cra_exit = cprng_exit, | ||
433 | .cra_u = { | ||
434 | .rng = { | ||
435 | .rng_make_random = cprng_get_random, | ||
436 | .rng_reset = cprng_reset, | ||
437 | .seedsize = DEFAULT_PRNG_KSZ + 2*DEFAULT_BLK_SZ, | ||
438 | } | ||
439 | } | ||
440 | #ifdef CONFIG_CRYPTO_FIPS | ||
441 | }, { | ||
443 | .cra_name = "fips(ansi_cprng)", | 442 | .cra_name = "fips(ansi_cprng)", |
444 | .cra_driver_name = "fips_ansi_cprng", | 443 | .cra_driver_name = "fips_ansi_cprng", |
445 | .cra_priority = 300, | 444 | .cra_priority = 300, |
@@ -447,7 +446,6 @@ static struct crypto_alg fips_rng_alg = { | |||
447 | .cra_ctxsize = sizeof(struct prng_context), | 446 | .cra_ctxsize = sizeof(struct prng_context), |
448 | .cra_type = &crypto_rng_type, | 447 | .cra_type = &crypto_rng_type, |
449 | .cra_module = THIS_MODULE, | 448 | .cra_module = THIS_MODULE, |
450 | .cra_list = LIST_HEAD_INIT(rng_alg.cra_list), | ||
451 | .cra_init = cprng_init, | 449 | .cra_init = cprng_init, |
452 | .cra_exit = cprng_exit, | 450 | .cra_exit = cprng_exit, |
453 | .cra_u = { | 451 | .cra_u = { |
@@ -457,33 +455,18 @@ static struct crypto_alg fips_rng_alg = { | |||
457 | .seedsize = DEFAULT_PRNG_KSZ + 2*DEFAULT_BLK_SZ, | 455 | .seedsize = DEFAULT_PRNG_KSZ + 2*DEFAULT_BLK_SZ, |
458 | } | 456 | } |
459 | } | 457 | } |
460 | }; | ||
461 | #endif | 458 | #endif |
459 | } }; | ||
462 | 460 | ||
463 | /* Module initalization */ | 461 | /* Module initalization */ |
464 | static int __init prng_mod_init(void) | 462 | static int __init prng_mod_init(void) |
465 | { | 463 | { |
466 | int rc = 0; | 464 | return crypto_register_algs(rng_algs, ARRAY_SIZE(rng_algs)); |
467 | |||
468 | rc = crypto_register_alg(&rng_alg); | ||
469 | #ifdef CONFIG_CRYPTO_FIPS | ||
470 | if (rc) | ||
471 | goto out; | ||
472 | |||
473 | rc = crypto_register_alg(&fips_rng_alg); | ||
474 | |||
475 | out: | ||
476 | #endif | ||
477 | return rc; | ||
478 | } | 465 | } |
479 | 466 | ||
480 | static void __exit prng_mod_fini(void) | 467 | static void __exit prng_mod_fini(void) |
481 | { | 468 | { |
482 | crypto_unregister_alg(&rng_alg); | 469 | crypto_unregister_algs(rng_algs, ARRAY_SIZE(rng_algs)); |
483 | #ifdef CONFIG_CRYPTO_FIPS | ||
484 | crypto_unregister_alg(&fips_rng_alg); | ||
485 | #endif | ||
486 | return; | ||
487 | } | 470 | } |
488 | 471 | ||
489 | MODULE_LICENSE("GPL"); | 472 | MODULE_LICENSE("GPL"); |
diff --git a/crypto/anubis.c b/crypto/anubis.c index 77530d571c96..008c8a4fb67c 100644 --- a/crypto/anubis.c +++ b/crypto/anubis.c | |||
@@ -678,7 +678,6 @@ static struct crypto_alg anubis_alg = { | |||
678 | .cra_ctxsize = sizeof (struct anubis_ctx), | 678 | .cra_ctxsize = sizeof (struct anubis_ctx), |
679 | .cra_alignmask = 3, | 679 | .cra_alignmask = 3, |
680 | .cra_module = THIS_MODULE, | 680 | .cra_module = THIS_MODULE, |
681 | .cra_list = LIST_HEAD_INIT(anubis_alg.cra_list), | ||
682 | .cra_u = { .cipher = { | 681 | .cra_u = { .cipher = { |
683 | .cia_min_keysize = ANUBIS_MIN_KEY_SIZE, | 682 | .cia_min_keysize = ANUBIS_MIN_KEY_SIZE, |
684 | .cia_max_keysize = ANUBIS_MAX_KEY_SIZE, | 683 | .cia_max_keysize = ANUBIS_MAX_KEY_SIZE, |
diff --git a/crypto/blowfish_generic.c b/crypto/blowfish_generic.c index 6f269b5cfa3b..8baf5447d35b 100644 --- a/crypto/blowfish_generic.c +++ b/crypto/blowfish_generic.c | |||
@@ -115,7 +115,6 @@ static struct crypto_alg alg = { | |||
115 | .cra_ctxsize = sizeof(struct bf_ctx), | 115 | .cra_ctxsize = sizeof(struct bf_ctx), |
116 | .cra_alignmask = 3, | 116 | .cra_alignmask = 3, |
117 | .cra_module = THIS_MODULE, | 117 | .cra_module = THIS_MODULE, |
118 | .cra_list = LIST_HEAD_INIT(alg.cra_list), | ||
119 | .cra_u = { .cipher = { | 118 | .cra_u = { .cipher = { |
120 | .cia_min_keysize = BF_MIN_KEY_SIZE, | 119 | .cia_min_keysize = BF_MIN_KEY_SIZE, |
121 | .cia_max_keysize = BF_MAX_KEY_SIZE, | 120 | .cia_max_keysize = BF_MAX_KEY_SIZE, |
diff --git a/crypto/camellia_generic.c b/crypto/camellia_generic.c index f7aaaaf86982..75efa2052305 100644 --- a/crypto/camellia_generic.c +++ b/crypto/camellia_generic.c | |||
@@ -1072,7 +1072,6 @@ static struct crypto_alg camellia_alg = { | |||
1072 | .cra_ctxsize = sizeof(struct camellia_ctx), | 1072 | .cra_ctxsize = sizeof(struct camellia_ctx), |
1073 | .cra_alignmask = 3, | 1073 | .cra_alignmask = 3, |
1074 | .cra_module = THIS_MODULE, | 1074 | .cra_module = THIS_MODULE, |
1075 | .cra_list = LIST_HEAD_INIT(camellia_alg.cra_list), | ||
1076 | .cra_u = { | 1075 | .cra_u = { |
1077 | .cipher = { | 1076 | .cipher = { |
1078 | .cia_min_keysize = CAMELLIA_MIN_KEY_SIZE, | 1077 | .cia_min_keysize = CAMELLIA_MIN_KEY_SIZE, |
diff --git a/crypto/cast5.c b/crypto/cast5_generic.c index 4a230ddec877..bc525dbd8a4b 100644 --- a/crypto/cast5.c +++ b/crypto/cast5_generic.c | |||
@@ -4,8 +4,8 @@ | |||
4 | * Derived from GnuPG implementation of cast5. | 4 | * Derived from GnuPG implementation of cast5. |
5 | * | 5 | * |
6 | * Major Changes. | 6 | * Major Changes. |
7 | * Complete conformance to rfc2144. | 7 | * Complete conformance to rfc2144. |
8 | * Supports key size from 40 to 128 bits. | 8 | * Supports key size from 40 to 128 bits. |
9 | * | 9 | * |
10 | * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. | 10 | * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. |
11 | * Copyright (C) 2003 Kartikey Mahendra Bhatt <kartik_me@hotmail.com>. | 11 | * Copyright (C) 2003 Kartikey Mahendra Bhatt <kartik_me@hotmail.com>. |
@@ -28,19 +28,10 @@ | |||
28 | #include <linux/errno.h> | 28 | #include <linux/errno.h> |
29 | #include <linux/string.h> | 29 | #include <linux/string.h> |
30 | #include <linux/types.h> | 30 | #include <linux/types.h> |
31 | #include <crypto/cast5.h> | ||
31 | 32 | ||
32 | #define CAST5_BLOCK_SIZE 8 | ||
33 | #define CAST5_MIN_KEY_SIZE 5 | ||
34 | #define CAST5_MAX_KEY_SIZE 16 | ||
35 | 33 | ||
36 | struct cast5_ctx { | 34 | const u32 cast5_s1[256] = { |
37 | u32 Km[16]; | ||
38 | u8 Kr[16]; | ||
39 | int rr; /* rr?number of rounds = 16:number of rounds = 12; (rfc 2144) */ | ||
40 | }; | ||
41 | |||
42 | |||
43 | static const u32 s1[256] = { | ||
44 | 0x30fb40d4, 0x9fa0ff0b, 0x6beccd2f, 0x3f258c7a, 0x1e213f2f, | 35 | 0x30fb40d4, 0x9fa0ff0b, 0x6beccd2f, 0x3f258c7a, 0x1e213f2f, |
45 | 0x9c004dd3, 0x6003e540, 0xcf9fc949, | 36 | 0x9c004dd3, 0x6003e540, 0xcf9fc949, |
46 | 0xbfd4af27, 0x88bbbdb5, 0xe2034090, 0x98d09675, 0x6e63a0e0, | 37 | 0xbfd4af27, 0x88bbbdb5, 0xe2034090, 0x98d09675, 0x6e63a0e0, |
@@ -106,7 +97,8 @@ static const u32 s1[256] = { | |||
106 | 0x1a69e783, 0x02cc4843, 0xa2f7c579, 0x429ef47d, 0x427b169c, | 97 | 0x1a69e783, 0x02cc4843, 0xa2f7c579, 0x429ef47d, 0x427b169c, |
107 | 0x5ac9f049, 0xdd8f0f00, 0x5c8165bf | 98 | 0x5ac9f049, 0xdd8f0f00, 0x5c8165bf |
108 | }; | 99 | }; |
109 | static const u32 s2[256] = { | 100 | EXPORT_SYMBOL_GPL(cast5_s1); |
101 | const u32 cast5_s2[256] = { | ||
110 | 0x1f201094, 0xef0ba75b, 0x69e3cf7e, 0x393f4380, 0xfe61cf7a, | 102 | 0x1f201094, 0xef0ba75b, 0x69e3cf7e, 0x393f4380, 0xfe61cf7a, |
111 | 0xeec5207a, 0x55889c94, 0x72fc0651, | 103 | 0xeec5207a, 0x55889c94, 0x72fc0651, |
112 | 0xada7ef79, 0x4e1d7235, 0xd55a63ce, 0xde0436ba, 0x99c430ef, | 104 | 0xada7ef79, 0x4e1d7235, 0xd55a63ce, 0xde0436ba, 0x99c430ef, |
@@ -172,7 +164,8 @@ static const u32 s2[256] = { | |||
172 | 0x43d79572, 0x7e6dd07c, 0x06dfdf1e, 0x6c6cc4ef, 0x7160a539, | 164 | 0x43d79572, 0x7e6dd07c, 0x06dfdf1e, 0x6c6cc4ef, 0x7160a539, |
173 | 0x73bfbe70, 0x83877605, 0x4523ecf1 | 165 | 0x73bfbe70, 0x83877605, 0x4523ecf1 |
174 | }; | 166 | }; |
175 | static const u32 s3[256] = { | 167 | EXPORT_SYMBOL_GPL(cast5_s2); |
168 | const u32 cast5_s3[256] = { | ||
176 | 0x8defc240, 0x25fa5d9f, 0xeb903dbf, 0xe810c907, 0x47607fff, | 169 | 0x8defc240, 0x25fa5d9f, 0xeb903dbf, 0xe810c907, 0x47607fff, |
177 | 0x369fe44b, 0x8c1fc644, 0xaececa90, | 170 | 0x369fe44b, 0x8c1fc644, 0xaececa90, |
178 | 0xbeb1f9bf, 0xeefbcaea, 0xe8cf1950, 0x51df07ae, 0x920e8806, | 171 | 0xbeb1f9bf, 0xeefbcaea, 0xe8cf1950, 0x51df07ae, 0x920e8806, |
@@ -238,7 +231,8 @@ static const u32 s3[256] = { | |||
238 | 0xf7baefd5, 0x4142ed9c, 0xa4315c11, 0x83323ec5, 0xdfef4636, | 231 | 0xf7baefd5, 0x4142ed9c, 0xa4315c11, 0x83323ec5, 0xdfef4636, |
239 | 0xa133c501, 0xe9d3531c, 0xee353783 | 232 | 0xa133c501, 0xe9d3531c, 0xee353783 |
240 | }; | 233 | }; |
241 | static const u32 s4[256] = { | 234 | EXPORT_SYMBOL_GPL(cast5_s3); |
235 | const u32 cast5_s4[256] = { | ||
242 | 0x9db30420, 0x1fb6e9de, 0xa7be7bef, 0xd273a298, 0x4a4f7bdb, | 236 | 0x9db30420, 0x1fb6e9de, 0xa7be7bef, 0xd273a298, 0x4a4f7bdb, |
243 | 0x64ad8c57, 0x85510443, 0xfa020ed1, | 237 | 0x64ad8c57, 0x85510443, 0xfa020ed1, |
244 | 0x7e287aff, 0xe60fb663, 0x095f35a1, 0x79ebf120, 0xfd059d43, | 238 | 0x7e287aff, 0xe60fb663, 0x095f35a1, 0x79ebf120, 0xfd059d43, |
@@ -304,6 +298,7 @@ static const u32 s4[256] = { | |||
304 | 0x7ae5290c, 0x3cb9536b, 0x851e20fe, 0x9833557e, 0x13ecf0b0, | 298 | 0x7ae5290c, 0x3cb9536b, 0x851e20fe, 0x9833557e, 0x13ecf0b0, |
305 | 0xd3ffb372, 0x3f85c5c1, 0x0aef7ed2 | 299 | 0xd3ffb372, 0x3f85c5c1, 0x0aef7ed2 |
306 | }; | 300 | }; |
301 | EXPORT_SYMBOL_GPL(cast5_s4); | ||
307 | static const u32 s5[256] = { | 302 | static const u32 s5[256] = { |
308 | 0x7ec90c04, 0x2c6e74b9, 0x9b0e66df, 0xa6337911, 0xb86a7fff, | 303 | 0x7ec90c04, 0x2c6e74b9, 0x9b0e66df, 0xa6337911, 0xb86a7fff, |
309 | 0x1dd358f5, 0x44dd9d44, 0x1731167f, | 304 | 0x1dd358f5, 0x44dd9d44, 0x1731167f, |
@@ -569,17 +564,21 @@ static const u32 sb8[256] = { | |||
569 | 0xeaee6801, 0x8db2a283, 0xea8bf59e | 564 | 0xeaee6801, 0x8db2a283, 0xea8bf59e |
570 | }; | 565 | }; |
571 | 566 | ||
567 | #define s1 cast5_s1 | ||
568 | #define s2 cast5_s2 | ||
569 | #define s3 cast5_s3 | ||
570 | #define s4 cast5_s4 | ||
571 | |||
572 | #define F1(D, m, r) ((I = ((m) + (D))), (I = rol32(I, (r))), \ | 572 | #define F1(D, m, r) ((I = ((m) + (D))), (I = rol32(I, (r))), \ |
573 | (((s1[I >> 24] ^ s2[(I>>16)&0xff]) - s3[(I>>8)&0xff]) + s4[I&0xff])) | 573 | (((s1[I >> 24] ^ s2[(I>>16)&0xff]) - s3[(I>>8)&0xff]) + s4[I&0xff])) |
574 | #define F2(D, m, r) ((I = ((m) ^ (D))), (I = rol32(I, (r))), \ | 574 | #define F2(D, m, r) ((I = ((m) ^ (D))), (I = rol32(I, (r))), \ |
575 | (((s1[I >> 24] - s2[(I>>16)&0xff]) + s3[(I>>8)&0xff]) ^ s4[I&0xff])) | 575 | (((s1[I >> 24] - s2[(I>>16)&0xff]) + s3[(I>>8)&0xff]) ^ s4[I&0xff])) |
576 | #define F3(D, m, r) ((I = ((m) - (D))), (I = rol32(I, (r))), \ | 576 | #define F3(D, m, r) ((I = ((m) - (D))), (I = rol32(I, (r))), \ |
577 | (((s1[I >> 24] + s2[(I>>16)&0xff]) ^ s3[(I>>8)&0xff]) - s4[I&0xff])) | 577 | (((s1[I >> 24] + s2[(I>>16)&0xff]) ^ s3[(I>>8)&0xff]) - s4[I&0xff])) |
578 | 578 | ||
579 | 579 | ||
580 | static void cast5_encrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) | 580 | void __cast5_encrypt(struct cast5_ctx *c, u8 *outbuf, const u8 *inbuf) |
581 | { | 581 | { |
582 | struct cast5_ctx *c = crypto_tfm_ctx(tfm); | ||
583 | const __be32 *src = (const __be32 *)inbuf; | 582 | const __be32 *src = (const __be32 *)inbuf; |
584 | __be32 *dst = (__be32 *)outbuf; | 583 | __be32 *dst = (__be32 *)outbuf; |
585 | u32 l, r, t; | 584 | u32 l, r, t; |
@@ -628,10 +627,15 @@ static void cast5_encrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) | |||
628 | dst[0] = cpu_to_be32(r); | 627 | dst[0] = cpu_to_be32(r); |
629 | dst[1] = cpu_to_be32(l); | 628 | dst[1] = cpu_to_be32(l); |
630 | } | 629 | } |
630 | EXPORT_SYMBOL_GPL(__cast5_encrypt); | ||
631 | 631 | ||
632 | static void cast5_decrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) | 632 | static void cast5_encrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) |
633 | { | ||
634 | __cast5_encrypt(crypto_tfm_ctx(tfm), outbuf, inbuf); | ||
635 | } | ||
636 | |||
637 | void __cast5_decrypt(struct cast5_ctx *c, u8 *outbuf, const u8 *inbuf) | ||
633 | { | 638 | { |
634 | struct cast5_ctx *c = crypto_tfm_ctx(tfm); | ||
635 | const __be32 *src = (const __be32 *)inbuf; | 639 | const __be32 *src = (const __be32 *)inbuf; |
636 | __be32 *dst = (__be32 *)outbuf; | 640 | __be32 *dst = (__be32 *)outbuf; |
637 | u32 l, r, t; | 641 | u32 l, r, t; |
@@ -667,6 +671,12 @@ static void cast5_decrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) | |||
667 | dst[0] = cpu_to_be32(r); | 671 | dst[0] = cpu_to_be32(r); |
668 | dst[1] = cpu_to_be32(l); | 672 | dst[1] = cpu_to_be32(l); |
669 | } | 673 | } |
674 | EXPORT_SYMBOL_GPL(__cast5_decrypt); | ||
675 | |||
676 | static void cast5_decrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) | ||
677 | { | ||
678 | __cast5_decrypt(crypto_tfm_ctx(tfm), outbuf, inbuf); | ||
679 | } | ||
670 | 680 | ||
671 | static void key_schedule(u32 *x, u32 *z, u32 *k) | 681 | static void key_schedule(u32 *x, u32 *z, u32 *k) |
672 | { | 682 | { |
@@ -743,7 +753,7 @@ static void key_schedule(u32 *x, u32 *z, u32 *k) | |||
743 | } | 753 | } |
744 | 754 | ||
745 | 755 | ||
746 | static int cast5_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned key_len) | 756 | int cast5_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int key_len) |
747 | { | 757 | { |
748 | struct cast5_ctx *c = crypto_tfm_ctx(tfm); | 758 | struct cast5_ctx *c = crypto_tfm_ctx(tfm); |
749 | int i; | 759 | int i; |
@@ -771,20 +781,22 @@ static int cast5_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned key_len) | |||
771 | c->Kr[i] = k[i] & 0x1f; | 781 | c->Kr[i] = k[i] & 0x1f; |
772 | return 0; | 782 | return 0; |
773 | } | 783 | } |
784 | EXPORT_SYMBOL_GPL(cast5_setkey); | ||
774 | 785 | ||
775 | static struct crypto_alg alg = { | 786 | static struct crypto_alg alg = { |
776 | .cra_name = "cast5", | 787 | .cra_name = "cast5", |
777 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, | 788 | .cra_driver_name = "cast5-generic", |
778 | .cra_blocksize = CAST5_BLOCK_SIZE, | 789 | .cra_priority = 100, |
779 | .cra_ctxsize = sizeof(struct cast5_ctx), | 790 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, |
780 | .cra_alignmask = 3, | 791 | .cra_blocksize = CAST5_BLOCK_SIZE, |
781 | .cra_module = THIS_MODULE, | 792 | .cra_ctxsize = sizeof(struct cast5_ctx), |
782 | .cra_list = LIST_HEAD_INIT(alg.cra_list), | 793 | .cra_alignmask = 3, |
783 | .cra_u = { | 794 | .cra_module = THIS_MODULE, |
795 | .cra_u = { | ||
784 | .cipher = { | 796 | .cipher = { |
785 | .cia_min_keysize = CAST5_MIN_KEY_SIZE, | 797 | .cia_min_keysize = CAST5_MIN_KEY_SIZE, |
786 | .cia_max_keysize = CAST5_MAX_KEY_SIZE, | 798 | .cia_max_keysize = CAST5_MAX_KEY_SIZE, |
787 | .cia_setkey = cast5_setkey, | 799 | .cia_setkey = cast5_setkey, |
788 | .cia_encrypt = cast5_encrypt, | 800 | .cia_encrypt = cast5_encrypt, |
789 | .cia_decrypt = cast5_decrypt | 801 | .cia_decrypt = cast5_decrypt |
790 | } | 802 | } |
@@ -806,4 +818,4 @@ module_exit(cast5_mod_fini); | |||
806 | 818 | ||
807 | MODULE_LICENSE("GPL"); | 819 | MODULE_LICENSE("GPL"); |
808 | MODULE_DESCRIPTION("Cast5 Cipher Algorithm"); | 820 | MODULE_DESCRIPTION("Cast5 Cipher Algorithm"); |
809 | 821 | MODULE_ALIAS("cast5"); | |
diff --git a/crypto/cast6.c b/crypto/cast6_generic.c index e0c15a6c7c34..1acd2f1c48fc 100644 --- a/crypto/cast6.c +++ b/crypto/cast6_generic.c | |||
@@ -25,24 +25,21 @@ | |||
25 | #include <linux/errno.h> | 25 | #include <linux/errno.h> |
26 | #include <linux/string.h> | 26 | #include <linux/string.h> |
27 | #include <linux/types.h> | 27 | #include <linux/types.h> |
28 | #include <crypto/cast6.h> | ||
28 | 29 | ||
29 | #define CAST6_BLOCK_SIZE 16 | 30 | #define s1 cast6_s1 |
30 | #define CAST6_MIN_KEY_SIZE 16 | 31 | #define s2 cast6_s2 |
31 | #define CAST6_MAX_KEY_SIZE 32 | 32 | #define s3 cast6_s3 |
32 | 33 | #define s4 cast6_s4 | |
33 | struct cast6_ctx { | ||
34 | u32 Km[12][4]; | ||
35 | u8 Kr[12][4]; | ||
36 | }; | ||
37 | 34 | ||
38 | #define F1(D, r, m) ((I = ((m) + (D))), (I = rol32(I, (r))), \ | 35 | #define F1(D, r, m) ((I = ((m) + (D))), (I = rol32(I, (r))), \ |
39 | (((s1[I >> 24] ^ s2[(I>>16)&0xff]) - s3[(I>>8)&0xff]) + s4[I&0xff])) | 36 | (((s1[I >> 24] ^ s2[(I>>16)&0xff]) - s3[(I>>8)&0xff]) + s4[I&0xff])) |
40 | #define F2(D, r, m) ((I = ((m) ^ (D))), (I = rol32(I, (r))), \ | 37 | #define F2(D, r, m) ((I = ((m) ^ (D))), (I = rol32(I, (r))), \ |
41 | (((s1[I >> 24] - s2[(I>>16)&0xff]) + s3[(I>>8)&0xff]) ^ s4[I&0xff])) | 38 | (((s1[I >> 24] - s2[(I>>16)&0xff]) + s3[(I>>8)&0xff]) ^ s4[I&0xff])) |
42 | #define F3(D, r, m) ((I = ((m) - (D))), (I = rol32(I, (r))), \ | 39 | #define F3(D, r, m) ((I = ((m) - (D))), (I = rol32(I, (r))), \ |
43 | (((s1[I >> 24] + s2[(I>>16)&0xff]) ^ s3[(I>>8)&0xff]) - s4[I&0xff])) | 40 | (((s1[I >> 24] + s2[(I>>16)&0xff]) ^ s3[(I>>8)&0xff]) - s4[I&0xff])) |
44 | 41 | ||
45 | static const u32 s1[256] = { | 42 | const u32 cast6_s1[256] = { |
46 | 0x30fb40d4, 0x9fa0ff0b, 0x6beccd2f, 0x3f258c7a, 0x1e213f2f, | 43 | 0x30fb40d4, 0x9fa0ff0b, 0x6beccd2f, 0x3f258c7a, 0x1e213f2f, |
47 | 0x9c004dd3, 0x6003e540, 0xcf9fc949, | 44 | 0x9c004dd3, 0x6003e540, 0xcf9fc949, |
48 | 0xbfd4af27, 0x88bbbdb5, 0xe2034090, 0x98d09675, 0x6e63a0e0, | 45 | 0xbfd4af27, 0x88bbbdb5, 0xe2034090, 0x98d09675, 0x6e63a0e0, |
@@ -108,8 +105,9 @@ static const u32 s1[256] = { | |||
108 | 0x1a69e783, 0x02cc4843, 0xa2f7c579, 0x429ef47d, 0x427b169c, | 105 | 0x1a69e783, 0x02cc4843, 0xa2f7c579, 0x429ef47d, 0x427b169c, |
109 | 0x5ac9f049, 0xdd8f0f00, 0x5c8165bf | 106 | 0x5ac9f049, 0xdd8f0f00, 0x5c8165bf |
110 | }; | 107 | }; |
108 | EXPORT_SYMBOL_GPL(cast6_s1); | ||
111 | 109 | ||
112 | static const u32 s2[256] = { | 110 | const u32 cast6_s2[256] = { |
113 | 0x1f201094, 0xef0ba75b, 0x69e3cf7e, 0x393f4380, 0xfe61cf7a, | 111 | 0x1f201094, 0xef0ba75b, 0x69e3cf7e, 0x393f4380, 0xfe61cf7a, |
114 | 0xeec5207a, 0x55889c94, 0x72fc0651, | 112 | 0xeec5207a, 0x55889c94, 0x72fc0651, |
115 | 0xada7ef79, 0x4e1d7235, 0xd55a63ce, 0xde0436ba, 0x99c430ef, | 113 | 0xada7ef79, 0x4e1d7235, 0xd55a63ce, 0xde0436ba, 0x99c430ef, |
@@ -175,8 +173,9 @@ static const u32 s2[256] = { | |||
175 | 0x43d79572, 0x7e6dd07c, 0x06dfdf1e, 0x6c6cc4ef, 0x7160a539, | 173 | 0x43d79572, 0x7e6dd07c, 0x06dfdf1e, 0x6c6cc4ef, 0x7160a539, |
176 | 0x73bfbe70, 0x83877605, 0x4523ecf1 | 174 | 0x73bfbe70, 0x83877605, 0x4523ecf1 |
177 | }; | 175 | }; |
176 | EXPORT_SYMBOL_GPL(cast6_s2); | ||
178 | 177 | ||
179 | static const u32 s3[256] = { | 178 | const u32 cast6_s3[256] = { |
180 | 0x8defc240, 0x25fa5d9f, 0xeb903dbf, 0xe810c907, 0x47607fff, | 179 | 0x8defc240, 0x25fa5d9f, 0xeb903dbf, 0xe810c907, 0x47607fff, |
181 | 0x369fe44b, 0x8c1fc644, 0xaececa90, | 180 | 0x369fe44b, 0x8c1fc644, 0xaececa90, |
182 | 0xbeb1f9bf, 0xeefbcaea, 0xe8cf1950, 0x51df07ae, 0x920e8806, | 181 | 0xbeb1f9bf, 0xeefbcaea, 0xe8cf1950, 0x51df07ae, 0x920e8806, |
@@ -242,8 +241,9 @@ static const u32 s3[256] = { | |||
242 | 0xf7baefd5, 0x4142ed9c, 0xa4315c11, 0x83323ec5, 0xdfef4636, | 241 | 0xf7baefd5, 0x4142ed9c, 0xa4315c11, 0x83323ec5, 0xdfef4636, |
243 | 0xa133c501, 0xe9d3531c, 0xee353783 | 242 | 0xa133c501, 0xe9d3531c, 0xee353783 |
244 | }; | 243 | }; |
244 | EXPORT_SYMBOL_GPL(cast6_s3); | ||
245 | 245 | ||
246 | static const u32 s4[256] = { | 246 | const u32 cast6_s4[256] = { |
247 | 0x9db30420, 0x1fb6e9de, 0xa7be7bef, 0xd273a298, 0x4a4f7bdb, | 247 | 0x9db30420, 0x1fb6e9de, 0xa7be7bef, 0xd273a298, 0x4a4f7bdb, |
248 | 0x64ad8c57, 0x85510443, 0xfa020ed1, | 248 | 0x64ad8c57, 0x85510443, 0xfa020ed1, |
249 | 0x7e287aff, 0xe60fb663, 0x095f35a1, 0x79ebf120, 0xfd059d43, | 249 | 0x7e287aff, 0xe60fb663, 0x095f35a1, 0x79ebf120, 0xfd059d43, |
@@ -309,6 +309,7 @@ static const u32 s4[256] = { | |||
309 | 0x7ae5290c, 0x3cb9536b, 0x851e20fe, 0x9833557e, 0x13ecf0b0, | 309 | 0x7ae5290c, 0x3cb9536b, 0x851e20fe, 0x9833557e, 0x13ecf0b0, |
310 | 0xd3ffb372, 0x3f85c5c1, 0x0aef7ed2 | 310 | 0xd3ffb372, 0x3f85c5c1, 0x0aef7ed2 |
311 | }; | 311 | }; |
312 | EXPORT_SYMBOL_GPL(cast6_s4); | ||
312 | 313 | ||
313 | static const u32 Tm[24][8] = { | 314 | static const u32 Tm[24][8] = { |
314 | { 0x5a827999, 0xc95c653a, 0x383650db, 0xa7103c7c, 0x15ea281d, | 315 | { 0x5a827999, 0xc95c653a, 0x383650db, 0xa7103c7c, 0x15ea281d, |
@@ -369,7 +370,7 @@ static const u8 Tr[4][8] = { | |||
369 | }; | 370 | }; |
370 | 371 | ||
371 | /* forward octave */ | 372 | /* forward octave */ |
372 | static void W(u32 *key, unsigned int i) | 373 | static inline void W(u32 *key, unsigned int i) |
373 | { | 374 | { |
374 | u32 I; | 375 | u32 I; |
375 | key[6] ^= F1(key[7], Tr[i % 4][0], Tm[i][0]); | 376 | key[6] ^= F1(key[7], Tr[i % 4][0], Tm[i][0]); |
@@ -382,14 +383,12 @@ static void W(u32 *key, unsigned int i) | |||
382 | key[7] ^= F2(key[0], Tr[i % 4][7], Tm[i][7]); | 383 | key[7] ^= F2(key[0], Tr[i % 4][7], Tm[i][7]); |
383 | } | 384 | } |
384 | 385 | ||
385 | static int cast6_setkey(struct crypto_tfm *tfm, const u8 *in_key, | 386 | int __cast6_setkey(struct cast6_ctx *c, const u8 *in_key, |
386 | unsigned key_len) | 387 | unsigned key_len, u32 *flags) |
387 | { | 388 | { |
388 | int i; | 389 | int i; |
389 | u32 key[8]; | 390 | u32 key[8]; |
390 | __be32 p_key[8]; /* padded key */ | 391 | __be32 p_key[8]; /* padded key */ |
391 | struct cast6_ctx *c = crypto_tfm_ctx(tfm); | ||
392 | u32 *flags = &tfm->crt_flags; | ||
393 | 392 | ||
394 | if (key_len % 4 != 0) { | 393 | if (key_len % 4 != 0) { |
395 | *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; | 394 | *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; |
@@ -425,9 +424,17 @@ static int cast6_setkey(struct crypto_tfm *tfm, const u8 *in_key, | |||
425 | 424 | ||
426 | return 0; | 425 | return 0; |
427 | } | 426 | } |
427 | EXPORT_SYMBOL_GPL(__cast6_setkey); | ||
428 | |||
429 | int cast6_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) | ||
430 | { | ||
431 | return __cast6_setkey(crypto_tfm_ctx(tfm), key, keylen, | ||
432 | &tfm->crt_flags); | ||
433 | } | ||
434 | EXPORT_SYMBOL_GPL(cast6_setkey); | ||
428 | 435 | ||
429 | /*forward quad round*/ | 436 | /*forward quad round*/ |
430 | static void Q(u32 *block, u8 *Kr, u32 *Km) | 437 | static inline void Q(u32 *block, u8 *Kr, u32 *Km) |
431 | { | 438 | { |
432 | u32 I; | 439 | u32 I; |
433 | block[2] ^= F1(block[3], Kr[0], Km[0]); | 440 | block[2] ^= F1(block[3], Kr[0], Km[0]); |
@@ -437,7 +444,7 @@ static void Q(u32 *block, u8 *Kr, u32 *Km) | |||
437 | } | 444 | } |
438 | 445 | ||
439 | /*reverse quad round*/ | 446 | /*reverse quad round*/ |
440 | static void QBAR(u32 *block, u8 *Kr, u32 *Km) | 447 | static inline void QBAR(u32 *block, u8 *Kr, u32 *Km) |
441 | { | 448 | { |
442 | u32 I; | 449 | u32 I; |
443 | block[3] ^= F1(block[0], Kr[3], Km[3]); | 450 | block[3] ^= F1(block[0], Kr[3], Km[3]); |
@@ -446,9 +453,8 @@ static void QBAR(u32 *block, u8 *Kr, u32 *Km) | |||
446 | block[2] ^= F1(block[3], Kr[0], Km[0]); | 453 | block[2] ^= F1(block[3], Kr[0], Km[0]); |
447 | } | 454 | } |
448 | 455 | ||
449 | static void cast6_encrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) | 456 | void __cast6_encrypt(struct cast6_ctx *c, u8 *outbuf, const u8 *inbuf) |
450 | { | 457 | { |
451 | struct cast6_ctx *c = crypto_tfm_ctx(tfm); | ||
452 | const __be32 *src = (const __be32 *)inbuf; | 458 | const __be32 *src = (const __be32 *)inbuf; |
453 | __be32 *dst = (__be32 *)outbuf; | 459 | __be32 *dst = (__be32 *)outbuf; |
454 | u32 block[4]; | 460 | u32 block[4]; |
@@ -478,10 +484,15 @@ static void cast6_encrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) | |||
478 | dst[2] = cpu_to_be32(block[2]); | 484 | dst[2] = cpu_to_be32(block[2]); |
479 | dst[3] = cpu_to_be32(block[3]); | 485 | dst[3] = cpu_to_be32(block[3]); |
480 | } | 486 | } |
487 | EXPORT_SYMBOL_GPL(__cast6_encrypt); | ||
481 | 488 | ||
482 | static void cast6_decrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) | 489 | static void cast6_encrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) |
490 | { | ||
491 | __cast6_encrypt(crypto_tfm_ctx(tfm), outbuf, inbuf); | ||
492 | } | ||
493 | |||
494 | void __cast6_decrypt(struct cast6_ctx *c, u8 *outbuf, const u8 *inbuf) | ||
483 | { | 495 | { |
484 | struct cast6_ctx *c = crypto_tfm_ctx(tfm); | ||
485 | const __be32 *src = (const __be32 *)inbuf; | 496 | const __be32 *src = (const __be32 *)inbuf; |
486 | __be32 *dst = (__be32 *)outbuf; | 497 | __be32 *dst = (__be32 *)outbuf; |
487 | u32 block[4]; | 498 | u32 block[4]; |
@@ -511,15 +522,22 @@ static void cast6_decrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) | |||
511 | dst[2] = cpu_to_be32(block[2]); | 522 | dst[2] = cpu_to_be32(block[2]); |
512 | dst[3] = cpu_to_be32(block[3]); | 523 | dst[3] = cpu_to_be32(block[3]); |
513 | } | 524 | } |
525 | EXPORT_SYMBOL_GPL(__cast6_decrypt); | ||
526 | |||
527 | static void cast6_decrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) | ||
528 | { | ||
529 | __cast6_decrypt(crypto_tfm_ctx(tfm), outbuf, inbuf); | ||
530 | } | ||
514 | 531 | ||
515 | static struct crypto_alg alg = { | 532 | static struct crypto_alg alg = { |
516 | .cra_name = "cast6", | 533 | .cra_name = "cast6", |
534 | .cra_driver_name = "cast6-generic", | ||
535 | .cra_priority = 100, | ||
517 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, | 536 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, |
518 | .cra_blocksize = CAST6_BLOCK_SIZE, | 537 | .cra_blocksize = CAST6_BLOCK_SIZE, |
519 | .cra_ctxsize = sizeof(struct cast6_ctx), | 538 | .cra_ctxsize = sizeof(struct cast6_ctx), |
520 | .cra_alignmask = 3, | 539 | .cra_alignmask = 3, |
521 | .cra_module = THIS_MODULE, | 540 | .cra_module = THIS_MODULE, |
522 | .cra_list = LIST_HEAD_INIT(alg.cra_list), | ||
523 | .cra_u = { | 541 | .cra_u = { |
524 | .cipher = { | 542 | .cipher = { |
525 | .cia_min_keysize = CAST6_MIN_KEY_SIZE, | 543 | .cia_min_keysize = CAST6_MIN_KEY_SIZE, |
@@ -545,3 +563,4 @@ module_exit(cast6_mod_fini); | |||
545 | 563 | ||
546 | MODULE_LICENSE("GPL"); | 564 | MODULE_LICENSE("GPL"); |
547 | MODULE_DESCRIPTION("Cast6 Cipher Algorithm"); | 565 | MODULE_DESCRIPTION("Cast6 Cipher Algorithm"); |
566 | MODULE_ALIAS("cast6"); | ||
diff --git a/crypto/crypto_null.c b/crypto/crypto_null.c index 07a8a96d46fc..fee7265cd35d 100644 --- a/crypto/crypto_null.c +++ b/crypto/crypto_null.c | |||
@@ -94,18 +94,6 @@ static int skcipher_null_crypt(struct blkcipher_desc *desc, | |||
94 | return err; | 94 | return err; |
95 | } | 95 | } |
96 | 96 | ||
97 | static struct crypto_alg compress_null = { | ||
98 | .cra_name = "compress_null", | ||
99 | .cra_flags = CRYPTO_ALG_TYPE_COMPRESS, | ||
100 | .cra_blocksize = NULL_BLOCK_SIZE, | ||
101 | .cra_ctxsize = 0, | ||
102 | .cra_module = THIS_MODULE, | ||
103 | .cra_list = LIST_HEAD_INIT(compress_null.cra_list), | ||
104 | .cra_u = { .compress = { | ||
105 | .coa_compress = null_compress, | ||
106 | .coa_decompress = null_compress } } | ||
107 | }; | ||
108 | |||
109 | static struct shash_alg digest_null = { | 97 | static struct shash_alg digest_null = { |
110 | .digestsize = NULL_DIGEST_SIZE, | 98 | .digestsize = NULL_DIGEST_SIZE, |
111 | .setkey = null_hash_setkey, | 99 | .setkey = null_hash_setkey, |
@@ -122,22 +110,19 @@ static struct shash_alg digest_null = { | |||
122 | } | 110 | } |
123 | }; | 111 | }; |
124 | 112 | ||
125 | static struct crypto_alg cipher_null = { | 113 | static struct crypto_alg null_algs[3] = { { |
126 | .cra_name = "cipher_null", | 114 | .cra_name = "cipher_null", |
127 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, | 115 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, |
128 | .cra_blocksize = NULL_BLOCK_SIZE, | 116 | .cra_blocksize = NULL_BLOCK_SIZE, |
129 | .cra_ctxsize = 0, | 117 | .cra_ctxsize = 0, |
130 | .cra_module = THIS_MODULE, | 118 | .cra_module = THIS_MODULE, |
131 | .cra_list = LIST_HEAD_INIT(cipher_null.cra_list), | ||
132 | .cra_u = { .cipher = { | 119 | .cra_u = { .cipher = { |
133 | .cia_min_keysize = NULL_KEY_SIZE, | 120 | .cia_min_keysize = NULL_KEY_SIZE, |
134 | .cia_max_keysize = NULL_KEY_SIZE, | 121 | .cia_max_keysize = NULL_KEY_SIZE, |
135 | .cia_setkey = null_setkey, | 122 | .cia_setkey = null_setkey, |
136 | .cia_encrypt = null_crypt, | 123 | .cia_encrypt = null_crypt, |
137 | .cia_decrypt = null_crypt } } | 124 | .cia_decrypt = null_crypt } } |
138 | }; | 125 | }, { |
139 | |||
140 | static struct crypto_alg skcipher_null = { | ||
141 | .cra_name = "ecb(cipher_null)", | 126 | .cra_name = "ecb(cipher_null)", |
142 | .cra_driver_name = "ecb-cipher_null", | 127 | .cra_driver_name = "ecb-cipher_null", |
143 | .cra_priority = 100, | 128 | .cra_priority = 100, |
@@ -146,7 +131,6 @@ static struct crypto_alg skcipher_null = { | |||
146 | .cra_type = &crypto_blkcipher_type, | 131 | .cra_type = &crypto_blkcipher_type, |
147 | .cra_ctxsize = 0, | 132 | .cra_ctxsize = 0, |
148 | .cra_module = THIS_MODULE, | 133 | .cra_module = THIS_MODULE, |
149 | .cra_list = LIST_HEAD_INIT(skcipher_null.cra_list), | ||
150 | .cra_u = { .blkcipher = { | 134 | .cra_u = { .blkcipher = { |
151 | .min_keysize = NULL_KEY_SIZE, | 135 | .min_keysize = NULL_KEY_SIZE, |
152 | .max_keysize = NULL_KEY_SIZE, | 136 | .max_keysize = NULL_KEY_SIZE, |
@@ -154,7 +138,16 @@ static struct crypto_alg skcipher_null = { | |||
154 | .setkey = null_setkey, | 138 | .setkey = null_setkey, |
155 | .encrypt = skcipher_null_crypt, | 139 | .encrypt = skcipher_null_crypt, |
156 | .decrypt = skcipher_null_crypt } } | 140 | .decrypt = skcipher_null_crypt } } |
157 | }; | 141 | }, { |
142 | .cra_name = "compress_null", | ||
143 | .cra_flags = CRYPTO_ALG_TYPE_COMPRESS, | ||
144 | .cra_blocksize = NULL_BLOCK_SIZE, | ||
145 | .cra_ctxsize = 0, | ||
146 | .cra_module = THIS_MODULE, | ||
147 | .cra_u = { .compress = { | ||
148 | .coa_compress = null_compress, | ||
149 | .coa_decompress = null_compress } } | ||
150 | } }; | ||
158 | 151 | ||
159 | MODULE_ALIAS("compress_null"); | 152 | MODULE_ALIAS("compress_null"); |
160 | MODULE_ALIAS("digest_null"); | 153 | MODULE_ALIAS("digest_null"); |
@@ -164,40 +157,26 @@ static int __init crypto_null_mod_init(void) | |||
164 | { | 157 | { |
165 | int ret = 0; | 158 | int ret = 0; |
166 | 159 | ||
167 | ret = crypto_register_alg(&cipher_null); | 160 | ret = crypto_register_algs(null_algs, ARRAY_SIZE(null_algs)); |
168 | if (ret < 0) | 161 | if (ret < 0) |
169 | goto out; | 162 | goto out; |
170 | 163 | ||
171 | ret = crypto_register_alg(&skcipher_null); | ||
172 | if (ret < 0) | ||
173 | goto out_unregister_cipher; | ||
174 | |||
175 | ret = crypto_register_shash(&digest_null); | 164 | ret = crypto_register_shash(&digest_null); |
176 | if (ret < 0) | 165 | if (ret < 0) |
177 | goto out_unregister_skcipher; | 166 | goto out_unregister_algs; |
178 | 167 | ||
179 | ret = crypto_register_alg(&compress_null); | 168 | return 0; |
180 | if (ret < 0) | ||
181 | goto out_unregister_digest; | ||
182 | 169 | ||
170 | out_unregister_algs: | ||
171 | crypto_unregister_algs(null_algs, ARRAY_SIZE(null_algs)); | ||
183 | out: | 172 | out: |
184 | return ret; | 173 | return ret; |
185 | |||
186 | out_unregister_digest: | ||
187 | crypto_unregister_shash(&digest_null); | ||
188 | out_unregister_skcipher: | ||
189 | crypto_unregister_alg(&skcipher_null); | ||
190 | out_unregister_cipher: | ||
191 | crypto_unregister_alg(&cipher_null); | ||
192 | goto out; | ||
193 | } | 174 | } |
194 | 175 | ||
195 | static void __exit crypto_null_mod_fini(void) | 176 | static void __exit crypto_null_mod_fini(void) |
196 | { | 177 | { |
197 | crypto_unregister_alg(&compress_null); | ||
198 | crypto_unregister_shash(&digest_null); | 178 | crypto_unregister_shash(&digest_null); |
199 | crypto_unregister_alg(&skcipher_null); | 179 | crypto_unregister_algs(null_algs, ARRAY_SIZE(null_algs)); |
200 | crypto_unregister_alg(&cipher_null); | ||
201 | } | 180 | } |
202 | 181 | ||
203 | module_init(crypto_null_mod_init); | 182 | module_init(crypto_null_mod_init); |
diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c index 6bba414d0c61..35d700a97d79 100644 --- a/crypto/crypto_user.c +++ b/crypto/crypto_user.c | |||
@@ -30,7 +30,7 @@ | |||
30 | 30 | ||
31 | #include "internal.h" | 31 | #include "internal.h" |
32 | 32 | ||
33 | DEFINE_MUTEX(crypto_cfg_mutex); | 33 | static DEFINE_MUTEX(crypto_cfg_mutex); |
34 | 34 | ||
35 | /* The crypto netlink socket */ | 35 | /* The crypto netlink socket */ |
36 | static struct sock *crypto_nlsk; | 36 | static struct sock *crypto_nlsk; |
diff --git a/crypto/deflate.c b/crypto/deflate.c index b0165ecad0c5..b57d70eb156b 100644 --- a/crypto/deflate.c +++ b/crypto/deflate.c | |||
@@ -199,7 +199,6 @@ static struct crypto_alg alg = { | |||
199 | .cra_flags = CRYPTO_ALG_TYPE_COMPRESS, | 199 | .cra_flags = CRYPTO_ALG_TYPE_COMPRESS, |
200 | .cra_ctxsize = sizeof(struct deflate_ctx), | 200 | .cra_ctxsize = sizeof(struct deflate_ctx), |
201 | .cra_module = THIS_MODULE, | 201 | .cra_module = THIS_MODULE, |
202 | .cra_list = LIST_HEAD_INIT(alg.cra_list), | ||
203 | .cra_init = deflate_init, | 202 | .cra_init = deflate_init, |
204 | .cra_exit = deflate_exit, | 203 | .cra_exit = deflate_exit, |
205 | .cra_u = { .compress = { | 204 | .cra_u = { .compress = { |
diff --git a/crypto/des_generic.c b/crypto/des_generic.c index 873818d48e86..f6cf63f88468 100644 --- a/crypto/des_generic.c +++ b/crypto/des_generic.c | |||
@@ -943,59 +943,44 @@ static void des3_ede_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) | |||
943 | d[1] = cpu_to_le32(L); | 943 | d[1] = cpu_to_le32(L); |
944 | } | 944 | } |
945 | 945 | ||
946 | static struct crypto_alg des_alg = { | 946 | static struct crypto_alg des_algs[2] = { { |
947 | .cra_name = "des", | 947 | .cra_name = "des", |
948 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, | 948 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, |
949 | .cra_blocksize = DES_BLOCK_SIZE, | 949 | .cra_blocksize = DES_BLOCK_SIZE, |
950 | .cra_ctxsize = sizeof(struct des_ctx), | 950 | .cra_ctxsize = sizeof(struct des_ctx), |
951 | .cra_module = THIS_MODULE, | 951 | .cra_module = THIS_MODULE, |
952 | .cra_alignmask = 3, | 952 | .cra_alignmask = 3, |
953 | .cra_list = LIST_HEAD_INIT(des_alg.cra_list), | ||
954 | .cra_u = { .cipher = { | 953 | .cra_u = { .cipher = { |
955 | .cia_min_keysize = DES_KEY_SIZE, | 954 | .cia_min_keysize = DES_KEY_SIZE, |
956 | .cia_max_keysize = DES_KEY_SIZE, | 955 | .cia_max_keysize = DES_KEY_SIZE, |
957 | .cia_setkey = des_setkey, | 956 | .cia_setkey = des_setkey, |
958 | .cia_encrypt = des_encrypt, | 957 | .cia_encrypt = des_encrypt, |
959 | .cia_decrypt = des_decrypt } } | 958 | .cia_decrypt = des_decrypt } } |
960 | }; | 959 | }, { |
961 | |||
962 | static struct crypto_alg des3_ede_alg = { | ||
963 | .cra_name = "des3_ede", | 960 | .cra_name = "des3_ede", |
964 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, | 961 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, |
965 | .cra_blocksize = DES3_EDE_BLOCK_SIZE, | 962 | .cra_blocksize = DES3_EDE_BLOCK_SIZE, |
966 | .cra_ctxsize = sizeof(struct des3_ede_ctx), | 963 | .cra_ctxsize = sizeof(struct des3_ede_ctx), |
967 | .cra_module = THIS_MODULE, | 964 | .cra_module = THIS_MODULE, |
968 | .cra_alignmask = 3, | 965 | .cra_alignmask = 3, |
969 | .cra_list = LIST_HEAD_INIT(des3_ede_alg.cra_list), | ||
970 | .cra_u = { .cipher = { | 966 | .cra_u = { .cipher = { |
971 | .cia_min_keysize = DES3_EDE_KEY_SIZE, | 967 | .cia_min_keysize = DES3_EDE_KEY_SIZE, |
972 | .cia_max_keysize = DES3_EDE_KEY_SIZE, | 968 | .cia_max_keysize = DES3_EDE_KEY_SIZE, |
973 | .cia_setkey = des3_ede_setkey, | 969 | .cia_setkey = des3_ede_setkey, |
974 | .cia_encrypt = des3_ede_encrypt, | 970 | .cia_encrypt = des3_ede_encrypt, |
975 | .cia_decrypt = des3_ede_decrypt } } | 971 | .cia_decrypt = des3_ede_decrypt } } |
976 | }; | 972 | } }; |
977 | 973 | ||
978 | MODULE_ALIAS("des3_ede"); | 974 | MODULE_ALIAS("des3_ede"); |
979 | 975 | ||
980 | static int __init des_generic_mod_init(void) | 976 | static int __init des_generic_mod_init(void) |
981 | { | 977 | { |
982 | int ret = 0; | 978 | return crypto_register_algs(des_algs, ARRAY_SIZE(des_algs)); |
983 | |||
984 | ret = crypto_register_alg(&des_alg); | ||
985 | if (ret < 0) | ||
986 | goto out; | ||
987 | |||
988 | ret = crypto_register_alg(&des3_ede_alg); | ||
989 | if (ret < 0) | ||
990 | crypto_unregister_alg(&des_alg); | ||
991 | out: | ||
992 | return ret; | ||
993 | } | 979 | } |
994 | 980 | ||
995 | static void __exit des_generic_mod_fini(void) | 981 | static void __exit des_generic_mod_fini(void) |
996 | { | 982 | { |
997 | crypto_unregister_alg(&des3_ede_alg); | 983 | crypto_unregister_algs(des_algs, ARRAY_SIZE(des_algs)); |
998 | crypto_unregister_alg(&des_alg); | ||
999 | } | 984 | } |
1000 | 985 | ||
1001 | module_init(des_generic_mod_init); | 986 | module_init(des_generic_mod_init); |
diff --git a/crypto/fcrypt.c b/crypto/fcrypt.c index c33107e340b6..3b2cf569c684 100644 --- a/crypto/fcrypt.c +++ b/crypto/fcrypt.c | |||
@@ -396,7 +396,6 @@ static struct crypto_alg fcrypt_alg = { | |||
396 | .cra_ctxsize = sizeof(struct fcrypt_ctx), | 396 | .cra_ctxsize = sizeof(struct fcrypt_ctx), |
397 | .cra_module = THIS_MODULE, | 397 | .cra_module = THIS_MODULE, |
398 | .cra_alignmask = 3, | 398 | .cra_alignmask = 3, |
399 | .cra_list = LIST_HEAD_INIT(fcrypt_alg.cra_list), | ||
400 | .cra_u = { .cipher = { | 399 | .cra_u = { .cipher = { |
401 | .cia_min_keysize = 8, | 400 | .cia_min_keysize = 8, |
402 | .cia_max_keysize = 8, | 401 | .cia_max_keysize = 8, |
diff --git a/crypto/ghash-generic.c b/crypto/ghash-generic.c index 7835b8fc94db..9d3f0c69a86f 100644 --- a/crypto/ghash-generic.c +++ b/crypto/ghash-generic.c | |||
@@ -153,7 +153,6 @@ static struct shash_alg ghash_alg = { | |||
153 | .cra_blocksize = GHASH_BLOCK_SIZE, | 153 | .cra_blocksize = GHASH_BLOCK_SIZE, |
154 | .cra_ctxsize = sizeof(struct ghash_ctx), | 154 | .cra_ctxsize = sizeof(struct ghash_ctx), |
155 | .cra_module = THIS_MODULE, | 155 | .cra_module = THIS_MODULE, |
156 | .cra_list = LIST_HEAD_INIT(ghash_alg.base.cra_list), | ||
157 | .cra_exit = ghash_exit_tfm, | 156 | .cra_exit = ghash_exit_tfm, |
158 | }, | 157 | }, |
159 | }; | 158 | }; |
diff --git a/crypto/khazad.c b/crypto/khazad.c index 527e4e395fc3..60e7cd66facc 100644 --- a/crypto/khazad.c +++ b/crypto/khazad.c | |||
@@ -853,7 +853,6 @@ static struct crypto_alg khazad_alg = { | |||
853 | .cra_ctxsize = sizeof (struct khazad_ctx), | 853 | .cra_ctxsize = sizeof (struct khazad_ctx), |
854 | .cra_alignmask = 7, | 854 | .cra_alignmask = 7, |
855 | .cra_module = THIS_MODULE, | 855 | .cra_module = THIS_MODULE, |
856 | .cra_list = LIST_HEAD_INIT(khazad_alg.cra_list), | ||
857 | .cra_u = { .cipher = { | 856 | .cra_u = { .cipher = { |
858 | .cia_min_keysize = KHAZAD_KEY_SIZE, | 857 | .cia_min_keysize = KHAZAD_KEY_SIZE, |
859 | .cia_max_keysize = KHAZAD_KEY_SIZE, | 858 | .cia_max_keysize = KHAZAD_KEY_SIZE, |
diff --git a/crypto/krng.c b/crypto/krng.c index 4328bb3430ed..a2d2b72fc135 100644 --- a/crypto/krng.c +++ b/crypto/krng.c | |||
@@ -35,7 +35,6 @@ static struct crypto_alg krng_alg = { | |||
35 | .cra_ctxsize = 0, | 35 | .cra_ctxsize = 0, |
36 | .cra_type = &crypto_rng_type, | 36 | .cra_type = &crypto_rng_type, |
37 | .cra_module = THIS_MODULE, | 37 | .cra_module = THIS_MODULE, |
38 | .cra_list = LIST_HEAD_INIT(krng_alg.cra_list), | ||
39 | .cra_u = { | 38 | .cra_u = { |
40 | .rng = { | 39 | .rng = { |
41 | .rng_make_random = krng_get_random, | 40 | .rng_make_random = krng_get_random, |
diff --git a/crypto/lzo.c b/crypto/lzo.c index b5e77077d751..1c2aa69c54b8 100644 --- a/crypto/lzo.c +++ b/crypto/lzo.c | |||
@@ -81,7 +81,6 @@ static struct crypto_alg alg = { | |||
81 | .cra_flags = CRYPTO_ALG_TYPE_COMPRESS, | 81 | .cra_flags = CRYPTO_ALG_TYPE_COMPRESS, |
82 | .cra_ctxsize = sizeof(struct lzo_ctx), | 82 | .cra_ctxsize = sizeof(struct lzo_ctx), |
83 | .cra_module = THIS_MODULE, | 83 | .cra_module = THIS_MODULE, |
84 | .cra_list = LIST_HEAD_INIT(alg.cra_list), | ||
85 | .cra_init = lzo_init, | 84 | .cra_init = lzo_init, |
86 | .cra_exit = lzo_exit, | 85 | .cra_exit = lzo_exit, |
87 | .cra_u = { .compress = { | 86 | .cra_u = { .compress = { |
diff --git a/crypto/salsa20_generic.c b/crypto/salsa20_generic.c index eac10c11685c..9a4770c02284 100644 --- a/crypto/salsa20_generic.c +++ b/crypto/salsa20_generic.c | |||
@@ -221,7 +221,6 @@ static struct crypto_alg alg = { | |||
221 | .cra_ctxsize = sizeof(struct salsa20_ctx), | 221 | .cra_ctxsize = sizeof(struct salsa20_ctx), |
222 | .cra_alignmask = 3, | 222 | .cra_alignmask = 3, |
223 | .cra_module = THIS_MODULE, | 223 | .cra_module = THIS_MODULE, |
224 | .cra_list = LIST_HEAD_INIT(alg.cra_list), | ||
225 | .cra_u = { | 224 | .cra_u = { |
226 | .blkcipher = { | 225 | .blkcipher = { |
227 | .setkey = setkey, | 226 | .setkey = setkey, |
diff --git a/crypto/seed.c b/crypto/seed.c index d3e422f60556..9c904d6d2151 100644 --- a/crypto/seed.c +++ b/crypto/seed.c | |||
@@ -449,7 +449,6 @@ static struct crypto_alg seed_alg = { | |||
449 | .cra_ctxsize = sizeof(struct seed_ctx), | 449 | .cra_ctxsize = sizeof(struct seed_ctx), |
450 | .cra_alignmask = 3, | 450 | .cra_alignmask = 3, |
451 | .cra_module = THIS_MODULE, | 451 | .cra_module = THIS_MODULE, |
452 | .cra_list = LIST_HEAD_INIT(seed_alg.cra_list), | ||
453 | .cra_u = { | 452 | .cra_u = { |
454 | .cipher = { | 453 | .cipher = { |
455 | .cia_min_keysize = SEED_KEY_SIZE, | 454 | .cia_min_keysize = SEED_KEY_SIZE, |
diff --git a/crypto/serpent_generic.c b/crypto/serpent_generic.c index 8f32cf35e5ce..7ddbd7e88859 100644 --- a/crypto/serpent_generic.c +++ b/crypto/serpent_generic.c | |||
@@ -567,24 +567,6 @@ static void serpent_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) | |||
567 | __serpent_decrypt(ctx, dst, src); | 567 | __serpent_decrypt(ctx, dst, src); |
568 | } | 568 | } |
569 | 569 | ||
570 | static struct crypto_alg serpent_alg = { | ||
571 | .cra_name = "serpent", | ||
572 | .cra_driver_name = "serpent-generic", | ||
573 | .cra_priority = 100, | ||
574 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, | ||
575 | .cra_blocksize = SERPENT_BLOCK_SIZE, | ||
576 | .cra_ctxsize = sizeof(struct serpent_ctx), | ||
577 | .cra_alignmask = 3, | ||
578 | .cra_module = THIS_MODULE, | ||
579 | .cra_list = LIST_HEAD_INIT(serpent_alg.cra_list), | ||
580 | .cra_u = { .cipher = { | ||
581 | .cia_min_keysize = SERPENT_MIN_KEY_SIZE, | ||
582 | .cia_max_keysize = SERPENT_MAX_KEY_SIZE, | ||
583 | .cia_setkey = serpent_setkey, | ||
584 | .cia_encrypt = serpent_encrypt, | ||
585 | .cia_decrypt = serpent_decrypt } } | ||
586 | }; | ||
587 | |||
588 | static int tnepres_setkey(struct crypto_tfm *tfm, const u8 *key, | 570 | static int tnepres_setkey(struct crypto_tfm *tfm, const u8 *key, |
589 | unsigned int keylen) | 571 | unsigned int keylen) |
590 | { | 572 | { |
@@ -637,41 +619,44 @@ static void tnepres_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) | |||
637 | d[3] = swab32(rd[0]); | 619 | d[3] = swab32(rd[0]); |
638 | } | 620 | } |
639 | 621 | ||
640 | static struct crypto_alg tnepres_alg = { | 622 | static struct crypto_alg srp_algs[2] = { { |
623 | .cra_name = "serpent", | ||
624 | .cra_driver_name = "serpent-generic", | ||
625 | .cra_priority = 100, | ||
626 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, | ||
627 | .cra_blocksize = SERPENT_BLOCK_SIZE, | ||
628 | .cra_ctxsize = sizeof(struct serpent_ctx), | ||
629 | .cra_alignmask = 3, | ||
630 | .cra_module = THIS_MODULE, | ||
631 | .cra_u = { .cipher = { | ||
632 | .cia_min_keysize = SERPENT_MIN_KEY_SIZE, | ||
633 | .cia_max_keysize = SERPENT_MAX_KEY_SIZE, | ||
634 | .cia_setkey = serpent_setkey, | ||
635 | .cia_encrypt = serpent_encrypt, | ||
636 | .cia_decrypt = serpent_decrypt } } | ||
637 | }, { | ||
641 | .cra_name = "tnepres", | 638 | .cra_name = "tnepres", |
642 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, | 639 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, |
643 | .cra_blocksize = SERPENT_BLOCK_SIZE, | 640 | .cra_blocksize = SERPENT_BLOCK_SIZE, |
644 | .cra_ctxsize = sizeof(struct serpent_ctx), | 641 | .cra_ctxsize = sizeof(struct serpent_ctx), |
645 | .cra_alignmask = 3, | 642 | .cra_alignmask = 3, |
646 | .cra_module = THIS_MODULE, | 643 | .cra_module = THIS_MODULE, |
647 | .cra_list = LIST_HEAD_INIT(serpent_alg.cra_list), | ||
648 | .cra_u = { .cipher = { | 644 | .cra_u = { .cipher = { |
649 | .cia_min_keysize = SERPENT_MIN_KEY_SIZE, | 645 | .cia_min_keysize = SERPENT_MIN_KEY_SIZE, |
650 | .cia_max_keysize = SERPENT_MAX_KEY_SIZE, | 646 | .cia_max_keysize = SERPENT_MAX_KEY_SIZE, |
651 | .cia_setkey = tnepres_setkey, | 647 | .cia_setkey = tnepres_setkey, |
652 | .cia_encrypt = tnepres_encrypt, | 648 | .cia_encrypt = tnepres_encrypt, |
653 | .cia_decrypt = tnepres_decrypt } } | 649 | .cia_decrypt = tnepres_decrypt } } |
654 | }; | 650 | } }; |
655 | 651 | ||
656 | static int __init serpent_mod_init(void) | 652 | static int __init serpent_mod_init(void) |
657 | { | 653 | { |
658 | int ret = crypto_register_alg(&serpent_alg); | 654 | return crypto_register_algs(srp_algs, ARRAY_SIZE(srp_algs)); |
659 | |||
660 | if (ret) | ||
661 | return ret; | ||
662 | |||
663 | ret = crypto_register_alg(&tnepres_alg); | ||
664 | |||
665 | if (ret) | ||
666 | crypto_unregister_alg(&serpent_alg); | ||
667 | |||
668 | return ret; | ||
669 | } | 655 | } |
670 | 656 | ||
671 | static void __exit serpent_mod_fini(void) | 657 | static void __exit serpent_mod_fini(void) |
672 | { | 658 | { |
673 | crypto_unregister_alg(&tnepres_alg); | 659 | crypto_unregister_algs(srp_algs, ARRAY_SIZE(srp_algs)); |
674 | crypto_unregister_alg(&serpent_alg); | ||
675 | } | 660 | } |
676 | 661 | ||
677 | module_init(serpent_mod_init); | 662 | module_init(serpent_mod_init); |
diff --git a/crypto/sha256_generic.c b/crypto/sha256_generic.c index c48459ebf05b..c3ed4ec924e1 100644 --- a/crypto/sha256_generic.c +++ b/crypto/sha256_generic.c | |||
@@ -336,7 +336,7 @@ static int sha256_import(struct shash_desc *desc, const void *in) | |||
336 | return 0; | 336 | return 0; |
337 | } | 337 | } |
338 | 338 | ||
339 | static struct shash_alg sha256 = { | 339 | static struct shash_alg sha256_algs[2] = { { |
340 | .digestsize = SHA256_DIGEST_SIZE, | 340 | .digestsize = SHA256_DIGEST_SIZE, |
341 | .init = sha256_init, | 341 | .init = sha256_init, |
342 | .update = sha256_update, | 342 | .update = sha256_update, |
@@ -352,9 +352,7 @@ static struct shash_alg sha256 = { | |||
352 | .cra_blocksize = SHA256_BLOCK_SIZE, | 352 | .cra_blocksize = SHA256_BLOCK_SIZE, |
353 | .cra_module = THIS_MODULE, | 353 | .cra_module = THIS_MODULE, |
354 | } | 354 | } |
355 | }; | 355 | }, { |
356 | |||
357 | static struct shash_alg sha224 = { | ||
358 | .digestsize = SHA224_DIGEST_SIZE, | 356 | .digestsize = SHA224_DIGEST_SIZE, |
359 | .init = sha224_init, | 357 | .init = sha224_init, |
360 | .update = sha256_update, | 358 | .update = sha256_update, |
@@ -367,29 +365,16 @@ static struct shash_alg sha224 = { | |||
367 | .cra_blocksize = SHA224_BLOCK_SIZE, | 365 | .cra_blocksize = SHA224_BLOCK_SIZE, |
368 | .cra_module = THIS_MODULE, | 366 | .cra_module = THIS_MODULE, |
369 | } | 367 | } |
370 | }; | 368 | } }; |
371 | 369 | ||
372 | static int __init sha256_generic_mod_init(void) | 370 | static int __init sha256_generic_mod_init(void) |
373 | { | 371 | { |
374 | int ret = 0; | 372 | return crypto_register_shashes(sha256_algs, ARRAY_SIZE(sha256_algs)); |
375 | |||
376 | ret = crypto_register_shash(&sha224); | ||
377 | |||
378 | if (ret < 0) | ||
379 | return ret; | ||
380 | |||
381 | ret = crypto_register_shash(&sha256); | ||
382 | |||
383 | if (ret < 0) | ||
384 | crypto_unregister_shash(&sha224); | ||
385 | |||
386 | return ret; | ||
387 | } | 373 | } |
388 | 374 | ||
389 | static void __exit sha256_generic_mod_fini(void) | 375 | static void __exit sha256_generic_mod_fini(void) |
390 | { | 376 | { |
391 | crypto_unregister_shash(&sha224); | 377 | crypto_unregister_shashes(sha256_algs, ARRAY_SIZE(sha256_algs)); |
392 | crypto_unregister_shash(&sha256); | ||
393 | } | 378 | } |
394 | 379 | ||
395 | module_init(sha256_generic_mod_init); | 380 | module_init(sha256_generic_mod_init); |
diff --git a/crypto/sha512_generic.c b/crypto/sha512_generic.c index dd30f40af9f5..71fcf361102d 100644 --- a/crypto/sha512_generic.c +++ b/crypto/sha512_generic.c | |||
@@ -242,7 +242,7 @@ static int sha384_final(struct shash_desc *desc, u8 *hash) | |||
242 | return 0; | 242 | return 0; |
243 | } | 243 | } |
244 | 244 | ||
245 | static struct shash_alg sha512 = { | 245 | static struct shash_alg sha512_algs[2] = { { |
246 | .digestsize = SHA512_DIGEST_SIZE, | 246 | .digestsize = SHA512_DIGEST_SIZE, |
247 | .init = sha512_init, | 247 | .init = sha512_init, |
248 | .update = sha512_update, | 248 | .update = sha512_update, |
@@ -254,9 +254,7 @@ static struct shash_alg sha512 = { | |||
254 | .cra_blocksize = SHA512_BLOCK_SIZE, | 254 | .cra_blocksize = SHA512_BLOCK_SIZE, |
255 | .cra_module = THIS_MODULE, | 255 | .cra_module = THIS_MODULE, |
256 | } | 256 | } |
257 | }; | 257 | }, { |
258 | |||
259 | static struct shash_alg sha384 = { | ||
260 | .digestsize = SHA384_DIGEST_SIZE, | 258 | .digestsize = SHA384_DIGEST_SIZE, |
261 | .init = sha384_init, | 259 | .init = sha384_init, |
262 | .update = sha512_update, | 260 | .update = sha512_update, |
@@ -268,24 +266,16 @@ static struct shash_alg sha384 = { | |||
268 | .cra_blocksize = SHA384_BLOCK_SIZE, | 266 | .cra_blocksize = SHA384_BLOCK_SIZE, |
269 | .cra_module = THIS_MODULE, | 267 | .cra_module = THIS_MODULE, |
270 | } | 268 | } |
271 | }; | 269 | } }; |
272 | 270 | ||
273 | static int __init sha512_generic_mod_init(void) | 271 | static int __init sha512_generic_mod_init(void) |
274 | { | 272 | { |
275 | int ret = 0; | 273 | return crypto_register_shashes(sha512_algs, ARRAY_SIZE(sha512_algs)); |
276 | |||
277 | if ((ret = crypto_register_shash(&sha384)) < 0) | ||
278 | goto out; | ||
279 | if ((ret = crypto_register_shash(&sha512)) < 0) | ||
280 | crypto_unregister_shash(&sha384); | ||
281 | out: | ||
282 | return ret; | ||
283 | } | 274 | } |
284 | 275 | ||
285 | static void __exit sha512_generic_mod_fini(void) | 276 | static void __exit sha512_generic_mod_fini(void) |
286 | { | 277 | { |
287 | crypto_unregister_shash(&sha384); | 278 | crypto_unregister_shashes(sha512_algs, ARRAY_SIZE(sha512_algs)); |
288 | crypto_unregister_shash(&sha512); | ||
289 | } | 279 | } |
290 | 280 | ||
291 | module_init(sha512_generic_mod_init); | 281 | module_init(sha512_generic_mod_init); |
diff --git a/crypto/shash.c b/crypto/shash.c index 32067f47e6c7..f426330f1017 100644 --- a/crypto/shash.c +++ b/crypto/shash.c | |||
@@ -629,6 +629,42 @@ int crypto_unregister_shash(struct shash_alg *alg) | |||
629 | } | 629 | } |
630 | EXPORT_SYMBOL_GPL(crypto_unregister_shash); | 630 | EXPORT_SYMBOL_GPL(crypto_unregister_shash); |
631 | 631 | ||
632 | int crypto_register_shashes(struct shash_alg *algs, int count) | ||
633 | { | ||
634 | int i, ret; | ||
635 | |||
636 | for (i = 0; i < count; i++) { | ||
637 | ret = crypto_register_shash(&algs[i]); | ||
638 | if (ret) | ||
639 | goto err; | ||
640 | } | ||
641 | |||
642 | return 0; | ||
643 | |||
644 | err: | ||
645 | for (--i; i >= 0; --i) | ||
646 | crypto_unregister_shash(&algs[i]); | ||
647 | |||
648 | return ret; | ||
649 | } | ||
650 | EXPORT_SYMBOL_GPL(crypto_register_shashes); | ||
651 | |||
652 | int crypto_unregister_shashes(struct shash_alg *algs, int count) | ||
653 | { | ||
654 | int i, ret; | ||
655 | |||
656 | for (i = count - 1; i >= 0; --i) { | ||
657 | ret = crypto_unregister_shash(&algs[i]); | ||
658 | if (ret) | ||
659 | pr_err("Failed to unregister %s %s: %d\n", | ||
660 | algs[i].base.cra_driver_name, | ||
661 | algs[i].base.cra_name, ret); | ||
662 | } | ||
663 | |||
664 | return 0; | ||
665 | } | ||
666 | EXPORT_SYMBOL_GPL(crypto_unregister_shashes); | ||
667 | |||
632 | int shash_register_instance(struct crypto_template *tmpl, | 668 | int shash_register_instance(struct crypto_template *tmpl, |
633 | struct shash_instance *inst) | 669 | struct shash_instance *inst) |
634 | { | 670 | { |
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index 5cf2ccb1540c..e87fa60f5831 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c | |||
@@ -97,7 +97,6 @@ static int test_cipher_cycles(struct blkcipher_desc *desc, int enc, | |||
97 | int ret = 0; | 97 | int ret = 0; |
98 | int i; | 98 | int i; |
99 | 99 | ||
100 | local_bh_disable(); | ||
101 | local_irq_disable(); | 100 | local_irq_disable(); |
102 | 101 | ||
103 | /* Warm-up run. */ | 102 | /* Warm-up run. */ |
@@ -130,7 +129,6 @@ static int test_cipher_cycles(struct blkcipher_desc *desc, int enc, | |||
130 | 129 | ||
131 | out: | 130 | out: |
132 | local_irq_enable(); | 131 | local_irq_enable(); |
133 | local_bh_enable(); | ||
134 | 132 | ||
135 | if (ret == 0) | 133 | if (ret == 0) |
136 | printk("1 operation in %lu cycles (%d bytes)\n", | 134 | printk("1 operation in %lu cycles (%d bytes)\n", |
@@ -300,7 +298,6 @@ static int test_hash_cycles_digest(struct hash_desc *desc, | |||
300 | int i; | 298 | int i; |
301 | int ret; | 299 | int ret; |
302 | 300 | ||
303 | local_bh_disable(); | ||
304 | local_irq_disable(); | 301 | local_irq_disable(); |
305 | 302 | ||
306 | /* Warm-up run. */ | 303 | /* Warm-up run. */ |
@@ -327,7 +324,6 @@ static int test_hash_cycles_digest(struct hash_desc *desc, | |||
327 | 324 | ||
328 | out: | 325 | out: |
329 | local_irq_enable(); | 326 | local_irq_enable(); |
330 | local_bh_enable(); | ||
331 | 327 | ||
332 | if (ret) | 328 | if (ret) |
333 | return ret; | 329 | return ret; |
@@ -348,7 +344,6 @@ static int test_hash_cycles(struct hash_desc *desc, struct scatterlist *sg, | |||
348 | if (plen == blen) | 344 | if (plen == blen) |
349 | return test_hash_cycles_digest(desc, sg, blen, out); | 345 | return test_hash_cycles_digest(desc, sg, blen, out); |
350 | 346 | ||
351 | local_bh_disable(); | ||
352 | local_irq_disable(); | 347 | local_irq_disable(); |
353 | 348 | ||
354 | /* Warm-up run. */ | 349 | /* Warm-up run. */ |
@@ -391,7 +386,6 @@ static int test_hash_cycles(struct hash_desc *desc, struct scatterlist *sg, | |||
391 | 386 | ||
392 | out: | 387 | out: |
393 | local_irq_enable(); | 388 | local_irq_enable(); |
394 | local_bh_enable(); | ||
395 | 389 | ||
396 | if (ret) | 390 | if (ret) |
397 | return ret; | 391 | return ret; |
@@ -1037,10 +1031,16 @@ static int do_test(int m) | |||
1037 | 1031 | ||
1038 | case 14: | 1032 | case 14: |
1039 | ret += tcrypt_test("ecb(cast5)"); | 1033 | ret += tcrypt_test("ecb(cast5)"); |
1034 | ret += tcrypt_test("cbc(cast5)"); | ||
1035 | ret += tcrypt_test("ctr(cast5)"); | ||
1040 | break; | 1036 | break; |
1041 | 1037 | ||
1042 | case 15: | 1038 | case 15: |
1043 | ret += tcrypt_test("ecb(cast6)"); | 1039 | ret += tcrypt_test("ecb(cast6)"); |
1040 | ret += tcrypt_test("cbc(cast6)"); | ||
1041 | ret += tcrypt_test("ctr(cast6)"); | ||
1042 | ret += tcrypt_test("lrw(cast6)"); | ||
1043 | ret += tcrypt_test("xts(cast6)"); | ||
1044 | break; | 1044 | break; |
1045 | 1045 | ||
1046 | case 16: | 1046 | case 16: |
@@ -1112,6 +1112,9 @@ static int do_test(int m) | |||
1112 | case 32: | 1112 | case 32: |
1113 | ret += tcrypt_test("ecb(camellia)"); | 1113 | ret += tcrypt_test("ecb(camellia)"); |
1114 | ret += tcrypt_test("cbc(camellia)"); | 1114 | ret += tcrypt_test("cbc(camellia)"); |
1115 | ret += tcrypt_test("ctr(camellia)"); | ||
1116 | ret += tcrypt_test("lrw(camellia)"); | ||
1117 | ret += tcrypt_test("xts(camellia)"); | ||
1115 | break; | 1118 | break; |
1116 | case 33: | 1119 | case 33: |
1117 | ret += tcrypt_test("sha224"); | 1120 | ret += tcrypt_test("sha224"); |
@@ -1165,6 +1168,10 @@ static int do_test(int m) | |||
1165 | ret += tcrypt_test("rfc4309(ccm(aes))"); | 1168 | ret += tcrypt_test("rfc4309(ccm(aes))"); |
1166 | break; | 1169 | break; |
1167 | 1170 | ||
1171 | case 46: | ||
1172 | ret += tcrypt_test("ghash"); | ||
1173 | break; | ||
1174 | |||
1168 | case 100: | 1175 | case 100: |
1169 | ret += tcrypt_test("hmac(md5)"); | 1176 | ret += tcrypt_test("hmac(md5)"); |
1170 | break; | 1177 | break; |
@@ -1359,6 +1366,44 @@ static int do_test(int m) | |||
1359 | speed_template_8); | 1366 | speed_template_8); |
1360 | break; | 1367 | break; |
1361 | 1368 | ||
1369 | case 209: | ||
1370 | test_cipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0, | ||
1371 | speed_template_8_16); | ||
1372 | test_cipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0, | ||
1373 | speed_template_8_16); | ||
1374 | test_cipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0, | ||
1375 | speed_template_8_16); | ||
1376 | test_cipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0, | ||
1377 | speed_template_8_16); | ||
1378 | test_cipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0, | ||
1379 | speed_template_8_16); | ||
1380 | test_cipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0, | ||
1381 | speed_template_8_16); | ||
1382 | break; | ||
1383 | |||
1384 | case 210: | ||
1385 | test_cipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0, | ||
1386 | speed_template_16_32); | ||
1387 | test_cipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0, | ||
1388 | speed_template_16_32); | ||
1389 | test_cipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0, | ||
1390 | speed_template_16_32); | ||
1391 | test_cipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0, | ||
1392 | speed_template_16_32); | ||
1393 | test_cipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0, | ||
1394 | speed_template_16_32); | ||
1395 | test_cipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0, | ||
1396 | speed_template_16_32); | ||
1397 | test_cipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0, | ||
1398 | speed_template_32_48); | ||
1399 | test_cipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0, | ||
1400 | speed_template_32_48); | ||
1401 | test_cipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0, | ||
1402 | speed_template_32_64); | ||
1403 | test_cipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0, | ||
1404 | speed_template_32_64); | ||
1405 | break; | ||
1406 | |||
1362 | case 300: | 1407 | case 300: |
1363 | /* fall through */ | 1408 | /* fall through */ |
1364 | 1409 | ||
@@ -1639,6 +1684,44 @@ static int do_test(int m) | |||
1639 | speed_template_8); | 1684 | speed_template_8); |
1640 | break; | 1685 | break; |
1641 | 1686 | ||
1687 | case 506: | ||
1688 | test_acipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0, | ||
1689 | speed_template_8_16); | ||
1690 | test_acipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0, | ||
1691 | speed_template_8_16); | ||
1692 | test_acipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0, | ||
1693 | speed_template_8_16); | ||
1694 | test_acipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0, | ||
1695 | speed_template_8_16); | ||
1696 | test_acipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0, | ||
1697 | speed_template_8_16); | ||
1698 | test_acipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0, | ||
1699 | speed_template_8_16); | ||
1700 | break; | ||
1701 | |||
1702 | case 507: | ||
1703 | test_acipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0, | ||
1704 | speed_template_16_32); | ||
1705 | test_acipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0, | ||
1706 | speed_template_16_32); | ||
1707 | test_acipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0, | ||
1708 | speed_template_16_32); | ||
1709 | test_acipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0, | ||
1710 | speed_template_16_32); | ||
1711 | test_acipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0, | ||
1712 | speed_template_16_32); | ||
1713 | test_acipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0, | ||
1714 | speed_template_16_32); | ||
1715 | test_acipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0, | ||
1716 | speed_template_32_48); | ||
1717 | test_acipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0, | ||
1718 | speed_template_32_48); | ||
1719 | test_acipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0, | ||
1720 | speed_template_32_64); | ||
1721 | test_acipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0, | ||
1722 | speed_template_32_64); | ||
1723 | break; | ||
1724 | |||
1642 | case 1000: | 1725 | case 1000: |
1643 | test_available(); | 1726 | test_available(); |
1644 | break; | 1727 | break; |
diff --git a/crypto/tcrypt.h b/crypto/tcrypt.h index 5be1fc8c1ab3..cd2068524f3f 100644 --- a/crypto/tcrypt.h +++ b/crypto/tcrypt.h | |||
@@ -47,6 +47,7 @@ static struct cipher_speed_template des3_speed_template[] = { | |||
47 | */ | 47 | */ |
48 | static u8 speed_template_8[] = {8, 0}; | 48 | static u8 speed_template_8[] = {8, 0}; |
49 | static u8 speed_template_24[] = {24, 0}; | 49 | static u8 speed_template_24[] = {24, 0}; |
50 | static u8 speed_template_8_16[] = {8, 16, 0}; | ||
50 | static u8 speed_template_8_32[] = {8, 32, 0}; | 51 | static u8 speed_template_8_32[] = {8, 32, 0}; |
51 | static u8 speed_template_16_32[] = {16, 32, 0}; | 52 | static u8 speed_template_16_32[] = {16, 32, 0}; |
52 | static u8 speed_template_16_24_32[] = {16, 24, 32, 0}; | 53 | static u8 speed_template_16_24_32[] = {16, 24, 32, 0}; |
diff --git a/crypto/tea.c b/crypto/tea.c index 412bc74f8179..0a572323ee4a 100644 --- a/crypto/tea.c +++ b/crypto/tea.c | |||
@@ -219,84 +219,55 @@ static void xeta_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) | |||
219 | out[1] = cpu_to_le32(z); | 219 | out[1] = cpu_to_le32(z); |
220 | } | 220 | } |
221 | 221 | ||
222 | static struct crypto_alg tea_alg = { | 222 | static struct crypto_alg tea_algs[3] = { { |
223 | .cra_name = "tea", | 223 | .cra_name = "tea", |
224 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, | 224 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, |
225 | .cra_blocksize = TEA_BLOCK_SIZE, | 225 | .cra_blocksize = TEA_BLOCK_SIZE, |
226 | .cra_ctxsize = sizeof (struct tea_ctx), | 226 | .cra_ctxsize = sizeof (struct tea_ctx), |
227 | .cra_alignmask = 3, | 227 | .cra_alignmask = 3, |
228 | .cra_module = THIS_MODULE, | 228 | .cra_module = THIS_MODULE, |
229 | .cra_list = LIST_HEAD_INIT(tea_alg.cra_list), | ||
230 | .cra_u = { .cipher = { | 229 | .cra_u = { .cipher = { |
231 | .cia_min_keysize = TEA_KEY_SIZE, | 230 | .cia_min_keysize = TEA_KEY_SIZE, |
232 | .cia_max_keysize = TEA_KEY_SIZE, | 231 | .cia_max_keysize = TEA_KEY_SIZE, |
233 | .cia_setkey = tea_setkey, | 232 | .cia_setkey = tea_setkey, |
234 | .cia_encrypt = tea_encrypt, | 233 | .cia_encrypt = tea_encrypt, |
235 | .cia_decrypt = tea_decrypt } } | 234 | .cia_decrypt = tea_decrypt } } |
236 | }; | 235 | }, { |
237 | |||
238 | static struct crypto_alg xtea_alg = { | ||
239 | .cra_name = "xtea", | 236 | .cra_name = "xtea", |
240 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, | 237 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, |
241 | .cra_blocksize = XTEA_BLOCK_SIZE, | 238 | .cra_blocksize = XTEA_BLOCK_SIZE, |
242 | .cra_ctxsize = sizeof (struct xtea_ctx), | 239 | .cra_ctxsize = sizeof (struct xtea_ctx), |
243 | .cra_alignmask = 3, | 240 | .cra_alignmask = 3, |
244 | .cra_module = THIS_MODULE, | 241 | .cra_module = THIS_MODULE, |
245 | .cra_list = LIST_HEAD_INIT(xtea_alg.cra_list), | ||
246 | .cra_u = { .cipher = { | 242 | .cra_u = { .cipher = { |
247 | .cia_min_keysize = XTEA_KEY_SIZE, | 243 | .cia_min_keysize = XTEA_KEY_SIZE, |
248 | .cia_max_keysize = XTEA_KEY_SIZE, | 244 | .cia_max_keysize = XTEA_KEY_SIZE, |
249 | .cia_setkey = xtea_setkey, | 245 | .cia_setkey = xtea_setkey, |
250 | .cia_encrypt = xtea_encrypt, | 246 | .cia_encrypt = xtea_encrypt, |
251 | .cia_decrypt = xtea_decrypt } } | 247 | .cia_decrypt = xtea_decrypt } } |
252 | }; | 248 | }, { |
253 | |||
254 | static struct crypto_alg xeta_alg = { | ||
255 | .cra_name = "xeta", | 249 | .cra_name = "xeta", |
256 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, | 250 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, |
257 | .cra_blocksize = XTEA_BLOCK_SIZE, | 251 | .cra_blocksize = XTEA_BLOCK_SIZE, |
258 | .cra_ctxsize = sizeof (struct xtea_ctx), | 252 | .cra_ctxsize = sizeof (struct xtea_ctx), |
259 | .cra_alignmask = 3, | 253 | .cra_alignmask = 3, |
260 | .cra_module = THIS_MODULE, | 254 | .cra_module = THIS_MODULE, |
261 | .cra_list = LIST_HEAD_INIT(xtea_alg.cra_list), | ||
262 | .cra_u = { .cipher = { | 255 | .cra_u = { .cipher = { |
263 | .cia_min_keysize = XTEA_KEY_SIZE, | 256 | .cia_min_keysize = XTEA_KEY_SIZE, |
264 | .cia_max_keysize = XTEA_KEY_SIZE, | 257 | .cia_max_keysize = XTEA_KEY_SIZE, |
265 | .cia_setkey = xtea_setkey, | 258 | .cia_setkey = xtea_setkey, |
266 | .cia_encrypt = xeta_encrypt, | 259 | .cia_encrypt = xeta_encrypt, |
267 | .cia_decrypt = xeta_decrypt } } | 260 | .cia_decrypt = xeta_decrypt } } |
268 | }; | 261 | } }; |
269 | 262 | ||
270 | static int __init tea_mod_init(void) | 263 | static int __init tea_mod_init(void) |
271 | { | 264 | { |
272 | int ret = 0; | 265 | return crypto_register_algs(tea_algs, ARRAY_SIZE(tea_algs)); |
273 | |||
274 | ret = crypto_register_alg(&tea_alg); | ||
275 | if (ret < 0) | ||
276 | goto out; | ||
277 | |||
278 | ret = crypto_register_alg(&xtea_alg); | ||
279 | if (ret < 0) { | ||
280 | crypto_unregister_alg(&tea_alg); | ||
281 | goto out; | ||
282 | } | ||
283 | |||
284 | ret = crypto_register_alg(&xeta_alg); | ||
285 | if (ret < 0) { | ||
286 | crypto_unregister_alg(&tea_alg); | ||
287 | crypto_unregister_alg(&xtea_alg); | ||
288 | goto out; | ||
289 | } | ||
290 | |||
291 | out: | ||
292 | return ret; | ||
293 | } | 266 | } |
294 | 267 | ||
295 | static void __exit tea_mod_fini(void) | 268 | static void __exit tea_mod_fini(void) |
296 | { | 269 | { |
297 | crypto_unregister_alg(&tea_alg); | 270 | crypto_unregister_algs(tea_algs, ARRAY_SIZE(tea_algs)); |
298 | crypto_unregister_alg(&xtea_alg); | ||
299 | crypto_unregister_alg(&xeta_alg); | ||
300 | } | 271 | } |
301 | 272 | ||
302 | MODULE_ALIAS("xtea"); | 273 | MODULE_ALIAS("xtea"); |
diff --git a/crypto/testmgr.c b/crypto/testmgr.c index a2ca7431760a..941d75cd1f7c 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c | |||
@@ -358,8 +358,9 @@ out_nobuf: | |||
358 | return ret; | 358 | return ret; |
359 | } | 359 | } |
360 | 360 | ||
361 | static int test_aead(struct crypto_aead *tfm, int enc, | 361 | static int __test_aead(struct crypto_aead *tfm, int enc, |
362 | struct aead_testvec *template, unsigned int tcount) | 362 | struct aead_testvec *template, unsigned int tcount, |
363 | const bool diff_dst) | ||
363 | { | 364 | { |
364 | const char *algo = crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)); | 365 | const char *algo = crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)); |
365 | unsigned int i, j, k, n, temp; | 366 | unsigned int i, j, k, n, temp; |
@@ -367,15 +368,18 @@ static int test_aead(struct crypto_aead *tfm, int enc, | |||
367 | char *q; | 368 | char *q; |
368 | char *key; | 369 | char *key; |
369 | struct aead_request *req; | 370 | struct aead_request *req; |
370 | struct scatterlist sg[8]; | 371 | struct scatterlist *sg; |
371 | struct scatterlist asg[8]; | 372 | struct scatterlist *asg; |
372 | const char *e; | 373 | struct scatterlist *sgout; |
374 | const char *e, *d; | ||
373 | struct tcrypt_result result; | 375 | struct tcrypt_result result; |
374 | unsigned int authsize; | 376 | unsigned int authsize; |
375 | void *input; | 377 | void *input; |
378 | void *output; | ||
376 | void *assoc; | 379 | void *assoc; |
377 | char iv[MAX_IVLEN]; | 380 | char iv[MAX_IVLEN]; |
378 | char *xbuf[XBUFSIZE]; | 381 | char *xbuf[XBUFSIZE]; |
382 | char *xoutbuf[XBUFSIZE]; | ||
379 | char *axbuf[XBUFSIZE]; | 383 | char *axbuf[XBUFSIZE]; |
380 | 384 | ||
381 | if (testmgr_alloc_buf(xbuf)) | 385 | if (testmgr_alloc_buf(xbuf)) |
@@ -383,6 +387,21 @@ static int test_aead(struct crypto_aead *tfm, int enc, | |||
383 | if (testmgr_alloc_buf(axbuf)) | 387 | if (testmgr_alloc_buf(axbuf)) |
384 | goto out_noaxbuf; | 388 | goto out_noaxbuf; |
385 | 389 | ||
390 | if (diff_dst && testmgr_alloc_buf(xoutbuf)) | ||
391 | goto out_nooutbuf; | ||
392 | |||
393 | /* avoid "the frame size is larger than 1024 bytes" compiler warning */ | ||
394 | sg = kmalloc(sizeof(*sg) * 8 * (diff_dst ? 3 : 2), GFP_KERNEL); | ||
395 | if (!sg) | ||
396 | goto out_nosg; | ||
397 | asg = &sg[8]; | ||
398 | sgout = &asg[8]; | ||
399 | |||
400 | if (diff_dst) | ||
401 | d = "-ddst"; | ||
402 | else | ||
403 | d = ""; | ||
404 | |||
386 | if (enc == ENCRYPT) | 405 | if (enc == ENCRYPT) |
387 | e = "encryption"; | 406 | e = "encryption"; |
388 | else | 407 | else |
@@ -392,8 +411,8 @@ static int test_aead(struct crypto_aead *tfm, int enc, | |||
392 | 411 | ||
393 | req = aead_request_alloc(tfm, GFP_KERNEL); | 412 | req = aead_request_alloc(tfm, GFP_KERNEL); |
394 | if (!req) { | 413 | if (!req) { |
395 | printk(KERN_ERR "alg: aead: Failed to allocate request for " | 414 | pr_err("alg: aead%s: Failed to allocate request for %s\n", |
396 | "%s\n", algo); | 415 | d, algo); |
397 | goto out; | 416 | goto out; |
398 | } | 417 | } |
399 | 418 | ||
@@ -432,9 +451,8 @@ static int test_aead(struct crypto_aead *tfm, int enc, | |||
432 | ret = crypto_aead_setkey(tfm, key, | 451 | ret = crypto_aead_setkey(tfm, key, |
433 | template[i].klen); | 452 | template[i].klen); |
434 | if (!ret == template[i].fail) { | 453 | if (!ret == template[i].fail) { |
435 | printk(KERN_ERR "alg: aead: setkey failed on " | 454 | pr_err("alg: aead%s: setkey failed on test %d for %s: flags=%x\n", |
436 | "test %d for %s: flags=%x\n", j, algo, | 455 | d, j, algo, crypto_aead_get_flags(tfm)); |
437 | crypto_aead_get_flags(tfm)); | ||
438 | goto out; | 456 | goto out; |
439 | } else if (ret) | 457 | } else if (ret) |
440 | continue; | 458 | continue; |
@@ -442,18 +460,26 @@ static int test_aead(struct crypto_aead *tfm, int enc, | |||
442 | authsize = abs(template[i].rlen - template[i].ilen); | 460 | authsize = abs(template[i].rlen - template[i].ilen); |
443 | ret = crypto_aead_setauthsize(tfm, authsize); | 461 | ret = crypto_aead_setauthsize(tfm, authsize); |
444 | if (ret) { | 462 | if (ret) { |
445 | printk(KERN_ERR "alg: aead: Failed to set " | 463 | pr_err("alg: aead%s: Failed to set authsize to %u on test %d for %s\n", |
446 | "authsize to %u on test %d for %s\n", | 464 | d, authsize, j, algo); |
447 | authsize, j, algo); | ||
448 | goto out; | 465 | goto out; |
449 | } | 466 | } |
450 | 467 | ||
451 | sg_init_one(&sg[0], input, | 468 | sg_init_one(&sg[0], input, |
452 | template[i].ilen + (enc ? authsize : 0)); | 469 | template[i].ilen + (enc ? authsize : 0)); |
453 | 470 | ||
471 | if (diff_dst) { | ||
472 | output = xoutbuf[0]; | ||
473 | sg_init_one(&sgout[0], output, | ||
474 | template[i].ilen + | ||
475 | (enc ? authsize : 0)); | ||
476 | } else { | ||
477 | output = input; | ||
478 | } | ||
479 | |||
454 | sg_init_one(&asg[0], assoc, template[i].alen); | 480 | sg_init_one(&asg[0], assoc, template[i].alen); |
455 | 481 | ||
456 | aead_request_set_crypt(req, sg, sg, | 482 | aead_request_set_crypt(req, sg, (diff_dst) ? sgout : sg, |
457 | template[i].ilen, iv); | 483 | template[i].ilen, iv); |
458 | 484 | ||
459 | aead_request_set_assoc(req, asg, template[i].alen); | 485 | aead_request_set_assoc(req, asg, template[i].alen); |
@@ -466,10 +492,8 @@ static int test_aead(struct crypto_aead *tfm, int enc, | |||
466 | case 0: | 492 | case 0: |
467 | if (template[i].novrfy) { | 493 | if (template[i].novrfy) { |
468 | /* verification was supposed to fail */ | 494 | /* verification was supposed to fail */ |
469 | printk(KERN_ERR "alg: aead: %s failed " | 495 | pr_err("alg: aead%s: %s failed on test %d for %s: ret was 0, expected -EBADMSG\n", |
470 | "on test %d for %s: ret was 0, " | 496 | d, e, j, algo); |
471 | "expected -EBADMSG\n", | ||
472 | e, j, algo); | ||
473 | /* so really, we got a bad message */ | 497 | /* so really, we got a bad message */ |
474 | ret = -EBADMSG; | 498 | ret = -EBADMSG; |
475 | goto out; | 499 | goto out; |
@@ -489,15 +513,15 @@ static int test_aead(struct crypto_aead *tfm, int enc, | |||
489 | continue; | 513 | continue; |
490 | /* fall through */ | 514 | /* fall through */ |
491 | default: | 515 | default: |
492 | printk(KERN_ERR "alg: aead: %s failed on test " | 516 | pr_err("alg: aead%s: %s failed on test %d for %s: ret=%d\n", |
493 | "%d for %s: ret=%d\n", e, j, algo, -ret); | 517 | d, e, j, algo, -ret); |
494 | goto out; | 518 | goto out; |
495 | } | 519 | } |
496 | 520 | ||
497 | q = input; | 521 | q = output; |
498 | if (memcmp(q, template[i].result, template[i].rlen)) { | 522 | if (memcmp(q, template[i].result, template[i].rlen)) { |
499 | printk(KERN_ERR "alg: aead: Test %d failed on " | 523 | pr_err("alg: aead%s: Test %d failed on %s for %s\n", |
500 | "%s for %s\n", j, e, algo); | 524 | d, j, e, algo); |
501 | hexdump(q, template[i].rlen); | 525 | hexdump(q, template[i].rlen); |
502 | ret = -EINVAL; | 526 | ret = -EINVAL; |
503 | goto out; | 527 | goto out; |
@@ -522,9 +546,8 @@ static int test_aead(struct crypto_aead *tfm, int enc, | |||
522 | 546 | ||
523 | ret = crypto_aead_setkey(tfm, key, template[i].klen); | 547 | ret = crypto_aead_setkey(tfm, key, template[i].klen); |
524 | if (!ret == template[i].fail) { | 548 | if (!ret == template[i].fail) { |
525 | printk(KERN_ERR "alg: aead: setkey failed on " | 549 | pr_err("alg: aead%s: setkey failed on chunk test %d for %s: flags=%x\n", |
526 | "chunk test %d for %s: flags=%x\n", j, | 550 | d, j, algo, crypto_aead_get_flags(tfm)); |
527 | algo, crypto_aead_get_flags(tfm)); | ||
528 | goto out; | 551 | goto out; |
529 | } else if (ret) | 552 | } else if (ret) |
530 | continue; | 553 | continue; |
@@ -533,6 +556,8 @@ static int test_aead(struct crypto_aead *tfm, int enc, | |||
533 | 556 | ||
534 | ret = -EINVAL; | 557 | ret = -EINVAL; |
535 | sg_init_table(sg, template[i].np); | 558 | sg_init_table(sg, template[i].np); |
559 | if (diff_dst) | ||
560 | sg_init_table(sgout, template[i].np); | ||
536 | for (k = 0, temp = 0; k < template[i].np; k++) { | 561 | for (k = 0, temp = 0; k < template[i].np; k++) { |
537 | if (WARN_ON(offset_in_page(IDX[k]) + | 562 | if (WARN_ON(offset_in_page(IDX[k]) + |
538 | template[i].tap[k] > PAGE_SIZE)) | 563 | template[i].tap[k] > PAGE_SIZE)) |
@@ -551,14 +576,26 @@ static int test_aead(struct crypto_aead *tfm, int enc, | |||
551 | q[n] = 0; | 576 | q[n] = 0; |
552 | 577 | ||
553 | sg_set_buf(&sg[k], q, template[i].tap[k]); | 578 | sg_set_buf(&sg[k], q, template[i].tap[k]); |
579 | |||
580 | if (diff_dst) { | ||
581 | q = xoutbuf[IDX[k] >> PAGE_SHIFT] + | ||
582 | offset_in_page(IDX[k]); | ||
583 | |||
584 | memset(q, 0, template[i].tap[k]); | ||
585 | if (offset_in_page(q) + n < PAGE_SIZE) | ||
586 | q[n] = 0; | ||
587 | |||
588 | sg_set_buf(&sgout[k], q, | ||
589 | template[i].tap[k]); | ||
590 | } | ||
591 | |||
554 | temp += template[i].tap[k]; | 592 | temp += template[i].tap[k]; |
555 | } | 593 | } |
556 | 594 | ||
557 | ret = crypto_aead_setauthsize(tfm, authsize); | 595 | ret = crypto_aead_setauthsize(tfm, authsize); |
558 | if (ret) { | 596 | if (ret) { |
559 | printk(KERN_ERR "alg: aead: Failed to set " | 597 | pr_err("alg: aead%s: Failed to set authsize to %u on chunk test %d for %s\n", |
560 | "authsize to %u on chunk test %d for " | 598 | d, authsize, j, algo); |
561 | "%s\n", authsize, j, algo); | ||
562 | goto out; | 599 | goto out; |
563 | } | 600 | } |
564 | 601 | ||
@@ -571,6 +608,9 @@ static int test_aead(struct crypto_aead *tfm, int enc, | |||
571 | } | 608 | } |
572 | 609 | ||
573 | sg[k - 1].length += authsize; | 610 | sg[k - 1].length += authsize; |
611 | |||
612 | if (diff_dst) | ||
613 | sgout[k - 1].length += authsize; | ||
574 | } | 614 | } |
575 | 615 | ||
576 | sg_init_table(asg, template[i].anp); | 616 | sg_init_table(asg, template[i].anp); |
@@ -588,7 +628,7 @@ static int test_aead(struct crypto_aead *tfm, int enc, | |||
588 | temp += template[i].atap[k]; | 628 | temp += template[i].atap[k]; |
589 | } | 629 | } |
590 | 630 | ||
591 | aead_request_set_crypt(req, sg, sg, | 631 | aead_request_set_crypt(req, sg, (diff_dst) ? sgout : sg, |
592 | template[i].ilen, | 632 | template[i].ilen, |
593 | iv); | 633 | iv); |
594 | 634 | ||
@@ -602,10 +642,8 @@ static int test_aead(struct crypto_aead *tfm, int enc, | |||
602 | case 0: | 642 | case 0: |
603 | if (template[i].novrfy) { | 643 | if (template[i].novrfy) { |
604 | /* verification was supposed to fail */ | 644 | /* verification was supposed to fail */ |
605 | printk(KERN_ERR "alg: aead: %s failed " | 645 | pr_err("alg: aead%s: %s failed on chunk test %d for %s: ret was 0, expected -EBADMSG\n", |
606 | "on chunk test %d for %s: ret " | 646 | d, e, j, algo); |
607 | "was 0, expected -EBADMSG\n", | ||
608 | e, j, algo); | ||
609 | /* so really, we got a bad message */ | 647 | /* so really, we got a bad message */ |
610 | ret = -EBADMSG; | 648 | ret = -EBADMSG; |
611 | goto out; | 649 | goto out; |
@@ -625,32 +663,35 @@ static int test_aead(struct crypto_aead *tfm, int enc, | |||
625 | continue; | 663 | continue; |
626 | /* fall through */ | 664 | /* fall through */ |
627 | default: | 665 | default: |
628 | printk(KERN_ERR "alg: aead: %s failed on " | 666 | pr_err("alg: aead%s: %s failed on chunk test %d for %s: ret=%d\n", |
629 | "chunk test %d for %s: ret=%d\n", e, j, | 667 | d, e, j, algo, -ret); |
630 | algo, -ret); | ||
631 | goto out; | 668 | goto out; |
632 | } | 669 | } |
633 | 670 | ||
634 | ret = -EINVAL; | 671 | ret = -EINVAL; |
635 | for (k = 0, temp = 0; k < template[i].np; k++) { | 672 | for (k = 0, temp = 0; k < template[i].np; k++) { |
636 | q = xbuf[IDX[k] >> PAGE_SHIFT] + | 673 | if (diff_dst) |
637 | offset_in_page(IDX[k]); | 674 | q = xoutbuf[IDX[k] >> PAGE_SHIFT] + |
675 | offset_in_page(IDX[k]); | ||
676 | else | ||
677 | q = xbuf[IDX[k] >> PAGE_SHIFT] + | ||
678 | offset_in_page(IDX[k]); | ||
638 | 679 | ||
639 | n = template[i].tap[k]; | 680 | n = template[i].tap[k]; |
640 | if (k == template[i].np - 1) | 681 | if (k == template[i].np - 1) |
641 | n += enc ? authsize : -authsize; | 682 | n += enc ? authsize : -authsize; |
642 | 683 | ||
643 | if (memcmp(q, template[i].result + temp, n)) { | 684 | if (memcmp(q, template[i].result + temp, n)) { |
644 | printk(KERN_ERR "alg: aead: Chunk " | 685 | pr_err("alg: aead%s: Chunk test %d failed on %s at page %u for %s\n", |
645 | "test %d failed on %s at page " | 686 | d, j, e, k, algo); |
646 | "%u for %s\n", j, e, k, algo); | ||
647 | hexdump(q, n); | 687 | hexdump(q, n); |
648 | goto out; | 688 | goto out; |
649 | } | 689 | } |
650 | 690 | ||
651 | q += n; | 691 | q += n; |
652 | if (k == template[i].np - 1 && !enc) { | 692 | if (k == template[i].np - 1 && !enc) { |
653 | if (memcmp(q, template[i].input + | 693 | if (!diff_dst && |
694 | memcmp(q, template[i].input + | ||
654 | temp + n, authsize)) | 695 | temp + n, authsize)) |
655 | n = authsize; | 696 | n = authsize; |
656 | else | 697 | else |
@@ -661,11 +702,8 @@ static int test_aead(struct crypto_aead *tfm, int enc, | |||
661 | ; | 702 | ; |
662 | } | 703 | } |
663 | if (n) { | 704 | if (n) { |
664 | printk(KERN_ERR "alg: aead: Result " | 705 | pr_err("alg: aead%s: Result buffer corruption in chunk test %d on %s at page %u for %s: %u bytes:\n", |
665 | "buffer corruption in chunk " | 706 | d, j, e, k, algo, n); |
666 | "test %d on %s at page %u for " | ||
667 | "%s: %u bytes:\n", j, e, k, | ||
668 | algo, n); | ||
669 | hexdump(q, n); | 707 | hexdump(q, n); |
670 | goto out; | 708 | goto out; |
671 | } | 709 | } |
@@ -679,6 +717,11 @@ static int test_aead(struct crypto_aead *tfm, int enc, | |||
679 | 717 | ||
680 | out: | 718 | out: |
681 | aead_request_free(req); | 719 | aead_request_free(req); |
720 | kfree(sg); | ||
721 | out_nosg: | ||
722 | if (diff_dst) | ||
723 | testmgr_free_buf(xoutbuf); | ||
724 | out_nooutbuf: | ||
682 | testmgr_free_buf(axbuf); | 725 | testmgr_free_buf(axbuf); |
683 | out_noaxbuf: | 726 | out_noaxbuf: |
684 | testmgr_free_buf(xbuf); | 727 | testmgr_free_buf(xbuf); |
@@ -686,6 +729,20 @@ out_noxbuf: | |||
686 | return ret; | 729 | return ret; |
687 | } | 730 | } |
688 | 731 | ||
732 | static int test_aead(struct crypto_aead *tfm, int enc, | ||
733 | struct aead_testvec *template, unsigned int tcount) | ||
734 | { | ||
735 | int ret; | ||
736 | |||
737 | /* test 'dst == src' case */ | ||
738 | ret = __test_aead(tfm, enc, template, tcount, false); | ||
739 | if (ret) | ||
740 | return ret; | ||
741 | |||
742 | /* test 'dst != src' case */ | ||
743 | return __test_aead(tfm, enc, template, tcount, true); | ||
744 | } | ||
745 | |||
689 | static int test_cipher(struct crypto_cipher *tfm, int enc, | 746 | static int test_cipher(struct crypto_cipher *tfm, int enc, |
690 | struct cipher_testvec *template, unsigned int tcount) | 747 | struct cipher_testvec *template, unsigned int tcount) |
691 | { | 748 | { |
@@ -761,8 +818,9 @@ out_nobuf: | |||
761 | return ret; | 818 | return ret; |
762 | } | 819 | } |
763 | 820 | ||
764 | static int test_skcipher(struct crypto_ablkcipher *tfm, int enc, | 821 | static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc, |
765 | struct cipher_testvec *template, unsigned int tcount) | 822 | struct cipher_testvec *template, unsigned int tcount, |
823 | const bool diff_dst) | ||
766 | { | 824 | { |
767 | const char *algo = | 825 | const char *algo = |
768 | crypto_tfm_alg_driver_name(crypto_ablkcipher_tfm(tfm)); | 826 | crypto_tfm_alg_driver_name(crypto_ablkcipher_tfm(tfm)); |
@@ -770,16 +828,26 @@ static int test_skcipher(struct crypto_ablkcipher *tfm, int enc, | |||
770 | char *q; | 828 | char *q; |
771 | struct ablkcipher_request *req; | 829 | struct ablkcipher_request *req; |
772 | struct scatterlist sg[8]; | 830 | struct scatterlist sg[8]; |
773 | const char *e; | 831 | struct scatterlist sgout[8]; |
832 | const char *e, *d; | ||
774 | struct tcrypt_result result; | 833 | struct tcrypt_result result; |
775 | void *data; | 834 | void *data; |
776 | char iv[MAX_IVLEN]; | 835 | char iv[MAX_IVLEN]; |
777 | char *xbuf[XBUFSIZE]; | 836 | char *xbuf[XBUFSIZE]; |
837 | char *xoutbuf[XBUFSIZE]; | ||
778 | int ret = -ENOMEM; | 838 | int ret = -ENOMEM; |
779 | 839 | ||
780 | if (testmgr_alloc_buf(xbuf)) | 840 | if (testmgr_alloc_buf(xbuf)) |
781 | goto out_nobuf; | 841 | goto out_nobuf; |
782 | 842 | ||
843 | if (diff_dst && testmgr_alloc_buf(xoutbuf)) | ||
844 | goto out_nooutbuf; | ||
845 | |||
846 | if (diff_dst) | ||
847 | d = "-ddst"; | ||
848 | else | ||
849 | d = ""; | ||
850 | |||
783 | if (enc == ENCRYPT) | 851 | if (enc == ENCRYPT) |
784 | e = "encryption"; | 852 | e = "encryption"; |
785 | else | 853 | else |
@@ -789,8 +857,8 @@ static int test_skcipher(struct crypto_ablkcipher *tfm, int enc, | |||
789 | 857 | ||
790 | req = ablkcipher_request_alloc(tfm, GFP_KERNEL); | 858 | req = ablkcipher_request_alloc(tfm, GFP_KERNEL); |
791 | if (!req) { | 859 | if (!req) { |
792 | printk(KERN_ERR "alg: skcipher: Failed to allocate request " | 860 | pr_err("alg: skcipher%s: Failed to allocate request for %s\n", |
793 | "for %s\n", algo); | 861 | d, algo); |
794 | goto out; | 862 | goto out; |
795 | } | 863 | } |
796 | 864 | ||
@@ -804,7 +872,7 @@ static int test_skcipher(struct crypto_ablkcipher *tfm, int enc, | |||
804 | else | 872 | else |
805 | memset(iv, 0, MAX_IVLEN); | 873 | memset(iv, 0, MAX_IVLEN); |
806 | 874 | ||
807 | if (!(template[i].np)) { | 875 | if (!(template[i].np) || (template[i].also_non_np)) { |
808 | j++; | 876 | j++; |
809 | 877 | ||
810 | ret = -EINVAL; | 878 | ret = -EINVAL; |
@@ -822,16 +890,21 @@ static int test_skcipher(struct crypto_ablkcipher *tfm, int enc, | |||
822 | ret = crypto_ablkcipher_setkey(tfm, template[i].key, | 890 | ret = crypto_ablkcipher_setkey(tfm, template[i].key, |
823 | template[i].klen); | 891 | template[i].klen); |
824 | if (!ret == template[i].fail) { | 892 | if (!ret == template[i].fail) { |
825 | printk(KERN_ERR "alg: skcipher: setkey failed " | 893 | pr_err("alg: skcipher%s: setkey failed on test %d for %s: flags=%x\n", |
826 | "on test %d for %s: flags=%x\n", j, | 894 | d, j, algo, |
827 | algo, crypto_ablkcipher_get_flags(tfm)); | 895 | crypto_ablkcipher_get_flags(tfm)); |
828 | goto out; | 896 | goto out; |
829 | } else if (ret) | 897 | } else if (ret) |
830 | continue; | 898 | continue; |
831 | 899 | ||
832 | sg_init_one(&sg[0], data, template[i].ilen); | 900 | sg_init_one(&sg[0], data, template[i].ilen); |
901 | if (diff_dst) { | ||
902 | data = xoutbuf[0]; | ||
903 | sg_init_one(&sgout[0], data, template[i].ilen); | ||
904 | } | ||
833 | 905 | ||
834 | ablkcipher_request_set_crypt(req, sg, sg, | 906 | ablkcipher_request_set_crypt(req, sg, |
907 | (diff_dst) ? sgout : sg, | ||
835 | template[i].ilen, iv); | 908 | template[i].ilen, iv); |
836 | ret = enc ? | 909 | ret = enc ? |
837 | crypto_ablkcipher_encrypt(req) : | 910 | crypto_ablkcipher_encrypt(req) : |
@@ -850,16 +923,15 @@ static int test_skcipher(struct crypto_ablkcipher *tfm, int enc, | |||
850 | } | 923 | } |
851 | /* fall through */ | 924 | /* fall through */ |
852 | default: | 925 | default: |
853 | printk(KERN_ERR "alg: skcipher: %s failed on " | 926 | pr_err("alg: skcipher%s: %s failed on test %d for %s: ret=%d\n", |
854 | "test %d for %s: ret=%d\n", e, j, algo, | 927 | d, e, j, algo, -ret); |
855 | -ret); | ||
856 | goto out; | 928 | goto out; |
857 | } | 929 | } |
858 | 930 | ||
859 | q = data; | 931 | q = data; |
860 | if (memcmp(q, template[i].result, template[i].rlen)) { | 932 | if (memcmp(q, template[i].result, template[i].rlen)) { |
861 | printk(KERN_ERR "alg: skcipher: Test %d " | 933 | pr_err("alg: skcipher%s: Test %d failed on %s for %s\n", |
862 | "failed on %s for %s\n", j, e, algo); | 934 | d, j, e, algo); |
863 | hexdump(q, template[i].rlen); | 935 | hexdump(q, template[i].rlen); |
864 | ret = -EINVAL; | 936 | ret = -EINVAL; |
865 | goto out; | 937 | goto out; |
@@ -886,9 +958,8 @@ static int test_skcipher(struct crypto_ablkcipher *tfm, int enc, | |||
886 | ret = crypto_ablkcipher_setkey(tfm, template[i].key, | 958 | ret = crypto_ablkcipher_setkey(tfm, template[i].key, |
887 | template[i].klen); | 959 | template[i].klen); |
888 | if (!ret == template[i].fail) { | 960 | if (!ret == template[i].fail) { |
889 | printk(KERN_ERR "alg: skcipher: setkey failed " | 961 | pr_err("alg: skcipher%s: setkey failed on chunk test %d for %s: flags=%x\n", |
890 | "on chunk test %d for %s: flags=%x\n", | 962 | d, j, algo, |
891 | j, algo, | ||
892 | crypto_ablkcipher_get_flags(tfm)); | 963 | crypto_ablkcipher_get_flags(tfm)); |
893 | goto out; | 964 | goto out; |
894 | } else if (ret) | 965 | } else if (ret) |
@@ -897,6 +968,8 @@ static int test_skcipher(struct crypto_ablkcipher *tfm, int enc, | |||
897 | temp = 0; | 968 | temp = 0; |
898 | ret = -EINVAL; | 969 | ret = -EINVAL; |
899 | sg_init_table(sg, template[i].np); | 970 | sg_init_table(sg, template[i].np); |
971 | if (diff_dst) | ||
972 | sg_init_table(sgout, template[i].np); | ||
900 | for (k = 0; k < template[i].np; k++) { | 973 | for (k = 0; k < template[i].np; k++) { |
901 | if (WARN_ON(offset_in_page(IDX[k]) + | 974 | if (WARN_ON(offset_in_page(IDX[k]) + |
902 | template[i].tap[k] > PAGE_SIZE)) | 975 | template[i].tap[k] > PAGE_SIZE)) |
@@ -913,11 +986,24 @@ static int test_skcipher(struct crypto_ablkcipher *tfm, int enc, | |||
913 | q[template[i].tap[k]] = 0; | 986 | q[template[i].tap[k]] = 0; |
914 | 987 | ||
915 | sg_set_buf(&sg[k], q, template[i].tap[k]); | 988 | sg_set_buf(&sg[k], q, template[i].tap[k]); |
989 | if (diff_dst) { | ||
990 | q = xoutbuf[IDX[k] >> PAGE_SHIFT] + | ||
991 | offset_in_page(IDX[k]); | ||
992 | |||
993 | sg_set_buf(&sgout[k], q, | ||
994 | template[i].tap[k]); | ||
995 | |||
996 | memset(q, 0, template[i].tap[k]); | ||
997 | if (offset_in_page(q) + | ||
998 | template[i].tap[k] < PAGE_SIZE) | ||
999 | q[template[i].tap[k]] = 0; | ||
1000 | } | ||
916 | 1001 | ||
917 | temp += template[i].tap[k]; | 1002 | temp += template[i].tap[k]; |
918 | } | 1003 | } |
919 | 1004 | ||
920 | ablkcipher_request_set_crypt(req, sg, sg, | 1005 | ablkcipher_request_set_crypt(req, sg, |
1006 | (diff_dst) ? sgout : sg, | ||
921 | template[i].ilen, iv); | 1007 | template[i].ilen, iv); |
922 | 1008 | ||
923 | ret = enc ? | 1009 | ret = enc ? |
@@ -937,23 +1023,25 @@ static int test_skcipher(struct crypto_ablkcipher *tfm, int enc, | |||
937 | } | 1023 | } |
938 | /* fall through */ | 1024 | /* fall through */ |
939 | default: | 1025 | default: |
940 | printk(KERN_ERR "alg: skcipher: %s failed on " | 1026 | pr_err("alg: skcipher%s: %s failed on chunk test %d for %s: ret=%d\n", |
941 | "chunk test %d for %s: ret=%d\n", e, j, | 1027 | d, e, j, algo, -ret); |
942 | algo, -ret); | ||
943 | goto out; | 1028 | goto out; |
944 | } | 1029 | } |
945 | 1030 | ||
946 | temp = 0; | 1031 | temp = 0; |
947 | ret = -EINVAL; | 1032 | ret = -EINVAL; |
948 | for (k = 0; k < template[i].np; k++) { | 1033 | for (k = 0; k < template[i].np; k++) { |
949 | q = xbuf[IDX[k] >> PAGE_SHIFT] + | 1034 | if (diff_dst) |
950 | offset_in_page(IDX[k]); | 1035 | q = xoutbuf[IDX[k] >> PAGE_SHIFT] + |
1036 | offset_in_page(IDX[k]); | ||
1037 | else | ||
1038 | q = xbuf[IDX[k] >> PAGE_SHIFT] + | ||
1039 | offset_in_page(IDX[k]); | ||
951 | 1040 | ||
952 | if (memcmp(q, template[i].result + temp, | 1041 | if (memcmp(q, template[i].result + temp, |
953 | template[i].tap[k])) { | 1042 | template[i].tap[k])) { |
954 | printk(KERN_ERR "alg: skcipher: Chunk " | 1043 | pr_err("alg: skcipher%s: Chunk test %d failed on %s at page %u for %s\n", |
955 | "test %d failed on %s at page " | 1044 | d, j, e, k, algo); |
956 | "%u for %s\n", j, e, k, algo); | ||
957 | hexdump(q, template[i].tap[k]); | 1045 | hexdump(q, template[i].tap[k]); |
958 | goto out; | 1046 | goto out; |
959 | } | 1047 | } |
@@ -962,11 +1050,8 @@ static int test_skcipher(struct crypto_ablkcipher *tfm, int enc, | |||
962 | for (n = 0; offset_in_page(q + n) && q[n]; n++) | 1050 | for (n = 0; offset_in_page(q + n) && q[n]; n++) |
963 | ; | 1051 | ; |
964 | if (n) { | 1052 | if (n) { |
965 | printk(KERN_ERR "alg: skcipher: " | 1053 | pr_err("alg: skcipher%s: Result buffer corruption in chunk test %d on %s at page %u for %s: %u bytes:\n", |
966 | "Result buffer corruption in " | 1054 | d, j, e, k, algo, n); |
967 | "chunk test %d on %s at page " | ||
968 | "%u for %s: %u bytes:\n", j, e, | ||
969 | k, algo, n); | ||
970 | hexdump(q, n); | 1055 | hexdump(q, n); |
971 | goto out; | 1056 | goto out; |
972 | } | 1057 | } |
@@ -979,11 +1064,28 @@ static int test_skcipher(struct crypto_ablkcipher *tfm, int enc, | |||
979 | 1064 | ||
980 | out: | 1065 | out: |
981 | ablkcipher_request_free(req); | 1066 | ablkcipher_request_free(req); |
1067 | if (diff_dst) | ||
1068 | testmgr_free_buf(xoutbuf); | ||
1069 | out_nooutbuf: | ||
982 | testmgr_free_buf(xbuf); | 1070 | testmgr_free_buf(xbuf); |
983 | out_nobuf: | 1071 | out_nobuf: |
984 | return ret; | 1072 | return ret; |
985 | } | 1073 | } |
986 | 1074 | ||
1075 | static int test_skcipher(struct crypto_ablkcipher *tfm, int enc, | ||
1076 | struct cipher_testvec *template, unsigned int tcount) | ||
1077 | { | ||
1078 | int ret; | ||
1079 | |||
1080 | /* test 'dst == src' case */ | ||
1081 | ret = __test_skcipher(tfm, enc, template, tcount, false); | ||
1082 | if (ret) | ||
1083 | return ret; | ||
1084 | |||
1085 | /* test 'dst != src' case */ | ||
1086 | return __test_skcipher(tfm, enc, template, tcount, true); | ||
1087 | } | ||
1088 | |||
987 | static int test_comp(struct crypto_comp *tfm, struct comp_testvec *ctemplate, | 1089 | static int test_comp(struct crypto_comp *tfm, struct comp_testvec *ctemplate, |
988 | struct comp_testvec *dtemplate, int ctcount, int dtcount) | 1090 | struct comp_testvec *dtemplate, int ctcount, int dtcount) |
989 | { | 1091 | { |
@@ -1534,6 +1636,36 @@ static int alg_test_null(const struct alg_test_desc *desc, | |||
1534 | /* Please keep this list sorted by algorithm name. */ | 1636 | /* Please keep this list sorted by algorithm name. */ |
1535 | static const struct alg_test_desc alg_test_descs[] = { | 1637 | static const struct alg_test_desc alg_test_descs[] = { |
1536 | { | 1638 | { |
1639 | .alg = "__cbc-cast5-avx", | ||
1640 | .test = alg_test_null, | ||
1641 | .suite = { | ||
1642 | .cipher = { | ||
1643 | .enc = { | ||
1644 | .vecs = NULL, | ||
1645 | .count = 0 | ||
1646 | }, | ||
1647 | .dec = { | ||
1648 | .vecs = NULL, | ||
1649 | .count = 0 | ||
1650 | } | ||
1651 | } | ||
1652 | } | ||
1653 | }, { | ||
1654 | .alg = "__cbc-cast6-avx", | ||
1655 | .test = alg_test_null, | ||
1656 | .suite = { | ||
1657 | .cipher = { | ||
1658 | .enc = { | ||
1659 | .vecs = NULL, | ||
1660 | .count = 0 | ||
1661 | }, | ||
1662 | .dec = { | ||
1663 | .vecs = NULL, | ||
1664 | .count = 0 | ||
1665 | } | ||
1666 | } | ||
1667 | } | ||
1668 | }, { | ||
1537 | .alg = "__cbc-serpent-avx", | 1669 | .alg = "__cbc-serpent-avx", |
1538 | .test = alg_test_null, | 1670 | .test = alg_test_null, |
1539 | .suite = { | 1671 | .suite = { |
@@ -1595,6 +1727,36 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1595 | } | 1727 | } |
1596 | } | 1728 | } |
1597 | }, { | 1729 | }, { |
1730 | .alg = "__driver-cbc-cast5-avx", | ||
1731 | .test = alg_test_null, | ||
1732 | .suite = { | ||
1733 | .cipher = { | ||
1734 | .enc = { | ||
1735 | .vecs = NULL, | ||
1736 | .count = 0 | ||
1737 | }, | ||
1738 | .dec = { | ||
1739 | .vecs = NULL, | ||
1740 | .count = 0 | ||
1741 | } | ||
1742 | } | ||
1743 | } | ||
1744 | }, { | ||
1745 | .alg = "__driver-cbc-cast6-avx", | ||
1746 | .test = alg_test_null, | ||
1747 | .suite = { | ||
1748 | .cipher = { | ||
1749 | .enc = { | ||
1750 | .vecs = NULL, | ||
1751 | .count = 0 | ||
1752 | }, | ||
1753 | .dec = { | ||
1754 | .vecs = NULL, | ||
1755 | .count = 0 | ||
1756 | } | ||
1757 | } | ||
1758 | } | ||
1759 | }, { | ||
1598 | .alg = "__driver-cbc-serpent-avx", | 1760 | .alg = "__driver-cbc-serpent-avx", |
1599 | .test = alg_test_null, | 1761 | .test = alg_test_null, |
1600 | .suite = { | 1762 | .suite = { |
@@ -1656,6 +1818,36 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1656 | } | 1818 | } |
1657 | } | 1819 | } |
1658 | }, { | 1820 | }, { |
1821 | .alg = "__driver-ecb-cast5-avx", | ||
1822 | .test = alg_test_null, | ||
1823 | .suite = { | ||
1824 | .cipher = { | ||
1825 | .enc = { | ||
1826 | .vecs = NULL, | ||
1827 | .count = 0 | ||
1828 | }, | ||
1829 | .dec = { | ||
1830 | .vecs = NULL, | ||
1831 | .count = 0 | ||
1832 | } | ||
1833 | } | ||
1834 | } | ||
1835 | }, { | ||
1836 | .alg = "__driver-ecb-cast6-avx", | ||
1837 | .test = alg_test_null, | ||
1838 | .suite = { | ||
1839 | .cipher = { | ||
1840 | .enc = { | ||
1841 | .vecs = NULL, | ||
1842 | .count = 0 | ||
1843 | }, | ||
1844 | .dec = { | ||
1845 | .vecs = NULL, | ||
1846 | .count = 0 | ||
1847 | } | ||
1848 | } | ||
1849 | } | ||
1850 | }, { | ||
1659 | .alg = "__driver-ecb-serpent-avx", | 1851 | .alg = "__driver-ecb-serpent-avx", |
1660 | .test = alg_test_null, | 1852 | .test = alg_test_null, |
1661 | .suite = { | 1853 | .suite = { |
@@ -1818,6 +2010,36 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1818 | } | 2010 | } |
1819 | } | 2011 | } |
1820 | }, { | 2012 | }, { |
2013 | .alg = "cbc(cast5)", | ||
2014 | .test = alg_test_skcipher, | ||
2015 | .suite = { | ||
2016 | .cipher = { | ||
2017 | .enc = { | ||
2018 | .vecs = cast5_cbc_enc_tv_template, | ||
2019 | .count = CAST5_CBC_ENC_TEST_VECTORS | ||
2020 | }, | ||
2021 | .dec = { | ||
2022 | .vecs = cast5_cbc_dec_tv_template, | ||
2023 | .count = CAST5_CBC_DEC_TEST_VECTORS | ||
2024 | } | ||
2025 | } | ||
2026 | } | ||
2027 | }, { | ||
2028 | .alg = "cbc(cast6)", | ||
2029 | .test = alg_test_skcipher, | ||
2030 | .suite = { | ||
2031 | .cipher = { | ||
2032 | .enc = { | ||
2033 | .vecs = cast6_cbc_enc_tv_template, | ||
2034 | .count = CAST6_CBC_ENC_TEST_VECTORS | ||
2035 | }, | ||
2036 | .dec = { | ||
2037 | .vecs = cast6_cbc_dec_tv_template, | ||
2038 | .count = CAST6_CBC_DEC_TEST_VECTORS | ||
2039 | } | ||
2040 | } | ||
2041 | } | ||
2042 | }, { | ||
1821 | .alg = "cbc(des)", | 2043 | .alg = "cbc(des)", |
1822 | .test = alg_test_skcipher, | 2044 | .test = alg_test_skcipher, |
1823 | .suite = { | 2045 | .suite = { |
@@ -1937,6 +2159,36 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1937 | } | 2159 | } |
1938 | } | 2160 | } |
1939 | }, { | 2161 | }, { |
2162 | .alg = "cryptd(__driver-ecb-cast5-avx)", | ||
2163 | .test = alg_test_null, | ||
2164 | .suite = { | ||
2165 | .cipher = { | ||
2166 | .enc = { | ||
2167 | .vecs = NULL, | ||
2168 | .count = 0 | ||
2169 | }, | ||
2170 | .dec = { | ||
2171 | .vecs = NULL, | ||
2172 | .count = 0 | ||
2173 | } | ||
2174 | } | ||
2175 | } | ||
2176 | }, { | ||
2177 | .alg = "cryptd(__driver-ecb-cast6-avx)", | ||
2178 | .test = alg_test_null, | ||
2179 | .suite = { | ||
2180 | .cipher = { | ||
2181 | .enc = { | ||
2182 | .vecs = NULL, | ||
2183 | .count = 0 | ||
2184 | }, | ||
2185 | .dec = { | ||
2186 | .vecs = NULL, | ||
2187 | .count = 0 | ||
2188 | } | ||
2189 | } | ||
2190 | } | ||
2191 | }, { | ||
1940 | .alg = "cryptd(__driver-ecb-serpent-avx)", | 2192 | .alg = "cryptd(__driver-ecb-serpent-avx)", |
1941 | .test = alg_test_null, | 2193 | .test = alg_test_null, |
1942 | .suite = { | 2194 | .suite = { |
@@ -2054,6 +2306,36 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
2054 | } | 2306 | } |
2055 | } | 2307 | } |
2056 | }, { | 2308 | }, { |
2309 | .alg = "ctr(cast5)", | ||
2310 | .test = alg_test_skcipher, | ||
2311 | .suite = { | ||
2312 | .cipher = { | ||
2313 | .enc = { | ||
2314 | .vecs = cast5_ctr_enc_tv_template, | ||
2315 | .count = CAST5_CTR_ENC_TEST_VECTORS | ||
2316 | }, | ||
2317 | .dec = { | ||
2318 | .vecs = cast5_ctr_dec_tv_template, | ||
2319 | .count = CAST5_CTR_DEC_TEST_VECTORS | ||
2320 | } | ||
2321 | } | ||
2322 | } | ||
2323 | }, { | ||
2324 | .alg = "ctr(cast6)", | ||
2325 | .test = alg_test_skcipher, | ||
2326 | .suite = { | ||
2327 | .cipher = { | ||
2328 | .enc = { | ||
2329 | .vecs = cast6_ctr_enc_tv_template, | ||
2330 | .count = CAST6_CTR_ENC_TEST_VECTORS | ||
2331 | }, | ||
2332 | .dec = { | ||
2333 | .vecs = cast6_ctr_dec_tv_template, | ||
2334 | .count = CAST6_CTR_DEC_TEST_VECTORS | ||
2335 | } | ||
2336 | } | ||
2337 | } | ||
2338 | }, { | ||
2057 | .alg = "ctr(serpent)", | 2339 | .alg = "ctr(serpent)", |
2058 | .test = alg_test_skcipher, | 2340 | .test = alg_test_skcipher, |
2059 | .suite = { | 2341 | .suite = { |
@@ -2530,6 +2812,21 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
2530 | } | 2812 | } |
2531 | } | 2813 | } |
2532 | }, { | 2814 | }, { |
2815 | .alg = "lrw(cast6)", | ||
2816 | .test = alg_test_skcipher, | ||
2817 | .suite = { | ||
2818 | .cipher = { | ||
2819 | .enc = { | ||
2820 | .vecs = cast6_lrw_enc_tv_template, | ||
2821 | .count = CAST6_LRW_ENC_TEST_VECTORS | ||
2822 | }, | ||
2823 | .dec = { | ||
2824 | .vecs = cast6_lrw_dec_tv_template, | ||
2825 | .count = CAST6_LRW_DEC_TEST_VECTORS | ||
2826 | } | ||
2827 | } | ||
2828 | } | ||
2829 | }, { | ||
2533 | .alg = "lrw(serpent)", | 2830 | .alg = "lrw(serpent)", |
2534 | .test = alg_test_skcipher, | 2831 | .test = alg_test_skcipher, |
2535 | .suite = { | 2832 | .suite = { |
@@ -2882,6 +3179,21 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
2882 | } | 3179 | } |
2883 | } | 3180 | } |
2884 | }, { | 3181 | }, { |
3182 | .alg = "xts(cast6)", | ||
3183 | .test = alg_test_skcipher, | ||
3184 | .suite = { | ||
3185 | .cipher = { | ||
3186 | .enc = { | ||
3187 | .vecs = cast6_xts_enc_tv_template, | ||
3188 | .count = CAST6_XTS_ENC_TEST_VECTORS | ||
3189 | }, | ||
3190 | .dec = { | ||
3191 | .vecs = cast6_xts_dec_tv_template, | ||
3192 | .count = CAST6_XTS_DEC_TEST_VECTORS | ||
3193 | } | ||
3194 | } | ||
3195 | } | ||
3196 | }, { | ||
2885 | .alg = "xts(serpent)", | 3197 | .alg = "xts(serpent)", |
2886 | .test = alg_test_skcipher, | 3198 | .test = alg_test_skcipher, |
2887 | .suite = { | 3199 | .suite = { |
diff --git a/crypto/testmgr.h b/crypto/testmgr.h index f8179e0344ed..76d7f6cc82f5 100644 --- a/crypto/testmgr.h +++ b/crypto/testmgr.h | |||
@@ -53,6 +53,7 @@ struct cipher_testvec { | |||
53 | char *result; | 53 | char *result; |
54 | unsigned short tap[MAX_TAP]; | 54 | unsigned short tap[MAX_TAP]; |
55 | int np; | 55 | int np; |
56 | unsigned char also_non_np; | ||
56 | unsigned char fail; | 57 | unsigned char fail; |
57 | unsigned char wk; /* weak key flag */ | 58 | unsigned char wk; /* weak key flag */ |
58 | unsigned char klen; | 59 | unsigned char klen; |
@@ -2468,6 +2469,9 @@ static struct cipher_testvec bf_enc_tv_template[] = { | |||
2468 | "\xC2\xF4\x6D\xFF\xF6\xCD\x6B\x40" | 2469 | "\xC2\xF4\x6D\xFF\xF6\xCD\x6B\x40" |
2469 | "\xE1\xB3\xBF\xD4\x38\x2B\xC8\x3B", | 2470 | "\xE1\xB3\xBF\xD4\x38\x2B\xC8\x3B", |
2470 | .rlen = 40, | 2471 | .rlen = 40, |
2472 | .also_non_np = 1, | ||
2473 | .np = 2, | ||
2474 | .tap = { 40 - 8, 8 }, | ||
2471 | }, | 2475 | }, |
2472 | }; | 2476 | }; |
2473 | 2477 | ||
@@ -2541,6 +2545,9 @@ static struct cipher_testvec bf_dec_tv_template[] = { | |||
2541 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | 2545 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" |
2542 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9", | 2546 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9", |
2543 | .rlen = 40, | 2547 | .rlen = 40, |
2548 | .also_non_np = 1, | ||
2549 | .np = 2, | ||
2550 | .tap = { 40 - 8, 8 }, | ||
2544 | }, | 2551 | }, |
2545 | }; | 2552 | }; |
2546 | 2553 | ||
@@ -2579,6 +2586,9 @@ static struct cipher_testvec bf_cbc_enc_tv_template[] = { | |||
2579 | "\x1B\xD9\x02\xB6\x48\xB0\x87\x25" | 2586 | "\x1B\xD9\x02\xB6\x48\xB0\x87\x25" |
2580 | "\x01\x9C\x93\x63\x51\x60\x82\xD2", | 2587 | "\x01\x9C\x93\x63\x51\x60\x82\xD2", |
2581 | .rlen = 40, | 2588 | .rlen = 40, |
2589 | .also_non_np = 1, | ||
2590 | .np = 2, | ||
2591 | .tap = { 40 - 8, 8 }, | ||
2582 | }, | 2592 | }, |
2583 | }; | 2593 | }; |
2584 | 2594 | ||
@@ -2617,6 +2627,9 @@ static struct cipher_testvec bf_cbc_dec_tv_template[] = { | |||
2617 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | 2627 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" |
2618 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9", | 2628 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9", |
2619 | .rlen = 40, | 2629 | .rlen = 40, |
2630 | .also_non_np = 1, | ||
2631 | .np = 2, | ||
2632 | .tap = { 40 - 8, 8 }, | ||
2620 | }, | 2633 | }, |
2621 | }; | 2634 | }; |
2622 | 2635 | ||
@@ -2661,6 +2674,144 @@ static struct cipher_testvec bf_ctr_enc_tv_template[] = { | |||
2661 | "\xE4\x1F\x5E\xA5\x89\xAC\x32\xBC" | 2674 | "\xE4\x1F\x5E\xA5\x89\xAC\x32\xBC" |
2662 | "\x3D\xA7\xE9", | 2675 | "\x3D\xA7\xE9", |
2663 | .rlen = 43, | 2676 | .rlen = 43, |
2677 | .also_non_np = 1, | ||
2678 | .np = 2, | ||
2679 | .tap = { 43 - 8, 8 }, | ||
2680 | }, { /* Generated with Crypto++ */ | ||
2681 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
2682 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
2683 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
2684 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
2685 | .klen = 32, | ||
2686 | .iv = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFD", | ||
2687 | .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
2688 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
2689 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
2690 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
2691 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
2692 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
2693 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
2694 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" | ||
2695 | "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" | ||
2696 | "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" | ||
2697 | "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" | ||
2698 | "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" | ||
2699 | "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" | ||
2700 | "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" | ||
2701 | "\x29\xC0\x57\xEE\x62\xF9\x90\x04" | ||
2702 | "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" | ||
2703 | "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" | ||
2704 | "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" | ||
2705 | "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" | ||
2706 | "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" | ||
2707 | "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" | ||
2708 | "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" | ||
2709 | "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" | ||
2710 | "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" | ||
2711 | "\x57\xEE\x85\x1C\x90\x27\xBE\x32" | ||
2712 | "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" | ||
2713 | "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" | ||
2714 | "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" | ||
2715 | "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" | ||
2716 | "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" | ||
2717 | "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" | ||
2718 | "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" | ||
2719 | "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" | ||
2720 | "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" | ||
2721 | "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" | ||
2722 | "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" | ||
2723 | "\x69\x00\x74\x0B\xA2\x16\xAD\x44" | ||
2724 | "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" | ||
2725 | "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" | ||
2726 | "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" | ||
2727 | "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" | ||
2728 | "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" | ||
2729 | "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" | ||
2730 | "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" | ||
2731 | "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" | ||
2732 | "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" | ||
2733 | "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" | ||
2734 | "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" | ||
2735 | "\x58\xEF\x86\x1D\x91\x28\xBF\x33" | ||
2736 | "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" | ||
2737 | "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" | ||
2738 | "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" | ||
2739 | "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" | ||
2740 | "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" | ||
2741 | "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" | ||
2742 | "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" | ||
2743 | "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" | ||
2744 | "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" | ||
2745 | "\x86\x1D\xB4\x28\xBF\x56\xED\x61" | ||
2746 | "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" | ||
2747 | "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" | ||
2748 | "\xDC\x50\xE7\x7E\x15\x89\x20\xB7" | ||
2749 | "\x2B\xC2\x59\xF0\x64\xFB\x92\x06", | ||
2750 | .ilen = 504, | ||
2751 | .result = "\x5F\x58\x6E\x60\x51\x6E\xDC\x3D" | ||
2752 | "\xD1\xBB\xF7\xB7\xFD\x04\x44\x82" | ||
2753 | "\xDC\x9F\x4B\x02\xF1\xD2\x5A\x6F" | ||
2754 | "\x25\xF9\x27\x21\xF2\xD2\x9A\x01" | ||
2755 | "\xBD\xAD\x3D\x93\x87\xCA\x0D\xFE" | ||
2756 | "\xB7\x2C\x17\x1F\x42\x8C\x13\xB2" | ||
2757 | "\x62\x44\x72\xB9\x5D\xC0\xF8\x37" | ||
2758 | "\xDF\xEA\x78\x81\x8F\xA6\x34\xB2" | ||
2759 | "\x07\x09\x7C\xB9\x3A\xA0\x2B\x18" | ||
2760 | "\x34\x6A\x9D\x3D\xA5\xEB\xF4\x60" | ||
2761 | "\xF8\x98\xA2\x39\x81\x23\x6C\xA9" | ||
2762 | "\x70\xCA\xCC\x45\xD8\x1F\xDF\x44" | ||
2763 | "\x2A\x67\x7A\x88\x28\xDC\x36\x83" | ||
2764 | "\x18\xD7\x48\x43\x17\x2B\x1B\xE6" | ||
2765 | "\x0B\x82\x59\x14\x26\x67\x08\x09" | ||
2766 | "\x5B\x5D\x38\xD0\x81\xCE\x54\x2A" | ||
2767 | "\xCD\x22\x94\x42\xF5\xBA\x74\x7E" | ||
2768 | "\xD9\x00\x40\xA9\x0D\x0B\xBD\x8E" | ||
2769 | "\xC4\x8E\x5E\x17\x8F\x48\xE2\xB8" | ||
2770 | "\xF4\xCC\x19\x76\xAB\x48\x29\xAA" | ||
2771 | "\x81\xD5\xCE\xD5\x8A\x3B\xC9\x21" | ||
2772 | "\xEF\x50\x4F\x04\x02\xBF\xE1\x1F" | ||
2773 | "\x59\x28\x1A\xE4\x18\x16\xA0\x29" | ||
2774 | "\xBF\x34\xA9\x2D\x28\x83\xC0\x5E" | ||
2775 | "\xEA\x44\xC4\x6E\xAB\x24\x79\x9D" | ||
2776 | "\x2D\xA1\xE8\x55\xCA\x74\xFC\xBD" | ||
2777 | "\xFE\xDD\xDA\xA5\xFB\x34\x90\x31" | ||
2778 | "\x0E\x62\x28\x9B\xDC\xD7\xA1\xBB" | ||
2779 | "\xF0\x1A\xB3\xE2\xD0\xFA\xBD\xE8" | ||
2780 | "\x5C\x5A\x10\x67\xF6\x6A\x17\x3F" | ||
2781 | "\xC5\xE9\x09\x08\xDD\x22\x77\x42" | ||
2782 | "\x26\x6A\x6A\x7A\x3F\x87\x80\x0C" | ||
2783 | "\xF0\xFF\x15\x8E\x84\x86\xC0\x10" | ||
2784 | "\x0F\x8D\x33\x06\xB8\x72\xA4\x47" | ||
2785 | "\x6B\xED\x2E\x05\x94\x6C\x5C\x5B" | ||
2786 | "\x13\xF6\x77\xEE\x3B\x16\xDF\xC2" | ||
2787 | "\x63\x66\x07\x6D\x3F\x6C\x51\x7C" | ||
2788 | "\x1C\xAC\x80\xB6\x58\x48\xB7\x9D" | ||
2789 | "\xB4\x19\xD8\x19\x45\x66\x27\x02" | ||
2790 | "\xA1\xA9\x99\xF3\x1F\xE5\xA7\x1D" | ||
2791 | "\x31\xE7\x1B\x0D\xFF\xBB\xB5\xA1" | ||
2792 | "\xF5\x9C\x45\x1E\x18\x19\xA1\xE7" | ||
2793 | "\xC2\xF1\xBF\x68\xC3\xEC\xCF\x53" | ||
2794 | "\x67\xA6\x2B\x7D\x3C\x6D\x24\xC3" | ||
2795 | "\xE8\xE6\x07\x5A\x09\xE0\x32\xA8" | ||
2796 | "\x52\xF6\xE9\xED\x0E\xC6\x0A\x6A" | ||
2797 | "\xFC\x60\x2A\xE0\x93\xCE\xB8\x2E" | ||
2798 | "\xA2\xA8\x0E\x79\x9E\x34\x5D\x37" | ||
2799 | "\x6F\x12\xFE\x48\x7B\xE7\xB9\x22" | ||
2800 | "\x29\xE8\xD7\xBE\x5D\xD1\x8B\xD9" | ||
2801 | "\x91\x51\x4E\x71\xF2\x98\x85\x16" | ||
2802 | "\x25\x7A\x76\x8A\x51\x0E\x65\x14" | ||
2803 | "\x81\xB5\x3A\x37\xFD\xEC\xB5\x8A" | ||
2804 | "\xE1\xCF\x41\x72\x14\x29\x4C\xF0" | ||
2805 | "\x20\xD9\x9A\xC5\x66\xA4\x03\x76" | ||
2806 | "\x5B\xA4\x15\x4F\x0E\x64\x39\x40" | ||
2807 | "\x25\xF9\x20\x22\xF5\x88\xF5\xBA" | ||
2808 | "\xE4\xDF\x45\x61\xBF\x8D\x7A\x24" | ||
2809 | "\x4B\x92\x71\xD9\x2F\x77\xA7\x95" | ||
2810 | "\xA8\x7F\x61\xD5\xA4\x57\xB0\xFB" | ||
2811 | "\xB5\x77\xBA\x1C\xEE\x71\xFA\xB0" | ||
2812 | "\x16\x4C\x18\x6B\xF2\x69\xA0\x07" | ||
2813 | "\xEF\xBE\xEC\x69\xAC\xA8\x63\x9E", | ||
2814 | .rlen = 504, | ||
2664 | }, | 2815 | }, |
2665 | }; | 2816 | }; |
2666 | 2817 | ||
@@ -2705,6 +2856,144 @@ static struct cipher_testvec bf_ctr_dec_tv_template[] = { | |||
2705 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | 2856 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" |
2706 | "\x6D\x04\x9B", | 2857 | "\x6D\x04\x9B", |
2707 | .rlen = 43, | 2858 | .rlen = 43, |
2859 | .also_non_np = 1, | ||
2860 | .np = 2, | ||
2861 | .tap = { 43 - 8, 8 }, | ||
2862 | }, { /* Generated with Crypto++ */ | ||
2863 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
2864 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
2865 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
2866 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
2867 | .klen = 32, | ||
2868 | .iv = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFD", | ||
2869 | .input = "\x5F\x58\x6E\x60\x51\x6E\xDC\x3D" | ||
2870 | "\xD1\xBB\xF7\xB7\xFD\x04\x44\x82" | ||
2871 | "\xDC\x9F\x4B\x02\xF1\xD2\x5A\x6F" | ||
2872 | "\x25\xF9\x27\x21\xF2\xD2\x9A\x01" | ||
2873 | "\xBD\xAD\x3D\x93\x87\xCA\x0D\xFE" | ||
2874 | "\xB7\x2C\x17\x1F\x42\x8C\x13\xB2" | ||
2875 | "\x62\x44\x72\xB9\x5D\xC0\xF8\x37" | ||
2876 | "\xDF\xEA\x78\x81\x8F\xA6\x34\xB2" | ||
2877 | "\x07\x09\x7C\xB9\x3A\xA0\x2B\x18" | ||
2878 | "\x34\x6A\x9D\x3D\xA5\xEB\xF4\x60" | ||
2879 | "\xF8\x98\xA2\x39\x81\x23\x6C\xA9" | ||
2880 | "\x70\xCA\xCC\x45\xD8\x1F\xDF\x44" | ||
2881 | "\x2A\x67\x7A\x88\x28\xDC\x36\x83" | ||
2882 | "\x18\xD7\x48\x43\x17\x2B\x1B\xE6" | ||
2883 | "\x0B\x82\x59\x14\x26\x67\x08\x09" | ||
2884 | "\x5B\x5D\x38\xD0\x81\xCE\x54\x2A" | ||
2885 | "\xCD\x22\x94\x42\xF5\xBA\x74\x7E" | ||
2886 | "\xD9\x00\x40\xA9\x0D\x0B\xBD\x8E" | ||
2887 | "\xC4\x8E\x5E\x17\x8F\x48\xE2\xB8" | ||
2888 | "\xF4\xCC\x19\x76\xAB\x48\x29\xAA" | ||
2889 | "\x81\xD5\xCE\xD5\x8A\x3B\xC9\x21" | ||
2890 | "\xEF\x50\x4F\x04\x02\xBF\xE1\x1F" | ||
2891 | "\x59\x28\x1A\xE4\x18\x16\xA0\x29" | ||
2892 | "\xBF\x34\xA9\x2D\x28\x83\xC0\x5E" | ||
2893 | "\xEA\x44\xC4\x6E\xAB\x24\x79\x9D" | ||
2894 | "\x2D\xA1\xE8\x55\xCA\x74\xFC\xBD" | ||
2895 | "\xFE\xDD\xDA\xA5\xFB\x34\x90\x31" | ||
2896 | "\x0E\x62\x28\x9B\xDC\xD7\xA1\xBB" | ||
2897 | "\xF0\x1A\xB3\xE2\xD0\xFA\xBD\xE8" | ||
2898 | "\x5C\x5A\x10\x67\xF6\x6A\x17\x3F" | ||
2899 | "\xC5\xE9\x09\x08\xDD\x22\x77\x42" | ||
2900 | "\x26\x6A\x6A\x7A\x3F\x87\x80\x0C" | ||
2901 | "\xF0\xFF\x15\x8E\x84\x86\xC0\x10" | ||
2902 | "\x0F\x8D\x33\x06\xB8\x72\xA4\x47" | ||
2903 | "\x6B\xED\x2E\x05\x94\x6C\x5C\x5B" | ||
2904 | "\x13\xF6\x77\xEE\x3B\x16\xDF\xC2" | ||
2905 | "\x63\x66\x07\x6D\x3F\x6C\x51\x7C" | ||
2906 | "\x1C\xAC\x80\xB6\x58\x48\xB7\x9D" | ||
2907 | "\xB4\x19\xD8\x19\x45\x66\x27\x02" | ||
2908 | "\xA1\xA9\x99\xF3\x1F\xE5\xA7\x1D" | ||
2909 | "\x31\xE7\x1B\x0D\xFF\xBB\xB5\xA1" | ||
2910 | "\xF5\x9C\x45\x1E\x18\x19\xA1\xE7" | ||
2911 | "\xC2\xF1\xBF\x68\xC3\xEC\xCF\x53" | ||
2912 | "\x67\xA6\x2B\x7D\x3C\x6D\x24\xC3" | ||
2913 | "\xE8\xE6\x07\x5A\x09\xE0\x32\xA8" | ||
2914 | "\x52\xF6\xE9\xED\x0E\xC6\x0A\x6A" | ||
2915 | "\xFC\x60\x2A\xE0\x93\xCE\xB8\x2E" | ||
2916 | "\xA2\xA8\x0E\x79\x9E\x34\x5D\x37" | ||
2917 | "\x6F\x12\xFE\x48\x7B\xE7\xB9\x22" | ||
2918 | "\x29\xE8\xD7\xBE\x5D\xD1\x8B\xD9" | ||
2919 | "\x91\x51\x4E\x71\xF2\x98\x85\x16" | ||
2920 | "\x25\x7A\x76\x8A\x51\x0E\x65\x14" | ||
2921 | "\x81\xB5\x3A\x37\xFD\xEC\xB5\x8A" | ||
2922 | "\xE1\xCF\x41\x72\x14\x29\x4C\xF0" | ||
2923 | "\x20\xD9\x9A\xC5\x66\xA4\x03\x76" | ||
2924 | "\x5B\xA4\x15\x4F\x0E\x64\x39\x40" | ||
2925 | "\x25\xF9\x20\x22\xF5\x88\xF5\xBA" | ||
2926 | "\xE4\xDF\x45\x61\xBF\x8D\x7A\x24" | ||
2927 | "\x4B\x92\x71\xD9\x2F\x77\xA7\x95" | ||
2928 | "\xA8\x7F\x61\xD5\xA4\x57\xB0\xFB" | ||
2929 | "\xB5\x77\xBA\x1C\xEE\x71\xFA\xB0" | ||
2930 | "\x16\x4C\x18\x6B\xF2\x69\xA0\x07" | ||
2931 | "\xEF\xBE\xEC\x69\xAC\xA8\x63\x9E", | ||
2932 | .ilen = 504, | ||
2933 | .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
2934 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
2935 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
2936 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
2937 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
2938 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
2939 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
2940 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" | ||
2941 | "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" | ||
2942 | "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" | ||
2943 | "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" | ||
2944 | "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" | ||
2945 | "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" | ||
2946 | "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" | ||
2947 | "\x29\xC0\x57\xEE\x62\xF9\x90\x04" | ||
2948 | "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" | ||
2949 | "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" | ||
2950 | "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" | ||
2951 | "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" | ||
2952 | "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" | ||
2953 | "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" | ||
2954 | "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" | ||
2955 | "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" | ||
2956 | "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" | ||
2957 | "\x57\xEE\x85\x1C\x90\x27\xBE\x32" | ||
2958 | "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" | ||
2959 | "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" | ||
2960 | "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" | ||
2961 | "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" | ||
2962 | "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" | ||
2963 | "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" | ||
2964 | "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" | ||
2965 | "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" | ||
2966 | "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" | ||
2967 | "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" | ||
2968 | "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" | ||
2969 | "\x69\x00\x74\x0B\xA2\x16\xAD\x44" | ||
2970 | "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" | ||
2971 | "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" | ||
2972 | "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" | ||
2973 | "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" | ||
2974 | "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" | ||
2975 | "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" | ||
2976 | "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" | ||
2977 | "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" | ||
2978 | "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" | ||
2979 | "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" | ||
2980 | "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" | ||
2981 | "\x58\xEF\x86\x1D\x91\x28\xBF\x33" | ||
2982 | "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" | ||
2983 | "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" | ||
2984 | "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" | ||
2985 | "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" | ||
2986 | "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" | ||
2987 | "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" | ||
2988 | "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" | ||
2989 | "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" | ||
2990 | "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" | ||
2991 | "\x86\x1D\xB4\x28\xBF\x56\xED\x61" | ||
2992 | "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" | ||
2993 | "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" | ||
2994 | "\xDC\x50\xE7\x7E\x15\x89\x20\xB7" | ||
2995 | "\x2B\xC2\x59\xF0\x64\xFB\x92\x06", | ||
2996 | .rlen = 504, | ||
2708 | }, | 2997 | }, |
2709 | }; | 2998 | }; |
2710 | 2999 | ||
@@ -2884,6 +3173,9 @@ static struct cipher_testvec tf_enc_tv_template[] = { | |||
2884 | "\x58\x33\x9B\x78\xC7\x58\x48\x6B" | 3173 | "\x58\x33\x9B\x78\xC7\x58\x48\x6B" |
2885 | "\x2C\x75\x64\xC4\xCA\xC1\x7E\xD5", | 3174 | "\x2C\x75\x64\xC4\xCA\xC1\x7E\xD5", |
2886 | .rlen = 496, | 3175 | .rlen = 496, |
3176 | .also_non_np = 1, | ||
3177 | .np = 2, | ||
3178 | .tap = { 496 - 16, 16 }, | ||
2887 | }, | 3179 | }, |
2888 | }; | 3180 | }; |
2889 | 3181 | ||
@@ -3049,6 +3341,9 @@ static struct cipher_testvec tf_dec_tv_template[] = { | |||
3049 | "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" | 3341 | "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" |
3050 | "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", | 3342 | "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", |
3051 | .rlen = 496, | 3343 | .rlen = 496, |
3344 | .also_non_np = 1, | ||
3345 | .np = 2, | ||
3346 | .tap = { 496 - 16, 16 }, | ||
3052 | }, | 3347 | }, |
3053 | }; | 3348 | }; |
3054 | 3349 | ||
@@ -3229,6 +3524,9 @@ static struct cipher_testvec tf_cbc_enc_tv_template[] = { | |||
3229 | "\x30\x70\x56\xA4\x37\xDD\x7C\xC0" | 3524 | "\x30\x70\x56\xA4\x37\xDD\x7C\xC0" |
3230 | "\x0A\xA3\x30\x10\x26\x25\x41\x2C", | 3525 | "\x0A\xA3\x30\x10\x26\x25\x41\x2C", |
3231 | .rlen = 496, | 3526 | .rlen = 496, |
3527 | .also_non_np = 1, | ||
3528 | .np = 2, | ||
3529 | .tap = { 496 - 16, 16 }, | ||
3232 | }, | 3530 | }, |
3233 | }; | 3531 | }; |
3234 | 3532 | ||
@@ -3409,6 +3707,9 @@ static struct cipher_testvec tf_cbc_dec_tv_template[] = { | |||
3409 | "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" | 3707 | "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" |
3410 | "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", | 3708 | "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", |
3411 | .rlen = 496, | 3709 | .rlen = 496, |
3710 | .also_non_np = 1, | ||
3711 | .np = 2, | ||
3712 | .tap = { 496 - 16, 16 }, | ||
3412 | }, | 3713 | }, |
3413 | }; | 3714 | }; |
3414 | 3715 | ||
@@ -3553,6 +3854,140 @@ static struct cipher_testvec tf_ctr_enc_tv_template[] = { | |||
3553 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | 3854 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" |
3554 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | 3855 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", |
3555 | .klen = 32, | 3856 | .klen = 32, |
3857 | .iv = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" | ||
3858 | "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFD", | ||
3859 | .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
3860 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
3861 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
3862 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
3863 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
3864 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
3865 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
3866 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" | ||
3867 | "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" | ||
3868 | "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" | ||
3869 | "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" | ||
3870 | "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" | ||
3871 | "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" | ||
3872 | "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" | ||
3873 | "\x29\xC0\x57\xEE\x62\xF9\x90\x04" | ||
3874 | "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" | ||
3875 | "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" | ||
3876 | "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" | ||
3877 | "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" | ||
3878 | "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" | ||
3879 | "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" | ||
3880 | "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" | ||
3881 | "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" | ||
3882 | "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" | ||
3883 | "\x57\xEE\x85\x1C\x90\x27\xBE\x32" | ||
3884 | "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" | ||
3885 | "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" | ||
3886 | "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" | ||
3887 | "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" | ||
3888 | "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" | ||
3889 | "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" | ||
3890 | "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" | ||
3891 | "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" | ||
3892 | "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" | ||
3893 | "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" | ||
3894 | "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" | ||
3895 | "\x69\x00\x74\x0B\xA2\x16\xAD\x44" | ||
3896 | "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" | ||
3897 | "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" | ||
3898 | "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" | ||
3899 | "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" | ||
3900 | "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" | ||
3901 | "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" | ||
3902 | "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" | ||
3903 | "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" | ||
3904 | "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" | ||
3905 | "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" | ||
3906 | "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" | ||
3907 | "\x58\xEF\x86\x1D\x91\x28\xBF\x33" | ||
3908 | "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" | ||
3909 | "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" | ||
3910 | "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" | ||
3911 | "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" | ||
3912 | "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" | ||
3913 | "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" | ||
3914 | "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" | ||
3915 | "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" | ||
3916 | "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" | ||
3917 | "\x86\x1D\xB4\x28\xBF\x56\xED\x61" | ||
3918 | "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" | ||
3919 | "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" | ||
3920 | "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", | ||
3921 | .ilen = 496, | ||
3922 | .result = "\xEB\x44\xAF\x49\x27\xB8\xFB\x44" | ||
3923 | "\x4C\xA6\xC3\x0C\x8B\xD0\x01\x0C" | ||
3924 | "\x53\xC8\x16\x38\xDE\x40\x4F\x91" | ||
3925 | "\x25\x6D\x4C\xA0\x9A\x87\x1E\xDA" | ||
3926 | "\x88\x7E\x89\xE9\x67\x2B\x83\xA2" | ||
3927 | "\x5F\x2E\x23\x3E\x45\xB9\x77\x7B" | ||
3928 | "\xA6\x7E\x47\x36\x81\x9F\x9B\xF3" | ||
3929 | "\xE0\xF0\xD7\x47\xA9\xC8\xEF\x33" | ||
3930 | "\x0C\x43\xFE\x67\x50\x0A\x2C\x3E" | ||
3931 | "\xA0\xE1\x25\x8E\x80\x07\x4A\xC0" | ||
3932 | "\x64\x89\x9F\x6A\x27\x96\x07\xA6" | ||
3933 | "\x9B\xC8\x1B\x21\x60\xAE\x5D\x01" | ||
3934 | "\xE2\xCD\xC8\xAA\x6C\x9D\x1C\x34" | ||
3935 | "\x39\x18\x09\xA4\x82\x59\x78\xE7" | ||
3936 | "\xFC\x59\x65\xF2\x94\xFF\xFB\xE2" | ||
3937 | "\x3C\xDA\xB1\x90\x95\xBF\x91\xE3" | ||
3938 | "\xE6\x87\x31\x9E\x16\x85\xAD\xB1" | ||
3939 | "\x4C\xAE\x43\x4D\x19\x58\xB5\x5E" | ||
3940 | "\x2E\xF5\x09\xAA\x39\xF4\xC0\xB3" | ||
3941 | "\xD4\x4D\xDB\x73\x7A\xD4\xF1\xBF" | ||
3942 | "\x89\x16\x4D\x2D\xA2\x26\x33\x72" | ||
3943 | "\x18\x33\x7E\xD6\xD2\x16\xA4\x54" | ||
3944 | "\xF4\x8C\xB3\x52\xDF\x21\x9C\xEB" | ||
3945 | "\xBF\x49\xD3\xF9\x05\x06\xCB\xD2" | ||
3946 | "\xA9\xD2\x3B\x6E\x19\x8C\xBC\x19" | ||
3947 | "\xAB\x89\xD6\xD8\xCD\x56\x89\x5E" | ||
3948 | "\xAC\x00\xE3\x50\x63\x4A\x80\x9A" | ||
3949 | "\x05\xBC\x50\x39\xD3\x32\xD9\x0D" | ||
3950 | "\xE3\x20\x0D\x75\x54\xEC\xE6\x31" | ||
3951 | "\x14\xB9\x3A\x59\x00\x43\x37\x8E" | ||
3952 | "\x8C\x5A\x79\x62\x14\x76\x8A\xAE" | ||
3953 | "\x8F\xCC\xA1\x6C\x38\x78\xDD\x2D" | ||
3954 | "\x8B\x6D\xEA\xBD\x7B\x25\xFF\x60" | ||
3955 | "\xC9\x87\xB1\x79\x1E\xA5\x86\x68" | ||
3956 | "\x81\xB4\xE2\xC1\x05\x7D\x3A\x73" | ||
3957 | "\xD0\xDA\x75\x77\x9E\x05\x27\xF1" | ||
3958 | "\x08\xA9\x66\x64\x6C\xBC\x82\x17" | ||
3959 | "\x2C\x23\x5F\x62\x4D\x02\x1A\x58" | ||
3960 | "\xE7\xB7\x23\x6D\xE2\x20\xDA\xEF" | ||
3961 | "\xB4\xB3\x3F\xB2\x2B\x69\x98\x83" | ||
3962 | "\x95\x87\x13\x57\x60\xD7\xB5\xB1" | ||
3963 | "\xEE\x0A\x2F\x95\x36\x4C\x76\x5D" | ||
3964 | "\x5F\xD9\x19\xED\xB9\xA5\x48\xBF" | ||
3965 | "\xC8\xAB\x0F\x71\xCC\x61\x8E\x0A" | ||
3966 | "\xD0\x29\x44\xA8\xB9\xC1\xE8\xC8" | ||
3967 | "\xC9\xA8\x28\x81\xFB\x50\xF2\xF0" | ||
3968 | "\x26\xAE\x39\xB8\x91\xCD\xA8\xAC" | ||
3969 | "\xDE\x55\x1B\x50\x14\x53\x44\x17" | ||
3970 | "\x54\x46\xFC\xB1\xE4\x07\x6B\x9A" | ||
3971 | "\x01\x14\xF0\x2E\x2E\xDB\x46\x1B" | ||
3972 | "\x1A\x09\x97\xA9\xB6\x97\x79\x06" | ||
3973 | "\xFB\xCB\x85\xCF\xDD\xA1\x41\xB1" | ||
3974 | "\x00\xAA\xF7\xE0\x89\x73\xFB\xE5" | ||
3975 | "\xBF\x84\xDB\xC9\xCD\xC4\xA2\x0D" | ||
3976 | "\x3B\xAC\xF9\xDF\x96\xBF\x88\x23" | ||
3977 | "\x41\x67\xA1\x24\x99\x7E\xCC\x9B" | ||
3978 | "\x02\x8F\x6A\x49\xF6\x25\xBA\x7A" | ||
3979 | "\xF4\x78\xFD\x79\x62\x63\x4F\x14" | ||
3980 | "\xD6\x11\x11\x04\x05\x5F\x7E\xEA" | ||
3981 | "\x4C\xB6\xF8\xF4\x5F\x48\x52\x54" | ||
3982 | "\x94\x63\xA8\x4E\xCF\xD2\x1B\x1B" | ||
3983 | "\x22\x18\x6A\xAF\x6E\x3E\xE1\x0D", | ||
3984 | .rlen = 496, | ||
3985 | }, { /* Generated with Crypto++ */ | ||
3986 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
3987 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
3988 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
3989 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
3990 | .klen = 32, | ||
3556 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F" | 3991 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F" |
3557 | "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64", | 3992 | "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64", |
3558 | .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | 3993 | .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" |
@@ -3683,6 +4118,9 @@ static struct cipher_testvec tf_ctr_enc_tv_template[] = { | |||
3683 | "\xC5\xC9\x7F\x9E\xCF\x33\x7A\xDF" | 4118 | "\xC5\xC9\x7F\x9E\xCF\x33\x7A\xDF" |
3684 | "\x6C\x82\x9D", | 4119 | "\x6C\x82\x9D", |
3685 | .rlen = 499, | 4120 | .rlen = 499, |
4121 | .also_non_np = 1, | ||
4122 | .np = 2, | ||
4123 | .tap = { 499 - 16, 16 }, | ||
3686 | }, | 4124 | }, |
3687 | }; | 4125 | }; |
3688 | 4126 | ||
@@ -3827,6 +4265,140 @@ static struct cipher_testvec tf_ctr_dec_tv_template[] = { | |||
3827 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | 4265 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" |
3828 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | 4266 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", |
3829 | .klen = 32, | 4267 | .klen = 32, |
4268 | .iv = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" | ||
4269 | "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFD", | ||
4270 | .input = "\xEB\x44\xAF\x49\x27\xB8\xFB\x44" | ||
4271 | "\x4C\xA6\xC3\x0C\x8B\xD0\x01\x0C" | ||
4272 | "\x53\xC8\x16\x38\xDE\x40\x4F\x91" | ||
4273 | "\x25\x6D\x4C\xA0\x9A\x87\x1E\xDA" | ||
4274 | "\x88\x7E\x89\xE9\x67\x2B\x83\xA2" | ||
4275 | "\x5F\x2E\x23\x3E\x45\xB9\x77\x7B" | ||
4276 | "\xA6\x7E\x47\x36\x81\x9F\x9B\xF3" | ||
4277 | "\xE0\xF0\xD7\x47\xA9\xC8\xEF\x33" | ||
4278 | "\x0C\x43\xFE\x67\x50\x0A\x2C\x3E" | ||
4279 | "\xA0\xE1\x25\x8E\x80\x07\x4A\xC0" | ||
4280 | "\x64\x89\x9F\x6A\x27\x96\x07\xA6" | ||
4281 | "\x9B\xC8\x1B\x21\x60\xAE\x5D\x01" | ||
4282 | "\xE2\xCD\xC8\xAA\x6C\x9D\x1C\x34" | ||
4283 | "\x39\x18\x09\xA4\x82\x59\x78\xE7" | ||
4284 | "\xFC\x59\x65\xF2\x94\xFF\xFB\xE2" | ||
4285 | "\x3C\xDA\xB1\x90\x95\xBF\x91\xE3" | ||
4286 | "\xE6\x87\x31\x9E\x16\x85\xAD\xB1" | ||
4287 | "\x4C\xAE\x43\x4D\x19\x58\xB5\x5E" | ||
4288 | "\x2E\xF5\x09\xAA\x39\xF4\xC0\xB3" | ||
4289 | "\xD4\x4D\xDB\x73\x7A\xD4\xF1\xBF" | ||
4290 | "\x89\x16\x4D\x2D\xA2\x26\x33\x72" | ||
4291 | "\x18\x33\x7E\xD6\xD2\x16\xA4\x54" | ||
4292 | "\xF4\x8C\xB3\x52\xDF\x21\x9C\xEB" | ||
4293 | "\xBF\x49\xD3\xF9\x05\x06\xCB\xD2" | ||
4294 | "\xA9\xD2\x3B\x6E\x19\x8C\xBC\x19" | ||
4295 | "\xAB\x89\xD6\xD8\xCD\x56\x89\x5E" | ||
4296 | "\xAC\x00\xE3\x50\x63\x4A\x80\x9A" | ||
4297 | "\x05\xBC\x50\x39\xD3\x32\xD9\x0D" | ||
4298 | "\xE3\x20\x0D\x75\x54\xEC\xE6\x31" | ||
4299 | "\x14\xB9\x3A\x59\x00\x43\x37\x8E" | ||
4300 | "\x8C\x5A\x79\x62\x14\x76\x8A\xAE" | ||
4301 | "\x8F\xCC\xA1\x6C\x38\x78\xDD\x2D" | ||
4302 | "\x8B\x6D\xEA\xBD\x7B\x25\xFF\x60" | ||
4303 | "\xC9\x87\xB1\x79\x1E\xA5\x86\x68" | ||
4304 | "\x81\xB4\xE2\xC1\x05\x7D\x3A\x73" | ||
4305 | "\xD0\xDA\x75\x77\x9E\x05\x27\xF1" | ||
4306 | "\x08\xA9\x66\x64\x6C\xBC\x82\x17" | ||
4307 | "\x2C\x23\x5F\x62\x4D\x02\x1A\x58" | ||
4308 | "\xE7\xB7\x23\x6D\xE2\x20\xDA\xEF" | ||
4309 | "\xB4\xB3\x3F\xB2\x2B\x69\x98\x83" | ||
4310 | "\x95\x87\x13\x57\x60\xD7\xB5\xB1" | ||
4311 | "\xEE\x0A\x2F\x95\x36\x4C\x76\x5D" | ||
4312 | "\x5F\xD9\x19\xED\xB9\xA5\x48\xBF" | ||
4313 | "\xC8\xAB\x0F\x71\xCC\x61\x8E\x0A" | ||
4314 | "\xD0\x29\x44\xA8\xB9\xC1\xE8\xC8" | ||
4315 | "\xC9\xA8\x28\x81\xFB\x50\xF2\xF0" | ||
4316 | "\x26\xAE\x39\xB8\x91\xCD\xA8\xAC" | ||
4317 | "\xDE\x55\x1B\x50\x14\x53\x44\x17" | ||
4318 | "\x54\x46\xFC\xB1\xE4\x07\x6B\x9A" | ||
4319 | "\x01\x14\xF0\x2E\x2E\xDB\x46\x1B" | ||
4320 | "\x1A\x09\x97\xA9\xB6\x97\x79\x06" | ||
4321 | "\xFB\xCB\x85\xCF\xDD\xA1\x41\xB1" | ||
4322 | "\x00\xAA\xF7\xE0\x89\x73\xFB\xE5" | ||
4323 | "\xBF\x84\xDB\xC9\xCD\xC4\xA2\x0D" | ||
4324 | "\x3B\xAC\xF9\xDF\x96\xBF\x88\x23" | ||
4325 | "\x41\x67\xA1\x24\x99\x7E\xCC\x9B" | ||
4326 | "\x02\x8F\x6A\x49\xF6\x25\xBA\x7A" | ||
4327 | "\xF4\x78\xFD\x79\x62\x63\x4F\x14" | ||
4328 | "\xD6\x11\x11\x04\x05\x5F\x7E\xEA" | ||
4329 | "\x4C\xB6\xF8\xF4\x5F\x48\x52\x54" | ||
4330 | "\x94\x63\xA8\x4E\xCF\xD2\x1B\x1B" | ||
4331 | "\x22\x18\x6A\xAF\x6E\x3E\xE1\x0D", | ||
4332 | .ilen = 496, | ||
4333 | .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
4334 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
4335 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
4336 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
4337 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
4338 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
4339 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
4340 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" | ||
4341 | "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" | ||
4342 | "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" | ||
4343 | "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" | ||
4344 | "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" | ||
4345 | "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" | ||
4346 | "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" | ||
4347 | "\x29\xC0\x57\xEE\x62\xF9\x90\x04" | ||
4348 | "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" | ||
4349 | "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" | ||
4350 | "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" | ||
4351 | "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" | ||
4352 | "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" | ||
4353 | "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" | ||
4354 | "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" | ||
4355 | "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" | ||
4356 | "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" | ||
4357 | "\x57\xEE\x85\x1C\x90\x27\xBE\x32" | ||
4358 | "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" | ||
4359 | "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" | ||
4360 | "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" | ||
4361 | "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" | ||
4362 | "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" | ||
4363 | "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" | ||
4364 | "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" | ||
4365 | "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" | ||
4366 | "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" | ||
4367 | "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" | ||
4368 | "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" | ||
4369 | "\x69\x00\x74\x0B\xA2\x16\xAD\x44" | ||
4370 | "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" | ||
4371 | "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" | ||
4372 | "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" | ||
4373 | "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" | ||
4374 | "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" | ||
4375 | "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" | ||
4376 | "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" | ||
4377 | "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" | ||
4378 | "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" | ||
4379 | "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" | ||
4380 | "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" | ||
4381 | "\x58\xEF\x86\x1D\x91\x28\xBF\x33" | ||
4382 | "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" | ||
4383 | "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" | ||
4384 | "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" | ||
4385 | "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" | ||
4386 | "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" | ||
4387 | "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" | ||
4388 | "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" | ||
4389 | "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" | ||
4390 | "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" | ||
4391 | "\x86\x1D\xB4\x28\xBF\x56\xED\x61" | ||
4392 | "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" | ||
4393 | "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" | ||
4394 | "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", | ||
4395 | .rlen = 496, | ||
4396 | }, { /* Generated with Crypto++ */ | ||
4397 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
4398 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
4399 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
4400 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
4401 | .klen = 32, | ||
3830 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F" | 4402 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F" |
3831 | "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64", | 4403 | "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64", |
3832 | .input = "\xDF\xDD\x69\xFA\xB0\x2E\xFD\xFE" | 4404 | .input = "\xDF\xDD\x69\xFA\xB0\x2E\xFD\xFE" |
@@ -3957,6 +4529,9 @@ static struct cipher_testvec tf_ctr_dec_tv_template[] = { | |||
3957 | "\xDC\x50\xE7\x7E\x15\x89\x20\xB7" | 4529 | "\xDC\x50\xE7\x7E\x15\x89\x20\xB7" |
3958 | "\x2B\xC2\x59", | 4530 | "\x2B\xC2\x59", |
3959 | .rlen = 499, | 4531 | .rlen = 499, |
4532 | .also_non_np = 1, | ||
4533 | .np = 2, | ||
4534 | .tap = { 499 - 16, 16 }, | ||
3960 | }, | 4535 | }, |
3961 | }; | 4536 | }; |
3962 | 4537 | ||
@@ -4206,6 +4781,9 @@ static struct cipher_testvec tf_lrw_enc_tv_template[] = { | |||
4206 | "\x80\x18\xc4\x6c\x03\xd3\xb7\xba" | 4781 | "\x80\x18\xc4\x6c\x03\xd3\xb7\xba" |
4207 | "\x11\xd7\xb8\x6e\xea\xe1\x80\x30", | 4782 | "\x11\xd7\xb8\x6e\xea\xe1\x80\x30", |
4208 | .rlen = 512, | 4783 | .rlen = 512, |
4784 | .also_non_np = 1, | ||
4785 | .np = 2, | ||
4786 | .tap = { 512 - 16, 16 }, | ||
4209 | }, | 4787 | }, |
4210 | }; | 4788 | }; |
4211 | 4789 | ||
@@ -4456,6 +5034,9 @@ static struct cipher_testvec tf_lrw_dec_tv_template[] = { | |||
4456 | "\xe9\x2e\xc4\x29\x0f\x84\xdb\xc4" | 5034 | "\xe9\x2e\xc4\x29\x0f\x84\xdb\xc4" |
4457 | "\x21\xc4\xc2\x75\x67\x89\x37\x0a", | 5035 | "\x21\xc4\xc2\x75\x67\x89\x37\x0a", |
4458 | .rlen = 512, | 5036 | .rlen = 512, |
5037 | .also_non_np = 1, | ||
5038 | .np = 2, | ||
5039 | .tap = { 512 - 16, 16 }, | ||
4459 | }, | 5040 | }, |
4460 | }; | 5041 | }; |
4461 | 5042 | ||
@@ -4795,6 +5376,9 @@ static struct cipher_testvec tf_xts_enc_tv_template[] = { | |||
4795 | "\xa4\x05\x0b\xb2\xb3\xa8\x30\x97" | 5376 | "\xa4\x05\x0b\xb2\xb3\xa8\x30\x97" |
4796 | "\x37\x30\xe1\x91\x8d\xb3\x2a\xff", | 5377 | "\x37\x30\xe1\x91\x8d\xb3\x2a\xff", |
4797 | .rlen = 512, | 5378 | .rlen = 512, |
5379 | .also_non_np = 1, | ||
5380 | .np = 2, | ||
5381 | .tap = { 512 - 16, 16 }, | ||
4798 | }, | 5382 | }, |
4799 | }; | 5383 | }; |
4800 | 5384 | ||
@@ -5135,6 +5719,9 @@ static struct cipher_testvec tf_xts_dec_tv_template[] = { | |||
5135 | "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7" | 5719 | "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7" |
5136 | "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", | 5720 | "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", |
5137 | .rlen = 512, | 5721 | .rlen = 512, |
5722 | .also_non_np = 1, | ||
5723 | .np = 2, | ||
5724 | .tap = { 512 - 16, 16 }, | ||
5138 | }, | 5725 | }, |
5139 | }; | 5726 | }; |
5140 | 5727 | ||
@@ -5242,6 +5829,9 @@ static struct cipher_testvec serpent_enc_tv_template[] = { | |||
5242 | "\x30\xD4\x2C\xF2\x8E\x06\x4B\x39" | 5829 | "\x30\xD4\x2C\xF2\x8E\x06\x4B\x39" |
5243 | "\xB3\x12\x1D\xB3\x17\x46\xE6\xD6", | 5830 | "\xB3\x12\x1D\xB3\x17\x46\xE6\xD6", |
5244 | .rlen = 144, | 5831 | .rlen = 144, |
5832 | .also_non_np = 1, | ||
5833 | .np = 2, | ||
5834 | .tap = { 144 - 16, 16 }, | ||
5245 | }, | 5835 | }, |
5246 | }; | 5836 | }; |
5247 | 5837 | ||
@@ -5377,6 +5967,9 @@ static struct cipher_testvec serpent_dec_tv_template[] = { | |||
5377 | "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" | 5967 | "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" |
5378 | "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A", | 5968 | "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A", |
5379 | .rlen = 144, | 5969 | .rlen = 144, |
5970 | .also_non_np = 1, | ||
5971 | .np = 2, | ||
5972 | .tap = { 144 - 16, 16 }, | ||
5380 | }, | 5973 | }, |
5381 | }; | 5974 | }; |
5382 | 5975 | ||
@@ -5468,6 +6061,9 @@ static struct cipher_testvec serpent_cbc_enc_tv_template[] = { | |||
5468 | "\x27\xDF\x89\x1D\x86\x3E\xF7\x5A" | 6061 | "\x27\xDF\x89\x1D\x86\x3E\xF7\x5A" |
5469 | "\xF6\xE3\x0F\xC7\x6B\x4C\x96\x7C", | 6062 | "\xF6\xE3\x0F\xC7\x6B\x4C\x96\x7C", |
5470 | .rlen = 144, | 6063 | .rlen = 144, |
6064 | .also_non_np = 1, | ||
6065 | .np = 2, | ||
6066 | .tap = { 144 - 16, 16 }, | ||
5471 | }, | 6067 | }, |
5472 | }; | 6068 | }; |
5473 | 6069 | ||
@@ -5518,6 +6114,9 @@ static struct cipher_testvec serpent_cbc_dec_tv_template[] = { | |||
5518 | "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" | 6114 | "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" |
5519 | "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A", | 6115 | "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A", |
5520 | .rlen = 144, | 6116 | .rlen = 144, |
6117 | .also_non_np = 1, | ||
6118 | .np = 2, | ||
6119 | .tap = { 144 - 16, 16 }, | ||
5521 | }, | 6120 | }, |
5522 | }; | 6121 | }; |
5523 | 6122 | ||
@@ -5616,6 +6215,143 @@ static struct cipher_testvec serpent_ctr_enc_tv_template[] = { | |||
5616 | "\x5D\xE1\x4F\xA1\xEA\xB3\xCA\xB9" | 6215 | "\x5D\xE1\x4F\xA1\xEA\xB3\xCA\xB9" |
5617 | "\xE6\xD0\x97", | 6216 | "\xE6\xD0\x97", |
5618 | .rlen = 147, | 6217 | .rlen = 147, |
6218 | .also_non_np = 1, | ||
6219 | .np = 2, | ||
6220 | .tap = { 147 - 16, 16 }, | ||
6221 | }, { /* Generated with Crypto++ */ | ||
6222 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
6223 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
6224 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
6225 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
6226 | .klen = 32, | ||
6227 | .iv = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" | ||
6228 | "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFD", | ||
6229 | .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
6230 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
6231 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
6232 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
6233 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
6234 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
6235 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
6236 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" | ||
6237 | "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" | ||
6238 | "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" | ||
6239 | "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" | ||
6240 | "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" | ||
6241 | "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" | ||
6242 | "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" | ||
6243 | "\x29\xC0\x57\xEE\x62\xF9\x90\x04" | ||
6244 | "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" | ||
6245 | "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" | ||
6246 | "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" | ||
6247 | "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" | ||
6248 | "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" | ||
6249 | "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" | ||
6250 | "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" | ||
6251 | "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" | ||
6252 | "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" | ||
6253 | "\x57\xEE\x85\x1C\x90\x27\xBE\x32" | ||
6254 | "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" | ||
6255 | "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" | ||
6256 | "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" | ||
6257 | "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" | ||
6258 | "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" | ||
6259 | "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" | ||
6260 | "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" | ||
6261 | "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" | ||
6262 | "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" | ||
6263 | "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" | ||
6264 | "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" | ||
6265 | "\x69\x00\x74\x0B\xA2\x16\xAD\x44" | ||
6266 | "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" | ||
6267 | "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" | ||
6268 | "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" | ||
6269 | "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" | ||
6270 | "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" | ||
6271 | "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" | ||
6272 | "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" | ||
6273 | "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" | ||
6274 | "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" | ||
6275 | "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" | ||
6276 | "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" | ||
6277 | "\x58\xEF\x86\x1D\x91\x28\xBF\x33" | ||
6278 | "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" | ||
6279 | "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" | ||
6280 | "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" | ||
6281 | "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" | ||
6282 | "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" | ||
6283 | "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" | ||
6284 | "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" | ||
6285 | "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" | ||
6286 | "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" | ||
6287 | "\x86\x1D\xB4\x28\xBF\x56\xED\x61" | ||
6288 | "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" | ||
6289 | "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" | ||
6290 | "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", | ||
6291 | .ilen = 496, | ||
6292 | .result = "\x06\x9A\xF8\xB4\x53\x88\x62\xFC" | ||
6293 | "\x68\xB8\x2E\xDF\xC1\x05\x0F\x3D" | ||
6294 | "\xAF\x4D\x95\xAE\xC4\xE9\x1C\xDC" | ||
6295 | "\xF6\x2B\x8F\x90\x89\xF6\x7E\x1A" | ||
6296 | "\xA6\xB9\xE4\xF4\xFA\xCA\xE5\x7E" | ||
6297 | "\x71\x28\x06\x4F\xE8\x08\x39\xDA" | ||
6298 | "\xA5\x0E\xC8\xC0\xB8\x16\xE5\x69" | ||
6299 | "\xE5\xCA\xEC\x4F\x63\x2C\xC0\x9B" | ||
6300 | "\x9F\x3E\x39\x79\xF0\xCD\x64\x35" | ||
6301 | "\x4A\xD3\xC8\xA9\x31\xCD\x48\x5B" | ||
6302 | "\x92\x3D\x8F\x3F\x96\xBD\xB3\x18" | ||
6303 | "\x74\x2A\x5D\x29\x3F\x57\x8F\xE2" | ||
6304 | "\x67\x9A\xE0\xE5\xD4\x4A\xE2\x47" | ||
6305 | "\xBC\xF6\xEB\x14\xF3\x8C\x20\xC2" | ||
6306 | "\x7D\xE2\x43\x81\x86\x72\x2E\xB1" | ||
6307 | "\x39\xF6\x95\xE1\x1F\xCB\x76\x33" | ||
6308 | "\x5B\x7D\x23\x0F\x3A\x67\x2A\x2F" | ||
6309 | "\xB9\x37\x9D\xDD\x1F\x16\xA1\x3C" | ||
6310 | "\x70\xFE\x52\xAA\x93\x3C\xC4\x46" | ||
6311 | "\xB1\xE5\xFF\xDA\xAF\xE2\x84\xFE" | ||
6312 | "\x25\x92\xB2\x63\xBD\x49\x77\xB4" | ||
6313 | "\x22\xA4\x6A\xD5\x04\xE0\x45\x58" | ||
6314 | "\x1C\x34\x96\x7C\x03\x0C\x13\xA2" | ||
6315 | "\x05\x22\xE2\xCB\x5A\x35\x03\x09" | ||
6316 | "\x40\xD2\x82\x05\xCA\x58\x73\xF2" | ||
6317 | "\x29\x5E\x01\x47\x13\x32\x78\xBE" | ||
6318 | "\x06\xB0\x51\xDB\x6C\x31\xA0\x1C" | ||
6319 | "\x74\xBC\x8D\x25\xDF\xF8\x65\xD1" | ||
6320 | "\x38\x35\x11\x26\x4A\xB4\x06\x32" | ||
6321 | "\xFA\xD2\x07\x77\xB3\x74\x98\x80" | ||
6322 | "\x61\x59\xA8\x9F\xF3\x6F\x2A\xBF" | ||
6323 | "\xE6\xA5\x9A\xC4\x6B\xA6\x49\x6F" | ||
6324 | "\xBC\x47\xD9\xFB\xC6\xEF\x25\x65" | ||
6325 | "\x96\xAC\x9F\xE4\x81\x4B\xD8\xBA" | ||
6326 | "\xD6\x9B\xC9\x6D\x58\x40\x81\x02" | ||
6327 | "\x73\x44\x4E\x43\x6E\x37\xBB\x11" | ||
6328 | "\xE3\xF9\xB8\x2F\xEC\x76\x34\xEA" | ||
6329 | "\x90\xCD\xB7\x2E\x0E\x32\x71\xE8" | ||
6330 | "\xBB\x4E\x0B\x98\xA4\x17\x17\x5B" | ||
6331 | "\x07\xB5\x82\x3A\xC4\xE8\x42\x51" | ||
6332 | "\x5A\x4C\x4E\x7D\xBF\xC4\xC0\x4F" | ||
6333 | "\x68\xB8\xC6\x4A\x32\x6F\x0B\xD7" | ||
6334 | "\x85\xED\x6B\xFB\x72\xD2\xA5\x8F" | ||
6335 | "\xBF\xF9\xAC\x59\x50\xA8\x08\x70" | ||
6336 | "\xEC\xBD\x0A\xBF\xE5\x87\xA1\xC2" | ||
6337 | "\x92\x14\x78\xAF\xE8\xEA\x2E\xDD" | ||
6338 | "\xC1\x03\x9A\xAA\x89\x8B\x32\x46" | ||
6339 | "\x5B\x18\x27\xBA\x46\xAA\x64\xDE" | ||
6340 | "\xE3\xD5\xA3\xFC\x7B\x5B\x61\xDB" | ||
6341 | "\x7E\xDA\xEC\x30\x17\x19\xF8\x80" | ||
6342 | "\xB5\x5E\x27\xB5\x37\x3A\x1F\x28" | ||
6343 | "\x07\x73\xC3\x63\xCE\xFF\x8C\xFE" | ||
6344 | "\x81\x4E\xF8\x24\xF3\xB8\xC7\xE8" | ||
6345 | "\x16\x9A\xCC\x58\x2F\x88\x1C\x4B" | ||
6346 | "\xBB\x33\xA2\x73\xF0\x1C\x89\x0E" | ||
6347 | "\xDC\x34\x27\x89\x98\xCE\x1C\xA2" | ||
6348 | "\xD8\xB8\x90\xBE\xEC\x72\x28\x13" | ||
6349 | "\xAC\x7B\xF1\xD0\x7F\x7A\x28\x50" | ||
6350 | "\xB7\x99\x65\x8A\xC9\xC6\x21\x34" | ||
6351 | "\x7F\x67\x9D\xB7\x2C\xCC\xF5\x17" | ||
6352 | "\x2B\x89\xAC\xB0\xD7\x1E\x47\xB0" | ||
6353 | "\x61\xAF\xD4\x63\x6D\xB8\x2D\x20", | ||
6354 | .rlen = 496, | ||
5619 | }, | 6355 | }, |
5620 | }; | 6356 | }; |
5621 | 6357 | ||
@@ -5714,6 +6450,143 @@ static struct cipher_testvec serpent_ctr_dec_tv_template[] = { | |||
5714 | "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" | 6450 | "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" |
5715 | "\xF1\x65\xFC", | 6451 | "\xF1\x65\xFC", |
5716 | .rlen = 147, | 6452 | .rlen = 147, |
6453 | .also_non_np = 1, | ||
6454 | .np = 2, | ||
6455 | .tap = { 147 - 16, 16 }, | ||
6456 | }, { /* Generated with Crypto++ */ | ||
6457 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
6458 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
6459 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
6460 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
6461 | .klen = 32, | ||
6462 | .iv = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" | ||
6463 | "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFD", | ||
6464 | .input = "\x06\x9A\xF8\xB4\x53\x88\x62\xFC" | ||
6465 | "\x68\xB8\x2E\xDF\xC1\x05\x0F\x3D" | ||
6466 | "\xAF\x4D\x95\xAE\xC4\xE9\x1C\xDC" | ||
6467 | "\xF6\x2B\x8F\x90\x89\xF6\x7E\x1A" | ||
6468 | "\xA6\xB9\xE4\xF4\xFA\xCA\xE5\x7E" | ||
6469 | "\x71\x28\x06\x4F\xE8\x08\x39\xDA" | ||
6470 | "\xA5\x0E\xC8\xC0\xB8\x16\xE5\x69" | ||
6471 | "\xE5\xCA\xEC\x4F\x63\x2C\xC0\x9B" | ||
6472 | "\x9F\x3E\x39\x79\xF0\xCD\x64\x35" | ||
6473 | "\x4A\xD3\xC8\xA9\x31\xCD\x48\x5B" | ||
6474 | "\x92\x3D\x8F\x3F\x96\xBD\xB3\x18" | ||
6475 | "\x74\x2A\x5D\x29\x3F\x57\x8F\xE2" | ||
6476 | "\x67\x9A\xE0\xE5\xD4\x4A\xE2\x47" | ||
6477 | "\xBC\xF6\xEB\x14\xF3\x8C\x20\xC2" | ||
6478 | "\x7D\xE2\x43\x81\x86\x72\x2E\xB1" | ||
6479 | "\x39\xF6\x95\xE1\x1F\xCB\x76\x33" | ||
6480 | "\x5B\x7D\x23\x0F\x3A\x67\x2A\x2F" | ||
6481 | "\xB9\x37\x9D\xDD\x1F\x16\xA1\x3C" | ||
6482 | "\x70\xFE\x52\xAA\x93\x3C\xC4\x46" | ||
6483 | "\xB1\xE5\xFF\xDA\xAF\xE2\x84\xFE" | ||
6484 | "\x25\x92\xB2\x63\xBD\x49\x77\xB4" | ||
6485 | "\x22\xA4\x6A\xD5\x04\xE0\x45\x58" | ||
6486 | "\x1C\x34\x96\x7C\x03\x0C\x13\xA2" | ||
6487 | "\x05\x22\xE2\xCB\x5A\x35\x03\x09" | ||
6488 | "\x40\xD2\x82\x05\xCA\x58\x73\xF2" | ||
6489 | "\x29\x5E\x01\x47\x13\x32\x78\xBE" | ||
6490 | "\x06\xB0\x51\xDB\x6C\x31\xA0\x1C" | ||
6491 | "\x74\xBC\x8D\x25\xDF\xF8\x65\xD1" | ||
6492 | "\x38\x35\x11\x26\x4A\xB4\x06\x32" | ||
6493 | "\xFA\xD2\x07\x77\xB3\x74\x98\x80" | ||
6494 | "\x61\x59\xA8\x9F\xF3\x6F\x2A\xBF" | ||
6495 | "\xE6\xA5\x9A\xC4\x6B\xA6\x49\x6F" | ||
6496 | "\xBC\x47\xD9\xFB\xC6\xEF\x25\x65" | ||
6497 | "\x96\xAC\x9F\xE4\x81\x4B\xD8\xBA" | ||
6498 | "\xD6\x9B\xC9\x6D\x58\x40\x81\x02" | ||
6499 | "\x73\x44\x4E\x43\x6E\x37\xBB\x11" | ||
6500 | "\xE3\xF9\xB8\x2F\xEC\x76\x34\xEA" | ||
6501 | "\x90\xCD\xB7\x2E\x0E\x32\x71\xE8" | ||
6502 | "\xBB\x4E\x0B\x98\xA4\x17\x17\x5B" | ||
6503 | "\x07\xB5\x82\x3A\xC4\xE8\x42\x51" | ||
6504 | "\x5A\x4C\x4E\x7D\xBF\xC4\xC0\x4F" | ||
6505 | "\x68\xB8\xC6\x4A\x32\x6F\x0B\xD7" | ||
6506 | "\x85\xED\x6B\xFB\x72\xD2\xA5\x8F" | ||
6507 | "\xBF\xF9\xAC\x59\x50\xA8\x08\x70" | ||
6508 | "\xEC\xBD\x0A\xBF\xE5\x87\xA1\xC2" | ||
6509 | "\x92\x14\x78\xAF\xE8\xEA\x2E\xDD" | ||
6510 | "\xC1\x03\x9A\xAA\x89\x8B\x32\x46" | ||
6511 | "\x5B\x18\x27\xBA\x46\xAA\x64\xDE" | ||
6512 | "\xE3\xD5\xA3\xFC\x7B\x5B\x61\xDB" | ||
6513 | "\x7E\xDA\xEC\x30\x17\x19\xF8\x80" | ||
6514 | "\xB5\x5E\x27\xB5\x37\x3A\x1F\x28" | ||
6515 | "\x07\x73\xC3\x63\xCE\xFF\x8C\xFE" | ||
6516 | "\x81\x4E\xF8\x24\xF3\xB8\xC7\xE8" | ||
6517 | "\x16\x9A\xCC\x58\x2F\x88\x1C\x4B" | ||
6518 | "\xBB\x33\xA2\x73\xF0\x1C\x89\x0E" | ||
6519 | "\xDC\x34\x27\x89\x98\xCE\x1C\xA2" | ||
6520 | "\xD8\xB8\x90\xBE\xEC\x72\x28\x13" | ||
6521 | "\xAC\x7B\xF1\xD0\x7F\x7A\x28\x50" | ||
6522 | "\xB7\x99\x65\x8A\xC9\xC6\x21\x34" | ||
6523 | "\x7F\x67\x9D\xB7\x2C\xCC\xF5\x17" | ||
6524 | "\x2B\x89\xAC\xB0\xD7\x1E\x47\xB0" | ||
6525 | "\x61\xAF\xD4\x63\x6D\xB8\x2D\x20", | ||
6526 | .ilen = 496, | ||
6527 | .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
6528 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
6529 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
6530 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
6531 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
6532 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
6533 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
6534 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" | ||
6535 | "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" | ||
6536 | "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" | ||
6537 | "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" | ||
6538 | "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" | ||
6539 | "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" | ||
6540 | "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" | ||
6541 | "\x29\xC0\x57\xEE\x62\xF9\x90\x04" | ||
6542 | "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" | ||
6543 | "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" | ||
6544 | "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" | ||
6545 | "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" | ||
6546 | "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" | ||
6547 | "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" | ||
6548 | "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" | ||
6549 | "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" | ||
6550 | "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" | ||
6551 | "\x57\xEE\x85\x1C\x90\x27\xBE\x32" | ||
6552 | "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" | ||
6553 | "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" | ||
6554 | "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" | ||
6555 | "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" | ||
6556 | "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" | ||
6557 | "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" | ||
6558 | "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" | ||
6559 | "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" | ||
6560 | "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" | ||
6561 | "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" | ||
6562 | "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" | ||
6563 | "\x69\x00\x74\x0B\xA2\x16\xAD\x44" | ||
6564 | "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" | ||
6565 | "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" | ||
6566 | "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" | ||
6567 | "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" | ||
6568 | "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" | ||
6569 | "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" | ||
6570 | "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" | ||
6571 | "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" | ||
6572 | "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" | ||
6573 | "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" | ||
6574 | "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" | ||
6575 | "\x58\xEF\x86\x1D\x91\x28\xBF\x33" | ||
6576 | "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" | ||
6577 | "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" | ||
6578 | "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" | ||
6579 | "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" | ||
6580 | "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" | ||
6581 | "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" | ||
6582 | "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" | ||
6583 | "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" | ||
6584 | "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" | ||
6585 | "\x86\x1D\xB4\x28\xBF\x56\xED\x61" | ||
6586 | "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" | ||
6587 | "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" | ||
6588 | "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", | ||
6589 | .rlen = 496, | ||
5717 | }, | 6590 | }, |
5718 | }; | 6591 | }; |
5719 | 6592 | ||
@@ -5963,6 +6836,9 @@ static struct cipher_testvec serpent_lrw_enc_tv_template[] = { | |||
5963 | "\x5c\xc6\x84\xfe\x7c\xcb\x26\xfd" | 6836 | "\x5c\xc6\x84\xfe\x7c\xcb\x26\xfd" |
5964 | "\xd9\x51\x0f\xd7\x94\x2f\xc5\xa7", | 6837 | "\xd9\x51\x0f\xd7\x94\x2f\xc5\xa7", |
5965 | .rlen = 512, | 6838 | .rlen = 512, |
6839 | .also_non_np = 1, | ||
6840 | .np = 2, | ||
6841 | .tap = { 512 - 16, 16 }, | ||
5966 | }, | 6842 | }, |
5967 | }; | 6843 | }; |
5968 | 6844 | ||
@@ -6213,6 +7089,9 @@ static struct cipher_testvec serpent_lrw_dec_tv_template[] = { | |||
6213 | "\xe9\x2e\xc4\x29\x0f\x84\xdb\xc4" | 7089 | "\xe9\x2e\xc4\x29\x0f\x84\xdb\xc4" |
6214 | "\x21\xc4\xc2\x75\x67\x89\x37\x0a", | 7090 | "\x21\xc4\xc2\x75\x67\x89\x37\x0a", |
6215 | .rlen = 512, | 7091 | .rlen = 512, |
7092 | .also_non_np = 1, | ||
7093 | .np = 2, | ||
7094 | .tap = { 512 - 16, 16 }, | ||
6216 | }, | 7095 | }, |
6217 | }; | 7096 | }; |
6218 | 7097 | ||
@@ -6552,6 +7431,9 @@ static struct cipher_testvec serpent_xts_enc_tv_template[] = { | |||
6552 | "\xaf\x43\x0b\xc5\x20\x41\x92\x20" | 7431 | "\xaf\x43\x0b\xc5\x20\x41\x92\x20" |
6553 | "\xd4\xa0\x91\x98\x11\x5f\x4d\xb1", | 7432 | "\xd4\xa0\x91\x98\x11\x5f\x4d\xb1", |
6554 | .rlen = 512, | 7433 | .rlen = 512, |
7434 | .also_non_np = 1, | ||
7435 | .np = 2, | ||
7436 | .tap = { 512 - 16, 16 }, | ||
6555 | }, | 7437 | }, |
6556 | }; | 7438 | }; |
6557 | 7439 | ||
@@ -6892,12 +7774,23 @@ static struct cipher_testvec serpent_xts_dec_tv_template[] = { | |||
6892 | "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7" | 7774 | "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7" |
6893 | "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", | 7775 | "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", |
6894 | .rlen = 512, | 7776 | .rlen = 512, |
7777 | .also_non_np = 1, | ||
7778 | .np = 2, | ||
7779 | .tap = { 512 - 16, 16 }, | ||
6895 | }, | 7780 | }, |
6896 | }; | 7781 | }; |
6897 | 7782 | ||
6898 | /* Cast6 test vectors from RFC 2612 */ | 7783 | /* Cast6 test vectors from RFC 2612 */ |
6899 | #define CAST6_ENC_TEST_VECTORS 3 | 7784 | #define CAST6_ENC_TEST_VECTORS 4 |
6900 | #define CAST6_DEC_TEST_VECTORS 3 | 7785 | #define CAST6_DEC_TEST_VECTORS 4 |
7786 | #define CAST6_CBC_ENC_TEST_VECTORS 1 | ||
7787 | #define CAST6_CBC_DEC_TEST_VECTORS 1 | ||
7788 | #define CAST6_CTR_ENC_TEST_VECTORS 2 | ||
7789 | #define CAST6_CTR_DEC_TEST_VECTORS 2 | ||
7790 | #define CAST6_LRW_ENC_TEST_VECTORS 1 | ||
7791 | #define CAST6_LRW_DEC_TEST_VECTORS 1 | ||
7792 | #define CAST6_XTS_ENC_TEST_VECTORS 1 | ||
7793 | #define CAST6_XTS_DEC_TEST_VECTORS 1 | ||
6901 | 7794 | ||
6902 | static struct cipher_testvec cast6_enc_tv_template[] = { | 7795 | static struct cipher_testvec cast6_enc_tv_template[] = { |
6903 | { | 7796 | { |
@@ -6930,6 +7823,143 @@ static struct cipher_testvec cast6_enc_tv_template[] = { | |||
6930 | .result = "\x4f\x6a\x20\x38\x28\x68\x97\xb9" | 7823 | .result = "\x4f\x6a\x20\x38\x28\x68\x97\xb9" |
6931 | "\xc9\x87\x01\x36\x55\x33\x17\xfa", | 7824 | "\xc9\x87\x01\x36\x55\x33\x17\xfa", |
6932 | .rlen = 16, | 7825 | .rlen = 16, |
7826 | }, { /* Generated from TF test vectors */ | ||
7827 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
7828 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
7829 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
7830 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
7831 | .klen = 32, | ||
7832 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F" | ||
7833 | "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64", | ||
7834 | .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
7835 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
7836 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
7837 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
7838 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
7839 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
7840 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
7841 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" | ||
7842 | "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" | ||
7843 | "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" | ||
7844 | "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" | ||
7845 | "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" | ||
7846 | "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" | ||
7847 | "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" | ||
7848 | "\x29\xC0\x57\xEE\x62\xF9\x90\x04" | ||
7849 | "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" | ||
7850 | "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" | ||
7851 | "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" | ||
7852 | "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" | ||
7853 | "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" | ||
7854 | "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" | ||
7855 | "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" | ||
7856 | "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" | ||
7857 | "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" | ||
7858 | "\x57\xEE\x85\x1C\x90\x27\xBE\x32" | ||
7859 | "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" | ||
7860 | "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" | ||
7861 | "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" | ||
7862 | "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" | ||
7863 | "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" | ||
7864 | "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" | ||
7865 | "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" | ||
7866 | "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" | ||
7867 | "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" | ||
7868 | "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" | ||
7869 | "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" | ||
7870 | "\x69\x00\x74\x0B\xA2\x16\xAD\x44" | ||
7871 | "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" | ||
7872 | "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" | ||
7873 | "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" | ||
7874 | "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" | ||
7875 | "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" | ||
7876 | "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" | ||
7877 | "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" | ||
7878 | "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" | ||
7879 | "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" | ||
7880 | "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" | ||
7881 | "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" | ||
7882 | "\x58\xEF\x86\x1D\x91\x28\xBF\x33" | ||
7883 | "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" | ||
7884 | "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" | ||
7885 | "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" | ||
7886 | "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" | ||
7887 | "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" | ||
7888 | "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" | ||
7889 | "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" | ||
7890 | "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" | ||
7891 | "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" | ||
7892 | "\x86\x1D\xB4\x28\xBF\x56\xED\x61" | ||
7893 | "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" | ||
7894 | "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" | ||
7895 | "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", | ||
7896 | .ilen = 496, | ||
7897 | .result = "\xC3\x70\x22\x32\xF5\x80\xCB\x54" | ||
7898 | "\xFC\x30\xE0\xF6\xEB\x39\x57\xA6" | ||
7899 | "\xB6\xB9\xC5\xA4\x91\x55\x14\x97" | ||
7900 | "\xC1\x20\xFF\x6C\x5C\xF0\x67\xEA" | ||
7901 | "\x2F\xED\xD8\xC9\xFB\x38\x3F\xFE" | ||
7902 | "\x93\xBE\xDC\x00\xD3\x7F\xAD\x4C" | ||
7903 | "\x5A\x08\x92\xD1\x47\x0C\xFA\x6C" | ||
7904 | "\xD0\x6A\x99\x10\x72\xF8\x47\x62" | ||
7905 | "\x81\x42\xF8\xD8\xF5\xBB\x94\x08" | ||
7906 | "\xAA\x97\xA2\x8B\x69\xB3\xD2\x7E" | ||
7907 | "\xBC\xB5\x00\x0C\xE5\x44\x4B\x58" | ||
7908 | "\xE8\x63\xDC\xB3\xC4\xE5\x23\x12" | ||
7909 | "\x5A\x72\x85\x47\x8B\xEC\x9F\x26" | ||
7910 | "\x84\xB6\xED\x10\x33\x63\x9B\x5F" | ||
7911 | "\x4D\x53\xEE\x94\x45\x8B\x60\x58" | ||
7912 | "\x86\x20\xF9\x1E\x82\x08\x3E\x58" | ||
7913 | "\x60\x1B\x34\x19\x02\xBE\x4E\x09" | ||
7914 | "\xBB\x7C\x15\xCC\x60\x27\x55\x7A" | ||
7915 | "\x12\xB8\xD8\x08\x89\x3C\xA6\xF3" | ||
7916 | "\xF1\xDD\xA7\x07\xA3\x12\x85\x28" | ||
7917 | "\xE9\x57\xAC\x80\x0C\x5C\x0F\x3A" | ||
7918 | "\x5D\xC2\x91\xC7\x90\xE4\x8C\x43" | ||
7919 | "\x92\xE4\x7C\x26\x69\x4D\x83\x68" | ||
7920 | "\x14\x96\x42\x47\xBD\xA9\xE4\x8A" | ||
7921 | "\x33\x19\xEB\x54\x8E\x0D\x4B\x6E" | ||
7922 | "\x91\x51\xB5\x36\x08\xDE\x1C\x06" | ||
7923 | "\x03\xBD\xDE\x81\x26\xF7\x99\xC2" | ||
7924 | "\xBA\xF7\x6D\x87\x0D\xE4\xA6\xCF" | ||
7925 | "\xC1\xF5\x27\x05\xB8\x02\x57\x72" | ||
7926 | "\xE6\x42\x13\x0B\xC6\x47\x05\x74" | ||
7927 | "\x24\x15\xF7\x0D\xC2\x23\x9D\xB9" | ||
7928 | "\x3C\x77\x18\x93\xBA\xB4\xFC\x8C" | ||
7929 | "\x98\x82\x67\x67\xB4\xD7\xD3\x43" | ||
7930 | "\x23\x08\x02\xB7\x9B\x99\x05\xFB" | ||
7931 | "\xD3\xB5\x00\x0A\xA9\x9D\x66\xD6" | ||
7932 | "\x2E\x49\x58\xD0\xA8\x57\x29\x7F" | ||
7933 | "\x0A\x0E\x7D\xFC\x92\x83\xCC\x67" | ||
7934 | "\xA2\xB1\x70\x3A\x8F\x87\x4A\x8D" | ||
7935 | "\x17\xE2\x58\x2B\x88\x0D\x68\x62" | ||
7936 | "\xBF\x35\xD1\x6F\xC0\xF0\x18\x62" | ||
7937 | "\xB2\xC7\x2D\x58\xC7\x16\xDE\x08" | ||
7938 | "\xEB\x84\x1D\x25\xA7\x38\x94\x06" | ||
7939 | "\x93\x9D\xF8\xFE\x88\x71\xE7\x84" | ||
7940 | "\x2C\xA0\x38\xA3\x1D\x48\xCF\x29" | ||
7941 | "\x0B\xBC\xD8\x50\x99\x1A\x26\xFB" | ||
7942 | "\x8E\x75\x3D\x73\xEB\x6A\xED\x29" | ||
7943 | "\xE0\x8E\xED\xFC\xFE\x6F\xF6\xBA" | ||
7944 | "\x41\xE2\x10\x4C\x01\x8B\x69\x2B" | ||
7945 | "\x25\x3F\x4D\x70\x7B\x92\xD6\x3B" | ||
7946 | "\xAC\xF9\x77\x18\xD9\x6A\x30\xA6" | ||
7947 | "\x2E\xFA\x30\xFF\xC8\xD5\x1D\x06" | ||
7948 | "\x59\x28\x1D\x86\x43\x04\x5D\x3B" | ||
7949 | "\x99\x4C\x04\x5A\x21\x17\x8B\x76" | ||
7950 | "\x8F\x72\xCB\xA1\x9C\x29\x4C\xC3" | ||
7951 | "\x65\xA2\x58\x2A\xC5\x66\x24\xBF" | ||
7952 | "\xBA\xE6\x0C\xDD\x34\x24\x74\xC8" | ||
7953 | "\x84\x0A\x66\x2C\xBE\x8F\x32\xA9" | ||
7954 | "\xE7\xE4\xA1\xD7\xDA\xAB\x23\x1E" | ||
7955 | "\xEB\xEE\x6C\x94\x6F\x9C\x2E\xD1" | ||
7956 | "\x49\x2C\xF3\xD4\x90\xCC\x93\x4C" | ||
7957 | "\x84\x52\x6D\x68\xDE\xC6\x64\xB2" | ||
7958 | "\x11\x74\x93\x57\xB4\x7E\xC6\x00", | ||
7959 | .rlen = 496, | ||
7960 | .also_non_np = 1, | ||
7961 | .np = 2, | ||
7962 | .tap = { 496 - 16, 16 }, | ||
6933 | }, | 7963 | }, |
6934 | }; | 7964 | }; |
6935 | 7965 | ||
@@ -6964,6 +7994,1331 @@ static struct cipher_testvec cast6_dec_tv_template[] = { | |||
6964 | .ilen = 16, | 7994 | .ilen = 16, |
6965 | .result = zeroed_string, | 7995 | .result = zeroed_string, |
6966 | .rlen = 16, | 7996 | .rlen = 16, |
7997 | }, { /* Generated from TF test vectors */ | ||
7998 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
7999 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
8000 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
8001 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
8002 | .klen = 32, | ||
8003 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F" | ||
8004 | "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64", | ||
8005 | .input = "\xC3\x70\x22\x32\xF5\x80\xCB\x54" | ||
8006 | "\xFC\x30\xE0\xF6\xEB\x39\x57\xA6" | ||
8007 | "\xB6\xB9\xC5\xA4\x91\x55\x14\x97" | ||
8008 | "\xC1\x20\xFF\x6C\x5C\xF0\x67\xEA" | ||
8009 | "\x2F\xED\xD8\xC9\xFB\x38\x3F\xFE" | ||
8010 | "\x93\xBE\xDC\x00\xD3\x7F\xAD\x4C" | ||
8011 | "\x5A\x08\x92\xD1\x47\x0C\xFA\x6C" | ||
8012 | "\xD0\x6A\x99\x10\x72\xF8\x47\x62" | ||
8013 | "\x81\x42\xF8\xD8\xF5\xBB\x94\x08" | ||
8014 | "\xAA\x97\xA2\x8B\x69\xB3\xD2\x7E" | ||
8015 | "\xBC\xB5\x00\x0C\xE5\x44\x4B\x58" | ||
8016 | "\xE8\x63\xDC\xB3\xC4\xE5\x23\x12" | ||
8017 | "\x5A\x72\x85\x47\x8B\xEC\x9F\x26" | ||
8018 | "\x84\xB6\xED\x10\x33\x63\x9B\x5F" | ||
8019 | "\x4D\x53\xEE\x94\x45\x8B\x60\x58" | ||
8020 | "\x86\x20\xF9\x1E\x82\x08\x3E\x58" | ||
8021 | "\x60\x1B\x34\x19\x02\xBE\x4E\x09" | ||
8022 | "\xBB\x7C\x15\xCC\x60\x27\x55\x7A" | ||
8023 | "\x12\xB8\xD8\x08\x89\x3C\xA6\xF3" | ||
8024 | "\xF1\xDD\xA7\x07\xA3\x12\x85\x28" | ||
8025 | "\xE9\x57\xAC\x80\x0C\x5C\x0F\x3A" | ||
8026 | "\x5D\xC2\x91\xC7\x90\xE4\x8C\x43" | ||
8027 | "\x92\xE4\x7C\x26\x69\x4D\x83\x68" | ||
8028 | "\x14\x96\x42\x47\xBD\xA9\xE4\x8A" | ||
8029 | "\x33\x19\xEB\x54\x8E\x0D\x4B\x6E" | ||
8030 | "\x91\x51\xB5\x36\x08\xDE\x1C\x06" | ||
8031 | "\x03\xBD\xDE\x81\x26\xF7\x99\xC2" | ||
8032 | "\xBA\xF7\x6D\x87\x0D\xE4\xA6\xCF" | ||
8033 | "\xC1\xF5\x27\x05\xB8\x02\x57\x72" | ||
8034 | "\xE6\x42\x13\x0B\xC6\x47\x05\x74" | ||
8035 | "\x24\x15\xF7\x0D\xC2\x23\x9D\xB9" | ||
8036 | "\x3C\x77\x18\x93\xBA\xB4\xFC\x8C" | ||
8037 | "\x98\x82\x67\x67\xB4\xD7\xD3\x43" | ||
8038 | "\x23\x08\x02\xB7\x9B\x99\x05\xFB" | ||
8039 | "\xD3\xB5\x00\x0A\xA9\x9D\x66\xD6" | ||
8040 | "\x2E\x49\x58\xD0\xA8\x57\x29\x7F" | ||
8041 | "\x0A\x0E\x7D\xFC\x92\x83\xCC\x67" | ||
8042 | "\xA2\xB1\x70\x3A\x8F\x87\x4A\x8D" | ||
8043 | "\x17\xE2\x58\x2B\x88\x0D\x68\x62" | ||
8044 | "\xBF\x35\xD1\x6F\xC0\xF0\x18\x62" | ||
8045 | "\xB2\xC7\x2D\x58\xC7\x16\xDE\x08" | ||
8046 | "\xEB\x84\x1D\x25\xA7\x38\x94\x06" | ||
8047 | "\x93\x9D\xF8\xFE\x88\x71\xE7\x84" | ||
8048 | "\x2C\xA0\x38\xA3\x1D\x48\xCF\x29" | ||
8049 | "\x0B\xBC\xD8\x50\x99\x1A\x26\xFB" | ||
8050 | "\x8E\x75\x3D\x73\xEB\x6A\xED\x29" | ||
8051 | "\xE0\x8E\xED\xFC\xFE\x6F\xF6\xBA" | ||
8052 | "\x41\xE2\x10\x4C\x01\x8B\x69\x2B" | ||
8053 | "\x25\x3F\x4D\x70\x7B\x92\xD6\x3B" | ||
8054 | "\xAC\xF9\x77\x18\xD9\x6A\x30\xA6" | ||
8055 | "\x2E\xFA\x30\xFF\xC8\xD5\x1D\x06" | ||
8056 | "\x59\x28\x1D\x86\x43\x04\x5D\x3B" | ||
8057 | "\x99\x4C\x04\x5A\x21\x17\x8B\x76" | ||
8058 | "\x8F\x72\xCB\xA1\x9C\x29\x4C\xC3" | ||
8059 | "\x65\xA2\x58\x2A\xC5\x66\x24\xBF" | ||
8060 | "\xBA\xE6\x0C\xDD\x34\x24\x74\xC8" | ||
8061 | "\x84\x0A\x66\x2C\xBE\x8F\x32\xA9" | ||
8062 | "\xE7\xE4\xA1\xD7\xDA\xAB\x23\x1E" | ||
8063 | "\xEB\xEE\x6C\x94\x6F\x9C\x2E\xD1" | ||
8064 | "\x49\x2C\xF3\xD4\x90\xCC\x93\x4C" | ||
8065 | "\x84\x52\x6D\x68\xDE\xC6\x64\xB2" | ||
8066 | "\x11\x74\x93\x57\xB4\x7E\xC6\x00", | ||
8067 | .ilen = 496, | ||
8068 | .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
8069 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
8070 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
8071 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
8072 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
8073 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
8074 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
8075 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" | ||
8076 | "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" | ||
8077 | "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" | ||
8078 | "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" | ||
8079 | "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" | ||
8080 | "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" | ||
8081 | "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" | ||
8082 | "\x29\xC0\x57\xEE\x62\xF9\x90\x04" | ||
8083 | "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" | ||
8084 | "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" | ||
8085 | "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" | ||
8086 | "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" | ||
8087 | "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" | ||
8088 | "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" | ||
8089 | "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" | ||
8090 | "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" | ||
8091 | "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" | ||
8092 | "\x57\xEE\x85\x1C\x90\x27\xBE\x32" | ||
8093 | "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" | ||
8094 | "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" | ||
8095 | "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" | ||
8096 | "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" | ||
8097 | "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" | ||
8098 | "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" | ||
8099 | "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" | ||
8100 | "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" | ||
8101 | "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" | ||
8102 | "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" | ||
8103 | "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" | ||
8104 | "\x69\x00\x74\x0B\xA2\x16\xAD\x44" | ||
8105 | "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" | ||
8106 | "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" | ||
8107 | "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" | ||
8108 | "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" | ||
8109 | "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" | ||
8110 | "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" | ||
8111 | "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" | ||
8112 | "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" | ||
8113 | "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" | ||
8114 | "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" | ||
8115 | "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" | ||
8116 | "\x58\xEF\x86\x1D\x91\x28\xBF\x33" | ||
8117 | "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" | ||
8118 | "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" | ||
8119 | "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" | ||
8120 | "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" | ||
8121 | "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" | ||
8122 | "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" | ||
8123 | "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" | ||
8124 | "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" | ||
8125 | "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" | ||
8126 | "\x86\x1D\xB4\x28\xBF\x56\xED\x61" | ||
8127 | "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" | ||
8128 | "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" | ||
8129 | "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", | ||
8130 | .rlen = 496, | ||
8131 | .also_non_np = 1, | ||
8132 | .np = 2, | ||
8133 | .tap = { 496 - 16, 16 }, | ||
8134 | }, | ||
8135 | }; | ||
8136 | |||
8137 | static struct cipher_testvec cast6_cbc_enc_tv_template[] = { | ||
8138 | { /* Generated from TF test vectors */ | ||
8139 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
8140 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
8141 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
8142 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
8143 | .klen = 32, | ||
8144 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F" | ||
8145 | "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64", | ||
8146 | .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
8147 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
8148 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
8149 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
8150 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
8151 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
8152 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
8153 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" | ||
8154 | "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" | ||
8155 | "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" | ||
8156 | "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" | ||
8157 | "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" | ||
8158 | "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" | ||
8159 | "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" | ||
8160 | "\x29\xC0\x57\xEE\x62\xF9\x90\x04" | ||
8161 | "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" | ||
8162 | "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" | ||
8163 | "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" | ||
8164 | "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" | ||
8165 | "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" | ||
8166 | "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" | ||
8167 | "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" | ||
8168 | "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" | ||
8169 | "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" | ||
8170 | "\x57\xEE\x85\x1C\x90\x27\xBE\x32" | ||
8171 | "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" | ||
8172 | "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" | ||
8173 | "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" | ||
8174 | "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" | ||
8175 | "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" | ||
8176 | "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" | ||
8177 | "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" | ||
8178 | "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" | ||
8179 | "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" | ||
8180 | "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" | ||
8181 | "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" | ||
8182 | "\x69\x00\x74\x0B\xA2\x16\xAD\x44" | ||
8183 | "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" | ||
8184 | "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" | ||
8185 | "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" | ||
8186 | "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" | ||
8187 | "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" | ||
8188 | "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" | ||
8189 | "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" | ||
8190 | "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" | ||
8191 | "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" | ||
8192 | "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" | ||
8193 | "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" | ||
8194 | "\x58\xEF\x86\x1D\x91\x28\xBF\x33" | ||
8195 | "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" | ||
8196 | "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" | ||
8197 | "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" | ||
8198 | "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" | ||
8199 | "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" | ||
8200 | "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" | ||
8201 | "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" | ||
8202 | "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" | ||
8203 | "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" | ||
8204 | "\x86\x1D\xB4\x28\xBF\x56\xED\x61" | ||
8205 | "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" | ||
8206 | "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" | ||
8207 | "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", | ||
8208 | .ilen = 496, | ||
8209 | .result = "\xDF\x77\x68\x96\xC7\xBA\xF8\xE2" | ||
8210 | "\x0E\x24\x99\x1A\xAA\xF3\xC6\x9F" | ||
8211 | "\xA0\x73\xB3\x70\xC3\x68\x64\x70" | ||
8212 | "\xAD\x33\x02\xFB\x88\x74\xAA\x78" | ||
8213 | "\xC7\x47\x1A\x18\x61\x2D\xAC\x9F" | ||
8214 | "\x7E\x6F\xDF\x05\x13\x76\xA6\x72" | ||
8215 | "\xB7\x13\x09\x0F\x7D\x38\xDF\x25" | ||
8216 | "\x4E\xFD\x50\x45\xFA\x35\x6A\xC0" | ||
8217 | "\x57\x95\xE1\x21\x26\x10\x9A\x21" | ||
8218 | "\xA1\x8A\x51\x05\xD1\xB1\x78\x35" | ||
8219 | "\x98\xF5\xAE\xC0\xC1\x8B\x94\xFF" | ||
8220 | "\xD0\x69\x3F\x42\xC2\x01\xA7\x9B" | ||
8221 | "\x23\x16\x47\x72\x81\x13\x3A\x72" | ||
8222 | "\xEC\xD9\x40\x88\x00\x9C\xB0\xA8" | ||
8223 | "\x9C\xAC\xCE\x11\x73\x7B\x63\x3E" | ||
8224 | "\xA3\x63\x98\x7D\x35\xE4\xD9\x83" | ||
8225 | "\xE2\xD0\x52\x87\x0C\x1F\xB0\xB3" | ||
8226 | "\x41\x1A\x93\x8D\x76\x31\x9F\xF2" | ||
8227 | "\xFE\x09\xA3\x8F\x22\x6A\x3B\xB9" | ||
8228 | "\x6C\x9E\xE4\xA1\xA0\xC4\xE7\xA1" | ||
8229 | "\x21\x9C\x1A\xCA\x65\xDE\x44\x03" | ||
8230 | "\x99\xF2\xD2\x39\xE3\x3F\x0F\x37" | ||
8231 | "\x53\x50\x23\xA4\x81\x6E\xDA\xFB" | ||
8232 | "\xF8\x7B\x01\xD7\xB2\x32\x9C\xB8" | ||
8233 | "\xB1\x0E\x99\x17\xB5\x38\xF9\xD7" | ||
8234 | "\x86\x2D\x6E\x94\x5C\x99\x9D\xB3" | ||
8235 | "\xD3\x63\x4B\x2A\x7D\x44\x6A\xB2" | ||
8236 | "\xC1\x03\xE6\x5A\x37\xD8\x64\x18" | ||
8237 | "\xAA\x32\xCE\x29\xED\xC0\xA2\xCB" | ||
8238 | "\x8D\xAF\xCD\xBE\x8F\xB6\xEC\xB4" | ||
8239 | "\x89\x05\x81\x6E\x71\x4F\xC3\x28" | ||
8240 | "\x10\xC1\x62\xC4\x41\xE9\xD2\x39" | ||
8241 | "\xF3\x22\x39\x12\x2C\xC2\x95\x2D" | ||
8242 | "\xBF\x93\x58\x4B\x04\xD1\x8D\x57" | ||
8243 | "\xAE\xEB\x60\x03\x56\x35\xAD\x5A" | ||
8244 | "\xE9\xC3\xFF\x4E\x31\xE1\x37\xF8" | ||
8245 | "\x7D\xEE\x65\x8A\xB6\x88\x1A\x3E" | ||
8246 | "\x07\x09\x82\xBA\xF0\x80\x8A\xD0" | ||
8247 | "\xA0\x3F\x6A\xE9\x24\x87\x19\x65" | ||
8248 | "\x73\x3F\x12\x91\x47\x54\xBA\x39" | ||
8249 | "\x30\x5B\x1E\xE5\xC2\xF9\x3F\xEF" | ||
8250 | "\xD6\x75\xF9\xB8\x7C\x8B\x05\x76" | ||
8251 | "\xEE\xB7\x08\x25\x4B\xB6\x7B\x47" | ||
8252 | "\x72\xC0\x4C\xD4\xDA\xE0\x75\xF1" | ||
8253 | "\x7C\xE8\x94\x9E\x16\x6E\xB8\x12" | ||
8254 | "\xA1\xC1\x6E\x3B\x1C\x59\x41\x2D" | ||
8255 | "\x23\xFA\x7D\x77\xB8\x46\x75\xFE" | ||
8256 | "\x4F\x10\xD3\x09\x60\xA1\x36\x96" | ||
8257 | "\x5B\xC2\xDC\x6E\x84\x7D\x9B\x14" | ||
8258 | "\x80\x21\x83\x58\x3C\x76\xFD\x28" | ||
8259 | "\x1D\xF9\x93\x13\xD7\x0E\x62\x14" | ||
8260 | "\x5A\xC5\x4E\x08\xA5\x56\xA4\x3C" | ||
8261 | "\x68\x93\x44\x70\xDF\xCF\x4A\x51" | ||
8262 | "\x0B\x81\x29\x41\xE5\x62\x4D\x36" | ||
8263 | "\xB3\xEA\x94\xA6\xB9\xDD\x3F\x09" | ||
8264 | "\x62\x34\xA0\x6A\x7E\x7D\xF5\xF6" | ||
8265 | "\x01\x91\xB4\x27\xDA\x59\xD6\x17" | ||
8266 | "\x56\x4D\x82\x62\x37\xA3\x48\x01" | ||
8267 | "\x99\x91\x77\xB2\x08\x6B\x2C\x37" | ||
8268 | "\xC5\x5C\xAD\xB6\x07\xB6\x84\xF3" | ||
8269 | "\x4D\x59\x7D\xC5\x28\x69\xFA\x92" | ||
8270 | "\x22\x46\x89\x2D\x0F\x2B\x08\x24", | ||
8271 | .rlen = 496, | ||
8272 | .also_non_np = 1, | ||
8273 | .np = 2, | ||
8274 | .tap = { 496 - 16, 16 }, | ||
8275 | }, | ||
8276 | }; | ||
8277 | |||
8278 | static struct cipher_testvec cast6_cbc_dec_tv_template[] = { | ||
8279 | { /* Generated from TF test vectors */ | ||
8280 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
8281 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
8282 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
8283 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
8284 | .klen = 32, | ||
8285 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F" | ||
8286 | "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64", | ||
8287 | .input = "\xDF\x77\x68\x96\xC7\xBA\xF8\xE2" | ||
8288 | "\x0E\x24\x99\x1A\xAA\xF3\xC6\x9F" | ||
8289 | "\xA0\x73\xB3\x70\xC3\x68\x64\x70" | ||
8290 | "\xAD\x33\x02\xFB\x88\x74\xAA\x78" | ||
8291 | "\xC7\x47\x1A\x18\x61\x2D\xAC\x9F" | ||
8292 | "\x7E\x6F\xDF\x05\x13\x76\xA6\x72" | ||
8293 | "\xB7\x13\x09\x0F\x7D\x38\xDF\x25" | ||
8294 | "\x4E\xFD\x50\x45\xFA\x35\x6A\xC0" | ||
8295 | "\x57\x95\xE1\x21\x26\x10\x9A\x21" | ||
8296 | "\xA1\x8A\x51\x05\xD1\xB1\x78\x35" | ||
8297 | "\x98\xF5\xAE\xC0\xC1\x8B\x94\xFF" | ||
8298 | "\xD0\x69\x3F\x42\xC2\x01\xA7\x9B" | ||
8299 | "\x23\x16\x47\x72\x81\x13\x3A\x72" | ||
8300 | "\xEC\xD9\x40\x88\x00\x9C\xB0\xA8" | ||
8301 | "\x9C\xAC\xCE\x11\x73\x7B\x63\x3E" | ||
8302 | "\xA3\x63\x98\x7D\x35\xE4\xD9\x83" | ||
8303 | "\xE2\xD0\x52\x87\x0C\x1F\xB0\xB3" | ||
8304 | "\x41\x1A\x93\x8D\x76\x31\x9F\xF2" | ||
8305 | "\xFE\x09\xA3\x8F\x22\x6A\x3B\xB9" | ||
8306 | "\x6C\x9E\xE4\xA1\xA0\xC4\xE7\xA1" | ||
8307 | "\x21\x9C\x1A\xCA\x65\xDE\x44\x03" | ||
8308 | "\x99\xF2\xD2\x39\xE3\x3F\x0F\x37" | ||
8309 | "\x53\x50\x23\xA4\x81\x6E\xDA\xFB" | ||
8310 | "\xF8\x7B\x01\xD7\xB2\x32\x9C\xB8" | ||
8311 | "\xB1\x0E\x99\x17\xB5\x38\xF9\xD7" | ||
8312 | "\x86\x2D\x6E\x94\x5C\x99\x9D\xB3" | ||
8313 | "\xD3\x63\x4B\x2A\x7D\x44\x6A\xB2" | ||
8314 | "\xC1\x03\xE6\x5A\x37\xD8\x64\x18" | ||
8315 | "\xAA\x32\xCE\x29\xED\xC0\xA2\xCB" | ||
8316 | "\x8D\xAF\xCD\xBE\x8F\xB6\xEC\xB4" | ||
8317 | "\x89\x05\x81\x6E\x71\x4F\xC3\x28" | ||
8318 | "\x10\xC1\x62\xC4\x41\xE9\xD2\x39" | ||
8319 | "\xF3\x22\x39\x12\x2C\xC2\x95\x2D" | ||
8320 | "\xBF\x93\x58\x4B\x04\xD1\x8D\x57" | ||
8321 | "\xAE\xEB\x60\x03\x56\x35\xAD\x5A" | ||
8322 | "\xE9\xC3\xFF\x4E\x31\xE1\x37\xF8" | ||
8323 | "\x7D\xEE\x65\x8A\xB6\x88\x1A\x3E" | ||
8324 | "\x07\x09\x82\xBA\xF0\x80\x8A\xD0" | ||
8325 | "\xA0\x3F\x6A\xE9\x24\x87\x19\x65" | ||
8326 | "\x73\x3F\x12\x91\x47\x54\xBA\x39" | ||
8327 | "\x30\x5B\x1E\xE5\xC2\xF9\x3F\xEF" | ||
8328 | "\xD6\x75\xF9\xB8\x7C\x8B\x05\x76" | ||
8329 | "\xEE\xB7\x08\x25\x4B\xB6\x7B\x47" | ||
8330 | "\x72\xC0\x4C\xD4\xDA\xE0\x75\xF1" | ||
8331 | "\x7C\xE8\x94\x9E\x16\x6E\xB8\x12" | ||
8332 | "\xA1\xC1\x6E\x3B\x1C\x59\x41\x2D" | ||
8333 | "\x23\xFA\x7D\x77\xB8\x46\x75\xFE" | ||
8334 | "\x4F\x10\xD3\x09\x60\xA1\x36\x96" | ||
8335 | "\x5B\xC2\xDC\x6E\x84\x7D\x9B\x14" | ||
8336 | "\x80\x21\x83\x58\x3C\x76\xFD\x28" | ||
8337 | "\x1D\xF9\x93\x13\xD7\x0E\x62\x14" | ||
8338 | "\x5A\xC5\x4E\x08\xA5\x56\xA4\x3C" | ||
8339 | "\x68\x93\x44\x70\xDF\xCF\x4A\x51" | ||
8340 | "\x0B\x81\x29\x41\xE5\x62\x4D\x36" | ||
8341 | "\xB3\xEA\x94\xA6\xB9\xDD\x3F\x09" | ||
8342 | "\x62\x34\xA0\x6A\x7E\x7D\xF5\xF6" | ||
8343 | "\x01\x91\xB4\x27\xDA\x59\xD6\x17" | ||
8344 | "\x56\x4D\x82\x62\x37\xA3\x48\x01" | ||
8345 | "\x99\x91\x77\xB2\x08\x6B\x2C\x37" | ||
8346 | "\xC5\x5C\xAD\xB6\x07\xB6\x84\xF3" | ||
8347 | "\x4D\x59\x7D\xC5\x28\x69\xFA\x92" | ||
8348 | "\x22\x46\x89\x2D\x0F\x2B\x08\x24", | ||
8349 | .ilen = 496, | ||
8350 | .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
8351 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
8352 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
8353 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
8354 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
8355 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
8356 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
8357 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" | ||
8358 | "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" | ||
8359 | "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" | ||
8360 | "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" | ||
8361 | "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" | ||
8362 | "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" | ||
8363 | "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" | ||
8364 | "\x29\xC0\x57\xEE\x62\xF9\x90\x04" | ||
8365 | "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" | ||
8366 | "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" | ||
8367 | "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" | ||
8368 | "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" | ||
8369 | "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" | ||
8370 | "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" | ||
8371 | "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" | ||
8372 | "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" | ||
8373 | "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" | ||
8374 | "\x57\xEE\x85\x1C\x90\x27\xBE\x32" | ||
8375 | "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" | ||
8376 | "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" | ||
8377 | "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" | ||
8378 | "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" | ||
8379 | "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" | ||
8380 | "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" | ||
8381 | "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" | ||
8382 | "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" | ||
8383 | "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" | ||
8384 | "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" | ||
8385 | "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" | ||
8386 | "\x69\x00\x74\x0B\xA2\x16\xAD\x44" | ||
8387 | "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" | ||
8388 | "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" | ||
8389 | "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" | ||
8390 | "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" | ||
8391 | "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" | ||
8392 | "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" | ||
8393 | "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" | ||
8394 | "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" | ||
8395 | "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" | ||
8396 | "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" | ||
8397 | "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" | ||
8398 | "\x58\xEF\x86\x1D\x91\x28\xBF\x33" | ||
8399 | "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" | ||
8400 | "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" | ||
8401 | "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" | ||
8402 | "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" | ||
8403 | "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" | ||
8404 | "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" | ||
8405 | "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" | ||
8406 | "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" | ||
8407 | "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" | ||
8408 | "\x86\x1D\xB4\x28\xBF\x56\xED\x61" | ||
8409 | "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" | ||
8410 | "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" | ||
8411 | "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", | ||
8412 | .rlen = 496, | ||
8413 | .also_non_np = 1, | ||
8414 | .np = 2, | ||
8415 | .tap = { 496 - 16, 16 }, | ||
8416 | }, | ||
8417 | }; | ||
8418 | |||
8419 | static struct cipher_testvec cast6_ctr_enc_tv_template[] = { | ||
8420 | { /* Generated from TF test vectors */ | ||
8421 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
8422 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
8423 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
8424 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
8425 | .klen = 32, | ||
8426 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F" | ||
8427 | "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64", | ||
8428 | .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
8429 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
8430 | "\x3A", | ||
8431 | .ilen = 17, | ||
8432 | .result = "\x26\x0A\xF1\xE2\x3F\x8A\xEF\xA3" | ||
8433 | "\x53\x9A\x5E\x1B\x2A\x1A\xC6\x0A" | ||
8434 | "\x57", | ||
8435 | .rlen = 17, | ||
8436 | }, { /* Generated from TF test vectors */ | ||
8437 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
8438 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
8439 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
8440 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
8441 | .klen = 32, | ||
8442 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F" | ||
8443 | "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64", | ||
8444 | .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
8445 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
8446 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
8447 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
8448 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
8449 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
8450 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
8451 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" | ||
8452 | "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" | ||
8453 | "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" | ||
8454 | "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" | ||
8455 | "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" | ||
8456 | "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" | ||
8457 | "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" | ||
8458 | "\x29\xC0\x57\xEE\x62\xF9\x90\x04" | ||
8459 | "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" | ||
8460 | "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" | ||
8461 | "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" | ||
8462 | "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" | ||
8463 | "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" | ||
8464 | "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" | ||
8465 | "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" | ||
8466 | "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" | ||
8467 | "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" | ||
8468 | "\x57\xEE\x85\x1C\x90\x27\xBE\x32" | ||
8469 | "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" | ||
8470 | "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" | ||
8471 | "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" | ||
8472 | "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" | ||
8473 | "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" | ||
8474 | "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" | ||
8475 | "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" | ||
8476 | "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" | ||
8477 | "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" | ||
8478 | "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" | ||
8479 | "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" | ||
8480 | "\x69\x00\x74\x0B\xA2\x16\xAD\x44" | ||
8481 | "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" | ||
8482 | "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" | ||
8483 | "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" | ||
8484 | "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" | ||
8485 | "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" | ||
8486 | "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" | ||
8487 | "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" | ||
8488 | "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" | ||
8489 | "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" | ||
8490 | "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" | ||
8491 | "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" | ||
8492 | "\x58\xEF\x86\x1D\x91\x28\xBF\x33" | ||
8493 | "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" | ||
8494 | "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" | ||
8495 | "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" | ||
8496 | "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" | ||
8497 | "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" | ||
8498 | "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" | ||
8499 | "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" | ||
8500 | "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" | ||
8501 | "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" | ||
8502 | "\x86\x1D\xB4\x28\xBF\x56\xED\x61" | ||
8503 | "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" | ||
8504 | "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" | ||
8505 | "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", | ||
8506 | .ilen = 496, | ||
8507 | .result = "\x26\x0A\xF1\xE2\x3F\x8A\xEF\xA3" | ||
8508 | "\x53\x9A\x5E\x1B\x2A\x1A\xC6\x0A" | ||
8509 | "\x57\xA3\xEF\x47\x2A\xE8\x88\xA7" | ||
8510 | "\x3C\xD0\xEC\xB9\x94\x50\x7D\x56" | ||
8511 | "\xBC\xE1\xC1\xF5\xE1\xEE\x12\xF8" | ||
8512 | "\x4F\x03\x82\x3A\x93\x6B\x4C\xD3" | ||
8513 | "\xE3\xF3\xFA\xC2\x23\x55\x98\x20" | ||
8514 | "\x49\x76\x9B\x6B\xC1\x23\xBF\xE5" | ||
8515 | "\xD4\xC4\x2F\x61\xE1\x67\x2A\x30" | ||
8516 | "\x6F\x29\xCA\x54\xF8\x1B\xA6\x7D" | ||
8517 | "\x66\x45\xEE\xC8\x19\xBE\x50\xF0" | ||
8518 | "\x5F\x65\xF8\x1E\x4D\x07\x87\xD9" | ||
8519 | "\xD3\xD9\x1B\x09\x89\xFD\x42\xC5" | ||
8520 | "\xDB\xEB\x86\xF1\x67\x04\x0F\x5C" | ||
8521 | "\x81\xDF\x82\x12\xC7\x4C\x1B\x07" | ||
8522 | "\xDE\xE6\xFA\x29\x86\xD1\xB0\xBA" | ||
8523 | "\x3D\x6A\x69\x76\xEC\x0F\xB4\xE6" | ||
8524 | "\xCD\xA7\xF8\xA8\xB8\xE0\x33\xF5" | ||
8525 | "\x49\x61\x22\x52\x64\x8C\x46\x41" | ||
8526 | "\x1F\x48\x5F\x4F\xA2\x89\x36\x17" | ||
8527 | "\x20\xF8\x2F\x8F\x4B\xFA\xF2\xC0" | ||
8528 | "\x1E\x18\xA2\xF8\xB7\x6D\x98\xE3" | ||
8529 | "\x00\x14\x15\x59\xC1\x30\x64\xAF" | ||
8530 | "\xA8\x01\x38\xAB\xD4\x8B\xEC\x7C" | ||
8531 | "\x44\x9A\xC6\x2C\x2E\x2B\x2B\xF4" | ||
8532 | "\x02\x37\xC4\x69\xEF\x36\xC1\xF3" | ||
8533 | "\xA0\xFB\xFE\x29\xAD\x39\xCF\xD0" | ||
8534 | "\x51\x73\xA3\x22\x42\x41\xAB\xD2" | ||
8535 | "\x0F\x50\x14\xB9\x54\xD3\xD4\xFA" | ||
8536 | "\xBF\xC9\xBB\xCE\xC4\x1D\x2D\xAF" | ||
8537 | "\xC9\x3F\x07\x87\x42\x4B\x3A\x54" | ||
8538 | "\x34\x8E\x37\xA3\x03\x6F\x65\x66" | ||
8539 | "\xDB\x44\xC3\xE8\xD7\xDD\x7D\xDD" | ||
8540 | "\x61\xB4\x2B\x80\xA3\x98\x13\xF5" | ||
8541 | "\x5A\xD3\x34\x58\xC3\x6E\xF6\xB8" | ||
8542 | "\x0A\xC6\x50\x01\x8E\xD5\x6C\x7D" | ||
8543 | "\xFE\x16\xB6\xCF\xFC\x51\x40\xAE" | ||
8544 | "\xB3\x15\xAC\x90\x6F\x0B\x28\x3A" | ||
8545 | "\x60\x40\x38\x90\x20\x46\xC7\xB3" | ||
8546 | "\x0B\x12\x6D\x3B\x15\x14\xF9\xF4" | ||
8547 | "\x11\x41\x76\x6B\xB3\x60\x82\x3C" | ||
8548 | "\x84\xFB\x08\x2E\x92\x25\xCB\x79" | ||
8549 | "\x6F\x58\xC5\x94\x00\x00\x47\xB6" | ||
8550 | "\x9E\xDC\x0F\x29\x70\x46\x20\x76" | ||
8551 | "\x65\x75\x66\x5C\x00\x96\xB3\xE1" | ||
8552 | "\x0B\xA7\x11\x8B\x2E\x61\x4E\x45" | ||
8553 | "\x73\xFC\x91\xAB\x79\x41\x23\x14" | ||
8554 | "\x13\xB6\x72\x6C\x46\xB3\x03\x11" | ||
8555 | "\xE4\xF1\xEE\xC9\x7A\xCF\x96\x32" | ||
8556 | "\xB6\xF0\x8B\x97\xB4\xCF\x82\xB7" | ||
8557 | "\x15\x48\x44\x99\x09\xF6\xE0\xD7" | ||
8558 | "\xBC\xF1\x5B\x91\x4F\x30\x22\xA2" | ||
8559 | "\x45\xC4\x68\x55\xC2\xBE\xA7\xD2" | ||
8560 | "\x12\x53\x35\x9C\xF9\xE7\x35\x5D" | ||
8561 | "\x81\xE4\x86\x42\xC3\x58\xFB\xF0" | ||
8562 | "\x38\x9B\x8E\x5A\xEF\x83\x33\x0F" | ||
8563 | "\x00\x4E\x3F\x9F\xF5\x84\x62\xC4" | ||
8564 | "\x19\x35\x88\x22\x45\x59\x0E\x8F" | ||
8565 | "\xEC\x27\xDD\x4A\xA4\x1F\xBC\x41" | ||
8566 | "\x9B\x66\x8D\x32\xBA\x81\x34\x87" | ||
8567 | "\x0E\x74\x33\x30\x62\xB9\x89\xDF" | ||
8568 | "\xF9\xC5\xDD\x27\xB3\x39\xCB\xCB", | ||
8569 | .rlen = 496, | ||
8570 | .also_non_np = 1, | ||
8571 | .np = 2, | ||
8572 | .tap = { 496 - 16, 16 }, | ||
8573 | }, | ||
8574 | }; | ||
8575 | |||
8576 | static struct cipher_testvec cast6_ctr_dec_tv_template[] = { | ||
8577 | { /* Generated from TF test vectors */ | ||
8578 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
8579 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
8580 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
8581 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
8582 | .klen = 32, | ||
8583 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F" | ||
8584 | "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64", | ||
8585 | .input = "\x26\x0A\xF1\xE2\x3F\x8A\xEF\xA3" | ||
8586 | "\x53\x9A\x5E\x1B\x2A\x1A\xC6\x0A" | ||
8587 | "\x57", | ||
8588 | .ilen = 17, | ||
8589 | .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
8590 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
8591 | "\x3A", | ||
8592 | .rlen = 17, | ||
8593 | }, { /* Generated from TF test vectors */ | ||
8594 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
8595 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
8596 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
8597 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
8598 | .klen = 32, | ||
8599 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F" | ||
8600 | "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64", | ||
8601 | .input = "\x26\x0A\xF1\xE2\x3F\x8A\xEF\xA3" | ||
8602 | "\x53\x9A\x5E\x1B\x2A\x1A\xC6\x0A" | ||
8603 | "\x57\xA3\xEF\x47\x2A\xE8\x88\xA7" | ||
8604 | "\x3C\xD0\xEC\xB9\x94\x50\x7D\x56" | ||
8605 | "\xBC\xE1\xC1\xF5\xE1\xEE\x12\xF8" | ||
8606 | "\x4F\x03\x82\x3A\x93\x6B\x4C\xD3" | ||
8607 | "\xE3\xF3\xFA\xC2\x23\x55\x98\x20" | ||
8608 | "\x49\x76\x9B\x6B\xC1\x23\xBF\xE5" | ||
8609 | "\xD4\xC4\x2F\x61\xE1\x67\x2A\x30" | ||
8610 | "\x6F\x29\xCA\x54\xF8\x1B\xA6\x7D" | ||
8611 | "\x66\x45\xEE\xC8\x19\xBE\x50\xF0" | ||
8612 | "\x5F\x65\xF8\x1E\x4D\x07\x87\xD9" | ||
8613 | "\xD3\xD9\x1B\x09\x89\xFD\x42\xC5" | ||
8614 | "\xDB\xEB\x86\xF1\x67\x04\x0F\x5C" | ||
8615 | "\x81\xDF\x82\x12\xC7\x4C\x1B\x07" | ||
8616 | "\xDE\xE6\xFA\x29\x86\xD1\xB0\xBA" | ||
8617 | "\x3D\x6A\x69\x76\xEC\x0F\xB4\xE6" | ||
8618 | "\xCD\xA7\xF8\xA8\xB8\xE0\x33\xF5" | ||
8619 | "\x49\x61\x22\x52\x64\x8C\x46\x41" | ||
8620 | "\x1F\x48\x5F\x4F\xA2\x89\x36\x17" | ||
8621 | "\x20\xF8\x2F\x8F\x4B\xFA\xF2\xC0" | ||
8622 | "\x1E\x18\xA2\xF8\xB7\x6D\x98\xE3" | ||
8623 | "\x00\x14\x15\x59\xC1\x30\x64\xAF" | ||
8624 | "\xA8\x01\x38\xAB\xD4\x8B\xEC\x7C" | ||
8625 | "\x44\x9A\xC6\x2C\x2E\x2B\x2B\xF4" | ||
8626 | "\x02\x37\xC4\x69\xEF\x36\xC1\xF3" | ||
8627 | "\xA0\xFB\xFE\x29\xAD\x39\xCF\xD0" | ||
8628 | "\x51\x73\xA3\x22\x42\x41\xAB\xD2" | ||
8629 | "\x0F\x50\x14\xB9\x54\xD3\xD4\xFA" | ||
8630 | "\xBF\xC9\xBB\xCE\xC4\x1D\x2D\xAF" | ||
8631 | "\xC9\x3F\x07\x87\x42\x4B\x3A\x54" | ||
8632 | "\x34\x8E\x37\xA3\x03\x6F\x65\x66" | ||
8633 | "\xDB\x44\xC3\xE8\xD7\xDD\x7D\xDD" | ||
8634 | "\x61\xB4\x2B\x80\xA3\x98\x13\xF5" | ||
8635 | "\x5A\xD3\x34\x58\xC3\x6E\xF6\xB8" | ||
8636 | "\x0A\xC6\x50\x01\x8E\xD5\x6C\x7D" | ||
8637 | "\xFE\x16\xB6\xCF\xFC\x51\x40\xAE" | ||
8638 | "\xB3\x15\xAC\x90\x6F\x0B\x28\x3A" | ||
8639 | "\x60\x40\x38\x90\x20\x46\xC7\xB3" | ||
8640 | "\x0B\x12\x6D\x3B\x15\x14\xF9\xF4" | ||
8641 | "\x11\x41\x76\x6B\xB3\x60\x82\x3C" | ||
8642 | "\x84\xFB\x08\x2E\x92\x25\xCB\x79" | ||
8643 | "\x6F\x58\xC5\x94\x00\x00\x47\xB6" | ||
8644 | "\x9E\xDC\x0F\x29\x70\x46\x20\x76" | ||
8645 | "\x65\x75\x66\x5C\x00\x96\xB3\xE1" | ||
8646 | "\x0B\xA7\x11\x8B\x2E\x61\x4E\x45" | ||
8647 | "\x73\xFC\x91\xAB\x79\x41\x23\x14" | ||
8648 | "\x13\xB6\x72\x6C\x46\xB3\x03\x11" | ||
8649 | "\xE4\xF1\xEE\xC9\x7A\xCF\x96\x32" | ||
8650 | "\xB6\xF0\x8B\x97\xB4\xCF\x82\xB7" | ||
8651 | "\x15\x48\x44\x99\x09\xF6\xE0\xD7" | ||
8652 | "\xBC\xF1\x5B\x91\x4F\x30\x22\xA2" | ||
8653 | "\x45\xC4\x68\x55\xC2\xBE\xA7\xD2" | ||
8654 | "\x12\x53\x35\x9C\xF9\xE7\x35\x5D" | ||
8655 | "\x81\xE4\x86\x42\xC3\x58\xFB\xF0" | ||
8656 | "\x38\x9B\x8E\x5A\xEF\x83\x33\x0F" | ||
8657 | "\x00\x4E\x3F\x9F\xF5\x84\x62\xC4" | ||
8658 | "\x19\x35\x88\x22\x45\x59\x0E\x8F" | ||
8659 | "\xEC\x27\xDD\x4A\xA4\x1F\xBC\x41" | ||
8660 | "\x9B\x66\x8D\x32\xBA\x81\x34\x87" | ||
8661 | "\x0E\x74\x33\x30\x62\xB9\x89\xDF" | ||
8662 | "\xF9\xC5\xDD\x27\xB3\x39\xCB\xCB", | ||
8663 | .ilen = 496, | ||
8664 | .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
8665 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
8666 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
8667 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
8668 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
8669 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
8670 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
8671 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" | ||
8672 | "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" | ||
8673 | "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" | ||
8674 | "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" | ||
8675 | "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" | ||
8676 | "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" | ||
8677 | "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" | ||
8678 | "\x29\xC0\x57\xEE\x62\xF9\x90\x04" | ||
8679 | "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" | ||
8680 | "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" | ||
8681 | "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" | ||
8682 | "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" | ||
8683 | "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" | ||
8684 | "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" | ||
8685 | "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" | ||
8686 | "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" | ||
8687 | "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" | ||
8688 | "\x57\xEE\x85\x1C\x90\x27\xBE\x32" | ||
8689 | "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" | ||
8690 | "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" | ||
8691 | "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" | ||
8692 | "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" | ||
8693 | "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" | ||
8694 | "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" | ||
8695 | "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" | ||
8696 | "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" | ||
8697 | "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" | ||
8698 | "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" | ||
8699 | "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" | ||
8700 | "\x69\x00\x74\x0B\xA2\x16\xAD\x44" | ||
8701 | "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" | ||
8702 | "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" | ||
8703 | "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" | ||
8704 | "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" | ||
8705 | "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" | ||
8706 | "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" | ||
8707 | "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" | ||
8708 | "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" | ||
8709 | "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" | ||
8710 | "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" | ||
8711 | "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" | ||
8712 | "\x58\xEF\x86\x1D\x91\x28\xBF\x33" | ||
8713 | "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" | ||
8714 | "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" | ||
8715 | "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" | ||
8716 | "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" | ||
8717 | "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" | ||
8718 | "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" | ||
8719 | "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" | ||
8720 | "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" | ||
8721 | "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" | ||
8722 | "\x86\x1D\xB4\x28\xBF\x56\xED\x61" | ||
8723 | "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" | ||
8724 | "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" | ||
8725 | "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", | ||
8726 | .rlen = 496, | ||
8727 | .also_non_np = 1, | ||
8728 | .np = 2, | ||
8729 | .tap = { 496 - 16, 16 }, | ||
8730 | }, | ||
8731 | }; | ||
8732 | |||
8733 | static struct cipher_testvec cast6_lrw_enc_tv_template[] = { | ||
8734 | { /* Generated from TF test vectors */ | ||
8735 | .key = "\xf8\xd4\x76\xff\xd6\x46\xee\x6c" | ||
8736 | "\x23\x84\xcb\x1c\x77\xd6\x19\x5d" | ||
8737 | "\xfe\xf1\xa9\xf3\x7b\xbc\x8d\x21" | ||
8738 | "\xa7\x9c\x21\xf8\xcb\x90\x02\x89" | ||
8739 | "\xa8\x45\x34\x8e\xc8\xc5\xb5\xf1" | ||
8740 | "\x26\xf5\x0e\x76\xfe\xfd\x1b\x1e", | ||
8741 | .klen = 48, | ||
8742 | .iv = "\x00\x00\x00\x00\x00\x00\x00\x00" | ||
8743 | "\x00\x00\x00\x00\x00\x00\x00\x01", | ||
8744 | .input = "\x05\x11\xb7\x18\xab\xc6\x2d\xac" | ||
8745 | "\x70\x5d\xf6\x22\x94\xcd\xe5\x6c" | ||
8746 | "\x17\x6b\xf6\x1c\xf0\xf3\x6e\xf8" | ||
8747 | "\x50\x38\x1f\x71\x49\xb6\x57\xd6" | ||
8748 | "\x8f\xcb\x8d\x6b\xe3\xa6\x29\x90" | ||
8749 | "\xfe\x2a\x62\x82\xae\x6d\x8b\xf6" | ||
8750 | "\xad\x1e\x9e\x20\x5f\x38\xbe\x04" | ||
8751 | "\xda\x10\x8e\xed\xa2\xa4\x87\xab" | ||
8752 | "\xda\x6b\xb4\x0c\x75\xba\xd3\x7c" | ||
8753 | "\xc9\xac\x42\x31\x95\x7c\xc9\x04" | ||
8754 | "\xeb\xd5\x6e\x32\x69\x8a\xdb\xa6" | ||
8755 | "\x15\xd7\x3f\x4f\x2f\x66\x69\x03" | ||
8756 | "\x9c\x1f\x54\x0f\xde\x1f\xf3\x65" | ||
8757 | "\x4c\x96\x12\xed\x7c\x92\x03\x01" | ||
8758 | "\x6f\xbc\x35\x93\xac\xf1\x27\xf1" | ||
8759 | "\xb4\x96\x82\x5a\x5f\xb0\xa0\x50" | ||
8760 | "\x89\xa4\x8e\x66\x44\x85\xcc\xfd" | ||
8761 | "\x33\x14\x70\xe3\x96\xb2\xc3\xd3" | ||
8762 | "\xbb\x54\x5a\x1a\xf9\x74\xa2\xc5" | ||
8763 | "\x2d\x64\x75\xdd\xb4\x54\xe6\x74" | ||
8764 | "\x8c\xd3\x9d\x9e\x86\xab\x51\x53" | ||
8765 | "\xb7\x93\x3e\x6f\xd0\x4e\x2c\x40" | ||
8766 | "\xf6\xa8\x2e\x3e\x9d\xf4\x66\xa5" | ||
8767 | "\x76\x12\x73\x44\x1a\x56\xd7\x72" | ||
8768 | "\x88\xcd\x21\x8c\x4c\x0f\xfe\xda" | ||
8769 | "\x95\xe0\x3a\xa6\xa5\x84\x46\xcd" | ||
8770 | "\xd5\x3e\x9d\x3a\xe2\x67\xe6\x60" | ||
8771 | "\x1a\xe2\x70\x85\x58\xc2\x1b\x09" | ||
8772 | "\xe1\xd7\x2c\xca\xad\xa8\x8f\xf9" | ||
8773 | "\xac\xb3\x0e\xdb\xca\x2e\xe2\xb8" | ||
8774 | "\x51\x71\xd9\x3c\x6c\xf1\x56\xf8" | ||
8775 | "\xea\x9c\xf1\xfb\x0c\xe6\xb7\x10" | ||
8776 | "\x1c\xf8\xa9\x7c\xe8\x53\x35\xc1" | ||
8777 | "\x90\x3e\x76\x4a\x74\xa4\x21\x2c" | ||
8778 | "\xf6\x2c\x4e\x0f\x94\x3a\x88\x2e" | ||
8779 | "\x41\x09\x6a\x33\x7d\xf6\xdd\x3f" | ||
8780 | "\x8d\x23\x31\x74\x84\xeb\x88\x6e" | ||
8781 | "\xcc\xb9\xbc\x22\x83\x19\x07\x22" | ||
8782 | "\xa5\x2d\xdf\xa5\xf3\x80\x85\x78" | ||
8783 | "\x84\x39\x6a\x6d\x6a\x99\x4f\xa5" | ||
8784 | "\x15\xfe\x46\xb0\xe4\x6c\xa5\x41" | ||
8785 | "\x3c\xce\x8f\x42\x60\x71\xa7\x75" | ||
8786 | "\x08\x40\x65\x8a\x82\xbf\xf5\x43" | ||
8787 | "\x71\x96\xa9\x4d\x44\x8a\x20\xbe" | ||
8788 | "\xfa\x4d\xbb\xc0\x7d\x31\x96\x65" | ||
8789 | "\xe7\x75\xe5\x3e\xfd\x92\x3b\xc9" | ||
8790 | "\x55\xbb\x16\x7e\xf7\xc2\x8c\xa4" | ||
8791 | "\x40\x1d\xe5\xef\x0e\xdf\xe4\x9a" | ||
8792 | "\x62\x73\x65\xfd\x46\x63\x25\x3d" | ||
8793 | "\x2b\xaf\xe5\x64\xfe\xa5\x5c\xcf" | ||
8794 | "\x24\xf3\xb4\xac\x64\xba\xdf\x4b" | ||
8795 | "\xc6\x96\x7d\x81\x2d\x8d\x97\xf7" | ||
8796 | "\xc5\x68\x77\x84\x32\x2b\xcc\x85" | ||
8797 | "\x74\x96\xf0\x12\x77\x61\xb9\xeb" | ||
8798 | "\x71\xaa\x82\xcb\x1c\xdb\x89\xc8" | ||
8799 | "\xc6\xb5\xe3\x5c\x7d\x39\x07\x24" | ||
8800 | "\xda\x39\x87\x45\xc0\x2b\xbb\x01" | ||
8801 | "\xac\xbc\x2a\x5c\x7f\xfc\xe8\xce" | ||
8802 | "\x6d\x9c\x6f\xed\xd3\xc1\xa1\xd6" | ||
8803 | "\xc5\x55\xa9\x66\x2f\xe1\xc8\x32" | ||
8804 | "\xa6\x5d\xa4\x3a\x98\x73\xe8\x45" | ||
8805 | "\xa4\xc7\xa8\xb4\xf6\x13\x03\xf6" | ||
8806 | "\xe9\x2e\xc4\x29\x0f\x84\xdb\xc4" | ||
8807 | "\x21\xc4\xc2\x75\x67\x89\x37\x0a", | ||
8808 | .ilen = 512, | ||
8809 | .result = "\x55\x25\x09\x8B\xB5\xD5\xF8\xBF" | ||
8810 | "\x37\x4A\xFE\x3C\x47\xD8\xE6\xEB" | ||
8811 | "\xCA\xA4\x9B\xB0\xAB\x6D\x64\xCA" | ||
8812 | "\x58\xB6\x73\xF0\xD7\x52\x34\xEF" | ||
8813 | "\xFB\x3E\x96\x81\xB7\x71\x34\xA4" | ||
8814 | "\x55\x20\xBE\x39\x5A\x2B\xF9\xD1" | ||
8815 | "\x65\x0B\xDA\xD3\x7E\xB3\xA6\xF7" | ||
8816 | "\x2E\x0B\x5A\x52\xDB\x39\x8C\x9B" | ||
8817 | "\x61\x17\x5F\xAF\xB6\x5A\xC8\x08" | ||
8818 | "\xA7\xB7\x2A\x11\x7C\x97\x38\x9D" | ||
8819 | "\x59\x0E\x66\x59\x5E\xD8\x8B\xCE" | ||
8820 | "\x70\xE0\xC3\x42\xB0\x8C\x0F\xBA" | ||
8821 | "\xB2\x0D\x81\xB6\xBE\x61\x1C\x2D" | ||
8822 | "\x7E\xEA\x91\x25\xAC\xEC\xF8\x28" | ||
8823 | "\x80\x1D\xF0\x30\xBA\x62\x77\x7D" | ||
8824 | "\xDB\x15\x69\xDF\xFA\x2A\x81\x64" | ||
8825 | "\x95\x5B\xA4\x7F\x3E\x4F\xE3\x30" | ||
8826 | "\xB0\x5C\xC2\x05\xF8\xF0\x29\xE7" | ||
8827 | "\x0A\xA0\x66\xB2\x5D\x0F\x39\x2B" | ||
8828 | "\xB4\xB3\x00\xA9\xD0\xAB\x63\x61" | ||
8829 | "\x5E\xDB\xFC\x11\x74\x25\x96\x65" | ||
8830 | "\xE8\xE2\x34\x57\x77\x15\x5E\x70" | ||
8831 | "\xFF\x10\x90\xC3\x64\xF0\x11\x0A" | ||
8832 | "\x63\x3A\xD3\x55\x92\x15\x4B\x0C" | ||
8833 | "\xC7\x08\x89\x17\x3B\x99\xAD\x63" | ||
8834 | "\xE7\x06\xDF\x52\xBC\x15\x64\x45" | ||
8835 | "\x9D\x7A\xFB\x69\xBC\x2D\x6E\xA9" | ||
8836 | "\x35\xD9\xD8\xF5\x0C\xC4\xA2\x23" | ||
8837 | "\x9C\x18\x8B\xA8\x8C\xFE\xF8\x0E" | ||
8838 | "\xBD\xAB\x60\x1A\x51\x17\x54\x27" | ||
8839 | "\xB6\xE8\xBE\x0F\xA9\xA5\x82\x19" | ||
8840 | "\x2F\x6F\x20\xA7\x47\xED\x74\x6C" | ||
8841 | "\x4E\xC1\xF8\x8C\x14\xF3\xBB\x1F" | ||
8842 | "\xED\x4D\x8F\x7C\x37\xEF\x19\xA1" | ||
8843 | "\x07\x16\xDE\x76\xCC\x5E\x94\x02" | ||
8844 | "\xFB\xBF\xE4\x81\x50\xCE\xFC\x0F" | ||
8845 | "\x9E\xCF\x3D\xF6\x67\x00\xBF\xA7" | ||
8846 | "\x6E\x21\x58\x36\x06\xDE\xB3\xD4" | ||
8847 | "\xA2\xFA\xD8\x4E\xE0\xB9\x7F\x23" | ||
8848 | "\x51\x21\x2B\x32\x68\xAA\xF8\xA8" | ||
8849 | "\x93\x08\xB5\x6D\xE6\x43\x2C\xB7" | ||
8850 | "\x31\xB2\x0F\xD0\xA2\x51\xC0\x25" | ||
8851 | "\x30\xC7\x10\x3F\x97\x27\x01\x8E" | ||
8852 | "\xFA\xD8\x4F\x78\xD8\x2E\x1D\xEB" | ||
8853 | "\xA1\x37\x52\x0F\x7B\x5E\x87\xA8" | ||
8854 | "\x22\xE2\xE6\x92\xA7\x5F\x11\x32" | ||
8855 | "\xCC\x93\x34\xFC\xD1\x7E\xAE\x54" | ||
8856 | "\xBC\x6A\x1B\x91\xD1\x2E\x21\xEC" | ||
8857 | "\x5D\xF1\xC4\xF1\x55\x20\xBF\xE5" | ||
8858 | "\x96\x3D\x69\x91\x20\x4E\xF2\x61" | ||
8859 | "\xDA\x77\xFE\xEE\xC3\x74\x57\x2A" | ||
8860 | "\x78\x39\xB0\xE0\xCF\x12\x56\xD6" | ||
8861 | "\x05\xDC\xF9\x19\x66\x44\x1D\xF9" | ||
8862 | "\x82\x37\xD4\xC2\x60\xB6\x31\xDF" | ||
8863 | "\x0C\xAF\xBC\x8B\x55\x9A\xC8\x2D" | ||
8864 | "\xAB\xA7\x88\x7B\x41\xE8\x29\xC9" | ||
8865 | "\x9B\x8D\xA7\x00\x86\x25\xB6\x14" | ||
8866 | "\xF5\x13\x73\xD7\x4B\x6B\x83\xF3" | ||
8867 | "\xAF\x96\x00\xE4\xB7\x3C\x65\xA6" | ||
8868 | "\x15\xB7\x94\x7D\x4E\x70\x4C\x75" | ||
8869 | "\xF3\xB4\x02\xA9\x17\x1C\x7A\x0A" | ||
8870 | "\xC0\xD5\x33\x11\x56\xDE\xDC\xF5" | ||
8871 | "\x8D\xD9\xCD\x3B\x22\x67\x18\xC7" | ||
8872 | "\xC4\xF5\x99\x61\xBC\xBB\x5B\x46", | ||
8873 | .rlen = 512, | ||
8874 | .also_non_np = 1, | ||
8875 | .np = 2, | ||
8876 | .tap = { 512 - 16, 16 }, | ||
8877 | }, | ||
8878 | }; | ||
8879 | |||
8880 | static struct cipher_testvec cast6_lrw_dec_tv_template[] = { | ||
8881 | { /* Generated from TF test vectors */ | ||
8882 | .key = "\xf8\xd4\x76\xff\xd6\x46\xee\x6c" | ||
8883 | "\x23\x84\xcb\x1c\x77\xd6\x19\x5d" | ||
8884 | "\xfe\xf1\xa9\xf3\x7b\xbc\x8d\x21" | ||
8885 | "\xa7\x9c\x21\xf8\xcb\x90\x02\x89" | ||
8886 | "\xa8\x45\x34\x8e\xc8\xc5\xb5\xf1" | ||
8887 | "\x26\xf5\x0e\x76\xfe\xfd\x1b\x1e", | ||
8888 | .klen = 48, | ||
8889 | .iv = "\x00\x00\x00\x00\x00\x00\x00\x00" | ||
8890 | "\x00\x00\x00\x00\x00\x00\x00\x01", | ||
8891 | .input = "\x55\x25\x09\x8B\xB5\xD5\xF8\xBF" | ||
8892 | "\x37\x4A\xFE\x3C\x47\xD8\xE6\xEB" | ||
8893 | "\xCA\xA4\x9B\xB0\xAB\x6D\x64\xCA" | ||
8894 | "\x58\xB6\x73\xF0\xD7\x52\x34\xEF" | ||
8895 | "\xFB\x3E\x96\x81\xB7\x71\x34\xA4" | ||
8896 | "\x55\x20\xBE\x39\x5A\x2B\xF9\xD1" | ||
8897 | "\x65\x0B\xDA\xD3\x7E\xB3\xA6\xF7" | ||
8898 | "\x2E\x0B\x5A\x52\xDB\x39\x8C\x9B" | ||
8899 | "\x61\x17\x5F\xAF\xB6\x5A\xC8\x08" | ||
8900 | "\xA7\xB7\x2A\x11\x7C\x97\x38\x9D" | ||
8901 | "\x59\x0E\x66\x59\x5E\xD8\x8B\xCE" | ||
8902 | "\x70\xE0\xC3\x42\xB0\x8C\x0F\xBA" | ||
8903 | "\xB2\x0D\x81\xB6\xBE\x61\x1C\x2D" | ||
8904 | "\x7E\xEA\x91\x25\xAC\xEC\xF8\x28" | ||
8905 | "\x80\x1D\xF0\x30\xBA\x62\x77\x7D" | ||
8906 | "\xDB\x15\x69\xDF\xFA\x2A\x81\x64" | ||
8907 | "\x95\x5B\xA4\x7F\x3E\x4F\xE3\x30" | ||
8908 | "\xB0\x5C\xC2\x05\xF8\xF0\x29\xE7" | ||
8909 | "\x0A\xA0\x66\xB2\x5D\x0F\x39\x2B" | ||
8910 | "\xB4\xB3\x00\xA9\xD0\xAB\x63\x61" | ||
8911 | "\x5E\xDB\xFC\x11\x74\x25\x96\x65" | ||
8912 | "\xE8\xE2\x34\x57\x77\x15\x5E\x70" | ||
8913 | "\xFF\x10\x90\xC3\x64\xF0\x11\x0A" | ||
8914 | "\x63\x3A\xD3\x55\x92\x15\x4B\x0C" | ||
8915 | "\xC7\x08\x89\x17\x3B\x99\xAD\x63" | ||
8916 | "\xE7\x06\xDF\x52\xBC\x15\x64\x45" | ||
8917 | "\x9D\x7A\xFB\x69\xBC\x2D\x6E\xA9" | ||
8918 | "\x35\xD9\xD8\xF5\x0C\xC4\xA2\x23" | ||
8919 | "\x9C\x18\x8B\xA8\x8C\xFE\xF8\x0E" | ||
8920 | "\xBD\xAB\x60\x1A\x51\x17\x54\x27" | ||
8921 | "\xB6\xE8\xBE\x0F\xA9\xA5\x82\x19" | ||
8922 | "\x2F\x6F\x20\xA7\x47\xED\x74\x6C" | ||
8923 | "\x4E\xC1\xF8\x8C\x14\xF3\xBB\x1F" | ||
8924 | "\xED\x4D\x8F\x7C\x37\xEF\x19\xA1" | ||
8925 | "\x07\x16\xDE\x76\xCC\x5E\x94\x02" | ||
8926 | "\xFB\xBF\xE4\x81\x50\xCE\xFC\x0F" | ||
8927 | "\x9E\xCF\x3D\xF6\x67\x00\xBF\xA7" | ||
8928 | "\x6E\x21\x58\x36\x06\xDE\xB3\xD4" | ||
8929 | "\xA2\xFA\xD8\x4E\xE0\xB9\x7F\x23" | ||
8930 | "\x51\x21\x2B\x32\x68\xAA\xF8\xA8" | ||
8931 | "\x93\x08\xB5\x6D\xE6\x43\x2C\xB7" | ||
8932 | "\x31\xB2\x0F\xD0\xA2\x51\xC0\x25" | ||
8933 | "\x30\xC7\x10\x3F\x97\x27\x01\x8E" | ||
8934 | "\xFA\xD8\x4F\x78\xD8\x2E\x1D\xEB" | ||
8935 | "\xA1\x37\x52\x0F\x7B\x5E\x87\xA8" | ||
8936 | "\x22\xE2\xE6\x92\xA7\x5F\x11\x32" | ||
8937 | "\xCC\x93\x34\xFC\xD1\x7E\xAE\x54" | ||
8938 | "\xBC\x6A\x1B\x91\xD1\x2E\x21\xEC" | ||
8939 | "\x5D\xF1\xC4\xF1\x55\x20\xBF\xE5" | ||
8940 | "\x96\x3D\x69\x91\x20\x4E\xF2\x61" | ||
8941 | "\xDA\x77\xFE\xEE\xC3\x74\x57\x2A" | ||
8942 | "\x78\x39\xB0\xE0\xCF\x12\x56\xD6" | ||
8943 | "\x05\xDC\xF9\x19\x66\x44\x1D\xF9" | ||
8944 | "\x82\x37\xD4\xC2\x60\xB6\x31\xDF" | ||
8945 | "\x0C\xAF\xBC\x8B\x55\x9A\xC8\x2D" | ||
8946 | "\xAB\xA7\x88\x7B\x41\xE8\x29\xC9" | ||
8947 | "\x9B\x8D\xA7\x00\x86\x25\xB6\x14" | ||
8948 | "\xF5\x13\x73\xD7\x4B\x6B\x83\xF3" | ||
8949 | "\xAF\x96\x00\xE4\xB7\x3C\x65\xA6" | ||
8950 | "\x15\xB7\x94\x7D\x4E\x70\x4C\x75" | ||
8951 | "\xF3\xB4\x02\xA9\x17\x1C\x7A\x0A" | ||
8952 | "\xC0\xD5\x33\x11\x56\xDE\xDC\xF5" | ||
8953 | "\x8D\xD9\xCD\x3B\x22\x67\x18\xC7" | ||
8954 | "\xC4\xF5\x99\x61\xBC\xBB\x5B\x46", | ||
8955 | .ilen = 512, | ||
8956 | .result = "\x05\x11\xb7\x18\xab\xc6\x2d\xac" | ||
8957 | "\x70\x5d\xf6\x22\x94\xcd\xe5\x6c" | ||
8958 | "\x17\x6b\xf6\x1c\xf0\xf3\x6e\xf8" | ||
8959 | "\x50\x38\x1f\x71\x49\xb6\x57\xd6" | ||
8960 | "\x8f\xcb\x8d\x6b\xe3\xa6\x29\x90" | ||
8961 | "\xfe\x2a\x62\x82\xae\x6d\x8b\xf6" | ||
8962 | "\xad\x1e\x9e\x20\x5f\x38\xbe\x04" | ||
8963 | "\xda\x10\x8e\xed\xa2\xa4\x87\xab" | ||
8964 | "\xda\x6b\xb4\x0c\x75\xba\xd3\x7c" | ||
8965 | "\xc9\xac\x42\x31\x95\x7c\xc9\x04" | ||
8966 | "\xeb\xd5\x6e\x32\x69\x8a\xdb\xa6" | ||
8967 | "\x15\xd7\x3f\x4f\x2f\x66\x69\x03" | ||
8968 | "\x9c\x1f\x54\x0f\xde\x1f\xf3\x65" | ||
8969 | "\x4c\x96\x12\xed\x7c\x92\x03\x01" | ||
8970 | "\x6f\xbc\x35\x93\xac\xf1\x27\xf1" | ||
8971 | "\xb4\x96\x82\x5a\x5f\xb0\xa0\x50" | ||
8972 | "\x89\xa4\x8e\x66\x44\x85\xcc\xfd" | ||
8973 | "\x33\x14\x70\xe3\x96\xb2\xc3\xd3" | ||
8974 | "\xbb\x54\x5a\x1a\xf9\x74\xa2\xc5" | ||
8975 | "\x2d\x64\x75\xdd\xb4\x54\xe6\x74" | ||
8976 | "\x8c\xd3\x9d\x9e\x86\xab\x51\x53" | ||
8977 | "\xb7\x93\x3e\x6f\xd0\x4e\x2c\x40" | ||
8978 | "\xf6\xa8\x2e\x3e\x9d\xf4\x66\xa5" | ||
8979 | "\x76\x12\x73\x44\x1a\x56\xd7\x72" | ||
8980 | "\x88\xcd\x21\x8c\x4c\x0f\xfe\xda" | ||
8981 | "\x95\xe0\x3a\xa6\xa5\x84\x46\xcd" | ||
8982 | "\xd5\x3e\x9d\x3a\xe2\x67\xe6\x60" | ||
8983 | "\x1a\xe2\x70\x85\x58\xc2\x1b\x09" | ||
8984 | "\xe1\xd7\x2c\xca\xad\xa8\x8f\xf9" | ||
8985 | "\xac\xb3\x0e\xdb\xca\x2e\xe2\xb8" | ||
8986 | "\x51\x71\xd9\x3c\x6c\xf1\x56\xf8" | ||
8987 | "\xea\x9c\xf1\xfb\x0c\xe6\xb7\x10" | ||
8988 | "\x1c\xf8\xa9\x7c\xe8\x53\x35\xc1" | ||
8989 | "\x90\x3e\x76\x4a\x74\xa4\x21\x2c" | ||
8990 | "\xf6\x2c\x4e\x0f\x94\x3a\x88\x2e" | ||
8991 | "\x41\x09\x6a\x33\x7d\xf6\xdd\x3f" | ||
8992 | "\x8d\x23\x31\x74\x84\xeb\x88\x6e" | ||
8993 | "\xcc\xb9\xbc\x22\x83\x19\x07\x22" | ||
8994 | "\xa5\x2d\xdf\xa5\xf3\x80\x85\x78" | ||
8995 | "\x84\x39\x6a\x6d\x6a\x99\x4f\xa5" | ||
8996 | "\x15\xfe\x46\xb0\xe4\x6c\xa5\x41" | ||
8997 | "\x3c\xce\x8f\x42\x60\x71\xa7\x75" | ||
8998 | "\x08\x40\x65\x8a\x82\xbf\xf5\x43" | ||
8999 | "\x71\x96\xa9\x4d\x44\x8a\x20\xbe" | ||
9000 | "\xfa\x4d\xbb\xc0\x7d\x31\x96\x65" | ||
9001 | "\xe7\x75\xe5\x3e\xfd\x92\x3b\xc9" | ||
9002 | "\x55\xbb\x16\x7e\xf7\xc2\x8c\xa4" | ||
9003 | "\x40\x1d\xe5\xef\x0e\xdf\xe4\x9a" | ||
9004 | "\x62\x73\x65\xfd\x46\x63\x25\x3d" | ||
9005 | "\x2b\xaf\xe5\x64\xfe\xa5\x5c\xcf" | ||
9006 | "\x24\xf3\xb4\xac\x64\xba\xdf\x4b" | ||
9007 | "\xc6\x96\x7d\x81\x2d\x8d\x97\xf7" | ||
9008 | "\xc5\x68\x77\x84\x32\x2b\xcc\x85" | ||
9009 | "\x74\x96\xf0\x12\x77\x61\xb9\xeb" | ||
9010 | "\x71\xaa\x82\xcb\x1c\xdb\x89\xc8" | ||
9011 | "\xc6\xb5\xe3\x5c\x7d\x39\x07\x24" | ||
9012 | "\xda\x39\x87\x45\xc0\x2b\xbb\x01" | ||
9013 | "\xac\xbc\x2a\x5c\x7f\xfc\xe8\xce" | ||
9014 | "\x6d\x9c\x6f\xed\xd3\xc1\xa1\xd6" | ||
9015 | "\xc5\x55\xa9\x66\x2f\xe1\xc8\x32" | ||
9016 | "\xa6\x5d\xa4\x3a\x98\x73\xe8\x45" | ||
9017 | "\xa4\xc7\xa8\xb4\xf6\x13\x03\xf6" | ||
9018 | "\xe9\x2e\xc4\x29\x0f\x84\xdb\xc4" | ||
9019 | "\x21\xc4\xc2\x75\x67\x89\x37\x0a", | ||
9020 | .rlen = 512, | ||
9021 | .also_non_np = 1, | ||
9022 | .np = 2, | ||
9023 | .tap = { 512 - 16, 16 }, | ||
9024 | }, | ||
9025 | }; | ||
9026 | |||
9027 | static struct cipher_testvec cast6_xts_enc_tv_template[] = { | ||
9028 | { /* Generated from TF test vectors */ | ||
9029 | .key = "\x27\x18\x28\x18\x28\x45\x90\x45" | ||
9030 | "\x23\x53\x60\x28\x74\x71\x35\x26" | ||
9031 | "\x62\x49\x77\x57\x24\x70\x93\x69" | ||
9032 | "\x99\x59\x57\x49\x66\x96\x76\x27" | ||
9033 | "\x31\x41\x59\x26\x53\x58\x97\x93" | ||
9034 | "\x23\x84\x62\x64\x33\x83\x27\x95" | ||
9035 | "\x02\x88\x41\x97\x16\x93\x99\x37" | ||
9036 | "\x51\x05\x82\x09\x74\x94\x45\x92", | ||
9037 | .klen = 64, | ||
9038 | .iv = "\xff\x00\x00\x00\x00\x00\x00\x00" | ||
9039 | "\x00\x00\x00\x00\x00\x00\x00\x00", | ||
9040 | .input = "\x00\x01\x02\x03\x04\x05\x06\x07" | ||
9041 | "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" | ||
9042 | "\x10\x11\x12\x13\x14\x15\x16\x17" | ||
9043 | "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" | ||
9044 | "\x20\x21\x22\x23\x24\x25\x26\x27" | ||
9045 | "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f" | ||
9046 | "\x30\x31\x32\x33\x34\x35\x36\x37" | ||
9047 | "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f" | ||
9048 | "\x40\x41\x42\x43\x44\x45\x46\x47" | ||
9049 | "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f" | ||
9050 | "\x50\x51\x52\x53\x54\x55\x56\x57" | ||
9051 | "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f" | ||
9052 | "\x60\x61\x62\x63\x64\x65\x66\x67" | ||
9053 | "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f" | ||
9054 | "\x70\x71\x72\x73\x74\x75\x76\x77" | ||
9055 | "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f" | ||
9056 | "\x80\x81\x82\x83\x84\x85\x86\x87" | ||
9057 | "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" | ||
9058 | "\x90\x91\x92\x93\x94\x95\x96\x97" | ||
9059 | "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" | ||
9060 | "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7" | ||
9061 | "\xa8\xa9\xaa\xab\xac\xad\xae\xaf" | ||
9062 | "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7" | ||
9063 | "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" | ||
9064 | "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7" | ||
9065 | "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" | ||
9066 | "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7" | ||
9067 | "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" | ||
9068 | "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7" | ||
9069 | "\xe8\xe9\xea\xeb\xec\xed\xee\xef" | ||
9070 | "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7" | ||
9071 | "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff" | ||
9072 | "\x00\x01\x02\x03\x04\x05\x06\x07" | ||
9073 | "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" | ||
9074 | "\x10\x11\x12\x13\x14\x15\x16\x17" | ||
9075 | "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" | ||
9076 | "\x20\x21\x22\x23\x24\x25\x26\x27" | ||
9077 | "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f" | ||
9078 | "\x30\x31\x32\x33\x34\x35\x36\x37" | ||
9079 | "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f" | ||
9080 | "\x40\x41\x42\x43\x44\x45\x46\x47" | ||
9081 | "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f" | ||
9082 | "\x50\x51\x52\x53\x54\x55\x56\x57" | ||
9083 | "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f" | ||
9084 | "\x60\x61\x62\x63\x64\x65\x66\x67" | ||
9085 | "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f" | ||
9086 | "\x70\x71\x72\x73\x74\x75\x76\x77" | ||
9087 | "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f" | ||
9088 | "\x80\x81\x82\x83\x84\x85\x86\x87" | ||
9089 | "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" | ||
9090 | "\x90\x91\x92\x93\x94\x95\x96\x97" | ||
9091 | "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" | ||
9092 | "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7" | ||
9093 | "\xa8\xa9\xaa\xab\xac\xad\xae\xaf" | ||
9094 | "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7" | ||
9095 | "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" | ||
9096 | "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7" | ||
9097 | "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" | ||
9098 | "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7" | ||
9099 | "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" | ||
9100 | "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7" | ||
9101 | "\xe8\xe9\xea\xeb\xec\xed\xee\xef" | ||
9102 | "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7" | ||
9103 | "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", | ||
9104 | .ilen = 512, | ||
9105 | .result = "\xDE\x6F\x22\xA5\xE8\x39\xE8\x78" | ||
9106 | "\x88\x5A\x4F\x8D\x82\x76\x52\x6D" | ||
9107 | "\xB2\x41\x16\xF4\x2B\xA6\xEB\xF6" | ||
9108 | "\xE2\xC5\x62\x8D\x61\xA1\x01\xED" | ||
9109 | "\xD9\x38\x01\xC1\x43\x63\x4E\x88" | ||
9110 | "\xC9\x4B\x5A\x88\x80\xB7\x5C\x71" | ||
9111 | "\x47\xEE\x11\xD8\xB7\x2D\x5D\x13" | ||
9112 | "\x1A\xB1\x68\x5B\x61\xA7\xA9\x81" | ||
9113 | "\x8B\x83\xA1\x6A\xAA\x36\xD6\xB6" | ||
9114 | "\x60\x54\x09\x32\xFE\x6A\x76\x2E" | ||
9115 | "\x28\xFF\xD5\xD6\xDD\x1D\x45\x7D" | ||
9116 | "\xF0\x8B\xF3\x32\x4E\x6C\x12\xCB" | ||
9117 | "\xB8\x25\x70\xF8\x40\xBC\x90\x1B" | ||
9118 | "\x11\xC3\x59\xAF\xF0\x2F\x92\xDD" | ||
9119 | "\xD3\x3B\xCF\x60\xA1\x78\x94\x57" | ||
9120 | "\xAF\x76\xC1\x67\xA6\x3C\xCD\x98" | ||
9121 | "\xB1\xF7\x27\xB9\xA3\xBD\x10\xEA" | ||
9122 | "\xCD\x8B\xC2\xF2\x14\xF2\xB2\x67" | ||
9123 | "\x05\xDD\x1D\x58\x6E\x2F\x95\x08" | ||
9124 | "\x3A\xF8\x78\x76\x82\x56\xA7\xEC" | ||
9125 | "\x51\x4B\x85\x77\xC2\x4C\x4A\x34" | ||
9126 | "\x71\x38\x17\x91\x44\xE8\xFC\x65" | ||
9127 | "\x99\x0D\x52\x91\xEE\xF8\xEF\x27" | ||
9128 | "\x2A\x9E\x6E\x78\xC4\x26\x87\xF4" | ||
9129 | "\x8A\xF0\x2D\x04\xE8\x14\x92\x5D" | ||
9130 | "\x59\x22\x9B\x29\x5C\x18\xF0\xC3" | ||
9131 | "\x47\xF3\x76\xD8\xE4\xF3\x1B\xD1" | ||
9132 | "\x70\xA3\x0D\xB5\x70\x02\x1D\xA3" | ||
9133 | "\x91\x3B\x49\x73\x18\xAB\xD4\xC9" | ||
9134 | "\xC3\x1E\xEF\x1F\xFE\xD5\x59\x8A" | ||
9135 | "\xD7\xF6\xC9\x71\x67\x79\xD7\x0E" | ||
9136 | "\xBE\x1F\x8E\xEC\x55\x7E\x4F\x24" | ||
9137 | "\xE6\x87\xEA\xFE\x96\x25\x67\x8E" | ||
9138 | "\x93\x03\xFA\xFF\xCE\xAF\xB2\x3C" | ||
9139 | "\x6F\xEB\x57\xFB\xD3\x28\x87\xA9" | ||
9140 | "\xCE\xC2\xF5\x9C\xC6\x67\xB5\x97" | ||
9141 | "\x49\xF7\x04\xCB\xEF\x84\x98\x33" | ||
9142 | "\xAF\x38\xD3\x04\x1C\x24\x71\x38" | ||
9143 | "\xC7\x71\xDD\x43\x0D\x12\x4A\x18" | ||
9144 | "\xBA\xC4\xAF\xBA\xB2\x5B\xEB\x95" | ||
9145 | "\x02\x43\x5D\xCE\x19\xCC\xCD\x66" | ||
9146 | "\x91\x0B\x8C\x7F\x51\xC4\xBF\x3C" | ||
9147 | "\x8B\xF1\xCC\xAA\x29\xD7\x87\xCB" | ||
9148 | "\x3E\xC5\xF3\xC9\x75\xE8\xA3\x5B" | ||
9149 | "\x30\x45\xA9\xB7\xAF\x80\x64\x6F" | ||
9150 | "\x75\x4A\xA7\xC0\x6D\x19\x6B\xDE" | ||
9151 | "\x17\xDE\x6D\xEA\x87\x9F\x95\xAE" | ||
9152 | "\xF5\x3C\xEE\x54\xB8\x27\x84\xF8" | ||
9153 | "\x97\xA3\xE1\x6F\x38\x24\x34\x88" | ||
9154 | "\xCE\xBD\x32\x52\xE0\x00\x6C\x94" | ||
9155 | "\xC9\xD7\x5D\x37\x81\x33\x2E\x7F" | ||
9156 | "\x4F\x7E\x2E\x0D\x94\xBD\xEA\x59" | ||
9157 | "\x34\x39\xA8\x35\x12\xB7\xBC\xAC" | ||
9158 | "\xEA\x52\x9C\x78\x02\x6D\x92\x36" | ||
9159 | "\xFB\x59\x2B\xA4\xEA\x7B\x1B\x83" | ||
9160 | "\xE1\x4D\x5E\x2A\x7E\x92\xB1\x64" | ||
9161 | "\xDE\xE0\x27\x4B\x0A\x6F\x4C\xE3" | ||
9162 | "\xB0\xEB\x31\xE4\x69\x95\xAB\x35" | ||
9163 | "\x8B\x2C\xF5\x6B\x7F\xF1\xA2\x82" | ||
9164 | "\xF8\xD9\x47\x82\xA9\x82\x03\x91" | ||
9165 | "\x69\x1F\xBE\x4C\xE7\xC7\x34\x2F" | ||
9166 | "\x45\x72\x80\x17\x81\xBD\x9D\x62" | ||
9167 | "\xA1\xAC\xE8\xCF\xC6\x74\xCF\xDC" | ||
9168 | "\x22\x60\x4E\xE8\xA4\x5D\x85\xB9", | ||
9169 | .rlen = 512, | ||
9170 | .also_non_np = 1, | ||
9171 | .np = 2, | ||
9172 | .tap = { 512 - 16, 16 }, | ||
9173 | }, | ||
9174 | }; | ||
9175 | |||
9176 | static struct cipher_testvec cast6_xts_dec_tv_template[] = { | ||
9177 | { /* Generated from TF test vectors */ | ||
9178 | .key = "\x27\x18\x28\x18\x28\x45\x90\x45" | ||
9179 | "\x23\x53\x60\x28\x74\x71\x35\x26" | ||
9180 | "\x62\x49\x77\x57\x24\x70\x93\x69" | ||
9181 | "\x99\x59\x57\x49\x66\x96\x76\x27" | ||
9182 | "\x31\x41\x59\x26\x53\x58\x97\x93" | ||
9183 | "\x23\x84\x62\x64\x33\x83\x27\x95" | ||
9184 | "\x02\x88\x41\x97\x16\x93\x99\x37" | ||
9185 | "\x51\x05\x82\x09\x74\x94\x45\x92", | ||
9186 | .klen = 64, | ||
9187 | .iv = "\xff\x00\x00\x00\x00\x00\x00\x00" | ||
9188 | "\x00\x00\x00\x00\x00\x00\x00\x00", | ||
9189 | .input = "\xDE\x6F\x22\xA5\xE8\x39\xE8\x78" | ||
9190 | "\x88\x5A\x4F\x8D\x82\x76\x52\x6D" | ||
9191 | "\xB2\x41\x16\xF4\x2B\xA6\xEB\xF6" | ||
9192 | "\xE2\xC5\x62\x8D\x61\xA1\x01\xED" | ||
9193 | "\xD9\x38\x01\xC1\x43\x63\x4E\x88" | ||
9194 | "\xC9\x4B\x5A\x88\x80\xB7\x5C\x71" | ||
9195 | "\x47\xEE\x11\xD8\xB7\x2D\x5D\x13" | ||
9196 | "\x1A\xB1\x68\x5B\x61\xA7\xA9\x81" | ||
9197 | "\x8B\x83\xA1\x6A\xAA\x36\xD6\xB6" | ||
9198 | "\x60\x54\x09\x32\xFE\x6A\x76\x2E" | ||
9199 | "\x28\xFF\xD5\xD6\xDD\x1D\x45\x7D" | ||
9200 | "\xF0\x8B\xF3\x32\x4E\x6C\x12\xCB" | ||
9201 | "\xB8\x25\x70\xF8\x40\xBC\x90\x1B" | ||
9202 | "\x11\xC3\x59\xAF\xF0\x2F\x92\xDD" | ||
9203 | "\xD3\x3B\xCF\x60\xA1\x78\x94\x57" | ||
9204 | "\xAF\x76\xC1\x67\xA6\x3C\xCD\x98" | ||
9205 | "\xB1\xF7\x27\xB9\xA3\xBD\x10\xEA" | ||
9206 | "\xCD\x8B\xC2\xF2\x14\xF2\xB2\x67" | ||
9207 | "\x05\xDD\x1D\x58\x6E\x2F\x95\x08" | ||
9208 | "\x3A\xF8\x78\x76\x82\x56\xA7\xEC" | ||
9209 | "\x51\x4B\x85\x77\xC2\x4C\x4A\x34" | ||
9210 | "\x71\x38\x17\x91\x44\xE8\xFC\x65" | ||
9211 | "\x99\x0D\x52\x91\xEE\xF8\xEF\x27" | ||
9212 | "\x2A\x9E\x6E\x78\xC4\x26\x87\xF4" | ||
9213 | "\x8A\xF0\x2D\x04\xE8\x14\x92\x5D" | ||
9214 | "\x59\x22\x9B\x29\x5C\x18\xF0\xC3" | ||
9215 | "\x47\xF3\x76\xD8\xE4\xF3\x1B\xD1" | ||
9216 | "\x70\xA3\x0D\xB5\x70\x02\x1D\xA3" | ||
9217 | "\x91\x3B\x49\x73\x18\xAB\xD4\xC9" | ||
9218 | "\xC3\x1E\xEF\x1F\xFE\xD5\x59\x8A" | ||
9219 | "\xD7\xF6\xC9\x71\x67\x79\xD7\x0E" | ||
9220 | "\xBE\x1F\x8E\xEC\x55\x7E\x4F\x24" | ||
9221 | "\xE6\x87\xEA\xFE\x96\x25\x67\x8E" | ||
9222 | "\x93\x03\xFA\xFF\xCE\xAF\xB2\x3C" | ||
9223 | "\x6F\xEB\x57\xFB\xD3\x28\x87\xA9" | ||
9224 | "\xCE\xC2\xF5\x9C\xC6\x67\xB5\x97" | ||
9225 | "\x49\xF7\x04\xCB\xEF\x84\x98\x33" | ||
9226 | "\xAF\x38\xD3\x04\x1C\x24\x71\x38" | ||
9227 | "\xC7\x71\xDD\x43\x0D\x12\x4A\x18" | ||
9228 | "\xBA\xC4\xAF\xBA\xB2\x5B\xEB\x95" | ||
9229 | "\x02\x43\x5D\xCE\x19\xCC\xCD\x66" | ||
9230 | "\x91\x0B\x8C\x7F\x51\xC4\xBF\x3C" | ||
9231 | "\x8B\xF1\xCC\xAA\x29\xD7\x87\xCB" | ||
9232 | "\x3E\xC5\xF3\xC9\x75\xE8\xA3\x5B" | ||
9233 | "\x30\x45\xA9\xB7\xAF\x80\x64\x6F" | ||
9234 | "\x75\x4A\xA7\xC0\x6D\x19\x6B\xDE" | ||
9235 | "\x17\xDE\x6D\xEA\x87\x9F\x95\xAE" | ||
9236 | "\xF5\x3C\xEE\x54\xB8\x27\x84\xF8" | ||
9237 | "\x97\xA3\xE1\x6F\x38\x24\x34\x88" | ||
9238 | "\xCE\xBD\x32\x52\xE0\x00\x6C\x94" | ||
9239 | "\xC9\xD7\x5D\x37\x81\x33\x2E\x7F" | ||
9240 | "\x4F\x7E\x2E\x0D\x94\xBD\xEA\x59" | ||
9241 | "\x34\x39\xA8\x35\x12\xB7\xBC\xAC" | ||
9242 | "\xEA\x52\x9C\x78\x02\x6D\x92\x36" | ||
9243 | "\xFB\x59\x2B\xA4\xEA\x7B\x1B\x83" | ||
9244 | "\xE1\x4D\x5E\x2A\x7E\x92\xB1\x64" | ||
9245 | "\xDE\xE0\x27\x4B\x0A\x6F\x4C\xE3" | ||
9246 | "\xB0\xEB\x31\xE4\x69\x95\xAB\x35" | ||
9247 | "\x8B\x2C\xF5\x6B\x7F\xF1\xA2\x82" | ||
9248 | "\xF8\xD9\x47\x82\xA9\x82\x03\x91" | ||
9249 | "\x69\x1F\xBE\x4C\xE7\xC7\x34\x2F" | ||
9250 | "\x45\x72\x80\x17\x81\xBD\x9D\x62" | ||
9251 | "\xA1\xAC\xE8\xCF\xC6\x74\xCF\xDC" | ||
9252 | "\x22\x60\x4E\xE8\xA4\x5D\x85\xB9", | ||
9253 | .ilen = 512, | ||
9254 | .result = "\x00\x01\x02\x03\x04\x05\x06\x07" | ||
9255 | "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" | ||
9256 | "\x10\x11\x12\x13\x14\x15\x16\x17" | ||
9257 | "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" | ||
9258 | "\x20\x21\x22\x23\x24\x25\x26\x27" | ||
9259 | "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f" | ||
9260 | "\x30\x31\x32\x33\x34\x35\x36\x37" | ||
9261 | "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f" | ||
9262 | "\x40\x41\x42\x43\x44\x45\x46\x47" | ||
9263 | "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f" | ||
9264 | "\x50\x51\x52\x53\x54\x55\x56\x57" | ||
9265 | "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f" | ||
9266 | "\x60\x61\x62\x63\x64\x65\x66\x67" | ||
9267 | "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f" | ||
9268 | "\x70\x71\x72\x73\x74\x75\x76\x77" | ||
9269 | "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f" | ||
9270 | "\x80\x81\x82\x83\x84\x85\x86\x87" | ||
9271 | "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" | ||
9272 | "\x90\x91\x92\x93\x94\x95\x96\x97" | ||
9273 | "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" | ||
9274 | "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7" | ||
9275 | "\xa8\xa9\xaa\xab\xac\xad\xae\xaf" | ||
9276 | "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7" | ||
9277 | "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" | ||
9278 | "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7" | ||
9279 | "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" | ||
9280 | "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7" | ||
9281 | "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" | ||
9282 | "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7" | ||
9283 | "\xe8\xe9\xea\xeb\xec\xed\xee\xef" | ||
9284 | "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7" | ||
9285 | "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff" | ||
9286 | "\x00\x01\x02\x03\x04\x05\x06\x07" | ||
9287 | "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" | ||
9288 | "\x10\x11\x12\x13\x14\x15\x16\x17" | ||
9289 | "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" | ||
9290 | "\x20\x21\x22\x23\x24\x25\x26\x27" | ||
9291 | "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f" | ||
9292 | "\x30\x31\x32\x33\x34\x35\x36\x37" | ||
9293 | "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f" | ||
9294 | "\x40\x41\x42\x43\x44\x45\x46\x47" | ||
9295 | "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f" | ||
9296 | "\x50\x51\x52\x53\x54\x55\x56\x57" | ||
9297 | "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f" | ||
9298 | "\x60\x61\x62\x63\x64\x65\x66\x67" | ||
9299 | "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f" | ||
9300 | "\x70\x71\x72\x73\x74\x75\x76\x77" | ||
9301 | "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f" | ||
9302 | "\x80\x81\x82\x83\x84\x85\x86\x87" | ||
9303 | "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" | ||
9304 | "\x90\x91\x92\x93\x94\x95\x96\x97" | ||
9305 | "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" | ||
9306 | "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7" | ||
9307 | "\xa8\xa9\xaa\xab\xac\xad\xae\xaf" | ||
9308 | "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7" | ||
9309 | "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" | ||
9310 | "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7" | ||
9311 | "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" | ||
9312 | "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7" | ||
9313 | "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" | ||
9314 | "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7" | ||
9315 | "\xe8\xe9\xea\xeb\xec\xed\xee\xef" | ||
9316 | "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7" | ||
9317 | "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", | ||
9318 | .rlen = 512, | ||
9319 | .also_non_np = 1, | ||
9320 | .np = 2, | ||
9321 | .tap = { 512 - 16, 16 }, | ||
6967 | }, | 9322 | }, |
6968 | }; | 9323 | }; |
6969 | 9324 | ||
@@ -8313,6 +10668,9 @@ static struct cipher_testvec aes_lrw_enc_tv_template[] = { | |||
8313 | "\xcd\x7e\x2b\x5d\x43\xea\x42\xe7" | 10668 | "\xcd\x7e\x2b\x5d\x43\xea\x42\xe7" |
8314 | "\x74\x3f\x7d\x58\x88\x75\xde\x3e", | 10669 | "\x74\x3f\x7d\x58\x88\x75\xde\x3e", |
8315 | .rlen = 512, | 10670 | .rlen = 512, |
10671 | .also_non_np = 1, | ||
10672 | .np = 2, | ||
10673 | .tap = { 512 - 16, 16 }, | ||
8316 | } | 10674 | } |
8317 | }; | 10675 | }; |
8318 | 10676 | ||
@@ -8564,6 +10922,9 @@ static struct cipher_testvec aes_lrw_dec_tv_template[] = { | |||
8564 | "\xe9\x2e\xc4\x29\x0f\x84\xdb\xc4" | 10922 | "\xe9\x2e\xc4\x29\x0f\x84\xdb\xc4" |
8565 | "\x21\xc4\xc2\x75\x67\x89\x37\x0a", | 10923 | "\x21\xc4\xc2\x75\x67\x89\x37\x0a", |
8566 | .rlen = 512, | 10924 | .rlen = 512, |
10925 | .also_non_np = 1, | ||
10926 | .np = 2, | ||
10927 | .tap = { 512 - 16, 16 }, | ||
8567 | } | 10928 | } |
8568 | }; | 10929 | }; |
8569 | 10930 | ||
@@ -8905,6 +11266,9 @@ static struct cipher_testvec aes_xts_enc_tv_template[] = { | |||
8905 | "\xc4\xf3\x6f\xfd\xa9\xfc\xea\x70" | 11266 | "\xc4\xf3\x6f\xfd\xa9\xfc\xea\x70" |
8906 | "\xb9\xc6\xe6\x93\xe1\x48\xc1\x51", | 11267 | "\xb9\xc6\xe6\x93\xe1\x48\xc1\x51", |
8907 | .rlen = 512, | 11268 | .rlen = 512, |
11269 | .also_non_np = 1, | ||
11270 | .np = 2, | ||
11271 | .tap = { 512 - 16, 16 }, | ||
8908 | } | 11272 | } |
8909 | }; | 11273 | }; |
8910 | 11274 | ||
@@ -9246,7 +11610,9 @@ static struct cipher_testvec aes_xts_dec_tv_template[] = { | |||
9246 | "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7" | 11610 | "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7" |
9247 | "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", | 11611 | "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", |
9248 | .rlen = 512, | 11612 | .rlen = 512, |
9249 | 11613 | .also_non_np = 1, | |
11614 | .np = 2, | ||
11615 | .tap = { 512 - 16, 16 }, | ||
9250 | } | 11616 | } |
9251 | }; | 11617 | }; |
9252 | 11618 | ||
@@ -12125,8 +14491,12 @@ static struct cprng_testvec ansi_cprng_aes_tv_template[] = { | |||
12125 | }; | 14491 | }; |
12126 | 14492 | ||
12127 | /* Cast5 test vectors from RFC 2144 */ | 14493 | /* Cast5 test vectors from RFC 2144 */ |
12128 | #define CAST5_ENC_TEST_VECTORS 3 | 14494 | #define CAST5_ENC_TEST_VECTORS 4 |
12129 | #define CAST5_DEC_TEST_VECTORS 3 | 14495 | #define CAST5_DEC_TEST_VECTORS 4 |
14496 | #define CAST5_CBC_ENC_TEST_VECTORS 1 | ||
14497 | #define CAST5_CBC_DEC_TEST_VECTORS 1 | ||
14498 | #define CAST5_CTR_ENC_TEST_VECTORS 2 | ||
14499 | #define CAST5_CTR_DEC_TEST_VECTORS 2 | ||
12130 | 14500 | ||
12131 | static struct cipher_testvec cast5_enc_tv_template[] = { | 14501 | static struct cipher_testvec cast5_enc_tv_template[] = { |
12132 | { | 14502 | { |
@@ -12152,6 +14522,140 @@ static struct cipher_testvec cast5_enc_tv_template[] = { | |||
12152 | .ilen = 8, | 14522 | .ilen = 8, |
12153 | .result = "\x7a\xc8\x16\xd1\x6e\x9b\x30\x2e", | 14523 | .result = "\x7a\xc8\x16\xd1\x6e\x9b\x30\x2e", |
12154 | .rlen = 8, | 14524 | .rlen = 8, |
14525 | }, { /* Generated from TF test vectors */ | ||
14526 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
14527 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A", | ||
14528 | .klen = 16, | ||
14529 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F", | ||
14530 | .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
14531 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
14532 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
14533 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
14534 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
14535 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
14536 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
14537 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" | ||
14538 | "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" | ||
14539 | "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" | ||
14540 | "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" | ||
14541 | "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" | ||
14542 | "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" | ||
14543 | "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" | ||
14544 | "\x29\xC0\x57\xEE\x62\xF9\x90\x04" | ||
14545 | "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" | ||
14546 | "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" | ||
14547 | "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" | ||
14548 | "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" | ||
14549 | "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" | ||
14550 | "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" | ||
14551 | "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" | ||
14552 | "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" | ||
14553 | "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" | ||
14554 | "\x57\xEE\x85\x1C\x90\x27\xBE\x32" | ||
14555 | "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" | ||
14556 | "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" | ||
14557 | "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" | ||
14558 | "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" | ||
14559 | "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" | ||
14560 | "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" | ||
14561 | "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" | ||
14562 | "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" | ||
14563 | "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" | ||
14564 | "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" | ||
14565 | "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" | ||
14566 | "\x69\x00\x74\x0B\xA2\x16\xAD\x44" | ||
14567 | "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" | ||
14568 | "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" | ||
14569 | "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" | ||
14570 | "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" | ||
14571 | "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" | ||
14572 | "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" | ||
14573 | "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" | ||
14574 | "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" | ||
14575 | "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" | ||
14576 | "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" | ||
14577 | "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" | ||
14578 | "\x58\xEF\x86\x1D\x91\x28\xBF\x33" | ||
14579 | "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" | ||
14580 | "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" | ||
14581 | "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" | ||
14582 | "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" | ||
14583 | "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" | ||
14584 | "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" | ||
14585 | "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" | ||
14586 | "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" | ||
14587 | "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" | ||
14588 | "\x86\x1D\xB4\x28\xBF\x56\xED\x61" | ||
14589 | "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" | ||
14590 | "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" | ||
14591 | "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", | ||
14592 | .ilen = 496, | ||
14593 | .result = "\x8D\xFC\x81\x9C\xCB\xAA\x5A\x1C" | ||
14594 | "\x7E\x95\xCF\x40\xAB\x4D\x6F\xEA" | ||
14595 | "\xD3\xD9\xB0\x9A\xB7\xC7\xE0\x2E" | ||
14596 | "\xD1\x39\x34\x92\x8F\xFA\x14\xF1" | ||
14597 | "\xD5\xD2\x7B\x59\x1F\x35\x28\xC2" | ||
14598 | "\x20\xD9\x42\x06\xC9\x0B\x10\x04" | ||
14599 | "\xF8\x79\xCD\x32\x86\x75\x4C\xB6" | ||
14600 | "\x7B\x1C\x52\xB1\x91\x64\x22\x4B" | ||
14601 | "\x13\xC7\xAE\x98\x0E\xB5\xCF\x6F" | ||
14602 | "\x3F\xF4\x43\x96\x73\x0D\xA2\x05" | ||
14603 | "\xDB\xFD\x28\x90\x2C\x56\xB9\x37" | ||
14604 | "\x5B\x69\x0C\xAD\x84\x67\xFF\x15" | ||
14605 | "\x4A\xD4\xA7\xD3\xDD\x99\x47\x3A" | ||
14606 | "\xED\x34\x35\x78\x6B\x91\xC9\x32" | ||
14607 | "\xE1\xBF\xBC\xB4\x04\x85\x6A\x39" | ||
14608 | "\xC0\xBA\x51\xD0\x0F\x4E\xD1\xE2" | ||
14609 | "\x1C\xFD\x0E\x05\x07\xF4\x10\xED" | ||
14610 | "\xA2\x17\xFF\xF5\x64\xC6\x1A\x22" | ||
14611 | "\xAD\x78\xE7\xD7\x11\xE9\x99\xB9" | ||
14612 | "\xAA\xEC\x6F\xF8\x3B\xBF\xCE\x77" | ||
14613 | "\x93\xE8\xAD\x1D\x50\x6C\xAE\xBC" | ||
14614 | "\xBA\x5C\x80\xD1\x91\x65\x51\x1B" | ||
14615 | "\xE8\x0A\xCD\x99\x96\x71\x3D\xB6" | ||
14616 | "\x78\x75\x37\x55\xC1\xF5\x90\x40" | ||
14617 | "\x34\xF4\x7E\xC8\xCC\x3A\x5F\x6E" | ||
14618 | "\x36\xA1\xA1\xC2\x3A\x72\x42\x8E" | ||
14619 | "\x0E\x37\x88\xE8\xCE\x83\xCB\xAD" | ||
14620 | "\xE0\x69\x77\x50\xC7\x0C\x99\xCA" | ||
14621 | "\x19\x5B\x30\x25\x9A\xEF\x9B\x0C" | ||
14622 | "\xEF\x8F\x74\x4C\xCF\x49\x4E\xB9" | ||
14623 | "\xC5\xAE\x9E\x2E\x78\x9A\xB9\x48" | ||
14624 | "\xD5\x81\xE4\x37\x1D\xBF\x27\xD9" | ||
14625 | "\xC5\xD6\x65\x43\x45\x8C\xBB\xB6" | ||
14626 | "\x55\xF4\x06\xBB\x49\x53\x8B\x1B" | ||
14627 | "\x07\xA9\x96\x69\x5B\xCB\x0F\xBC" | ||
14628 | "\x93\x85\x90\x0F\x0A\x68\x40\x2A" | ||
14629 | "\x95\xED\x2D\x88\xBF\x71\xD0\xBB" | ||
14630 | "\xEC\xB0\x77\x6C\x79\xFC\x3C\x05" | ||
14631 | "\x49\x3F\xB8\x24\xEF\x8E\x09\xA2" | ||
14632 | "\x1D\xEF\x92\x02\x96\xD4\x7F\xC8" | ||
14633 | "\x03\xB2\xCA\xDB\x17\x5C\x52\xCF" | ||
14634 | "\xDD\x70\x37\x63\xAA\xA5\x83\x20" | ||
14635 | "\x52\x02\xF6\xB9\xE7\x6E\x0A\xB6" | ||
14636 | "\x79\x03\xA0\xDA\xA3\x79\x21\xBD" | ||
14637 | "\xE3\x37\x3A\xC0\xF7\x2C\x32\xBE" | ||
14638 | "\x8B\xE8\xA6\x00\xC7\x32\xD5\x06" | ||
14639 | "\xBB\xE3\xAB\x06\x21\x82\xB8\x32" | ||
14640 | "\x31\x34\x2A\xA7\x1F\x64\x99\xBF" | ||
14641 | "\xFA\xDA\x3D\x75\xF7\x48\xD5\x48" | ||
14642 | "\x4B\x52\x7E\xF6\x7C\xAB\x67\x59" | ||
14643 | "\xC5\xDC\xA8\xC6\x63\x85\x4A\xDF" | ||
14644 | "\xF0\x40\x5F\xCF\xE3\x58\x52\x67" | ||
14645 | "\x7A\x24\x32\xC5\xEC\x9E\xA9\x6F" | ||
14646 | "\x58\x56\xDD\x94\x1F\x71\x8D\xF4" | ||
14647 | "\x6E\xFF\x2C\xA7\xA5\xD8\xBA\xAF" | ||
14648 | "\x1D\x8B\xA2\x46\xB5\xC4\x9F\x57" | ||
14649 | "\x8D\xD8\xB3\x3C\x02\x0D\xBB\x84" | ||
14650 | "\xC7\xBD\xB4\x9A\x6E\xBB\xB1\x37" | ||
14651 | "\x95\x79\xC4\xA7\xEA\x1D\xDC\x33" | ||
14652 | "\x5D\x0B\x3F\x03\x8F\x30\xF9\xAE" | ||
14653 | "\x4F\xFE\x24\x9C\x9A\x02\xE5\x57" | ||
14654 | "\xF5\xBC\x25\xD6\x02\x56\x57\x1C", | ||
14655 | .rlen = 496, | ||
14656 | .also_non_np = 1, | ||
14657 | .np = 2, | ||
14658 | .tap = { 496 - 16, 16 }, | ||
12155 | }, | 14659 | }, |
12156 | }; | 14660 | }; |
12157 | 14661 | ||
@@ -12179,6 +14683,718 @@ static struct cipher_testvec cast5_dec_tv_template[] = { | |||
12179 | .ilen = 8, | 14683 | .ilen = 8, |
12180 | .result = "\x01\x23\x45\x67\x89\xab\xcd\xef", | 14684 | .result = "\x01\x23\x45\x67\x89\xab\xcd\xef", |
12181 | .rlen = 8, | 14685 | .rlen = 8, |
14686 | }, { /* Generated from TF test vectors */ | ||
14687 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
14688 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A", | ||
14689 | .klen = 16, | ||
14690 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F", | ||
14691 | .input = "\x8D\xFC\x81\x9C\xCB\xAA\x5A\x1C" | ||
14692 | "\x7E\x95\xCF\x40\xAB\x4D\x6F\xEA" | ||
14693 | "\xD3\xD9\xB0\x9A\xB7\xC7\xE0\x2E" | ||
14694 | "\xD1\x39\x34\x92\x8F\xFA\x14\xF1" | ||
14695 | "\xD5\xD2\x7B\x59\x1F\x35\x28\xC2" | ||
14696 | "\x20\xD9\x42\x06\xC9\x0B\x10\x04" | ||
14697 | "\xF8\x79\xCD\x32\x86\x75\x4C\xB6" | ||
14698 | "\x7B\x1C\x52\xB1\x91\x64\x22\x4B" | ||
14699 | "\x13\xC7\xAE\x98\x0E\xB5\xCF\x6F" | ||
14700 | "\x3F\xF4\x43\x96\x73\x0D\xA2\x05" | ||
14701 | "\xDB\xFD\x28\x90\x2C\x56\xB9\x37" | ||
14702 | "\x5B\x69\x0C\xAD\x84\x67\xFF\x15" | ||
14703 | "\x4A\xD4\xA7\xD3\xDD\x99\x47\x3A" | ||
14704 | "\xED\x34\x35\x78\x6B\x91\xC9\x32" | ||
14705 | "\xE1\xBF\xBC\xB4\x04\x85\x6A\x39" | ||
14706 | "\xC0\xBA\x51\xD0\x0F\x4E\xD1\xE2" | ||
14707 | "\x1C\xFD\x0E\x05\x07\xF4\x10\xED" | ||
14708 | "\xA2\x17\xFF\xF5\x64\xC6\x1A\x22" | ||
14709 | "\xAD\x78\xE7\xD7\x11\xE9\x99\xB9" | ||
14710 | "\xAA\xEC\x6F\xF8\x3B\xBF\xCE\x77" | ||
14711 | "\x93\xE8\xAD\x1D\x50\x6C\xAE\xBC" | ||
14712 | "\xBA\x5C\x80\xD1\x91\x65\x51\x1B" | ||
14713 | "\xE8\x0A\xCD\x99\x96\x71\x3D\xB6" | ||
14714 | "\x78\x75\x37\x55\xC1\xF5\x90\x40" | ||
14715 | "\x34\xF4\x7E\xC8\xCC\x3A\x5F\x6E" | ||
14716 | "\x36\xA1\xA1\xC2\x3A\x72\x42\x8E" | ||
14717 | "\x0E\x37\x88\xE8\xCE\x83\xCB\xAD" | ||
14718 | "\xE0\x69\x77\x50\xC7\x0C\x99\xCA" | ||
14719 | "\x19\x5B\x30\x25\x9A\xEF\x9B\x0C" | ||
14720 | "\xEF\x8F\x74\x4C\xCF\x49\x4E\xB9" | ||
14721 | "\xC5\xAE\x9E\x2E\x78\x9A\xB9\x48" | ||
14722 | "\xD5\x81\xE4\x37\x1D\xBF\x27\xD9" | ||
14723 | "\xC5\xD6\x65\x43\x45\x8C\xBB\xB6" | ||
14724 | "\x55\xF4\x06\xBB\x49\x53\x8B\x1B" | ||
14725 | "\x07\xA9\x96\x69\x5B\xCB\x0F\xBC" | ||
14726 | "\x93\x85\x90\x0F\x0A\x68\x40\x2A" | ||
14727 | "\x95\xED\x2D\x88\xBF\x71\xD0\xBB" | ||
14728 | "\xEC\xB0\x77\x6C\x79\xFC\x3C\x05" | ||
14729 | "\x49\x3F\xB8\x24\xEF\x8E\x09\xA2" | ||
14730 | "\x1D\xEF\x92\x02\x96\xD4\x7F\xC8" | ||
14731 | "\x03\xB2\xCA\xDB\x17\x5C\x52\xCF" | ||
14732 | "\xDD\x70\x37\x63\xAA\xA5\x83\x20" | ||
14733 | "\x52\x02\xF6\xB9\xE7\x6E\x0A\xB6" | ||
14734 | "\x79\x03\xA0\xDA\xA3\x79\x21\xBD" | ||
14735 | "\xE3\x37\x3A\xC0\xF7\x2C\x32\xBE" | ||
14736 | "\x8B\xE8\xA6\x00\xC7\x32\xD5\x06" | ||
14737 | "\xBB\xE3\xAB\x06\x21\x82\xB8\x32" | ||
14738 | "\x31\x34\x2A\xA7\x1F\x64\x99\xBF" | ||
14739 | "\xFA\xDA\x3D\x75\xF7\x48\xD5\x48" | ||
14740 | "\x4B\x52\x7E\xF6\x7C\xAB\x67\x59" | ||
14741 | "\xC5\xDC\xA8\xC6\x63\x85\x4A\xDF" | ||
14742 | "\xF0\x40\x5F\xCF\xE3\x58\x52\x67" | ||
14743 | "\x7A\x24\x32\xC5\xEC\x9E\xA9\x6F" | ||
14744 | "\x58\x56\xDD\x94\x1F\x71\x8D\xF4" | ||
14745 | "\x6E\xFF\x2C\xA7\xA5\xD8\xBA\xAF" | ||
14746 | "\x1D\x8B\xA2\x46\xB5\xC4\x9F\x57" | ||
14747 | "\x8D\xD8\xB3\x3C\x02\x0D\xBB\x84" | ||
14748 | "\xC7\xBD\xB4\x9A\x6E\xBB\xB1\x37" | ||
14749 | "\x95\x79\xC4\xA7\xEA\x1D\xDC\x33" | ||
14750 | "\x5D\x0B\x3F\x03\x8F\x30\xF9\xAE" | ||
14751 | "\x4F\xFE\x24\x9C\x9A\x02\xE5\x57" | ||
14752 | "\xF5\xBC\x25\xD6\x02\x56\x57\x1C", | ||
14753 | .ilen = 496, | ||
14754 | .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
14755 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
14756 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
14757 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
14758 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
14759 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
14760 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
14761 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" | ||
14762 | "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" | ||
14763 | "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" | ||
14764 | "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" | ||
14765 | "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" | ||
14766 | "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" | ||
14767 | "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" | ||
14768 | "\x29\xC0\x57\xEE\x62\xF9\x90\x04" | ||
14769 | "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" | ||
14770 | "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" | ||
14771 | "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" | ||
14772 | "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" | ||
14773 | "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" | ||
14774 | "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" | ||
14775 | "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" | ||
14776 | "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" | ||
14777 | "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" | ||
14778 | "\x57\xEE\x85\x1C\x90\x27\xBE\x32" | ||
14779 | "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" | ||
14780 | "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" | ||
14781 | "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" | ||
14782 | "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" | ||
14783 | "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" | ||
14784 | "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" | ||
14785 | "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" | ||
14786 | "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" | ||
14787 | "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" | ||
14788 | "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" | ||
14789 | "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" | ||
14790 | "\x69\x00\x74\x0B\xA2\x16\xAD\x44" | ||
14791 | "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" | ||
14792 | "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" | ||
14793 | "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" | ||
14794 | "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" | ||
14795 | "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" | ||
14796 | "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" | ||
14797 | "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" | ||
14798 | "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" | ||
14799 | "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" | ||
14800 | "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" | ||
14801 | "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" | ||
14802 | "\x58\xEF\x86\x1D\x91\x28\xBF\x33" | ||
14803 | "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" | ||
14804 | "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" | ||
14805 | "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" | ||
14806 | "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" | ||
14807 | "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" | ||
14808 | "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" | ||
14809 | "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" | ||
14810 | "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" | ||
14811 | "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" | ||
14812 | "\x86\x1D\xB4\x28\xBF\x56\xED\x61" | ||
14813 | "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" | ||
14814 | "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" | ||
14815 | "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", | ||
14816 | .rlen = 496, | ||
14817 | .also_non_np = 1, | ||
14818 | .np = 2, | ||
14819 | .tap = { 496 - 16, 16 }, | ||
14820 | }, | ||
14821 | }; | ||
14822 | |||
14823 | static struct cipher_testvec cast5_cbc_enc_tv_template[] = { | ||
14824 | { /* Generated from TF test vectors */ | ||
14825 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
14826 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A", | ||
14827 | .klen = 16, | ||
14828 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F", | ||
14829 | .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
14830 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
14831 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
14832 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
14833 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
14834 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
14835 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
14836 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" | ||
14837 | "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" | ||
14838 | "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" | ||
14839 | "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" | ||
14840 | "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" | ||
14841 | "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" | ||
14842 | "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" | ||
14843 | "\x29\xC0\x57\xEE\x62\xF9\x90\x04" | ||
14844 | "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" | ||
14845 | "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" | ||
14846 | "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" | ||
14847 | "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" | ||
14848 | "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" | ||
14849 | "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" | ||
14850 | "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" | ||
14851 | "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" | ||
14852 | "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" | ||
14853 | "\x57\xEE\x85\x1C\x90\x27\xBE\x32" | ||
14854 | "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" | ||
14855 | "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" | ||
14856 | "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" | ||
14857 | "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" | ||
14858 | "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" | ||
14859 | "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" | ||
14860 | "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" | ||
14861 | "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" | ||
14862 | "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" | ||
14863 | "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" | ||
14864 | "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" | ||
14865 | "\x69\x00\x74\x0B\xA2\x16\xAD\x44" | ||
14866 | "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" | ||
14867 | "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" | ||
14868 | "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" | ||
14869 | "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" | ||
14870 | "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" | ||
14871 | "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" | ||
14872 | "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" | ||
14873 | "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" | ||
14874 | "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" | ||
14875 | "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" | ||
14876 | "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" | ||
14877 | "\x58\xEF\x86\x1D\x91\x28\xBF\x33" | ||
14878 | "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" | ||
14879 | "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" | ||
14880 | "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" | ||
14881 | "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" | ||
14882 | "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" | ||
14883 | "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" | ||
14884 | "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" | ||
14885 | "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" | ||
14886 | "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" | ||
14887 | "\x86\x1D\xB4\x28\xBF\x56\xED\x61" | ||
14888 | "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" | ||
14889 | "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" | ||
14890 | "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", | ||
14891 | .ilen = 496, | ||
14892 | .result = "\x05\x28\xCE\x61\x90\x80\xE1\x78" | ||
14893 | "\xB9\x2A\x97\x7C\xB0\x83\xD8\x1A" | ||
14894 | "\xDE\x58\x7F\xD7\xFD\x72\xB8\xFB" | ||
14895 | "\xDA\xF0\x6E\x77\x14\x47\x82\xBA" | ||
14896 | "\x29\x0E\x25\x6E\xB4\x39\xD9\x7F" | ||
14897 | "\x05\xA7\xA7\x3A\xC1\x5D\x9E\x39" | ||
14898 | "\xA7\xFB\x0D\x05\x00\xF3\x58\x67" | ||
14899 | "\x60\xEC\x73\x77\x46\x85\x9B\x6A" | ||
14900 | "\x08\x3E\xBE\x59\xFB\xE4\x96\x34" | ||
14901 | "\xB4\x05\x49\x1A\x97\x43\xAD\xA0" | ||
14902 | "\xA9\x1E\x6E\x74\xF1\x94\xEC\xA8" | ||
14903 | "\xB5\x8A\x20\xEA\x89\x6B\x19\xAA" | ||
14904 | "\xA7\xF1\x33\x67\x90\x23\x0D\xEE" | ||
14905 | "\x81\xD5\x78\x4F\xD3\x63\xEA\x46" | ||
14906 | "\xB5\xB2\x6E\xBB\xCA\x76\x06\x10" | ||
14907 | "\x96\x2A\x0A\xBA\xF9\x41\x5A\x1D" | ||
14908 | "\x36\x7C\x56\x14\x54\x83\xFA\xA1" | ||
14909 | "\x27\xDD\xBA\x8A\x90\x29\xD6\xA6" | ||
14910 | "\xFA\x48\x3E\x1E\x23\x6E\x98\xA8" | ||
14911 | "\xA7\xD9\x67\x92\x5C\x13\xB4\x71" | ||
14912 | "\xA8\xAA\x89\x4A\xA4\xB3\x49\x7C" | ||
14913 | "\x7D\x7F\xCE\x6F\x29\x2E\x7E\x37" | ||
14914 | "\xC8\x52\x60\xD9\xE7\xCA\x60\x98" | ||
14915 | "\xED\xCD\xE8\x60\x83\xAD\x34\x4D" | ||
14916 | "\x96\x4A\x99\x2B\xB7\x14\x75\x66" | ||
14917 | "\x6C\x2C\x1A\xBA\x4B\xBB\x49\x56" | ||
14918 | "\xE1\x86\xA2\x0E\xD0\xF0\x07\xD3" | ||
14919 | "\x18\x38\x09\x9C\x0E\x8B\x86\x07" | ||
14920 | "\x90\x12\x37\x49\x27\x98\x69\x18" | ||
14921 | "\xB0\xCC\xFB\xD3\xBD\x04\xA0\x85" | ||
14922 | "\x4B\x22\x97\x07\xB6\x97\xE9\x95" | ||
14923 | "\x0F\x88\x36\xA9\x44\x00\xC6\xE9" | ||
14924 | "\x27\x53\x5C\x5B\x1F\xD3\xE2\xEE" | ||
14925 | "\xD0\xCD\x63\x30\xA9\xC0\xDD\x49" | ||
14926 | "\xFE\x16\xA4\x07\x0D\xE2\x5D\x97" | ||
14927 | "\xDE\x89\xBA\x2E\xF3\xA9\x5E\xBE" | ||
14928 | "\x03\x55\x0E\x02\x41\x4A\x45\x06" | ||
14929 | "\xBE\xEA\x32\xF2\xDC\x91\x5C\x20" | ||
14930 | "\x94\x02\x30\xD2\xFC\x29\xFA\x8E" | ||
14931 | "\x34\xA0\x31\xB8\x34\xBA\xAE\x54" | ||
14932 | "\xB5\x88\x1F\xDC\x43\xDC\x22\x9F" | ||
14933 | "\xDC\xCE\xD3\xFA\xA4\xA8\xBC\x8A" | ||
14934 | "\xC7\x5A\x43\x21\xA5\xB1\xDB\xC3" | ||
14935 | "\x84\x3B\xB4\x9B\xB5\xA7\xF1\x0A" | ||
14936 | "\xB6\x37\x21\x19\x55\xC2\xBD\x99" | ||
14937 | "\x49\x24\xBB\x7C\xB3\x8E\xEF\xD2" | ||
14938 | "\x3A\xCF\xA0\x31\x28\x0E\x25\xA2" | ||
14939 | "\x11\xB4\x18\x17\x1A\x65\x92\x56" | ||
14940 | "\xE8\xE0\x52\x9C\x61\x18\x2A\xB1" | ||
14941 | "\x1A\x01\x22\x45\x17\x62\x52\x6C" | ||
14942 | "\x91\x44\xCF\x98\xC7\xC0\x79\x26" | ||
14943 | "\x32\x66\x6F\x23\x7F\x94\x36\x88" | ||
14944 | "\x3C\xC9\xD0\xB7\x45\x30\x31\x86" | ||
14945 | "\x3D\xC6\xA3\x98\x62\x84\x1A\x8B" | ||
14946 | "\x16\x88\xC7\xA3\xE9\x4F\xE0\x86" | ||
14947 | "\xA4\x93\xA8\x34\x5A\xCA\xDF\xCA" | ||
14948 | "\x46\x38\xD2\xF4\xE0\x2D\x1E\xC9" | ||
14949 | "\x7C\xEF\x53\xB7\x60\x72\x41\xBF" | ||
14950 | "\x29\x00\x87\x02\xAF\x44\x4C\xB7" | ||
14951 | "\x8C\xF5\x3F\x19\xF4\x80\x45\xA7" | ||
14952 | "\x15\x5F\xDB\xE9\xB1\x83\xD2\xE6" | ||
14953 | "\x1D\x18\x66\x44\x5B\x8F\x14\xEB", | ||
14954 | .rlen = 496, | ||
14955 | .also_non_np = 1, | ||
14956 | .np = 2, | ||
14957 | .tap = { 496 - 16, 16 }, | ||
14958 | }, | ||
14959 | }; | ||
14960 | |||
14961 | static struct cipher_testvec cast5_cbc_dec_tv_template[] = { | ||
14962 | { /* Generated from TF test vectors */ | ||
14963 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
14964 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A", | ||
14965 | .klen = 16, | ||
14966 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F", | ||
14967 | .input = "\x05\x28\xCE\x61\x90\x80\xE1\x78" | ||
14968 | "\xB9\x2A\x97\x7C\xB0\x83\xD8\x1A" | ||
14969 | "\xDE\x58\x7F\xD7\xFD\x72\xB8\xFB" | ||
14970 | "\xDA\xF0\x6E\x77\x14\x47\x82\xBA" | ||
14971 | "\x29\x0E\x25\x6E\xB4\x39\xD9\x7F" | ||
14972 | "\x05\xA7\xA7\x3A\xC1\x5D\x9E\x39" | ||
14973 | "\xA7\xFB\x0D\x05\x00\xF3\x58\x67" | ||
14974 | "\x60\xEC\x73\x77\x46\x85\x9B\x6A" | ||
14975 | "\x08\x3E\xBE\x59\xFB\xE4\x96\x34" | ||
14976 | "\xB4\x05\x49\x1A\x97\x43\xAD\xA0" | ||
14977 | "\xA9\x1E\x6E\x74\xF1\x94\xEC\xA8" | ||
14978 | "\xB5\x8A\x20\xEA\x89\x6B\x19\xAA" | ||
14979 | "\xA7\xF1\x33\x67\x90\x23\x0D\xEE" | ||
14980 | "\x81\xD5\x78\x4F\xD3\x63\xEA\x46" | ||
14981 | "\xB5\xB2\x6E\xBB\xCA\x76\x06\x10" | ||
14982 | "\x96\x2A\x0A\xBA\xF9\x41\x5A\x1D" | ||
14983 | "\x36\x7C\x56\x14\x54\x83\xFA\xA1" | ||
14984 | "\x27\xDD\xBA\x8A\x90\x29\xD6\xA6" | ||
14985 | "\xFA\x48\x3E\x1E\x23\x6E\x98\xA8" | ||
14986 | "\xA7\xD9\x67\x92\x5C\x13\xB4\x71" | ||
14987 | "\xA8\xAA\x89\x4A\xA4\xB3\x49\x7C" | ||
14988 | "\x7D\x7F\xCE\x6F\x29\x2E\x7E\x37" | ||
14989 | "\xC8\x52\x60\xD9\xE7\xCA\x60\x98" | ||
14990 | "\xED\xCD\xE8\x60\x83\xAD\x34\x4D" | ||
14991 | "\x96\x4A\x99\x2B\xB7\x14\x75\x66" | ||
14992 | "\x6C\x2C\x1A\xBA\x4B\xBB\x49\x56" | ||
14993 | "\xE1\x86\xA2\x0E\xD0\xF0\x07\xD3" | ||
14994 | "\x18\x38\x09\x9C\x0E\x8B\x86\x07" | ||
14995 | "\x90\x12\x37\x49\x27\x98\x69\x18" | ||
14996 | "\xB0\xCC\xFB\xD3\xBD\x04\xA0\x85" | ||
14997 | "\x4B\x22\x97\x07\xB6\x97\xE9\x95" | ||
14998 | "\x0F\x88\x36\xA9\x44\x00\xC6\xE9" | ||
14999 | "\x27\x53\x5C\x5B\x1F\xD3\xE2\xEE" | ||
15000 | "\xD0\xCD\x63\x30\xA9\xC0\xDD\x49" | ||
15001 | "\xFE\x16\xA4\x07\x0D\xE2\x5D\x97" | ||
15002 | "\xDE\x89\xBA\x2E\xF3\xA9\x5E\xBE" | ||
15003 | "\x03\x55\x0E\x02\x41\x4A\x45\x06" | ||
15004 | "\xBE\xEA\x32\xF2\xDC\x91\x5C\x20" | ||
15005 | "\x94\x02\x30\xD2\xFC\x29\xFA\x8E" | ||
15006 | "\x34\xA0\x31\xB8\x34\xBA\xAE\x54" | ||
15007 | "\xB5\x88\x1F\xDC\x43\xDC\x22\x9F" | ||
15008 | "\xDC\xCE\xD3\xFA\xA4\xA8\xBC\x8A" | ||
15009 | "\xC7\x5A\x43\x21\xA5\xB1\xDB\xC3" | ||
15010 | "\x84\x3B\xB4\x9B\xB5\xA7\xF1\x0A" | ||
15011 | "\xB6\x37\x21\x19\x55\xC2\xBD\x99" | ||
15012 | "\x49\x24\xBB\x7C\xB3\x8E\xEF\xD2" | ||
15013 | "\x3A\xCF\xA0\x31\x28\x0E\x25\xA2" | ||
15014 | "\x11\xB4\x18\x17\x1A\x65\x92\x56" | ||
15015 | "\xE8\xE0\x52\x9C\x61\x18\x2A\xB1" | ||
15016 | "\x1A\x01\x22\x45\x17\x62\x52\x6C" | ||
15017 | "\x91\x44\xCF\x98\xC7\xC0\x79\x26" | ||
15018 | "\x32\x66\x6F\x23\x7F\x94\x36\x88" | ||
15019 | "\x3C\xC9\xD0\xB7\x45\x30\x31\x86" | ||
15020 | "\x3D\xC6\xA3\x98\x62\x84\x1A\x8B" | ||
15021 | "\x16\x88\xC7\xA3\xE9\x4F\xE0\x86" | ||
15022 | "\xA4\x93\xA8\x34\x5A\xCA\xDF\xCA" | ||
15023 | "\x46\x38\xD2\xF4\xE0\x2D\x1E\xC9" | ||
15024 | "\x7C\xEF\x53\xB7\x60\x72\x41\xBF" | ||
15025 | "\x29\x00\x87\x02\xAF\x44\x4C\xB7" | ||
15026 | "\x8C\xF5\x3F\x19\xF4\x80\x45\xA7" | ||
15027 | "\x15\x5F\xDB\xE9\xB1\x83\xD2\xE6" | ||
15028 | "\x1D\x18\x66\x44\x5B\x8F\x14\xEB", | ||
15029 | .ilen = 496, | ||
15030 | .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
15031 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
15032 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
15033 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
15034 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
15035 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
15036 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
15037 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" | ||
15038 | "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" | ||
15039 | "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" | ||
15040 | "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" | ||
15041 | "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" | ||
15042 | "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" | ||
15043 | "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" | ||
15044 | "\x29\xC0\x57\xEE\x62\xF9\x90\x04" | ||
15045 | "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" | ||
15046 | "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" | ||
15047 | "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" | ||
15048 | "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" | ||
15049 | "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" | ||
15050 | "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" | ||
15051 | "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" | ||
15052 | "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" | ||
15053 | "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" | ||
15054 | "\x57\xEE\x85\x1C\x90\x27\xBE\x32" | ||
15055 | "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" | ||
15056 | "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" | ||
15057 | "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" | ||
15058 | "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" | ||
15059 | "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" | ||
15060 | "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" | ||
15061 | "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" | ||
15062 | "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" | ||
15063 | "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" | ||
15064 | "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" | ||
15065 | "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" | ||
15066 | "\x69\x00\x74\x0B\xA2\x16\xAD\x44" | ||
15067 | "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" | ||
15068 | "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" | ||
15069 | "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" | ||
15070 | "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" | ||
15071 | "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" | ||
15072 | "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" | ||
15073 | "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" | ||
15074 | "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" | ||
15075 | "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" | ||
15076 | "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" | ||
15077 | "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" | ||
15078 | "\x58\xEF\x86\x1D\x91\x28\xBF\x33" | ||
15079 | "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" | ||
15080 | "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" | ||
15081 | "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" | ||
15082 | "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" | ||
15083 | "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" | ||
15084 | "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" | ||
15085 | "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" | ||
15086 | "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" | ||
15087 | "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" | ||
15088 | "\x86\x1D\xB4\x28\xBF\x56\xED\x61" | ||
15089 | "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" | ||
15090 | "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" | ||
15091 | "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", | ||
15092 | .rlen = 496, | ||
15093 | .also_non_np = 1, | ||
15094 | .np = 2, | ||
15095 | .tap = { 496 - 16, 16 }, | ||
15096 | }, | ||
15097 | }; | ||
15098 | |||
15099 | static struct cipher_testvec cast5_ctr_enc_tv_template[] = { | ||
15100 | { /* Generated from TF test vectors */ | ||
15101 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
15102 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A", | ||
15103 | .klen = 16, | ||
15104 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F", | ||
15105 | .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
15106 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
15107 | "\x3A", | ||
15108 | .ilen = 17, | ||
15109 | .result = "\xFF\xC4\x2E\x82\x3D\xF8\xA8\x39" | ||
15110 | "\x7C\x52\xC4\xD3\xBB\x62\xC6\xA8" | ||
15111 | "\x0C", | ||
15112 | .rlen = 17, | ||
15113 | }, { /* Generated from TF test vectors */ | ||
15114 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
15115 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A", | ||
15116 | .klen = 16, | ||
15117 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F", | ||
15118 | .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
15119 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
15120 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
15121 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
15122 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
15123 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
15124 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
15125 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" | ||
15126 | "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" | ||
15127 | "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" | ||
15128 | "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" | ||
15129 | "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" | ||
15130 | "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" | ||
15131 | "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" | ||
15132 | "\x29\xC0\x57\xEE\x62\xF9\x90\x04" | ||
15133 | "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" | ||
15134 | "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" | ||
15135 | "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" | ||
15136 | "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" | ||
15137 | "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" | ||
15138 | "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" | ||
15139 | "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" | ||
15140 | "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" | ||
15141 | "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" | ||
15142 | "\x57\xEE\x85\x1C\x90\x27\xBE\x32" | ||
15143 | "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" | ||
15144 | "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" | ||
15145 | "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" | ||
15146 | "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" | ||
15147 | "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" | ||
15148 | "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" | ||
15149 | "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" | ||
15150 | "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" | ||
15151 | "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" | ||
15152 | "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" | ||
15153 | "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" | ||
15154 | "\x69\x00\x74\x0B\xA2\x16\xAD\x44" | ||
15155 | "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" | ||
15156 | "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" | ||
15157 | "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" | ||
15158 | "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" | ||
15159 | "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" | ||
15160 | "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" | ||
15161 | "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" | ||
15162 | "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" | ||
15163 | "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" | ||
15164 | "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" | ||
15165 | "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" | ||
15166 | "\x58\xEF\x86\x1D\x91\x28\xBF\x33" | ||
15167 | "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" | ||
15168 | "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" | ||
15169 | "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" | ||
15170 | "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" | ||
15171 | "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" | ||
15172 | "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" | ||
15173 | "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" | ||
15174 | "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" | ||
15175 | "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" | ||
15176 | "\x86\x1D\xB4\x28\xBF\x56\xED\x61" | ||
15177 | "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" | ||
15178 | "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" | ||
15179 | "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", | ||
15180 | .ilen = 496, | ||
15181 | .result = "\xFF\xC4\x2E\x82\x3D\xF8\xA8\x39" | ||
15182 | "\x7C\x52\xC4\xD3\xBB\x62\xC6\xA8" | ||
15183 | "\x0C\x63\xA5\x55\xE3\xF8\x1C\x7F" | ||
15184 | "\xDC\x59\xF9\xA0\x52\xAD\x83\xDF" | ||
15185 | "\xD5\x3B\x53\x4A\xAA\x1F\x49\x44" | ||
15186 | "\xE8\x20\xCC\xF8\x97\xE6\xE0\x3C" | ||
15187 | "\x5A\xD2\x83\xEC\xEE\x25\x3F\xCF" | ||
15188 | "\x0D\xC2\x79\x80\x99\x6E\xFF\x7B" | ||
15189 | "\x64\xB0\x7B\x86\x29\x1D\x9F\x17" | ||
15190 | "\x10\xA5\xA5\xEB\x16\x55\x9E\xE3" | ||
15191 | "\x88\x18\x52\x56\x48\x58\xD1\x6B" | ||
15192 | "\xE8\x74\x6E\x48\xB0\x2E\x69\x63" | ||
15193 | "\x32\xAA\xAC\x26\x55\x45\x94\xDE" | ||
15194 | "\x30\x26\x26\xE6\x08\x82\x2F\x5F" | ||
15195 | "\xA7\x15\x94\x07\x75\x2D\xC6\x3A" | ||
15196 | "\x1B\xA0\x39\xFB\xBA\xB9\x06\x56" | ||
15197 | "\xF6\x9F\xF1\x2F\x9B\xF3\x89\x8B" | ||
15198 | "\x08\xC8\x9D\x5E\x6B\x95\x09\xC7" | ||
15199 | "\x98\xB7\x62\xA4\x1D\x25\xFA\xC5" | ||
15200 | "\x62\xC8\x5D\x6B\xB4\x85\x88\x7F" | ||
15201 | "\x3B\x29\xF9\xB4\x32\x62\x69\xBF" | ||
15202 | "\x32\xB8\xEB\xFD\x0E\x26\xAA\xA3" | ||
15203 | "\x44\x67\x90\x20\xAC\x41\xDF\x43" | ||
15204 | "\xC6\xC7\x19\x9F\x2C\x28\x74\xEB" | ||
15205 | "\x3E\x7F\x7A\x80\x5B\xE4\x08\x60" | ||
15206 | "\xC7\xC9\x71\x34\x44\xCE\x05\xFD" | ||
15207 | "\xA8\x91\xA8\x44\x5E\xD3\x89\x2C" | ||
15208 | "\xAE\x59\x0F\x07\x88\x79\x53\x26" | ||
15209 | "\xAF\xAC\xCB\x1D\x6F\x08\x25\x62" | ||
15210 | "\xD0\x82\x65\x66\xE4\x2A\x29\x1C" | ||
15211 | "\x9C\x64\x5F\x49\x9D\xF8\x62\xF9" | ||
15212 | "\xED\xC4\x13\x52\x75\xDC\xE4\xF9" | ||
15213 | "\x68\x0F\x8A\xCD\xA6\x8D\x75\xAA" | ||
15214 | "\x49\xA1\x86\x86\x37\x5C\x6B\x3D" | ||
15215 | "\x56\xE5\x6F\xBE\x27\xC0\x10\xF8" | ||
15216 | "\x3C\x4D\x17\x35\x14\xDC\x1C\xA0" | ||
15217 | "\x6E\xAE\xD1\x10\xDD\x83\x06\xC2" | ||
15218 | "\x23\xD3\xC7\x27\x15\x04\x2C\x27" | ||
15219 | "\xDD\x1F\x2E\x97\x09\x9C\x33\x7D" | ||
15220 | "\xAC\x50\x1B\x2E\xC9\x52\x0C\x14" | ||
15221 | "\x4B\x78\xC4\xDE\x07\x6A\x12\x02" | ||
15222 | "\x6E\xD7\x4B\x91\xB9\x88\x4D\x02" | ||
15223 | "\xC3\xB5\x04\xBC\xE0\x67\xCA\x18" | ||
15224 | "\x22\xA1\xAE\x9A\x21\xEF\xB2\x06" | ||
15225 | "\x35\xCD\xEC\x37\x70\x2D\xFC\x1E" | ||
15226 | "\xA8\x31\xE7\xFC\xE5\x8E\x88\x66" | ||
15227 | "\x16\xB5\xC8\x45\x21\x37\xBD\x24" | ||
15228 | "\xA9\xD5\x36\x12\x9F\x6E\x67\x80" | ||
15229 | "\x87\x54\xD5\xAF\x97\xE1\x15\xA7" | ||
15230 | "\x11\xF0\x63\x7B\xE1\x44\x14\x1C" | ||
15231 | "\x06\x32\x05\x8C\x6C\xDB\x9B\x36" | ||
15232 | "\x6A\x6B\xAD\x3A\x27\x55\x20\x4C" | ||
15233 | "\x76\x36\x43\xE8\x16\x60\xB5\xF3" | ||
15234 | "\xDF\x5A\xC6\xA5\x69\x78\x59\x51" | ||
15235 | "\x54\x68\x65\x06\x84\xDE\x3D\xAE" | ||
15236 | "\x38\x91\xBD\xCC\xA2\x8A\xEC\xE6" | ||
15237 | "\x9E\x83\xAE\x1E\x8E\x34\x5D\xDE" | ||
15238 | "\x91\xCE\x8F\xED\x40\xF7\xC8\x8B" | ||
15239 | "\x9A\x13\x4C\xAD\x89\x97\x9E\xD1" | ||
15240 | "\x91\x01\xD7\x21\x23\x28\x1E\xCC" | ||
15241 | "\x8C\x98\xDB\xDE\xFC\x72\x94\xAA" | ||
15242 | "\xC0\x0D\x96\xAA\x23\xF8\xFE\x13", | ||
15243 | .rlen = 496, | ||
15244 | .also_non_np = 1, | ||
15245 | .np = 2, | ||
15246 | .tap = { 496 - 16, 16 }, | ||
15247 | }, | ||
15248 | }; | ||
15249 | |||
15250 | static struct cipher_testvec cast5_ctr_dec_tv_template[] = { | ||
15251 | { /* Generated from TF test vectors */ | ||
15252 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
15253 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A", | ||
15254 | .klen = 16, | ||
15255 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F", | ||
15256 | .input = "\xFF\xC4\x2E\x82\x3D\xF8\xA8\x39" | ||
15257 | "\x7C\x52\xC4\xD3\xBB\x62\xC6\xA8" | ||
15258 | "\x0C", | ||
15259 | .ilen = 17, | ||
15260 | .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
15261 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
15262 | "\x3A", | ||
15263 | .rlen = 17, | ||
15264 | }, { /* Generated from TF test vectors */ | ||
15265 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
15266 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A", | ||
15267 | .klen = 16, | ||
15268 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F", | ||
15269 | .input = "\xFF\xC4\x2E\x82\x3D\xF8\xA8\x39" | ||
15270 | "\x7C\x52\xC4\xD3\xBB\x62\xC6\xA8" | ||
15271 | "\x0C\x63\xA5\x55\xE3\xF8\x1C\x7F" | ||
15272 | "\xDC\x59\xF9\xA0\x52\xAD\x83\xDF" | ||
15273 | "\xD5\x3B\x53\x4A\xAA\x1F\x49\x44" | ||
15274 | "\xE8\x20\xCC\xF8\x97\xE6\xE0\x3C" | ||
15275 | "\x5A\xD2\x83\xEC\xEE\x25\x3F\xCF" | ||
15276 | "\x0D\xC2\x79\x80\x99\x6E\xFF\x7B" | ||
15277 | "\x64\xB0\x7B\x86\x29\x1D\x9F\x17" | ||
15278 | "\x10\xA5\xA5\xEB\x16\x55\x9E\xE3" | ||
15279 | "\x88\x18\x52\x56\x48\x58\xD1\x6B" | ||
15280 | "\xE8\x74\x6E\x48\xB0\x2E\x69\x63" | ||
15281 | "\x32\xAA\xAC\x26\x55\x45\x94\xDE" | ||
15282 | "\x30\x26\x26\xE6\x08\x82\x2F\x5F" | ||
15283 | "\xA7\x15\x94\x07\x75\x2D\xC6\x3A" | ||
15284 | "\x1B\xA0\x39\xFB\xBA\xB9\x06\x56" | ||
15285 | "\xF6\x9F\xF1\x2F\x9B\xF3\x89\x8B" | ||
15286 | "\x08\xC8\x9D\x5E\x6B\x95\x09\xC7" | ||
15287 | "\x98\xB7\x62\xA4\x1D\x25\xFA\xC5" | ||
15288 | "\x62\xC8\x5D\x6B\xB4\x85\x88\x7F" | ||
15289 | "\x3B\x29\xF9\xB4\x32\x62\x69\xBF" | ||
15290 | "\x32\xB8\xEB\xFD\x0E\x26\xAA\xA3" | ||
15291 | "\x44\x67\x90\x20\xAC\x41\xDF\x43" | ||
15292 | "\xC6\xC7\x19\x9F\x2C\x28\x74\xEB" | ||
15293 | "\x3E\x7F\x7A\x80\x5B\xE4\x08\x60" | ||
15294 | "\xC7\xC9\x71\x34\x44\xCE\x05\xFD" | ||
15295 | "\xA8\x91\xA8\x44\x5E\xD3\x89\x2C" | ||
15296 | "\xAE\x59\x0F\x07\x88\x79\x53\x26" | ||
15297 | "\xAF\xAC\xCB\x1D\x6F\x08\x25\x62" | ||
15298 | "\xD0\x82\x65\x66\xE4\x2A\x29\x1C" | ||
15299 | "\x9C\x64\x5F\x49\x9D\xF8\x62\xF9" | ||
15300 | "\xED\xC4\x13\x52\x75\xDC\xE4\xF9" | ||
15301 | "\x68\x0F\x8A\xCD\xA6\x8D\x75\xAA" | ||
15302 | "\x49\xA1\x86\x86\x37\x5C\x6B\x3D" | ||
15303 | "\x56\xE5\x6F\xBE\x27\xC0\x10\xF8" | ||
15304 | "\x3C\x4D\x17\x35\x14\xDC\x1C\xA0" | ||
15305 | "\x6E\xAE\xD1\x10\xDD\x83\x06\xC2" | ||
15306 | "\x23\xD3\xC7\x27\x15\x04\x2C\x27" | ||
15307 | "\xDD\x1F\x2E\x97\x09\x9C\x33\x7D" | ||
15308 | "\xAC\x50\x1B\x2E\xC9\x52\x0C\x14" | ||
15309 | "\x4B\x78\xC4\xDE\x07\x6A\x12\x02" | ||
15310 | "\x6E\xD7\x4B\x91\xB9\x88\x4D\x02" | ||
15311 | "\xC3\xB5\x04\xBC\xE0\x67\xCA\x18" | ||
15312 | "\x22\xA1\xAE\x9A\x21\xEF\xB2\x06" | ||
15313 | "\x35\xCD\xEC\x37\x70\x2D\xFC\x1E" | ||
15314 | "\xA8\x31\xE7\xFC\xE5\x8E\x88\x66" | ||
15315 | "\x16\xB5\xC8\x45\x21\x37\xBD\x24" | ||
15316 | "\xA9\xD5\x36\x12\x9F\x6E\x67\x80" | ||
15317 | "\x87\x54\xD5\xAF\x97\xE1\x15\xA7" | ||
15318 | "\x11\xF0\x63\x7B\xE1\x44\x14\x1C" | ||
15319 | "\x06\x32\x05\x8C\x6C\xDB\x9B\x36" | ||
15320 | "\x6A\x6B\xAD\x3A\x27\x55\x20\x4C" | ||
15321 | "\x76\x36\x43\xE8\x16\x60\xB5\xF3" | ||
15322 | "\xDF\x5A\xC6\xA5\x69\x78\x59\x51" | ||
15323 | "\x54\x68\x65\x06\x84\xDE\x3D\xAE" | ||
15324 | "\x38\x91\xBD\xCC\xA2\x8A\xEC\xE6" | ||
15325 | "\x9E\x83\xAE\x1E\x8E\x34\x5D\xDE" | ||
15326 | "\x91\xCE\x8F\xED\x40\xF7\xC8\x8B" | ||
15327 | "\x9A\x13\x4C\xAD\x89\x97\x9E\xD1" | ||
15328 | "\x91\x01\xD7\x21\x23\x28\x1E\xCC" | ||
15329 | "\x8C\x98\xDB\xDE\xFC\x72\x94\xAA" | ||
15330 | "\xC0\x0D\x96\xAA\x23\xF8\xFE\x13", | ||
15331 | .ilen = 496, | ||
15332 | .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
15333 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
15334 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
15335 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
15336 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
15337 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
15338 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
15339 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" | ||
15340 | "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" | ||
15341 | "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" | ||
15342 | "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" | ||
15343 | "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" | ||
15344 | "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" | ||
15345 | "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" | ||
15346 | "\x29\xC0\x57\xEE\x62\xF9\x90\x04" | ||
15347 | "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" | ||
15348 | "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" | ||
15349 | "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" | ||
15350 | "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" | ||
15351 | "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" | ||
15352 | "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" | ||
15353 | "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" | ||
15354 | "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" | ||
15355 | "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" | ||
15356 | "\x57\xEE\x85\x1C\x90\x27\xBE\x32" | ||
15357 | "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" | ||
15358 | "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" | ||
15359 | "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" | ||
15360 | "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" | ||
15361 | "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" | ||
15362 | "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" | ||
15363 | "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" | ||
15364 | "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" | ||
15365 | "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" | ||
15366 | "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" | ||
15367 | "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" | ||
15368 | "\x69\x00\x74\x0B\xA2\x16\xAD\x44" | ||
15369 | "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" | ||
15370 | "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" | ||
15371 | "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" | ||
15372 | "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" | ||
15373 | "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" | ||
15374 | "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" | ||
15375 | "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" | ||
15376 | "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" | ||
15377 | "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" | ||
15378 | "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" | ||
15379 | "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" | ||
15380 | "\x58\xEF\x86\x1D\x91\x28\xBF\x33" | ||
15381 | "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" | ||
15382 | "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" | ||
15383 | "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" | ||
15384 | "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" | ||
15385 | "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" | ||
15386 | "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" | ||
15387 | "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" | ||
15388 | "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" | ||
15389 | "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" | ||
15390 | "\x86\x1D\xB4\x28\xBF\x56\xED\x61" | ||
15391 | "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" | ||
15392 | "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" | ||
15393 | "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", | ||
15394 | .rlen = 496, | ||
15395 | .also_non_np = 1, | ||
15396 | .np = 2, | ||
15397 | .tap = { 496 - 16, 16 }, | ||
12182 | }, | 15398 | }, |
12183 | }; | 15399 | }; |
12184 | 15400 | ||
@@ -13096,6 +16312,9 @@ static struct cipher_testvec camellia_enc_tv_template[] = { | |||
13096 | "\x0D\xD0\xFD\xC4\x65\xA5\x69\xB9" | 16312 | "\x0D\xD0\xFD\xC4\x65\xA5\x69\xB9" |
13097 | "\xF1\xF6\xB1\xA5\xB2\x75\x4F\x8A", | 16313 | "\xF1\xF6\xB1\xA5\xB2\x75\x4F\x8A", |
13098 | .rlen = 48, | 16314 | .rlen = 48, |
16315 | .also_non_np = 1, | ||
16316 | .np = 2, | ||
16317 | .tap = { 48 - 16, 16 }, | ||
13099 | }, | 16318 | }, |
13100 | }; | 16319 | }; |
13101 | 16320 | ||
@@ -13154,6 +16373,9 @@ static struct cipher_testvec camellia_dec_tv_template[] = { | |||
13154 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | 16373 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" |
13155 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48", | 16374 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48", |
13156 | .rlen = 48, | 16375 | .rlen = 48, |
16376 | .also_non_np = 1, | ||
16377 | .np = 2, | ||
16378 | .tap = { 48 - 16, 16 }, | ||
13157 | }, | 16379 | }, |
13158 | }; | 16380 | }; |
13159 | 16381 | ||
@@ -13208,6 +16430,9 @@ static struct cipher_testvec camellia_cbc_enc_tv_template[] = { | |||
13208 | "\xB9\xF9\xC2\x27\x6A\xB6\x31\x27" | 16430 | "\xB9\xF9\xC2\x27\x6A\xB6\x31\x27" |
13209 | "\xA6\xAD\xEF\xE5\x5D\xE4\x02\x01", | 16431 | "\xA6\xAD\xEF\xE5\x5D\xE4\x02\x01", |
13210 | .rlen = 48, | 16432 | .rlen = 48, |
16433 | .also_non_np = 1, | ||
16434 | .np = 2, | ||
16435 | .tap = { 48 - 16, 16 }, | ||
13211 | }, | 16436 | }, |
13212 | }; | 16437 | }; |
13213 | 16438 | ||
@@ -13262,6 +16487,9 @@ static struct cipher_testvec camellia_cbc_dec_tv_template[] = { | |||
13262 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | 16487 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" |
13263 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48", | 16488 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48", |
13264 | .rlen = 48, | 16489 | .rlen = 48, |
16490 | .also_non_np = 1, | ||
16491 | .np = 2, | ||
16492 | .tap = { 48 - 16, 16 }, | ||
13265 | }, | 16493 | }, |
13266 | }; | 16494 | }; |
13267 | 16495 | ||
@@ -13313,6 +16541,143 @@ static struct cipher_testvec camellia_ctr_enc_tv_template[] = { | |||
13313 | "\x60\xFC\xE8\x94\xE8\xB5\x09\x2C" | 16541 | "\x60\xFC\xE8\x94\xE8\xB5\x09\x2C" |
13314 | "\x1E\x43\xEF", | 16542 | "\x1E\x43\xEF", |
13315 | .rlen = 51, | 16543 | .rlen = 51, |
16544 | .also_non_np = 1, | ||
16545 | .np = 2, | ||
16546 | .tap = { 51 - 16, 16 }, | ||
16547 | }, { /* Generated with Crypto++ */ | ||
16548 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
16549 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
16550 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
16551 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
16552 | .klen = 32, | ||
16553 | .iv = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" | ||
16554 | "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFD", | ||
16555 | .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
16556 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
16557 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
16558 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
16559 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
16560 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
16561 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
16562 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" | ||
16563 | "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" | ||
16564 | "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" | ||
16565 | "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" | ||
16566 | "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" | ||
16567 | "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" | ||
16568 | "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" | ||
16569 | "\x29\xC0\x57\xEE\x62\xF9\x90\x04" | ||
16570 | "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" | ||
16571 | "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" | ||
16572 | "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" | ||
16573 | "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" | ||
16574 | "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" | ||
16575 | "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" | ||
16576 | "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" | ||
16577 | "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" | ||
16578 | "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" | ||
16579 | "\x57\xEE\x85\x1C\x90\x27\xBE\x32" | ||
16580 | "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" | ||
16581 | "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" | ||
16582 | "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" | ||
16583 | "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" | ||
16584 | "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" | ||
16585 | "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" | ||
16586 | "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" | ||
16587 | "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" | ||
16588 | "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" | ||
16589 | "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" | ||
16590 | "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" | ||
16591 | "\x69\x00\x74\x0B\xA2\x16\xAD\x44" | ||
16592 | "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" | ||
16593 | "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" | ||
16594 | "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" | ||
16595 | "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" | ||
16596 | "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" | ||
16597 | "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" | ||
16598 | "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" | ||
16599 | "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" | ||
16600 | "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" | ||
16601 | "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" | ||
16602 | "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" | ||
16603 | "\x58\xEF\x86\x1D\x91\x28\xBF\x33" | ||
16604 | "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" | ||
16605 | "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" | ||
16606 | "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" | ||
16607 | "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" | ||
16608 | "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" | ||
16609 | "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" | ||
16610 | "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" | ||
16611 | "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" | ||
16612 | "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" | ||
16613 | "\x86\x1D\xB4\x28\xBF\x56\xED\x61" | ||
16614 | "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" | ||
16615 | "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" | ||
16616 | "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", | ||
16617 | .ilen = 496, | ||
16618 | .result = "\x85\x79\x6C\x8B\x2B\x6D\x14\xF9" | ||
16619 | "\xA6\x83\xB6\x80\x5B\x3A\xF3\x7E" | ||
16620 | "\x30\x29\xEB\x1F\xDC\x19\x5F\xEB" | ||
16621 | "\xF7\xC4\x27\x04\x51\x87\xD7\x6F" | ||
16622 | "\xB8\x4E\x07\xFB\xAC\x3B\x08\xB4" | ||
16623 | "\x4D\xCB\xE8\xE1\x71\x7D\x4F\x48" | ||
16624 | "\xCD\x81\x64\xA5\xC4\x07\x1A\x9A" | ||
16625 | "\x4B\x62\x90\x0E\xC8\xB3\x2B\x6B" | ||
16626 | "\x8F\x9C\x6E\x72\x4B\xBA\xEF\x07" | ||
16627 | "\x2C\x56\x07\x5E\x37\x30\x60\xA9" | ||
16628 | "\xE3\xEF\xD6\x69\xE1\xA1\x77\x64" | ||
16629 | "\x93\x75\x7A\xB7\x7A\x3B\xE9\x43" | ||
16630 | "\x23\x35\x95\x91\x80\x8A\xC7\xCF" | ||
16631 | "\xC3\xD5\xBF\xE7\xFE\x4C\x06\x6B" | ||
16632 | "\x05\x19\x48\xE2\x62\xBA\x4F\xF2" | ||
16633 | "\xFB\xEE\xE4\xCB\x79\x9D\xA3\x10" | ||
16634 | "\x1D\x29\x8C\x1D\x7A\x88\x5A\xDD" | ||
16635 | "\x4E\xB6\x18\xAA\xCD\xE6\x33\x96" | ||
16636 | "\xD9\x0F\x90\x5A\x78\x76\x4D\x77" | ||
16637 | "\x3C\x20\x89\x3B\xA3\xF9\x07\xFD" | ||
16638 | "\xE4\xE8\x20\x2D\x15\x0A\x63\x49" | ||
16639 | "\xF5\x4F\x89\xD8\xDE\xA1\x28\x78" | ||
16640 | "\x28\x07\x09\x1B\x03\x94\x1D\x4B" | ||
16641 | "\x82\x28\x1E\x1D\x95\xBA\xAC\x85" | ||
16642 | "\x71\x6E\x3C\x18\x4B\x77\x74\x79" | ||
16643 | "\xBF\x67\x0A\x53\x3C\x94\xD9\x60" | ||
16644 | "\xE9\x6D\x40\x34\xA0\x2A\x53\x5D" | ||
16645 | "\x27\xD5\x47\xF9\xC3\x4B\x27\x29" | ||
16646 | "\xE4\x76\x9C\x3F\xA7\x1C\x87\xFC" | ||
16647 | "\x6E\x0F\xCF\x9B\x60\xF0\xF0\x8B" | ||
16648 | "\x70\x1C\x84\x81\x72\x4D\xB4\x98" | ||
16649 | "\x23\x62\xE7\x6A\x2B\xFC\xA5\xB2" | ||
16650 | "\xFF\xF5\x71\x07\xCD\x90\x23\x13" | ||
16651 | "\x19\xD7\x79\x36\x6C\x9D\x55\x8B" | ||
16652 | "\x93\x78\x86\x05\x69\x46\xD0\xC5" | ||
16653 | "\x39\x09\xEB\x79\xEF\xFA\x9F\xAE" | ||
16654 | "\xF3\xD5\x44\xC3\xFD\x86\xD2\x7C" | ||
16655 | "\x83\x4B\xD8\x75\x9C\x18\x04\x7B" | ||
16656 | "\x73\xAD\x72\xA4\xF6\xAB\xCF\x4B" | ||
16657 | "\xCC\x01\x45\x90\xA6\x43\x05\x0C" | ||
16658 | "\x6C\x4F\x62\x77\x57\x97\x9F\xEE" | ||
16659 | "\x75\xA7\x3C\x38\xD1\x0F\x3D\x0E" | ||
16660 | "\x2C\x43\x98\xFB\x13\x65\x73\xE4" | ||
16661 | "\x3C\x1E\xD6\x90\x08\xF7\xE0\x99" | ||
16662 | "\x3B\xF1\x9D\x6C\x48\xA9\x0E\x32" | ||
16663 | "\x17\xC2\xCC\x20\xA1\x19\x26\xAA" | ||
16664 | "\xE0\x75\x2F\xFB\x54\x66\x0A\xDF" | ||
16665 | "\xB5\xF2\x1F\xC1\x34\x3C\x30\x56" | ||
16666 | "\xE8\xDC\xF7\x92\x6B\xBF\x17\x24" | ||
16667 | "\xEC\x94\xB5\x3B\xD6\xCE\xA2\x54" | ||
16668 | "\x10\x7F\x50\xDE\x69\x77\xD5\x37" | ||
16669 | "\xFE\x9C\x10\x83\xC5\xEB\xC9\x53" | ||
16670 | "\xB7\xF3\xC4\x20\xAF\x0A\x7E\x57" | ||
16671 | "\x3A\xE6\x75\xFE\x89\x00\x6E\x48" | ||
16672 | "\xFB\x99\x17\x2C\xF6\x64\x40\x95" | ||
16673 | "\x5E\xDC\x7A\xA6\x70\xC7\xF4\xDD" | ||
16674 | "\x52\x05\x24\x34\xF9\x0E\xC8\x64" | ||
16675 | "\x6D\xE2\xD8\x80\x53\x31\x4C\xFE" | ||
16676 | "\xB4\x3A\x5F\x19\xCF\x42\x1B\x22" | ||
16677 | "\x0B\x2D\x7B\xF1\xC5\x43\xF7\x5E" | ||
16678 | "\x12\xA8\x01\x64\x16\x0B\x26\x5A" | ||
16679 | "\x0C\x95\x0F\x40\xC5\x5A\x06\x7C", | ||
16680 | .rlen = 496, | ||
13316 | }, | 16681 | }, |
13317 | }; | 16682 | }; |
13318 | 16683 | ||
@@ -13364,8 +16729,144 @@ static struct cipher_testvec camellia_ctr_dec_tv_template[] = { | |||
13364 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | 16729 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" |
13365 | "\xDF\x76\x0D", | 16730 | "\xDF\x76\x0D", |
13366 | .rlen = 51, | 16731 | .rlen = 51, |
16732 | .also_non_np = 1, | ||
16733 | .np = 2, | ||
16734 | .tap = { 51 - 16, 16 }, | ||
16735 | }, { /* Generated with Crypto++ */ | ||
16736 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
16737 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
16738 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
16739 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
16740 | .klen = 32, | ||
16741 | .iv = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" | ||
16742 | "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFD", | ||
16743 | .input = "\x85\x79\x6C\x8B\x2B\x6D\x14\xF9" | ||
16744 | "\xA6\x83\xB6\x80\x5B\x3A\xF3\x7E" | ||
16745 | "\x30\x29\xEB\x1F\xDC\x19\x5F\xEB" | ||
16746 | "\xF7\xC4\x27\x04\x51\x87\xD7\x6F" | ||
16747 | "\xB8\x4E\x07\xFB\xAC\x3B\x08\xB4" | ||
16748 | "\x4D\xCB\xE8\xE1\x71\x7D\x4F\x48" | ||
16749 | "\xCD\x81\x64\xA5\xC4\x07\x1A\x9A" | ||
16750 | "\x4B\x62\x90\x0E\xC8\xB3\x2B\x6B" | ||
16751 | "\x8F\x9C\x6E\x72\x4B\xBA\xEF\x07" | ||
16752 | "\x2C\x56\x07\x5E\x37\x30\x60\xA9" | ||
16753 | "\xE3\xEF\xD6\x69\xE1\xA1\x77\x64" | ||
16754 | "\x93\x75\x7A\xB7\x7A\x3B\xE9\x43" | ||
16755 | "\x23\x35\x95\x91\x80\x8A\xC7\xCF" | ||
16756 | "\xC3\xD5\xBF\xE7\xFE\x4C\x06\x6B" | ||
16757 | "\x05\x19\x48\xE2\x62\xBA\x4F\xF2" | ||
16758 | "\xFB\xEE\xE4\xCB\x79\x9D\xA3\x10" | ||
16759 | "\x1D\x29\x8C\x1D\x7A\x88\x5A\xDD" | ||
16760 | "\x4E\xB6\x18\xAA\xCD\xE6\x33\x96" | ||
16761 | "\xD9\x0F\x90\x5A\x78\x76\x4D\x77" | ||
16762 | "\x3C\x20\x89\x3B\xA3\xF9\x07\xFD" | ||
16763 | "\xE4\xE8\x20\x2D\x15\x0A\x63\x49" | ||
16764 | "\xF5\x4F\x89\xD8\xDE\xA1\x28\x78" | ||
16765 | "\x28\x07\x09\x1B\x03\x94\x1D\x4B" | ||
16766 | "\x82\x28\x1E\x1D\x95\xBA\xAC\x85" | ||
16767 | "\x71\x6E\x3C\x18\x4B\x77\x74\x79" | ||
16768 | "\xBF\x67\x0A\x53\x3C\x94\xD9\x60" | ||
16769 | "\xE9\x6D\x40\x34\xA0\x2A\x53\x5D" | ||
16770 | "\x27\xD5\x47\xF9\xC3\x4B\x27\x29" | ||
16771 | "\xE4\x76\x9C\x3F\xA7\x1C\x87\xFC" | ||
16772 | "\x6E\x0F\xCF\x9B\x60\xF0\xF0\x8B" | ||
16773 | "\x70\x1C\x84\x81\x72\x4D\xB4\x98" | ||
16774 | "\x23\x62\xE7\x6A\x2B\xFC\xA5\xB2" | ||
16775 | "\xFF\xF5\x71\x07\xCD\x90\x23\x13" | ||
16776 | "\x19\xD7\x79\x36\x6C\x9D\x55\x8B" | ||
16777 | "\x93\x78\x86\x05\x69\x46\xD0\xC5" | ||
16778 | "\x39\x09\xEB\x79\xEF\xFA\x9F\xAE" | ||
16779 | "\xF3\xD5\x44\xC3\xFD\x86\xD2\x7C" | ||
16780 | "\x83\x4B\xD8\x75\x9C\x18\x04\x7B" | ||
16781 | "\x73\xAD\x72\xA4\xF6\xAB\xCF\x4B" | ||
16782 | "\xCC\x01\x45\x90\xA6\x43\x05\x0C" | ||
16783 | "\x6C\x4F\x62\x77\x57\x97\x9F\xEE" | ||
16784 | "\x75\xA7\x3C\x38\xD1\x0F\x3D\x0E" | ||
16785 | "\x2C\x43\x98\xFB\x13\x65\x73\xE4" | ||
16786 | "\x3C\x1E\xD6\x90\x08\xF7\xE0\x99" | ||
16787 | "\x3B\xF1\x9D\x6C\x48\xA9\x0E\x32" | ||
16788 | "\x17\xC2\xCC\x20\xA1\x19\x26\xAA" | ||
16789 | "\xE0\x75\x2F\xFB\x54\x66\x0A\xDF" | ||
16790 | "\xB5\xF2\x1F\xC1\x34\x3C\x30\x56" | ||
16791 | "\xE8\xDC\xF7\x92\x6B\xBF\x17\x24" | ||
16792 | "\xEC\x94\xB5\x3B\xD6\xCE\xA2\x54" | ||
16793 | "\x10\x7F\x50\xDE\x69\x77\xD5\x37" | ||
16794 | "\xFE\x9C\x10\x83\xC5\xEB\xC9\x53" | ||
16795 | "\xB7\xF3\xC4\x20\xAF\x0A\x7E\x57" | ||
16796 | "\x3A\xE6\x75\xFE\x89\x00\x6E\x48" | ||
16797 | "\xFB\x99\x17\x2C\xF6\x64\x40\x95" | ||
16798 | "\x5E\xDC\x7A\xA6\x70\xC7\xF4\xDD" | ||
16799 | "\x52\x05\x24\x34\xF9\x0E\xC8\x64" | ||
16800 | "\x6D\xE2\xD8\x80\x53\x31\x4C\xFE" | ||
16801 | "\xB4\x3A\x5F\x19\xCF\x42\x1B\x22" | ||
16802 | "\x0B\x2D\x7B\xF1\xC5\x43\xF7\x5E" | ||
16803 | "\x12\xA8\x01\x64\x16\x0B\x26\x5A" | ||
16804 | "\x0C\x95\x0F\x40\xC5\x5A\x06\x7C", | ||
16805 | .ilen = 496, | ||
16806 | .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
16807 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
16808 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
16809 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
16810 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
16811 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
16812 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
16813 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" | ||
16814 | "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" | ||
16815 | "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" | ||
16816 | "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" | ||
16817 | "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" | ||
16818 | "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" | ||
16819 | "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" | ||
16820 | "\x29\xC0\x57\xEE\x62\xF9\x90\x04" | ||
16821 | "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" | ||
16822 | "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" | ||
16823 | "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" | ||
16824 | "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" | ||
16825 | "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" | ||
16826 | "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" | ||
16827 | "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" | ||
16828 | "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" | ||
16829 | "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" | ||
16830 | "\x57\xEE\x85\x1C\x90\x27\xBE\x32" | ||
16831 | "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" | ||
16832 | "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" | ||
16833 | "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" | ||
16834 | "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" | ||
16835 | "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" | ||
16836 | "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" | ||
16837 | "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" | ||
16838 | "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" | ||
16839 | "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" | ||
16840 | "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" | ||
16841 | "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" | ||
16842 | "\x69\x00\x74\x0B\xA2\x16\xAD\x44" | ||
16843 | "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" | ||
16844 | "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" | ||
16845 | "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" | ||
16846 | "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" | ||
16847 | "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" | ||
16848 | "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" | ||
16849 | "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" | ||
16850 | "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" | ||
16851 | "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" | ||
16852 | "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" | ||
16853 | "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" | ||
16854 | "\x58\xEF\x86\x1D\x91\x28\xBF\x33" | ||
16855 | "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" | ||
16856 | "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" | ||
16857 | "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" | ||
16858 | "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" | ||
16859 | "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" | ||
16860 | "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" | ||
16861 | "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" | ||
16862 | "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" | ||
16863 | "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" | ||
16864 | "\x86\x1D\xB4\x28\xBF\x56\xED\x61" | ||
16865 | "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" | ||
16866 | "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" | ||
16867 | "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", | ||
16868 | .rlen = 496, | ||
13367 | }, | 16869 | }, |
13368 | |||
13369 | }; | 16870 | }; |
13370 | 16871 | ||
13371 | static struct cipher_testvec camellia_lrw_enc_tv_template[] = { | 16872 | static struct cipher_testvec camellia_lrw_enc_tv_template[] = { |
@@ -13614,6 +17115,9 @@ static struct cipher_testvec camellia_lrw_enc_tv_template[] = { | |||
13614 | "\xb2\x1a\xd8\x4c\xbd\x1d\x10\xe9" | 17115 | "\xb2\x1a\xd8\x4c\xbd\x1d\x10\xe9" |
13615 | "\x5a\xa8\x92\x7f\xba\xe6\x0c\x95", | 17116 | "\x5a\xa8\x92\x7f\xba\xe6\x0c\x95", |
13616 | .rlen = 512, | 17117 | .rlen = 512, |
17118 | .also_non_np = 1, | ||
17119 | .np = 2, | ||
17120 | .tap = { 512 - 16, 16 }, | ||
13617 | }, | 17121 | }, |
13618 | }; | 17122 | }; |
13619 | 17123 | ||
@@ -13864,6 +17368,9 @@ static struct cipher_testvec camellia_lrw_dec_tv_template[] = { | |||
13864 | "\xe9\x2e\xc4\x29\x0f\x84\xdb\xc4" | 17368 | "\xe9\x2e\xc4\x29\x0f\x84\xdb\xc4" |
13865 | "\x21\xc4\xc2\x75\x67\x89\x37\x0a", | 17369 | "\x21\xc4\xc2\x75\x67\x89\x37\x0a", |
13866 | .rlen = 512, | 17370 | .rlen = 512, |
17371 | .also_non_np = 1, | ||
17372 | .np = 2, | ||
17373 | .tap = { 512 - 16, 16 }, | ||
13867 | }, | 17374 | }, |
13868 | }; | 17375 | }; |
13869 | 17376 | ||
@@ -14203,6 +17710,9 @@ static struct cipher_testvec camellia_xts_enc_tv_template[] = { | |||
14203 | "\xb7\x16\xd8\x12\x5c\xcd\x7d\x4e" | 17710 | "\xb7\x16\xd8\x12\x5c\xcd\x7d\x4e" |
14204 | "\xd5\xc6\x99\xcc\x4e\x6c\x94\x95", | 17711 | "\xd5\xc6\x99\xcc\x4e\x6c\x94\x95", |
14205 | .rlen = 512, | 17712 | .rlen = 512, |
17713 | .also_non_np = 1, | ||
17714 | .np = 2, | ||
17715 | .tap = { 512 - 16, 16 }, | ||
14206 | }, | 17716 | }, |
14207 | }; | 17717 | }; |
14208 | 17718 | ||
@@ -14543,6 +18053,9 @@ static struct cipher_testvec camellia_xts_dec_tv_template[] = { | |||
14543 | "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7" | 18053 | "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7" |
14544 | "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", | 18054 | "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", |
14545 | .rlen = 512, | 18055 | .rlen = 512, |
18056 | .also_non_np = 1, | ||
18057 | .np = 2, | ||
18058 | .tap = { 512 - 16, 16 }, | ||
14546 | }, | 18059 | }, |
14547 | }; | 18060 | }; |
14548 | 18061 | ||
diff --git a/crypto/tgr192.c b/crypto/tgr192.c index cbca4f208c9f..87403556fd0b 100644 --- a/crypto/tgr192.c +++ b/crypto/tgr192.c | |||
@@ -628,7 +628,7 @@ static int tgr128_final(struct shash_desc *desc, u8 * out) | |||
628 | return 0; | 628 | return 0; |
629 | } | 629 | } |
630 | 630 | ||
631 | static struct shash_alg tgr192 = { | 631 | static struct shash_alg tgr_algs[3] = { { |
632 | .digestsize = TGR192_DIGEST_SIZE, | 632 | .digestsize = TGR192_DIGEST_SIZE, |
633 | .init = tgr192_init, | 633 | .init = tgr192_init, |
634 | .update = tgr192_update, | 634 | .update = tgr192_update, |
@@ -640,9 +640,7 @@ static struct shash_alg tgr192 = { | |||
640 | .cra_blocksize = TGR192_BLOCK_SIZE, | 640 | .cra_blocksize = TGR192_BLOCK_SIZE, |
641 | .cra_module = THIS_MODULE, | 641 | .cra_module = THIS_MODULE, |
642 | } | 642 | } |
643 | }; | 643 | }, { |
644 | |||
645 | static struct shash_alg tgr160 = { | ||
646 | .digestsize = TGR160_DIGEST_SIZE, | 644 | .digestsize = TGR160_DIGEST_SIZE, |
647 | .init = tgr192_init, | 645 | .init = tgr192_init, |
648 | .update = tgr192_update, | 646 | .update = tgr192_update, |
@@ -654,9 +652,7 @@ static struct shash_alg tgr160 = { | |||
654 | .cra_blocksize = TGR192_BLOCK_SIZE, | 652 | .cra_blocksize = TGR192_BLOCK_SIZE, |
655 | .cra_module = THIS_MODULE, | 653 | .cra_module = THIS_MODULE, |
656 | } | 654 | } |
657 | }; | 655 | }, { |
658 | |||
659 | static struct shash_alg tgr128 = { | ||
660 | .digestsize = TGR128_DIGEST_SIZE, | 656 | .digestsize = TGR128_DIGEST_SIZE, |
661 | .init = tgr192_init, | 657 | .init = tgr192_init, |
662 | .update = tgr192_update, | 658 | .update = tgr192_update, |
@@ -668,38 +664,16 @@ static struct shash_alg tgr128 = { | |||
668 | .cra_blocksize = TGR192_BLOCK_SIZE, | 664 | .cra_blocksize = TGR192_BLOCK_SIZE, |
669 | .cra_module = THIS_MODULE, | 665 | .cra_module = THIS_MODULE, |
670 | } | 666 | } |
671 | }; | 667 | } }; |
672 | 668 | ||
673 | static int __init tgr192_mod_init(void) | 669 | static int __init tgr192_mod_init(void) |
674 | { | 670 | { |
675 | int ret = 0; | 671 | return crypto_register_shashes(tgr_algs, ARRAY_SIZE(tgr_algs)); |
676 | |||
677 | ret = crypto_register_shash(&tgr192); | ||
678 | |||
679 | if (ret < 0) { | ||
680 | goto out; | ||
681 | } | ||
682 | |||
683 | ret = crypto_register_shash(&tgr160); | ||
684 | if (ret < 0) { | ||
685 | crypto_unregister_shash(&tgr192); | ||
686 | goto out; | ||
687 | } | ||
688 | |||
689 | ret = crypto_register_shash(&tgr128); | ||
690 | if (ret < 0) { | ||
691 | crypto_unregister_shash(&tgr192); | ||
692 | crypto_unregister_shash(&tgr160); | ||
693 | } | ||
694 | out: | ||
695 | return ret; | ||
696 | } | 672 | } |
697 | 673 | ||
698 | static void __exit tgr192_mod_fini(void) | 674 | static void __exit tgr192_mod_fini(void) |
699 | { | 675 | { |
700 | crypto_unregister_shash(&tgr192); | 676 | crypto_unregister_shashes(tgr_algs, ARRAY_SIZE(tgr_algs)); |
701 | crypto_unregister_shash(&tgr160); | ||
702 | crypto_unregister_shash(&tgr128); | ||
703 | } | 677 | } |
704 | 678 | ||
705 | MODULE_ALIAS("tgr160"); | 679 | MODULE_ALIAS("tgr160"); |
diff --git a/crypto/twofish_generic.c b/crypto/twofish_generic.c index 1f07b843e07c..2d5000552d0f 100644 --- a/crypto/twofish_generic.c +++ b/crypto/twofish_generic.c | |||
@@ -188,7 +188,6 @@ static struct crypto_alg alg = { | |||
188 | .cra_ctxsize = sizeof(struct twofish_ctx), | 188 | .cra_ctxsize = sizeof(struct twofish_ctx), |
189 | .cra_alignmask = 3, | 189 | .cra_alignmask = 3, |
190 | .cra_module = THIS_MODULE, | 190 | .cra_module = THIS_MODULE, |
191 | .cra_list = LIST_HEAD_INIT(alg.cra_list), | ||
192 | .cra_u = { .cipher = { | 191 | .cra_u = { .cipher = { |
193 | .cia_min_keysize = TF_MIN_KEY_SIZE, | 192 | .cia_min_keysize = TF_MIN_KEY_SIZE, |
194 | .cia_max_keysize = TF_MAX_KEY_SIZE, | 193 | .cia_max_keysize = TF_MAX_KEY_SIZE, |
diff --git a/crypto/vmac.c b/crypto/vmac.c index 4243905ba135..f2338ca98368 100644 --- a/crypto/vmac.c +++ b/crypto/vmac.c | |||
@@ -38,11 +38,11 @@ | |||
38 | * Constants and masks | 38 | * Constants and masks |
39 | */ | 39 | */ |
40 | #define UINT64_C(x) x##ULL | 40 | #define UINT64_C(x) x##ULL |
41 | const u64 p64 = UINT64_C(0xfffffffffffffeff); /* 2^64 - 257 prime */ | 41 | static const u64 p64 = UINT64_C(0xfffffffffffffeff); /* 2^64 - 257 prime */ |
42 | const u64 m62 = UINT64_C(0x3fffffffffffffff); /* 62-bit mask */ | 42 | static const u64 m62 = UINT64_C(0x3fffffffffffffff); /* 62-bit mask */ |
43 | const u64 m63 = UINT64_C(0x7fffffffffffffff); /* 63-bit mask */ | 43 | static const u64 m63 = UINT64_C(0x7fffffffffffffff); /* 63-bit mask */ |
44 | const u64 m64 = UINT64_C(0xffffffffffffffff); /* 64-bit mask */ | 44 | static const u64 m64 = UINT64_C(0xffffffffffffffff); /* 64-bit mask */ |
45 | const u64 mpoly = UINT64_C(0x1fffffff1fffffff); /* Poly key mask */ | 45 | static const u64 mpoly = UINT64_C(0x1fffffff1fffffff); /* Poly key mask */ |
46 | 46 | ||
47 | #define pe64_to_cpup le64_to_cpup /* Prefer little endian */ | 47 | #define pe64_to_cpup le64_to_cpup /* Prefer little endian */ |
48 | 48 | ||
diff --git a/crypto/wp512.c b/crypto/wp512.c index 71719a2be25a..180f1d6e03f4 100644 --- a/crypto/wp512.c +++ b/crypto/wp512.c | |||
@@ -1119,7 +1119,7 @@ static int wp256_final(struct shash_desc *desc, u8 *out) | |||
1119 | return 0; | 1119 | return 0; |
1120 | } | 1120 | } |
1121 | 1121 | ||
1122 | static struct shash_alg wp512 = { | 1122 | static struct shash_alg wp_algs[3] = { { |
1123 | .digestsize = WP512_DIGEST_SIZE, | 1123 | .digestsize = WP512_DIGEST_SIZE, |
1124 | .init = wp512_init, | 1124 | .init = wp512_init, |
1125 | .update = wp512_update, | 1125 | .update = wp512_update, |
@@ -1131,9 +1131,7 @@ static struct shash_alg wp512 = { | |||
1131 | .cra_blocksize = WP512_BLOCK_SIZE, | 1131 | .cra_blocksize = WP512_BLOCK_SIZE, |
1132 | .cra_module = THIS_MODULE, | 1132 | .cra_module = THIS_MODULE, |
1133 | } | 1133 | } |
1134 | }; | 1134 | }, { |
1135 | |||
1136 | static struct shash_alg wp384 = { | ||
1137 | .digestsize = WP384_DIGEST_SIZE, | 1135 | .digestsize = WP384_DIGEST_SIZE, |
1138 | .init = wp512_init, | 1136 | .init = wp512_init, |
1139 | .update = wp512_update, | 1137 | .update = wp512_update, |
@@ -1145,9 +1143,7 @@ static struct shash_alg wp384 = { | |||
1145 | .cra_blocksize = WP512_BLOCK_SIZE, | 1143 | .cra_blocksize = WP512_BLOCK_SIZE, |
1146 | .cra_module = THIS_MODULE, | 1144 | .cra_module = THIS_MODULE, |
1147 | } | 1145 | } |
1148 | }; | 1146 | }, { |
1149 | |||
1150 | static struct shash_alg wp256 = { | ||
1151 | .digestsize = WP256_DIGEST_SIZE, | 1147 | .digestsize = WP256_DIGEST_SIZE, |
1152 | .init = wp512_init, | 1148 | .init = wp512_init, |
1153 | .update = wp512_update, | 1149 | .update = wp512_update, |
@@ -1159,39 +1155,16 @@ static struct shash_alg wp256 = { | |||
1159 | .cra_blocksize = WP512_BLOCK_SIZE, | 1155 | .cra_blocksize = WP512_BLOCK_SIZE, |
1160 | .cra_module = THIS_MODULE, | 1156 | .cra_module = THIS_MODULE, |
1161 | } | 1157 | } |
1162 | }; | 1158 | } }; |
1163 | 1159 | ||
1164 | static int __init wp512_mod_init(void) | 1160 | static int __init wp512_mod_init(void) |
1165 | { | 1161 | { |
1166 | int ret = 0; | 1162 | return crypto_register_shashes(wp_algs, ARRAY_SIZE(wp_algs)); |
1167 | |||
1168 | ret = crypto_register_shash(&wp512); | ||
1169 | |||
1170 | if (ret < 0) | ||
1171 | goto out; | ||
1172 | |||
1173 | ret = crypto_register_shash(&wp384); | ||
1174 | if (ret < 0) | ||
1175 | { | ||
1176 | crypto_unregister_shash(&wp512); | ||
1177 | goto out; | ||
1178 | } | ||
1179 | |||
1180 | ret = crypto_register_shash(&wp256); | ||
1181 | if (ret < 0) | ||
1182 | { | ||
1183 | crypto_unregister_shash(&wp512); | ||
1184 | crypto_unregister_shash(&wp384); | ||
1185 | } | ||
1186 | out: | ||
1187 | return ret; | ||
1188 | } | 1163 | } |
1189 | 1164 | ||
1190 | static void __exit wp512_mod_fini(void) | 1165 | static void __exit wp512_mod_fini(void) |
1191 | { | 1166 | { |
1192 | crypto_unregister_shash(&wp512); | 1167 | crypto_unregister_shashes(wp_algs, ARRAY_SIZE(wp_algs)); |
1193 | crypto_unregister_shash(&wp384); | ||
1194 | crypto_unregister_shash(&wp256); | ||
1195 | } | 1168 | } |
1196 | 1169 | ||
1197 | MODULE_ALIAS("wp384"); | 1170 | MODULE_ALIAS("wp384"); |
diff --git a/drivers/char/hw_random/mxc-rnga.c b/drivers/char/hw_random/mxc-rnga.c index 85074de5042e..f05d85713fd3 100644 --- a/drivers/char/hw_random/mxc-rnga.c +++ b/drivers/char/hw_random/mxc-rnga.c | |||
@@ -59,16 +59,21 @@ | |||
59 | #define RNGA_STATUS_LAST_READ_STATUS 0x00000002 | 59 | #define RNGA_STATUS_LAST_READ_STATUS 0x00000002 |
60 | #define RNGA_STATUS_SECURITY_VIOLATION 0x00000001 | 60 | #define RNGA_STATUS_SECURITY_VIOLATION 0x00000001 |
61 | 61 | ||
62 | static struct platform_device *rng_dev; | 62 | struct mxc_rng { |
63 | struct device *dev; | ||
64 | struct hwrng rng; | ||
65 | void __iomem *mem; | ||
66 | struct clk *clk; | ||
67 | }; | ||
63 | 68 | ||
64 | static int mxc_rnga_data_present(struct hwrng *rng, int wait) | 69 | static int mxc_rnga_data_present(struct hwrng *rng, int wait) |
65 | { | 70 | { |
66 | void __iomem *rng_base = (void __iomem *)rng->priv; | ||
67 | int i; | 71 | int i; |
72 | struct mxc_rng *mxc_rng = container_of(rng, struct mxc_rng, rng); | ||
68 | 73 | ||
69 | for (i = 0; i < 20; i++) { | 74 | for (i = 0; i < 20; i++) { |
70 | /* how many random numbers are in FIFO? [0-16] */ | 75 | /* how many random numbers are in FIFO? [0-16] */ |
71 | int level = (__raw_readl(rng_base + RNGA_STATUS) & | 76 | int level = (__raw_readl(mxc_rng->mem + RNGA_STATUS) & |
72 | RNGA_STATUS_LEVEL_MASK) >> 8; | 77 | RNGA_STATUS_LEVEL_MASK) >> 8; |
73 | if (level || !wait) | 78 | if (level || !wait) |
74 | return !!level; | 79 | return !!level; |
@@ -81,20 +86,20 @@ static int mxc_rnga_data_read(struct hwrng *rng, u32 * data) | |||
81 | { | 86 | { |
82 | int err; | 87 | int err; |
83 | u32 ctrl; | 88 | u32 ctrl; |
84 | void __iomem *rng_base = (void __iomem *)rng->priv; | 89 | struct mxc_rng *mxc_rng = container_of(rng, struct mxc_rng, rng); |
85 | 90 | ||
86 | /* retrieve a random number from FIFO */ | 91 | /* retrieve a random number from FIFO */ |
87 | *data = __raw_readl(rng_base + RNGA_OUTPUT_FIFO); | 92 | *data = __raw_readl(mxc_rng->mem + RNGA_OUTPUT_FIFO); |
88 | 93 | ||
89 | /* some error while reading this random number? */ | 94 | /* some error while reading this random number? */ |
90 | err = __raw_readl(rng_base + RNGA_STATUS) & RNGA_STATUS_ERROR_INT; | 95 | err = __raw_readl(mxc_rng->mem + RNGA_STATUS) & RNGA_STATUS_ERROR_INT; |
91 | 96 | ||
92 | /* if error: clear error interrupt, but doesn't return random number */ | 97 | /* if error: clear error interrupt, but doesn't return random number */ |
93 | if (err) { | 98 | if (err) { |
94 | dev_dbg(&rng_dev->dev, "Error while reading random number!\n"); | 99 | dev_dbg(mxc_rng->dev, "Error while reading random number!\n"); |
95 | ctrl = __raw_readl(rng_base + RNGA_CONTROL); | 100 | ctrl = __raw_readl(mxc_rng->mem + RNGA_CONTROL); |
96 | __raw_writel(ctrl | RNGA_CONTROL_CLEAR_INT, | 101 | __raw_writel(ctrl | RNGA_CONTROL_CLEAR_INT, |
97 | rng_base + RNGA_CONTROL); | 102 | mxc_rng->mem + RNGA_CONTROL); |
98 | return 0; | 103 | return 0; |
99 | } else | 104 | } else |
100 | return 4; | 105 | return 4; |
@@ -103,22 +108,22 @@ static int mxc_rnga_data_read(struct hwrng *rng, u32 * data) | |||
103 | static int mxc_rnga_init(struct hwrng *rng) | 108 | static int mxc_rnga_init(struct hwrng *rng) |
104 | { | 109 | { |
105 | u32 ctrl, osc; | 110 | u32 ctrl, osc; |
106 | void __iomem *rng_base = (void __iomem *)rng->priv; | 111 | struct mxc_rng *mxc_rng = container_of(rng, struct mxc_rng, rng); |
107 | 112 | ||
108 | /* wake up */ | 113 | /* wake up */ |
109 | ctrl = __raw_readl(rng_base + RNGA_CONTROL); | 114 | ctrl = __raw_readl(mxc_rng->mem + RNGA_CONTROL); |
110 | __raw_writel(ctrl & ~RNGA_CONTROL_SLEEP, rng_base + RNGA_CONTROL); | 115 | __raw_writel(ctrl & ~RNGA_CONTROL_SLEEP, mxc_rng->mem + RNGA_CONTROL); |
111 | 116 | ||
112 | /* verify if oscillator is working */ | 117 | /* verify if oscillator is working */ |
113 | osc = __raw_readl(rng_base + RNGA_STATUS); | 118 | osc = __raw_readl(mxc_rng->mem + RNGA_STATUS); |
114 | if (osc & RNGA_STATUS_OSC_DEAD) { | 119 | if (osc & RNGA_STATUS_OSC_DEAD) { |
115 | dev_err(&rng_dev->dev, "RNGA Oscillator is dead!\n"); | 120 | dev_err(mxc_rng->dev, "RNGA Oscillator is dead!\n"); |
116 | return -ENODEV; | 121 | return -ENODEV; |
117 | } | 122 | } |
118 | 123 | ||
119 | /* go running */ | 124 | /* go running */ |
120 | ctrl = __raw_readl(rng_base + RNGA_CONTROL); | 125 | ctrl = __raw_readl(mxc_rng->mem + RNGA_CONTROL); |
121 | __raw_writel(ctrl | RNGA_CONTROL_GO, rng_base + RNGA_CONTROL); | 126 | __raw_writel(ctrl | RNGA_CONTROL_GO, mxc_rng->mem + RNGA_CONTROL); |
122 | 127 | ||
123 | return 0; | 128 | return 0; |
124 | } | 129 | } |
@@ -126,40 +131,40 @@ static int mxc_rnga_init(struct hwrng *rng) | |||
126 | static void mxc_rnga_cleanup(struct hwrng *rng) | 131 | static void mxc_rnga_cleanup(struct hwrng *rng) |
127 | { | 132 | { |
128 | u32 ctrl; | 133 | u32 ctrl; |
129 | void __iomem *rng_base = (void __iomem *)rng->priv; | 134 | struct mxc_rng *mxc_rng = container_of(rng, struct mxc_rng, rng); |
130 | 135 | ||
131 | ctrl = __raw_readl(rng_base + RNGA_CONTROL); | 136 | ctrl = __raw_readl(mxc_rng->mem + RNGA_CONTROL); |
132 | 137 | ||
133 | /* stop rnga */ | 138 | /* stop rnga */ |
134 | __raw_writel(ctrl & ~RNGA_CONTROL_GO, rng_base + RNGA_CONTROL); | 139 | __raw_writel(ctrl & ~RNGA_CONTROL_GO, mxc_rng->mem + RNGA_CONTROL); |
135 | } | 140 | } |
136 | 141 | ||
137 | static struct hwrng mxc_rnga = { | ||
138 | .name = "mxc-rnga", | ||
139 | .init = mxc_rnga_init, | ||
140 | .cleanup = mxc_rnga_cleanup, | ||
141 | .data_present = mxc_rnga_data_present, | ||
142 | .data_read = mxc_rnga_data_read | ||
143 | }; | ||
144 | |||
145 | static int __init mxc_rnga_probe(struct platform_device *pdev) | 142 | static int __init mxc_rnga_probe(struct platform_device *pdev) |
146 | { | 143 | { |
147 | int err = -ENODEV; | 144 | int err = -ENODEV; |
148 | struct clk *clk; | ||
149 | struct resource *res, *mem; | 145 | struct resource *res, *mem; |
150 | void __iomem *rng_base = NULL; | 146 | struct mxc_rng *mxc_rng; |
151 | 147 | ||
152 | if (rng_dev) | 148 | mxc_rng = devm_kzalloc(&pdev->dev, sizeof(struct mxc_rng), |
153 | return -EBUSY; | 149 | GFP_KERNEL); |
154 | 150 | if (!mxc_rng) | |
155 | clk = clk_get(&pdev->dev, "rng"); | 151 | return -ENOMEM; |
156 | if (IS_ERR(clk)) { | 152 | |
153 | mxc_rng->dev = &pdev->dev; | ||
154 | mxc_rng->rng.name = "mxc-rnga"; | ||
155 | mxc_rng->rng.init = mxc_rnga_init; | ||
156 | mxc_rng->rng.cleanup = mxc_rnga_cleanup, | ||
157 | mxc_rng->rng.data_present = mxc_rnga_data_present, | ||
158 | mxc_rng->rng.data_read = mxc_rnga_data_read, | ||
159 | |||
160 | mxc_rng->clk = devm_clk_get(&pdev->dev, NULL); | ||
161 | if (IS_ERR(mxc_rng->clk)) { | ||
157 | dev_err(&pdev->dev, "Could not get rng_clk!\n"); | 162 | dev_err(&pdev->dev, "Could not get rng_clk!\n"); |
158 | err = PTR_ERR(clk); | 163 | err = PTR_ERR(mxc_rng->clk); |
159 | goto out; | 164 | goto out; |
160 | } | 165 | } |
161 | 166 | ||
162 | clk_enable(clk); | 167 | clk_prepare_enable(mxc_rng->clk); |
163 | 168 | ||
164 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 169 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
165 | if (!res) { | 170 | if (!res) { |
@@ -173,36 +178,27 @@ static int __init mxc_rnga_probe(struct platform_device *pdev) | |||
173 | goto err_region; | 178 | goto err_region; |
174 | } | 179 | } |
175 | 180 | ||
176 | rng_base = ioremap(res->start, resource_size(res)); | 181 | mxc_rng->mem = ioremap(res->start, resource_size(res)); |
177 | if (!rng_base) { | 182 | if (!mxc_rng->mem) { |
178 | err = -ENOMEM; | 183 | err = -ENOMEM; |
179 | goto err_ioremap; | 184 | goto err_ioremap; |
180 | } | 185 | } |
181 | 186 | ||
182 | mxc_rnga.priv = (unsigned long)rng_base; | 187 | err = hwrng_register(&mxc_rng->rng); |
183 | |||
184 | err = hwrng_register(&mxc_rnga); | ||
185 | if (err) { | 188 | if (err) { |
186 | dev_err(&pdev->dev, "MXC RNGA registering failed (%d)\n", err); | 189 | dev_err(&pdev->dev, "MXC RNGA registering failed (%d)\n", err); |
187 | goto err_register; | 190 | goto err_ioremap; |
188 | } | 191 | } |
189 | 192 | ||
190 | rng_dev = pdev; | ||
191 | |||
192 | dev_info(&pdev->dev, "MXC RNGA Registered.\n"); | 193 | dev_info(&pdev->dev, "MXC RNGA Registered.\n"); |
193 | 194 | ||
194 | return 0; | 195 | return 0; |
195 | 196 | ||
196 | err_register: | ||
197 | iounmap(rng_base); | ||
198 | rng_base = NULL; | ||
199 | |||
200 | err_ioremap: | 197 | err_ioremap: |
201 | release_mem_region(res->start, resource_size(res)); | 198 | release_mem_region(res->start, resource_size(res)); |
202 | 199 | ||
203 | err_region: | 200 | err_region: |
204 | clk_disable(clk); | 201 | clk_disable_unprepare(mxc_rng->clk); |
205 | clk_put(clk); | ||
206 | 202 | ||
207 | out: | 203 | out: |
208 | return err; | 204 | return err; |
@@ -211,17 +207,15 @@ out: | |||
211 | static int __exit mxc_rnga_remove(struct platform_device *pdev) | 207 | static int __exit mxc_rnga_remove(struct platform_device *pdev) |
212 | { | 208 | { |
213 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 209 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
214 | void __iomem *rng_base = (void __iomem *)mxc_rnga.priv; | 210 | struct mxc_rng *mxc_rng = platform_get_drvdata(pdev); |
215 | struct clk *clk = clk_get(&pdev->dev, "rng"); | ||
216 | 211 | ||
217 | hwrng_unregister(&mxc_rnga); | 212 | hwrng_unregister(&mxc_rng->rng); |
218 | 213 | ||
219 | iounmap(rng_base); | 214 | iounmap(mxc_rng->mem); |
220 | 215 | ||
221 | release_mem_region(res->start, resource_size(res)); | 216 | release_mem_region(res->start, resource_size(res)); |
222 | 217 | ||
223 | clk_disable(clk); | 218 | clk_disable_unprepare(mxc_rng->clk); |
224 | clk_put(clk); | ||
225 | 219 | ||
226 | return 0; | 220 | return 0; |
227 | } | 221 | } |
diff --git a/drivers/char/hw_random/octeon-rng.c b/drivers/char/hw_random/octeon-rng.c index 0943edc782a1..5c34c092af71 100644 --- a/drivers/char/hw_random/octeon-rng.c +++ b/drivers/char/hw_random/octeon-rng.c | |||
@@ -75,42 +75,35 @@ static int __devinit octeon_rng_probe(struct platform_device *pdev) | |||
75 | 75 | ||
76 | res_ports = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 76 | res_ports = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
77 | if (!res_ports) | 77 | if (!res_ports) |
78 | goto err_ports; | 78 | return -ENOENT; |
79 | 79 | ||
80 | res_result = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 80 | res_result = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
81 | if (!res_result) | 81 | if (!res_result) |
82 | goto err_ports; | 82 | return -ENOENT; |
83 | 83 | ||
84 | 84 | ||
85 | rng->control_status = devm_ioremap_nocache(&pdev->dev, | 85 | rng->control_status = devm_ioremap_nocache(&pdev->dev, |
86 | res_ports->start, | 86 | res_ports->start, |
87 | sizeof(u64)); | 87 | sizeof(u64)); |
88 | if (!rng->control_status) | 88 | if (!rng->control_status) |
89 | goto err_ports; | 89 | return -ENOENT; |
90 | 90 | ||
91 | rng->result = devm_ioremap_nocache(&pdev->dev, | 91 | rng->result = devm_ioremap_nocache(&pdev->dev, |
92 | res_result->start, | 92 | res_result->start, |
93 | sizeof(u64)); | 93 | sizeof(u64)); |
94 | if (!rng->result) | 94 | if (!rng->result) |
95 | goto err_r; | 95 | return -ENOENT; |
96 | 96 | ||
97 | rng->ops = ops; | 97 | rng->ops = ops; |
98 | 98 | ||
99 | dev_set_drvdata(&pdev->dev, &rng->ops); | 99 | dev_set_drvdata(&pdev->dev, &rng->ops); |
100 | ret = hwrng_register(&rng->ops); | 100 | ret = hwrng_register(&rng->ops); |
101 | if (ret) | 101 | if (ret) |
102 | goto err; | 102 | return -ENOENT; |
103 | 103 | ||
104 | dev_info(&pdev->dev, "Octeon Random Number Generator\n"); | 104 | dev_info(&pdev->dev, "Octeon Random Number Generator\n"); |
105 | 105 | ||
106 | return 0; | 106 | return 0; |
107 | err: | ||
108 | devm_iounmap(&pdev->dev, rng->control_status); | ||
109 | err_r: | ||
110 | devm_iounmap(&pdev->dev, rng->result); | ||
111 | err_ports: | ||
112 | devm_kfree(&pdev->dev, rng); | ||
113 | return -ENOENT; | ||
114 | } | 107 | } |
115 | 108 | ||
116 | static int __exit octeon_rng_remove(struct platform_device *pdev) | 109 | static int __exit octeon_rng_remove(struct platform_device *pdev) |
diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig index 7d74d092aa8f..308c7fb92a60 100644 --- a/drivers/crypto/Kconfig +++ b/drivers/crypto/Kconfig | |||
@@ -298,21 +298,15 @@ config CRYPTO_DEV_TEGRA_AES | |||
298 | will be called tegra-aes. | 298 | will be called tegra-aes. |
299 | 299 | ||
300 | config CRYPTO_DEV_NX | 300 | config CRYPTO_DEV_NX |
301 | tristate "Support for Power7+ in-Nest cryptographic acceleration" | 301 | bool "Support for IBM Power7+ in-Nest cryptographic acceleration" |
302 | depends on PPC64 && IBMVIO | 302 | depends on PPC64 && IBMVIO |
303 | select CRYPTO_AES | 303 | default n |
304 | select CRYPTO_CBC | ||
305 | select CRYPTO_ECB | ||
306 | select CRYPTO_CCM | ||
307 | select CRYPTO_GCM | ||
308 | select CRYPTO_AUTHENC | ||
309 | select CRYPTO_XCBC | ||
310 | select CRYPTO_SHA256 | ||
311 | select CRYPTO_SHA512 | ||
312 | help | 304 | help |
313 | Support for Power7+ in-Nest cryptographic acceleration. This | 305 | Support for Power7+ in-Nest cryptographic acceleration. |
314 | module supports acceleration for AES and SHA2 algorithms. If you | 306 | |
315 | choose 'M' here, this module will be called nx_crypto. | 307 | if CRYPTO_DEV_NX |
308 | source "drivers/crypto/nx/Kconfig" | ||
309 | endif | ||
316 | 310 | ||
317 | config CRYPTO_DEV_UX500 | 311 | config CRYPTO_DEV_UX500 |
318 | tristate "Driver for ST-Ericsson UX500 crypto hardware acceleration" | 312 | tristate "Driver for ST-Ericsson UX500 crypto hardware acceleration" |
@@ -340,7 +334,7 @@ config CRYPTO_DEV_ATMEL_AES | |||
340 | select CRYPTO_AES | 334 | select CRYPTO_AES |
341 | select CRYPTO_ALGAPI | 335 | select CRYPTO_ALGAPI |
342 | select CRYPTO_BLKCIPHER | 336 | select CRYPTO_BLKCIPHER |
343 | select CONFIG_AT_HDMAC | 337 | select AT_HDMAC |
344 | help | 338 | help |
345 | Some Atmel processors have AES hw accelerator. | 339 | Some Atmel processors have AES hw accelerator. |
346 | Select this if you want to use the Atmel module for | 340 | Select this if you want to use the Atmel module for |
diff --git a/drivers/crypto/amcc/crypto4xx_core.c b/drivers/crypto/amcc/crypto4xx_core.c index 802e85102c32..f88e3d8f6b64 100644 --- a/drivers/crypto/amcc/crypto4xx_core.c +++ b/drivers/crypto/amcc/crypto4xx_core.c | |||
@@ -1226,6 +1226,7 @@ static int __init crypto4xx_probe(struct platform_device *ofdev) | |||
1226 | core_dev->dev->ce_base = of_iomap(ofdev->dev.of_node, 0); | 1226 | core_dev->dev->ce_base = of_iomap(ofdev->dev.of_node, 0); |
1227 | if (!core_dev->dev->ce_base) { | 1227 | if (!core_dev->dev->ce_base) { |
1228 | dev_err(dev, "failed to of_iomap\n"); | 1228 | dev_err(dev, "failed to of_iomap\n"); |
1229 | rc = -ENOMEM; | ||
1229 | goto err_iomap; | 1230 | goto err_iomap; |
1230 | } | 1231 | } |
1231 | 1232 | ||
diff --git a/drivers/crypto/atmel-aes.c b/drivers/crypto/atmel-aes.c index 6bb20fffbf49..8061336e07e7 100644 --- a/drivers/crypto/atmel-aes.c +++ b/drivers/crypto/atmel-aes.c | |||
@@ -24,15 +24,10 @@ | |||
24 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
25 | 25 | ||
26 | #include <linux/device.h> | 26 | #include <linux/device.h> |
27 | #include <linux/module.h> | ||
28 | #include <linux/init.h> | 27 | #include <linux/init.h> |
29 | #include <linux/errno.h> | 28 | #include <linux/errno.h> |
30 | #include <linux/interrupt.h> | 29 | #include <linux/interrupt.h> |
31 | #include <linux/kernel.h> | ||
32 | #include <linux/clk.h> | ||
33 | #include <linux/irq.h> | 30 | #include <linux/irq.h> |
34 | #include <linux/io.h> | ||
35 | #include <linux/platform_device.h> | ||
36 | #include <linux/scatterlist.h> | 31 | #include <linux/scatterlist.h> |
37 | #include <linux/dma-mapping.h> | 32 | #include <linux/dma-mapping.h> |
38 | #include <linux/delay.h> | 33 | #include <linux/delay.h> |
@@ -1017,7 +1012,6 @@ static int atmel_aes_register_algs(struct atmel_aes_dev *dd) | |||
1017 | int err, i, j; | 1012 | int err, i, j; |
1018 | 1013 | ||
1019 | for (i = 0; i < ARRAY_SIZE(aes_algs); i++) { | 1014 | for (i = 0; i < ARRAY_SIZE(aes_algs); i++) { |
1020 | INIT_LIST_HEAD(&aes_algs[i].cra_list); | ||
1021 | err = crypto_register_alg(&aes_algs[i]); | 1015 | err = crypto_register_alg(&aes_algs[i]); |
1022 | if (err) | 1016 | if (err) |
1023 | goto err_aes_algs; | 1017 | goto err_aes_algs; |
@@ -1026,7 +1020,6 @@ static int atmel_aes_register_algs(struct atmel_aes_dev *dd) | |||
1026 | atmel_aes_hw_version_init(dd); | 1020 | atmel_aes_hw_version_init(dd); |
1027 | 1021 | ||
1028 | if (dd->hw_version >= 0x130) { | 1022 | if (dd->hw_version >= 0x130) { |
1029 | INIT_LIST_HEAD(&aes_cfb64_alg[0].cra_list); | ||
1030 | err = crypto_register_alg(&aes_cfb64_alg[0]); | 1023 | err = crypto_register_alg(&aes_cfb64_alg[0]); |
1031 | if (err) | 1024 | if (err) |
1032 | goto err_aes_cfb64_alg; | 1025 | goto err_aes_cfb64_alg; |
diff --git a/drivers/crypto/atmel-sha.c b/drivers/crypto/atmel-sha.c index f938b9d79b66..bcdf55fdc623 100644 --- a/drivers/crypto/atmel-sha.c +++ b/drivers/crypto/atmel-sha.c | |||
@@ -24,15 +24,10 @@ | |||
24 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
25 | 25 | ||
26 | #include <linux/device.h> | 26 | #include <linux/device.h> |
27 | #include <linux/module.h> | ||
28 | #include <linux/init.h> | 27 | #include <linux/init.h> |
29 | #include <linux/errno.h> | 28 | #include <linux/errno.h> |
30 | #include <linux/interrupt.h> | 29 | #include <linux/interrupt.h> |
31 | #include <linux/kernel.h> | ||
32 | #include <linux/clk.h> | ||
33 | #include <linux/irq.h> | 30 | #include <linux/irq.h> |
34 | #include <linux/io.h> | ||
35 | #include <linux/platform_device.h> | ||
36 | #include <linux/scatterlist.h> | 31 | #include <linux/scatterlist.h> |
37 | #include <linux/dma-mapping.h> | 32 | #include <linux/dma-mapping.h> |
38 | #include <linux/delay.h> | 33 | #include <linux/delay.h> |
diff --git a/drivers/crypto/atmel-tdes.c b/drivers/crypto/atmel-tdes.c index eb2b61e57e2d..7495f98c7221 100644 --- a/drivers/crypto/atmel-tdes.c +++ b/drivers/crypto/atmel-tdes.c | |||
@@ -24,15 +24,10 @@ | |||
24 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
25 | 25 | ||
26 | #include <linux/device.h> | 26 | #include <linux/device.h> |
27 | #include <linux/module.h> | ||
28 | #include <linux/init.h> | 27 | #include <linux/init.h> |
29 | #include <linux/errno.h> | 28 | #include <linux/errno.h> |
30 | #include <linux/interrupt.h> | 29 | #include <linux/interrupt.h> |
31 | #include <linux/kernel.h> | ||
32 | #include <linux/clk.h> | ||
33 | #include <linux/irq.h> | 30 | #include <linux/irq.h> |
34 | #include <linux/io.h> | ||
35 | #include <linux/platform_device.h> | ||
36 | #include <linux/scatterlist.h> | 31 | #include <linux/scatterlist.h> |
37 | #include <linux/dma-mapping.h> | 32 | #include <linux/dma-mapping.h> |
38 | #include <linux/delay.h> | 33 | #include <linux/delay.h> |
@@ -1044,7 +1039,6 @@ static int atmel_tdes_register_algs(struct atmel_tdes_dev *dd) | |||
1044 | int err, i, j; | 1039 | int err, i, j; |
1045 | 1040 | ||
1046 | for (i = 0; i < ARRAY_SIZE(tdes_algs); i++) { | 1041 | for (i = 0; i < ARRAY_SIZE(tdes_algs); i++) { |
1047 | INIT_LIST_HEAD(&tdes_algs[i].cra_list); | ||
1048 | err = crypto_register_alg(&tdes_algs[i]); | 1042 | err = crypto_register_alg(&tdes_algs[i]); |
1049 | if (err) | 1043 | if (err) |
1050 | goto err_tdes_algs; | 1044 | goto err_tdes_algs; |
diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c index 0c1ea8492eff..b2a0a0726a54 100644 --- a/drivers/crypto/caam/caamalg.c +++ b/drivers/crypto/caam/caamalg.c | |||
@@ -205,7 +205,7 @@ static void init_sh_desc_key_aead(u32 *desc, struct caam_ctx *ctx, | |||
205 | { | 205 | { |
206 | u32 *key_jump_cmd; | 206 | u32 *key_jump_cmd; |
207 | 207 | ||
208 | init_sh_desc(desc, HDR_SHARE_WAIT); | 208 | init_sh_desc(desc, HDR_SHARE_SERIAL); |
209 | 209 | ||
210 | /* Skip if already shared */ | 210 | /* Skip if already shared */ |
211 | key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL | | 211 | key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL | |
@@ -224,7 +224,7 @@ static int aead_set_sh_desc(struct crypto_aead *aead) | |||
224 | struct aead_tfm *tfm = &aead->base.crt_aead; | 224 | struct aead_tfm *tfm = &aead->base.crt_aead; |
225 | struct caam_ctx *ctx = crypto_aead_ctx(aead); | 225 | struct caam_ctx *ctx = crypto_aead_ctx(aead); |
226 | struct device *jrdev = ctx->jrdev; | 226 | struct device *jrdev = ctx->jrdev; |
227 | bool keys_fit_inline = 0; | 227 | bool keys_fit_inline = false; |
228 | u32 *key_jump_cmd, *jump_cmd; | 228 | u32 *key_jump_cmd, *jump_cmd; |
229 | u32 geniv, moveiv; | 229 | u32 geniv, moveiv; |
230 | u32 *desc; | 230 | u32 *desc; |
@@ -239,7 +239,7 @@ static int aead_set_sh_desc(struct crypto_aead *aead) | |||
239 | if (DESC_AEAD_ENC_LEN + DESC_JOB_IO_LEN + | 239 | if (DESC_AEAD_ENC_LEN + DESC_JOB_IO_LEN + |
240 | ctx->split_key_pad_len + ctx->enckeylen <= | 240 | ctx->split_key_pad_len + ctx->enckeylen <= |
241 | CAAM_DESC_BYTES_MAX) | 241 | CAAM_DESC_BYTES_MAX) |
242 | keys_fit_inline = 1; | 242 | keys_fit_inline = true; |
243 | 243 | ||
244 | /* aead_encrypt shared descriptor */ | 244 | /* aead_encrypt shared descriptor */ |
245 | desc = ctx->sh_desc_enc; | 245 | desc = ctx->sh_desc_enc; |
@@ -297,12 +297,12 @@ static int aead_set_sh_desc(struct crypto_aead *aead) | |||
297 | if (DESC_AEAD_DEC_LEN + DESC_JOB_IO_LEN + | 297 | if (DESC_AEAD_DEC_LEN + DESC_JOB_IO_LEN + |
298 | ctx->split_key_pad_len + ctx->enckeylen <= | 298 | ctx->split_key_pad_len + ctx->enckeylen <= |
299 | CAAM_DESC_BYTES_MAX) | 299 | CAAM_DESC_BYTES_MAX) |
300 | keys_fit_inline = 1; | 300 | keys_fit_inline = true; |
301 | 301 | ||
302 | desc = ctx->sh_desc_dec; | 302 | desc = ctx->sh_desc_dec; |
303 | 303 | ||
304 | /* aead_decrypt shared descriptor */ | 304 | /* aead_decrypt shared descriptor */ |
305 | init_sh_desc(desc, HDR_SHARE_WAIT); | 305 | init_sh_desc(desc, HDR_SHARE_SERIAL); |
306 | 306 | ||
307 | /* Skip if already shared */ | 307 | /* Skip if already shared */ |
308 | key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL | | 308 | key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL | |
@@ -365,7 +365,7 @@ static int aead_set_sh_desc(struct crypto_aead *aead) | |||
365 | if (DESC_AEAD_GIVENC_LEN + DESC_JOB_IO_LEN + | 365 | if (DESC_AEAD_GIVENC_LEN + DESC_JOB_IO_LEN + |
366 | ctx->split_key_pad_len + ctx->enckeylen <= | 366 | ctx->split_key_pad_len + ctx->enckeylen <= |
367 | CAAM_DESC_BYTES_MAX) | 367 | CAAM_DESC_BYTES_MAX) |
368 | keys_fit_inline = 1; | 368 | keys_fit_inline = true; |
369 | 369 | ||
370 | /* aead_givencrypt shared descriptor */ | 370 | /* aead_givencrypt shared descriptor */ |
371 | desc = ctx->sh_desc_givenc; | 371 | desc = ctx->sh_desc_givenc; |
@@ -564,7 +564,7 @@ static int ablkcipher_setkey(struct crypto_ablkcipher *ablkcipher, | |||
564 | 564 | ||
565 | /* ablkcipher_encrypt shared descriptor */ | 565 | /* ablkcipher_encrypt shared descriptor */ |
566 | desc = ctx->sh_desc_enc; | 566 | desc = ctx->sh_desc_enc; |
567 | init_sh_desc(desc, HDR_SHARE_WAIT); | 567 | init_sh_desc(desc, HDR_SHARE_SERIAL); |
568 | /* Skip if already shared */ | 568 | /* Skip if already shared */ |
569 | key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL | | 569 | key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL | |
570 | JUMP_COND_SHRD); | 570 | JUMP_COND_SHRD); |
@@ -605,7 +605,7 @@ static int ablkcipher_setkey(struct crypto_ablkcipher *ablkcipher, | |||
605 | /* ablkcipher_decrypt shared descriptor */ | 605 | /* ablkcipher_decrypt shared descriptor */ |
606 | desc = ctx->sh_desc_dec; | 606 | desc = ctx->sh_desc_dec; |
607 | 607 | ||
608 | init_sh_desc(desc, HDR_SHARE_WAIT); | 608 | init_sh_desc(desc, HDR_SHARE_SERIAL); |
609 | /* Skip if already shared */ | 609 | /* Skip if already shared */ |
610 | key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL | | 610 | key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL | |
611 | JUMP_COND_SHRD); | 611 | JUMP_COND_SHRD); |
@@ -1354,10 +1354,10 @@ static struct aead_edesc *aead_giv_edesc_alloc(struct aead_givcrypt_request | |||
1354 | contig &= ~GIV_SRC_CONTIG; | 1354 | contig &= ~GIV_SRC_CONTIG; |
1355 | if (dst_nents || iv_dma + ivsize != sg_dma_address(req->dst)) | 1355 | if (dst_nents || iv_dma + ivsize != sg_dma_address(req->dst)) |
1356 | contig &= ~GIV_DST_CONTIG; | 1356 | contig &= ~GIV_DST_CONTIG; |
1357 | if (unlikely(req->src != req->dst)) { | 1357 | if (unlikely(req->src != req->dst)) { |
1358 | dst_nents = dst_nents ? : 1; | 1358 | dst_nents = dst_nents ? : 1; |
1359 | sec4_sg_len += 1; | 1359 | sec4_sg_len += 1; |
1360 | } | 1360 | } |
1361 | if (!(contig & GIV_SRC_CONTIG)) { | 1361 | if (!(contig & GIV_SRC_CONTIG)) { |
1362 | assoc_nents = assoc_nents ? : 1; | 1362 | assoc_nents = assoc_nents ? : 1; |
1363 | src_nents = src_nents ? : 1; | 1363 | src_nents = src_nents ? : 1; |
@@ -1650,7 +1650,11 @@ struct caam_alg_template { | |||
1650 | }; | 1650 | }; |
1651 | 1651 | ||
1652 | static struct caam_alg_template driver_algs[] = { | 1652 | static struct caam_alg_template driver_algs[] = { |
1653 | /* single-pass ipsec_esp descriptor */ | 1653 | /* |
1654 | * single-pass ipsec_esp descriptor | ||
1655 | * authencesn(*,*) is also registered, although not present | ||
1656 | * explicitly here. | ||
1657 | */ | ||
1654 | { | 1658 | { |
1655 | .name = "authenc(hmac(md5),cbc(aes))", | 1659 | .name = "authenc(hmac(md5),cbc(aes))", |
1656 | .driver_name = "authenc-hmac-md5-cbc-aes-caam", | 1660 | .driver_name = "authenc-hmac-md5-cbc-aes-caam", |
@@ -2213,7 +2217,9 @@ static int __init caam_algapi_init(void) | |||
2213 | for (i = 0; i < ARRAY_SIZE(driver_algs); i++) { | 2217 | for (i = 0; i < ARRAY_SIZE(driver_algs); i++) { |
2214 | /* TODO: check if h/w supports alg */ | 2218 | /* TODO: check if h/w supports alg */ |
2215 | struct caam_crypto_alg *t_alg; | 2219 | struct caam_crypto_alg *t_alg; |
2220 | bool done = false; | ||
2216 | 2221 | ||
2222 | authencesn: | ||
2217 | t_alg = caam_alg_alloc(ctrldev, &driver_algs[i]); | 2223 | t_alg = caam_alg_alloc(ctrldev, &driver_algs[i]); |
2218 | if (IS_ERR(t_alg)) { | 2224 | if (IS_ERR(t_alg)) { |
2219 | err = PTR_ERR(t_alg); | 2225 | err = PTR_ERR(t_alg); |
@@ -2227,8 +2233,25 @@ static int __init caam_algapi_init(void) | |||
2227 | dev_warn(ctrldev, "%s alg registration failed\n", | 2233 | dev_warn(ctrldev, "%s alg registration failed\n", |
2228 | t_alg->crypto_alg.cra_driver_name); | 2234 | t_alg->crypto_alg.cra_driver_name); |
2229 | kfree(t_alg); | 2235 | kfree(t_alg); |
2230 | } else | 2236 | } else { |
2231 | list_add_tail(&t_alg->entry, &priv->alg_list); | 2237 | list_add_tail(&t_alg->entry, &priv->alg_list); |
2238 | if (driver_algs[i].type == CRYPTO_ALG_TYPE_AEAD && | ||
2239 | !memcmp(driver_algs[i].name, "authenc", 7) && | ||
2240 | !done) { | ||
2241 | char *name; | ||
2242 | |||
2243 | name = driver_algs[i].name; | ||
2244 | memmove(name + 10, name + 7, strlen(name) - 7); | ||
2245 | memcpy(name + 7, "esn", 3); | ||
2246 | |||
2247 | name = driver_algs[i].driver_name; | ||
2248 | memmove(name + 10, name + 7, strlen(name) - 7); | ||
2249 | memcpy(name + 7, "esn", 3); | ||
2250 | |||
2251 | done = true; | ||
2252 | goto authencesn; | ||
2253 | } | ||
2254 | } | ||
2232 | } | 2255 | } |
2233 | if (!list_empty(&priv->alg_list)) | 2256 | if (!list_empty(&priv->alg_list)) |
2234 | dev_info(ctrldev, "%s algorithms registered in /proc/crypto\n", | 2257 | dev_info(ctrldev, "%s algorithms registered in /proc/crypto\n", |
diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c index 895aaf2bca92..32aba7a61503 100644 --- a/drivers/crypto/caam/caamhash.c +++ b/drivers/crypto/caam/caamhash.c | |||
@@ -225,7 +225,7 @@ static inline void init_sh_desc_key_ahash(u32 *desc, struct caam_hash_ctx *ctx) | |||
225 | { | 225 | { |
226 | u32 *key_jump_cmd; | 226 | u32 *key_jump_cmd; |
227 | 227 | ||
228 | init_sh_desc(desc, HDR_SHARE_WAIT); | 228 | init_sh_desc(desc, HDR_SHARE_SERIAL); |
229 | 229 | ||
230 | if (ctx->split_key_len) { | 230 | if (ctx->split_key_len) { |
231 | /* Skip if already shared */ | 231 | /* Skip if already shared */ |
@@ -311,7 +311,7 @@ static int ahash_set_sh_desc(struct crypto_ahash *ahash) | |||
311 | /* ahash_update shared descriptor */ | 311 | /* ahash_update shared descriptor */ |
312 | desc = ctx->sh_desc_update; | 312 | desc = ctx->sh_desc_update; |
313 | 313 | ||
314 | init_sh_desc(desc, HDR_SHARE_WAIT); | 314 | init_sh_desc(desc, HDR_SHARE_SERIAL); |
315 | 315 | ||
316 | /* Import context from software */ | 316 | /* Import context from software */ |
317 | append_cmd(desc, CMD_SEQ_LOAD | LDST_SRCDST_BYTE_CONTEXT | | 317 | append_cmd(desc, CMD_SEQ_LOAD | LDST_SRCDST_BYTE_CONTEXT | |
@@ -430,6 +430,10 @@ static u32 hash_digest_key(struct caam_hash_ctx *ctx, const u8 *key_in, | |||
430 | int ret = 0; | 430 | int ret = 0; |
431 | 431 | ||
432 | desc = kmalloc(CAAM_CMD_SZ * 6 + CAAM_PTR_SZ * 2, GFP_KERNEL | GFP_DMA); | 432 | desc = kmalloc(CAAM_CMD_SZ * 6 + CAAM_PTR_SZ * 2, GFP_KERNEL | GFP_DMA); |
433 | if (!desc) { | ||
434 | dev_err(jrdev, "unable to allocate key input memory\n"); | ||
435 | return -ENOMEM; | ||
436 | } | ||
433 | 437 | ||
434 | init_job_desc(desc, 0); | 438 | init_job_desc(desc, 0); |
435 | 439 | ||
@@ -1736,8 +1740,11 @@ static void __exit caam_algapi_hash_exit(void) | |||
1736 | struct caam_hash_alg *t_alg, *n; | 1740 | struct caam_hash_alg *t_alg, *n; |
1737 | 1741 | ||
1738 | dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec-v4.0"); | 1742 | dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec-v4.0"); |
1739 | if (!dev_node) | 1743 | if (!dev_node) { |
1740 | return; | 1744 | dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec4.0"); |
1745 | if (!dev_node) | ||
1746 | return; | ||
1747 | } | ||
1741 | 1748 | ||
1742 | pdev = of_find_device_by_node(dev_node); | 1749 | pdev = of_find_device_by_node(dev_node); |
1743 | if (!pdev) | 1750 | if (!pdev) |
@@ -1812,8 +1819,11 @@ static int __init caam_algapi_hash_init(void) | |||
1812 | int i = 0, err = 0; | 1819 | int i = 0, err = 0; |
1813 | 1820 | ||
1814 | dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec-v4.0"); | 1821 | dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec-v4.0"); |
1815 | if (!dev_node) | 1822 | if (!dev_node) { |
1816 | return -ENODEV; | 1823 | dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec4.0"); |
1824 | if (!dev_node) | ||
1825 | return -ENODEV; | ||
1826 | } | ||
1817 | 1827 | ||
1818 | pdev = of_find_device_by_node(dev_node); | 1828 | pdev = of_find_device_by_node(dev_node); |
1819 | if (!pdev) | 1829 | if (!pdev) |
diff --git a/drivers/crypto/caam/caamrng.c b/drivers/crypto/caam/caamrng.c index e2bfe161dece..d1939a9539c0 100644 --- a/drivers/crypto/caam/caamrng.c +++ b/drivers/crypto/caam/caamrng.c | |||
@@ -193,7 +193,7 @@ static inline void rng_create_sh_desc(struct caam_rng_ctx *ctx) | |||
193 | struct device *jrdev = ctx->jrdev; | 193 | struct device *jrdev = ctx->jrdev; |
194 | u32 *desc = ctx->sh_desc; | 194 | u32 *desc = ctx->sh_desc; |
195 | 195 | ||
196 | init_sh_desc(desc, HDR_SHARE_WAIT); | 196 | init_sh_desc(desc, HDR_SHARE_SERIAL); |
197 | 197 | ||
198 | /* Propagate errors from shared to job descriptor */ | 198 | /* Propagate errors from shared to job descriptor */ |
199 | append_cmd(desc, SET_OK_NO_PROP_ERRORS | CMD_LOAD); | 199 | append_cmd(desc, SET_OK_NO_PROP_ERRORS | CMD_LOAD); |
@@ -284,8 +284,11 @@ static int __init caam_rng_init(void) | |||
284 | struct caam_drv_private *priv; | 284 | struct caam_drv_private *priv; |
285 | 285 | ||
286 | dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec-v4.0"); | 286 | dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec-v4.0"); |
287 | if (!dev_node) | 287 | if (!dev_node) { |
288 | return -ENODEV; | 288 | dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec4.0"); |
289 | if (!dev_node) | ||
290 | return -ENODEV; | ||
291 | } | ||
289 | 292 | ||
290 | pdev = of_find_device_by_node(dev_node); | 293 | pdev = of_find_device_by_node(dev_node); |
291 | if (!pdev) | 294 | if (!pdev) |
diff --git a/drivers/crypto/caam/compat.h b/drivers/crypto/caam/compat.h index 762aeff626ac..cf15e7813801 100644 --- a/drivers/crypto/caam/compat.h +++ b/drivers/crypto/caam/compat.h | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/types.h> | 23 | #include <linux/types.h> |
24 | #include <linux/debugfs.h> | 24 | #include <linux/debugfs.h> |
25 | #include <linux/circ_buf.h> | 25 | #include <linux/circ_buf.h> |
26 | #include <linux/string.h> | ||
26 | #include <net/xfrm.h> | 27 | #include <net/xfrm.h> |
27 | 28 | ||
28 | #include <crypto/algapi.h> | 29 | #include <crypto/algapi.h> |
diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index 414ba20c05a1..bf20dd891705 100644 --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c | |||
@@ -129,7 +129,7 @@ static int instantiate_rng(struct device *jrdev) | |||
129 | 129 | ||
130 | /* | 130 | /* |
131 | * By default, the TRNG runs for 200 clocks per sample; | 131 | * By default, the TRNG runs for 200 clocks per sample; |
132 | * 800 clocks per sample generates better entropy. | 132 | * 1600 clocks per sample generates better entropy. |
133 | */ | 133 | */ |
134 | static void kick_trng(struct platform_device *pdev) | 134 | static void kick_trng(struct platform_device *pdev) |
135 | { | 135 | { |
@@ -144,9 +144,9 @@ static void kick_trng(struct platform_device *pdev) | |||
144 | 144 | ||
145 | /* put RNG4 into program mode */ | 145 | /* put RNG4 into program mode */ |
146 | setbits32(&r4tst->rtmctl, RTMCTL_PRGM); | 146 | setbits32(&r4tst->rtmctl, RTMCTL_PRGM); |
147 | /* 800 clocks per sample */ | 147 | /* 1600 clocks per sample */ |
148 | val = rd_reg32(&r4tst->rtsdctl); | 148 | val = rd_reg32(&r4tst->rtsdctl); |
149 | val = (val & ~RTSDCTL_ENT_DLY_MASK) | (800 << RTSDCTL_ENT_DLY_SHIFT); | 149 | val = (val & ~RTSDCTL_ENT_DLY_MASK) | (1600 << RTSDCTL_ENT_DLY_SHIFT); |
150 | wr_reg32(&r4tst->rtsdctl, val); | 150 | wr_reg32(&r4tst->rtsdctl, val); |
151 | /* min. freq. count */ | 151 | /* min. freq. count */ |
152 | wr_reg32(&r4tst->rtfrqmin, 400); | 152 | wr_reg32(&r4tst->rtfrqmin, 400); |
diff --git a/drivers/crypto/caam/error.c b/drivers/crypto/caam/error.c index 9955ed9643e6..30b8f74833d4 100644 --- a/drivers/crypto/caam/error.c +++ b/drivers/crypto/caam/error.c | |||
@@ -77,10 +77,8 @@ static void report_ccb_status(u32 status, char *outstr) | |||
77 | "Not instantiated", | 77 | "Not instantiated", |
78 | "Test instantiate", | 78 | "Test instantiate", |
79 | "Prediction resistance", | 79 | "Prediction resistance", |
80 | "", | ||
81 | "Prediction resistance and test request", | 80 | "Prediction resistance and test request", |
82 | "Uninstantiate", | 81 | "Uninstantiate", |
83 | "", | ||
84 | "Secure key generation", | 82 | "Secure key generation", |
85 | }; | 83 | }; |
86 | u8 cha_id = (status & JRSTA_CCBERR_CHAID_MASK) >> | 84 | u8 cha_id = (status & JRSTA_CCBERR_CHAID_MASK) >> |
diff --git a/drivers/crypto/caam/key_gen.c b/drivers/crypto/caam/key_gen.c index d216cd3cc569..f6dba10246c3 100644 --- a/drivers/crypto/caam/key_gen.c +++ b/drivers/crypto/caam/key_gen.c | |||
@@ -54,6 +54,10 @@ u32 gen_split_key(struct device *jrdev, u8 *key_out, int split_key_len, | |||
54 | int ret = 0; | 54 | int ret = 0; |
55 | 55 | ||
56 | desc = kmalloc(CAAM_CMD_SZ * 6 + CAAM_PTR_SZ * 2, GFP_KERNEL | GFP_DMA); | 56 | desc = kmalloc(CAAM_CMD_SZ * 6 + CAAM_PTR_SZ * 2, GFP_KERNEL | GFP_DMA); |
57 | if (!desc) { | ||
58 | dev_err(jrdev, "unable to allocate key input memory\n"); | ||
59 | return -ENOMEM; | ||
60 | } | ||
57 | 61 | ||
58 | init_job_desc(desc, 0); | 62 | init_job_desc(desc, 0); |
59 | 63 | ||
diff --git a/drivers/crypto/geode-aes.c b/drivers/crypto/geode-aes.c index f3e36c86b6c3..51f196d77f21 100644 --- a/drivers/crypto/geode-aes.c +++ b/drivers/crypto/geode-aes.c | |||
@@ -289,7 +289,6 @@ static struct crypto_alg geode_alg = { | |||
289 | .cra_blocksize = AES_MIN_BLOCK_SIZE, | 289 | .cra_blocksize = AES_MIN_BLOCK_SIZE, |
290 | .cra_ctxsize = sizeof(struct geode_aes_op), | 290 | .cra_ctxsize = sizeof(struct geode_aes_op), |
291 | .cra_module = THIS_MODULE, | 291 | .cra_module = THIS_MODULE, |
292 | .cra_list = LIST_HEAD_INIT(geode_alg.cra_list), | ||
293 | .cra_u = { | 292 | .cra_u = { |
294 | .cipher = { | 293 | .cipher = { |
295 | .cia_min_keysize = AES_MIN_KEY_SIZE, | 294 | .cia_min_keysize = AES_MIN_KEY_SIZE, |
@@ -402,7 +401,6 @@ static struct crypto_alg geode_cbc_alg = { | |||
402 | .cra_alignmask = 15, | 401 | .cra_alignmask = 15, |
403 | .cra_type = &crypto_blkcipher_type, | 402 | .cra_type = &crypto_blkcipher_type, |
404 | .cra_module = THIS_MODULE, | 403 | .cra_module = THIS_MODULE, |
405 | .cra_list = LIST_HEAD_INIT(geode_cbc_alg.cra_list), | ||
406 | .cra_u = { | 404 | .cra_u = { |
407 | .blkcipher = { | 405 | .blkcipher = { |
408 | .min_keysize = AES_MIN_KEY_SIZE, | 406 | .min_keysize = AES_MIN_KEY_SIZE, |
@@ -489,7 +487,6 @@ static struct crypto_alg geode_ecb_alg = { | |||
489 | .cra_alignmask = 15, | 487 | .cra_alignmask = 15, |
490 | .cra_type = &crypto_blkcipher_type, | 488 | .cra_type = &crypto_blkcipher_type, |
491 | .cra_module = THIS_MODULE, | 489 | .cra_module = THIS_MODULE, |
492 | .cra_list = LIST_HEAD_INIT(geode_ecb_alg.cra_list), | ||
493 | .cra_u = { | 490 | .cra_u = { |
494 | .blkcipher = { | 491 | .blkcipher = { |
495 | .min_keysize = AES_MIN_KEY_SIZE, | 492 | .min_keysize = AES_MIN_KEY_SIZE, |
@@ -588,21 +585,8 @@ static struct pci_driver geode_aes_driver = { | |||
588 | .remove = __devexit_p(geode_aes_remove) | 585 | .remove = __devexit_p(geode_aes_remove) |
589 | }; | 586 | }; |
590 | 587 | ||
591 | static int __init | 588 | module_pci_driver(geode_aes_driver); |
592 | geode_aes_init(void) | ||
593 | { | ||
594 | return pci_register_driver(&geode_aes_driver); | ||
595 | } | ||
596 | |||
597 | static void __exit | ||
598 | geode_aes_exit(void) | ||
599 | { | ||
600 | pci_unregister_driver(&geode_aes_driver); | ||
601 | } | ||
602 | 589 | ||
603 | MODULE_AUTHOR("Advanced Micro Devices, Inc."); | 590 | MODULE_AUTHOR("Advanced Micro Devices, Inc."); |
604 | MODULE_DESCRIPTION("Geode LX Hardware AES driver"); | 591 | MODULE_DESCRIPTION("Geode LX Hardware AES driver"); |
605 | MODULE_LICENSE("GPL"); | 592 | MODULE_LICENSE("GPL"); |
606 | |||
607 | module_init(geode_aes_init); | ||
608 | module_exit(geode_aes_exit); | ||
diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c index df14358d7fa1..fda32968a66b 100644 --- a/drivers/crypto/hifn_795x.c +++ b/drivers/crypto/hifn_795x.c | |||
@@ -2611,14 +2611,17 @@ static int __devinit hifn_probe(struct pci_dev *pdev, const struct pci_device_id | |||
2611 | size = pci_resource_len(pdev, i); | 2611 | size = pci_resource_len(pdev, i); |
2612 | 2612 | ||
2613 | dev->bar[i] = ioremap_nocache(addr, size); | 2613 | dev->bar[i] = ioremap_nocache(addr, size); |
2614 | if (!dev->bar[i]) | 2614 | if (!dev->bar[i]) { |
2615 | err = -ENOMEM; | ||
2615 | goto err_out_unmap_bars; | 2616 | goto err_out_unmap_bars; |
2617 | } | ||
2616 | } | 2618 | } |
2617 | 2619 | ||
2618 | dev->desc_virt = pci_alloc_consistent(pdev, sizeof(struct hifn_dma), | 2620 | dev->desc_virt = pci_alloc_consistent(pdev, sizeof(struct hifn_dma), |
2619 | &dev->desc_dma); | 2621 | &dev->desc_dma); |
2620 | if (!dev->desc_virt) { | 2622 | if (!dev->desc_virt) { |
2621 | dprintk("Failed to allocate descriptor rings.\n"); | 2623 | dprintk("Failed to allocate descriptor rings.\n"); |
2624 | err = -ENOMEM; | ||
2622 | goto err_out_unmap_bars; | 2625 | goto err_out_unmap_bars; |
2623 | } | 2626 | } |
2624 | memset(dev->desc_virt, 0, sizeof(struct hifn_dma)); | 2627 | memset(dev->desc_virt, 0, sizeof(struct hifn_dma)); |
diff --git a/drivers/crypto/nx/Kconfig b/drivers/crypto/nx/Kconfig new file mode 100644 index 000000000000..f82616621ae1 --- /dev/null +++ b/drivers/crypto/nx/Kconfig | |||
@@ -0,0 +1,26 @@ | |||
1 | config CRYPTO_DEV_NX_ENCRYPT | ||
2 | tristate "Encryption acceleration support" | ||
3 | depends on PPC64 && IBMVIO | ||
4 | default y | ||
5 | select CRYPTO_AES | ||
6 | select CRYPTO_CBC | ||
7 | select CRYPTO_ECB | ||
8 | select CRYPTO_CCM | ||
9 | select CRYPTO_GCM | ||
10 | select CRYPTO_AUTHENC | ||
11 | select CRYPTO_XCBC | ||
12 | select CRYPTO_SHA256 | ||
13 | select CRYPTO_SHA512 | ||
14 | help | ||
15 | Support for Power7+ in-Nest encryption acceleration. This | ||
16 | module supports acceleration for AES and SHA2 algorithms. If you | ||
17 | choose 'M' here, this module will be called nx_crypto. | ||
18 | |||
19 | config CRYPTO_DEV_NX_COMPRESS | ||
20 | tristate "Compression acceleration support" | ||
21 | depends on PPC64 && IBMVIO | ||
22 | default y | ||
23 | help | ||
24 | Support for Power7+ in-Nest compression acceleration. This | ||
25 | module supports acceleration for AES and SHA2 algorithms. If you | ||
26 | choose 'M' here, this module will be called nx_compress. | ||
diff --git a/drivers/crypto/nx/Makefile b/drivers/crypto/nx/Makefile index 411ce59c80d1..bb770ea45ce9 100644 --- a/drivers/crypto/nx/Makefile +++ b/drivers/crypto/nx/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | obj-$(CONFIG_CRYPTO_DEV_NX) += nx-crypto.o | 1 | obj-$(CONFIG_CRYPTO_DEV_NX_ENCRYPT) += nx-crypto.o |
2 | nx-crypto-objs := nx.o \ | 2 | nx-crypto-objs := nx.o \ |
3 | nx_debugfs.o \ | 3 | nx_debugfs.o \ |
4 | nx-aes-cbc.o \ | 4 | nx-aes-cbc.o \ |
@@ -9,3 +9,6 @@ nx-crypto-objs := nx.o \ | |||
9 | nx-aes-xcbc.o \ | 9 | nx-aes-xcbc.o \ |
10 | nx-sha256.o \ | 10 | nx-sha256.o \ |
11 | nx-sha512.o | 11 | nx-sha512.o |
12 | |||
13 | obj-$(CONFIG_CRYPTO_DEV_NX_COMPRESS) += nx-compress.o | ||
14 | nx-compress-objs := nx-842.o | ||
diff --git a/drivers/crypto/nx/nx-842.c b/drivers/crypto/nx/nx-842.c new file mode 100644 index 000000000000..0ce625738677 --- /dev/null +++ b/drivers/crypto/nx/nx-842.c | |||
@@ -0,0 +1,1617 @@ | |||
1 | /* | ||
2 | * Driver for IBM Power 842 compression accelerator | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | * | ||
18 | * Copyright (C) IBM Corporation, 2012 | ||
19 | * | ||
20 | * Authors: Robert Jennings <rcj@linux.vnet.ibm.com> | ||
21 | * Seth Jennings <sjenning@linux.vnet.ibm.com> | ||
22 | */ | ||
23 | |||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/nx842.h> | ||
27 | #include <linux/of.h> | ||
28 | #include <linux/slab.h> | ||
29 | |||
30 | #include <asm/page.h> | ||
31 | #include <asm/pSeries_reconfig.h> | ||
32 | #include <asm/vio.h> | ||
33 | |||
34 | #include "nx_csbcpb.h" /* struct nx_csbcpb */ | ||
35 | |||
36 | #define MODULE_NAME "nx-compress" | ||
37 | MODULE_LICENSE("GPL"); | ||
38 | MODULE_AUTHOR("Robert Jennings <rcj@linux.vnet.ibm.com>"); | ||
39 | MODULE_DESCRIPTION("842 H/W Compression driver for IBM Power processors"); | ||
40 | |||
41 | #define SHIFT_4K 12 | ||
42 | #define SHIFT_64K 16 | ||
43 | #define SIZE_4K (1UL << SHIFT_4K) | ||
44 | #define SIZE_64K (1UL << SHIFT_64K) | ||
45 | |||
46 | /* IO buffer must be 128 byte aligned */ | ||
47 | #define IO_BUFFER_ALIGN 128 | ||
48 | |||
49 | struct nx842_header { | ||
50 | int blocks_nr; /* number of compressed blocks */ | ||
51 | int offset; /* offset of the first block (from beginning of header) */ | ||
52 | int sizes[0]; /* size of compressed blocks */ | ||
53 | }; | ||
54 | |||
55 | static inline int nx842_header_size(const struct nx842_header *hdr) | ||
56 | { | ||
57 | return sizeof(struct nx842_header) + | ||
58 | hdr->blocks_nr * sizeof(hdr->sizes[0]); | ||
59 | } | ||
60 | |||
61 | /* Macros for fields within nx_csbcpb */ | ||
62 | /* Check the valid bit within the csbcpb valid field */ | ||
63 | #define NX842_CSBCBP_VALID_CHK(x) (x & BIT_MASK(7)) | ||
64 | |||
65 | /* CE macros operate on the completion_extension field bits in the csbcpb. | ||
66 | * CE0 0=full completion, 1=partial completion | ||
67 | * CE1 0=CE0 indicates completion, 1=termination (output may be modified) | ||
68 | * CE2 0=processed_bytes is source bytes, 1=processed_bytes is target bytes */ | ||
69 | #define NX842_CSBCPB_CE0(x) (x & BIT_MASK(7)) | ||
70 | #define NX842_CSBCPB_CE1(x) (x & BIT_MASK(6)) | ||
71 | #define NX842_CSBCPB_CE2(x) (x & BIT_MASK(5)) | ||
72 | |||
73 | /* The NX unit accepts data only on 4K page boundaries */ | ||
74 | #define NX842_HW_PAGE_SHIFT SHIFT_4K | ||
75 | #define NX842_HW_PAGE_SIZE (ASM_CONST(1) << NX842_HW_PAGE_SHIFT) | ||
76 | #define NX842_HW_PAGE_MASK (~(NX842_HW_PAGE_SIZE-1)) | ||
77 | |||
78 | enum nx842_status { | ||
79 | UNAVAILABLE, | ||
80 | AVAILABLE | ||
81 | }; | ||
82 | |||
83 | struct ibm_nx842_counters { | ||
84 | atomic64_t comp_complete; | ||
85 | atomic64_t comp_failed; | ||
86 | atomic64_t decomp_complete; | ||
87 | atomic64_t decomp_failed; | ||
88 | atomic64_t swdecomp; | ||
89 | atomic64_t comp_times[32]; | ||
90 | atomic64_t decomp_times[32]; | ||
91 | }; | ||
92 | |||
93 | static struct nx842_devdata { | ||
94 | struct vio_dev *vdev; | ||
95 | struct device *dev; | ||
96 | struct ibm_nx842_counters *counters; | ||
97 | unsigned int max_sg_len; | ||
98 | unsigned int max_sync_size; | ||
99 | unsigned int max_sync_sg; | ||
100 | enum nx842_status status; | ||
101 | } __rcu *devdata; | ||
102 | static DEFINE_SPINLOCK(devdata_mutex); | ||
103 | |||
104 | #define NX842_COUNTER_INC(_x) \ | ||
105 | static inline void nx842_inc_##_x( \ | ||
106 | const struct nx842_devdata *dev) { \ | ||
107 | if (dev) \ | ||
108 | atomic64_inc(&dev->counters->_x); \ | ||
109 | } | ||
110 | NX842_COUNTER_INC(comp_complete); | ||
111 | NX842_COUNTER_INC(comp_failed); | ||
112 | NX842_COUNTER_INC(decomp_complete); | ||
113 | NX842_COUNTER_INC(decomp_failed); | ||
114 | NX842_COUNTER_INC(swdecomp); | ||
115 | |||
116 | #define NX842_HIST_SLOTS 16 | ||
117 | |||
118 | static void ibm_nx842_incr_hist(atomic64_t *times, unsigned int time) | ||
119 | { | ||
120 | int bucket = fls(time); | ||
121 | |||
122 | if (bucket) | ||
123 | bucket = min((NX842_HIST_SLOTS - 1), bucket - 1); | ||
124 | |||
125 | atomic64_inc(×[bucket]); | ||
126 | } | ||
127 | |||
128 | /* NX unit operation flags */ | ||
129 | #define NX842_OP_COMPRESS 0x0 | ||
130 | #define NX842_OP_CRC 0x1 | ||
131 | #define NX842_OP_DECOMPRESS 0x2 | ||
132 | #define NX842_OP_COMPRESS_CRC (NX842_OP_COMPRESS | NX842_OP_CRC) | ||
133 | #define NX842_OP_DECOMPRESS_CRC (NX842_OP_DECOMPRESS | NX842_OP_CRC) | ||
134 | #define NX842_OP_ASYNC (1<<23) | ||
135 | #define NX842_OP_NOTIFY (1<<22) | ||
136 | #define NX842_OP_NOTIFY_INT(x) ((x & 0xff)<<8) | ||
137 | |||
138 | static unsigned long nx842_get_desired_dma(struct vio_dev *viodev) | ||
139 | { | ||
140 | /* No use of DMA mappings within the driver. */ | ||
141 | return 0; | ||
142 | } | ||
143 | |||
144 | struct nx842_slentry { | ||
145 | unsigned long ptr; /* Real address (use __pa()) */ | ||
146 | unsigned long len; | ||
147 | }; | ||
148 | |||
149 | /* pHyp scatterlist entry */ | ||
150 | struct nx842_scatterlist { | ||
151 | int entry_nr; /* number of slentries */ | ||
152 | struct nx842_slentry *entries; /* ptr to array of slentries */ | ||
153 | }; | ||
154 | |||
155 | /* Does not include sizeof(entry_nr) in the size */ | ||
156 | static inline unsigned long nx842_get_scatterlist_size( | ||
157 | struct nx842_scatterlist *sl) | ||
158 | { | ||
159 | return sl->entry_nr * sizeof(struct nx842_slentry); | ||
160 | } | ||
161 | |||
162 | static int nx842_build_scatterlist(unsigned long buf, int len, | ||
163 | struct nx842_scatterlist *sl) | ||
164 | { | ||
165 | unsigned long nextpage; | ||
166 | struct nx842_slentry *entry; | ||
167 | |||
168 | sl->entry_nr = 0; | ||
169 | |||
170 | entry = sl->entries; | ||
171 | while (len) { | ||
172 | entry->ptr = __pa(buf); | ||
173 | nextpage = ALIGN(buf + 1, NX842_HW_PAGE_SIZE); | ||
174 | if (nextpage < buf + len) { | ||
175 | /* we aren't at the end yet */ | ||
176 | if (IS_ALIGNED(buf, NX842_HW_PAGE_SIZE)) | ||
177 | /* we are in the middle (or beginning) */ | ||
178 | entry->len = NX842_HW_PAGE_SIZE; | ||
179 | else | ||
180 | /* we are at the beginning */ | ||
181 | entry->len = nextpage - buf; | ||
182 | } else { | ||
183 | /* at the end */ | ||
184 | entry->len = len; | ||
185 | } | ||
186 | |||
187 | len -= entry->len; | ||
188 | buf += entry->len; | ||
189 | sl->entry_nr++; | ||
190 | entry++; | ||
191 | } | ||
192 | |||
193 | return 0; | ||
194 | } | ||
195 | |||
196 | /* | ||
197 | * Working memory for software decompression | ||
198 | */ | ||
199 | struct sw842_fifo { | ||
200 | union { | ||
201 | char f8[256][8]; | ||
202 | char f4[512][4]; | ||
203 | }; | ||
204 | char f2[256][2]; | ||
205 | unsigned char f84_full; | ||
206 | unsigned char f2_full; | ||
207 | unsigned char f8_count; | ||
208 | unsigned char f2_count; | ||
209 | unsigned int f4_count; | ||
210 | }; | ||
211 | |||
212 | /* | ||
213 | * Working memory for crypto API | ||
214 | */ | ||
215 | struct nx842_workmem { | ||
216 | char bounce[PAGE_SIZE]; /* bounce buffer for decompression input */ | ||
217 | union { | ||
218 | /* hardware working memory */ | ||
219 | struct { | ||
220 | /* scatterlist */ | ||
221 | char slin[SIZE_4K]; | ||
222 | char slout[SIZE_4K]; | ||
223 | /* coprocessor status/parameter block */ | ||
224 | struct nx_csbcpb csbcpb; | ||
225 | }; | ||
226 | /* software working memory */ | ||
227 | struct sw842_fifo swfifo; /* software decompression fifo */ | ||
228 | }; | ||
229 | }; | ||
230 | |||
231 | int nx842_get_workmem_size(void) | ||
232 | { | ||
233 | return sizeof(struct nx842_workmem) + NX842_HW_PAGE_SIZE; | ||
234 | } | ||
235 | EXPORT_SYMBOL_GPL(nx842_get_workmem_size); | ||
236 | |||
237 | int nx842_get_workmem_size_aligned(void) | ||
238 | { | ||
239 | return sizeof(struct nx842_workmem); | ||
240 | } | ||
241 | EXPORT_SYMBOL_GPL(nx842_get_workmem_size_aligned); | ||
242 | |||
243 | static int nx842_validate_result(struct device *dev, | ||
244 | struct cop_status_block *csb) | ||
245 | { | ||
246 | /* The csb must be valid after returning from vio_h_cop_sync */ | ||
247 | if (!NX842_CSBCBP_VALID_CHK(csb->valid)) { | ||
248 | dev_err(dev, "%s: cspcbp not valid upon completion.\n", | ||
249 | __func__); | ||
250 | dev_dbg(dev, "valid:0x%02x cs:0x%02x cc:0x%02x ce:0x%02x\n", | ||
251 | csb->valid, | ||
252 | csb->crb_seq_number, | ||
253 | csb->completion_code, | ||
254 | csb->completion_extension); | ||
255 | dev_dbg(dev, "processed_bytes:%d address:0x%016lx\n", | ||
256 | csb->processed_byte_count, | ||
257 | (unsigned long)csb->address); | ||
258 | return -EIO; | ||
259 | } | ||
260 | |||
261 | /* Check return values from the hardware in the CSB */ | ||
262 | switch (csb->completion_code) { | ||
263 | case 0: /* Completed without error */ | ||
264 | break; | ||
265 | case 64: /* Target bytes > Source bytes during compression */ | ||
266 | case 13: /* Output buffer too small */ | ||
267 | dev_dbg(dev, "%s: Compression output larger than input\n", | ||
268 | __func__); | ||
269 | return -ENOSPC; | ||
270 | case 66: /* Input data contains an illegal template field */ | ||
271 | case 67: /* Template indicates data past the end of the input stream */ | ||
272 | dev_dbg(dev, "%s: Bad data for decompression (code:%d)\n", | ||
273 | __func__, csb->completion_code); | ||
274 | return -EINVAL; | ||
275 | default: | ||
276 | dev_dbg(dev, "%s: Unspecified error (code:%d)\n", | ||
277 | __func__, csb->completion_code); | ||
278 | return -EIO; | ||
279 | } | ||
280 | |||
281 | /* Hardware sanity check */ | ||
282 | if (!NX842_CSBCPB_CE2(csb->completion_extension)) { | ||
283 | dev_err(dev, "%s: No error returned by hardware, but " | ||
284 | "data returned is unusable, contact support.\n" | ||
285 | "(Additional info: csbcbp->processed bytes " | ||
286 | "does not specify processed bytes for the " | ||
287 | "target buffer.)\n", __func__); | ||
288 | return -EIO; | ||
289 | } | ||
290 | |||
291 | return 0; | ||
292 | } | ||
293 | |||
294 | /** | ||
295 | * nx842_compress - Compress data using the 842 algorithm | ||
296 | * | ||
297 | * Compression provide by the NX842 coprocessor on IBM Power systems. | ||
298 | * The input buffer is compressed and the result is stored in the | ||
299 | * provided output buffer. | ||
300 | * | ||
301 | * Upon return from this function @outlen contains the length of the | ||
302 | * compressed data. If there is an error then @outlen will be 0 and an | ||
303 | * error will be specified by the return code from this function. | ||
304 | * | ||
305 | * @in: Pointer to input buffer, must be page aligned | ||
306 | * @inlen: Length of input buffer, must be PAGE_SIZE | ||
307 | * @out: Pointer to output buffer | ||
308 | * @outlen: Length of output buffer | ||
309 | * @wrkmem: ptr to buffer for working memory, size determined by | ||
310 | * nx842_get_workmem_size() | ||
311 | * | ||
312 | * Returns: | ||
313 | * 0 Success, output of length @outlen stored in the buffer at @out | ||
314 | * -ENOMEM Unable to allocate internal buffers | ||
315 | * -ENOSPC Output buffer is to small | ||
316 | * -EMSGSIZE XXX Difficult to describe this limitation | ||
317 | * -EIO Internal error | ||
318 | * -ENODEV Hardware unavailable | ||
319 | */ | ||
320 | int nx842_compress(const unsigned char *in, unsigned int inlen, | ||
321 | unsigned char *out, unsigned int *outlen, void *wmem) | ||
322 | { | ||
323 | struct nx842_header *hdr; | ||
324 | struct nx842_devdata *local_devdata; | ||
325 | struct device *dev = NULL; | ||
326 | struct nx842_workmem *workmem; | ||
327 | struct nx842_scatterlist slin, slout; | ||
328 | struct nx_csbcpb *csbcpb; | ||
329 | int ret = 0, max_sync_size, i, bytesleft, size, hdrsize; | ||
330 | unsigned long inbuf, outbuf, padding; | ||
331 | struct vio_pfo_op op = { | ||
332 | .done = NULL, | ||
333 | .handle = 0, | ||
334 | .timeout = 0, | ||
335 | }; | ||
336 | unsigned long start_time = get_tb(); | ||
337 | |||
338 | /* | ||
339 | * Make sure input buffer is 64k page aligned. This is assumed since | ||
340 | * this driver is designed for page compression only (for now). This | ||
341 | * is very nice since we can now use direct DDE(s) for the input and | ||
342 | * the alignment is guaranteed. | ||
343 | */ | ||
344 | inbuf = (unsigned long)in; | ||
345 | if (!IS_ALIGNED(inbuf, PAGE_SIZE) || inlen != PAGE_SIZE) | ||
346 | return -EINVAL; | ||
347 | |||
348 | rcu_read_lock(); | ||
349 | local_devdata = rcu_dereference(devdata); | ||
350 | if (!local_devdata || !local_devdata->dev) { | ||
351 | rcu_read_unlock(); | ||
352 | return -ENODEV; | ||
353 | } | ||
354 | max_sync_size = local_devdata->max_sync_size; | ||
355 | dev = local_devdata->dev; | ||
356 | |||
357 | /* Create the header */ | ||
358 | hdr = (struct nx842_header *)out; | ||
359 | hdr->blocks_nr = PAGE_SIZE / max_sync_size; | ||
360 | hdrsize = nx842_header_size(hdr); | ||
361 | outbuf = (unsigned long)out + hdrsize; | ||
362 | bytesleft = *outlen - hdrsize; | ||
363 | |||
364 | /* Init scatterlist */ | ||
365 | workmem = (struct nx842_workmem *)ALIGN((unsigned long)wmem, | ||
366 | NX842_HW_PAGE_SIZE); | ||
367 | slin.entries = (struct nx842_slentry *)workmem->slin; | ||
368 | slout.entries = (struct nx842_slentry *)workmem->slout; | ||
369 | |||
370 | /* Init operation */ | ||
371 | op.flags = NX842_OP_COMPRESS; | ||
372 | csbcpb = &workmem->csbcpb; | ||
373 | memset(csbcpb, 0, sizeof(*csbcpb)); | ||
374 | op.csbcpb = __pa(csbcpb); | ||
375 | op.out = __pa(slout.entries); | ||
376 | |||
377 | for (i = 0; i < hdr->blocks_nr; i++) { | ||
378 | /* | ||
379 | * Aligning the output blocks to 128 bytes does waste space, | ||
380 | * but it prevents the need for bounce buffers and memory | ||
381 | * copies. It also simplifies the code a lot. In the worst | ||
382 | * case (64k page, 4k max_sync_size), you lose up to | ||
383 | * (128*16)/64k = ~3% the compression factor. For 64k | ||
384 | * max_sync_size, the loss would be at most 128/64k = ~0.2%. | ||
385 | */ | ||
386 | padding = ALIGN(outbuf, IO_BUFFER_ALIGN) - outbuf; | ||
387 | outbuf += padding; | ||
388 | bytesleft -= padding; | ||
389 | if (i == 0) | ||
390 | /* save offset into first block in header */ | ||
391 | hdr->offset = padding + hdrsize; | ||
392 | |||
393 | if (bytesleft <= 0) { | ||
394 | ret = -ENOSPC; | ||
395 | goto unlock; | ||
396 | } | ||
397 | |||
398 | /* | ||
399 | * NOTE: If the default max_sync_size is changed from 4k | ||
400 | * to 64k, remove the "likely" case below, since a | ||
401 | * scatterlist will always be needed. | ||
402 | */ | ||
403 | if (likely(max_sync_size == NX842_HW_PAGE_SIZE)) { | ||
404 | /* Create direct DDE */ | ||
405 | op.in = __pa(inbuf); | ||
406 | op.inlen = max_sync_size; | ||
407 | |||
408 | } else { | ||
409 | /* Create indirect DDE (scatterlist) */ | ||
410 | nx842_build_scatterlist(inbuf, max_sync_size, &slin); | ||
411 | op.in = __pa(slin.entries); | ||
412 | op.inlen = -nx842_get_scatterlist_size(&slin); | ||
413 | } | ||
414 | |||
415 | /* | ||
416 | * If max_sync_size != NX842_HW_PAGE_SIZE, an indirect | ||
417 | * DDE is required for the outbuf. | ||
418 | * If max_sync_size == NX842_HW_PAGE_SIZE, outbuf must | ||
419 | * also be page aligned (1 in 128/4k=32 chance) in order | ||
420 | * to use a direct DDE. | ||
421 | * This is unlikely, just use an indirect DDE always. | ||
422 | */ | ||
423 | nx842_build_scatterlist(outbuf, | ||
424 | min(bytesleft, max_sync_size), &slout); | ||
425 | /* op.out set before loop */ | ||
426 | op.outlen = -nx842_get_scatterlist_size(&slout); | ||
427 | |||
428 | /* Send request to pHyp */ | ||
429 | ret = vio_h_cop_sync(local_devdata->vdev, &op); | ||
430 | |||
431 | /* Check for pHyp error */ | ||
432 | if (ret) { | ||
433 | dev_dbg(dev, "%s: vio_h_cop_sync error (ret=%d, hret=%ld)\n", | ||
434 | __func__, ret, op.hcall_err); | ||
435 | ret = -EIO; | ||
436 | goto unlock; | ||
437 | } | ||
438 | |||
439 | /* Check for hardware error */ | ||
440 | ret = nx842_validate_result(dev, &csbcpb->csb); | ||
441 | if (ret && ret != -ENOSPC) | ||
442 | goto unlock; | ||
443 | |||
444 | /* Handle incompressible data */ | ||
445 | if (unlikely(ret == -ENOSPC)) { | ||
446 | if (bytesleft < max_sync_size) { | ||
447 | /* | ||
448 | * Not enough space left in the output buffer | ||
449 | * to store uncompressed block | ||
450 | */ | ||
451 | goto unlock; | ||
452 | } else { | ||
453 | /* Store incompressible block */ | ||
454 | memcpy((void *)outbuf, (void *)inbuf, | ||
455 | max_sync_size); | ||
456 | hdr->sizes[i] = -max_sync_size; | ||
457 | outbuf += max_sync_size; | ||
458 | bytesleft -= max_sync_size; | ||
459 | /* Reset ret, incompressible data handled */ | ||
460 | ret = 0; | ||
461 | } | ||
462 | } else { | ||
463 | /* Normal case, compression was successful */ | ||
464 | size = csbcpb->csb.processed_byte_count; | ||
465 | dev_dbg(dev, "%s: processed_bytes=%d\n", | ||
466 | __func__, size); | ||
467 | hdr->sizes[i] = size; | ||
468 | outbuf += size; | ||
469 | bytesleft -= size; | ||
470 | } | ||
471 | |||
472 | inbuf += max_sync_size; | ||
473 | } | ||
474 | |||
475 | *outlen = (unsigned int)(outbuf - (unsigned long)out); | ||
476 | |||
477 | unlock: | ||
478 | if (ret) | ||
479 | nx842_inc_comp_failed(local_devdata); | ||
480 | else { | ||
481 | nx842_inc_comp_complete(local_devdata); | ||
482 | ibm_nx842_incr_hist(local_devdata->counters->comp_times, | ||
483 | (get_tb() - start_time) / tb_ticks_per_usec); | ||
484 | } | ||
485 | rcu_read_unlock(); | ||
486 | return ret; | ||
487 | } | ||
488 | EXPORT_SYMBOL_GPL(nx842_compress); | ||
489 | |||
490 | static int sw842_decompress(const unsigned char *, int, unsigned char *, int *, | ||
491 | const void *); | ||
492 | |||
493 | /** | ||
494 | * nx842_decompress - Decompress data using the 842 algorithm | ||
495 | * | ||
496 | * Decompression provide by the NX842 coprocessor on IBM Power systems. | ||
497 | * The input buffer is decompressed and the result is stored in the | ||
498 | * provided output buffer. The size allocated to the output buffer is | ||
499 | * provided by the caller of this function in @outlen. Upon return from | ||
500 | * this function @outlen contains the length of the decompressed data. | ||
501 | * If there is an error then @outlen will be 0 and an error will be | ||
502 | * specified by the return code from this function. | ||
503 | * | ||
504 | * @in: Pointer to input buffer, will use bounce buffer if not 128 byte | ||
505 | * aligned | ||
506 | * @inlen: Length of input buffer | ||
507 | * @out: Pointer to output buffer, must be page aligned | ||
508 | * @outlen: Length of output buffer, must be PAGE_SIZE | ||
509 | * @wrkmem: ptr to buffer for working memory, size determined by | ||
510 | * nx842_get_workmem_size() | ||
511 | * | ||
512 | * Returns: | ||
513 | * 0 Success, output of length @outlen stored in the buffer at @out | ||
514 | * -ENODEV Hardware decompression device is unavailable | ||
515 | * -ENOMEM Unable to allocate internal buffers | ||
516 | * -ENOSPC Output buffer is to small | ||
517 | * -EINVAL Bad input data encountered when attempting decompress | ||
518 | * -EIO Internal error | ||
519 | */ | ||
520 | int nx842_decompress(const unsigned char *in, unsigned int inlen, | ||
521 | unsigned char *out, unsigned int *outlen, void *wmem) | ||
522 | { | ||
523 | struct nx842_header *hdr; | ||
524 | struct nx842_devdata *local_devdata; | ||
525 | struct device *dev = NULL; | ||
526 | struct nx842_workmem *workmem; | ||
527 | struct nx842_scatterlist slin, slout; | ||
528 | struct nx_csbcpb *csbcpb; | ||
529 | int ret = 0, i, size, max_sync_size; | ||
530 | unsigned long inbuf, outbuf; | ||
531 | struct vio_pfo_op op = { | ||
532 | .done = NULL, | ||
533 | .handle = 0, | ||
534 | .timeout = 0, | ||
535 | }; | ||
536 | unsigned long start_time = get_tb(); | ||
537 | |||
538 | /* Ensure page alignment and size */ | ||
539 | outbuf = (unsigned long)out; | ||
540 | if (!IS_ALIGNED(outbuf, PAGE_SIZE) || *outlen != PAGE_SIZE) | ||
541 | return -EINVAL; | ||
542 | |||
543 | rcu_read_lock(); | ||
544 | local_devdata = rcu_dereference(devdata); | ||
545 | if (local_devdata) | ||
546 | dev = local_devdata->dev; | ||
547 | |||
548 | /* Get header */ | ||
549 | hdr = (struct nx842_header *)in; | ||
550 | |||
551 | workmem = (struct nx842_workmem *)ALIGN((unsigned long)wmem, | ||
552 | NX842_HW_PAGE_SIZE); | ||
553 | |||
554 | inbuf = (unsigned long)in + hdr->offset; | ||
555 | if (likely(!IS_ALIGNED(inbuf, IO_BUFFER_ALIGN))) { | ||
556 | /* Copy block(s) into bounce buffer for alignment */ | ||
557 | memcpy(workmem->bounce, in + hdr->offset, inlen - hdr->offset); | ||
558 | inbuf = (unsigned long)workmem->bounce; | ||
559 | } | ||
560 | |||
561 | /* Init scatterlist */ | ||
562 | slin.entries = (struct nx842_slentry *)workmem->slin; | ||
563 | slout.entries = (struct nx842_slentry *)workmem->slout; | ||
564 | |||
565 | /* Init operation */ | ||
566 | op.flags = NX842_OP_DECOMPRESS; | ||
567 | csbcpb = &workmem->csbcpb; | ||
568 | memset(csbcpb, 0, sizeof(*csbcpb)); | ||
569 | op.csbcpb = __pa(csbcpb); | ||
570 | |||
571 | /* | ||
572 | * max_sync_size may have changed since compression, | ||
573 | * so we can't read it from the device info. We need | ||
574 | * to derive it from hdr->blocks_nr. | ||
575 | */ | ||
576 | max_sync_size = PAGE_SIZE / hdr->blocks_nr; | ||
577 | |||
578 | for (i = 0; i < hdr->blocks_nr; i++) { | ||
579 | /* Skip padding */ | ||
580 | inbuf = ALIGN(inbuf, IO_BUFFER_ALIGN); | ||
581 | |||
582 | if (hdr->sizes[i] < 0) { | ||
583 | /* Negative sizes indicate uncompressed data blocks */ | ||
584 | size = abs(hdr->sizes[i]); | ||
585 | memcpy((void *)outbuf, (void *)inbuf, size); | ||
586 | outbuf += size; | ||
587 | inbuf += size; | ||
588 | continue; | ||
589 | } | ||
590 | |||
591 | if (!dev) | ||
592 | goto sw; | ||
593 | |||
594 | /* | ||
595 | * The better the compression, the more likely the "likely" | ||
596 | * case becomes. | ||
597 | */ | ||
598 | if (likely((inbuf & NX842_HW_PAGE_MASK) == | ||
599 | ((inbuf + hdr->sizes[i] - 1) & NX842_HW_PAGE_MASK))) { | ||
600 | /* Create direct DDE */ | ||
601 | op.in = __pa(inbuf); | ||
602 | op.inlen = hdr->sizes[i]; | ||
603 | } else { | ||
604 | /* Create indirect DDE (scatterlist) */ | ||
605 | nx842_build_scatterlist(inbuf, hdr->sizes[i] , &slin); | ||
606 | op.in = __pa(slin.entries); | ||
607 | op.inlen = -nx842_get_scatterlist_size(&slin); | ||
608 | } | ||
609 | |||
610 | /* | ||
611 | * NOTE: If the default max_sync_size is changed from 4k | ||
612 | * to 64k, remove the "likely" case below, since a | ||
613 | * scatterlist will always be needed. | ||
614 | */ | ||
615 | if (likely(max_sync_size == NX842_HW_PAGE_SIZE)) { | ||
616 | /* Create direct DDE */ | ||
617 | op.out = __pa(outbuf); | ||
618 | op.outlen = max_sync_size; | ||
619 | } else { | ||
620 | /* Create indirect DDE (scatterlist) */ | ||
621 | nx842_build_scatterlist(outbuf, max_sync_size, &slout); | ||
622 | op.out = __pa(slout.entries); | ||
623 | op.outlen = -nx842_get_scatterlist_size(&slout); | ||
624 | } | ||
625 | |||
626 | /* Send request to pHyp */ | ||
627 | ret = vio_h_cop_sync(local_devdata->vdev, &op); | ||
628 | |||
629 | /* Check for pHyp error */ | ||
630 | if (ret) { | ||
631 | dev_dbg(dev, "%s: vio_h_cop_sync error (ret=%d, hret=%ld)\n", | ||
632 | __func__, ret, op.hcall_err); | ||
633 | dev = NULL; | ||
634 | goto sw; | ||
635 | } | ||
636 | |||
637 | /* Check for hardware error */ | ||
638 | ret = nx842_validate_result(dev, &csbcpb->csb); | ||
639 | if (ret) { | ||
640 | dev = NULL; | ||
641 | goto sw; | ||
642 | } | ||
643 | |||
644 | /* HW decompression success */ | ||
645 | inbuf += hdr->sizes[i]; | ||
646 | outbuf += csbcpb->csb.processed_byte_count; | ||
647 | continue; | ||
648 | |||
649 | sw: | ||
650 | /* software decompression */ | ||
651 | size = max_sync_size; | ||
652 | ret = sw842_decompress( | ||
653 | (unsigned char *)inbuf, hdr->sizes[i], | ||
654 | (unsigned char *)outbuf, &size, wmem); | ||
655 | if (ret) | ||
656 | pr_debug("%s: sw842_decompress failed with %d\n", | ||
657 | __func__, ret); | ||
658 | |||
659 | if (ret) { | ||
660 | if (ret != -ENOSPC && ret != -EINVAL && | ||
661 | ret != -EMSGSIZE) | ||
662 | ret = -EIO; | ||
663 | goto unlock; | ||
664 | } | ||
665 | |||
666 | /* SW decompression success */ | ||
667 | inbuf += hdr->sizes[i]; | ||
668 | outbuf += size; | ||
669 | } | ||
670 | |||
671 | *outlen = (unsigned int)(outbuf - (unsigned long)out); | ||
672 | |||
673 | unlock: | ||
674 | if (ret) | ||
675 | /* decompress fail */ | ||
676 | nx842_inc_decomp_failed(local_devdata); | ||
677 | else { | ||
678 | if (!dev) | ||
679 | /* software decompress */ | ||
680 | nx842_inc_swdecomp(local_devdata); | ||
681 | nx842_inc_decomp_complete(local_devdata); | ||
682 | ibm_nx842_incr_hist(local_devdata->counters->decomp_times, | ||
683 | (get_tb() - start_time) / tb_ticks_per_usec); | ||
684 | } | ||
685 | |||
686 | rcu_read_unlock(); | ||
687 | return ret; | ||
688 | } | ||
689 | EXPORT_SYMBOL_GPL(nx842_decompress); | ||
690 | |||
691 | /** | ||
692 | * nx842_OF_set_defaults -- Set default (disabled) values for devdata | ||
693 | * | ||
694 | * @devdata - struct nx842_devdata to update | ||
695 | * | ||
696 | * Returns: | ||
697 | * 0 on success | ||
698 | * -ENOENT if @devdata ptr is NULL | ||
699 | */ | ||
700 | static int nx842_OF_set_defaults(struct nx842_devdata *devdata) | ||
701 | { | ||
702 | if (devdata) { | ||
703 | devdata->max_sync_size = 0; | ||
704 | devdata->max_sync_sg = 0; | ||
705 | devdata->max_sg_len = 0; | ||
706 | devdata->status = UNAVAILABLE; | ||
707 | return 0; | ||
708 | } else | ||
709 | return -ENOENT; | ||
710 | } | ||
711 | |||
712 | /** | ||
713 | * nx842_OF_upd_status -- Update the device info from OF status prop | ||
714 | * | ||
715 | * The status property indicates if the accelerator is enabled. If the | ||
716 | * device is in the OF tree it indicates that the hardware is present. | ||
717 | * The status field indicates if the device is enabled when the status | ||
718 | * is 'okay'. Otherwise the device driver will be disabled. | ||
719 | * | ||
720 | * @devdata - struct nx842_devdata to update | ||
721 | * @prop - struct property point containing the maxsyncop for the update | ||
722 | * | ||
723 | * Returns: | ||
724 | * 0 - Device is available | ||
725 | * -EINVAL - Device is not available | ||
726 | */ | ||
727 | static int nx842_OF_upd_status(struct nx842_devdata *devdata, | ||
728 | struct property *prop) { | ||
729 | int ret = 0; | ||
730 | const char *status = (const char *)prop->value; | ||
731 | |||
732 | if (!strncmp(status, "okay", (size_t)prop->length)) { | ||
733 | devdata->status = AVAILABLE; | ||
734 | } else { | ||
735 | dev_info(devdata->dev, "%s: status '%s' is not 'okay'\n", | ||
736 | __func__, status); | ||
737 | devdata->status = UNAVAILABLE; | ||
738 | } | ||
739 | |||
740 | return ret; | ||
741 | } | ||
742 | |||
743 | /** | ||
744 | * nx842_OF_upd_maxsglen -- Update the device info from OF maxsglen prop | ||
745 | * | ||
746 | * Definition of the 'ibm,max-sg-len' OF property: | ||
747 | * This field indicates the maximum byte length of a scatter list | ||
748 | * for the platform facility. It is a single cell encoded as with encode-int. | ||
749 | * | ||
750 | * Example: | ||
751 | * # od -x ibm,max-sg-len | ||
752 | * 0000000 0000 0ff0 | ||
753 | * | ||
754 | * In this example, the maximum byte length of a scatter list is | ||
755 | * 0x0ff0 (4,080). | ||
756 | * | ||
757 | * @devdata - struct nx842_devdata to update | ||
758 | * @prop - struct property point containing the maxsyncop for the update | ||
759 | * | ||
760 | * Returns: | ||
761 | * 0 on success | ||
762 | * -EINVAL on failure | ||
763 | */ | ||
764 | static int nx842_OF_upd_maxsglen(struct nx842_devdata *devdata, | ||
765 | struct property *prop) { | ||
766 | int ret = 0; | ||
767 | const int *maxsglen = prop->value; | ||
768 | |||
769 | if (prop->length != sizeof(*maxsglen)) { | ||
770 | dev_err(devdata->dev, "%s: unexpected format for ibm,max-sg-len property\n", __func__); | ||
771 | dev_dbg(devdata->dev, "%s: ibm,max-sg-len is %d bytes long, expected %lu bytes\n", __func__, | ||
772 | prop->length, sizeof(*maxsglen)); | ||
773 | ret = -EINVAL; | ||
774 | } else { | ||
775 | devdata->max_sg_len = (unsigned int)min(*maxsglen, | ||
776 | (int)NX842_HW_PAGE_SIZE); | ||
777 | } | ||
778 | |||
779 | return ret; | ||
780 | } | ||
781 | |||
782 | /** | ||
783 | * nx842_OF_upd_maxsyncop -- Update the device info from OF maxsyncop prop | ||
784 | * | ||
785 | * Definition of the 'ibm,max-sync-cop' OF property: | ||
786 | * Two series of cells. The first series of cells represents the maximums | ||
787 | * that can be synchronously compressed. The second series of cells | ||
788 | * represents the maximums that can be synchronously decompressed. | ||
789 | * 1. The first cell in each series contains the count of the number of | ||
790 | * data length, scatter list elements pairs that follow – each being | ||
791 | * of the form | ||
792 | * a. One cell data byte length | ||
793 | * b. One cell total number of scatter list elements | ||
794 | * | ||
795 | * Example: | ||
796 | * # od -x ibm,max-sync-cop | ||
797 | * 0000000 0000 0001 0000 1000 0000 01fe 0000 0001 | ||
798 | * 0000020 0000 1000 0000 01fe | ||
799 | * | ||
800 | * In this example, compression supports 0x1000 (4,096) data byte length | ||
801 | * and 0x1fe (510) total scatter list elements. Decompression supports | ||
802 | * 0x1000 (4,096) data byte length and 0x1f3 (510) total scatter list | ||
803 | * elements. | ||
804 | * | ||
805 | * @devdata - struct nx842_devdata to update | ||
806 | * @prop - struct property point containing the maxsyncop for the update | ||
807 | * | ||
808 | * Returns: | ||
809 | * 0 on success | ||
810 | * -EINVAL on failure | ||
811 | */ | ||
812 | static int nx842_OF_upd_maxsyncop(struct nx842_devdata *devdata, | ||
813 | struct property *prop) { | ||
814 | int ret = 0; | ||
815 | const struct maxsynccop_t { | ||
816 | int comp_elements; | ||
817 | int comp_data_limit; | ||
818 | int comp_sg_limit; | ||
819 | int decomp_elements; | ||
820 | int decomp_data_limit; | ||
821 | int decomp_sg_limit; | ||
822 | } *maxsynccop; | ||
823 | |||
824 | if (prop->length != sizeof(*maxsynccop)) { | ||
825 | dev_err(devdata->dev, "%s: unexpected format for ibm,max-sync-cop property\n", __func__); | ||
826 | dev_dbg(devdata->dev, "%s: ibm,max-sync-cop is %d bytes long, expected %lu bytes\n", __func__, prop->length, | ||
827 | sizeof(*maxsynccop)); | ||
828 | ret = -EINVAL; | ||
829 | goto out; | ||
830 | } | ||
831 | |||
832 | maxsynccop = (const struct maxsynccop_t *)prop->value; | ||
833 | |||
834 | /* Use one limit rather than separate limits for compression and | ||
835 | * decompression. Set a maximum for this so as not to exceed the | ||
836 | * size that the header can support and round the value down to | ||
837 | * the hardware page size (4K) */ | ||
838 | devdata->max_sync_size = | ||
839 | (unsigned int)min(maxsynccop->comp_data_limit, | ||
840 | maxsynccop->decomp_data_limit); | ||
841 | |||
842 | devdata->max_sync_size = min_t(unsigned int, devdata->max_sync_size, | ||
843 | SIZE_64K); | ||
844 | |||
845 | if (devdata->max_sync_size < SIZE_4K) { | ||
846 | dev_err(devdata->dev, "%s: hardware max data size (%u) is " | ||
847 | "less than the driver minimum, unable to use " | ||
848 | "the hardware device\n", | ||
849 | __func__, devdata->max_sync_size); | ||
850 | ret = -EINVAL; | ||
851 | goto out; | ||
852 | } | ||
853 | |||
854 | devdata->max_sync_sg = (unsigned int)min(maxsynccop->comp_sg_limit, | ||
855 | maxsynccop->decomp_sg_limit); | ||
856 | if (devdata->max_sync_sg < 1) { | ||
857 | dev_err(devdata->dev, "%s: hardware max sg size (%u) is " | ||
858 | "less than the driver minimum, unable to use " | ||
859 | "the hardware device\n", | ||
860 | __func__, devdata->max_sync_sg); | ||
861 | ret = -EINVAL; | ||
862 | goto out; | ||
863 | } | ||
864 | |||
865 | out: | ||
866 | return ret; | ||
867 | } | ||
868 | |||
869 | /** | ||
870 | * | ||
871 | * nx842_OF_upd -- Handle OF properties updates for the device. | ||
872 | * | ||
873 | * Set all properties from the OF tree. Optionally, a new property | ||
874 | * can be provided by the @new_prop pointer to overwrite an existing value. | ||
875 | * The device will remain disabled until all values are valid, this function | ||
876 | * will return an error for updates unless all values are valid. | ||
877 | * | ||
878 | * @new_prop: If not NULL, this property is being updated. If NULL, update | ||
879 | * all properties from the current values in the OF tree. | ||
880 | * | ||
881 | * Returns: | ||
882 | * 0 - Success | ||
883 | * -ENOMEM - Could not allocate memory for new devdata structure | ||
884 | * -EINVAL - property value not found, new_prop is not a recognized | ||
885 | * property for the device or property value is not valid. | ||
886 | * -ENODEV - Device is not available | ||
887 | */ | ||
888 | static int nx842_OF_upd(struct property *new_prop) | ||
889 | { | ||
890 | struct nx842_devdata *old_devdata = NULL; | ||
891 | struct nx842_devdata *new_devdata = NULL; | ||
892 | struct device_node *of_node = NULL; | ||
893 | struct property *status = NULL; | ||
894 | struct property *maxsglen = NULL; | ||
895 | struct property *maxsyncop = NULL; | ||
896 | int ret = 0; | ||
897 | unsigned long flags; | ||
898 | |||
899 | spin_lock_irqsave(&devdata_mutex, flags); | ||
900 | old_devdata = rcu_dereference_check(devdata, | ||
901 | lockdep_is_held(&devdata_mutex)); | ||
902 | if (old_devdata) | ||
903 | of_node = old_devdata->dev->of_node; | ||
904 | |||
905 | if (!old_devdata || !of_node) { | ||
906 | pr_err("%s: device is not available\n", __func__); | ||
907 | spin_unlock_irqrestore(&devdata_mutex, flags); | ||
908 | return -ENODEV; | ||
909 | } | ||
910 | |||
911 | new_devdata = kzalloc(sizeof(*new_devdata), GFP_NOFS); | ||
912 | if (!new_devdata) { | ||
913 | dev_err(old_devdata->dev, "%s: Could not allocate memory for device data\n", __func__); | ||
914 | ret = -ENOMEM; | ||
915 | goto error_out; | ||
916 | } | ||
917 | |||
918 | memcpy(new_devdata, old_devdata, sizeof(*old_devdata)); | ||
919 | new_devdata->counters = old_devdata->counters; | ||
920 | |||
921 | /* Set ptrs for existing properties */ | ||
922 | status = of_find_property(of_node, "status", NULL); | ||
923 | maxsglen = of_find_property(of_node, "ibm,max-sg-len", NULL); | ||
924 | maxsyncop = of_find_property(of_node, "ibm,max-sync-cop", NULL); | ||
925 | if (!status || !maxsglen || !maxsyncop) { | ||
926 | dev_err(old_devdata->dev, "%s: Could not locate device properties\n", __func__); | ||
927 | ret = -EINVAL; | ||
928 | goto error_out; | ||
929 | } | ||
930 | |||
931 | /* Set ptr to new property if provided */ | ||
932 | if (new_prop) { | ||
933 | /* Single property */ | ||
934 | if (!strncmp(new_prop->name, "status", new_prop->length)) { | ||
935 | status = new_prop; | ||
936 | |||
937 | } else if (!strncmp(new_prop->name, "ibm,max-sg-len", | ||
938 | new_prop->length)) { | ||
939 | maxsglen = new_prop; | ||
940 | |||
941 | } else if (!strncmp(new_prop->name, "ibm,max-sync-cop", | ||
942 | new_prop->length)) { | ||
943 | maxsyncop = new_prop; | ||
944 | |||
945 | } else { | ||
946 | /* | ||
947 | * Skip the update, the property being updated | ||
948 | * has no impact. | ||
949 | */ | ||
950 | goto out; | ||
951 | } | ||
952 | } | ||
953 | |||
954 | /* Perform property updates */ | ||
955 | ret = nx842_OF_upd_status(new_devdata, status); | ||
956 | if (ret) | ||
957 | goto error_out; | ||
958 | |||
959 | ret = nx842_OF_upd_maxsglen(new_devdata, maxsglen); | ||
960 | if (ret) | ||
961 | goto error_out; | ||
962 | |||
963 | ret = nx842_OF_upd_maxsyncop(new_devdata, maxsyncop); | ||
964 | if (ret) | ||
965 | goto error_out; | ||
966 | |||
967 | out: | ||
968 | dev_info(old_devdata->dev, "%s: max_sync_size new:%u old:%u\n", | ||
969 | __func__, new_devdata->max_sync_size, | ||
970 | old_devdata->max_sync_size); | ||
971 | dev_info(old_devdata->dev, "%s: max_sync_sg new:%u old:%u\n", | ||
972 | __func__, new_devdata->max_sync_sg, | ||
973 | old_devdata->max_sync_sg); | ||
974 | dev_info(old_devdata->dev, "%s: max_sg_len new:%u old:%u\n", | ||
975 | __func__, new_devdata->max_sg_len, | ||
976 | old_devdata->max_sg_len); | ||
977 | |||
978 | rcu_assign_pointer(devdata, new_devdata); | ||
979 | spin_unlock_irqrestore(&devdata_mutex, flags); | ||
980 | synchronize_rcu(); | ||
981 | dev_set_drvdata(new_devdata->dev, new_devdata); | ||
982 | kfree(old_devdata); | ||
983 | return 0; | ||
984 | |||
985 | error_out: | ||
986 | if (new_devdata) { | ||
987 | dev_info(old_devdata->dev, "%s: device disabled\n", __func__); | ||
988 | nx842_OF_set_defaults(new_devdata); | ||
989 | rcu_assign_pointer(devdata, new_devdata); | ||
990 | spin_unlock_irqrestore(&devdata_mutex, flags); | ||
991 | synchronize_rcu(); | ||
992 | dev_set_drvdata(new_devdata->dev, new_devdata); | ||
993 | kfree(old_devdata); | ||
994 | } else { | ||
995 | dev_err(old_devdata->dev, "%s: could not update driver from hardware\n", __func__); | ||
996 | spin_unlock_irqrestore(&devdata_mutex, flags); | ||
997 | } | ||
998 | |||
999 | if (!ret) | ||
1000 | ret = -EINVAL; | ||
1001 | return ret; | ||
1002 | } | ||
1003 | |||
1004 | /** | ||
1005 | * nx842_OF_notifier - Process updates to OF properties for the device | ||
1006 | * | ||
1007 | * @np: notifier block | ||
1008 | * @action: notifier action | ||
1009 | * @update: struct pSeries_reconfig_prop_update pointer if action is | ||
1010 | * PSERIES_UPDATE_PROPERTY | ||
1011 | * | ||
1012 | * Returns: | ||
1013 | * NOTIFY_OK on success | ||
1014 | * NOTIFY_BAD encoded with error number on failure, use | ||
1015 | * notifier_to_errno() to decode this value | ||
1016 | */ | ||
1017 | static int nx842_OF_notifier(struct notifier_block *np, | ||
1018 | unsigned long action, | ||
1019 | void *update) | ||
1020 | { | ||
1021 | struct pSeries_reconfig_prop_update *upd; | ||
1022 | struct nx842_devdata *local_devdata; | ||
1023 | struct device_node *node = NULL; | ||
1024 | |||
1025 | upd = (struct pSeries_reconfig_prop_update *)update; | ||
1026 | |||
1027 | rcu_read_lock(); | ||
1028 | local_devdata = rcu_dereference(devdata); | ||
1029 | if (local_devdata) | ||
1030 | node = local_devdata->dev->of_node; | ||
1031 | |||
1032 | if (local_devdata && | ||
1033 | action == PSERIES_UPDATE_PROPERTY && | ||
1034 | !strcmp(upd->node->name, node->name)) { | ||
1035 | rcu_read_unlock(); | ||
1036 | nx842_OF_upd(upd->property); | ||
1037 | } else | ||
1038 | rcu_read_unlock(); | ||
1039 | |||
1040 | return NOTIFY_OK; | ||
1041 | } | ||
1042 | |||
1043 | static struct notifier_block nx842_of_nb = { | ||
1044 | .notifier_call = nx842_OF_notifier, | ||
1045 | }; | ||
1046 | |||
1047 | #define nx842_counter_read(_name) \ | ||
1048 | static ssize_t nx842_##_name##_show(struct device *dev, \ | ||
1049 | struct device_attribute *attr, \ | ||
1050 | char *buf) { \ | ||
1051 | struct nx842_devdata *local_devdata; \ | ||
1052 | int p = 0; \ | ||
1053 | rcu_read_lock(); \ | ||
1054 | local_devdata = rcu_dereference(devdata); \ | ||
1055 | if (local_devdata) \ | ||
1056 | p = snprintf(buf, PAGE_SIZE, "%ld\n", \ | ||
1057 | atomic64_read(&local_devdata->counters->_name)); \ | ||
1058 | rcu_read_unlock(); \ | ||
1059 | return p; \ | ||
1060 | } | ||
1061 | |||
1062 | #define NX842DEV_COUNTER_ATTR_RO(_name) \ | ||
1063 | nx842_counter_read(_name); \ | ||
1064 | static struct device_attribute dev_attr_##_name = __ATTR(_name, \ | ||
1065 | 0444, \ | ||
1066 | nx842_##_name##_show,\ | ||
1067 | NULL); | ||
1068 | |||
1069 | NX842DEV_COUNTER_ATTR_RO(comp_complete); | ||
1070 | NX842DEV_COUNTER_ATTR_RO(comp_failed); | ||
1071 | NX842DEV_COUNTER_ATTR_RO(decomp_complete); | ||
1072 | NX842DEV_COUNTER_ATTR_RO(decomp_failed); | ||
1073 | NX842DEV_COUNTER_ATTR_RO(swdecomp); | ||
1074 | |||
1075 | static ssize_t nx842_timehist_show(struct device *, | ||
1076 | struct device_attribute *, char *); | ||
1077 | |||
1078 | static struct device_attribute dev_attr_comp_times = __ATTR(comp_times, 0444, | ||
1079 | nx842_timehist_show, NULL); | ||
1080 | static struct device_attribute dev_attr_decomp_times = __ATTR(decomp_times, | ||
1081 | 0444, nx842_timehist_show, NULL); | ||
1082 | |||
1083 | static ssize_t nx842_timehist_show(struct device *dev, | ||
1084 | struct device_attribute *attr, char *buf) { | ||
1085 | char *p = buf; | ||
1086 | struct nx842_devdata *local_devdata; | ||
1087 | atomic64_t *times; | ||
1088 | int bytes_remain = PAGE_SIZE; | ||
1089 | int bytes; | ||
1090 | int i; | ||
1091 | |||
1092 | rcu_read_lock(); | ||
1093 | local_devdata = rcu_dereference(devdata); | ||
1094 | if (!local_devdata) { | ||
1095 | rcu_read_unlock(); | ||
1096 | return 0; | ||
1097 | } | ||
1098 | |||
1099 | if (attr == &dev_attr_comp_times) | ||
1100 | times = local_devdata->counters->comp_times; | ||
1101 | else if (attr == &dev_attr_decomp_times) | ||
1102 | times = local_devdata->counters->decomp_times; | ||
1103 | else { | ||
1104 | rcu_read_unlock(); | ||
1105 | return 0; | ||
1106 | } | ||
1107 | |||
1108 | for (i = 0; i < (NX842_HIST_SLOTS - 2); i++) { | ||
1109 | bytes = snprintf(p, bytes_remain, "%u-%uus:\t%ld\n", | ||
1110 | i ? (2<<(i-1)) : 0, (2<<i)-1, | ||
1111 | atomic64_read(×[i])); | ||
1112 | bytes_remain -= bytes; | ||
1113 | p += bytes; | ||
1114 | } | ||
1115 | /* The last bucket holds everything over | ||
1116 | * 2<<(NX842_HIST_SLOTS - 2) us */ | ||
1117 | bytes = snprintf(p, bytes_remain, "%uus - :\t%ld\n", | ||
1118 | 2<<(NX842_HIST_SLOTS - 2), | ||
1119 | atomic64_read(×[(NX842_HIST_SLOTS - 1)])); | ||
1120 | p += bytes; | ||
1121 | |||
1122 | rcu_read_unlock(); | ||
1123 | return p - buf; | ||
1124 | } | ||
1125 | |||
1126 | static struct attribute *nx842_sysfs_entries[] = { | ||
1127 | &dev_attr_comp_complete.attr, | ||
1128 | &dev_attr_comp_failed.attr, | ||
1129 | &dev_attr_decomp_complete.attr, | ||
1130 | &dev_attr_decomp_failed.attr, | ||
1131 | &dev_attr_swdecomp.attr, | ||
1132 | &dev_attr_comp_times.attr, | ||
1133 | &dev_attr_decomp_times.attr, | ||
1134 | NULL, | ||
1135 | }; | ||
1136 | |||
1137 | static struct attribute_group nx842_attribute_group = { | ||
1138 | .name = NULL, /* put in device directory */ | ||
1139 | .attrs = nx842_sysfs_entries, | ||
1140 | }; | ||
1141 | |||
1142 | static int __init nx842_probe(struct vio_dev *viodev, | ||
1143 | const struct vio_device_id *id) | ||
1144 | { | ||
1145 | struct nx842_devdata *old_devdata, *new_devdata = NULL; | ||
1146 | unsigned long flags; | ||
1147 | int ret = 0; | ||
1148 | |||
1149 | spin_lock_irqsave(&devdata_mutex, flags); | ||
1150 | old_devdata = rcu_dereference_check(devdata, | ||
1151 | lockdep_is_held(&devdata_mutex)); | ||
1152 | |||
1153 | if (old_devdata && old_devdata->vdev != NULL) { | ||
1154 | dev_err(&viodev->dev, "%s: Attempt to register more than one instance of the hardware\n", __func__); | ||
1155 | ret = -1; | ||
1156 | goto error_unlock; | ||
1157 | } | ||
1158 | |||
1159 | dev_set_drvdata(&viodev->dev, NULL); | ||
1160 | |||
1161 | new_devdata = kzalloc(sizeof(*new_devdata), GFP_NOFS); | ||
1162 | if (!new_devdata) { | ||
1163 | dev_err(&viodev->dev, "%s: Could not allocate memory for device data\n", __func__); | ||
1164 | ret = -ENOMEM; | ||
1165 | goto error_unlock; | ||
1166 | } | ||
1167 | |||
1168 | new_devdata->counters = kzalloc(sizeof(*new_devdata->counters), | ||
1169 | GFP_NOFS); | ||
1170 | if (!new_devdata->counters) { | ||
1171 | dev_err(&viodev->dev, "%s: Could not allocate memory for performance counters\n", __func__); | ||
1172 | ret = -ENOMEM; | ||
1173 | goto error_unlock; | ||
1174 | } | ||
1175 | |||
1176 | new_devdata->vdev = viodev; | ||
1177 | new_devdata->dev = &viodev->dev; | ||
1178 | nx842_OF_set_defaults(new_devdata); | ||
1179 | |||
1180 | rcu_assign_pointer(devdata, new_devdata); | ||
1181 | spin_unlock_irqrestore(&devdata_mutex, flags); | ||
1182 | synchronize_rcu(); | ||
1183 | kfree(old_devdata); | ||
1184 | |||
1185 | pSeries_reconfig_notifier_register(&nx842_of_nb); | ||
1186 | |||
1187 | ret = nx842_OF_upd(NULL); | ||
1188 | if (ret && ret != -ENODEV) { | ||
1189 | dev_err(&viodev->dev, "could not parse device tree. %d\n", ret); | ||
1190 | ret = -1; | ||
1191 | goto error; | ||
1192 | } | ||
1193 | |||
1194 | rcu_read_lock(); | ||
1195 | if (dev_set_drvdata(&viodev->dev, rcu_dereference(devdata))) { | ||
1196 | rcu_read_unlock(); | ||
1197 | dev_err(&viodev->dev, "failed to set driver data for device\n"); | ||
1198 | ret = -1; | ||
1199 | goto error; | ||
1200 | } | ||
1201 | rcu_read_unlock(); | ||
1202 | |||
1203 | if (sysfs_create_group(&viodev->dev.kobj, &nx842_attribute_group)) { | ||
1204 | dev_err(&viodev->dev, "could not create sysfs device attributes\n"); | ||
1205 | ret = -1; | ||
1206 | goto error; | ||
1207 | } | ||
1208 | |||
1209 | return 0; | ||
1210 | |||
1211 | error_unlock: | ||
1212 | spin_unlock_irqrestore(&devdata_mutex, flags); | ||
1213 | if (new_devdata) | ||
1214 | kfree(new_devdata->counters); | ||
1215 | kfree(new_devdata); | ||
1216 | error: | ||
1217 | return ret; | ||
1218 | } | ||
1219 | |||
1220 | static int __exit nx842_remove(struct vio_dev *viodev) | ||
1221 | { | ||
1222 | struct nx842_devdata *old_devdata; | ||
1223 | unsigned long flags; | ||
1224 | |||
1225 | pr_info("Removing IBM Power 842 compression device\n"); | ||
1226 | sysfs_remove_group(&viodev->dev.kobj, &nx842_attribute_group); | ||
1227 | |||
1228 | spin_lock_irqsave(&devdata_mutex, flags); | ||
1229 | old_devdata = rcu_dereference_check(devdata, | ||
1230 | lockdep_is_held(&devdata_mutex)); | ||
1231 | pSeries_reconfig_notifier_unregister(&nx842_of_nb); | ||
1232 | rcu_assign_pointer(devdata, NULL); | ||
1233 | spin_unlock_irqrestore(&devdata_mutex, flags); | ||
1234 | synchronize_rcu(); | ||
1235 | dev_set_drvdata(&viodev->dev, NULL); | ||
1236 | if (old_devdata) | ||
1237 | kfree(old_devdata->counters); | ||
1238 | kfree(old_devdata); | ||
1239 | return 0; | ||
1240 | } | ||
1241 | |||
1242 | static struct vio_device_id nx842_driver_ids[] = { | ||
1243 | {"ibm,compression-v1", "ibm,compression"}, | ||
1244 | {"", ""}, | ||
1245 | }; | ||
1246 | |||
1247 | static struct vio_driver nx842_driver = { | ||
1248 | .name = MODULE_NAME, | ||
1249 | .probe = nx842_probe, | ||
1250 | .remove = nx842_remove, | ||
1251 | .get_desired_dma = nx842_get_desired_dma, | ||
1252 | .id_table = nx842_driver_ids, | ||
1253 | }; | ||
1254 | |||
1255 | static int __init nx842_init(void) | ||
1256 | { | ||
1257 | struct nx842_devdata *new_devdata; | ||
1258 | pr_info("Registering IBM Power 842 compression driver\n"); | ||
1259 | |||
1260 | RCU_INIT_POINTER(devdata, NULL); | ||
1261 | new_devdata = kzalloc(sizeof(*new_devdata), GFP_KERNEL); | ||
1262 | if (!new_devdata) { | ||
1263 | pr_err("Could not allocate memory for device data\n"); | ||
1264 | return -ENOMEM; | ||
1265 | } | ||
1266 | new_devdata->status = UNAVAILABLE; | ||
1267 | RCU_INIT_POINTER(devdata, new_devdata); | ||
1268 | |||
1269 | return vio_register_driver(&nx842_driver); | ||
1270 | } | ||
1271 | |||
1272 | module_init(nx842_init); | ||
1273 | |||
1274 | static void __exit nx842_exit(void) | ||
1275 | { | ||
1276 | struct nx842_devdata *old_devdata; | ||
1277 | unsigned long flags; | ||
1278 | |||
1279 | pr_info("Exiting IBM Power 842 compression driver\n"); | ||
1280 | spin_lock_irqsave(&devdata_mutex, flags); | ||
1281 | old_devdata = rcu_dereference_check(devdata, | ||
1282 | lockdep_is_held(&devdata_mutex)); | ||
1283 | rcu_assign_pointer(devdata, NULL); | ||
1284 | spin_unlock_irqrestore(&devdata_mutex, flags); | ||
1285 | synchronize_rcu(); | ||
1286 | if (old_devdata) | ||
1287 | dev_set_drvdata(old_devdata->dev, NULL); | ||
1288 | kfree(old_devdata); | ||
1289 | vio_unregister_driver(&nx842_driver); | ||
1290 | } | ||
1291 | |||
1292 | module_exit(nx842_exit); | ||
1293 | |||
1294 | /********************************* | ||
1295 | * 842 software decompressor | ||
1296 | *********************************/ | ||
1297 | typedef int (*sw842_template_op)(const char **, int *, unsigned char **, | ||
1298 | struct sw842_fifo *); | ||
1299 | |||
1300 | static int sw842_data8(const char **, int *, unsigned char **, | ||
1301 | struct sw842_fifo *); | ||
1302 | static int sw842_data4(const char **, int *, unsigned char **, | ||
1303 | struct sw842_fifo *); | ||
1304 | static int sw842_data2(const char **, int *, unsigned char **, | ||
1305 | struct sw842_fifo *); | ||
1306 | static int sw842_ptr8(const char **, int *, unsigned char **, | ||
1307 | struct sw842_fifo *); | ||
1308 | static int sw842_ptr4(const char **, int *, unsigned char **, | ||
1309 | struct sw842_fifo *); | ||
1310 | static int sw842_ptr2(const char **, int *, unsigned char **, | ||
1311 | struct sw842_fifo *); | ||
1312 | |||
1313 | /* special templates */ | ||
1314 | #define SW842_TMPL_REPEAT 0x1B | ||
1315 | #define SW842_TMPL_ZEROS 0x1C | ||
1316 | #define SW842_TMPL_EOF 0x1E | ||
1317 | |||
1318 | static sw842_template_op sw842_tmpl_ops[26][4] = { | ||
1319 | { sw842_data8, NULL}, /* 0 (00000) */ | ||
1320 | { sw842_data4, sw842_data2, sw842_ptr2, NULL}, | ||
1321 | { sw842_data4, sw842_ptr2, sw842_data2, NULL}, | ||
1322 | { sw842_data4, sw842_ptr2, sw842_ptr2, NULL}, | ||
1323 | { sw842_data4, sw842_ptr4, NULL}, | ||
1324 | { sw842_data2, sw842_ptr2, sw842_data4, NULL}, | ||
1325 | { sw842_data2, sw842_ptr2, sw842_data2, sw842_ptr2}, | ||
1326 | { sw842_data2, sw842_ptr2, sw842_ptr2, sw842_data2}, | ||
1327 | { sw842_data2, sw842_ptr2, sw842_ptr2, sw842_ptr2,}, | ||
1328 | { sw842_data2, sw842_ptr2, sw842_ptr4, NULL}, | ||
1329 | { sw842_ptr2, sw842_data2, sw842_data4, NULL}, /* 10 (01010) */ | ||
1330 | { sw842_ptr2, sw842_data4, sw842_ptr2, NULL}, | ||
1331 | { sw842_ptr2, sw842_data2, sw842_ptr2, sw842_data2}, | ||
1332 | { sw842_ptr2, sw842_data2, sw842_ptr2, sw842_ptr2}, | ||
1333 | { sw842_ptr2, sw842_data2, sw842_ptr4, NULL}, | ||
1334 | { sw842_ptr2, sw842_ptr2, sw842_data4, NULL}, | ||
1335 | { sw842_ptr2, sw842_ptr2, sw842_data2, sw842_ptr2}, | ||
1336 | { sw842_ptr2, sw842_ptr2, sw842_ptr2, sw842_data2}, | ||
1337 | { sw842_ptr2, sw842_ptr2, sw842_ptr2, sw842_ptr2}, | ||
1338 | { sw842_ptr2, sw842_ptr2, sw842_ptr4, NULL}, | ||
1339 | { sw842_ptr4, sw842_data4, NULL}, /* 20 (10100) */ | ||
1340 | { sw842_ptr4, sw842_data2, sw842_ptr2, NULL}, | ||
1341 | { sw842_ptr4, sw842_ptr2, sw842_data2, NULL}, | ||
1342 | { sw842_ptr4, sw842_ptr2, sw842_ptr2, NULL}, | ||
1343 | { sw842_ptr4, sw842_ptr4, NULL}, | ||
1344 | { sw842_ptr8, NULL} | ||
1345 | }; | ||
1346 | |||
1347 | /* Software decompress helpers */ | ||
1348 | |||
1349 | static uint8_t sw842_get_byte(const char *buf, int bit) | ||
1350 | { | ||
1351 | uint8_t tmpl; | ||
1352 | uint16_t tmp; | ||
1353 | tmp = htons(*(uint16_t *)(buf)); | ||
1354 | tmp = (uint16_t)(tmp << bit); | ||
1355 | tmp = ntohs(tmp); | ||
1356 | memcpy(&tmpl, &tmp, 1); | ||
1357 | return tmpl; | ||
1358 | } | ||
1359 | |||
1360 | static uint8_t sw842_get_template(const char **buf, int *bit) | ||
1361 | { | ||
1362 | uint8_t byte; | ||
1363 | byte = sw842_get_byte(*buf, *bit); | ||
1364 | byte = byte >> 3; | ||
1365 | byte &= 0x1F; | ||
1366 | *buf += (*bit + 5) / 8; | ||
1367 | *bit = (*bit + 5) % 8; | ||
1368 | return byte; | ||
1369 | } | ||
1370 | |||
1371 | /* repeat_count happens to be 5-bit too (like the template) */ | ||
1372 | static uint8_t sw842_get_repeat_count(const char **buf, int *bit) | ||
1373 | { | ||
1374 | uint8_t byte; | ||
1375 | byte = sw842_get_byte(*buf, *bit); | ||
1376 | byte = byte >> 2; | ||
1377 | byte &= 0x3F; | ||
1378 | *buf += (*bit + 6) / 8; | ||
1379 | *bit = (*bit + 6) % 8; | ||
1380 | return byte; | ||
1381 | } | ||
1382 | |||
1383 | static uint8_t sw842_get_ptr2(const char **buf, int *bit) | ||
1384 | { | ||
1385 | uint8_t ptr; | ||
1386 | ptr = sw842_get_byte(*buf, *bit); | ||
1387 | (*buf)++; | ||
1388 | return ptr; | ||
1389 | } | ||
1390 | |||
1391 | static uint16_t sw842_get_ptr4(const char **buf, int *bit, | ||
1392 | struct sw842_fifo *fifo) | ||
1393 | { | ||
1394 | uint16_t ptr; | ||
1395 | ptr = htons(*(uint16_t *)(*buf)); | ||
1396 | ptr = (uint16_t)(ptr << *bit); | ||
1397 | ptr = ptr >> 7; | ||
1398 | ptr &= 0x01FF; | ||
1399 | *buf += (*bit + 9) / 8; | ||
1400 | *bit = (*bit + 9) % 8; | ||
1401 | return ptr; | ||
1402 | } | ||
1403 | |||
1404 | static uint8_t sw842_get_ptr8(const char **buf, int *bit, | ||
1405 | struct sw842_fifo *fifo) | ||
1406 | { | ||
1407 | return sw842_get_ptr2(buf, bit); | ||
1408 | } | ||
1409 | |||
1410 | /* Software decompress template ops */ | ||
1411 | |||
1412 | static int sw842_data8(const char **inbuf, int *inbit, | ||
1413 | unsigned char **outbuf, struct sw842_fifo *fifo) | ||
1414 | { | ||
1415 | int ret; | ||
1416 | |||
1417 | ret = sw842_data4(inbuf, inbit, outbuf, fifo); | ||
1418 | if (ret) | ||
1419 | return ret; | ||
1420 | ret = sw842_data4(inbuf, inbit, outbuf, fifo); | ||
1421 | return ret; | ||
1422 | } | ||
1423 | |||
1424 | static int sw842_data4(const char **inbuf, int *inbit, | ||
1425 | unsigned char **outbuf, struct sw842_fifo *fifo) | ||
1426 | { | ||
1427 | int ret; | ||
1428 | |||
1429 | ret = sw842_data2(inbuf, inbit, outbuf, fifo); | ||
1430 | if (ret) | ||
1431 | return ret; | ||
1432 | ret = sw842_data2(inbuf, inbit, outbuf, fifo); | ||
1433 | return ret; | ||
1434 | } | ||
1435 | |||
1436 | static int sw842_data2(const char **inbuf, int *inbit, | ||
1437 | unsigned char **outbuf, struct sw842_fifo *fifo) | ||
1438 | { | ||
1439 | **outbuf = sw842_get_byte(*inbuf, *inbit); | ||
1440 | (*inbuf)++; | ||
1441 | (*outbuf)++; | ||
1442 | **outbuf = sw842_get_byte(*inbuf, *inbit); | ||
1443 | (*inbuf)++; | ||
1444 | (*outbuf)++; | ||
1445 | return 0; | ||
1446 | } | ||
1447 | |||
1448 | static int sw842_ptr8(const char **inbuf, int *inbit, | ||
1449 | unsigned char **outbuf, struct sw842_fifo *fifo) | ||
1450 | { | ||
1451 | uint8_t ptr; | ||
1452 | ptr = sw842_get_ptr8(inbuf, inbit, fifo); | ||
1453 | if (!fifo->f84_full && (ptr >= fifo->f8_count)) | ||
1454 | return 1; | ||
1455 | memcpy(*outbuf, fifo->f8[ptr], 8); | ||
1456 | *outbuf += 8; | ||
1457 | return 0; | ||
1458 | } | ||
1459 | |||
1460 | static int sw842_ptr4(const char **inbuf, int *inbit, | ||
1461 | unsigned char **outbuf, struct sw842_fifo *fifo) | ||
1462 | { | ||
1463 | uint16_t ptr; | ||
1464 | ptr = sw842_get_ptr4(inbuf, inbit, fifo); | ||
1465 | if (!fifo->f84_full && (ptr >= fifo->f4_count)) | ||
1466 | return 1; | ||
1467 | memcpy(*outbuf, fifo->f4[ptr], 4); | ||
1468 | *outbuf += 4; | ||
1469 | return 0; | ||
1470 | } | ||
1471 | |||
1472 | static int sw842_ptr2(const char **inbuf, int *inbit, | ||
1473 | unsigned char **outbuf, struct sw842_fifo *fifo) | ||
1474 | { | ||
1475 | uint8_t ptr; | ||
1476 | ptr = sw842_get_ptr2(inbuf, inbit); | ||
1477 | if (!fifo->f2_full && (ptr >= fifo->f2_count)) | ||
1478 | return 1; | ||
1479 | memcpy(*outbuf, fifo->f2[ptr], 2); | ||
1480 | *outbuf += 2; | ||
1481 | return 0; | ||
1482 | } | ||
1483 | |||
1484 | static void sw842_copy_to_fifo(const char *buf, struct sw842_fifo *fifo) | ||
1485 | { | ||
1486 | unsigned char initial_f2count = fifo->f2_count; | ||
1487 | |||
1488 | memcpy(fifo->f8[fifo->f8_count], buf, 8); | ||
1489 | fifo->f4_count += 2; | ||
1490 | fifo->f8_count += 1; | ||
1491 | |||
1492 | if (!fifo->f84_full && fifo->f4_count >= 512) { | ||
1493 | fifo->f84_full = 1; | ||
1494 | fifo->f4_count /= 512; | ||
1495 | } | ||
1496 | |||
1497 | memcpy(fifo->f2[fifo->f2_count++], buf, 2); | ||
1498 | memcpy(fifo->f2[fifo->f2_count++], buf + 2, 2); | ||
1499 | memcpy(fifo->f2[fifo->f2_count++], buf + 4, 2); | ||
1500 | memcpy(fifo->f2[fifo->f2_count++], buf + 6, 2); | ||
1501 | if (fifo->f2_count < initial_f2count) | ||
1502 | fifo->f2_full = 1; | ||
1503 | } | ||
1504 | |||
1505 | static int sw842_decompress(const unsigned char *src, int srclen, | ||
1506 | unsigned char *dst, int *destlen, | ||
1507 | const void *wrkmem) | ||
1508 | { | ||
1509 | uint8_t tmpl; | ||
1510 | const char *inbuf; | ||
1511 | int inbit = 0; | ||
1512 | unsigned char *outbuf, *outbuf_end, *origbuf, *prevbuf; | ||
1513 | const char *inbuf_end; | ||
1514 | sw842_template_op op; | ||
1515 | int opindex; | ||
1516 | int i, repeat_count; | ||
1517 | struct sw842_fifo *fifo; | ||
1518 | int ret = 0; | ||
1519 | |||
1520 | fifo = &((struct nx842_workmem *)(wrkmem))->swfifo; | ||
1521 | memset(fifo, 0, sizeof(*fifo)); | ||
1522 | |||
1523 | origbuf = NULL; | ||
1524 | inbuf = src; | ||
1525 | inbuf_end = src + srclen; | ||
1526 | outbuf = dst; | ||
1527 | outbuf_end = dst + *destlen; | ||
1528 | |||
1529 | while ((tmpl = sw842_get_template(&inbuf, &inbit)) != SW842_TMPL_EOF) { | ||
1530 | if (inbuf >= inbuf_end) { | ||
1531 | ret = -EINVAL; | ||
1532 | goto out; | ||
1533 | } | ||
1534 | |||
1535 | opindex = 0; | ||
1536 | prevbuf = origbuf; | ||
1537 | origbuf = outbuf; | ||
1538 | switch (tmpl) { | ||
1539 | case SW842_TMPL_REPEAT: | ||
1540 | if (prevbuf == NULL) { | ||
1541 | ret = -EINVAL; | ||
1542 | goto out; | ||
1543 | } | ||
1544 | |||
1545 | repeat_count = sw842_get_repeat_count(&inbuf, | ||
1546 | &inbit) + 1; | ||
1547 | |||
1548 | /* Did the repeat count advance past the end of input */ | ||
1549 | if (inbuf > inbuf_end) { | ||
1550 | ret = -EINVAL; | ||
1551 | goto out; | ||
1552 | } | ||
1553 | |||
1554 | for (i = 0; i < repeat_count; i++) { | ||
1555 | /* Would this overflow the output buffer */ | ||
1556 | if ((outbuf + 8) > outbuf_end) { | ||
1557 | ret = -ENOSPC; | ||
1558 | goto out; | ||
1559 | } | ||
1560 | |||
1561 | memcpy(outbuf, prevbuf, 8); | ||
1562 | sw842_copy_to_fifo(outbuf, fifo); | ||
1563 | outbuf += 8; | ||
1564 | } | ||
1565 | break; | ||
1566 | |||
1567 | case SW842_TMPL_ZEROS: | ||
1568 | /* Would this overflow the output buffer */ | ||
1569 | if ((outbuf + 8) > outbuf_end) { | ||
1570 | ret = -ENOSPC; | ||
1571 | goto out; | ||
1572 | } | ||
1573 | |||
1574 | memset(outbuf, 0, 8); | ||
1575 | sw842_copy_to_fifo(outbuf, fifo); | ||
1576 | outbuf += 8; | ||
1577 | break; | ||
1578 | |||
1579 | default: | ||
1580 | if (tmpl > 25) { | ||
1581 | ret = -EINVAL; | ||
1582 | goto out; | ||
1583 | } | ||
1584 | |||
1585 | /* Does this go past the end of the input buffer */ | ||
1586 | if ((inbuf + 2) > inbuf_end) { | ||
1587 | ret = -EINVAL; | ||
1588 | goto out; | ||
1589 | } | ||
1590 | |||
1591 | /* Would this overflow the output buffer */ | ||
1592 | if ((outbuf + 8) > outbuf_end) { | ||
1593 | ret = -ENOSPC; | ||
1594 | goto out; | ||
1595 | } | ||
1596 | |||
1597 | while (opindex < 4 && | ||
1598 | (op = sw842_tmpl_ops[tmpl][opindex++]) | ||
1599 | != NULL) { | ||
1600 | ret = (*op)(&inbuf, &inbit, &outbuf, fifo); | ||
1601 | if (ret) { | ||
1602 | ret = -EINVAL; | ||
1603 | goto out; | ||
1604 | } | ||
1605 | sw842_copy_to_fifo(origbuf, fifo); | ||
1606 | } | ||
1607 | } | ||
1608 | } | ||
1609 | |||
1610 | out: | ||
1611 | if (!ret) | ||
1612 | *destlen = (unsigned int)(outbuf - dst); | ||
1613 | else | ||
1614 | *destlen = 0; | ||
1615 | |||
1616 | return ret; | ||
1617 | } | ||
diff --git a/drivers/crypto/nx/nx-aes-cbc.c b/drivers/crypto/nx/nx-aes-cbc.c index 69ed796ee327..a76d4c4f29f5 100644 --- a/drivers/crypto/nx/nx-aes-cbc.c +++ b/drivers/crypto/nx/nx-aes-cbc.c | |||
@@ -127,7 +127,6 @@ struct crypto_alg nx_cbc_aes_alg = { | |||
127 | .cra_ctxsize = sizeof(struct nx_crypto_ctx), | 127 | .cra_ctxsize = sizeof(struct nx_crypto_ctx), |
128 | .cra_type = &crypto_blkcipher_type, | 128 | .cra_type = &crypto_blkcipher_type, |
129 | .cra_module = THIS_MODULE, | 129 | .cra_module = THIS_MODULE, |
130 | .cra_list = LIST_HEAD_INIT(nx_cbc_aes_alg.cra_list), | ||
131 | .cra_init = nx_crypto_ctx_aes_cbc_init, | 130 | .cra_init = nx_crypto_ctx_aes_cbc_init, |
132 | .cra_exit = nx_crypto_ctx_exit, | 131 | .cra_exit = nx_crypto_ctx_exit, |
133 | .cra_blkcipher = { | 132 | .cra_blkcipher = { |
diff --git a/drivers/crypto/nx/nx-aes-ccm.c b/drivers/crypto/nx/nx-aes-ccm.c index 7aeac678b9c0..ef5eae6d1400 100644 --- a/drivers/crypto/nx/nx-aes-ccm.c +++ b/drivers/crypto/nx/nx-aes-ccm.c | |||
@@ -430,7 +430,6 @@ struct crypto_alg nx_ccm_aes_alg = { | |||
430 | .cra_ctxsize = sizeof(struct nx_crypto_ctx), | 430 | .cra_ctxsize = sizeof(struct nx_crypto_ctx), |
431 | .cra_type = &crypto_aead_type, | 431 | .cra_type = &crypto_aead_type, |
432 | .cra_module = THIS_MODULE, | 432 | .cra_module = THIS_MODULE, |
433 | .cra_list = LIST_HEAD_INIT(nx_ccm_aes_alg.cra_list), | ||
434 | .cra_init = nx_crypto_ctx_aes_ccm_init, | 433 | .cra_init = nx_crypto_ctx_aes_ccm_init, |
435 | .cra_exit = nx_crypto_ctx_exit, | 434 | .cra_exit = nx_crypto_ctx_exit, |
436 | .cra_aead = { | 435 | .cra_aead = { |
@@ -453,7 +452,6 @@ struct crypto_alg nx_ccm4309_aes_alg = { | |||
453 | .cra_ctxsize = sizeof(struct nx_crypto_ctx), | 452 | .cra_ctxsize = sizeof(struct nx_crypto_ctx), |
454 | .cra_type = &crypto_nivaead_type, | 453 | .cra_type = &crypto_nivaead_type, |
455 | .cra_module = THIS_MODULE, | 454 | .cra_module = THIS_MODULE, |
456 | .cra_list = LIST_HEAD_INIT(nx_ccm4309_aes_alg.cra_list), | ||
457 | .cra_init = nx_crypto_ctx_aes_ccm_init, | 455 | .cra_init = nx_crypto_ctx_aes_ccm_init, |
458 | .cra_exit = nx_crypto_ctx_exit, | 456 | .cra_exit = nx_crypto_ctx_exit, |
459 | .cra_aead = { | 457 | .cra_aead = { |
diff --git a/drivers/crypto/nx/nx-aes-ctr.c b/drivers/crypto/nx/nx-aes-ctr.c index 52d4eb05e8f7..b6286f14680b 100644 --- a/drivers/crypto/nx/nx-aes-ctr.c +++ b/drivers/crypto/nx/nx-aes-ctr.c | |||
@@ -141,7 +141,6 @@ struct crypto_alg nx_ctr_aes_alg = { | |||
141 | .cra_ctxsize = sizeof(struct nx_crypto_ctx), | 141 | .cra_ctxsize = sizeof(struct nx_crypto_ctx), |
142 | .cra_type = &crypto_blkcipher_type, | 142 | .cra_type = &crypto_blkcipher_type, |
143 | .cra_module = THIS_MODULE, | 143 | .cra_module = THIS_MODULE, |
144 | .cra_list = LIST_HEAD_INIT(nx_ctr_aes_alg.cra_list), | ||
145 | .cra_init = nx_crypto_ctx_aes_ctr_init, | 144 | .cra_init = nx_crypto_ctx_aes_ctr_init, |
146 | .cra_exit = nx_crypto_ctx_exit, | 145 | .cra_exit = nx_crypto_ctx_exit, |
147 | .cra_blkcipher = { | 146 | .cra_blkcipher = { |
@@ -163,7 +162,6 @@ struct crypto_alg nx_ctr3686_aes_alg = { | |||
163 | .cra_ctxsize = sizeof(struct nx_crypto_ctx), | 162 | .cra_ctxsize = sizeof(struct nx_crypto_ctx), |
164 | .cra_type = &crypto_blkcipher_type, | 163 | .cra_type = &crypto_blkcipher_type, |
165 | .cra_module = THIS_MODULE, | 164 | .cra_module = THIS_MODULE, |
166 | .cra_list = LIST_HEAD_INIT(nx_ctr3686_aes_alg.cra_list), | ||
167 | .cra_init = nx_crypto_ctx_aes_ctr_init, | 165 | .cra_init = nx_crypto_ctx_aes_ctr_init, |
168 | .cra_exit = nx_crypto_ctx_exit, | 166 | .cra_exit = nx_crypto_ctx_exit, |
169 | .cra_blkcipher = { | 167 | .cra_blkcipher = { |
diff --git a/drivers/crypto/nx/nx-aes-ecb.c b/drivers/crypto/nx/nx-aes-ecb.c index 7b77bc2d1df4..ba5f1611336f 100644 --- a/drivers/crypto/nx/nx-aes-ecb.c +++ b/drivers/crypto/nx/nx-aes-ecb.c | |||
@@ -126,7 +126,6 @@ struct crypto_alg nx_ecb_aes_alg = { | |||
126 | .cra_ctxsize = sizeof(struct nx_crypto_ctx), | 126 | .cra_ctxsize = sizeof(struct nx_crypto_ctx), |
127 | .cra_type = &crypto_blkcipher_type, | 127 | .cra_type = &crypto_blkcipher_type, |
128 | .cra_module = THIS_MODULE, | 128 | .cra_module = THIS_MODULE, |
129 | .cra_list = LIST_HEAD_INIT(nx_ecb_aes_alg.cra_list), | ||
130 | .cra_init = nx_crypto_ctx_aes_ecb_init, | 129 | .cra_init = nx_crypto_ctx_aes_ecb_init, |
131 | .cra_exit = nx_crypto_ctx_exit, | 130 | .cra_exit = nx_crypto_ctx_exit, |
132 | .cra_blkcipher = { | 131 | .cra_blkcipher = { |
diff --git a/drivers/crypto/nx/nx-aes-gcm.c b/drivers/crypto/nx/nx-aes-gcm.c index 9ab1c7341dac..c8109edc5cfb 100644 --- a/drivers/crypto/nx/nx-aes-gcm.c +++ b/drivers/crypto/nx/nx-aes-gcm.c | |||
@@ -316,7 +316,6 @@ struct crypto_alg nx_gcm_aes_alg = { | |||
316 | .cra_ctxsize = sizeof(struct nx_crypto_ctx), | 316 | .cra_ctxsize = sizeof(struct nx_crypto_ctx), |
317 | .cra_type = &crypto_aead_type, | 317 | .cra_type = &crypto_aead_type, |
318 | .cra_module = THIS_MODULE, | 318 | .cra_module = THIS_MODULE, |
319 | .cra_list = LIST_HEAD_INIT(nx_gcm_aes_alg.cra_list), | ||
320 | .cra_init = nx_crypto_ctx_aes_gcm_init, | 319 | .cra_init = nx_crypto_ctx_aes_gcm_init, |
321 | .cra_exit = nx_crypto_ctx_exit, | 320 | .cra_exit = nx_crypto_ctx_exit, |
322 | .cra_aead = { | 321 | .cra_aead = { |
@@ -338,7 +337,6 @@ struct crypto_alg nx_gcm4106_aes_alg = { | |||
338 | .cra_ctxsize = sizeof(struct nx_crypto_ctx), | 337 | .cra_ctxsize = sizeof(struct nx_crypto_ctx), |
339 | .cra_type = &crypto_nivaead_type, | 338 | .cra_type = &crypto_nivaead_type, |
340 | .cra_module = THIS_MODULE, | 339 | .cra_module = THIS_MODULE, |
341 | .cra_list = LIST_HEAD_INIT(nx_gcm4106_aes_alg.cra_list), | ||
342 | .cra_init = nx_crypto_ctx_aes_gcm_init, | 340 | .cra_init = nx_crypto_ctx_aes_gcm_init, |
343 | .cra_exit = nx_crypto_ctx_exit, | 341 | .cra_exit = nx_crypto_ctx_exit, |
344 | .cra_aead = { | 342 | .cra_aead = { |
diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c index 63e57b57a12c..093a8af59cbe 100644 --- a/drivers/crypto/omap-aes.c +++ b/drivers/crypto/omap-aes.c | |||
@@ -876,7 +876,6 @@ static int omap_aes_probe(struct platform_device *pdev) | |||
876 | 876 | ||
877 | for (i = 0; i < ARRAY_SIZE(algs); i++) { | 877 | for (i = 0; i < ARRAY_SIZE(algs); i++) { |
878 | pr_debug("i: %d\n", i); | 878 | pr_debug("i: %d\n", i); |
879 | INIT_LIST_HEAD(&algs[i].cra_list); | ||
880 | err = crypto_register_alg(&algs[i]); | 879 | err = crypto_register_alg(&algs[i]); |
881 | if (err) | 880 | if (err) |
882 | goto err_algs; | 881 | goto err_algs; |
diff --git a/drivers/crypto/padlock-aes.c b/drivers/crypto/padlock-aes.c index 37b2e9406af6..633ba945e153 100644 --- a/drivers/crypto/padlock-aes.c +++ b/drivers/crypto/padlock-aes.c | |||
@@ -328,7 +328,6 @@ static struct crypto_alg aes_alg = { | |||
328 | .cra_ctxsize = sizeof(struct aes_ctx), | 328 | .cra_ctxsize = sizeof(struct aes_ctx), |
329 | .cra_alignmask = PADLOCK_ALIGNMENT - 1, | 329 | .cra_alignmask = PADLOCK_ALIGNMENT - 1, |
330 | .cra_module = THIS_MODULE, | 330 | .cra_module = THIS_MODULE, |
331 | .cra_list = LIST_HEAD_INIT(aes_alg.cra_list), | ||
332 | .cra_u = { | 331 | .cra_u = { |
333 | .cipher = { | 332 | .cipher = { |
334 | .cia_min_keysize = AES_MIN_KEY_SIZE, | 333 | .cia_min_keysize = AES_MIN_KEY_SIZE, |
@@ -408,7 +407,6 @@ static struct crypto_alg ecb_aes_alg = { | |||
408 | .cra_alignmask = PADLOCK_ALIGNMENT - 1, | 407 | .cra_alignmask = PADLOCK_ALIGNMENT - 1, |
409 | .cra_type = &crypto_blkcipher_type, | 408 | .cra_type = &crypto_blkcipher_type, |
410 | .cra_module = THIS_MODULE, | 409 | .cra_module = THIS_MODULE, |
411 | .cra_list = LIST_HEAD_INIT(ecb_aes_alg.cra_list), | ||
412 | .cra_u = { | 410 | .cra_u = { |
413 | .blkcipher = { | 411 | .blkcipher = { |
414 | .min_keysize = AES_MIN_KEY_SIZE, | 412 | .min_keysize = AES_MIN_KEY_SIZE, |
@@ -491,7 +489,6 @@ static struct crypto_alg cbc_aes_alg = { | |||
491 | .cra_alignmask = PADLOCK_ALIGNMENT - 1, | 489 | .cra_alignmask = PADLOCK_ALIGNMENT - 1, |
492 | .cra_type = &crypto_blkcipher_type, | 490 | .cra_type = &crypto_blkcipher_type, |
493 | .cra_module = THIS_MODULE, | 491 | .cra_module = THIS_MODULE, |
494 | .cra_list = LIST_HEAD_INIT(cbc_aes_alg.cra_list), | ||
495 | .cra_u = { | 492 | .cra_u = { |
496 | .blkcipher = { | 493 | .blkcipher = { |
497 | .min_keysize = AES_MIN_KEY_SIZE, | 494 | .min_keysize = AES_MIN_KEY_SIZE, |
diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c index bc986f806086..a22714412cda 100644 --- a/drivers/crypto/s5p-sss.c +++ b/drivers/crypto/s5p-sss.c | |||
@@ -626,7 +626,6 @@ static int s5p_aes_probe(struct platform_device *pdev) | |||
626 | crypto_init_queue(&pdata->queue, CRYPTO_QUEUE_LEN); | 626 | crypto_init_queue(&pdata->queue, CRYPTO_QUEUE_LEN); |
627 | 627 | ||
628 | for (i = 0; i < ARRAY_SIZE(algs); i++) { | 628 | for (i = 0; i < ARRAY_SIZE(algs); i++) { |
629 | INIT_LIST_HEAD(&algs[i].cra_list); | ||
630 | err = crypto_register_alg(&algs[i]); | 629 | err = crypto_register_alg(&algs[i]); |
631 | if (err) | 630 | if (err) |
632 | goto err_algs; | 631 | goto err_algs; |
diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index efff788d2f1d..da1112765a44 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/spinlock.h> | 38 | #include <linux/spinlock.h> |
39 | #include <linux/rtnetlink.h> | 39 | #include <linux/rtnetlink.h> |
40 | #include <linux/slab.h> | 40 | #include <linux/slab.h> |
41 | #include <linux/string.h> | ||
41 | 42 | ||
42 | #include <crypto/algapi.h> | 43 | #include <crypto/algapi.h> |
43 | #include <crypto/aes.h> | 44 | #include <crypto/aes.h> |
@@ -714,8 +715,13 @@ badkey: | |||
714 | 715 | ||
715 | /* | 716 | /* |
716 | * talitos_edesc - s/w-extended descriptor | 717 | * talitos_edesc - s/w-extended descriptor |
718 | * @assoc_nents: number of segments in associated data scatterlist | ||
717 | * @src_nents: number of segments in input scatterlist | 719 | * @src_nents: number of segments in input scatterlist |
718 | * @dst_nents: number of segments in output scatterlist | 720 | * @dst_nents: number of segments in output scatterlist |
721 | * @assoc_chained: whether assoc is chained or not | ||
722 | * @src_chained: whether src is chained or not | ||
723 | * @dst_chained: whether dst is chained or not | ||
724 | * @iv_dma: dma address of iv for checking continuity and link table | ||
719 | * @dma_len: length of dma mapped link_tbl space | 725 | * @dma_len: length of dma mapped link_tbl space |
720 | * @dma_link_tbl: bus physical address of link_tbl | 726 | * @dma_link_tbl: bus physical address of link_tbl |
721 | * @desc: h/w descriptor | 727 | * @desc: h/w descriptor |
@@ -726,10 +732,13 @@ badkey: | |||
726 | * of link_tbl data | 732 | * of link_tbl data |
727 | */ | 733 | */ |
728 | struct talitos_edesc { | 734 | struct talitos_edesc { |
735 | int assoc_nents; | ||
729 | int src_nents; | 736 | int src_nents; |
730 | int dst_nents; | 737 | int dst_nents; |
731 | int src_is_chained; | 738 | bool assoc_chained; |
732 | int dst_is_chained; | 739 | bool src_chained; |
740 | bool dst_chained; | ||
741 | dma_addr_t iv_dma; | ||
733 | int dma_len; | 742 | int dma_len; |
734 | dma_addr_t dma_link_tbl; | 743 | dma_addr_t dma_link_tbl; |
735 | struct talitos_desc desc; | 744 | struct talitos_desc desc; |
@@ -738,7 +747,7 @@ struct talitos_edesc { | |||
738 | 747 | ||
739 | static int talitos_map_sg(struct device *dev, struct scatterlist *sg, | 748 | static int talitos_map_sg(struct device *dev, struct scatterlist *sg, |
740 | unsigned int nents, enum dma_data_direction dir, | 749 | unsigned int nents, enum dma_data_direction dir, |
741 | int chained) | 750 | bool chained) |
742 | { | 751 | { |
743 | if (unlikely(chained)) | 752 | if (unlikely(chained)) |
744 | while (sg) { | 753 | while (sg) { |
@@ -768,13 +777,13 @@ static void talitos_sg_unmap(struct device *dev, | |||
768 | unsigned int dst_nents = edesc->dst_nents ? : 1; | 777 | unsigned int dst_nents = edesc->dst_nents ? : 1; |
769 | 778 | ||
770 | if (src != dst) { | 779 | if (src != dst) { |
771 | if (edesc->src_is_chained) | 780 | if (edesc->src_chained) |
772 | talitos_unmap_sg_chain(dev, src, DMA_TO_DEVICE); | 781 | talitos_unmap_sg_chain(dev, src, DMA_TO_DEVICE); |
773 | else | 782 | else |
774 | dma_unmap_sg(dev, src, src_nents, DMA_TO_DEVICE); | 783 | dma_unmap_sg(dev, src, src_nents, DMA_TO_DEVICE); |
775 | 784 | ||
776 | if (dst) { | 785 | if (dst) { |
777 | if (edesc->dst_is_chained) | 786 | if (edesc->dst_chained) |
778 | talitos_unmap_sg_chain(dev, dst, | 787 | talitos_unmap_sg_chain(dev, dst, |
779 | DMA_FROM_DEVICE); | 788 | DMA_FROM_DEVICE); |
780 | else | 789 | else |
@@ -782,7 +791,7 @@ static void talitos_sg_unmap(struct device *dev, | |||
782 | DMA_FROM_DEVICE); | 791 | DMA_FROM_DEVICE); |
783 | } | 792 | } |
784 | } else | 793 | } else |
785 | if (edesc->src_is_chained) | 794 | if (edesc->src_chained) |
786 | talitos_unmap_sg_chain(dev, src, DMA_BIDIRECTIONAL); | 795 | talitos_unmap_sg_chain(dev, src, DMA_BIDIRECTIONAL); |
787 | else | 796 | else |
788 | dma_unmap_sg(dev, src, src_nents, DMA_BIDIRECTIONAL); | 797 | dma_unmap_sg(dev, src, src_nents, DMA_BIDIRECTIONAL); |
@@ -797,7 +806,13 @@ static void ipsec_esp_unmap(struct device *dev, | |||
797 | unmap_single_talitos_ptr(dev, &edesc->desc.ptr[2], DMA_TO_DEVICE); | 806 | unmap_single_talitos_ptr(dev, &edesc->desc.ptr[2], DMA_TO_DEVICE); |
798 | unmap_single_talitos_ptr(dev, &edesc->desc.ptr[0], DMA_TO_DEVICE); | 807 | unmap_single_talitos_ptr(dev, &edesc->desc.ptr[0], DMA_TO_DEVICE); |
799 | 808 | ||
800 | dma_unmap_sg(dev, areq->assoc, 1, DMA_TO_DEVICE); | 809 | if (edesc->assoc_chained) |
810 | talitos_unmap_sg_chain(dev, areq->assoc, DMA_TO_DEVICE); | ||
811 | else | ||
812 | /* assoc_nents counts also for IV in non-contiguous cases */ | ||
813 | dma_unmap_sg(dev, areq->assoc, | ||
814 | edesc->assoc_nents ? edesc->assoc_nents - 1 : 1, | ||
815 | DMA_TO_DEVICE); | ||
801 | 816 | ||
802 | talitos_sg_unmap(dev, edesc, areq->src, areq->dst); | 817 | talitos_sg_unmap(dev, edesc, areq->src, areq->dst); |
803 | 818 | ||
@@ -825,9 +840,10 @@ static void ipsec_esp_encrypt_done(struct device *dev, | |||
825 | ipsec_esp_unmap(dev, edesc, areq); | 840 | ipsec_esp_unmap(dev, edesc, areq); |
826 | 841 | ||
827 | /* copy the generated ICV to dst */ | 842 | /* copy the generated ICV to dst */ |
828 | if (edesc->dma_len) { | 843 | if (edesc->dst_nents) { |
829 | icvdata = &edesc->link_tbl[edesc->src_nents + | 844 | icvdata = &edesc->link_tbl[edesc->src_nents + |
830 | edesc->dst_nents + 2]; | 845 | edesc->dst_nents + 2 + |
846 | edesc->assoc_nents]; | ||
831 | sg = sg_last(areq->dst, edesc->dst_nents); | 847 | sg = sg_last(areq->dst, edesc->dst_nents); |
832 | memcpy((char *)sg_virt(sg) + sg->length - ctx->authsize, | 848 | memcpy((char *)sg_virt(sg) + sg->length - ctx->authsize, |
833 | icvdata, ctx->authsize); | 849 | icvdata, ctx->authsize); |
@@ -857,7 +873,8 @@ static void ipsec_esp_decrypt_swauth_done(struct device *dev, | |||
857 | /* auth check */ | 873 | /* auth check */ |
858 | if (edesc->dma_len) | 874 | if (edesc->dma_len) |
859 | icvdata = &edesc->link_tbl[edesc->src_nents + | 875 | icvdata = &edesc->link_tbl[edesc->src_nents + |
860 | edesc->dst_nents + 2]; | 876 | edesc->dst_nents + 2 + |
877 | edesc->assoc_nents]; | ||
861 | else | 878 | else |
862 | icvdata = &edesc->link_tbl[0]; | 879 | icvdata = &edesc->link_tbl[0]; |
863 | 880 | ||
@@ -932,10 +949,9 @@ static int sg_to_link_tbl(struct scatterlist *sg, int sg_count, | |||
932 | * fill in and submit ipsec_esp descriptor | 949 | * fill in and submit ipsec_esp descriptor |
933 | */ | 950 | */ |
934 | static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq, | 951 | static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq, |
935 | u8 *giv, u64 seq, | 952 | u64 seq, void (*callback) (struct device *dev, |
936 | void (*callback) (struct device *dev, | 953 | struct talitos_desc *desc, |
937 | struct talitos_desc *desc, | 954 | void *context, int error)) |
938 | void *context, int error)) | ||
939 | { | 955 | { |
940 | struct crypto_aead *aead = crypto_aead_reqtfm(areq); | 956 | struct crypto_aead *aead = crypto_aead_reqtfm(areq); |
941 | struct talitos_ctx *ctx = crypto_aead_ctx(aead); | 957 | struct talitos_ctx *ctx = crypto_aead_ctx(aead); |
@@ -950,12 +966,42 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq, | |||
950 | /* hmac key */ | 966 | /* hmac key */ |
951 | map_single_talitos_ptr(dev, &desc->ptr[0], ctx->authkeylen, &ctx->key, | 967 | map_single_talitos_ptr(dev, &desc->ptr[0], ctx->authkeylen, &ctx->key, |
952 | 0, DMA_TO_DEVICE); | 968 | 0, DMA_TO_DEVICE); |
969 | |||
953 | /* hmac data */ | 970 | /* hmac data */ |
954 | map_single_talitos_ptr(dev, &desc->ptr[1], areq->assoclen + ivsize, | 971 | desc->ptr[1].len = cpu_to_be16(areq->assoclen + ivsize); |
955 | sg_virt(areq->assoc), 0, DMA_TO_DEVICE); | 972 | if (edesc->assoc_nents) { |
973 | int tbl_off = edesc->src_nents + edesc->dst_nents + 2; | ||
974 | struct talitos_ptr *tbl_ptr = &edesc->link_tbl[tbl_off]; | ||
975 | |||
976 | to_talitos_ptr(&desc->ptr[1], edesc->dma_link_tbl + tbl_off * | ||
977 | sizeof(struct talitos_ptr)); | ||
978 | desc->ptr[1].j_extent = DESC_PTR_LNKTBL_JUMP; | ||
979 | |||
980 | /* assoc_nents - 1 entries for assoc, 1 for IV */ | ||
981 | sg_count = sg_to_link_tbl(areq->assoc, edesc->assoc_nents - 1, | ||
982 | areq->assoclen, tbl_ptr); | ||
983 | |||
984 | /* add IV to link table */ | ||
985 | tbl_ptr += sg_count - 1; | ||
986 | tbl_ptr->j_extent = 0; | ||
987 | tbl_ptr++; | ||
988 | to_talitos_ptr(tbl_ptr, edesc->iv_dma); | ||
989 | tbl_ptr->len = cpu_to_be16(ivsize); | ||
990 | tbl_ptr->j_extent = DESC_PTR_LNKTBL_RETURN; | ||
991 | |||
992 | dma_sync_single_for_device(dev, edesc->dma_link_tbl, | ||
993 | edesc->dma_len, DMA_BIDIRECTIONAL); | ||
994 | } else { | ||
995 | to_talitos_ptr(&desc->ptr[1], sg_dma_address(areq->assoc)); | ||
996 | desc->ptr[1].j_extent = 0; | ||
997 | } | ||
998 | |||
956 | /* cipher iv */ | 999 | /* cipher iv */ |
957 | map_single_talitos_ptr(dev, &desc->ptr[2], ivsize, giv ?: areq->iv, 0, | 1000 | to_talitos_ptr(&desc->ptr[2], edesc->iv_dma); |
958 | DMA_TO_DEVICE); | 1001 | desc->ptr[2].len = cpu_to_be16(ivsize); |
1002 | desc->ptr[2].j_extent = 0; | ||
1003 | /* Sync needed for the aead_givencrypt case */ | ||
1004 | dma_sync_single_for_device(dev, edesc->iv_dma, ivsize, DMA_TO_DEVICE); | ||
959 | 1005 | ||
960 | /* cipher key */ | 1006 | /* cipher key */ |
961 | map_single_talitos_ptr(dev, &desc->ptr[3], ctx->enckeylen, | 1007 | map_single_talitos_ptr(dev, &desc->ptr[3], ctx->enckeylen, |
@@ -974,7 +1020,7 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq, | |||
974 | sg_count = talitos_map_sg(dev, areq->src, edesc->src_nents ? : 1, | 1020 | sg_count = talitos_map_sg(dev, areq->src, edesc->src_nents ? : 1, |
975 | (areq->src == areq->dst) ? DMA_BIDIRECTIONAL | 1021 | (areq->src == areq->dst) ? DMA_BIDIRECTIONAL |
976 | : DMA_TO_DEVICE, | 1022 | : DMA_TO_DEVICE, |
977 | edesc->src_is_chained); | 1023 | edesc->src_chained); |
978 | 1024 | ||
979 | if (sg_count == 1) { | 1025 | if (sg_count == 1) { |
980 | to_talitos_ptr(&desc->ptr[4], sg_dma_address(areq->src)); | 1026 | to_talitos_ptr(&desc->ptr[4], sg_dma_address(areq->src)); |
@@ -1006,32 +1052,30 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq, | |||
1006 | if (areq->src != areq->dst) | 1052 | if (areq->src != areq->dst) |
1007 | sg_count = talitos_map_sg(dev, areq->dst, | 1053 | sg_count = talitos_map_sg(dev, areq->dst, |
1008 | edesc->dst_nents ? : 1, | 1054 | edesc->dst_nents ? : 1, |
1009 | DMA_FROM_DEVICE, | 1055 | DMA_FROM_DEVICE, edesc->dst_chained); |
1010 | edesc->dst_is_chained); | ||
1011 | 1056 | ||
1012 | if (sg_count == 1) { | 1057 | if (sg_count == 1) { |
1013 | to_talitos_ptr(&desc->ptr[5], sg_dma_address(areq->dst)); | 1058 | to_talitos_ptr(&desc->ptr[5], sg_dma_address(areq->dst)); |
1014 | } else { | 1059 | } else { |
1015 | struct talitos_ptr *link_tbl_ptr = | 1060 | int tbl_off = edesc->src_nents + 1; |
1016 | &edesc->link_tbl[edesc->src_nents + 1]; | 1061 | struct talitos_ptr *tbl_ptr = &edesc->link_tbl[tbl_off]; |
1017 | 1062 | ||
1018 | to_talitos_ptr(&desc->ptr[5], edesc->dma_link_tbl + | 1063 | to_talitos_ptr(&desc->ptr[5], edesc->dma_link_tbl + |
1019 | (edesc->src_nents + 1) * | 1064 | tbl_off * sizeof(struct talitos_ptr)); |
1020 | sizeof(struct talitos_ptr)); | ||
1021 | sg_count = sg_to_link_tbl(areq->dst, sg_count, cryptlen, | 1065 | sg_count = sg_to_link_tbl(areq->dst, sg_count, cryptlen, |
1022 | link_tbl_ptr); | 1066 | tbl_ptr); |
1023 | 1067 | ||
1024 | /* Add an entry to the link table for ICV data */ | 1068 | /* Add an entry to the link table for ICV data */ |
1025 | link_tbl_ptr += sg_count - 1; | 1069 | tbl_ptr += sg_count - 1; |
1026 | link_tbl_ptr->j_extent = 0; | 1070 | tbl_ptr->j_extent = 0; |
1027 | sg_count++; | 1071 | tbl_ptr++; |
1028 | link_tbl_ptr++; | 1072 | tbl_ptr->j_extent = DESC_PTR_LNKTBL_RETURN; |
1029 | link_tbl_ptr->j_extent = DESC_PTR_LNKTBL_RETURN; | 1073 | tbl_ptr->len = cpu_to_be16(authsize); |
1030 | link_tbl_ptr->len = cpu_to_be16(authsize); | ||
1031 | 1074 | ||
1032 | /* icv data follows link tables */ | 1075 | /* icv data follows link tables */ |
1033 | to_talitos_ptr(link_tbl_ptr, edesc->dma_link_tbl + | 1076 | to_talitos_ptr(tbl_ptr, edesc->dma_link_tbl + |
1034 | (edesc->src_nents + edesc->dst_nents + 2) * | 1077 | (tbl_off + edesc->dst_nents + 1 + |
1078 | edesc->assoc_nents) * | ||
1035 | sizeof(struct talitos_ptr)); | 1079 | sizeof(struct talitos_ptr)); |
1036 | desc->ptr[5].j_extent |= DESC_PTR_LNKTBL_JUMP; | 1080 | desc->ptr[5].j_extent |= DESC_PTR_LNKTBL_JUMP; |
1037 | dma_sync_single_for_device(ctx->dev, edesc->dma_link_tbl, | 1081 | dma_sync_single_for_device(ctx->dev, edesc->dma_link_tbl, |
@@ -1053,17 +1097,17 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq, | |||
1053 | /* | 1097 | /* |
1054 | * derive number of elements in scatterlist | 1098 | * derive number of elements in scatterlist |
1055 | */ | 1099 | */ |
1056 | static int sg_count(struct scatterlist *sg_list, int nbytes, int *chained) | 1100 | static int sg_count(struct scatterlist *sg_list, int nbytes, bool *chained) |
1057 | { | 1101 | { |
1058 | struct scatterlist *sg = sg_list; | 1102 | struct scatterlist *sg = sg_list; |
1059 | int sg_nents = 0; | 1103 | int sg_nents = 0; |
1060 | 1104 | ||
1061 | *chained = 0; | 1105 | *chained = false; |
1062 | while (nbytes > 0) { | 1106 | while (nbytes > 0) { |
1063 | sg_nents++; | 1107 | sg_nents++; |
1064 | nbytes -= sg->length; | 1108 | nbytes -= sg->length; |
1065 | if (!sg_is_last(sg) && (sg + 1)->length == 0) | 1109 | if (!sg_is_last(sg) && (sg + 1)->length == 0) |
1066 | *chained = 1; | 1110 | *chained = true; |
1067 | sg = scatterwalk_sg_next(sg); | 1111 | sg = scatterwalk_sg_next(sg); |
1068 | } | 1112 | } |
1069 | 1113 | ||
@@ -1132,17 +1176,21 @@ static size_t sg_copy_end_to_buffer(struct scatterlist *sgl, unsigned int nents, | |||
1132 | * allocate and map the extended descriptor | 1176 | * allocate and map the extended descriptor |
1133 | */ | 1177 | */ |
1134 | static struct talitos_edesc *talitos_edesc_alloc(struct device *dev, | 1178 | static struct talitos_edesc *talitos_edesc_alloc(struct device *dev, |
1179 | struct scatterlist *assoc, | ||
1135 | struct scatterlist *src, | 1180 | struct scatterlist *src, |
1136 | struct scatterlist *dst, | 1181 | struct scatterlist *dst, |
1137 | int hash_result, | 1182 | u8 *iv, |
1183 | unsigned int assoclen, | ||
1138 | unsigned int cryptlen, | 1184 | unsigned int cryptlen, |
1139 | unsigned int authsize, | 1185 | unsigned int authsize, |
1186 | unsigned int ivsize, | ||
1140 | int icv_stashing, | 1187 | int icv_stashing, |
1141 | u32 cryptoflags) | 1188 | u32 cryptoflags) |
1142 | { | 1189 | { |
1143 | struct talitos_edesc *edesc; | 1190 | struct talitos_edesc *edesc; |
1144 | int src_nents, dst_nents, alloc_len, dma_len; | 1191 | int assoc_nents = 0, src_nents, dst_nents, alloc_len, dma_len; |
1145 | int src_chained, dst_chained = 0; | 1192 | bool assoc_chained = false, src_chained = false, dst_chained = false; |
1193 | dma_addr_t iv_dma = 0; | ||
1146 | gfp_t flags = cryptoflags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL : | 1194 | gfp_t flags = cryptoflags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL : |
1147 | GFP_ATOMIC; | 1195 | GFP_ATOMIC; |
1148 | 1196 | ||
@@ -1151,10 +1199,29 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev, | |||
1151 | return ERR_PTR(-EINVAL); | 1199 | return ERR_PTR(-EINVAL); |
1152 | } | 1200 | } |
1153 | 1201 | ||
1202 | if (iv) | ||
1203 | iv_dma = dma_map_single(dev, iv, ivsize, DMA_TO_DEVICE); | ||
1204 | |||
1205 | if (assoc) { | ||
1206 | /* | ||
1207 | * Currently it is assumed that iv is provided whenever assoc | ||
1208 | * is. | ||
1209 | */ | ||
1210 | BUG_ON(!iv); | ||
1211 | |||
1212 | assoc_nents = sg_count(assoc, assoclen, &assoc_chained); | ||
1213 | talitos_map_sg(dev, assoc, assoc_nents, DMA_TO_DEVICE, | ||
1214 | assoc_chained); | ||
1215 | assoc_nents = (assoc_nents == 1) ? 0 : assoc_nents; | ||
1216 | |||
1217 | if (assoc_nents || sg_dma_address(assoc) + assoclen != iv_dma) | ||
1218 | assoc_nents = assoc_nents ? assoc_nents + 1 : 2; | ||
1219 | } | ||
1220 | |||
1154 | src_nents = sg_count(src, cryptlen + authsize, &src_chained); | 1221 | src_nents = sg_count(src, cryptlen + authsize, &src_chained); |
1155 | src_nents = (src_nents == 1) ? 0 : src_nents; | 1222 | src_nents = (src_nents == 1) ? 0 : src_nents; |
1156 | 1223 | ||
1157 | if (hash_result) { | 1224 | if (!dst) { |
1158 | dst_nents = 0; | 1225 | dst_nents = 0; |
1159 | } else { | 1226 | } else { |
1160 | if (dst == src) { | 1227 | if (dst == src) { |
@@ -1172,9 +1239,9 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev, | |||
1172 | * and the ICV data itself | 1239 | * and the ICV data itself |
1173 | */ | 1240 | */ |
1174 | alloc_len = sizeof(struct talitos_edesc); | 1241 | alloc_len = sizeof(struct talitos_edesc); |
1175 | if (src_nents || dst_nents) { | 1242 | if (assoc_nents || src_nents || dst_nents) { |
1176 | dma_len = (src_nents + dst_nents + 2) * | 1243 | dma_len = (src_nents + dst_nents + 2 + assoc_nents) * |
1177 | sizeof(struct talitos_ptr) + authsize; | 1244 | sizeof(struct talitos_ptr) + authsize; |
1178 | alloc_len += dma_len; | 1245 | alloc_len += dma_len; |
1179 | } else { | 1246 | } else { |
1180 | dma_len = 0; | 1247 | dma_len = 0; |
@@ -1183,14 +1250,20 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev, | |||
1183 | 1250 | ||
1184 | edesc = kmalloc(alloc_len, GFP_DMA | flags); | 1251 | edesc = kmalloc(alloc_len, GFP_DMA | flags); |
1185 | if (!edesc) { | 1252 | if (!edesc) { |
1253 | talitos_unmap_sg_chain(dev, assoc, DMA_TO_DEVICE); | ||
1254 | if (iv_dma) | ||
1255 | dma_unmap_single(dev, iv_dma, ivsize, DMA_TO_DEVICE); | ||
1186 | dev_err(dev, "could not allocate edescriptor\n"); | 1256 | dev_err(dev, "could not allocate edescriptor\n"); |
1187 | return ERR_PTR(-ENOMEM); | 1257 | return ERR_PTR(-ENOMEM); |
1188 | } | 1258 | } |
1189 | 1259 | ||
1260 | edesc->assoc_nents = assoc_nents; | ||
1190 | edesc->src_nents = src_nents; | 1261 | edesc->src_nents = src_nents; |
1191 | edesc->dst_nents = dst_nents; | 1262 | edesc->dst_nents = dst_nents; |
1192 | edesc->src_is_chained = src_chained; | 1263 | edesc->assoc_chained = assoc_chained; |
1193 | edesc->dst_is_chained = dst_chained; | 1264 | edesc->src_chained = src_chained; |
1265 | edesc->dst_chained = dst_chained; | ||
1266 | edesc->iv_dma = iv_dma; | ||
1194 | edesc->dma_len = dma_len; | 1267 | edesc->dma_len = dma_len; |
1195 | if (dma_len) | 1268 | if (dma_len) |
1196 | edesc->dma_link_tbl = dma_map_single(dev, &edesc->link_tbl[0], | 1269 | edesc->dma_link_tbl = dma_map_single(dev, &edesc->link_tbl[0], |
@@ -1200,14 +1273,16 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev, | |||
1200 | return edesc; | 1273 | return edesc; |
1201 | } | 1274 | } |
1202 | 1275 | ||
1203 | static struct talitos_edesc *aead_edesc_alloc(struct aead_request *areq, | 1276 | static struct talitos_edesc *aead_edesc_alloc(struct aead_request *areq, u8 *iv, |
1204 | int icv_stashing) | 1277 | int icv_stashing) |
1205 | { | 1278 | { |
1206 | struct crypto_aead *authenc = crypto_aead_reqtfm(areq); | 1279 | struct crypto_aead *authenc = crypto_aead_reqtfm(areq); |
1207 | struct talitos_ctx *ctx = crypto_aead_ctx(authenc); | 1280 | struct talitos_ctx *ctx = crypto_aead_ctx(authenc); |
1281 | unsigned int ivsize = crypto_aead_ivsize(authenc); | ||
1208 | 1282 | ||
1209 | return talitos_edesc_alloc(ctx->dev, areq->src, areq->dst, 0, | 1283 | return talitos_edesc_alloc(ctx->dev, areq->assoc, areq->src, areq->dst, |
1210 | areq->cryptlen, ctx->authsize, icv_stashing, | 1284 | iv, areq->assoclen, areq->cryptlen, |
1285 | ctx->authsize, ivsize, icv_stashing, | ||
1211 | areq->base.flags); | 1286 | areq->base.flags); |
1212 | } | 1287 | } |
1213 | 1288 | ||
@@ -1218,14 +1293,14 @@ static int aead_encrypt(struct aead_request *req) | |||
1218 | struct talitos_edesc *edesc; | 1293 | struct talitos_edesc *edesc; |
1219 | 1294 | ||
1220 | /* allocate extended descriptor */ | 1295 | /* allocate extended descriptor */ |
1221 | edesc = aead_edesc_alloc(req, 0); | 1296 | edesc = aead_edesc_alloc(req, req->iv, 0); |
1222 | if (IS_ERR(edesc)) | 1297 | if (IS_ERR(edesc)) |
1223 | return PTR_ERR(edesc); | 1298 | return PTR_ERR(edesc); |
1224 | 1299 | ||
1225 | /* set encrypt */ | 1300 | /* set encrypt */ |
1226 | edesc->desc.hdr = ctx->desc_hdr_template | DESC_HDR_MODE0_ENCRYPT; | 1301 | edesc->desc.hdr = ctx->desc_hdr_template | DESC_HDR_MODE0_ENCRYPT; |
1227 | 1302 | ||
1228 | return ipsec_esp(edesc, req, NULL, 0, ipsec_esp_encrypt_done); | 1303 | return ipsec_esp(edesc, req, 0, ipsec_esp_encrypt_done); |
1229 | } | 1304 | } |
1230 | 1305 | ||
1231 | static int aead_decrypt(struct aead_request *req) | 1306 | static int aead_decrypt(struct aead_request *req) |
@@ -1241,7 +1316,7 @@ static int aead_decrypt(struct aead_request *req) | |||
1241 | req->cryptlen -= authsize; | 1316 | req->cryptlen -= authsize; |
1242 | 1317 | ||
1243 | /* allocate extended descriptor */ | 1318 | /* allocate extended descriptor */ |
1244 | edesc = aead_edesc_alloc(req, 1); | 1319 | edesc = aead_edesc_alloc(req, req->iv, 1); |
1245 | if (IS_ERR(edesc)) | 1320 | if (IS_ERR(edesc)) |
1246 | return PTR_ERR(edesc); | 1321 | return PTR_ERR(edesc); |
1247 | 1322 | ||
@@ -1257,9 +1332,7 @@ static int aead_decrypt(struct aead_request *req) | |||
1257 | /* reset integrity check result bits */ | 1332 | /* reset integrity check result bits */ |
1258 | edesc->desc.hdr_lo = 0; | 1333 | edesc->desc.hdr_lo = 0; |
1259 | 1334 | ||
1260 | return ipsec_esp(edesc, req, NULL, 0, | 1335 | return ipsec_esp(edesc, req, 0, ipsec_esp_decrypt_hwauth_done); |
1261 | ipsec_esp_decrypt_hwauth_done); | ||
1262 | |||
1263 | } | 1336 | } |
1264 | 1337 | ||
1265 | /* Have to check the ICV with software */ | 1338 | /* Have to check the ICV with software */ |
@@ -1268,7 +1341,8 @@ static int aead_decrypt(struct aead_request *req) | |||
1268 | /* stash incoming ICV for later cmp with ICV generated by the h/w */ | 1341 | /* stash incoming ICV for later cmp with ICV generated by the h/w */ |
1269 | if (edesc->dma_len) | 1342 | if (edesc->dma_len) |
1270 | icvdata = &edesc->link_tbl[edesc->src_nents + | 1343 | icvdata = &edesc->link_tbl[edesc->src_nents + |
1271 | edesc->dst_nents + 2]; | 1344 | edesc->dst_nents + 2 + |
1345 | edesc->assoc_nents]; | ||
1272 | else | 1346 | else |
1273 | icvdata = &edesc->link_tbl[0]; | 1347 | icvdata = &edesc->link_tbl[0]; |
1274 | 1348 | ||
@@ -1277,7 +1351,7 @@ static int aead_decrypt(struct aead_request *req) | |||
1277 | memcpy(icvdata, (char *)sg_virt(sg) + sg->length - ctx->authsize, | 1351 | memcpy(icvdata, (char *)sg_virt(sg) + sg->length - ctx->authsize, |
1278 | ctx->authsize); | 1352 | ctx->authsize); |
1279 | 1353 | ||
1280 | return ipsec_esp(edesc, req, NULL, 0, ipsec_esp_decrypt_swauth_done); | 1354 | return ipsec_esp(edesc, req, 0, ipsec_esp_decrypt_swauth_done); |
1281 | } | 1355 | } |
1282 | 1356 | ||
1283 | static int aead_givencrypt(struct aead_givcrypt_request *req) | 1357 | static int aead_givencrypt(struct aead_givcrypt_request *req) |
@@ -1288,7 +1362,7 @@ static int aead_givencrypt(struct aead_givcrypt_request *req) | |||
1288 | struct talitos_edesc *edesc; | 1362 | struct talitos_edesc *edesc; |
1289 | 1363 | ||
1290 | /* allocate extended descriptor */ | 1364 | /* allocate extended descriptor */ |
1291 | edesc = aead_edesc_alloc(areq, 0); | 1365 | edesc = aead_edesc_alloc(areq, req->giv, 0); |
1292 | if (IS_ERR(edesc)) | 1366 | if (IS_ERR(edesc)) |
1293 | return PTR_ERR(edesc); | 1367 | return PTR_ERR(edesc); |
1294 | 1368 | ||
@@ -1299,8 +1373,7 @@ static int aead_givencrypt(struct aead_givcrypt_request *req) | |||
1299 | /* avoid consecutive packets going out with same IV */ | 1373 | /* avoid consecutive packets going out with same IV */ |
1300 | *(__be64 *)req->giv ^= cpu_to_be64(req->seq); | 1374 | *(__be64 *)req->giv ^= cpu_to_be64(req->seq); |
1301 | 1375 | ||
1302 | return ipsec_esp(edesc, areq, req->giv, req->seq, | 1376 | return ipsec_esp(edesc, areq, req->seq, ipsec_esp_encrypt_done); |
1303 | ipsec_esp_encrypt_done); | ||
1304 | } | 1377 | } |
1305 | 1378 | ||
1306 | static int ablkcipher_setkey(struct crypto_ablkcipher *cipher, | 1379 | static int ablkcipher_setkey(struct crypto_ablkcipher *cipher, |
@@ -1356,7 +1429,7 @@ static int common_nonsnoop(struct talitos_edesc *edesc, | |||
1356 | struct device *dev = ctx->dev; | 1429 | struct device *dev = ctx->dev; |
1357 | struct talitos_desc *desc = &edesc->desc; | 1430 | struct talitos_desc *desc = &edesc->desc; |
1358 | unsigned int cryptlen = areq->nbytes; | 1431 | unsigned int cryptlen = areq->nbytes; |
1359 | unsigned int ivsize; | 1432 | unsigned int ivsize = crypto_ablkcipher_ivsize(cipher); |
1360 | int sg_count, ret; | 1433 | int sg_count, ret; |
1361 | 1434 | ||
1362 | /* first DWORD empty */ | 1435 | /* first DWORD empty */ |
@@ -1365,9 +1438,9 @@ static int common_nonsnoop(struct talitos_edesc *edesc, | |||
1365 | desc->ptr[0].j_extent = 0; | 1438 | desc->ptr[0].j_extent = 0; |
1366 | 1439 | ||
1367 | /* cipher iv */ | 1440 | /* cipher iv */ |
1368 | ivsize = crypto_ablkcipher_ivsize(cipher); | 1441 | to_talitos_ptr(&desc->ptr[1], edesc->iv_dma); |
1369 | map_single_talitos_ptr(dev, &desc->ptr[1], ivsize, areq->info, 0, | 1442 | desc->ptr[1].len = cpu_to_be16(ivsize); |
1370 | DMA_TO_DEVICE); | 1443 | desc->ptr[1].j_extent = 0; |
1371 | 1444 | ||
1372 | /* cipher key */ | 1445 | /* cipher key */ |
1373 | map_single_talitos_ptr(dev, &desc->ptr[2], ctx->keylen, | 1446 | map_single_talitos_ptr(dev, &desc->ptr[2], ctx->keylen, |
@@ -1382,7 +1455,7 @@ static int common_nonsnoop(struct talitos_edesc *edesc, | |||
1382 | sg_count = talitos_map_sg(dev, areq->src, edesc->src_nents ? : 1, | 1455 | sg_count = talitos_map_sg(dev, areq->src, edesc->src_nents ? : 1, |
1383 | (areq->src == areq->dst) ? DMA_BIDIRECTIONAL | 1456 | (areq->src == areq->dst) ? DMA_BIDIRECTIONAL |
1384 | : DMA_TO_DEVICE, | 1457 | : DMA_TO_DEVICE, |
1385 | edesc->src_is_chained); | 1458 | edesc->src_chained); |
1386 | 1459 | ||
1387 | if (sg_count == 1) { | 1460 | if (sg_count == 1) { |
1388 | to_talitos_ptr(&desc->ptr[3], sg_dma_address(areq->src)); | 1461 | to_talitos_ptr(&desc->ptr[3], sg_dma_address(areq->src)); |
@@ -1409,8 +1482,7 @@ static int common_nonsnoop(struct talitos_edesc *edesc, | |||
1409 | if (areq->src != areq->dst) | 1482 | if (areq->src != areq->dst) |
1410 | sg_count = talitos_map_sg(dev, areq->dst, | 1483 | sg_count = talitos_map_sg(dev, areq->dst, |
1411 | edesc->dst_nents ? : 1, | 1484 | edesc->dst_nents ? : 1, |
1412 | DMA_FROM_DEVICE, | 1485 | DMA_FROM_DEVICE, edesc->dst_chained); |
1413 | edesc->dst_is_chained); | ||
1414 | 1486 | ||
1415 | if (sg_count == 1) { | 1487 | if (sg_count == 1) { |
1416 | to_talitos_ptr(&desc->ptr[4], sg_dma_address(areq->dst)); | 1488 | to_talitos_ptr(&desc->ptr[4], sg_dma_address(areq->dst)); |
@@ -1450,9 +1522,11 @@ static struct talitos_edesc *ablkcipher_edesc_alloc(struct ablkcipher_request * | |||
1450 | { | 1522 | { |
1451 | struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq); | 1523 | struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq); |
1452 | struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher); | 1524 | struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher); |
1525 | unsigned int ivsize = crypto_ablkcipher_ivsize(cipher); | ||
1453 | 1526 | ||
1454 | return talitos_edesc_alloc(ctx->dev, areq->src, areq->dst, 0, | 1527 | return talitos_edesc_alloc(ctx->dev, NULL, areq->src, areq->dst, |
1455 | areq->nbytes, 0, 0, areq->base.flags); | 1528 | areq->info, 0, areq->nbytes, 0, ivsize, 0, |
1529 | areq->base.flags); | ||
1456 | } | 1530 | } |
1457 | 1531 | ||
1458 | static int ablkcipher_encrypt(struct ablkcipher_request *areq) | 1532 | static int ablkcipher_encrypt(struct ablkcipher_request *areq) |
@@ -1578,8 +1652,7 @@ static int common_nonsnoop_hash(struct talitos_edesc *edesc, | |||
1578 | 1652 | ||
1579 | sg_count = talitos_map_sg(dev, req_ctx->psrc, | 1653 | sg_count = talitos_map_sg(dev, req_ctx->psrc, |
1580 | edesc->src_nents ? : 1, | 1654 | edesc->src_nents ? : 1, |
1581 | DMA_TO_DEVICE, | 1655 | DMA_TO_DEVICE, edesc->src_chained); |
1582 | edesc->src_is_chained); | ||
1583 | 1656 | ||
1584 | if (sg_count == 1) { | 1657 | if (sg_count == 1) { |
1585 | to_talitos_ptr(&desc->ptr[3], sg_dma_address(req_ctx->psrc)); | 1658 | to_talitos_ptr(&desc->ptr[3], sg_dma_address(req_ctx->psrc)); |
@@ -1631,8 +1704,8 @@ static struct talitos_edesc *ahash_edesc_alloc(struct ahash_request *areq, | |||
1631 | struct talitos_ctx *ctx = crypto_ahash_ctx(tfm); | 1704 | struct talitos_ctx *ctx = crypto_ahash_ctx(tfm); |
1632 | struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq); | 1705 | struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq); |
1633 | 1706 | ||
1634 | return talitos_edesc_alloc(ctx->dev, req_ctx->psrc, NULL, 1, | 1707 | return talitos_edesc_alloc(ctx->dev, NULL, req_ctx->psrc, NULL, NULL, 0, |
1635 | nbytes, 0, 0, areq->base.flags); | 1708 | nbytes, 0, 0, 0, areq->base.flags); |
1636 | } | 1709 | } |
1637 | 1710 | ||
1638 | static int ahash_init(struct ahash_request *areq) | 1711 | static int ahash_init(struct ahash_request *areq) |
@@ -1690,7 +1763,7 @@ static int ahash_process_req(struct ahash_request *areq, unsigned int nbytes) | |||
1690 | unsigned int nbytes_to_hash; | 1763 | unsigned int nbytes_to_hash; |
1691 | unsigned int to_hash_later; | 1764 | unsigned int to_hash_later; |
1692 | unsigned int nsg; | 1765 | unsigned int nsg; |
1693 | int chained; | 1766 | bool chained; |
1694 | 1767 | ||
1695 | if (!req_ctx->last && (nbytes + req_ctx->nbuf <= blocksize)) { | 1768 | if (!req_ctx->last && (nbytes + req_ctx->nbuf <= blocksize)) { |
1696 | /* Buffer up to one whole block */ | 1769 | /* Buffer up to one whole block */ |
@@ -1902,21 +1975,18 @@ struct talitos_alg_template { | |||
1902 | }; | 1975 | }; |
1903 | 1976 | ||
1904 | static struct talitos_alg_template driver_algs[] = { | 1977 | static struct talitos_alg_template driver_algs[] = { |
1905 | /* AEAD algorithms. These use a single-pass ipsec_esp descriptor */ | 1978 | /* |
1979 | * AEAD algorithms. These use a single-pass ipsec_esp descriptor. | ||
1980 | * authencesn(*,*) is also registered, although not present | ||
1981 | * explicitly here. | ||
1982 | */ | ||
1906 | { .type = CRYPTO_ALG_TYPE_AEAD, | 1983 | { .type = CRYPTO_ALG_TYPE_AEAD, |
1907 | .alg.crypto = { | 1984 | .alg.crypto = { |
1908 | .cra_name = "authenc(hmac(sha1),cbc(aes))", | 1985 | .cra_name = "authenc(hmac(sha1),cbc(aes))", |
1909 | .cra_driver_name = "authenc-hmac-sha1-cbc-aes-talitos", | 1986 | .cra_driver_name = "authenc-hmac-sha1-cbc-aes-talitos", |
1910 | .cra_blocksize = AES_BLOCK_SIZE, | 1987 | .cra_blocksize = AES_BLOCK_SIZE, |
1911 | .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, | 1988 | .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, |
1912 | .cra_type = &crypto_aead_type, | ||
1913 | .cra_aead = { | 1989 | .cra_aead = { |
1914 | .setkey = aead_setkey, | ||
1915 | .setauthsize = aead_setauthsize, | ||
1916 | .encrypt = aead_encrypt, | ||
1917 | .decrypt = aead_decrypt, | ||
1918 | .givencrypt = aead_givencrypt, | ||
1919 | .geniv = "<built-in>", | ||
1920 | .ivsize = AES_BLOCK_SIZE, | 1990 | .ivsize = AES_BLOCK_SIZE, |
1921 | .maxauthsize = SHA1_DIGEST_SIZE, | 1991 | .maxauthsize = SHA1_DIGEST_SIZE, |
1922 | } | 1992 | } |
@@ -1935,14 +2005,7 @@ static struct talitos_alg_template driver_algs[] = { | |||
1935 | .cra_driver_name = "authenc-hmac-sha1-cbc-3des-talitos", | 2005 | .cra_driver_name = "authenc-hmac-sha1-cbc-3des-talitos", |
1936 | .cra_blocksize = DES3_EDE_BLOCK_SIZE, | 2006 | .cra_blocksize = DES3_EDE_BLOCK_SIZE, |
1937 | .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, | 2007 | .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, |
1938 | .cra_type = &crypto_aead_type, | ||
1939 | .cra_aead = { | 2008 | .cra_aead = { |
1940 | .setkey = aead_setkey, | ||
1941 | .setauthsize = aead_setauthsize, | ||
1942 | .encrypt = aead_encrypt, | ||
1943 | .decrypt = aead_decrypt, | ||
1944 | .givencrypt = aead_givencrypt, | ||
1945 | .geniv = "<built-in>", | ||
1946 | .ivsize = DES3_EDE_BLOCK_SIZE, | 2009 | .ivsize = DES3_EDE_BLOCK_SIZE, |
1947 | .maxauthsize = SHA1_DIGEST_SIZE, | 2010 | .maxauthsize = SHA1_DIGEST_SIZE, |
1948 | } | 2011 | } |
@@ -1962,14 +2025,7 @@ static struct talitos_alg_template driver_algs[] = { | |||
1962 | .cra_driver_name = "authenc-hmac-sha224-cbc-aes-talitos", | 2025 | .cra_driver_name = "authenc-hmac-sha224-cbc-aes-talitos", |
1963 | .cra_blocksize = AES_BLOCK_SIZE, | 2026 | .cra_blocksize = AES_BLOCK_SIZE, |
1964 | .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, | 2027 | .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, |
1965 | .cra_type = &crypto_aead_type, | ||
1966 | .cra_aead = { | 2028 | .cra_aead = { |
1967 | .setkey = aead_setkey, | ||
1968 | .setauthsize = aead_setauthsize, | ||
1969 | .encrypt = aead_encrypt, | ||
1970 | .decrypt = aead_decrypt, | ||
1971 | .givencrypt = aead_givencrypt, | ||
1972 | .geniv = "<built-in>", | ||
1973 | .ivsize = AES_BLOCK_SIZE, | 2029 | .ivsize = AES_BLOCK_SIZE, |
1974 | .maxauthsize = SHA224_DIGEST_SIZE, | 2030 | .maxauthsize = SHA224_DIGEST_SIZE, |
1975 | } | 2031 | } |
@@ -1988,14 +2044,7 @@ static struct talitos_alg_template driver_algs[] = { | |||
1988 | .cra_driver_name = "authenc-hmac-sha224-cbc-3des-talitos", | 2044 | .cra_driver_name = "authenc-hmac-sha224-cbc-3des-talitos", |
1989 | .cra_blocksize = DES3_EDE_BLOCK_SIZE, | 2045 | .cra_blocksize = DES3_EDE_BLOCK_SIZE, |
1990 | .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, | 2046 | .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, |
1991 | .cra_type = &crypto_aead_type, | ||
1992 | .cra_aead = { | 2047 | .cra_aead = { |
1993 | .setkey = aead_setkey, | ||
1994 | .setauthsize = aead_setauthsize, | ||
1995 | .encrypt = aead_encrypt, | ||
1996 | .decrypt = aead_decrypt, | ||
1997 | .givencrypt = aead_givencrypt, | ||
1998 | .geniv = "<built-in>", | ||
1999 | .ivsize = DES3_EDE_BLOCK_SIZE, | 2048 | .ivsize = DES3_EDE_BLOCK_SIZE, |
2000 | .maxauthsize = SHA224_DIGEST_SIZE, | 2049 | .maxauthsize = SHA224_DIGEST_SIZE, |
2001 | } | 2050 | } |
@@ -2015,14 +2064,7 @@ static struct talitos_alg_template driver_algs[] = { | |||
2015 | .cra_driver_name = "authenc-hmac-sha256-cbc-aes-talitos", | 2064 | .cra_driver_name = "authenc-hmac-sha256-cbc-aes-talitos", |
2016 | .cra_blocksize = AES_BLOCK_SIZE, | 2065 | .cra_blocksize = AES_BLOCK_SIZE, |
2017 | .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, | 2066 | .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, |
2018 | .cra_type = &crypto_aead_type, | ||
2019 | .cra_aead = { | 2067 | .cra_aead = { |
2020 | .setkey = aead_setkey, | ||
2021 | .setauthsize = aead_setauthsize, | ||
2022 | .encrypt = aead_encrypt, | ||
2023 | .decrypt = aead_decrypt, | ||
2024 | .givencrypt = aead_givencrypt, | ||
2025 | .geniv = "<built-in>", | ||
2026 | .ivsize = AES_BLOCK_SIZE, | 2068 | .ivsize = AES_BLOCK_SIZE, |
2027 | .maxauthsize = SHA256_DIGEST_SIZE, | 2069 | .maxauthsize = SHA256_DIGEST_SIZE, |
2028 | } | 2070 | } |
@@ -2041,14 +2083,7 @@ static struct talitos_alg_template driver_algs[] = { | |||
2041 | .cra_driver_name = "authenc-hmac-sha256-cbc-3des-talitos", | 2083 | .cra_driver_name = "authenc-hmac-sha256-cbc-3des-talitos", |
2042 | .cra_blocksize = DES3_EDE_BLOCK_SIZE, | 2084 | .cra_blocksize = DES3_EDE_BLOCK_SIZE, |
2043 | .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, | 2085 | .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, |
2044 | .cra_type = &crypto_aead_type, | ||
2045 | .cra_aead = { | 2086 | .cra_aead = { |
2046 | .setkey = aead_setkey, | ||
2047 | .setauthsize = aead_setauthsize, | ||
2048 | .encrypt = aead_encrypt, | ||
2049 | .decrypt = aead_decrypt, | ||
2050 | .givencrypt = aead_givencrypt, | ||
2051 | .geniv = "<built-in>", | ||
2052 | .ivsize = DES3_EDE_BLOCK_SIZE, | 2087 | .ivsize = DES3_EDE_BLOCK_SIZE, |
2053 | .maxauthsize = SHA256_DIGEST_SIZE, | 2088 | .maxauthsize = SHA256_DIGEST_SIZE, |
2054 | } | 2089 | } |
@@ -2068,14 +2103,7 @@ static struct talitos_alg_template driver_algs[] = { | |||
2068 | .cra_driver_name = "authenc-hmac-sha384-cbc-aes-talitos", | 2103 | .cra_driver_name = "authenc-hmac-sha384-cbc-aes-talitos", |
2069 | .cra_blocksize = AES_BLOCK_SIZE, | 2104 | .cra_blocksize = AES_BLOCK_SIZE, |
2070 | .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, | 2105 | .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, |
2071 | .cra_type = &crypto_aead_type, | ||
2072 | .cra_aead = { | 2106 | .cra_aead = { |
2073 | .setkey = aead_setkey, | ||
2074 | .setauthsize = aead_setauthsize, | ||
2075 | .encrypt = aead_encrypt, | ||
2076 | .decrypt = aead_decrypt, | ||
2077 | .givencrypt = aead_givencrypt, | ||
2078 | .geniv = "<built-in>", | ||
2079 | .ivsize = AES_BLOCK_SIZE, | 2107 | .ivsize = AES_BLOCK_SIZE, |
2080 | .maxauthsize = SHA384_DIGEST_SIZE, | 2108 | .maxauthsize = SHA384_DIGEST_SIZE, |
2081 | } | 2109 | } |
@@ -2094,14 +2122,7 @@ static struct talitos_alg_template driver_algs[] = { | |||
2094 | .cra_driver_name = "authenc-hmac-sha384-cbc-3des-talitos", | 2122 | .cra_driver_name = "authenc-hmac-sha384-cbc-3des-talitos", |
2095 | .cra_blocksize = DES3_EDE_BLOCK_SIZE, | 2123 | .cra_blocksize = DES3_EDE_BLOCK_SIZE, |
2096 | .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, | 2124 | .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, |
2097 | .cra_type = &crypto_aead_type, | ||
2098 | .cra_aead = { | 2125 | .cra_aead = { |
2099 | .setkey = aead_setkey, | ||
2100 | .setauthsize = aead_setauthsize, | ||
2101 | .encrypt = aead_encrypt, | ||
2102 | .decrypt = aead_decrypt, | ||
2103 | .givencrypt = aead_givencrypt, | ||
2104 | .geniv = "<built-in>", | ||
2105 | .ivsize = DES3_EDE_BLOCK_SIZE, | 2126 | .ivsize = DES3_EDE_BLOCK_SIZE, |
2106 | .maxauthsize = SHA384_DIGEST_SIZE, | 2127 | .maxauthsize = SHA384_DIGEST_SIZE, |
2107 | } | 2128 | } |
@@ -2121,14 +2142,7 @@ static struct talitos_alg_template driver_algs[] = { | |||
2121 | .cra_driver_name = "authenc-hmac-sha512-cbc-aes-talitos", | 2142 | .cra_driver_name = "authenc-hmac-sha512-cbc-aes-talitos", |
2122 | .cra_blocksize = AES_BLOCK_SIZE, | 2143 | .cra_blocksize = AES_BLOCK_SIZE, |
2123 | .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, | 2144 | .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, |
2124 | .cra_type = &crypto_aead_type, | ||
2125 | .cra_aead = { | 2145 | .cra_aead = { |
2126 | .setkey = aead_setkey, | ||
2127 | .setauthsize = aead_setauthsize, | ||
2128 | .encrypt = aead_encrypt, | ||
2129 | .decrypt = aead_decrypt, | ||
2130 | .givencrypt = aead_givencrypt, | ||
2131 | .geniv = "<built-in>", | ||
2132 | .ivsize = AES_BLOCK_SIZE, | 2146 | .ivsize = AES_BLOCK_SIZE, |
2133 | .maxauthsize = SHA512_DIGEST_SIZE, | 2147 | .maxauthsize = SHA512_DIGEST_SIZE, |
2134 | } | 2148 | } |
@@ -2147,14 +2161,7 @@ static struct talitos_alg_template driver_algs[] = { | |||
2147 | .cra_driver_name = "authenc-hmac-sha512-cbc-3des-talitos", | 2161 | .cra_driver_name = "authenc-hmac-sha512-cbc-3des-talitos", |
2148 | .cra_blocksize = DES3_EDE_BLOCK_SIZE, | 2162 | .cra_blocksize = DES3_EDE_BLOCK_SIZE, |
2149 | .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, | 2163 | .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, |
2150 | .cra_type = &crypto_aead_type, | ||
2151 | .cra_aead = { | 2164 | .cra_aead = { |
2152 | .setkey = aead_setkey, | ||
2153 | .setauthsize = aead_setauthsize, | ||
2154 | .encrypt = aead_encrypt, | ||
2155 | .decrypt = aead_decrypt, | ||
2156 | .givencrypt = aead_givencrypt, | ||
2157 | .geniv = "<built-in>", | ||
2158 | .ivsize = DES3_EDE_BLOCK_SIZE, | 2165 | .ivsize = DES3_EDE_BLOCK_SIZE, |
2159 | .maxauthsize = SHA512_DIGEST_SIZE, | 2166 | .maxauthsize = SHA512_DIGEST_SIZE, |
2160 | } | 2167 | } |
@@ -2174,14 +2181,7 @@ static struct talitos_alg_template driver_algs[] = { | |||
2174 | .cra_driver_name = "authenc-hmac-md5-cbc-aes-talitos", | 2181 | .cra_driver_name = "authenc-hmac-md5-cbc-aes-talitos", |
2175 | .cra_blocksize = AES_BLOCK_SIZE, | 2182 | .cra_blocksize = AES_BLOCK_SIZE, |
2176 | .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, | 2183 | .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, |
2177 | .cra_type = &crypto_aead_type, | ||
2178 | .cra_aead = { | 2184 | .cra_aead = { |
2179 | .setkey = aead_setkey, | ||
2180 | .setauthsize = aead_setauthsize, | ||
2181 | .encrypt = aead_encrypt, | ||
2182 | .decrypt = aead_decrypt, | ||
2183 | .givencrypt = aead_givencrypt, | ||
2184 | .geniv = "<built-in>", | ||
2185 | .ivsize = AES_BLOCK_SIZE, | 2185 | .ivsize = AES_BLOCK_SIZE, |
2186 | .maxauthsize = MD5_DIGEST_SIZE, | 2186 | .maxauthsize = MD5_DIGEST_SIZE, |
2187 | } | 2187 | } |
@@ -2200,14 +2200,7 @@ static struct talitos_alg_template driver_algs[] = { | |||
2200 | .cra_driver_name = "authenc-hmac-md5-cbc-3des-talitos", | 2200 | .cra_driver_name = "authenc-hmac-md5-cbc-3des-talitos", |
2201 | .cra_blocksize = DES3_EDE_BLOCK_SIZE, | 2201 | .cra_blocksize = DES3_EDE_BLOCK_SIZE, |
2202 | .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, | 2202 | .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, |
2203 | .cra_type = &crypto_aead_type, | ||
2204 | .cra_aead = { | 2203 | .cra_aead = { |
2205 | .setkey = aead_setkey, | ||
2206 | .setauthsize = aead_setauthsize, | ||
2207 | .encrypt = aead_encrypt, | ||
2208 | .decrypt = aead_decrypt, | ||
2209 | .givencrypt = aead_givencrypt, | ||
2210 | .geniv = "<built-in>", | ||
2211 | .ivsize = DES3_EDE_BLOCK_SIZE, | 2204 | .ivsize = DES3_EDE_BLOCK_SIZE, |
2212 | .maxauthsize = MD5_DIGEST_SIZE, | 2205 | .maxauthsize = MD5_DIGEST_SIZE, |
2213 | } | 2206 | } |
@@ -2229,12 +2222,7 @@ static struct talitos_alg_template driver_algs[] = { | |||
2229 | .cra_blocksize = AES_BLOCK_SIZE, | 2222 | .cra_blocksize = AES_BLOCK_SIZE, |
2230 | .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | | 2223 | .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | |
2231 | CRYPTO_ALG_ASYNC, | 2224 | CRYPTO_ALG_ASYNC, |
2232 | .cra_type = &crypto_ablkcipher_type, | ||
2233 | .cra_ablkcipher = { | 2225 | .cra_ablkcipher = { |
2234 | .setkey = ablkcipher_setkey, | ||
2235 | .encrypt = ablkcipher_encrypt, | ||
2236 | .decrypt = ablkcipher_decrypt, | ||
2237 | .geniv = "eseqiv", | ||
2238 | .min_keysize = AES_MIN_KEY_SIZE, | 2226 | .min_keysize = AES_MIN_KEY_SIZE, |
2239 | .max_keysize = AES_MAX_KEY_SIZE, | 2227 | .max_keysize = AES_MAX_KEY_SIZE, |
2240 | .ivsize = AES_BLOCK_SIZE, | 2228 | .ivsize = AES_BLOCK_SIZE, |
@@ -2251,12 +2239,7 @@ static struct talitos_alg_template driver_algs[] = { | |||
2251 | .cra_blocksize = DES3_EDE_BLOCK_SIZE, | 2239 | .cra_blocksize = DES3_EDE_BLOCK_SIZE, |
2252 | .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | | 2240 | .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | |
2253 | CRYPTO_ALG_ASYNC, | 2241 | CRYPTO_ALG_ASYNC, |
2254 | .cra_type = &crypto_ablkcipher_type, | ||
2255 | .cra_ablkcipher = { | 2242 | .cra_ablkcipher = { |
2256 | .setkey = ablkcipher_setkey, | ||
2257 | .encrypt = ablkcipher_encrypt, | ||
2258 | .decrypt = ablkcipher_decrypt, | ||
2259 | .geniv = "eseqiv", | ||
2260 | .min_keysize = DES3_EDE_KEY_SIZE, | 2243 | .min_keysize = DES3_EDE_KEY_SIZE, |
2261 | .max_keysize = DES3_EDE_KEY_SIZE, | 2244 | .max_keysize = DES3_EDE_KEY_SIZE, |
2262 | .ivsize = DES3_EDE_BLOCK_SIZE, | 2245 | .ivsize = DES3_EDE_BLOCK_SIZE, |
@@ -2270,11 +2253,6 @@ static struct talitos_alg_template driver_algs[] = { | |||
2270 | /* AHASH algorithms. */ | 2253 | /* AHASH algorithms. */ |
2271 | { .type = CRYPTO_ALG_TYPE_AHASH, | 2254 | { .type = CRYPTO_ALG_TYPE_AHASH, |
2272 | .alg.hash = { | 2255 | .alg.hash = { |
2273 | .init = ahash_init, | ||
2274 | .update = ahash_update, | ||
2275 | .final = ahash_final, | ||
2276 | .finup = ahash_finup, | ||
2277 | .digest = ahash_digest, | ||
2278 | .halg.digestsize = MD5_DIGEST_SIZE, | 2256 | .halg.digestsize = MD5_DIGEST_SIZE, |
2279 | .halg.base = { | 2257 | .halg.base = { |
2280 | .cra_name = "md5", | 2258 | .cra_name = "md5", |
@@ -2282,7 +2260,6 @@ static struct talitos_alg_template driver_algs[] = { | |||
2282 | .cra_blocksize = MD5_BLOCK_SIZE, | 2260 | .cra_blocksize = MD5_BLOCK_SIZE, |
2283 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | | 2261 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | |
2284 | CRYPTO_ALG_ASYNC, | 2262 | CRYPTO_ALG_ASYNC, |
2285 | .cra_type = &crypto_ahash_type | ||
2286 | } | 2263 | } |
2287 | }, | 2264 | }, |
2288 | .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | | 2265 | .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | |
@@ -2291,11 +2268,6 @@ static struct talitos_alg_template driver_algs[] = { | |||
2291 | }, | 2268 | }, |
2292 | { .type = CRYPTO_ALG_TYPE_AHASH, | 2269 | { .type = CRYPTO_ALG_TYPE_AHASH, |
2293 | .alg.hash = { | 2270 | .alg.hash = { |
2294 | .init = ahash_init, | ||
2295 | .update = ahash_update, | ||
2296 | .final = ahash_final, | ||
2297 | .finup = ahash_finup, | ||
2298 | .digest = ahash_digest, | ||
2299 | .halg.digestsize = SHA1_DIGEST_SIZE, | 2271 | .halg.digestsize = SHA1_DIGEST_SIZE, |
2300 | .halg.base = { | 2272 | .halg.base = { |
2301 | .cra_name = "sha1", | 2273 | .cra_name = "sha1", |
@@ -2303,7 +2275,6 @@ static struct talitos_alg_template driver_algs[] = { | |||
2303 | .cra_blocksize = SHA1_BLOCK_SIZE, | 2275 | .cra_blocksize = SHA1_BLOCK_SIZE, |
2304 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | | 2276 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | |
2305 | CRYPTO_ALG_ASYNC, | 2277 | CRYPTO_ALG_ASYNC, |
2306 | .cra_type = &crypto_ahash_type | ||
2307 | } | 2278 | } |
2308 | }, | 2279 | }, |
2309 | .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | | 2280 | .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | |
@@ -2312,11 +2283,6 @@ static struct talitos_alg_template driver_algs[] = { | |||
2312 | }, | 2283 | }, |
2313 | { .type = CRYPTO_ALG_TYPE_AHASH, | 2284 | { .type = CRYPTO_ALG_TYPE_AHASH, |
2314 | .alg.hash = { | 2285 | .alg.hash = { |
2315 | .init = ahash_init, | ||
2316 | .update = ahash_update, | ||
2317 | .final = ahash_final, | ||
2318 | .finup = ahash_finup, | ||
2319 | .digest = ahash_digest, | ||
2320 | .halg.digestsize = SHA224_DIGEST_SIZE, | 2286 | .halg.digestsize = SHA224_DIGEST_SIZE, |
2321 | .halg.base = { | 2287 | .halg.base = { |
2322 | .cra_name = "sha224", | 2288 | .cra_name = "sha224", |
@@ -2324,7 +2290,6 @@ static struct talitos_alg_template driver_algs[] = { | |||
2324 | .cra_blocksize = SHA224_BLOCK_SIZE, | 2290 | .cra_blocksize = SHA224_BLOCK_SIZE, |
2325 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | | 2291 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | |
2326 | CRYPTO_ALG_ASYNC, | 2292 | CRYPTO_ALG_ASYNC, |
2327 | .cra_type = &crypto_ahash_type | ||
2328 | } | 2293 | } |
2329 | }, | 2294 | }, |
2330 | .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | | 2295 | .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | |
@@ -2333,11 +2298,6 @@ static struct talitos_alg_template driver_algs[] = { | |||
2333 | }, | 2298 | }, |
2334 | { .type = CRYPTO_ALG_TYPE_AHASH, | 2299 | { .type = CRYPTO_ALG_TYPE_AHASH, |
2335 | .alg.hash = { | 2300 | .alg.hash = { |
2336 | .init = ahash_init, | ||
2337 | .update = ahash_update, | ||
2338 | .final = ahash_final, | ||
2339 | .finup = ahash_finup, | ||
2340 | .digest = ahash_digest, | ||
2341 | .halg.digestsize = SHA256_DIGEST_SIZE, | 2301 | .halg.digestsize = SHA256_DIGEST_SIZE, |
2342 | .halg.base = { | 2302 | .halg.base = { |
2343 | .cra_name = "sha256", | 2303 | .cra_name = "sha256", |
@@ -2345,7 +2305,6 @@ static struct talitos_alg_template driver_algs[] = { | |||
2345 | .cra_blocksize = SHA256_BLOCK_SIZE, | 2305 | .cra_blocksize = SHA256_BLOCK_SIZE, |
2346 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | | 2306 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | |
2347 | CRYPTO_ALG_ASYNC, | 2307 | CRYPTO_ALG_ASYNC, |
2348 | .cra_type = &crypto_ahash_type | ||
2349 | } | 2308 | } |
2350 | }, | 2309 | }, |
2351 | .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | | 2310 | .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | |
@@ -2354,11 +2313,6 @@ static struct talitos_alg_template driver_algs[] = { | |||
2354 | }, | 2313 | }, |
2355 | { .type = CRYPTO_ALG_TYPE_AHASH, | 2314 | { .type = CRYPTO_ALG_TYPE_AHASH, |
2356 | .alg.hash = { | 2315 | .alg.hash = { |
2357 | .init = ahash_init, | ||
2358 | .update = ahash_update, | ||
2359 | .final = ahash_final, | ||
2360 | .finup = ahash_finup, | ||
2361 | .digest = ahash_digest, | ||
2362 | .halg.digestsize = SHA384_DIGEST_SIZE, | 2316 | .halg.digestsize = SHA384_DIGEST_SIZE, |
2363 | .halg.base = { | 2317 | .halg.base = { |
2364 | .cra_name = "sha384", | 2318 | .cra_name = "sha384", |
@@ -2366,7 +2320,6 @@ static struct talitos_alg_template driver_algs[] = { | |||
2366 | .cra_blocksize = SHA384_BLOCK_SIZE, | 2320 | .cra_blocksize = SHA384_BLOCK_SIZE, |
2367 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | | 2321 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | |
2368 | CRYPTO_ALG_ASYNC, | 2322 | CRYPTO_ALG_ASYNC, |
2369 | .cra_type = &crypto_ahash_type | ||
2370 | } | 2323 | } |
2371 | }, | 2324 | }, |
2372 | .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | | 2325 | .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | |
@@ -2375,11 +2328,6 @@ static struct talitos_alg_template driver_algs[] = { | |||
2375 | }, | 2328 | }, |
2376 | { .type = CRYPTO_ALG_TYPE_AHASH, | 2329 | { .type = CRYPTO_ALG_TYPE_AHASH, |
2377 | .alg.hash = { | 2330 | .alg.hash = { |
2378 | .init = ahash_init, | ||
2379 | .update = ahash_update, | ||
2380 | .final = ahash_final, | ||
2381 | .finup = ahash_finup, | ||
2382 | .digest = ahash_digest, | ||
2383 | .halg.digestsize = SHA512_DIGEST_SIZE, | 2331 | .halg.digestsize = SHA512_DIGEST_SIZE, |
2384 | .halg.base = { | 2332 | .halg.base = { |
2385 | .cra_name = "sha512", | 2333 | .cra_name = "sha512", |
@@ -2387,7 +2335,6 @@ static struct talitos_alg_template driver_algs[] = { | |||
2387 | .cra_blocksize = SHA512_BLOCK_SIZE, | 2335 | .cra_blocksize = SHA512_BLOCK_SIZE, |
2388 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | | 2336 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | |
2389 | CRYPTO_ALG_ASYNC, | 2337 | CRYPTO_ALG_ASYNC, |
2390 | .cra_type = &crypto_ahash_type | ||
2391 | } | 2338 | } |
2392 | }, | 2339 | }, |
2393 | .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | | 2340 | .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | |
@@ -2396,12 +2343,6 @@ static struct talitos_alg_template driver_algs[] = { | |||
2396 | }, | 2343 | }, |
2397 | { .type = CRYPTO_ALG_TYPE_AHASH, | 2344 | { .type = CRYPTO_ALG_TYPE_AHASH, |
2398 | .alg.hash = { | 2345 | .alg.hash = { |
2399 | .init = ahash_init, | ||
2400 | .update = ahash_update, | ||
2401 | .final = ahash_final, | ||
2402 | .finup = ahash_finup, | ||
2403 | .digest = ahash_digest, | ||
2404 | .setkey = ahash_setkey, | ||
2405 | .halg.digestsize = MD5_DIGEST_SIZE, | 2346 | .halg.digestsize = MD5_DIGEST_SIZE, |
2406 | .halg.base = { | 2347 | .halg.base = { |
2407 | .cra_name = "hmac(md5)", | 2348 | .cra_name = "hmac(md5)", |
@@ -2409,7 +2350,6 @@ static struct talitos_alg_template driver_algs[] = { | |||
2409 | .cra_blocksize = MD5_BLOCK_SIZE, | 2350 | .cra_blocksize = MD5_BLOCK_SIZE, |
2410 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | | 2351 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | |
2411 | CRYPTO_ALG_ASYNC, | 2352 | CRYPTO_ALG_ASYNC, |
2412 | .cra_type = &crypto_ahash_type | ||
2413 | } | 2353 | } |
2414 | }, | 2354 | }, |
2415 | .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | | 2355 | .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | |
@@ -2418,12 +2358,6 @@ static struct talitos_alg_template driver_algs[] = { | |||
2418 | }, | 2358 | }, |
2419 | { .type = CRYPTO_ALG_TYPE_AHASH, | 2359 | { .type = CRYPTO_ALG_TYPE_AHASH, |
2420 | .alg.hash = { | 2360 | .alg.hash = { |
2421 | .init = ahash_init, | ||
2422 | .update = ahash_update, | ||
2423 | .final = ahash_final, | ||
2424 | .finup = ahash_finup, | ||
2425 | .digest = ahash_digest, | ||
2426 | .setkey = ahash_setkey, | ||
2427 | .halg.digestsize = SHA1_DIGEST_SIZE, | 2361 | .halg.digestsize = SHA1_DIGEST_SIZE, |
2428 | .halg.base = { | 2362 | .halg.base = { |
2429 | .cra_name = "hmac(sha1)", | 2363 | .cra_name = "hmac(sha1)", |
@@ -2431,7 +2365,6 @@ static struct talitos_alg_template driver_algs[] = { | |||
2431 | .cra_blocksize = SHA1_BLOCK_SIZE, | 2365 | .cra_blocksize = SHA1_BLOCK_SIZE, |
2432 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | | 2366 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | |
2433 | CRYPTO_ALG_ASYNC, | 2367 | CRYPTO_ALG_ASYNC, |
2434 | .cra_type = &crypto_ahash_type | ||
2435 | } | 2368 | } |
2436 | }, | 2369 | }, |
2437 | .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | | 2370 | .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | |
@@ -2440,12 +2373,6 @@ static struct talitos_alg_template driver_algs[] = { | |||
2440 | }, | 2373 | }, |
2441 | { .type = CRYPTO_ALG_TYPE_AHASH, | 2374 | { .type = CRYPTO_ALG_TYPE_AHASH, |
2442 | .alg.hash = { | 2375 | .alg.hash = { |
2443 | .init = ahash_init, | ||
2444 | .update = ahash_update, | ||
2445 | .final = ahash_final, | ||
2446 | .finup = ahash_finup, | ||
2447 | .digest = ahash_digest, | ||
2448 | .setkey = ahash_setkey, | ||
2449 | .halg.digestsize = SHA224_DIGEST_SIZE, | 2376 | .halg.digestsize = SHA224_DIGEST_SIZE, |
2450 | .halg.base = { | 2377 | .halg.base = { |
2451 | .cra_name = "hmac(sha224)", | 2378 | .cra_name = "hmac(sha224)", |
@@ -2453,7 +2380,6 @@ static struct talitos_alg_template driver_algs[] = { | |||
2453 | .cra_blocksize = SHA224_BLOCK_SIZE, | 2380 | .cra_blocksize = SHA224_BLOCK_SIZE, |
2454 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | | 2381 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | |
2455 | CRYPTO_ALG_ASYNC, | 2382 | CRYPTO_ALG_ASYNC, |
2456 | .cra_type = &crypto_ahash_type | ||
2457 | } | 2383 | } |
2458 | }, | 2384 | }, |
2459 | .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | | 2385 | .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | |
@@ -2462,12 +2388,6 @@ static struct talitos_alg_template driver_algs[] = { | |||
2462 | }, | 2388 | }, |
2463 | { .type = CRYPTO_ALG_TYPE_AHASH, | 2389 | { .type = CRYPTO_ALG_TYPE_AHASH, |
2464 | .alg.hash = { | 2390 | .alg.hash = { |
2465 | .init = ahash_init, | ||
2466 | .update = ahash_update, | ||
2467 | .final = ahash_final, | ||
2468 | .finup = ahash_finup, | ||
2469 | .digest = ahash_digest, | ||
2470 | .setkey = ahash_setkey, | ||
2471 | .halg.digestsize = SHA256_DIGEST_SIZE, | 2391 | .halg.digestsize = SHA256_DIGEST_SIZE, |
2472 | .halg.base = { | 2392 | .halg.base = { |
2473 | .cra_name = "hmac(sha256)", | 2393 | .cra_name = "hmac(sha256)", |
@@ -2475,7 +2395,6 @@ static struct talitos_alg_template driver_algs[] = { | |||
2475 | .cra_blocksize = SHA256_BLOCK_SIZE, | 2395 | .cra_blocksize = SHA256_BLOCK_SIZE, |
2476 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | | 2396 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | |
2477 | CRYPTO_ALG_ASYNC, | 2397 | CRYPTO_ALG_ASYNC, |
2478 | .cra_type = &crypto_ahash_type | ||
2479 | } | 2398 | } |
2480 | }, | 2399 | }, |
2481 | .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | | 2400 | .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | |
@@ -2484,12 +2403,6 @@ static struct talitos_alg_template driver_algs[] = { | |||
2484 | }, | 2403 | }, |
2485 | { .type = CRYPTO_ALG_TYPE_AHASH, | 2404 | { .type = CRYPTO_ALG_TYPE_AHASH, |
2486 | .alg.hash = { | 2405 | .alg.hash = { |
2487 | .init = ahash_init, | ||
2488 | .update = ahash_update, | ||
2489 | .final = ahash_final, | ||
2490 | .finup = ahash_finup, | ||
2491 | .digest = ahash_digest, | ||
2492 | .setkey = ahash_setkey, | ||
2493 | .halg.digestsize = SHA384_DIGEST_SIZE, | 2406 | .halg.digestsize = SHA384_DIGEST_SIZE, |
2494 | .halg.base = { | 2407 | .halg.base = { |
2495 | .cra_name = "hmac(sha384)", | 2408 | .cra_name = "hmac(sha384)", |
@@ -2497,7 +2410,6 @@ static struct talitos_alg_template driver_algs[] = { | |||
2497 | .cra_blocksize = SHA384_BLOCK_SIZE, | 2410 | .cra_blocksize = SHA384_BLOCK_SIZE, |
2498 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | | 2411 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | |
2499 | CRYPTO_ALG_ASYNC, | 2412 | CRYPTO_ALG_ASYNC, |
2500 | .cra_type = &crypto_ahash_type | ||
2501 | } | 2413 | } |
2502 | }, | 2414 | }, |
2503 | .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | | 2415 | .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | |
@@ -2506,12 +2418,6 @@ static struct talitos_alg_template driver_algs[] = { | |||
2506 | }, | 2418 | }, |
2507 | { .type = CRYPTO_ALG_TYPE_AHASH, | 2419 | { .type = CRYPTO_ALG_TYPE_AHASH, |
2508 | .alg.hash = { | 2420 | .alg.hash = { |
2509 | .init = ahash_init, | ||
2510 | .update = ahash_update, | ||
2511 | .final = ahash_final, | ||
2512 | .finup = ahash_finup, | ||
2513 | .digest = ahash_digest, | ||
2514 | .setkey = ahash_setkey, | ||
2515 | .halg.digestsize = SHA512_DIGEST_SIZE, | 2421 | .halg.digestsize = SHA512_DIGEST_SIZE, |
2516 | .halg.base = { | 2422 | .halg.base = { |
2517 | .cra_name = "hmac(sha512)", | 2423 | .cra_name = "hmac(sha512)", |
@@ -2519,7 +2425,6 @@ static struct talitos_alg_template driver_algs[] = { | |||
2519 | .cra_blocksize = SHA512_BLOCK_SIZE, | 2425 | .cra_blocksize = SHA512_BLOCK_SIZE, |
2520 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | | 2426 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | |
2521 | CRYPTO_ALG_ASYNC, | 2427 | CRYPTO_ALG_ASYNC, |
2522 | .cra_type = &crypto_ahash_type | ||
2523 | } | 2428 | } |
2524 | }, | 2429 | }, |
2525 | .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | | 2430 | .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | |
@@ -2677,14 +2582,34 @@ static struct talitos_crypto_alg *talitos_alg_alloc(struct device *dev, | |||
2677 | case CRYPTO_ALG_TYPE_ABLKCIPHER: | 2582 | case CRYPTO_ALG_TYPE_ABLKCIPHER: |
2678 | alg = &t_alg->algt.alg.crypto; | 2583 | alg = &t_alg->algt.alg.crypto; |
2679 | alg->cra_init = talitos_cra_init; | 2584 | alg->cra_init = talitos_cra_init; |
2585 | alg->cra_type = &crypto_ablkcipher_type; | ||
2586 | alg->cra_ablkcipher.setkey = ablkcipher_setkey; | ||
2587 | alg->cra_ablkcipher.encrypt = ablkcipher_encrypt; | ||
2588 | alg->cra_ablkcipher.decrypt = ablkcipher_decrypt; | ||
2589 | alg->cra_ablkcipher.geniv = "eseqiv"; | ||
2680 | break; | 2590 | break; |
2681 | case CRYPTO_ALG_TYPE_AEAD: | 2591 | case CRYPTO_ALG_TYPE_AEAD: |
2682 | alg = &t_alg->algt.alg.crypto; | 2592 | alg = &t_alg->algt.alg.crypto; |
2683 | alg->cra_init = talitos_cra_init_aead; | 2593 | alg->cra_init = talitos_cra_init_aead; |
2594 | alg->cra_type = &crypto_aead_type; | ||
2595 | alg->cra_aead.setkey = aead_setkey; | ||
2596 | alg->cra_aead.setauthsize = aead_setauthsize; | ||
2597 | alg->cra_aead.encrypt = aead_encrypt; | ||
2598 | alg->cra_aead.decrypt = aead_decrypt; | ||
2599 | alg->cra_aead.givencrypt = aead_givencrypt; | ||
2600 | alg->cra_aead.geniv = "<built-in>"; | ||
2684 | break; | 2601 | break; |
2685 | case CRYPTO_ALG_TYPE_AHASH: | 2602 | case CRYPTO_ALG_TYPE_AHASH: |
2686 | alg = &t_alg->algt.alg.hash.halg.base; | 2603 | alg = &t_alg->algt.alg.hash.halg.base; |
2687 | alg->cra_init = talitos_cra_init_ahash; | 2604 | alg->cra_init = talitos_cra_init_ahash; |
2605 | alg->cra_type = &crypto_ahash_type; | ||
2606 | t_alg->algt.alg.hash.init = ahash_init; | ||
2607 | t_alg->algt.alg.hash.update = ahash_update; | ||
2608 | t_alg->algt.alg.hash.final = ahash_final; | ||
2609 | t_alg->algt.alg.hash.finup = ahash_finup; | ||
2610 | t_alg->algt.alg.hash.digest = ahash_digest; | ||
2611 | t_alg->algt.alg.hash.setkey = ahash_setkey; | ||
2612 | |||
2688 | if (!(priv->features & TALITOS_FTR_HMAC_OK) && | 2613 | if (!(priv->features & TALITOS_FTR_HMAC_OK) && |
2689 | !strncmp(alg->cra_name, "hmac", 4)) { | 2614 | !strncmp(alg->cra_name, "hmac", 4)) { |
2690 | kfree(t_alg); | 2615 | kfree(t_alg); |
@@ -2896,7 +2821,9 @@ static int talitos_probe(struct platform_device *ofdev) | |||
2896 | if (hw_supports(dev, driver_algs[i].desc_hdr_template)) { | 2821 | if (hw_supports(dev, driver_algs[i].desc_hdr_template)) { |
2897 | struct talitos_crypto_alg *t_alg; | 2822 | struct talitos_crypto_alg *t_alg; |
2898 | char *name = NULL; | 2823 | char *name = NULL; |
2824 | bool authenc = false; | ||
2899 | 2825 | ||
2826 | authencesn: | ||
2900 | t_alg = talitos_alg_alloc(dev, &driver_algs[i]); | 2827 | t_alg = talitos_alg_alloc(dev, &driver_algs[i]); |
2901 | if (IS_ERR(t_alg)) { | 2828 | if (IS_ERR(t_alg)) { |
2902 | err = PTR_ERR(t_alg); | 2829 | err = PTR_ERR(t_alg); |
@@ -2911,6 +2838,8 @@ static int talitos_probe(struct platform_device *ofdev) | |||
2911 | err = crypto_register_alg( | 2838 | err = crypto_register_alg( |
2912 | &t_alg->algt.alg.crypto); | 2839 | &t_alg->algt.alg.crypto); |
2913 | name = t_alg->algt.alg.crypto.cra_driver_name; | 2840 | name = t_alg->algt.alg.crypto.cra_driver_name; |
2841 | authenc = authenc ? !authenc : | ||
2842 | !(bool)memcmp(name, "authenc", 7); | ||
2914 | break; | 2843 | break; |
2915 | case CRYPTO_ALG_TYPE_AHASH: | 2844 | case CRYPTO_ALG_TYPE_AHASH: |
2916 | err = crypto_register_ahash( | 2845 | err = crypto_register_ahash( |
@@ -2923,8 +2852,25 @@ static int talitos_probe(struct platform_device *ofdev) | |||
2923 | dev_err(dev, "%s alg registration failed\n", | 2852 | dev_err(dev, "%s alg registration failed\n", |
2924 | name); | 2853 | name); |
2925 | kfree(t_alg); | 2854 | kfree(t_alg); |
2926 | } else | 2855 | } else { |
2927 | list_add_tail(&t_alg->entry, &priv->alg_list); | 2856 | list_add_tail(&t_alg->entry, &priv->alg_list); |
2857 | if (authenc) { | ||
2858 | struct crypto_alg *alg = | ||
2859 | &driver_algs[i].alg.crypto; | ||
2860 | |||
2861 | name = alg->cra_name; | ||
2862 | memmove(name + 10, name + 7, | ||
2863 | strlen(name) - 7); | ||
2864 | memcpy(name + 7, "esn", 3); | ||
2865 | |||
2866 | name = alg->cra_driver_name; | ||
2867 | memmove(name + 10, name + 7, | ||
2868 | strlen(name) - 7); | ||
2869 | memcpy(name + 7, "esn", 3); | ||
2870 | |||
2871 | goto authencesn; | ||
2872 | } | ||
2873 | } | ||
2928 | } | 2874 | } |
2929 | } | 2875 | } |
2930 | if (!list_empty(&priv->alg_list)) | 2876 | if (!list_empty(&priv->alg_list)) |
diff --git a/drivers/crypto/tegra-aes.c b/drivers/crypto/tegra-aes.c index ac236f6724f4..37185e6630cd 100644 --- a/drivers/crypto/tegra-aes.c +++ b/drivers/crypto/tegra-aes.c | |||
@@ -969,6 +969,7 @@ static int tegra_aes_probe(struct platform_device *pdev) | |||
969 | aes_wq = alloc_workqueue("tegra_aes_wq", WQ_HIGHPRI | WQ_UNBOUND, 1); | 969 | aes_wq = alloc_workqueue("tegra_aes_wq", WQ_HIGHPRI | WQ_UNBOUND, 1); |
970 | if (!aes_wq) { | 970 | if (!aes_wq) { |
971 | dev_err(dev, "alloc_workqueue failed\n"); | 971 | dev_err(dev, "alloc_workqueue failed\n"); |
972 | err = -ENOMEM; | ||
972 | goto out; | 973 | goto out; |
973 | } | 974 | } |
974 | 975 | ||
@@ -1004,8 +1005,6 @@ static int tegra_aes_probe(struct platform_device *pdev) | |||
1004 | 1005 | ||
1005 | aes_dev = dd; | 1006 | aes_dev = dd; |
1006 | for (i = 0; i < ARRAY_SIZE(algs); i++) { | 1007 | for (i = 0; i < ARRAY_SIZE(algs); i++) { |
1007 | INIT_LIST_HEAD(&algs[i].cra_list); | ||
1008 | |||
1009 | algs[i].cra_priority = 300; | 1008 | algs[i].cra_priority = 300; |
1010 | algs[i].cra_ctxsize = sizeof(struct tegra_aes_ctx); | 1009 | algs[i].cra_ctxsize = sizeof(struct tegra_aes_ctx); |
1011 | algs[i].cra_module = THIS_MODULE; | 1010 | algs[i].cra_module = THIS_MODULE; |
diff --git a/drivers/crypto/ux500/cryp/cryp_core.c b/drivers/crypto/ux500/cryp/cryp_core.c index ef17e3871c71..bc615cc56266 100644 --- a/drivers/crypto/ux500/cryp/cryp_core.c +++ b/drivers/crypto/ux500/cryp/cryp_core.c | |||
@@ -1486,6 +1486,7 @@ static int ux500_cryp_probe(struct platform_device *pdev) | |||
1486 | if (!res_irq) { | 1486 | if (!res_irq) { |
1487 | dev_err(dev, "[%s]: IORESOURCE_IRQ unavailable", | 1487 | dev_err(dev, "[%s]: IORESOURCE_IRQ unavailable", |
1488 | __func__); | 1488 | __func__); |
1489 | ret = -ENODEV; | ||
1489 | goto out_power; | 1490 | goto out_power; |
1490 | } | 1491 | } |
1491 | 1492 | ||
diff --git a/drivers/crypto/ux500/hash/hash_core.c b/drivers/crypto/ux500/hash/hash_core.c index 08765072a2b3..632c3339895f 100644 --- a/drivers/crypto/ux500/hash/hash_core.c +++ b/drivers/crypto/ux500/hash/hash_core.c | |||
@@ -1991,7 +1991,6 @@ static int __init ux500_hash_mod_init(void) | |||
1991 | static void __exit ux500_hash_mod_fini(void) | 1991 | static void __exit ux500_hash_mod_fini(void) |
1992 | { | 1992 | { |
1993 | platform_driver_unregister(&hash_driver); | 1993 | platform_driver_unregister(&hash_driver); |
1994 | return; | ||
1995 | } | 1994 | } |
1996 | 1995 | ||
1997 | module_init(ux500_hash_mod_init); | 1996 | module_init(ux500_hash_mod_init); |
diff --git a/include/crypto/cast5.h b/include/crypto/cast5.h new file mode 100644 index 000000000000..586183a0406e --- /dev/null +++ b/include/crypto/cast5.h | |||
@@ -0,0 +1,27 @@ | |||
1 | #ifndef _CRYPTO_CAST5_H | ||
2 | #define _CRYPTO_CAST5_H | ||
3 | |||
4 | #include <linux/types.h> | ||
5 | #include <linux/crypto.h> | ||
6 | |||
7 | #define CAST5_BLOCK_SIZE 8 | ||
8 | #define CAST5_MIN_KEY_SIZE 5 | ||
9 | #define CAST5_MAX_KEY_SIZE 16 | ||
10 | |||
11 | struct cast5_ctx { | ||
12 | u32 Km[16]; | ||
13 | u8 Kr[16]; | ||
14 | int rr; /* rr ? rounds = 12 : rounds = 16; (rfc 2144) */ | ||
15 | }; | ||
16 | |||
17 | int cast5_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen); | ||
18 | |||
19 | void __cast5_encrypt(struct cast5_ctx *ctx, u8 *dst, const u8 *src); | ||
20 | void __cast5_decrypt(struct cast5_ctx *ctx, u8 *dst, const u8 *src); | ||
21 | |||
22 | extern const u32 cast5_s1[256]; | ||
23 | extern const u32 cast5_s2[256]; | ||
24 | extern const u32 cast5_s3[256]; | ||
25 | extern const u32 cast5_s4[256]; | ||
26 | |||
27 | #endif | ||
diff --git a/include/crypto/cast6.h b/include/crypto/cast6.h new file mode 100644 index 000000000000..157af6f342c8 --- /dev/null +++ b/include/crypto/cast6.h | |||
@@ -0,0 +1,28 @@ | |||
1 | #ifndef _CRYPTO_CAST6_H | ||
2 | #define _CRYPTO_CAST6_H | ||
3 | |||
4 | #include <linux/types.h> | ||
5 | #include <linux/crypto.h> | ||
6 | |||
7 | #define CAST6_BLOCK_SIZE 16 | ||
8 | #define CAST6_MIN_KEY_SIZE 16 | ||
9 | #define CAST6_MAX_KEY_SIZE 32 | ||
10 | |||
11 | struct cast6_ctx { | ||
12 | u32 Km[12][4]; | ||
13 | u8 Kr[12][4]; | ||
14 | }; | ||
15 | |||
16 | int __cast6_setkey(struct cast6_ctx *ctx, const u8 *key, | ||
17 | unsigned int keylen, u32 *flags); | ||
18 | int cast6_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen); | ||
19 | |||
20 | void __cast6_encrypt(struct cast6_ctx *ctx, u8 *dst, const u8 *src); | ||
21 | void __cast6_decrypt(struct cast6_ctx *ctx, u8 *dst, const u8 *src); | ||
22 | |||
23 | extern const u32 cast6_s1[256]; | ||
24 | extern const u32 cast6_s2[256]; | ||
25 | extern const u32 cast6_s3[256]; | ||
26 | extern const u32 cast6_s4[256]; | ||
27 | |||
28 | #endif | ||
diff --git a/include/crypto/internal/hash.h b/include/crypto/internal/hash.h index 5bfad8c80595..821eae8cbd8c 100644 --- a/include/crypto/internal/hash.h +++ b/include/crypto/internal/hash.h | |||
@@ -83,6 +83,8 @@ struct hash_alg_common *ahash_attr_alg(struct rtattr *rta, u32 type, u32 mask); | |||
83 | 83 | ||
84 | int crypto_register_shash(struct shash_alg *alg); | 84 | int crypto_register_shash(struct shash_alg *alg); |
85 | int crypto_unregister_shash(struct shash_alg *alg); | 85 | int crypto_unregister_shash(struct shash_alg *alg); |
86 | int crypto_register_shashes(struct shash_alg *algs, int count); | ||
87 | int crypto_unregister_shashes(struct shash_alg *algs, int count); | ||
86 | int shash_register_instance(struct crypto_template *tmpl, | 88 | int shash_register_instance(struct crypto_template *tmpl, |
87 | struct shash_instance *inst); | 89 | struct shash_instance *inst); |
88 | void shash_free_instance(struct crypto_instance *inst); | 90 | void shash_free_instance(struct crypto_instance *inst); |
diff --git a/include/linux/nx842.h b/include/linux/nx842.h new file mode 100644 index 000000000000..a4d324c6406a --- /dev/null +++ b/include/linux/nx842.h | |||
@@ -0,0 +1,11 @@ | |||
1 | #ifndef __NX842_H__ | ||
2 | #define __NX842_H__ | ||
3 | |||
4 | int nx842_get_workmem_size(void); | ||
5 | int nx842_get_workmem_size_aligned(void); | ||
6 | int nx842_compress(const unsigned char *in, unsigned int in_len, | ||
7 | unsigned char *out, unsigned int *out_len, void *wrkmem); | ||
8 | int nx842_decompress(const unsigned char *in, unsigned int in_len, | ||
9 | unsigned char *out, unsigned int *out_len, void *wrkmem); | ||
10 | |||
11 | #endif | ||