diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-10 14:20:42 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-10 14:20:42 -0400 |
commit | f6bccf695431da0e9bd773550ae91b8cb9ffb227 (patch) | |
tree | ff81689bd9bf849b4827da6fbd69fce471842057 /include | |
parent | 3af73d392c9c414ca527bab9c5d4c2a97698acbd (diff) | |
parent | a0f000ec9b61b99111757df138b11144236fc59b (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:
crypto: skcipher - Use RNG interface instead of get_random_bytes
crypto: rng - RNG interface and implementation
crypto: api - Add fips_enable flag
crypto: skcipher - Move IV generators into their own modules
crypto: cryptomgr - Test ciphers using ECB
crypto: api - Use test infrastructure
crypto: cryptomgr - Add test infrastructure
crypto: tcrypt - Add alg_test interface
crypto: tcrypt - Abort and only log if there is an error
crypto: crc32c - Use Intel CRC32 instruction
crypto: tcrypt - Avoid using contiguous pages
crypto: api - Display larval objects properly
crypto: api - Export crypto_alg_lookup instead of __crypto_alg_lookup
crypto: Kconfig - Replace leading spaces with tabs
Diffstat (limited to 'include')
-rw-r--r-- | include/crypto/internal/rng.h | 26 | ||||
-rw-r--r-- | include/crypto/internal/skcipher.h | 6 | ||||
-rw-r--r-- | include/crypto/rng.h | 75 | ||||
-rw-r--r-- | include/linux/crypto.h | 35 |
4 files changed, 136 insertions, 6 deletions
diff --git a/include/crypto/internal/rng.h b/include/crypto/internal/rng.h new file mode 100644 index 000000000000..896973369573 --- /dev/null +++ b/include/crypto/internal/rng.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /* | ||
2 | * RNG: Random Number Generator algorithms under the crypto API | ||
3 | * | ||
4 | * Copyright (c) 2008 Neil Horman <nhorman@tuxdriver.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published by the Free | ||
8 | * Software Foundation; either version 2 of the License, or (at your option) | ||
9 | * any later version. | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | #ifndef _CRYPTO_INTERNAL_RNG_H | ||
14 | #define _CRYPTO_INTERNAL_RNG_H | ||
15 | |||
16 | #include <crypto/algapi.h> | ||
17 | #include <crypto/rng.h> | ||
18 | |||
19 | extern const struct crypto_type crypto_rng_type; | ||
20 | |||
21 | static inline void *crypto_rng_ctx(struct crypto_rng *tfm) | ||
22 | { | ||
23 | return crypto_tfm_ctx(&tfm->base); | ||
24 | } | ||
25 | |||
26 | #endif | ||
diff --git a/include/crypto/internal/skcipher.h b/include/crypto/internal/skcipher.h index ccc32bad9a89..2ba42cd7d6aa 100644 --- a/include/crypto/internal/skcipher.h +++ b/include/crypto/internal/skcipher.h | |||
@@ -15,7 +15,6 @@ | |||
15 | 15 | ||
16 | #include <crypto/algapi.h> | 16 | #include <crypto/algapi.h> |
17 | #include <crypto/skcipher.h> | 17 | #include <crypto/skcipher.h> |
18 | #include <linux/init.h> | ||
19 | #include <linux/types.h> | 18 | #include <linux/types.h> |
20 | 19 | ||
21 | struct rtattr; | 20 | struct rtattr; |
@@ -65,11 +64,6 @@ void skcipher_geniv_free(struct crypto_instance *inst); | |||
65 | int skcipher_geniv_init(struct crypto_tfm *tfm); | 64 | int skcipher_geniv_init(struct crypto_tfm *tfm); |
66 | void skcipher_geniv_exit(struct crypto_tfm *tfm); | 65 | void skcipher_geniv_exit(struct crypto_tfm *tfm); |
67 | 66 | ||
68 | int __init eseqiv_module_init(void); | ||
69 | void __exit eseqiv_module_exit(void); | ||
70 | int __init chainiv_module_init(void); | ||
71 | void chainiv_module_exit(void); | ||
72 | |||
73 | static inline struct crypto_ablkcipher *skcipher_geniv_cipher( | 67 | static inline struct crypto_ablkcipher *skcipher_geniv_cipher( |
74 | struct crypto_ablkcipher *geniv) | 68 | struct crypto_ablkcipher *geniv) |
75 | { | 69 | { |
diff --git a/include/crypto/rng.h b/include/crypto/rng.h new file mode 100644 index 000000000000..c93f9b917925 --- /dev/null +++ b/include/crypto/rng.h | |||
@@ -0,0 +1,75 @@ | |||
1 | /* | ||
2 | * RNG: Random Number Generator algorithms under the crypto API | ||
3 | * | ||
4 | * Copyright (c) 2008 Neil Horman <nhorman@tuxdriver.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published by the Free | ||
8 | * Software Foundation; either version 2 of the License, or (at your option) | ||
9 | * any later version. | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | #ifndef _CRYPTO_RNG_H | ||
14 | #define _CRYPTO_RNG_H | ||
15 | |||
16 | #include <linux/crypto.h> | ||
17 | |||
18 | extern struct crypto_rng *crypto_default_rng; | ||
19 | |||
20 | int crypto_get_default_rng(void); | ||
21 | void crypto_put_default_rng(void); | ||
22 | |||
23 | static inline struct crypto_rng *__crypto_rng_cast(struct crypto_tfm *tfm) | ||
24 | { | ||
25 | return (struct crypto_rng *)tfm; | ||
26 | } | ||
27 | |||
28 | static inline struct crypto_rng *crypto_alloc_rng(const char *alg_name, | ||
29 | u32 type, u32 mask) | ||
30 | { | ||
31 | type &= ~CRYPTO_ALG_TYPE_MASK; | ||
32 | type |= CRYPTO_ALG_TYPE_RNG; | ||
33 | mask |= CRYPTO_ALG_TYPE_MASK; | ||
34 | |||
35 | return __crypto_rng_cast(crypto_alloc_base(alg_name, type, mask)); | ||
36 | } | ||
37 | |||
38 | static inline struct crypto_tfm *crypto_rng_tfm(struct crypto_rng *tfm) | ||
39 | { | ||
40 | return &tfm->base; | ||
41 | } | ||
42 | |||
43 | static inline struct rng_alg *crypto_rng_alg(struct crypto_rng *tfm) | ||
44 | { | ||
45 | return &crypto_rng_tfm(tfm)->__crt_alg->cra_rng; | ||
46 | } | ||
47 | |||
48 | static inline struct rng_tfm *crypto_rng_crt(struct crypto_rng *tfm) | ||
49 | { | ||
50 | return &crypto_rng_tfm(tfm)->crt_rng; | ||
51 | } | ||
52 | |||
53 | static inline void crypto_free_rng(struct crypto_rng *tfm) | ||
54 | { | ||
55 | crypto_free_tfm(crypto_rng_tfm(tfm)); | ||
56 | } | ||
57 | |||
58 | static inline int crypto_rng_get_bytes(struct crypto_rng *tfm, | ||
59 | u8 *rdata, unsigned int dlen) | ||
60 | { | ||
61 | return crypto_rng_crt(tfm)->rng_gen_random(tfm, rdata, dlen); | ||
62 | } | ||
63 | |||
64 | static inline int crypto_rng_reset(struct crypto_rng *tfm, | ||
65 | u8 *seed, unsigned int slen) | ||
66 | { | ||
67 | return crypto_rng_crt(tfm)->rng_reset(tfm, seed, slen); | ||
68 | } | ||
69 | |||
70 | static inline int crypto_rng_seedsize(struct crypto_rng *tfm) | ||
71 | { | ||
72 | return crypto_rng_alg(tfm)->seedsize; | ||
73 | } | ||
74 | |||
75 | #endif | ||
diff --git a/include/linux/crypto.h b/include/linux/crypto.h index c43dc47fdf75..3d2317e4af2e 100644 --- a/include/linux/crypto.h +++ b/include/linux/crypto.h | |||
@@ -38,6 +38,7 @@ | |||
38 | #define CRYPTO_ALG_TYPE_DIGEST 0x00000008 | 38 | #define CRYPTO_ALG_TYPE_DIGEST 0x00000008 |
39 | #define CRYPTO_ALG_TYPE_HASH 0x00000009 | 39 | #define CRYPTO_ALG_TYPE_HASH 0x00000009 |
40 | #define CRYPTO_ALG_TYPE_AHASH 0x0000000a | 40 | #define CRYPTO_ALG_TYPE_AHASH 0x0000000a |
41 | #define CRYPTO_ALG_TYPE_RNG 0x0000000c | ||
41 | 42 | ||
42 | #define CRYPTO_ALG_TYPE_HASH_MASK 0x0000000e | 43 | #define CRYPTO_ALG_TYPE_HASH_MASK 0x0000000e |
43 | #define CRYPTO_ALG_TYPE_AHASH_MASK 0x0000000c | 44 | #define CRYPTO_ALG_TYPE_AHASH_MASK 0x0000000c |
@@ -61,6 +62,14 @@ | |||
61 | #define CRYPTO_ALG_GENIV 0x00000200 | 62 | #define CRYPTO_ALG_GENIV 0x00000200 |
62 | 63 | ||
63 | /* | 64 | /* |
65 | * Set if the algorithm has passed automated run-time testing. Note that | ||
66 | * if there is no run-time testing for a given algorithm it is considered | ||
67 | * to have passed. | ||
68 | */ | ||
69 | |||
70 | #define CRYPTO_ALG_TESTED 0x00000400 | ||
71 | |||
72 | /* | ||
64 | * Transform masks and values (for crt_flags). | 73 | * Transform masks and values (for crt_flags). |
65 | */ | 74 | */ |
66 | #define CRYPTO_TFM_REQ_MASK 0x000fff00 | 75 | #define CRYPTO_TFM_REQ_MASK 0x000fff00 |
@@ -105,6 +114,7 @@ struct crypto_aead; | |||
105 | struct crypto_blkcipher; | 114 | struct crypto_blkcipher; |
106 | struct crypto_hash; | 115 | struct crypto_hash; |
107 | struct crypto_ahash; | 116 | struct crypto_ahash; |
117 | struct crypto_rng; | ||
108 | struct crypto_tfm; | 118 | struct crypto_tfm; |
109 | struct crypto_type; | 119 | struct crypto_type; |
110 | struct aead_givcrypt_request; | 120 | struct aead_givcrypt_request; |
@@ -290,6 +300,15 @@ struct compress_alg { | |||
290 | unsigned int slen, u8 *dst, unsigned int *dlen); | 300 | unsigned int slen, u8 *dst, unsigned int *dlen); |
291 | }; | 301 | }; |
292 | 302 | ||
303 | struct rng_alg { | ||
304 | int (*rng_make_random)(struct crypto_rng *tfm, u8 *rdata, | ||
305 | unsigned int dlen); | ||
306 | int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen); | ||
307 | |||
308 | unsigned int seedsize; | ||
309 | }; | ||
310 | |||
311 | |||
293 | #define cra_ablkcipher cra_u.ablkcipher | 312 | #define cra_ablkcipher cra_u.ablkcipher |
294 | #define cra_aead cra_u.aead | 313 | #define cra_aead cra_u.aead |
295 | #define cra_blkcipher cra_u.blkcipher | 314 | #define cra_blkcipher cra_u.blkcipher |
@@ -298,6 +317,7 @@ struct compress_alg { | |||
298 | #define cra_hash cra_u.hash | 317 | #define cra_hash cra_u.hash |
299 | #define cra_ahash cra_u.ahash | 318 | #define cra_ahash cra_u.ahash |
300 | #define cra_compress cra_u.compress | 319 | #define cra_compress cra_u.compress |
320 | #define cra_rng cra_u.rng | ||
301 | 321 | ||
302 | struct crypto_alg { | 322 | struct crypto_alg { |
303 | struct list_head cra_list; | 323 | struct list_head cra_list; |
@@ -325,6 +345,7 @@ struct crypto_alg { | |||
325 | struct hash_alg hash; | 345 | struct hash_alg hash; |
326 | struct ahash_alg ahash; | 346 | struct ahash_alg ahash; |
327 | struct compress_alg compress; | 347 | struct compress_alg compress; |
348 | struct rng_alg rng; | ||
328 | } cra_u; | 349 | } cra_u; |
329 | 350 | ||
330 | int (*cra_init)(struct crypto_tfm *tfm); | 351 | int (*cra_init)(struct crypto_tfm *tfm); |
@@ -430,6 +451,12 @@ struct compress_tfm { | |||
430 | u8 *dst, unsigned int *dlen); | 451 | u8 *dst, unsigned int *dlen); |
431 | }; | 452 | }; |
432 | 453 | ||
454 | struct rng_tfm { | ||
455 | int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata, | ||
456 | unsigned int dlen); | ||
457 | int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen); | ||
458 | }; | ||
459 | |||
433 | #define crt_ablkcipher crt_u.ablkcipher | 460 | #define crt_ablkcipher crt_u.ablkcipher |
434 | #define crt_aead crt_u.aead | 461 | #define crt_aead crt_u.aead |
435 | #define crt_blkcipher crt_u.blkcipher | 462 | #define crt_blkcipher crt_u.blkcipher |
@@ -437,6 +464,7 @@ struct compress_tfm { | |||
437 | #define crt_hash crt_u.hash | 464 | #define crt_hash crt_u.hash |
438 | #define crt_ahash crt_u.ahash | 465 | #define crt_ahash crt_u.ahash |
439 | #define crt_compress crt_u.compress | 466 | #define crt_compress crt_u.compress |
467 | #define crt_rng crt_u.rng | ||
440 | 468 | ||
441 | struct crypto_tfm { | 469 | struct crypto_tfm { |
442 | 470 | ||
@@ -450,6 +478,7 @@ struct crypto_tfm { | |||
450 | struct hash_tfm hash; | 478 | struct hash_tfm hash; |
451 | struct ahash_tfm ahash; | 479 | struct ahash_tfm ahash; |
452 | struct compress_tfm compress; | 480 | struct compress_tfm compress; |
481 | struct rng_tfm rng; | ||
453 | } crt_u; | 482 | } crt_u; |
454 | 483 | ||
455 | struct crypto_alg *__crt_alg; | 484 | struct crypto_alg *__crt_alg; |
@@ -481,6 +510,10 @@ struct crypto_hash { | |||
481 | struct crypto_tfm base; | 510 | struct crypto_tfm base; |
482 | }; | 511 | }; |
483 | 512 | ||
513 | struct crypto_rng { | ||
514 | struct crypto_tfm base; | ||
515 | }; | ||
516 | |||
484 | enum { | 517 | enum { |
485 | CRYPTOA_UNSPEC, | 518 | CRYPTOA_UNSPEC, |
486 | CRYPTOA_ALG, | 519 | CRYPTOA_ALG, |
@@ -515,6 +548,8 @@ struct crypto_tfm *crypto_alloc_tfm(const char *alg_name, u32 tfm_flags); | |||
515 | struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask); | 548 | struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask); |
516 | void crypto_free_tfm(struct crypto_tfm *tfm); | 549 | void crypto_free_tfm(struct crypto_tfm *tfm); |
517 | 550 | ||
551 | int alg_test(const char *driver, const char *alg, u32 type, u32 mask); | ||
552 | |||
518 | /* | 553 | /* |
519 | * Transform helpers which query the underlying algorithm. | 554 | * Transform helpers which query the underlying algorithm. |
520 | */ | 555 | */ |