diff options
author | Jiri Kosina <jkosina@suse.cz> | 2011-11-13 14:55:35 -0500 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2011-11-13 14:55:53 -0500 |
commit | 2290c0d06d82faee87b1ab2d9d4f7bf81ef64379 (patch) | |
tree | e075e4d5534193f28e6059904f61e5ca03958d3c /crypto | |
parent | 4da669a2e3e5bc70b30a0465f3641528681b5f77 (diff) | |
parent | 52e4c2a05256cb83cda12f3c2137ab1533344edb (diff) |
Merge branch 'master' into for-next
Sync with Linus tree to have 157550ff ("mtd: add GPMI-NAND driver
in the config and Makefile") as I have patch depending on that one.
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/Kconfig | 63 | ||||
-rw-r--r-- | crypto/Makefile | 4 | ||||
-rw-r--r-- | crypto/ablkcipher.c | 62 | ||||
-rw-r--r-- | crypto/aead.c | 62 | ||||
-rw-r--r-- | crypto/ahash.c | 28 | ||||
-rw-r--r-- | crypto/algapi.c | 12 | ||||
-rw-r--r-- | crypto/async_tx/async_memcpy.c | 1 | ||||
-rw-r--r-- | crypto/async_tx/async_pq.c | 1 | ||||
-rw-r--r-- | crypto/async_tx/async_raid6_recov.c | 1 | ||||
-rw-r--r-- | crypto/async_tx/async_tx.c | 1 | ||||
-rw-r--r-- | crypto/async_tx/async_xor.c | 1 | ||||
-rw-r--r-- | crypto/async_tx/raid6test.c | 1 | ||||
-rw-r--r-- | crypto/blkcipher.c | 32 | ||||
-rw-r--r-- | crypto/blowfish_common.c (renamed from crypto/blowfish.c) | 98 | ||||
-rw-r--r-- | crypto/blowfish_generic.c | 142 | ||||
-rw-r--r-- | crypto/cryptd.c | 2 | ||||
-rw-r--r-- | crypto/crypto_user.c | 435 | ||||
-rw-r--r-- | crypto/crypto_wq.c | 1 | ||||
-rw-r--r-- | crypto/internal.h | 3 | ||||
-rw-r--r-- | crypto/md4.c | 1 | ||||
-rw-r--r-- | crypto/pcompress.c | 25 | ||||
-rw-r--r-- | crypto/proc.c | 1 | ||||
-rw-r--r-- | crypto/rng.c | 27 | ||||
-rw-r--r-- | crypto/sha1_generic.c | 9 | ||||
-rw-r--r-- | crypto/shash.c | 28 | ||||
-rw-r--r-- | crypto/tcrypt.c | 10 | ||||
-rw-r--r-- | crypto/testmgr.c | 30 | ||||
-rw-r--r-- | crypto/testmgr.h | 398 | ||||
-rw-r--r-- | crypto/vmac.c | 1 | ||||
-rw-r--r-- | crypto/wp512.c | 18 | ||||
-rw-r--r-- | crypto/xcbc.c | 1 |
31 files changed, 1384 insertions, 115 deletions
diff --git a/crypto/Kconfig b/crypto/Kconfig index 82d4d454e1f..ae9c3ceb286 100644 --- a/crypto/Kconfig +++ b/crypto/Kconfig | |||
@@ -100,6 +100,14 @@ config CRYPTO_MANAGER2 | |||
100 | select CRYPTO_BLKCIPHER2 | 100 | select CRYPTO_BLKCIPHER2 |
101 | select CRYPTO_PCOMP2 | 101 | select CRYPTO_PCOMP2 |
102 | 102 | ||
103 | config CRYPTO_USER | ||
104 | tristate "Userspace cryptographic algorithm configuration" | ||
105 | depends on NET | ||
106 | select CRYPTO_MANAGER | ||
107 | help | ||
108 | Userapace configuration for cryptographic instantiations such as | ||
109 | cbc(aes). | ||
110 | |||
103 | config CRYPTO_MANAGER_DISABLE_TESTS | 111 | config CRYPTO_MANAGER_DISABLE_TESTS |
104 | bool "Disable run-time self tests" | 112 | bool "Disable run-time self tests" |
105 | default y | 113 | default y |
@@ -406,6 +414,16 @@ config CRYPTO_SHA1 | |||
406 | help | 414 | help |
407 | SHA-1 secure hash standard (FIPS 180-1/DFIPS 180-2). | 415 | SHA-1 secure hash standard (FIPS 180-1/DFIPS 180-2). |
408 | 416 | ||
417 | config CRYPTO_SHA1_SSSE3 | ||
418 | tristate "SHA1 digest algorithm (SSSE3/AVX)" | ||
419 | depends on X86 && 64BIT | ||
420 | select CRYPTO_SHA1 | ||
421 | select CRYPTO_HASH | ||
422 | help | ||
423 | SHA-1 secure hash standard (FIPS 180-1/DFIPS 180-2) implemented | ||
424 | using Supplemental SSE3 (SSSE3) instructions or Advanced Vector | ||
425 | Extensions (AVX), when available. | ||
426 | |||
409 | config CRYPTO_SHA256 | 427 | config CRYPTO_SHA256 |
410 | tristate "SHA224 and SHA256 digest algorithm" | 428 | tristate "SHA224 and SHA256 digest algorithm" |
411 | select CRYPTO_HASH | 429 | select CRYPTO_HASH |
@@ -588,6 +606,7 @@ config CRYPTO_ARC4 | |||
588 | config CRYPTO_BLOWFISH | 606 | config CRYPTO_BLOWFISH |
589 | tristate "Blowfish cipher algorithm" | 607 | tristate "Blowfish cipher algorithm" |
590 | select CRYPTO_ALGAPI | 608 | select CRYPTO_ALGAPI |
609 | select CRYPTO_BLOWFISH_COMMON | ||
591 | help | 610 | help |
592 | Blowfish cipher algorithm, by Bruce Schneier. | 611 | Blowfish cipher algorithm, by Bruce Schneier. |
593 | 612 | ||
@@ -598,6 +617,30 @@ config CRYPTO_BLOWFISH | |||
598 | See also: | 617 | See also: |
599 | <http://www.schneier.com/blowfish.html> | 618 | <http://www.schneier.com/blowfish.html> |
600 | 619 | ||
620 | config CRYPTO_BLOWFISH_COMMON | ||
621 | tristate | ||
622 | help | ||
623 | Common parts of the Blowfish cipher algorithm shared by the | ||
624 | generic c and the assembler implementations. | ||
625 | |||
626 | See also: | ||
627 | <http://www.schneier.com/blowfish.html> | ||
628 | |||
629 | config CRYPTO_BLOWFISH_X86_64 | ||
630 | tristate "Blowfish cipher algorithm (x86_64)" | ||
631 | depends on (X86 || UML_X86) && 64BIT | ||
632 | select CRYPTO_ALGAPI | ||
633 | select CRYPTO_BLOWFISH_COMMON | ||
634 | help | ||
635 | Blowfish cipher algorithm (x86_64), by Bruce Schneier. | ||
636 | |||
637 | This is a variable key length cipher which can use keys from 32 | ||
638 | bits to 448 bits in length. It's fast, simple and specifically | ||
639 | designed for use on "large microprocessors". | ||
640 | |||
641 | See also: | ||
642 | <http://www.schneier.com/blowfish.html> | ||
643 | |||
601 | config CRYPTO_CAMELLIA | 644 | config CRYPTO_CAMELLIA |
602 | tristate "Camellia cipher algorithms" | 645 | tristate "Camellia cipher algorithms" |
603 | depends on CRYPTO | 646 | depends on CRYPTO |
@@ -791,6 +834,26 @@ config CRYPTO_TWOFISH_X86_64 | |||
791 | See also: | 834 | See also: |
792 | <http://www.schneier.com/twofish.html> | 835 | <http://www.schneier.com/twofish.html> |
793 | 836 | ||
837 | config CRYPTO_TWOFISH_X86_64_3WAY | ||
838 | tristate "Twofish cipher algorithm (x86_64, 3-way parallel)" | ||
839 | depends on (X86 || UML_X86) && 64BIT | ||
840 | select CRYPTO_ALGAPI | ||
841 | select CRYPTO_TWOFISH_COMMON | ||
842 | select CRYPTO_TWOFISH_X86_64 | ||
843 | help | ||
844 | Twofish cipher algorithm (x86_64, 3-way parallel). | ||
845 | |||
846 | Twofish was submitted as an AES (Advanced Encryption Standard) | ||
847 | candidate cipher by researchers at CounterPane Systems. It is a | ||
848 | 16 round block cipher supporting key sizes of 128, 192, and 256 | ||
849 | bits. | ||
850 | |||
851 | This module provides Twofish cipher algorithm that processes three | ||
852 | blocks parallel, utilizing resources of out-of-order CPUs better. | ||
853 | |||
854 | See also: | ||
855 | <http://www.schneier.com/twofish.html> | ||
856 | |||
794 | comment "Compression" | 857 | comment "Compression" |
795 | 858 | ||
796 | config CRYPTO_DEFLATE | 859 | config CRYPTO_DEFLATE |
diff --git a/crypto/Makefile b/crypto/Makefile index ce5a813d363..9e6eee2c05d 100644 --- a/crypto/Makefile +++ b/crypto/Makefile | |||
@@ -31,6 +31,7 @@ obj-$(CONFIG_CRYPTO_PCOMP2) += pcompress.o | |||
31 | cryptomgr-y := algboss.o testmgr.o | 31 | cryptomgr-y := algboss.o testmgr.o |
32 | 32 | ||
33 | obj-$(CONFIG_CRYPTO_MANAGER2) += cryptomgr.o | 33 | obj-$(CONFIG_CRYPTO_MANAGER2) += cryptomgr.o |
34 | obj-$(CONFIG_CRYPTO_USER) += crypto_user.o | ||
34 | obj-$(CONFIG_CRYPTO_HMAC) += hmac.o | 35 | obj-$(CONFIG_CRYPTO_HMAC) += hmac.o |
35 | obj-$(CONFIG_CRYPTO_VMAC) += vmac.o | 36 | obj-$(CONFIG_CRYPTO_VMAC) += vmac.o |
36 | obj-$(CONFIG_CRYPTO_XCBC) += xcbc.o | 37 | obj-$(CONFIG_CRYPTO_XCBC) += xcbc.o |
@@ -60,7 +61,8 @@ obj-$(CONFIG_CRYPTO_PCRYPT) += pcrypt.o | |||
60 | obj-$(CONFIG_CRYPTO_CRYPTD) += cryptd.o | 61 | obj-$(CONFIG_CRYPTO_CRYPTD) += cryptd.o |
61 | obj-$(CONFIG_CRYPTO_DES) += des_generic.o | 62 | obj-$(CONFIG_CRYPTO_DES) += des_generic.o |
62 | obj-$(CONFIG_CRYPTO_FCRYPT) += fcrypt.o | 63 | obj-$(CONFIG_CRYPTO_FCRYPT) += fcrypt.o |
63 | obj-$(CONFIG_CRYPTO_BLOWFISH) += blowfish.o | 64 | obj-$(CONFIG_CRYPTO_BLOWFISH) += blowfish_generic.o |
65 | obj-$(CONFIG_CRYPTO_BLOWFISH_COMMON) += blowfish_common.o | ||
64 | obj-$(CONFIG_CRYPTO_TWOFISH) += twofish_generic.o | 66 | obj-$(CONFIG_CRYPTO_TWOFISH) += twofish_generic.o |
65 | obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o | 67 | obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o |
66 | obj-$(CONFIG_CRYPTO_SERPENT) += serpent.o | 68 | obj-$(CONFIG_CRYPTO_SERPENT) += serpent.o |
diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c index fdc67d38660..a0f768c1d9a 100644 --- a/crypto/ablkcipher.c +++ b/crypto/ablkcipher.c | |||
@@ -23,6 +23,8 @@ | |||
23 | #include <linux/sched.h> | 23 | #include <linux/sched.h> |
24 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
25 | #include <linux/seq_file.h> | 25 | #include <linux/seq_file.h> |
26 | #include <linux/cryptouser.h> | ||
27 | #include <net/netlink.h> | ||
26 | 28 | ||
27 | #include <crypto/scatterwalk.h> | 29 | #include <crypto/scatterwalk.h> |
28 | 30 | ||
@@ -381,6 +383,35 @@ static int crypto_init_ablkcipher_ops(struct crypto_tfm *tfm, u32 type, | |||
381 | return 0; | 383 | return 0; |
382 | } | 384 | } |
383 | 385 | ||
386 | #ifdef CONFIG_NET | ||
387 | static int crypto_ablkcipher_report(struct sk_buff *skb, struct crypto_alg *alg) | ||
388 | { | ||
389 | struct crypto_report_blkcipher rblkcipher; | ||
390 | |||
391 | snprintf(rblkcipher.type, CRYPTO_MAX_ALG_NAME, "%s", "ablkcipher"); | ||
392 | snprintf(rblkcipher.geniv, CRYPTO_MAX_ALG_NAME, "%s", | ||
393 | alg->cra_ablkcipher.geniv ?: "<default>"); | ||
394 | |||
395 | rblkcipher.blocksize = alg->cra_blocksize; | ||
396 | rblkcipher.min_keysize = alg->cra_ablkcipher.min_keysize; | ||
397 | rblkcipher.max_keysize = alg->cra_ablkcipher.max_keysize; | ||
398 | rblkcipher.ivsize = alg->cra_ablkcipher.ivsize; | ||
399 | |||
400 | NLA_PUT(skb, CRYPTOCFGA_REPORT_BLKCIPHER, | ||
401 | sizeof(struct crypto_report_blkcipher), &rblkcipher); | ||
402 | |||
403 | return 0; | ||
404 | |||
405 | nla_put_failure: | ||
406 | return -EMSGSIZE; | ||
407 | } | ||
408 | #else | ||
409 | static int crypto_ablkcipher_report(struct sk_buff *skb, struct crypto_alg *alg) | ||
410 | { | ||
411 | return -ENOSYS; | ||
412 | } | ||
413 | #endif | ||
414 | |||
384 | static void crypto_ablkcipher_show(struct seq_file *m, struct crypto_alg *alg) | 415 | static void crypto_ablkcipher_show(struct seq_file *m, struct crypto_alg *alg) |
385 | __attribute__ ((unused)); | 416 | __attribute__ ((unused)); |
386 | static void crypto_ablkcipher_show(struct seq_file *m, struct crypto_alg *alg) | 417 | static void crypto_ablkcipher_show(struct seq_file *m, struct crypto_alg *alg) |
@@ -403,6 +434,7 @@ const struct crypto_type crypto_ablkcipher_type = { | |||
403 | #ifdef CONFIG_PROC_FS | 434 | #ifdef CONFIG_PROC_FS |
404 | .show = crypto_ablkcipher_show, | 435 | .show = crypto_ablkcipher_show, |
405 | #endif | 436 | #endif |
437 | .report = crypto_ablkcipher_report, | ||
406 | }; | 438 | }; |
407 | EXPORT_SYMBOL_GPL(crypto_ablkcipher_type); | 439 | EXPORT_SYMBOL_GPL(crypto_ablkcipher_type); |
408 | 440 | ||
@@ -432,6 +464,35 @@ static int crypto_init_givcipher_ops(struct crypto_tfm *tfm, u32 type, | |||
432 | return 0; | 464 | return 0; |
433 | } | 465 | } |
434 | 466 | ||
467 | #ifdef CONFIG_NET | ||
468 | static int crypto_givcipher_report(struct sk_buff *skb, struct crypto_alg *alg) | ||
469 | { | ||
470 | struct crypto_report_blkcipher rblkcipher; | ||
471 | |||
472 | snprintf(rblkcipher.type, CRYPTO_MAX_ALG_NAME, "%s", "givcipher"); | ||
473 | snprintf(rblkcipher.geniv, CRYPTO_MAX_ALG_NAME, "%s", | ||
474 | alg->cra_ablkcipher.geniv ?: "<built-in>"); | ||
475 | |||
476 | rblkcipher.blocksize = alg->cra_blocksize; | ||
477 | rblkcipher.min_keysize = alg->cra_ablkcipher.min_keysize; | ||
478 | rblkcipher.max_keysize = alg->cra_ablkcipher.max_keysize; | ||
479 | rblkcipher.ivsize = alg->cra_ablkcipher.ivsize; | ||
480 | |||
481 | NLA_PUT(skb, CRYPTOCFGA_REPORT_BLKCIPHER, | ||
482 | sizeof(struct crypto_report_blkcipher), &rblkcipher); | ||
483 | |||
484 | return 0; | ||
485 | |||
486 | nla_put_failure: | ||
487 | return -EMSGSIZE; | ||
488 | } | ||
489 | #else | ||
490 | static int crypto_givcipher_report(struct sk_buff *skb, struct crypto_alg *alg) | ||
491 | { | ||
492 | return -ENOSYS; | ||
493 | } | ||
494 | #endif | ||
495 | |||
435 | static void crypto_givcipher_show(struct seq_file *m, struct crypto_alg *alg) | 496 | static void crypto_givcipher_show(struct seq_file *m, struct crypto_alg *alg) |
436 | __attribute__ ((unused)); | 497 | __attribute__ ((unused)); |
437 | static void crypto_givcipher_show(struct seq_file *m, struct crypto_alg *alg) | 498 | static void crypto_givcipher_show(struct seq_file *m, struct crypto_alg *alg) |
@@ -454,6 +515,7 @@ const struct crypto_type crypto_givcipher_type = { | |||
454 | #ifdef CONFIG_PROC_FS | 515 | #ifdef CONFIG_PROC_FS |
455 | .show = crypto_givcipher_show, | 516 | .show = crypto_givcipher_show, |
456 | #endif | 517 | #endif |
518 | .report = crypto_givcipher_report, | ||
457 | }; | 519 | }; |
458 | EXPORT_SYMBOL_GPL(crypto_givcipher_type); | 520 | EXPORT_SYMBOL_GPL(crypto_givcipher_type); |
459 | 521 | ||
diff --git a/crypto/aead.c b/crypto/aead.c index 6729e8ff68e..04add3dca6f 100644 --- a/crypto/aead.c +++ b/crypto/aead.c | |||
@@ -21,6 +21,8 @@ | |||
21 | #include <linux/sched.h> | 21 | #include <linux/sched.h> |
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
23 | #include <linux/seq_file.h> | 23 | #include <linux/seq_file.h> |
24 | #include <linux/cryptouser.h> | ||
25 | #include <net/netlink.h> | ||
24 | 26 | ||
25 | #include "internal.h" | 27 | #include "internal.h" |
26 | 28 | ||
@@ -109,6 +111,35 @@ static int crypto_init_aead_ops(struct crypto_tfm *tfm, u32 type, u32 mask) | |||
109 | return 0; | 111 | return 0; |
110 | } | 112 | } |
111 | 113 | ||
114 | #ifdef CONFIG_NET | ||
115 | static int crypto_aead_report(struct sk_buff *skb, struct crypto_alg *alg) | ||
116 | { | ||
117 | struct crypto_report_aead raead; | ||
118 | struct aead_alg *aead = &alg->cra_aead; | ||
119 | |||
120 | snprintf(raead.type, CRYPTO_MAX_ALG_NAME, "%s", "aead"); | ||
121 | snprintf(raead.geniv, CRYPTO_MAX_ALG_NAME, "%s", | ||
122 | aead->geniv ?: "<built-in>"); | ||
123 | |||
124 | raead.blocksize = alg->cra_blocksize; | ||
125 | raead.maxauthsize = aead->maxauthsize; | ||
126 | raead.ivsize = aead->ivsize; | ||
127 | |||
128 | NLA_PUT(skb, CRYPTOCFGA_REPORT_AEAD, | ||
129 | sizeof(struct crypto_report_aead), &raead); | ||
130 | |||
131 | return 0; | ||
132 | |||
133 | nla_put_failure: | ||
134 | return -EMSGSIZE; | ||
135 | } | ||
136 | #else | ||
137 | static int crypto_aead_report(struct sk_buff *skb, struct crypto_alg *alg) | ||
138 | { | ||
139 | return -ENOSYS; | ||
140 | } | ||
141 | #endif | ||
142 | |||
112 | static void crypto_aead_show(struct seq_file *m, struct crypto_alg *alg) | 143 | static void crypto_aead_show(struct seq_file *m, struct crypto_alg *alg) |
113 | __attribute__ ((unused)); | 144 | __attribute__ ((unused)); |
114 | static void crypto_aead_show(struct seq_file *m, struct crypto_alg *alg) | 145 | static void crypto_aead_show(struct seq_file *m, struct crypto_alg *alg) |
@@ -130,6 +161,7 @@ const struct crypto_type crypto_aead_type = { | |||
130 | #ifdef CONFIG_PROC_FS | 161 | #ifdef CONFIG_PROC_FS |
131 | .show = crypto_aead_show, | 162 | .show = crypto_aead_show, |
132 | #endif | 163 | #endif |
164 | .report = crypto_aead_report, | ||
133 | }; | 165 | }; |
134 | EXPORT_SYMBOL_GPL(crypto_aead_type); | 166 | EXPORT_SYMBOL_GPL(crypto_aead_type); |
135 | 167 | ||
@@ -165,6 +197,35 @@ static int crypto_init_nivaead_ops(struct crypto_tfm *tfm, u32 type, u32 mask) | |||
165 | return 0; | 197 | return 0; |
166 | } | 198 | } |
167 | 199 | ||
200 | #ifdef CONFIG_NET | ||
201 | static int crypto_nivaead_report(struct sk_buff *skb, struct crypto_alg *alg) | ||
202 | { | ||
203 | struct crypto_report_aead raead; | ||
204 | struct aead_alg *aead = &alg->cra_aead; | ||
205 | |||
206 | snprintf(raead.type, CRYPTO_MAX_ALG_NAME, "%s", "nivaead"); | ||
207 | snprintf(raead.geniv, CRYPTO_MAX_ALG_NAME, "%s", aead->geniv); | ||
208 | |||
209 | raead.blocksize = alg->cra_blocksize; | ||
210 | raead.maxauthsize = aead->maxauthsize; | ||
211 | raead.ivsize = aead->ivsize; | ||
212 | |||
213 | NLA_PUT(skb, CRYPTOCFGA_REPORT_AEAD, | ||
214 | sizeof(struct crypto_report_aead), &raead); | ||
215 | |||
216 | return 0; | ||
217 | |||
218 | nla_put_failure: | ||
219 | return -EMSGSIZE; | ||
220 | } | ||
221 | #else | ||
222 | static int crypto_nivaead_report(struct sk_buff *skb, struct crypto_alg *alg) | ||
223 | { | ||
224 | return -ENOSYS; | ||
225 | } | ||
226 | #endif | ||
227 | |||
228 | |||
168 | static void crypto_nivaead_show(struct seq_file *m, struct crypto_alg *alg) | 229 | static void crypto_nivaead_show(struct seq_file *m, struct crypto_alg *alg) |
169 | __attribute__ ((unused)); | 230 | __attribute__ ((unused)); |
170 | static void crypto_nivaead_show(struct seq_file *m, struct crypto_alg *alg) | 231 | static void crypto_nivaead_show(struct seq_file *m, struct crypto_alg *alg) |
@@ -186,6 +247,7 @@ const struct crypto_type crypto_nivaead_type = { | |||
186 | #ifdef CONFIG_PROC_FS | 247 | #ifdef CONFIG_PROC_FS |
187 | .show = crypto_nivaead_show, | 248 | .show = crypto_nivaead_show, |
188 | #endif | 249 | #endif |
250 | .report = crypto_nivaead_report, | ||
189 | }; | 251 | }; |
190 | EXPORT_SYMBOL_GPL(crypto_nivaead_type); | 252 | EXPORT_SYMBOL_GPL(crypto_nivaead_type); |
191 | 253 | ||
diff --git a/crypto/ahash.c b/crypto/ahash.c index f669822a7a4..ac93c99cfae 100644 --- a/crypto/ahash.c +++ b/crypto/ahash.c | |||
@@ -21,6 +21,8 @@ | |||
21 | #include <linux/sched.h> | 21 | #include <linux/sched.h> |
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
23 | #include <linux/seq_file.h> | 23 | #include <linux/seq_file.h> |
24 | #include <linux/cryptouser.h> | ||
25 | #include <net/netlink.h> | ||
24 | 26 | ||
25 | #include "internal.h" | 27 | #include "internal.h" |
26 | 28 | ||
@@ -397,6 +399,31 @@ static unsigned int crypto_ahash_extsize(struct crypto_alg *alg) | |||
397 | return sizeof(struct crypto_shash *); | 399 | return sizeof(struct crypto_shash *); |
398 | } | 400 | } |
399 | 401 | ||
402 | #ifdef CONFIG_NET | ||
403 | static int crypto_ahash_report(struct sk_buff *skb, struct crypto_alg *alg) | ||
404 | { | ||
405 | struct crypto_report_hash rhash; | ||
406 | |||
407 | snprintf(rhash.type, CRYPTO_MAX_ALG_NAME, "%s", "ahash"); | ||
408 | |||
409 | rhash.blocksize = alg->cra_blocksize; | ||
410 | rhash.digestsize = __crypto_hash_alg_common(alg)->digestsize; | ||
411 | |||
412 | NLA_PUT(skb, CRYPTOCFGA_REPORT_HASH, | ||
413 | sizeof(struct crypto_report_hash), &rhash); | ||
414 | |||
415 | return 0; | ||
416 | |||
417 | nla_put_failure: | ||
418 | return -EMSGSIZE; | ||
419 | } | ||
420 | #else | ||
421 | static int crypto_ahash_report(struct sk_buff *skb, struct crypto_alg *alg) | ||
422 | { | ||
423 | return -ENOSYS; | ||
424 | } | ||
425 | #endif | ||
426 | |||
400 | static void crypto_ahash_show(struct seq_file *m, struct crypto_alg *alg) | 427 | static void crypto_ahash_show(struct seq_file *m, struct crypto_alg *alg) |
401 | __attribute__ ((unused)); | 428 | __attribute__ ((unused)); |
402 | static void crypto_ahash_show(struct seq_file *m, struct crypto_alg *alg) | 429 | static void crypto_ahash_show(struct seq_file *m, struct crypto_alg *alg) |
@@ -415,6 +442,7 @@ const struct crypto_type crypto_ahash_type = { | |||
415 | #ifdef CONFIG_PROC_FS | 442 | #ifdef CONFIG_PROC_FS |
416 | .show = crypto_ahash_show, | 443 | .show = crypto_ahash_show, |
417 | #endif | 444 | #endif |
445 | .report = crypto_ahash_report, | ||
418 | .maskclear = ~CRYPTO_ALG_TYPE_MASK, | 446 | .maskclear = ~CRYPTO_ALG_TYPE_MASK, |
419 | .maskset = CRYPTO_ALG_TYPE_AHASH_MASK, | 447 | .maskset = CRYPTO_ALG_TYPE_AHASH_MASK, |
420 | .type = CRYPTO_ALG_TYPE_AHASH, | 448 | .type = CRYPTO_ALG_TYPE_AHASH, |
diff --git a/crypto/algapi.c b/crypto/algapi.c index c3cf1a69a47..54dd4e33b5d 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c | |||
@@ -22,8 +22,6 @@ | |||
22 | 22 | ||
23 | #include "internal.h" | 23 | #include "internal.h" |
24 | 24 | ||
25 | static void crypto_remove_final(struct list_head *list); | ||
26 | |||
27 | static LIST_HEAD(crypto_template_list); | 25 | static LIST_HEAD(crypto_template_list); |
28 | 26 | ||
29 | void crypto_larval_error(const char *name, u32 type, u32 mask) | 27 | void crypto_larval_error(const char *name, u32 type, u32 mask) |
@@ -129,9 +127,8 @@ static void crypto_remove_spawn(struct crypto_spawn *spawn, | |||
129 | BUG_ON(!list_empty(&inst->alg.cra_users)); | 127 | BUG_ON(!list_empty(&inst->alg.cra_users)); |
130 | } | 128 | } |
131 | 129 | ||
132 | static void crypto_remove_spawns(struct crypto_alg *alg, | 130 | void crypto_remove_spawns(struct crypto_alg *alg, struct list_head *list, |
133 | struct list_head *list, | 131 | struct crypto_alg *nalg) |
134 | struct crypto_alg *nalg) | ||
135 | { | 132 | { |
136 | u32 new_type = (nalg ?: alg)->cra_flags; | 133 | u32 new_type = (nalg ?: alg)->cra_flags; |
137 | struct crypto_spawn *spawn, *n; | 134 | struct crypto_spawn *spawn, *n; |
@@ -177,6 +174,7 @@ static void crypto_remove_spawns(struct crypto_alg *alg, | |||
177 | crypto_remove_spawn(spawn, list); | 174 | crypto_remove_spawn(spawn, list); |
178 | } | 175 | } |
179 | } | 176 | } |
177 | EXPORT_SYMBOL_GPL(crypto_remove_spawns); | ||
180 | 178 | ||
181 | static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg) | 179 | static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg) |
182 | { | 180 | { |
@@ -321,7 +319,7 @@ unlock: | |||
321 | } | 319 | } |
322 | EXPORT_SYMBOL_GPL(crypto_alg_tested); | 320 | EXPORT_SYMBOL_GPL(crypto_alg_tested); |
323 | 321 | ||
324 | static void crypto_remove_final(struct list_head *list) | 322 | void crypto_remove_final(struct list_head *list) |
325 | { | 323 | { |
326 | struct crypto_alg *alg; | 324 | struct crypto_alg *alg; |
327 | struct crypto_alg *n; | 325 | struct crypto_alg *n; |
@@ -331,6 +329,7 @@ static void crypto_remove_final(struct list_head *list) | |||
331 | crypto_alg_put(alg); | 329 | crypto_alg_put(alg); |
332 | } | 330 | } |
333 | } | 331 | } |
332 | EXPORT_SYMBOL_GPL(crypto_remove_final); | ||
334 | 333 | ||
335 | static void crypto_wait_for_test(struct crypto_larval *larval) | 334 | static void crypto_wait_for_test(struct crypto_larval *larval) |
336 | { | 335 | { |
@@ -493,6 +492,7 @@ int crypto_register_instance(struct crypto_template *tmpl, | |||
493 | goto err; | 492 | goto err; |
494 | 493 | ||
495 | inst->alg.cra_module = tmpl->module; | 494 | inst->alg.cra_module = tmpl->module; |
495 | inst->alg.cra_flags |= CRYPTO_ALG_INSTANCE; | ||
496 | 496 | ||
497 | down_write(&crypto_alg_sem); | 497 | down_write(&crypto_alg_sem); |
498 | 498 | ||
diff --git a/crypto/async_tx/async_memcpy.c b/crypto/async_tx/async_memcpy.c index 518c22bd956..0d5a90ca650 100644 --- a/crypto/async_tx/async_memcpy.c +++ b/crypto/async_tx/async_memcpy.c | |||
@@ -25,6 +25,7 @@ | |||
25 | */ | 25 | */ |
26 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
27 | #include <linux/highmem.h> | 27 | #include <linux/highmem.h> |
28 | #include <linux/module.h> | ||
28 | #include <linux/mm.h> | 29 | #include <linux/mm.h> |
29 | #include <linux/dma-mapping.h> | 30 | #include <linux/dma-mapping.h> |
30 | #include <linux/async_tx.h> | 31 | #include <linux/async_tx.h> |
diff --git a/crypto/async_tx/async_pq.c b/crypto/async_tx/async_pq.c index fdd8257d35d..91d5d385899 100644 --- a/crypto/async_tx/async_pq.c +++ b/crypto/async_tx/async_pq.c | |||
@@ -21,6 +21,7 @@ | |||
21 | */ | 21 | */ |
22 | #include <linux/kernel.h> | 22 | #include <linux/kernel.h> |
23 | #include <linux/interrupt.h> | 23 | #include <linux/interrupt.h> |
24 | #include <linux/module.h> | ||
24 | #include <linux/dma-mapping.h> | 25 | #include <linux/dma-mapping.h> |
25 | #include <linux/raid/pq.h> | 26 | #include <linux/raid/pq.h> |
26 | #include <linux/async_tx.h> | 27 | #include <linux/async_tx.h> |
diff --git a/crypto/async_tx/async_raid6_recov.c b/crypto/async_tx/async_raid6_recov.c index ce038d861eb..a9f08a6a582 100644 --- a/crypto/async_tx/async_raid6_recov.c +++ b/crypto/async_tx/async_raid6_recov.c | |||
@@ -22,6 +22,7 @@ | |||
22 | */ | 22 | */ |
23 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
24 | #include <linux/interrupt.h> | 24 | #include <linux/interrupt.h> |
25 | #include <linux/module.h> | ||
25 | #include <linux/dma-mapping.h> | 26 | #include <linux/dma-mapping.h> |
26 | #include <linux/raid/pq.h> | 27 | #include <linux/raid/pq.h> |
27 | #include <linux/async_tx.h> | 28 | #include <linux/async_tx.h> |
diff --git a/crypto/async_tx/async_tx.c b/crypto/async_tx/async_tx.c index 7f2c00a4520..84212097937 100644 --- a/crypto/async_tx/async_tx.c +++ b/crypto/async_tx/async_tx.c | |||
@@ -24,6 +24,7 @@ | |||
24 | * | 24 | * |
25 | */ | 25 | */ |
26 | #include <linux/rculist.h> | 26 | #include <linux/rculist.h> |
27 | #include <linux/module.h> | ||
27 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
28 | #include <linux/async_tx.h> | 29 | #include <linux/async_tx.h> |
29 | 30 | ||
diff --git a/crypto/async_tx/async_xor.c b/crypto/async_tx/async_xor.c index bc28337fded..154cc84381c 100644 --- a/crypto/async_tx/async_xor.c +++ b/crypto/async_tx/async_xor.c | |||
@@ -25,6 +25,7 @@ | |||
25 | */ | 25 | */ |
26 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
27 | #include <linux/interrupt.h> | 27 | #include <linux/interrupt.h> |
28 | #include <linux/module.h> | ||
28 | #include <linux/mm.h> | 29 | #include <linux/mm.h> |
29 | #include <linux/dma-mapping.h> | 30 | #include <linux/dma-mapping.h> |
30 | #include <linux/raid/xor.h> | 31 | #include <linux/raid/xor.h> |
diff --git a/crypto/async_tx/raid6test.c b/crypto/async_tx/raid6test.c index c88ff9e3fd3..aa2b0270ed1 100644 --- a/crypto/async_tx/raid6test.c +++ b/crypto/async_tx/raid6test.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/gfp.h> | 23 | #include <linux/gfp.h> |
24 | #include <linux/mm.h> | 24 | #include <linux/mm.h> |
25 | #include <linux/random.h> | 25 | #include <linux/random.h> |
26 | #include <linux/module.h> | ||
26 | 27 | ||
27 | #undef pr | 28 | #undef pr |
28 | #define pr(fmt, args...) pr_info("raid6test: " fmt, ##args) | 29 | #define pr(fmt, args...) pr_info("raid6test: " fmt, ##args) |
diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c index 7a7219266e3..1e61d1a888b 100644 --- a/crypto/blkcipher.c +++ b/crypto/blkcipher.c | |||
@@ -24,6 +24,8 @@ | |||
24 | #include <linux/seq_file.h> | 24 | #include <linux/seq_file.h> |
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/string.h> | 26 | #include <linux/string.h> |
27 | #include <linux/cryptouser.h> | ||
28 | #include <net/netlink.h> | ||
27 | 29 | ||
28 | #include "internal.h" | 30 | #include "internal.h" |
29 | 31 | ||
@@ -492,6 +494,35 @@ static int crypto_init_blkcipher_ops(struct crypto_tfm *tfm, u32 type, u32 mask) | |||
492 | return crypto_init_blkcipher_ops_async(tfm); | 494 | return crypto_init_blkcipher_ops_async(tfm); |
493 | } | 495 | } |
494 | 496 | ||
497 | #ifdef CONFIG_NET | ||
498 | static int crypto_blkcipher_report(struct sk_buff *skb, struct crypto_alg *alg) | ||
499 | { | ||
500 | struct crypto_report_blkcipher rblkcipher; | ||
501 | |||
502 | snprintf(rblkcipher.type, CRYPTO_MAX_ALG_NAME, "%s", "blkcipher"); | ||
503 | snprintf(rblkcipher.geniv, CRYPTO_MAX_ALG_NAME, "%s", | ||
504 | alg->cra_blkcipher.geniv ?: "<default>"); | ||
505 | |||
506 | rblkcipher.blocksize = alg->cra_blocksize; | ||
507 | rblkcipher.min_keysize = alg->cra_blkcipher.min_keysize; | ||
508 | rblkcipher.max_keysize = alg->cra_blkcipher.max_keysize; | ||
509 | rblkcipher.ivsize = alg->cra_blkcipher.ivsize; | ||
510 | |||
511 | NLA_PUT(skb, CRYPTOCFGA_REPORT_BLKCIPHER, | ||
512 | sizeof(struct crypto_report_blkcipher), &rblkcipher); | ||
513 | |||
514 | return 0; | ||
515 | |||
516 | nla_put_failure: | ||
517 | return -EMSGSIZE; | ||
518 | } | ||
519 | #else | ||
520 | static int crypto_blkcipher_report(struct sk_buff *skb, struct crypto_alg *alg) | ||
521 | { | ||
522 | return -ENOSYS; | ||
523 | } | ||
524 | #endif | ||
525 | |||
495 | static void crypto_blkcipher_show(struct seq_file *m, struct crypto_alg *alg) | 526 | static void crypto_blkcipher_show(struct seq_file *m, struct crypto_alg *alg) |
496 | __attribute__ ((unused)); | 527 | __attribute__ ((unused)); |
497 | static void crypto_blkcipher_show(struct seq_file *m, struct crypto_alg *alg) | 528 | static void crypto_blkcipher_show(struct seq_file *m, struct crypto_alg *alg) |
@@ -511,6 +542,7 @@ const struct crypto_type crypto_blkcipher_type = { | |||
511 | #ifdef CONFIG_PROC_FS | 542 | #ifdef CONFIG_PROC_FS |
512 | .show = crypto_blkcipher_show, | 543 | .show = crypto_blkcipher_show, |
513 | #endif | 544 | #endif |
545 | .report = crypto_blkcipher_report, | ||
514 | }; | 546 | }; |
515 | EXPORT_SYMBOL_GPL(crypto_blkcipher_type); | 547 | EXPORT_SYMBOL_GPL(crypto_blkcipher_type); |
516 | 548 | ||
diff --git a/crypto/blowfish.c b/crypto/blowfish_common.c index a67d52ee058..f636aab0209 100644 --- a/crypto/blowfish.c +++ b/crypto/blowfish_common.c | |||
@@ -1,6 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | * Cryptographic API. | 2 | * Cryptographic API. |
3 | * | 3 | * |
4 | * Common Blowfish algorithm parts shared between the c and assembler | ||
5 | * implementations. | ||
6 | * | ||
4 | * Blowfish Cipher Algorithm, by Bruce Schneier. | 7 | * Blowfish Cipher Algorithm, by Bruce Schneier. |
5 | * http://www.counterpane.com/blowfish.html | 8 | * http://www.counterpane.com/blowfish.html |
6 | * | 9 | * |
@@ -22,15 +25,7 @@ | |||
22 | #include <asm/byteorder.h> | 25 | #include <asm/byteorder.h> |
23 | #include <linux/crypto.h> | 26 | #include <linux/crypto.h> |
24 | #include <linux/types.h> | 27 | #include <linux/types.h> |
25 | 28 | #include <crypto/blowfish.h> | |
26 | #define BF_BLOCK_SIZE 8 | ||
27 | #define BF_MIN_KEY_SIZE 4 | ||
28 | #define BF_MAX_KEY_SIZE 56 | ||
29 | |||
30 | struct bf_ctx { | ||
31 | u32 p[18]; | ||
32 | u32 s[1024]; | ||
33 | }; | ||
34 | 29 | ||
35 | static const u32 bf_pbox[16 + 2] = { | 30 | static const u32 bf_pbox[16 + 2] = { |
36 | 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, | 31 | 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, |
@@ -309,9 +304,9 @@ static const u32 bf_sbox[256 * 4] = { | |||
309 | #define GET32_0(x) (((x) >> (24)) & (0xff)) | 304 | #define GET32_0(x) (((x) >> (24)) & (0xff)) |
310 | 305 | ||
311 | #define bf_F(x) (((S[GET32_0(x)] + S[256 + GET32_1(x)]) ^ \ | 306 | #define bf_F(x) (((S[GET32_0(x)] + S[256 + GET32_1(x)]) ^ \ |
312 | S[512 + GET32_2(x)]) + S[768 + GET32_3(x)]) | 307 | S[512 + GET32_2(x)]) + S[768 + GET32_3(x)]) |
313 | 308 | ||
314 | #define ROUND(a, b, n) b ^= P[n]; a ^= bf_F (b) | 309 | #define ROUND(a, b, n) ({ b ^= P[n]; a ^= bf_F(b); }) |
315 | 310 | ||
316 | /* | 311 | /* |
317 | * The blowfish encipher, processes 64-bit blocks. | 312 | * The blowfish encipher, processes 64-bit blocks. |
@@ -348,57 +343,10 @@ static void encrypt_block(struct bf_ctx *bctx, u32 *dst, u32 *src) | |||
348 | dst[1] = yl; | 343 | dst[1] = yl; |
349 | } | 344 | } |
350 | 345 | ||
351 | static void bf_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) | ||
352 | { | ||
353 | const __be32 *in_blk = (const __be32 *)src; | ||
354 | __be32 *const out_blk = (__be32 *)dst; | ||
355 | u32 in32[2], out32[2]; | ||
356 | |||
357 | in32[0] = be32_to_cpu(in_blk[0]); | ||
358 | in32[1] = be32_to_cpu(in_blk[1]); | ||
359 | encrypt_block(crypto_tfm_ctx(tfm), out32, in32); | ||
360 | out_blk[0] = cpu_to_be32(out32[0]); | ||
361 | out_blk[1] = cpu_to_be32(out32[1]); | ||
362 | } | ||
363 | |||
364 | static void bf_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) | ||
365 | { | ||
366 | struct bf_ctx *ctx = crypto_tfm_ctx(tfm); | ||
367 | const __be32 *in_blk = (const __be32 *)src; | ||
368 | __be32 *const out_blk = (__be32 *)dst; | ||
369 | const u32 *P = ctx->p; | ||
370 | const u32 *S = ctx->s; | ||
371 | u32 yl = be32_to_cpu(in_blk[0]); | ||
372 | u32 yr = be32_to_cpu(in_blk[1]); | ||
373 | |||
374 | ROUND(yr, yl, 17); | ||
375 | ROUND(yl, yr, 16); | ||
376 | ROUND(yr, yl, 15); | ||
377 | ROUND(yl, yr, 14); | ||
378 | ROUND(yr, yl, 13); | ||
379 | ROUND(yl, yr, 12); | ||
380 | ROUND(yr, yl, 11); | ||
381 | ROUND(yl, yr, 10); | ||
382 | ROUND(yr, yl, 9); | ||
383 | ROUND(yl, yr, 8); | ||
384 | ROUND(yr, yl, 7); | ||
385 | ROUND(yl, yr, 6); | ||
386 | ROUND(yr, yl, 5); | ||
387 | ROUND(yl, yr, 4); | ||
388 | ROUND(yr, yl, 3); | ||
389 | ROUND(yl, yr, 2); | ||
390 | |||
391 | yl ^= P[1]; | ||
392 | yr ^= P[0]; | ||
393 | |||
394 | out_blk[0] = cpu_to_be32(yr); | ||
395 | out_blk[1] = cpu_to_be32(yl); | ||
396 | } | ||
397 | |||
398 | /* | 346 | /* |
399 | * Calculates the blowfish S and P boxes for encryption and decryption. | 347 | * Calculates the blowfish S and P boxes for encryption and decryption. |
400 | */ | 348 | */ |
401 | static int bf_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) | 349 | int blowfish_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) |
402 | { | 350 | { |
403 | struct bf_ctx *ctx = crypto_tfm_ctx(tfm); | 351 | struct bf_ctx *ctx = crypto_tfm_ctx(tfm); |
404 | u32 *P = ctx->p; | 352 | u32 *P = ctx->p; |
@@ -448,35 +396,7 @@ static int bf_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) | |||
448 | /* Bruce says not to bother with the weak key check. */ | 396 | /* Bruce says not to bother with the weak key check. */ |
449 | return 0; | 397 | return 0; |
450 | } | 398 | } |
451 | 399 | EXPORT_SYMBOL_GPL(blowfish_setkey); | |
452 | static struct crypto_alg alg = { | ||
453 | .cra_name = "blowfish", | ||
454 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, | ||
455 | .cra_blocksize = BF_BLOCK_SIZE, | ||
456 | .cra_ctxsize = sizeof(struct bf_ctx), | ||
457 | .cra_alignmask = 3, | ||
458 | .cra_module = THIS_MODULE, | ||
459 | .cra_list = LIST_HEAD_INIT(alg.cra_list), | ||
460 | .cra_u = { .cipher = { | ||
461 | .cia_min_keysize = BF_MIN_KEY_SIZE, | ||
462 | .cia_max_keysize = BF_MAX_KEY_SIZE, | ||
463 | .cia_setkey = bf_setkey, | ||
464 | .cia_encrypt = bf_encrypt, | ||
465 | .cia_decrypt = bf_decrypt } } | ||
466 | }; | ||
467 | |||
468 | static int __init blowfish_mod_init(void) | ||
469 | { | ||
470 | return crypto_register_alg(&alg); | ||
471 | } | ||
472 | |||
473 | static void __exit blowfish_mod_fini(void) | ||
474 | { | ||
475 | crypto_unregister_alg(&alg); | ||
476 | } | ||
477 | |||
478 | module_init(blowfish_mod_init); | ||
479 | module_exit(blowfish_mod_fini); | ||
480 | 400 | ||
481 | MODULE_LICENSE("GPL"); | 401 | MODULE_LICENSE("GPL"); |
482 | MODULE_DESCRIPTION("Blowfish Cipher Algorithm"); | 402 | MODULE_DESCRIPTION("Blowfish Cipher common functions"); |
diff --git a/crypto/blowfish_generic.c b/crypto/blowfish_generic.c new file mode 100644 index 00000000000..6f269b5cfa3 --- /dev/null +++ b/crypto/blowfish_generic.c | |||
@@ -0,0 +1,142 @@ | |||
1 | /* | ||
2 | * Cryptographic API. | ||
3 | * | ||
4 | * Blowfish Cipher Algorithm, by Bruce Schneier. | ||
5 | * http://www.counterpane.com/blowfish.html | ||
6 | * | ||
7 | * Adapted from Kerneli implementation. | ||
8 | * | ||
9 | * Copyright (c) Herbert Valerio Riedel <hvr@hvrlab.org> | ||
10 | * Copyright (c) Kyle McMartin <kyle@debian.org> | ||
11 | * Copyright (c) 2002 James Morris <jmorris@intercode.com.au> | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or modify | ||
14 | * it under the terms of the GNU General Public License as published by | ||
15 | * the Free Software Foundation; either version 2 of the License, or | ||
16 | * (at your option) any later version. | ||
17 | * | ||
18 | */ | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/module.h> | ||
21 | #include <linux/mm.h> | ||
22 | #include <asm/byteorder.h> | ||
23 | #include <linux/crypto.h> | ||
24 | #include <linux/types.h> | ||
25 | #include <crypto/blowfish.h> | ||
26 | |||
27 | /* | ||
28 | * Round loop unrolling macros, S is a pointer to a S-Box array | ||
29 | * organized in 4 unsigned longs at a row. | ||
30 | */ | ||
31 | #define GET32_3(x) (((x) & 0xff)) | ||
32 | #define GET32_2(x) (((x) >> (8)) & (0xff)) | ||
33 | #define GET32_1(x) (((x) >> (16)) & (0xff)) | ||
34 | #define GET32_0(x) (((x) >> (24)) & (0xff)) | ||
35 | |||
36 | #define bf_F(x) (((S[GET32_0(x)] + S[256 + GET32_1(x)]) ^ \ | ||
37 | S[512 + GET32_2(x)]) + S[768 + GET32_3(x)]) | ||
38 | |||
39 | #define ROUND(a, b, n) ({ b ^= P[n]; a ^= bf_F(b); }) | ||
40 | |||
41 | static void bf_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) | ||
42 | { | ||
43 | struct bf_ctx *ctx = crypto_tfm_ctx(tfm); | ||
44 | const __be32 *in_blk = (const __be32 *)src; | ||
45 | __be32 *const out_blk = (__be32 *)dst; | ||
46 | const u32 *P = ctx->p; | ||
47 | const u32 *S = ctx->s; | ||
48 | u32 yl = be32_to_cpu(in_blk[0]); | ||
49 | u32 yr = be32_to_cpu(in_blk[1]); | ||
50 | |||
51 | ROUND(yr, yl, 0); | ||
52 | ROUND(yl, yr, 1); | ||
53 | ROUND(yr, yl, 2); | ||
54 | ROUND(yl, yr, 3); | ||
55 | ROUND(yr, yl, 4); | ||
56 | ROUND(yl, yr, 5); | ||
57 | ROUND(yr, yl, 6); | ||
58 | ROUND(yl, yr, 7); | ||
59 | ROUND(yr, yl, 8); | ||
60 | ROUND(yl, yr, 9); | ||
61 | ROUND(yr, yl, 10); | ||
62 | ROUND(yl, yr, 11); | ||
63 | ROUND(yr, yl, 12); | ||
64 | ROUND(yl, yr, 13); | ||
65 | ROUND(yr, yl, 14); | ||
66 | ROUND(yl, yr, 15); | ||
67 | |||
68 | yl ^= P[16]; | ||
69 | yr ^= P[17]; | ||
70 | |||
71 | out_blk[0] = cpu_to_be32(yr); | ||
72 | out_blk[1] = cpu_to_be32(yl); | ||
73 | } | ||
74 | |||
75 | static void bf_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) | ||
76 | { | ||
77 | struct bf_ctx *ctx = crypto_tfm_ctx(tfm); | ||
78 | const __be32 *in_blk = (const __be32 *)src; | ||
79 | __be32 *const out_blk = (__be32 *)dst; | ||
80 | const u32 *P = ctx->p; | ||
81 | const u32 *S = ctx->s; | ||
82 | u32 yl = be32_to_cpu(in_blk[0]); | ||
83 | u32 yr = be32_to_cpu(in_blk[1]); | ||
84 | |||
85 | ROUND(yr, yl, 17); | ||
86 | ROUND(yl, yr, 16); | ||
87 | ROUND(yr, yl, 15); | ||
88 | ROUND(yl, yr, 14); | ||
89 | ROUND(yr, yl, 13); | ||
90 | ROUND(yl, yr, 12); | ||
91 | ROUND(yr, yl, 11); | ||
92 | ROUND(yl, yr, 10); | ||
93 | ROUND(yr, yl, 9); | ||
94 | ROUND(yl, yr, 8); | ||
95 | ROUND(yr, yl, 7); | ||
96 | ROUND(yl, yr, 6); | ||
97 | ROUND(yr, yl, 5); | ||
98 | ROUND(yl, yr, 4); | ||
99 | ROUND(yr, yl, 3); | ||
100 | ROUND(yl, yr, 2); | ||
101 | |||
102 | yl ^= P[1]; | ||
103 | yr ^= P[0]; | ||
104 | |||
105 | out_blk[0] = cpu_to_be32(yr); | ||
106 | out_blk[1] = cpu_to_be32(yl); | ||
107 | } | ||
108 | |||
109 | static struct crypto_alg alg = { | ||
110 | .cra_name = "blowfish", | ||
111 | .cra_driver_name = "blowfish-generic", | ||
112 | .cra_priority = 100, | ||
113 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, | ||
114 | .cra_blocksize = BF_BLOCK_SIZE, | ||
115 | .cra_ctxsize = sizeof(struct bf_ctx), | ||
116 | .cra_alignmask = 3, | ||
117 | .cra_module = THIS_MODULE, | ||
118 | .cra_list = LIST_HEAD_INIT(alg.cra_list), | ||
119 | .cra_u = { .cipher = { | ||
120 | .cia_min_keysize = BF_MIN_KEY_SIZE, | ||
121 | .cia_max_keysize = BF_MAX_KEY_SIZE, | ||
122 | .cia_setkey = blowfish_setkey, | ||
123 | .cia_encrypt = bf_encrypt, | ||
124 | .cia_decrypt = bf_decrypt } } | ||
125 | }; | ||
126 | |||
127 | static int __init blowfish_mod_init(void) | ||
128 | { | ||
129 | return crypto_register_alg(&alg); | ||
130 | } | ||
131 | |||
132 | static void __exit blowfish_mod_fini(void) | ||
133 | { | ||
134 | crypto_unregister_alg(&alg); | ||
135 | } | ||
136 | |||
137 | module_init(blowfish_mod_init); | ||
138 | module_exit(blowfish_mod_fini); | ||
139 | |||
140 | MODULE_LICENSE("GPL"); | ||
141 | MODULE_DESCRIPTION("Blowfish Cipher Algorithm"); | ||
142 | MODULE_ALIAS("blowfish"); | ||
diff --git a/crypto/cryptd.c b/crypto/cryptd.c index e46d21ae26b..671d4d6d14d 100644 --- a/crypto/cryptd.c +++ b/crypto/cryptd.c | |||
@@ -945,7 +945,7 @@ static void __exit cryptd_exit(void) | |||
945 | crypto_unregister_template(&cryptd_tmpl); | 945 | crypto_unregister_template(&cryptd_tmpl); |
946 | } | 946 | } |
947 | 947 | ||
948 | module_init(cryptd_init); | 948 | subsys_initcall(cryptd_init); |
949 | module_exit(cryptd_exit); | 949 | module_exit(cryptd_exit); |
950 | 950 | ||
951 | MODULE_LICENSE("GPL"); | 951 | MODULE_LICENSE("GPL"); |
diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c new file mode 100644 index 00000000000..0605a2bbba7 --- /dev/null +++ b/crypto/crypto_user.c | |||
@@ -0,0 +1,435 @@ | |||
1 | /* | ||
2 | * Crypto user configuration API. | ||
3 | * | ||
4 | * Copyright (C) 2011 secunet Security Networks AG | ||
5 | * Copyright (C) 2011 Steffen Klassert <steffen.klassert@secunet.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms and conditions of the GNU General Public License, | ||
9 | * version 2, as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
14 | * more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along with | ||
17 | * this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | */ | ||
20 | |||
21 | #include <linux/module.h> | ||
22 | #include <linux/crypto.h> | ||
23 | #include <linux/cryptouser.h> | ||
24 | #include <net/netlink.h> | ||
25 | #include <linux/security.h> | ||
26 | #include <net/net_namespace.h> | ||
27 | #include "internal.h" | ||
28 | |||
29 | DEFINE_MUTEX(crypto_cfg_mutex); | ||
30 | |||
31 | /* The crypto netlink socket */ | ||
32 | static struct sock *crypto_nlsk; | ||
33 | |||
34 | struct crypto_dump_info { | ||
35 | struct sk_buff *in_skb; | ||
36 | struct sk_buff *out_skb; | ||
37 | u32 nlmsg_seq; | ||
38 | u16 nlmsg_flags; | ||
39 | }; | ||
40 | |||
41 | static struct crypto_alg *crypto_alg_match(struct crypto_user_alg *p, int exact) | ||
42 | { | ||
43 | struct crypto_alg *q, *alg = NULL; | ||
44 | |||
45 | down_read(&crypto_alg_sem); | ||
46 | |||
47 | list_for_each_entry(q, &crypto_alg_list, cra_list) { | ||
48 | int match = 0; | ||
49 | |||
50 | if ((q->cra_flags ^ p->cru_type) & p->cru_mask) | ||
51 | continue; | ||
52 | |||
53 | if (strlen(p->cru_driver_name)) | ||
54 | match = !strcmp(q->cra_driver_name, | ||
55 | p->cru_driver_name); | ||
56 | else if (!exact) | ||
57 | match = !strcmp(q->cra_name, p->cru_name); | ||
58 | |||
59 | if (match) { | ||
60 | alg = q; | ||
61 | break; | ||
62 | } | ||
63 | } | ||
64 | |||
65 | up_read(&crypto_alg_sem); | ||
66 | |||
67 | return alg; | ||
68 | } | ||
69 | |||
70 | static int crypto_report_cipher(struct sk_buff *skb, struct crypto_alg *alg) | ||
71 | { | ||
72 | struct crypto_report_cipher rcipher; | ||
73 | |||
74 | snprintf(rcipher.type, CRYPTO_MAX_ALG_NAME, "%s", "cipher"); | ||
75 | |||
76 | rcipher.blocksize = alg->cra_blocksize; | ||
77 | rcipher.min_keysize = alg->cra_cipher.cia_min_keysize; | ||
78 | rcipher.max_keysize = alg->cra_cipher.cia_max_keysize; | ||
79 | |||
80 | NLA_PUT(skb, CRYPTOCFGA_REPORT_CIPHER, | ||
81 | sizeof(struct crypto_report_cipher), &rcipher); | ||
82 | |||
83 | return 0; | ||
84 | |||
85 | nla_put_failure: | ||
86 | return -EMSGSIZE; | ||
87 | } | ||
88 | |||
89 | static int crypto_report_comp(struct sk_buff *skb, struct crypto_alg *alg) | ||
90 | { | ||
91 | struct crypto_report_comp rcomp; | ||
92 | |||
93 | snprintf(rcomp.type, CRYPTO_MAX_ALG_NAME, "%s", "compression"); | ||
94 | |||
95 | NLA_PUT(skb, CRYPTOCFGA_REPORT_COMPRESS, | ||
96 | sizeof(struct crypto_report_comp), &rcomp); | ||
97 | |||
98 | return 0; | ||
99 | |||
100 | nla_put_failure: | ||
101 | return -EMSGSIZE; | ||
102 | } | ||
103 | |||
104 | static int crypto_report_one(struct crypto_alg *alg, | ||
105 | struct crypto_user_alg *ualg, struct sk_buff *skb) | ||
106 | { | ||
107 | memcpy(&ualg->cru_name, &alg->cra_name, sizeof(ualg->cru_name)); | ||
108 | memcpy(&ualg->cru_driver_name, &alg->cra_driver_name, | ||
109 | sizeof(ualg->cru_driver_name)); | ||
110 | memcpy(&ualg->cru_module_name, module_name(alg->cra_module), | ||
111 | CRYPTO_MAX_ALG_NAME); | ||
112 | |||
113 | ualg->cru_flags = alg->cra_flags; | ||
114 | ualg->cru_refcnt = atomic_read(&alg->cra_refcnt); | ||
115 | |||
116 | NLA_PUT_U32(skb, CRYPTOCFGA_PRIORITY_VAL, alg->cra_priority); | ||
117 | |||
118 | if (alg->cra_flags & CRYPTO_ALG_LARVAL) { | ||
119 | struct crypto_report_larval rl; | ||
120 | |||
121 | snprintf(rl.type, CRYPTO_MAX_ALG_NAME, "%s", "larval"); | ||
122 | |||
123 | NLA_PUT(skb, CRYPTOCFGA_REPORT_LARVAL, | ||
124 | sizeof(struct crypto_report_larval), &rl); | ||
125 | |||
126 | goto out; | ||
127 | } | ||
128 | |||
129 | if (alg->cra_type && alg->cra_type->report) { | ||
130 | if (alg->cra_type->report(skb, alg)) | ||
131 | goto nla_put_failure; | ||
132 | |||
133 | goto out; | ||
134 | } | ||
135 | |||
136 | switch (alg->cra_flags & (CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_LARVAL)) { | ||
137 | case CRYPTO_ALG_TYPE_CIPHER: | ||
138 | if (crypto_report_cipher(skb, alg)) | ||
139 | goto nla_put_failure; | ||
140 | |||
141 | break; | ||
142 | case CRYPTO_ALG_TYPE_COMPRESS: | ||
143 | if (crypto_report_comp(skb, alg)) | ||
144 | goto nla_put_failure; | ||
145 | |||
146 | break; | ||
147 | } | ||
148 | |||
149 | out: | ||
150 | return 0; | ||
151 | |||
152 | nla_put_failure: | ||
153 | return -EMSGSIZE; | ||
154 | } | ||
155 | |||
156 | static int crypto_report_alg(struct crypto_alg *alg, | ||
157 | struct crypto_dump_info *info) | ||
158 | { | ||
159 | struct sk_buff *in_skb = info->in_skb; | ||
160 | struct sk_buff *skb = info->out_skb; | ||
161 | struct nlmsghdr *nlh; | ||
162 | struct crypto_user_alg *ualg; | ||
163 | int err = 0; | ||
164 | |||
165 | nlh = nlmsg_put(skb, NETLINK_CB(in_skb).pid, info->nlmsg_seq, | ||
166 | CRYPTO_MSG_GETALG, sizeof(*ualg), info->nlmsg_flags); | ||
167 | if (!nlh) { | ||
168 | err = -EMSGSIZE; | ||
169 | goto out; | ||
170 | } | ||
171 | |||
172 | ualg = nlmsg_data(nlh); | ||
173 | |||
174 | err = crypto_report_one(alg, ualg, skb); | ||
175 | if (err) { | ||
176 | nlmsg_cancel(skb, nlh); | ||
177 | goto out; | ||
178 | } | ||
179 | |||
180 | nlmsg_end(skb, nlh); | ||
181 | |||
182 | out: | ||
183 | return err; | ||
184 | } | ||
185 | |||
186 | static int crypto_report(struct sk_buff *in_skb, struct nlmsghdr *in_nlh, | ||
187 | struct nlattr **attrs) | ||
188 | { | ||
189 | struct crypto_user_alg *p = nlmsg_data(in_nlh); | ||
190 | struct crypto_alg *alg; | ||
191 | struct sk_buff *skb; | ||
192 | struct crypto_dump_info info; | ||
193 | int err; | ||
194 | |||
195 | if (!p->cru_driver_name) | ||
196 | return -EINVAL; | ||
197 | |||
198 | alg = crypto_alg_match(p, 1); | ||
199 | if (!alg) | ||
200 | return -ENOENT; | ||
201 | |||
202 | skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC); | ||
203 | if (!skb) | ||
204 | return -ENOMEM; | ||
205 | |||
206 | info.in_skb = in_skb; | ||
207 | info.out_skb = skb; | ||
208 | info.nlmsg_seq = in_nlh->nlmsg_seq; | ||
209 | info.nlmsg_flags = 0; | ||
210 | |||
211 | err = crypto_report_alg(alg, &info); | ||
212 | if (err) | ||
213 | return err; | ||
214 | |||
215 | return nlmsg_unicast(crypto_nlsk, skb, NETLINK_CB(in_skb).pid); | ||
216 | } | ||
217 | |||
218 | static int crypto_dump_report(struct sk_buff *skb, struct netlink_callback *cb) | ||
219 | { | ||
220 | struct crypto_alg *alg; | ||
221 | struct crypto_dump_info info; | ||
222 | int err; | ||
223 | |||
224 | if (cb->args[0]) | ||
225 | goto out; | ||
226 | |||
227 | cb->args[0] = 1; | ||
228 | |||
229 | info.in_skb = cb->skb; | ||
230 | info.out_skb = skb; | ||
231 | info.nlmsg_seq = cb->nlh->nlmsg_seq; | ||
232 | info.nlmsg_flags = NLM_F_MULTI; | ||
233 | |||
234 | list_for_each_entry(alg, &crypto_alg_list, cra_list) { | ||
235 | err = crypto_report_alg(alg, &info); | ||
236 | if (err) | ||
237 | goto out_err; | ||
238 | } | ||
239 | |||
240 | out: | ||
241 | return skb->len; | ||
242 | out_err: | ||
243 | return err; | ||
244 | } | ||
245 | |||
246 | static int crypto_dump_report_done(struct netlink_callback *cb) | ||
247 | { | ||
248 | return 0; | ||
249 | } | ||
250 | |||
251 | static int crypto_update_alg(struct sk_buff *skb, struct nlmsghdr *nlh, | ||
252 | struct nlattr **attrs) | ||
253 | { | ||
254 | struct crypto_alg *alg; | ||
255 | struct crypto_user_alg *p = nlmsg_data(nlh); | ||
256 | struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL]; | ||
257 | LIST_HEAD(list); | ||
258 | |||
259 | if (priority && !strlen(p->cru_driver_name)) | ||
260 | return -EINVAL; | ||
261 | |||
262 | alg = crypto_alg_match(p, 1); | ||
263 | if (!alg) | ||
264 | return -ENOENT; | ||
265 | |||
266 | down_write(&crypto_alg_sem); | ||
267 | |||
268 | crypto_remove_spawns(alg, &list, NULL); | ||
269 | |||
270 | if (priority) | ||
271 | alg->cra_priority = nla_get_u32(priority); | ||
272 | |||
273 | up_write(&crypto_alg_sem); | ||
274 | |||
275 | crypto_remove_final(&list); | ||
276 | |||
277 | return 0; | ||
278 | } | ||
279 | |||
280 | static int crypto_del_alg(struct sk_buff *skb, struct nlmsghdr *nlh, | ||
281 | struct nlattr **attrs) | ||
282 | { | ||
283 | struct crypto_alg *alg; | ||
284 | struct crypto_user_alg *p = nlmsg_data(nlh); | ||
285 | |||
286 | alg = crypto_alg_match(p, 1); | ||
287 | if (!alg) | ||
288 | return -ENOENT; | ||
289 | |||
290 | /* We can not unregister core algorithms such as aes-generic. | ||
291 | * We would loose the reference in the crypto_alg_list to this algorithm | ||
292 | * if we try to unregister. Unregistering such an algorithm without | ||
293 | * removing the module is not possible, so we restrict to crypto | ||
294 | * instances that are build from templates. */ | ||
295 | if (!(alg->cra_flags & CRYPTO_ALG_INSTANCE)) | ||
296 | return -EINVAL; | ||
297 | |||
298 | if (atomic_read(&alg->cra_refcnt) != 1) | ||
299 | return -EBUSY; | ||
300 | |||
301 | return crypto_unregister_alg(alg); | ||
302 | } | ||
303 | |||
304 | static int crypto_add_alg(struct sk_buff *skb, struct nlmsghdr *nlh, | ||
305 | struct nlattr **attrs) | ||
306 | { | ||
307 | int exact; | ||
308 | const char *name; | ||
309 | struct crypto_alg *alg; | ||
310 | struct crypto_user_alg *p = nlmsg_data(nlh); | ||
311 | struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL]; | ||
312 | |||
313 | if (strlen(p->cru_driver_name)) | ||
314 | exact = 1; | ||
315 | |||
316 | if (priority && !exact) | ||
317 | return -EINVAL; | ||
318 | |||
319 | alg = crypto_alg_match(p, exact); | ||
320 | if (alg) | ||
321 | return -EEXIST; | ||
322 | |||
323 | if (strlen(p->cru_driver_name)) | ||
324 | name = p->cru_driver_name; | ||
325 | else | ||
326 | name = p->cru_name; | ||
327 | |||
328 | alg = crypto_alg_mod_lookup(name, p->cru_type, p->cru_mask); | ||
329 | if (IS_ERR(alg)) | ||
330 | return PTR_ERR(alg); | ||
331 | |||
332 | down_write(&crypto_alg_sem); | ||
333 | |||
334 | if (priority) | ||
335 | alg->cra_priority = nla_get_u32(priority); | ||
336 | |||
337 | up_write(&crypto_alg_sem); | ||
338 | |||
339 | crypto_mod_put(alg); | ||
340 | |||
341 | return 0; | ||
342 | } | ||
343 | |||
344 | #define MSGSIZE(type) sizeof(struct type) | ||
345 | |||
346 | static const int crypto_msg_min[CRYPTO_NR_MSGTYPES] = { | ||
347 | [CRYPTO_MSG_NEWALG - CRYPTO_MSG_BASE] = MSGSIZE(crypto_user_alg), | ||
348 | [CRYPTO_MSG_DELALG - CRYPTO_MSG_BASE] = MSGSIZE(crypto_user_alg), | ||
349 | [CRYPTO_MSG_UPDATEALG - CRYPTO_MSG_BASE] = MSGSIZE(crypto_user_alg), | ||
350 | [CRYPTO_MSG_GETALG - CRYPTO_MSG_BASE] = MSGSIZE(crypto_user_alg), | ||
351 | }; | ||
352 | |||
353 | static const struct nla_policy crypto_policy[CRYPTOCFGA_MAX+1] = { | ||
354 | [CRYPTOCFGA_PRIORITY_VAL] = { .type = NLA_U32}, | ||
355 | }; | ||
356 | |||
357 | #undef MSGSIZE | ||
358 | |||
359 | static struct crypto_link { | ||
360 | int (*doit)(struct sk_buff *, struct nlmsghdr *, struct nlattr **); | ||
361 | int (*dump)(struct sk_buff *, struct netlink_callback *); | ||
362 | int (*done)(struct netlink_callback *); | ||
363 | } crypto_dispatch[CRYPTO_NR_MSGTYPES] = { | ||
364 | [CRYPTO_MSG_NEWALG - CRYPTO_MSG_BASE] = { .doit = crypto_add_alg}, | ||
365 | [CRYPTO_MSG_DELALG - CRYPTO_MSG_BASE] = { .doit = crypto_del_alg}, | ||
366 | [CRYPTO_MSG_UPDATEALG - CRYPTO_MSG_BASE] = { .doit = crypto_update_alg}, | ||
367 | [CRYPTO_MSG_GETALG - CRYPTO_MSG_BASE] = { .doit = crypto_report, | ||
368 | .dump = crypto_dump_report, | ||
369 | .done = crypto_dump_report_done}, | ||
370 | }; | ||
371 | |||
372 | static int crypto_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | ||
373 | { | ||
374 | struct nlattr *attrs[CRYPTOCFGA_MAX+1]; | ||
375 | struct crypto_link *link; | ||
376 | int type, err; | ||
377 | |||
378 | type = nlh->nlmsg_type; | ||
379 | if (type > CRYPTO_MSG_MAX) | ||
380 | return -EINVAL; | ||
381 | |||
382 | type -= CRYPTO_MSG_BASE; | ||
383 | link = &crypto_dispatch[type]; | ||
384 | |||
385 | if (security_netlink_recv(skb, CAP_NET_ADMIN)) | ||
386 | return -EPERM; | ||
387 | |||
388 | if ((type == (CRYPTO_MSG_GETALG - CRYPTO_MSG_BASE) && | ||
389 | (nlh->nlmsg_flags & NLM_F_DUMP))) { | ||
390 | if (link->dump == NULL) | ||
391 | return -EINVAL; | ||
392 | |||
393 | return netlink_dump_start(crypto_nlsk, skb, nlh, | ||
394 | link->dump, link->done, 0); | ||
395 | } | ||
396 | |||
397 | err = nlmsg_parse(nlh, crypto_msg_min[type], attrs, CRYPTOCFGA_MAX, | ||
398 | crypto_policy); | ||
399 | if (err < 0) | ||
400 | return err; | ||
401 | |||
402 | if (link->doit == NULL) | ||
403 | return -EINVAL; | ||
404 | |||
405 | return link->doit(skb, nlh, attrs); | ||
406 | } | ||
407 | |||
408 | static void crypto_netlink_rcv(struct sk_buff *skb) | ||
409 | { | ||
410 | mutex_lock(&crypto_cfg_mutex); | ||
411 | netlink_rcv_skb(skb, &crypto_user_rcv_msg); | ||
412 | mutex_unlock(&crypto_cfg_mutex); | ||
413 | } | ||
414 | |||
415 | static int __init crypto_user_init(void) | ||
416 | { | ||
417 | crypto_nlsk = netlink_kernel_create(&init_net, NETLINK_CRYPTO, | ||
418 | 0, crypto_netlink_rcv, | ||
419 | NULL, THIS_MODULE); | ||
420 | if (!crypto_nlsk) | ||
421 | return -ENOMEM; | ||
422 | |||
423 | return 0; | ||
424 | } | ||
425 | |||
426 | static void __exit crypto_user_exit(void) | ||
427 | { | ||
428 | netlink_kernel_release(crypto_nlsk); | ||
429 | } | ||
430 | |||
431 | module_init(crypto_user_init); | ||
432 | module_exit(crypto_user_exit); | ||
433 | MODULE_LICENSE("GPL"); | ||
434 | MODULE_AUTHOR("Steffen Klassert <steffen.klassert@secunet.com>"); | ||
435 | MODULE_DESCRIPTION("Crypto userspace configuration API"); | ||
diff --git a/crypto/crypto_wq.c b/crypto/crypto_wq.c index b980ee1af45..adad92a44ba 100644 --- a/crypto/crypto_wq.c +++ b/crypto/crypto_wq.c | |||
@@ -12,6 +12,7 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/workqueue.h> | 14 | #include <linux/workqueue.h> |
15 | #include <linux/module.h> | ||
15 | #include <crypto/algapi.h> | 16 | #include <crypto/algapi.h> |
16 | #include <crypto/crypto_wq.h> | 17 | #include <crypto/crypto_wq.h> |
17 | 18 | ||
diff --git a/crypto/internal.h b/crypto/internal.h index d4384b08ab2..b865ca1a861 100644 --- a/crypto/internal.h +++ b/crypto/internal.h | |||
@@ -86,6 +86,9 @@ struct crypto_alg *crypto_larval_lookup(const char *name, u32 type, u32 mask); | |||
86 | void crypto_larval_error(const char *name, u32 type, u32 mask); | 86 | void crypto_larval_error(const char *name, u32 type, u32 mask); |
87 | void crypto_alg_tested(const char *name, int err); | 87 | void crypto_alg_tested(const char *name, int err); |
88 | 88 | ||
89 | void crypto_remove_spawns(struct crypto_alg *alg, struct list_head *list, | ||
90 | struct crypto_alg *nalg); | ||
91 | void crypto_remove_final(struct list_head *list); | ||
89 | void crypto_shoot_alg(struct crypto_alg *alg); | 92 | void crypto_shoot_alg(struct crypto_alg *alg); |
90 | struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type, | 93 | struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type, |
91 | u32 mask); | 94 | u32 mask); |
diff --git a/crypto/md4.c b/crypto/md4.c index 7fca1f59a4f..0477a6a01d5 100644 --- a/crypto/md4.c +++ b/crypto/md4.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <crypto/internal/hash.h> | 23 | #include <crypto/internal/hash.h> |
24 | #include <linux/init.h> | 24 | #include <linux/init.h> |
25 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
26 | #include <linux/module.h> | ||
26 | #include <linux/string.h> | 27 | #include <linux/string.h> |
27 | #include <linux/types.h> | 28 | #include <linux/types.h> |
28 | #include <asm/byteorder.h> | 29 | #include <asm/byteorder.h> |
diff --git a/crypto/pcompress.c b/crypto/pcompress.c index f7c4a7d7412..2e458e5482d 100644 --- a/crypto/pcompress.c +++ b/crypto/pcompress.c | |||
@@ -24,6 +24,8 @@ | |||
24 | #include <linux/module.h> | 24 | #include <linux/module.h> |
25 | #include <linux/seq_file.h> | 25 | #include <linux/seq_file.h> |
26 | #include <linux/string.h> | 26 | #include <linux/string.h> |
27 | #include <linux/cryptouser.h> | ||
28 | #include <net/netlink.h> | ||
27 | 29 | ||
28 | #include <crypto/compress.h> | 30 | #include <crypto/compress.h> |
29 | #include <crypto/internal/compress.h> | 31 | #include <crypto/internal/compress.h> |
@@ -46,6 +48,28 @@ static int crypto_pcomp_init_tfm(struct crypto_tfm *tfm) | |||
46 | return 0; | 48 | return 0; |
47 | } | 49 | } |
48 | 50 | ||
51 | #ifdef CONFIG_NET | ||
52 | static int crypto_pcomp_report(struct sk_buff *skb, struct crypto_alg *alg) | ||
53 | { | ||
54 | struct crypto_report_comp rpcomp; | ||
55 | |||
56 | snprintf(rpcomp.type, CRYPTO_MAX_ALG_NAME, "%s", "pcomp"); | ||
57 | |||
58 | NLA_PUT(skb, CRYPTOCFGA_REPORT_COMPRESS, | ||
59 | sizeof(struct crypto_report_comp), &rpcomp); | ||
60 | |||
61 | return 0; | ||
62 | |||
63 | nla_put_failure: | ||
64 | return -EMSGSIZE; | ||
65 | } | ||
66 | #else | ||
67 | static int crypto_pcomp_report(struct sk_buff *skb, struct crypto_alg *alg) | ||
68 | { | ||
69 | return -ENOSYS; | ||
70 | } | ||
71 | #endif | ||
72 | |||
49 | static void crypto_pcomp_show(struct seq_file *m, struct crypto_alg *alg) | 73 | static void crypto_pcomp_show(struct seq_file *m, struct crypto_alg *alg) |
50 | __attribute__ ((unused)); | 74 | __attribute__ ((unused)); |
51 | static void crypto_pcomp_show(struct seq_file *m, struct crypto_alg *alg) | 75 | static void crypto_pcomp_show(struct seq_file *m, struct crypto_alg *alg) |
@@ -60,6 +84,7 @@ static const struct crypto_type crypto_pcomp_type = { | |||
60 | #ifdef CONFIG_PROC_FS | 84 | #ifdef CONFIG_PROC_FS |
61 | .show = crypto_pcomp_show, | 85 | .show = crypto_pcomp_show, |
62 | #endif | 86 | #endif |
87 | .report = crypto_pcomp_report, | ||
63 | .maskclear = ~CRYPTO_ALG_TYPE_MASK, | 88 | .maskclear = ~CRYPTO_ALG_TYPE_MASK, |
64 | .maskset = CRYPTO_ALG_TYPE_MASK, | 89 | .maskset = CRYPTO_ALG_TYPE_MASK, |
65 | .type = CRYPTO_ALG_TYPE_PCOMPRESS, | 90 | .type = CRYPTO_ALG_TYPE_PCOMPRESS, |
diff --git a/crypto/proc.c b/crypto/proc.c index 3808697814d..4a0a7aad220 100644 --- a/crypto/proc.c +++ b/crypto/proc.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/atomic.h> | 16 | #include <linux/atomic.h> |
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/crypto.h> | 18 | #include <linux/crypto.h> |
19 | #include <linux/module.h> /* for module_name() */ | ||
19 | #include <linux/rwsem.h> | 20 | #include <linux/rwsem.h> |
20 | #include <linux/proc_fs.h> | 21 | #include <linux/proc_fs.h> |
21 | #include <linux/seq_file.h> | 22 | #include <linux/seq_file.h> |
diff --git a/crypto/rng.c b/crypto/rng.c index 45229ae782b..64f864fa804 100644 --- a/crypto/rng.c +++ b/crypto/rng.c | |||
@@ -21,6 +21,8 @@ | |||
21 | #include <linux/seq_file.h> | 21 | #include <linux/seq_file.h> |
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
23 | #include <linux/string.h> | 23 | #include <linux/string.h> |
24 | #include <linux/cryptouser.h> | ||
25 | #include <net/netlink.h> | ||
24 | 26 | ||
25 | static DEFINE_MUTEX(crypto_default_rng_lock); | 27 | static DEFINE_MUTEX(crypto_default_rng_lock); |
26 | struct crypto_rng *crypto_default_rng; | 28 | struct crypto_rng *crypto_default_rng; |
@@ -58,6 +60,30 @@ static int crypto_init_rng_ops(struct crypto_tfm *tfm, u32 type, u32 mask) | |||
58 | return 0; | 60 | return 0; |
59 | } | 61 | } |
60 | 62 | ||
63 | #ifdef CONFIG_NET | ||
64 | static int crypto_rng_report(struct sk_buff *skb, struct crypto_alg *alg) | ||
65 | { | ||
66 | struct crypto_report_rng rrng; | ||
67 | |||
68 | snprintf(rrng.type, CRYPTO_MAX_ALG_NAME, "%s", "rng"); | ||
69 | |||
70 | rrng.seedsize = alg->cra_rng.seedsize; | ||
71 | |||
72 | NLA_PUT(skb, CRYPTOCFGA_REPORT_RNG, | ||
73 | sizeof(struct crypto_report_rng), &rrng); | ||
74 | |||
75 | return 0; | ||
76 | |||
77 | nla_put_failure: | ||
78 | return -EMSGSIZE; | ||
79 | } | ||
80 | #else | ||
81 | static int crypto_rng_report(struct sk_buff *skb, struct crypto_alg *alg) | ||
82 | { | ||
83 | return -ENOSYS; | ||
84 | } | ||
85 | #endif | ||
86 | |||
61 | static void crypto_rng_show(struct seq_file *m, struct crypto_alg *alg) | 87 | static void crypto_rng_show(struct seq_file *m, struct crypto_alg *alg) |
62 | __attribute__ ((unused)); | 88 | __attribute__ ((unused)); |
63 | static void crypto_rng_show(struct seq_file *m, struct crypto_alg *alg) | 89 | static void crypto_rng_show(struct seq_file *m, struct crypto_alg *alg) |
@@ -78,6 +104,7 @@ const struct crypto_type crypto_rng_type = { | |||
78 | #ifdef CONFIG_PROC_FS | 104 | #ifdef CONFIG_PROC_FS |
79 | .show = crypto_rng_show, | 105 | .show = crypto_rng_show, |
80 | #endif | 106 | #endif |
107 | .report = crypto_rng_report, | ||
81 | }; | 108 | }; |
82 | EXPORT_SYMBOL_GPL(crypto_rng_type); | 109 | EXPORT_SYMBOL_GPL(crypto_rng_type); |
83 | 110 | ||
diff --git a/crypto/sha1_generic.c b/crypto/sha1_generic.c index 00ae60eb925..42794803c48 100644 --- a/crypto/sha1_generic.c +++ b/crypto/sha1_generic.c | |||
@@ -36,7 +36,7 @@ static int sha1_init(struct shash_desc *desc) | |||
36 | return 0; | 36 | return 0; |
37 | } | 37 | } |
38 | 38 | ||
39 | static int sha1_update(struct shash_desc *desc, const u8 *data, | 39 | int crypto_sha1_update(struct shash_desc *desc, const u8 *data, |
40 | unsigned int len) | 40 | unsigned int len) |
41 | { | 41 | { |
42 | struct sha1_state *sctx = shash_desc_ctx(desc); | 42 | struct sha1_state *sctx = shash_desc_ctx(desc); |
@@ -71,6 +71,7 @@ static int sha1_update(struct shash_desc *desc, const u8 *data, | |||
71 | 71 | ||
72 | return 0; | 72 | return 0; |
73 | } | 73 | } |
74 | EXPORT_SYMBOL(crypto_sha1_update); | ||
74 | 75 | ||
75 | 76 | ||
76 | /* Add padding and return the message digest. */ | 77 | /* Add padding and return the message digest. */ |
@@ -87,10 +88,10 @@ static int sha1_final(struct shash_desc *desc, u8 *out) | |||
87 | /* Pad out to 56 mod 64 */ | 88 | /* Pad out to 56 mod 64 */ |
88 | index = sctx->count & 0x3f; | 89 | index = sctx->count & 0x3f; |
89 | padlen = (index < 56) ? (56 - index) : ((64+56) - index); | 90 | padlen = (index < 56) ? (56 - index) : ((64+56) - index); |
90 | sha1_update(desc, padding, padlen); | 91 | crypto_sha1_update(desc, padding, padlen); |
91 | 92 | ||
92 | /* Append length */ | 93 | /* Append length */ |
93 | sha1_update(desc, (const u8 *)&bits, sizeof(bits)); | 94 | crypto_sha1_update(desc, (const u8 *)&bits, sizeof(bits)); |
94 | 95 | ||
95 | /* Store state in digest */ | 96 | /* Store state in digest */ |
96 | for (i = 0; i < 5; i++) | 97 | for (i = 0; i < 5; i++) |
@@ -121,7 +122,7 @@ static int sha1_import(struct shash_desc *desc, const void *in) | |||
121 | static struct shash_alg alg = { | 122 | static struct shash_alg alg = { |
122 | .digestsize = SHA1_DIGEST_SIZE, | 123 | .digestsize = SHA1_DIGEST_SIZE, |
123 | .init = sha1_init, | 124 | .init = sha1_init, |
124 | .update = sha1_update, | 125 | .update = crypto_sha1_update, |
125 | .final = sha1_final, | 126 | .final = sha1_final, |
126 | .export = sha1_export, | 127 | .export = sha1_export, |
127 | .import = sha1_import, | 128 | .import = sha1_import, |
diff --git a/crypto/shash.c b/crypto/shash.c index 76f74b96315..9100912716a 100644 --- a/crypto/shash.c +++ b/crypto/shash.c | |||
@@ -17,6 +17,8 @@ | |||
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/seq_file.h> | 19 | #include <linux/seq_file.h> |
20 | #include <linux/cryptouser.h> | ||
21 | #include <net/netlink.h> | ||
20 | 22 | ||
21 | #include "internal.h" | 23 | #include "internal.h" |
22 | 24 | ||
@@ -522,6 +524,31 @@ static unsigned int crypto_shash_extsize(struct crypto_alg *alg) | |||
522 | return alg->cra_ctxsize; | 524 | return alg->cra_ctxsize; |
523 | } | 525 | } |
524 | 526 | ||
527 | #ifdef CONFIG_NET | ||
528 | static int crypto_shash_report(struct sk_buff *skb, struct crypto_alg *alg) | ||
529 | { | ||
530 | struct crypto_report_hash rhash; | ||
531 | struct shash_alg *salg = __crypto_shash_alg(alg); | ||
532 | |||
533 | snprintf(rhash.type, CRYPTO_MAX_ALG_NAME, "%s", "shash"); | ||
534 | rhash.blocksize = alg->cra_blocksize; | ||
535 | rhash.digestsize = salg->digestsize; | ||
536 | |||
537 | NLA_PUT(skb, CRYPTOCFGA_REPORT_HASH, | ||
538 | sizeof(struct crypto_report_hash), &rhash); | ||
539 | |||
540 | return 0; | ||
541 | |||
542 | nla_put_failure: | ||
543 | return -EMSGSIZE; | ||
544 | } | ||
545 | #else | ||
546 | static int crypto_shash_report(struct sk_buff *skb, struct crypto_alg *alg) | ||
547 | { | ||
548 | return -ENOSYS; | ||
549 | } | ||
550 | #endif | ||
551 | |||
525 | static void crypto_shash_show(struct seq_file *m, struct crypto_alg *alg) | 552 | static void crypto_shash_show(struct seq_file *m, struct crypto_alg *alg) |
526 | __attribute__ ((unused)); | 553 | __attribute__ ((unused)); |
527 | static void crypto_shash_show(struct seq_file *m, struct crypto_alg *alg) | 554 | static void crypto_shash_show(struct seq_file *m, struct crypto_alg *alg) |
@@ -541,6 +568,7 @@ static const struct crypto_type crypto_shash_type = { | |||
541 | #ifdef CONFIG_PROC_FS | 568 | #ifdef CONFIG_PROC_FS |
542 | .show = crypto_shash_show, | 569 | .show = crypto_shash_show, |
543 | #endif | 570 | #endif |
571 | .report = crypto_shash_report, | ||
544 | .maskclear = ~CRYPTO_ALG_TYPE_MASK, | 572 | .maskclear = ~CRYPTO_ALG_TYPE_MASK, |
545 | .maskset = CRYPTO_ALG_TYPE_MASK, | 573 | .maskset = CRYPTO_ALG_TYPE_MASK, |
546 | .type = CRYPTO_ALG_TYPE_SHASH, | 574 | .type = CRYPTO_ALG_TYPE_SHASH, |
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index 2222617b3be..0c4e80f3465 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c | |||
@@ -782,11 +782,13 @@ static int do_test(int m) | |||
782 | case 7: | 782 | case 7: |
783 | ret += tcrypt_test("ecb(blowfish)"); | 783 | ret += tcrypt_test("ecb(blowfish)"); |
784 | ret += tcrypt_test("cbc(blowfish)"); | 784 | ret += tcrypt_test("cbc(blowfish)"); |
785 | ret += tcrypt_test("ctr(blowfish)"); | ||
785 | break; | 786 | break; |
786 | 787 | ||
787 | case 8: | 788 | case 8: |
788 | ret += tcrypt_test("ecb(twofish)"); | 789 | ret += tcrypt_test("ecb(twofish)"); |
789 | ret += tcrypt_test("cbc(twofish)"); | 790 | ret += tcrypt_test("cbc(twofish)"); |
791 | ret += tcrypt_test("ctr(twofish)"); | ||
790 | break; | 792 | break; |
791 | 793 | ||
792 | case 9: | 794 | case 9: |
@@ -1039,6 +1041,10 @@ static int do_test(int m) | |||
1039 | speed_template_16_24_32); | 1041 | speed_template_16_24_32); |
1040 | test_cipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0, | 1042 | test_cipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0, |
1041 | speed_template_16_24_32); | 1043 | speed_template_16_24_32); |
1044 | test_cipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0, | ||
1045 | speed_template_16_24_32); | ||
1046 | test_cipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0, | ||
1047 | speed_template_16_24_32); | ||
1042 | break; | 1048 | break; |
1043 | 1049 | ||
1044 | case 203: | 1050 | case 203: |
@@ -1050,6 +1056,10 @@ static int do_test(int m) | |||
1050 | speed_template_8_32); | 1056 | speed_template_8_32); |
1051 | test_cipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0, | 1057 | test_cipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0, |
1052 | speed_template_8_32); | 1058 | speed_template_8_32); |
1059 | test_cipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0, | ||
1060 | speed_template_8_32); | ||
1061 | test_cipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0, | ||
1062 | speed_template_8_32); | ||
1053 | break; | 1063 | break; |
1054 | 1064 | ||
1055 | case 204: | 1065 | case 204: |
diff --git a/crypto/testmgr.c b/crypto/testmgr.c index b6b93d41635..e91c1eb1722 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c | |||
@@ -1756,6 +1756,36 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1756 | } | 1756 | } |
1757 | } | 1757 | } |
1758 | }, { | 1758 | }, { |
1759 | .alg = "ctr(blowfish)", | ||
1760 | .test = alg_test_skcipher, | ||
1761 | .suite = { | ||
1762 | .cipher = { | ||
1763 | .enc = { | ||
1764 | .vecs = bf_ctr_enc_tv_template, | ||
1765 | .count = BF_CTR_ENC_TEST_VECTORS | ||
1766 | }, | ||
1767 | .dec = { | ||
1768 | .vecs = bf_ctr_dec_tv_template, | ||
1769 | .count = BF_CTR_DEC_TEST_VECTORS | ||
1770 | } | ||
1771 | } | ||
1772 | } | ||
1773 | }, { | ||
1774 | .alg = "ctr(twofish)", | ||
1775 | .test = alg_test_skcipher, | ||
1776 | .suite = { | ||
1777 | .cipher = { | ||
1778 | .enc = { | ||
1779 | .vecs = tf_ctr_enc_tv_template, | ||
1780 | .count = TF_CTR_ENC_TEST_VECTORS | ||
1781 | }, | ||
1782 | .dec = { | ||
1783 | .vecs = tf_ctr_dec_tv_template, | ||
1784 | .count = TF_CTR_DEC_TEST_VECTORS | ||
1785 | } | ||
1786 | } | ||
1787 | } | ||
1788 | }, { | ||
1759 | .alg = "cts(cbc(aes))", | 1789 | .alg = "cts(cbc(aes))", |
1760 | .test = alg_test_skcipher, | 1790 | .test = alg_test_skcipher, |
1761 | .suite = { | 1791 | .suite = { |
diff --git a/crypto/testmgr.h b/crypto/testmgr.h index 27adc92842b..37b4d8f4544 100644 --- a/crypto/testmgr.h +++ b/crypto/testmgr.h | |||
@@ -2391,10 +2391,12 @@ static struct cipher_testvec des3_ede_cbc_dec_tv_template[] = { | |||
2391 | /* | 2391 | /* |
2392 | * Blowfish test vectors. | 2392 | * Blowfish test vectors. |
2393 | */ | 2393 | */ |
2394 | #define BF_ENC_TEST_VECTORS 6 | 2394 | #define BF_ENC_TEST_VECTORS 7 |
2395 | #define BF_DEC_TEST_VECTORS 6 | 2395 | #define BF_DEC_TEST_VECTORS 7 |
2396 | #define BF_CBC_ENC_TEST_VECTORS 1 | 2396 | #define BF_CBC_ENC_TEST_VECTORS 2 |
2397 | #define BF_CBC_DEC_TEST_VECTORS 1 | 2397 | #define BF_CBC_DEC_TEST_VECTORS 2 |
2398 | #define BF_CTR_ENC_TEST_VECTORS 2 | ||
2399 | #define BF_CTR_DEC_TEST_VECTORS 2 | ||
2398 | 2400 | ||
2399 | static struct cipher_testvec bf_enc_tv_template[] = { | 2401 | static struct cipher_testvec bf_enc_tv_template[] = { |
2400 | { /* DES test vectors from OpenSSL */ | 2402 | { /* DES test vectors from OpenSSL */ |
@@ -2448,6 +2450,24 @@ static struct cipher_testvec bf_enc_tv_template[] = { | |||
2448 | .ilen = 8, | 2450 | .ilen = 8, |
2449 | .result = "\xc0\x45\x04\x01\x2e\x4e\x1f\x53", | 2451 | .result = "\xc0\x45\x04\x01\x2e\x4e\x1f\x53", |
2450 | .rlen = 8, | 2452 | .rlen = 8, |
2453 | }, { /* Generated with Crypto++ */ | ||
2454 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
2455 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
2456 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
2457 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
2458 | .klen = 32, | ||
2459 | .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
2460 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
2461 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
2462 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
2463 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9", | ||
2464 | .ilen = 40, | ||
2465 | .result = "\x96\x87\x3D\x0C\x7B\xFB\xBD\x1F" | ||
2466 | "\xE3\xC1\x99\x6D\x39\xD4\xC2\x7D" | ||
2467 | "\xD7\x87\xA1\xF2\xDF\x51\x71\x26" | ||
2468 | "\xC2\xF4\x6D\xFF\xF6\xCD\x6B\x40" | ||
2469 | "\xE1\xB3\xBF\xD4\x38\x2B\xC8\x3B", | ||
2470 | .rlen = 40, | ||
2451 | }, | 2471 | }, |
2452 | }; | 2472 | }; |
2453 | 2473 | ||
@@ -2503,6 +2523,24 @@ static struct cipher_testvec bf_dec_tv_template[] = { | |||
2503 | .ilen = 8, | 2523 | .ilen = 8, |
2504 | .result = "\xfe\xdc\xba\x98\x76\x54\x32\x10", | 2524 | .result = "\xfe\xdc\xba\x98\x76\x54\x32\x10", |
2505 | .rlen = 8, | 2525 | .rlen = 8, |
2526 | }, { /* Generated with Crypto++ */ | ||
2527 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
2528 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
2529 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
2530 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
2531 | .klen = 32, | ||
2532 | .input = "\x96\x87\x3D\x0C\x7B\xFB\xBD\x1F" | ||
2533 | "\xE3\xC1\x99\x6D\x39\xD4\xC2\x7D" | ||
2534 | "\xD7\x87\xA1\xF2\xDF\x51\x71\x26" | ||
2535 | "\xC2\xF4\x6D\xFF\xF6\xCD\x6B\x40" | ||
2536 | "\xE1\xB3\xBF\xD4\x38\x2B\xC8\x3B", | ||
2537 | .ilen = 40, | ||
2538 | .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
2539 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
2540 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
2541 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
2542 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9", | ||
2543 | .rlen = 40, | ||
2506 | }, | 2544 | }, |
2507 | }; | 2545 | }; |
2508 | 2546 | ||
@@ -2522,6 +2560,25 @@ static struct cipher_testvec bf_cbc_enc_tv_template[] = { | |||
2522 | "\x58\xde\xb9\xe7\x15\x46\x16\xd9" | 2560 | "\x58\xde\xb9\xe7\x15\x46\x16\xd9" |
2523 | "\x59\xf1\x65\x2b\xd5\xff\x92\xcc", | 2561 | "\x59\xf1\x65\x2b\xd5\xff\x92\xcc", |
2524 | .rlen = 32, | 2562 | .rlen = 32, |
2563 | }, { /* Generated with Crypto++ */ | ||
2564 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
2565 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
2566 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
2567 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
2568 | .klen = 32, | ||
2569 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F", | ||
2570 | .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
2571 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
2572 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
2573 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
2574 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9", | ||
2575 | .ilen = 40, | ||
2576 | .result = "\xB4\xFE\xA5\xBB\x3D\x2C\x27\x06" | ||
2577 | "\x06\x2B\x3A\x92\xB2\xF5\x5E\x62" | ||
2578 | "\x84\xCD\xF7\x66\x7E\x41\x6C\x8E" | ||
2579 | "\x1B\xD9\x02\xB6\x48\xB0\x87\x25" | ||
2580 | "\x01\x9C\x93\x63\x51\x60\x82\xD2", | ||
2581 | .rlen = 40, | ||
2525 | }, | 2582 | }, |
2526 | }; | 2583 | }; |
2527 | 2584 | ||
@@ -2541,16 +2598,125 @@ static struct cipher_testvec bf_cbc_dec_tv_template[] = { | |||
2541 | "\x68\x65\x20\x74\x69\x6d\x65\x20" | 2598 | "\x68\x65\x20\x74\x69\x6d\x65\x20" |
2542 | "\x66\x6f\x72\x20\x00\x00\x00\x00", | 2599 | "\x66\x6f\x72\x20\x00\x00\x00\x00", |
2543 | .rlen = 32, | 2600 | .rlen = 32, |
2601 | }, { /* Generated with Crypto++ */ | ||
2602 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
2603 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
2604 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
2605 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
2606 | .klen = 32, | ||
2607 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F", | ||
2608 | .input = "\xB4\xFE\xA5\xBB\x3D\x2C\x27\x06" | ||
2609 | "\x06\x2B\x3A\x92\xB2\xF5\x5E\x62" | ||
2610 | "\x84\xCD\xF7\x66\x7E\x41\x6C\x8E" | ||
2611 | "\x1B\xD9\x02\xB6\x48\xB0\x87\x25" | ||
2612 | "\x01\x9C\x93\x63\x51\x60\x82\xD2", | ||
2613 | .ilen = 40, | ||
2614 | .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
2615 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
2616 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
2617 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
2618 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9", | ||
2619 | .rlen = 40, | ||
2620 | }, | ||
2621 | }; | ||
2622 | |||
2623 | static struct cipher_testvec bf_ctr_enc_tv_template[] = { | ||
2624 | { /* Generated with Crypto++ */ | ||
2625 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
2626 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
2627 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
2628 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
2629 | .klen = 32, | ||
2630 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F", | ||
2631 | .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
2632 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
2633 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
2634 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
2635 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9", | ||
2636 | .ilen = 40, | ||
2637 | .result = "\xC7\xA3\xDF\xB9\x05\xF4\x9E\x8D" | ||
2638 | "\x9E\xDF\x38\x18\x83\x07\xEF\xC1" | ||
2639 | "\x93\x3C\xAA\xAA\xFE\x06\x42\xCC" | ||
2640 | "\x0D\x70\x86\x5A\x44\xAD\x85\x17" | ||
2641 | "\xE4\x1F\x5E\xA5\x89\xAC\x32\xBC", | ||
2642 | .rlen = 40, | ||
2643 | }, { /* Generated with Crypto++ */ | ||
2644 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
2645 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
2646 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
2647 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
2648 | .klen = 32, | ||
2649 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F", | ||
2650 | .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
2651 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
2652 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
2653 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
2654 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
2655 | "\x6D\x04\x9B", | ||
2656 | .ilen = 43, | ||
2657 | .result = "\xC7\xA3\xDF\xB9\x05\xF4\x9E\x8D" | ||
2658 | "\x9E\xDF\x38\x18\x83\x07\xEF\xC1" | ||
2659 | "\x93\x3C\xAA\xAA\xFE\x06\x42\xCC" | ||
2660 | "\x0D\x70\x86\x5A\x44\xAD\x85\x17" | ||
2661 | "\xE4\x1F\x5E\xA5\x89\xAC\x32\xBC" | ||
2662 | "\x3D\xA7\xE9", | ||
2663 | .rlen = 43, | ||
2664 | }, | ||
2665 | }; | ||
2666 | |||
2667 | static struct cipher_testvec bf_ctr_dec_tv_template[] = { | ||
2668 | { /* Generated with Crypto++ */ | ||
2669 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
2670 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
2671 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
2672 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
2673 | .klen = 32, | ||
2674 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F", | ||
2675 | .input = "\xC7\xA3\xDF\xB9\x05\xF4\x9E\x8D" | ||
2676 | "\x9E\xDF\x38\x18\x83\x07\xEF\xC1" | ||
2677 | "\x93\x3C\xAA\xAA\xFE\x06\x42\xCC" | ||
2678 | "\x0D\x70\x86\x5A\x44\xAD\x85\x17" | ||
2679 | "\xE4\x1F\x5E\xA5\x89\xAC\x32\xBC", | ||
2680 | .ilen = 40, | ||
2681 | .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
2682 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
2683 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
2684 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
2685 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9", | ||
2686 | .rlen = 40, | ||
2687 | }, { /* Generated with Crypto++ */ | ||
2688 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
2689 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
2690 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
2691 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
2692 | .klen = 32, | ||
2693 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F", | ||
2694 | .input = "\xC7\xA3\xDF\xB9\x05\xF4\x9E\x8D" | ||
2695 | "\x9E\xDF\x38\x18\x83\x07\xEF\xC1" | ||
2696 | "\x93\x3C\xAA\xAA\xFE\x06\x42\xCC" | ||
2697 | "\x0D\x70\x86\x5A\x44\xAD\x85\x17" | ||
2698 | "\xE4\x1F\x5E\xA5\x89\xAC\x32\xBC" | ||
2699 | "\x3D\xA7\xE9", | ||
2700 | .ilen = 43, | ||
2701 | .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
2702 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
2703 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
2704 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
2705 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
2706 | "\x6D\x04\x9B", | ||
2707 | .rlen = 43, | ||
2544 | }, | 2708 | }, |
2545 | }; | 2709 | }; |
2546 | 2710 | ||
2547 | /* | 2711 | /* |
2548 | * Twofish test vectors. | 2712 | * Twofish test vectors. |
2549 | */ | 2713 | */ |
2550 | #define TF_ENC_TEST_VECTORS 3 | 2714 | #define TF_ENC_TEST_VECTORS 4 |
2551 | #define TF_DEC_TEST_VECTORS 3 | 2715 | #define TF_DEC_TEST_VECTORS 4 |
2552 | #define TF_CBC_ENC_TEST_VECTORS 4 | 2716 | #define TF_CBC_ENC_TEST_VECTORS 5 |
2553 | #define TF_CBC_DEC_TEST_VECTORS 4 | 2717 | #define TF_CBC_DEC_TEST_VECTORS 5 |
2718 | #define TF_CTR_ENC_TEST_VECTORS 2 | ||
2719 | #define TF_CTR_DEC_TEST_VECTORS 2 | ||
2554 | 2720 | ||
2555 | static struct cipher_testvec tf_enc_tv_template[] = { | 2721 | static struct cipher_testvec tf_enc_tv_template[] = { |
2556 | { | 2722 | { |
@@ -2582,6 +2748,30 @@ static struct cipher_testvec tf_enc_tv_template[] = { | |||
2582 | .result = "\x37\x52\x7b\xe0\x05\x23\x34\xb8" | 2748 | .result = "\x37\x52\x7b\xe0\x05\x23\x34\xb8" |
2583 | "\x9f\x0c\xfc\xca\xe8\x7c\xfa\x20", | 2749 | "\x9f\x0c\xfc\xca\xe8\x7c\xfa\x20", |
2584 | .rlen = 16, | 2750 | .rlen = 16, |
2751 | }, { /* Generated with Crypto++ */ | ||
2752 | .key = "\x3F\x85\x62\x3F\x1C\xF9\xD6\x1C" | ||
2753 | "\xF9\xD6\xB3\x90\x6D\x4A\x90\x6D" | ||
2754 | "\x4A\x27\x04\xE1\x27\x04\xE1\xBE" | ||
2755 | "\x9B\x78\xBE\x9B\x78\x55\x32\x0F", | ||
2756 | .klen = 32, | ||
2757 | .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
2758 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
2759 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
2760 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
2761 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
2762 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
2763 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
2764 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C", | ||
2765 | .ilen = 64, | ||
2766 | .result = "\x88\xCB\x1E\xC2\xAF\x8A\x97\xFF" | ||
2767 | "\xF6\x90\x46\x9C\x4A\x0F\x08\xDC" | ||
2768 | "\xDE\xAB\xAD\xFA\xFC\xA8\xC2\x3D" | ||
2769 | "\xE0\xE4\x8B\x3F\xD5\xA3\xF7\x14" | ||
2770 | "\x34\x9E\xB6\x08\xB2\xDD\xA8\xF5" | ||
2771 | "\xDF\xFA\xC7\xE8\x09\x50\x76\x08" | ||
2772 | "\xA2\xB6\x6A\x59\xC0\x2B\x6D\x05" | ||
2773 | "\x89\xF6\x82\xF0\xD3\xDB\x06\x02", | ||
2774 | .rlen = 64, | ||
2585 | }, | 2775 | }, |
2586 | }; | 2776 | }; |
2587 | 2777 | ||
@@ -2615,6 +2805,30 @@ static struct cipher_testvec tf_dec_tv_template[] = { | |||
2615 | .ilen = 16, | 2805 | .ilen = 16, |
2616 | .result = zeroed_string, | 2806 | .result = zeroed_string, |
2617 | .rlen = 16, | 2807 | .rlen = 16, |
2808 | }, { /* Generated with Crypto++ */ | ||
2809 | .key = "\x3F\x85\x62\x3F\x1C\xF9\xD6\x1C" | ||
2810 | "\xF9\xD6\xB3\x90\x6D\x4A\x90\x6D" | ||
2811 | "\x4A\x27\x04\xE1\x27\x04\xE1\xBE" | ||
2812 | "\x9B\x78\xBE\x9B\x78\x55\x32\x0F", | ||
2813 | .klen = 32, | ||
2814 | .input = "\x88\xCB\x1E\xC2\xAF\x8A\x97\xFF" | ||
2815 | "\xF6\x90\x46\x9C\x4A\x0F\x08\xDC" | ||
2816 | "\xDE\xAB\xAD\xFA\xFC\xA8\xC2\x3D" | ||
2817 | "\xE0\xE4\x8B\x3F\xD5\xA3\xF7\x14" | ||
2818 | "\x34\x9E\xB6\x08\xB2\xDD\xA8\xF5" | ||
2819 | "\xDF\xFA\xC7\xE8\x09\x50\x76\x08" | ||
2820 | "\xA2\xB6\x6A\x59\xC0\x2B\x6D\x05" | ||
2821 | "\x89\xF6\x82\xF0\xD3\xDB\x06\x02", | ||
2822 | .ilen = 64, | ||
2823 | .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
2824 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
2825 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
2826 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
2827 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
2828 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
2829 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
2830 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C", | ||
2831 | .rlen = 64, | ||
2618 | }, | 2832 | }, |
2619 | }; | 2833 | }; |
2620 | 2834 | ||
@@ -2661,6 +2875,32 @@ static struct cipher_testvec tf_cbc_enc_tv_template[] = { | |||
2661 | "\x05\xef\x8c\x61\xa8\x11\x58\x26" | 2875 | "\x05\xef\x8c\x61\xa8\x11\x58\x26" |
2662 | "\x34\xba\x5c\xb7\x10\x6a\xa6\x41", | 2876 | "\x34\xba\x5c\xb7\x10\x6a\xa6\x41", |
2663 | .rlen = 48, | 2877 | .rlen = 48, |
2878 | }, { /* Generated with Crypto++ */ | ||
2879 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
2880 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
2881 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
2882 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
2883 | .klen = 32, | ||
2884 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F" | ||
2885 | "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64", | ||
2886 | .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
2887 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
2888 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
2889 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
2890 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
2891 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
2892 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
2893 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C", | ||
2894 | .ilen = 64, | ||
2895 | .result = "\xC8\xFF\xF2\x53\xA6\x27\x09\xD1" | ||
2896 | "\x33\x38\xC2\xC0\x0C\x14\x7E\xB5" | ||
2897 | "\x26\x1B\x05\x0C\x05\x12\x3F\xC0" | ||
2898 | "\xF9\x1C\x02\x28\x40\x96\x6F\xD0" | ||
2899 | "\x3D\x32\xDF\xDA\x56\x00\x6E\xEE" | ||
2900 | "\x5B\x2A\x72\x9D\xC2\x4D\x19\xBC" | ||
2901 | "\x8C\x53\xFA\x87\x6F\xDD\x81\xA3" | ||
2902 | "\xB1\xD3\x44\x65\xDF\xE7\x63\x38", | ||
2903 | .rlen = 64, | ||
2664 | }, | 2904 | }, |
2665 | }; | 2905 | }; |
2666 | 2906 | ||
@@ -2707,6 +2947,148 @@ static struct cipher_testvec tf_cbc_dec_tv_template[] = { | |||
2707 | .ilen = 48, | 2947 | .ilen = 48, |
2708 | .result = zeroed_string, | 2948 | .result = zeroed_string, |
2709 | .rlen = 48, | 2949 | .rlen = 48, |
2950 | }, { /* Generated with Crypto++ */ | ||
2951 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
2952 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
2953 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
2954 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
2955 | .klen = 32, | ||
2956 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F" | ||
2957 | "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64", | ||
2958 | .input = "\xC8\xFF\xF2\x53\xA6\x27\x09\xD1" | ||
2959 | "\x33\x38\xC2\xC0\x0C\x14\x7E\xB5" | ||
2960 | "\x26\x1B\x05\x0C\x05\x12\x3F\xC0" | ||
2961 | "\xF9\x1C\x02\x28\x40\x96\x6F\xD0" | ||
2962 | "\x3D\x32\xDF\xDA\x56\x00\x6E\xEE" | ||
2963 | "\x5B\x2A\x72\x9D\xC2\x4D\x19\xBC" | ||
2964 | "\x8C\x53\xFA\x87\x6F\xDD\x81\xA3" | ||
2965 | "\xB1\xD3\x44\x65\xDF\xE7\x63\x38", | ||
2966 | .ilen = 64, | ||
2967 | .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
2968 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
2969 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
2970 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
2971 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
2972 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
2973 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
2974 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C", | ||
2975 | .rlen = 64, | ||
2976 | }, | ||
2977 | }; | ||
2978 | |||
2979 | static struct cipher_testvec tf_ctr_enc_tv_template[] = { | ||
2980 | { /* Generated with Crypto++ */ | ||
2981 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
2982 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
2983 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
2984 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
2985 | .klen = 32, | ||
2986 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F" | ||
2987 | "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64", | ||
2988 | .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
2989 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
2990 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
2991 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
2992 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
2993 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
2994 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
2995 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C", | ||
2996 | .ilen = 64, | ||
2997 | .result = "\xDF\xDD\x69\xFA\xB0\x2E\xFD\xFE" | ||
2998 | "\x70\x9E\xC5\x4B\xC9\xD4\xA1\x30" | ||
2999 | "\x26\x9B\x89\xA1\xEE\x43\xE0\x52" | ||
3000 | "\x55\x17\x4E\xC7\x0E\x33\x1F\xF1" | ||
3001 | "\x9F\x8D\x40\x9F\x24\xFD\x92\xA0" | ||
3002 | "\xBC\x8F\x35\xDD\x67\x38\xD8\xAA" | ||
3003 | "\xCF\xF8\x48\xCA\xFB\xE4\x5C\x60" | ||
3004 | "\x01\x41\x21\x12\x38\xAB\x52\x4F", | ||
3005 | .rlen = 64, | ||
3006 | }, { /* Generated with Crypto++ */ | ||
3007 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
3008 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
3009 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
3010 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
3011 | .klen = 32, | ||
3012 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F" | ||
3013 | "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64", | ||
3014 | .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
3015 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
3016 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
3017 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
3018 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
3019 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
3020 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
3021 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" | ||
3022 | "\xC3\x37\xCE", | ||
3023 | .ilen = 67, | ||
3024 | .result = "\xDF\xDD\x69\xFA\xB0\x2E\xFD\xFE" | ||
3025 | "\x70\x9E\xC5\x4B\xC9\xD4\xA1\x30" | ||
3026 | "\x26\x9B\x89\xA1\xEE\x43\xE0\x52" | ||
3027 | "\x55\x17\x4E\xC7\x0E\x33\x1F\xF1" | ||
3028 | "\x9F\x8D\x40\x9F\x24\xFD\x92\xA0" | ||
3029 | "\xBC\x8F\x35\xDD\x67\x38\xD8\xAA" | ||
3030 | "\xCF\xF8\x48\xCA\xFB\xE4\x5C\x60" | ||
3031 | "\x01\x41\x21\x12\x38\xAB\x52\x4F" | ||
3032 | "\xA8\x57\x20", | ||
3033 | .rlen = 67, | ||
3034 | }, | ||
3035 | }; | ||
3036 | |||
3037 | static struct cipher_testvec tf_ctr_dec_tv_template[] = { | ||
3038 | { /* Generated with Crypto++ */ | ||
3039 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
3040 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
3041 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
3042 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
3043 | .klen = 32, | ||
3044 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F" | ||
3045 | "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64", | ||
3046 | .input = "\xDF\xDD\x69\xFA\xB0\x2E\xFD\xFE" | ||
3047 | "\x70\x9E\xC5\x4B\xC9\xD4\xA1\x30" | ||
3048 | "\x26\x9B\x89\xA1\xEE\x43\xE0\x52" | ||
3049 | "\x55\x17\x4E\xC7\x0E\x33\x1F\xF1" | ||
3050 | "\x9F\x8D\x40\x9F\x24\xFD\x92\xA0" | ||
3051 | "\xBC\x8F\x35\xDD\x67\x38\xD8\xAA" | ||
3052 | "\xCF\xF8\x48\xCA\xFB\xE4\x5C\x60" | ||
3053 | "\x01\x41\x21\x12\x38\xAB\x52\x4F", | ||
3054 | .ilen = 64, | ||
3055 | .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
3056 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
3057 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
3058 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
3059 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
3060 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
3061 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
3062 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C", | ||
3063 | .rlen = 64, | ||
3064 | }, { /* Generated with Crypto++ */ | ||
3065 | .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" | ||
3066 | "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" | ||
3067 | "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" | ||
3068 | "\x78\xBE\x9B\x78\x55\x32\x0F\x55", | ||
3069 | .klen = 32, | ||
3070 | .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F" | ||
3071 | "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64", | ||
3072 | .input = "\xDF\xDD\x69\xFA\xB0\x2E\xFD\xFE" | ||
3073 | "\x70\x9E\xC5\x4B\xC9\xD4\xA1\x30" | ||
3074 | "\x26\x9B\x89\xA1\xEE\x43\xE0\x52" | ||
3075 | "\x55\x17\x4E\xC7\x0E\x33\x1F\xF1" | ||
3076 | "\x9F\x8D\x40\x9F\x24\xFD\x92\xA0" | ||
3077 | "\xBC\x8F\x35\xDD\x67\x38\xD8\xAA" | ||
3078 | "\xCF\xF8\x48\xCA\xFB\xE4\x5C\x60" | ||
3079 | "\x01\x41\x21\x12\x38\xAB\x52\x4F" | ||
3080 | "\xA8\x57\x20", | ||
3081 | .ilen = 67, | ||
3082 | .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" | ||
3083 | "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" | ||
3084 | "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" | ||
3085 | "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" | ||
3086 | "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" | ||
3087 | "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" | ||
3088 | "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" | ||
3089 | "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" | ||
3090 | "\xC3\x37\xCE", | ||
3091 | .rlen = 67, | ||
2710 | }, | 3092 | }, |
2711 | }; | 3093 | }; |
2712 | 3094 | ||
diff --git a/crypto/vmac.c b/crypto/vmac.c index f35ff8a3926..4243905ba13 100644 --- a/crypto/vmac.c +++ b/crypto/vmac.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/init.h> | 27 | #include <linux/init.h> |
28 | #include <linux/types.h> | 28 | #include <linux/types.h> |
29 | #include <linux/crypto.h> | 29 | #include <linux/crypto.h> |
30 | #include <linux/module.h> | ||
30 | #include <linux/scatterlist.h> | 31 | #include <linux/scatterlist.h> |
31 | #include <asm/byteorder.h> | 32 | #include <asm/byteorder.h> |
32 | #include <crypto/scatterwalk.h> | 33 | #include <crypto/scatterwalk.h> |
diff --git a/crypto/wp512.c b/crypto/wp512.c index 72342727368..71719a2be25 100644 --- a/crypto/wp512.c +++ b/crypto/wp512.c | |||
@@ -762,11 +762,17 @@ static const u64 C7[256] = { | |||
762 | 0x86228644a411c286ULL, | 762 | 0x86228644a411c286ULL, |
763 | }; | 763 | }; |
764 | 764 | ||
765 | static const u64 rc[WHIRLPOOL_ROUNDS + 1] = { | 765 | static const u64 rc[WHIRLPOOL_ROUNDS] = { |
766 | 0x0000000000000000ULL, 0x1823c6e887b8014fULL, 0x36a6d2f5796f9152ULL, | 766 | 0x1823c6e887b8014fULL, |
767 | 0x60bc9b8ea30c7b35ULL, 0x1de0d7c22e4bfe57ULL, 0x157737e59ff04adaULL, | 767 | 0x36a6d2f5796f9152ULL, |
768 | 0x58c9290ab1a06b85ULL, 0xbd5d10f4cb3e0567ULL, 0xe427418ba77d95d8ULL, | 768 | 0x60bc9b8ea30c7b35ULL, |
769 | 0xfbee7c66dd17479eULL, 0xca2dbf07ad5a8333ULL, | 769 | 0x1de0d7c22e4bfe57ULL, |
770 | 0x157737e59ff04adaULL, | ||
771 | 0x58c9290ab1a06b85ULL, | ||
772 | 0xbd5d10f4cb3e0567ULL, | ||
773 | 0xe427418ba77d95d8ULL, | ||
774 | 0xfbee7c66dd17479eULL, | ||
775 | 0xca2dbf07ad5a8333ULL, | ||
770 | }; | 776 | }; |
771 | 777 | ||
772 | /** | 778 | /** |
@@ -793,7 +799,7 @@ static void wp512_process_buffer(struct wp512_ctx *wctx) { | |||
793 | state[6] = block[6] ^ (K[6] = wctx->hash[6]); | 799 | state[6] = block[6] ^ (K[6] = wctx->hash[6]); |
794 | state[7] = block[7] ^ (K[7] = wctx->hash[7]); | 800 | state[7] = block[7] ^ (K[7] = wctx->hash[7]); |
795 | 801 | ||
796 | for (r = 1; r <= WHIRLPOOL_ROUNDS; r++) { | 802 | for (r = 0; r < WHIRLPOOL_ROUNDS; r++) { |
797 | 803 | ||
798 | L[0] = C0[(int)(K[0] >> 56) ] ^ | 804 | L[0] = C0[(int)(K[0] >> 56) ] ^ |
799 | C1[(int)(K[7] >> 48) & 0xff] ^ | 805 | C1[(int)(K[7] >> 48) & 0xff] ^ |
diff --git a/crypto/xcbc.c b/crypto/xcbc.c index bb7b67fba34..a5fbdf3738c 100644 --- a/crypto/xcbc.c +++ b/crypto/xcbc.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <crypto/internal/hash.h> | 22 | #include <crypto/internal/hash.h> |
23 | #include <linux/err.h> | 23 | #include <linux/err.h> |
24 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
25 | #include <linux/module.h> | ||
25 | 26 | ||
26 | static u_int32_t ks[12] = {0x01010101, 0x01010101, 0x01010101, 0x01010101, | 27 | static u_int32_t ks[12] = {0x01010101, 0x01010101, 0x01010101, 0x01010101, |
27 | 0x02020202, 0x02020202, 0x02020202, 0x02020202, | 28 | 0x02020202, 0x02020202, 0x02020202, 0x02020202, |