diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-01-25 11:38:25 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-01-25 11:38:25 -0500 |
commit | eba0e319c12fb098d66316a8eafbaaa9174a07c3 (patch) | |
tree | b2703117db9e36bb3510654efd55361f61c54742 /include/linux | |
parent | df8dc74e8a383eaf2d9b44b80a71ec6f0e52b42e (diff) | |
parent | 15e7b4452b72ae890f2fcb027b4c4fa63a1c9a7a (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (125 commits)
[CRYPTO] twofish: Merge common glue code
[CRYPTO] hifn_795x: Fixup container_of() usage
[CRYPTO] cast6: inline bloat--
[CRYPTO] api: Set default CRYPTO_MINALIGN to unsigned long long
[CRYPTO] tcrypt: Make xcbc available as a standalone test
[CRYPTO] xcbc: Remove bogus hash/cipher test
[CRYPTO] xcbc: Fix algorithm leak when block size check fails
[CRYPTO] tcrypt: Zero axbuf in the right function
[CRYPTO] padlock: Only reset the key once for each CBC and ECB operation
[CRYPTO] api: Include sched.h for cond_resched in scatterwalk.h
[CRYPTO] salsa20-asm: Remove unnecessary dependency on CRYPTO_SALSA20
[CRYPTO] tcrypt: Add select of AEAD
[CRYPTO] salsa20: Add x86-64 assembly version
[CRYPTO] salsa20_i586: Salsa20 stream cipher algorithm (i586 version)
[CRYPTO] gcm: Introduce rfc4106
[CRYPTO] api: Show async type
[CRYPTO] chainiv: Avoid lock spinning where possible
[CRYPTO] seqiv: Add select AEAD in Kconfig
[CRYPTO] scatterwalk: Handle zero nbytes in scatterwalk_map_and_copy
[CRYPTO] null: Allow setkey on digest_null
...
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/crypto.h | 103 | ||||
-rw-r--r-- | include/linux/hw_random.h | 2 |
2 files changed, 69 insertions, 36 deletions
diff --git a/include/linux/crypto.h b/include/linux/crypto.h index f3110ebe894..5e02d1b4637 100644 --- a/include/linux/crypto.h +++ b/include/linux/crypto.h | |||
@@ -33,10 +33,13 @@ | |||
33 | #define CRYPTO_ALG_TYPE_DIGEST 0x00000002 | 33 | #define CRYPTO_ALG_TYPE_DIGEST 0x00000002 |
34 | #define CRYPTO_ALG_TYPE_HASH 0x00000003 | 34 | #define CRYPTO_ALG_TYPE_HASH 0x00000003 |
35 | #define CRYPTO_ALG_TYPE_BLKCIPHER 0x00000004 | 35 | #define CRYPTO_ALG_TYPE_BLKCIPHER 0x00000004 |
36 | #define CRYPTO_ALG_TYPE_COMPRESS 0x00000005 | 36 | #define CRYPTO_ALG_TYPE_ABLKCIPHER 0x00000005 |
37 | #define CRYPTO_ALG_TYPE_AEAD 0x00000006 | 37 | #define CRYPTO_ALG_TYPE_GIVCIPHER 0x00000006 |
38 | #define CRYPTO_ALG_TYPE_COMPRESS 0x00000008 | ||
39 | #define CRYPTO_ALG_TYPE_AEAD 0x00000009 | ||
38 | 40 | ||
39 | #define CRYPTO_ALG_TYPE_HASH_MASK 0x0000000e | 41 | #define CRYPTO_ALG_TYPE_HASH_MASK 0x0000000e |
42 | #define CRYPTO_ALG_TYPE_BLKCIPHER_MASK 0x0000000c | ||
40 | 43 | ||
41 | #define CRYPTO_ALG_LARVAL 0x00000010 | 44 | #define CRYPTO_ALG_LARVAL 0x00000010 |
42 | #define CRYPTO_ALG_DEAD 0x00000020 | 45 | #define CRYPTO_ALG_DEAD 0x00000020 |
@@ -50,6 +53,12 @@ | |||
50 | #define CRYPTO_ALG_NEED_FALLBACK 0x00000100 | 53 | #define CRYPTO_ALG_NEED_FALLBACK 0x00000100 |
51 | 54 | ||
52 | /* | 55 | /* |
56 | * This bit is set for symmetric key ciphers that have already been wrapped | ||
57 | * with a generic IV generator to prevent them from being wrapped again. | ||
58 | */ | ||
59 | #define CRYPTO_ALG_GENIV 0x00000200 | ||
60 | |||
61 | /* | ||
53 | * Transform masks and values (for crt_flags). | 62 | * Transform masks and values (for crt_flags). |
54 | */ | 63 | */ |
55 | #define CRYPTO_TFM_REQ_MASK 0x000fff00 | 64 | #define CRYPTO_TFM_REQ_MASK 0x000fff00 |
@@ -81,13 +90,11 @@ | |||
81 | #define CRYPTO_MINALIGN ARCH_KMALLOC_MINALIGN | 90 | #define CRYPTO_MINALIGN ARCH_KMALLOC_MINALIGN |
82 | #elif defined(ARCH_SLAB_MINALIGN) | 91 | #elif defined(ARCH_SLAB_MINALIGN) |
83 | #define CRYPTO_MINALIGN ARCH_SLAB_MINALIGN | 92 | #define CRYPTO_MINALIGN ARCH_SLAB_MINALIGN |
93 | #else | ||
94 | #define CRYPTO_MINALIGN __alignof__(unsigned long long) | ||
84 | #endif | 95 | #endif |
85 | 96 | ||
86 | #ifdef CRYPTO_MINALIGN | ||
87 | #define CRYPTO_MINALIGN_ATTR __attribute__ ((__aligned__(CRYPTO_MINALIGN))) | 97 | #define CRYPTO_MINALIGN_ATTR __attribute__ ((__aligned__(CRYPTO_MINALIGN))) |
88 | #else | ||
89 | #define CRYPTO_MINALIGN_ATTR | ||
90 | #endif | ||
91 | 98 | ||
92 | struct scatterlist; | 99 | struct scatterlist; |
93 | struct crypto_ablkcipher; | 100 | struct crypto_ablkcipher; |
@@ -97,6 +104,8 @@ struct crypto_blkcipher; | |||
97 | struct crypto_hash; | 104 | struct crypto_hash; |
98 | struct crypto_tfm; | 105 | struct crypto_tfm; |
99 | struct crypto_type; | 106 | struct crypto_type; |
107 | struct aead_givcrypt_request; | ||
108 | struct skcipher_givcrypt_request; | ||
100 | 109 | ||
101 | typedef void (*crypto_completion_t)(struct crypto_async_request *req, int err); | 110 | typedef void (*crypto_completion_t)(struct crypto_async_request *req, int err); |
102 | 111 | ||
@@ -176,6 +185,10 @@ struct ablkcipher_alg { | |||
176 | unsigned int keylen); | 185 | unsigned int keylen); |
177 | int (*encrypt)(struct ablkcipher_request *req); | 186 | int (*encrypt)(struct ablkcipher_request *req); |
178 | int (*decrypt)(struct ablkcipher_request *req); | 187 | int (*decrypt)(struct ablkcipher_request *req); |
188 | int (*givencrypt)(struct skcipher_givcrypt_request *req); | ||
189 | int (*givdecrypt)(struct skcipher_givcrypt_request *req); | ||
190 | |||
191 | const char *geniv; | ||
179 | 192 | ||
180 | unsigned int min_keysize; | 193 | unsigned int min_keysize; |
181 | unsigned int max_keysize; | 194 | unsigned int max_keysize; |
@@ -185,11 +198,16 @@ struct ablkcipher_alg { | |||
185 | struct aead_alg { | 198 | struct aead_alg { |
186 | int (*setkey)(struct crypto_aead *tfm, const u8 *key, | 199 | int (*setkey)(struct crypto_aead *tfm, const u8 *key, |
187 | unsigned int keylen); | 200 | unsigned int keylen); |
201 | int (*setauthsize)(struct crypto_aead *tfm, unsigned int authsize); | ||
188 | int (*encrypt)(struct aead_request *req); | 202 | int (*encrypt)(struct aead_request *req); |
189 | int (*decrypt)(struct aead_request *req); | 203 | int (*decrypt)(struct aead_request *req); |
204 | int (*givencrypt)(struct aead_givcrypt_request *req); | ||
205 | int (*givdecrypt)(struct aead_givcrypt_request *req); | ||
206 | |||
207 | const char *geniv; | ||
190 | 208 | ||
191 | unsigned int ivsize; | 209 | unsigned int ivsize; |
192 | unsigned int authsize; | 210 | unsigned int maxauthsize; |
193 | }; | 211 | }; |
194 | 212 | ||
195 | struct blkcipher_alg { | 213 | struct blkcipher_alg { |
@@ -202,6 +220,8 @@ struct blkcipher_alg { | |||
202 | struct scatterlist *dst, struct scatterlist *src, | 220 | struct scatterlist *dst, struct scatterlist *src, |
203 | unsigned int nbytes); | 221 | unsigned int nbytes); |
204 | 222 | ||
223 | const char *geniv; | ||
224 | |||
205 | unsigned int min_keysize; | 225 | unsigned int min_keysize; |
206 | unsigned int max_keysize; | 226 | unsigned int max_keysize; |
207 | unsigned int ivsize; | 227 | unsigned int ivsize; |
@@ -317,6 +337,11 @@ struct ablkcipher_tfm { | |||
317 | unsigned int keylen); | 337 | unsigned int keylen); |
318 | int (*encrypt)(struct ablkcipher_request *req); | 338 | int (*encrypt)(struct ablkcipher_request *req); |
319 | int (*decrypt)(struct ablkcipher_request *req); | 339 | int (*decrypt)(struct ablkcipher_request *req); |
340 | int (*givencrypt)(struct skcipher_givcrypt_request *req); | ||
341 | int (*givdecrypt)(struct skcipher_givcrypt_request *req); | ||
342 | |||
343 | struct crypto_ablkcipher *base; | ||
344 | |||
320 | unsigned int ivsize; | 345 | unsigned int ivsize; |
321 | unsigned int reqsize; | 346 | unsigned int reqsize; |
322 | }; | 347 | }; |
@@ -326,6 +351,11 @@ struct aead_tfm { | |||
326 | unsigned int keylen); | 351 | unsigned int keylen); |
327 | int (*encrypt)(struct aead_request *req); | 352 | int (*encrypt)(struct aead_request *req); |
328 | int (*decrypt)(struct aead_request *req); | 353 | int (*decrypt)(struct aead_request *req); |
354 | int (*givencrypt)(struct aead_givcrypt_request *req); | ||
355 | int (*givdecrypt)(struct aead_givcrypt_request *req); | ||
356 | |||
357 | struct crypto_aead *base; | ||
358 | |||
329 | unsigned int ivsize; | 359 | unsigned int ivsize; |
330 | unsigned int authsize; | 360 | unsigned int authsize; |
331 | unsigned int reqsize; | 361 | unsigned int reqsize; |
@@ -525,17 +555,23 @@ static inline struct crypto_ablkcipher *__crypto_ablkcipher_cast( | |||
525 | return (struct crypto_ablkcipher *)tfm; | 555 | return (struct crypto_ablkcipher *)tfm; |
526 | } | 556 | } |
527 | 557 | ||
528 | static inline struct crypto_ablkcipher *crypto_alloc_ablkcipher( | 558 | static inline u32 crypto_skcipher_type(u32 type) |
529 | const char *alg_name, u32 type, u32 mask) | ||
530 | { | 559 | { |
531 | type &= ~CRYPTO_ALG_TYPE_MASK; | 560 | type &= ~(CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_GENIV); |
532 | type |= CRYPTO_ALG_TYPE_BLKCIPHER; | 561 | type |= CRYPTO_ALG_TYPE_BLKCIPHER; |
533 | mask |= CRYPTO_ALG_TYPE_MASK; | 562 | return type; |
563 | } | ||
534 | 564 | ||
535 | return __crypto_ablkcipher_cast( | 565 | static inline u32 crypto_skcipher_mask(u32 mask) |
536 | crypto_alloc_base(alg_name, type, mask)); | 566 | { |
567 | mask &= ~(CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_GENIV); | ||
568 | mask |= CRYPTO_ALG_TYPE_BLKCIPHER_MASK; | ||
569 | return mask; | ||
537 | } | 570 | } |
538 | 571 | ||
572 | struct crypto_ablkcipher *crypto_alloc_ablkcipher(const char *alg_name, | ||
573 | u32 type, u32 mask); | ||
574 | |||
539 | static inline struct crypto_tfm *crypto_ablkcipher_tfm( | 575 | static inline struct crypto_tfm *crypto_ablkcipher_tfm( |
540 | struct crypto_ablkcipher *tfm) | 576 | struct crypto_ablkcipher *tfm) |
541 | { | 577 | { |
@@ -550,11 +586,8 @@ static inline void crypto_free_ablkcipher(struct crypto_ablkcipher *tfm) | |||
550 | static inline int crypto_has_ablkcipher(const char *alg_name, u32 type, | 586 | static inline int crypto_has_ablkcipher(const char *alg_name, u32 type, |
551 | u32 mask) | 587 | u32 mask) |
552 | { | 588 | { |
553 | type &= ~CRYPTO_ALG_TYPE_MASK; | 589 | return crypto_has_alg(alg_name, crypto_skcipher_type(type), |
554 | type |= CRYPTO_ALG_TYPE_BLKCIPHER; | 590 | crypto_skcipher_mask(mask)); |
555 | mask |= CRYPTO_ALG_TYPE_MASK; | ||
556 | |||
557 | return crypto_has_alg(alg_name, type, mask); | ||
558 | } | 591 | } |
559 | 592 | ||
560 | static inline struct ablkcipher_tfm *crypto_ablkcipher_crt( | 593 | static inline struct ablkcipher_tfm *crypto_ablkcipher_crt( |
@@ -601,7 +634,9 @@ static inline void crypto_ablkcipher_clear_flags(struct crypto_ablkcipher *tfm, | |||
601 | static inline int crypto_ablkcipher_setkey(struct crypto_ablkcipher *tfm, | 634 | static inline int crypto_ablkcipher_setkey(struct crypto_ablkcipher *tfm, |
602 | const u8 *key, unsigned int keylen) | 635 | const u8 *key, unsigned int keylen) |
603 | { | 636 | { |
604 | return crypto_ablkcipher_crt(tfm)->setkey(tfm, key, keylen); | 637 | struct ablkcipher_tfm *crt = crypto_ablkcipher_crt(tfm); |
638 | |||
639 | return crt->setkey(crt->base, key, keylen); | ||
605 | } | 640 | } |
606 | 641 | ||
607 | static inline struct crypto_ablkcipher *crypto_ablkcipher_reqtfm( | 642 | static inline struct crypto_ablkcipher *crypto_ablkcipher_reqtfm( |
@@ -633,7 +668,7 @@ static inline unsigned int crypto_ablkcipher_reqsize( | |||
633 | static inline void ablkcipher_request_set_tfm( | 668 | static inline void ablkcipher_request_set_tfm( |
634 | struct ablkcipher_request *req, struct crypto_ablkcipher *tfm) | 669 | struct ablkcipher_request *req, struct crypto_ablkcipher *tfm) |
635 | { | 670 | { |
636 | req->base.tfm = crypto_ablkcipher_tfm(tfm); | 671 | req->base.tfm = crypto_ablkcipher_tfm(crypto_ablkcipher_crt(tfm)->base); |
637 | } | 672 | } |
638 | 673 | ||
639 | static inline struct ablkcipher_request *ablkcipher_request_cast( | 674 | static inline struct ablkcipher_request *ablkcipher_request_cast( |
@@ -686,15 +721,7 @@ static inline struct crypto_aead *__crypto_aead_cast(struct crypto_tfm *tfm) | |||
686 | return (struct crypto_aead *)tfm; | 721 | return (struct crypto_aead *)tfm; |
687 | } | 722 | } |
688 | 723 | ||
689 | static inline struct crypto_aead *crypto_alloc_aead(const char *alg_name, | 724 | struct crypto_aead *crypto_alloc_aead(const char *alg_name, u32 type, u32 mask); |
690 | u32 type, u32 mask) | ||
691 | { | ||
692 | type &= ~CRYPTO_ALG_TYPE_MASK; | ||
693 | type |= CRYPTO_ALG_TYPE_AEAD; | ||
694 | mask |= CRYPTO_ALG_TYPE_MASK; | ||
695 | |||
696 | return __crypto_aead_cast(crypto_alloc_base(alg_name, type, mask)); | ||
697 | } | ||
698 | 725 | ||
699 | static inline struct crypto_tfm *crypto_aead_tfm(struct crypto_aead *tfm) | 726 | static inline struct crypto_tfm *crypto_aead_tfm(struct crypto_aead *tfm) |
700 | { | 727 | { |
@@ -749,9 +776,13 @@ static inline void crypto_aead_clear_flags(struct crypto_aead *tfm, u32 flags) | |||
749 | static inline int crypto_aead_setkey(struct crypto_aead *tfm, const u8 *key, | 776 | static inline int crypto_aead_setkey(struct crypto_aead *tfm, const u8 *key, |
750 | unsigned int keylen) | 777 | unsigned int keylen) |
751 | { | 778 | { |
752 | return crypto_aead_crt(tfm)->setkey(tfm, key, keylen); | 779 | struct aead_tfm *crt = crypto_aead_crt(tfm); |
780 | |||
781 | return crt->setkey(crt->base, key, keylen); | ||
753 | } | 782 | } |
754 | 783 | ||
784 | int crypto_aead_setauthsize(struct crypto_aead *tfm, unsigned int authsize); | ||
785 | |||
755 | static inline struct crypto_aead *crypto_aead_reqtfm(struct aead_request *req) | 786 | static inline struct crypto_aead *crypto_aead_reqtfm(struct aead_request *req) |
756 | { | 787 | { |
757 | return __crypto_aead_cast(req->base.tfm); | 788 | return __crypto_aead_cast(req->base.tfm); |
@@ -775,7 +806,7 @@ static inline unsigned int crypto_aead_reqsize(struct crypto_aead *tfm) | |||
775 | static inline void aead_request_set_tfm(struct aead_request *req, | 806 | static inline void aead_request_set_tfm(struct aead_request *req, |
776 | struct crypto_aead *tfm) | 807 | struct crypto_aead *tfm) |
777 | { | 808 | { |
778 | req->base.tfm = crypto_aead_tfm(tfm); | 809 | req->base.tfm = crypto_aead_tfm(crypto_aead_crt(tfm)->base); |
779 | } | 810 | } |
780 | 811 | ||
781 | static inline struct aead_request *aead_request_alloc(struct crypto_aead *tfm, | 812 | static inline struct aead_request *aead_request_alloc(struct crypto_aead *tfm, |
@@ -841,9 +872,9 @@ static inline struct crypto_blkcipher *crypto_blkcipher_cast( | |||
841 | static inline struct crypto_blkcipher *crypto_alloc_blkcipher( | 872 | static inline struct crypto_blkcipher *crypto_alloc_blkcipher( |
842 | const char *alg_name, u32 type, u32 mask) | 873 | const char *alg_name, u32 type, u32 mask) |
843 | { | 874 | { |
844 | type &= ~(CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC); | 875 | type &= ~CRYPTO_ALG_TYPE_MASK; |
845 | type |= CRYPTO_ALG_TYPE_BLKCIPHER; | 876 | type |= CRYPTO_ALG_TYPE_BLKCIPHER; |
846 | mask |= CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC; | 877 | mask |= CRYPTO_ALG_TYPE_MASK; |
847 | 878 | ||
848 | return __crypto_blkcipher_cast(crypto_alloc_base(alg_name, type, mask)); | 879 | return __crypto_blkcipher_cast(crypto_alloc_base(alg_name, type, mask)); |
849 | } | 880 | } |
@@ -861,9 +892,9 @@ static inline void crypto_free_blkcipher(struct crypto_blkcipher *tfm) | |||
861 | 892 | ||
862 | static inline int crypto_has_blkcipher(const char *alg_name, u32 type, u32 mask) | 893 | static inline int crypto_has_blkcipher(const char *alg_name, u32 type, u32 mask) |
863 | { | 894 | { |
864 | type &= ~(CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC); | 895 | type &= ~CRYPTO_ALG_TYPE_MASK; |
865 | type |= CRYPTO_ALG_TYPE_BLKCIPHER; | 896 | type |= CRYPTO_ALG_TYPE_BLKCIPHER; |
866 | mask |= CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC; | 897 | mask |= CRYPTO_ALG_TYPE_MASK; |
867 | 898 | ||
868 | return crypto_has_alg(alg_name, type, mask); | 899 | return crypto_has_alg(alg_name, type, mask); |
869 | } | 900 | } |
@@ -1081,6 +1112,7 @@ static inline struct crypto_hash *crypto_alloc_hash(const char *alg_name, | |||
1081 | u32 type, u32 mask) | 1112 | u32 type, u32 mask) |
1082 | { | 1113 | { |
1083 | type &= ~CRYPTO_ALG_TYPE_MASK; | 1114 | type &= ~CRYPTO_ALG_TYPE_MASK; |
1115 | mask &= ~CRYPTO_ALG_TYPE_MASK; | ||
1084 | type |= CRYPTO_ALG_TYPE_HASH; | 1116 | type |= CRYPTO_ALG_TYPE_HASH; |
1085 | mask |= CRYPTO_ALG_TYPE_HASH_MASK; | 1117 | mask |= CRYPTO_ALG_TYPE_HASH_MASK; |
1086 | 1118 | ||
@@ -1100,6 +1132,7 @@ static inline void crypto_free_hash(struct crypto_hash *tfm) | |||
1100 | static inline int crypto_has_hash(const char *alg_name, u32 type, u32 mask) | 1132 | static inline int crypto_has_hash(const char *alg_name, u32 type, u32 mask) |
1101 | { | 1133 | { |
1102 | type &= ~CRYPTO_ALG_TYPE_MASK; | 1134 | type &= ~CRYPTO_ALG_TYPE_MASK; |
1135 | mask &= ~CRYPTO_ALG_TYPE_MASK; | ||
1103 | type |= CRYPTO_ALG_TYPE_HASH; | 1136 | type |= CRYPTO_ALG_TYPE_HASH; |
1104 | mask |= CRYPTO_ALG_TYPE_HASH_MASK; | 1137 | mask |= CRYPTO_ALG_TYPE_HASH_MASK; |
1105 | 1138 | ||
diff --git a/include/linux/hw_random.h b/include/linux/hw_random.h index 21ea7610e17..85d11916e9e 100644 --- a/include/linux/hw_random.h +++ b/include/linux/hw_random.h | |||
@@ -33,7 +33,7 @@ struct hwrng { | |||
33 | const char *name; | 33 | const char *name; |
34 | int (*init)(struct hwrng *rng); | 34 | int (*init)(struct hwrng *rng); |
35 | void (*cleanup)(struct hwrng *rng); | 35 | void (*cleanup)(struct hwrng *rng); |
36 | int (*data_present)(struct hwrng *rng); | 36 | int (*data_present)(struct hwrng *rng, int wait); |
37 | int (*data_read)(struct hwrng *rng, u32 *data); | 37 | int (*data_read)(struct hwrng *rng, u32 *data); |
38 | unsigned long priv; | 38 | unsigned long priv; |
39 | 39 | ||