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/crypto/aead.h | |
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/crypto/aead.h')
-rw-r--r-- | include/crypto/aead.h | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/include/crypto/aead.h b/include/crypto/aead.h new file mode 100644 index 000000000000..0edf949f6369 --- /dev/null +++ b/include/crypto/aead.h | |||
@@ -0,0 +1,105 @@ | |||
1 | /* | ||
2 | * AEAD: Authenticated Encryption with Associated Data | ||
3 | * | ||
4 | * Copyright (c) 2007 Herbert Xu <herbert@gondor.apana.org.au> | ||
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_AEAD_H | ||
14 | #define _CRYPTO_AEAD_H | ||
15 | |||
16 | #include <linux/crypto.h> | ||
17 | #include <linux/kernel.h> | ||
18 | #include <linux/slab.h> | ||
19 | |||
20 | /** | ||
21 | * struct aead_givcrypt_request - AEAD request with IV generation | ||
22 | * @seq: Sequence number for IV generation | ||
23 | * @giv: Space for generated IV | ||
24 | * @areq: The AEAD request itself | ||
25 | */ | ||
26 | struct aead_givcrypt_request { | ||
27 | u64 seq; | ||
28 | u8 *giv; | ||
29 | |||
30 | struct aead_request areq; | ||
31 | }; | ||
32 | |||
33 | static inline struct crypto_aead *aead_givcrypt_reqtfm( | ||
34 | struct aead_givcrypt_request *req) | ||
35 | { | ||
36 | return crypto_aead_reqtfm(&req->areq); | ||
37 | } | ||
38 | |||
39 | static inline int crypto_aead_givencrypt(struct aead_givcrypt_request *req) | ||
40 | { | ||
41 | struct aead_tfm *crt = crypto_aead_crt(aead_givcrypt_reqtfm(req)); | ||
42 | return crt->givencrypt(req); | ||
43 | }; | ||
44 | |||
45 | static inline int crypto_aead_givdecrypt(struct aead_givcrypt_request *req) | ||
46 | { | ||
47 | struct aead_tfm *crt = crypto_aead_crt(aead_givcrypt_reqtfm(req)); | ||
48 | return crt->givdecrypt(req); | ||
49 | }; | ||
50 | |||
51 | static inline void aead_givcrypt_set_tfm(struct aead_givcrypt_request *req, | ||
52 | struct crypto_aead *tfm) | ||
53 | { | ||
54 | req->areq.base.tfm = crypto_aead_tfm(tfm); | ||
55 | } | ||
56 | |||
57 | static inline struct aead_givcrypt_request *aead_givcrypt_alloc( | ||
58 | struct crypto_aead *tfm, gfp_t gfp) | ||
59 | { | ||
60 | struct aead_givcrypt_request *req; | ||
61 | |||
62 | req = kmalloc(sizeof(struct aead_givcrypt_request) + | ||
63 | crypto_aead_reqsize(tfm), gfp); | ||
64 | |||
65 | if (likely(req)) | ||
66 | aead_givcrypt_set_tfm(req, tfm); | ||
67 | |||
68 | return req; | ||
69 | } | ||
70 | |||
71 | static inline void aead_givcrypt_free(struct aead_givcrypt_request *req) | ||
72 | { | ||
73 | kfree(req); | ||
74 | } | ||
75 | |||
76 | static inline void aead_givcrypt_set_callback( | ||
77 | struct aead_givcrypt_request *req, u32 flags, | ||
78 | crypto_completion_t complete, void *data) | ||
79 | { | ||
80 | aead_request_set_callback(&req->areq, flags, complete, data); | ||
81 | } | ||
82 | |||
83 | static inline void aead_givcrypt_set_crypt(struct aead_givcrypt_request *req, | ||
84 | struct scatterlist *src, | ||
85 | struct scatterlist *dst, | ||
86 | unsigned int nbytes, void *iv) | ||
87 | { | ||
88 | aead_request_set_crypt(&req->areq, src, dst, nbytes, iv); | ||
89 | } | ||
90 | |||
91 | static inline void aead_givcrypt_set_assoc(struct aead_givcrypt_request *req, | ||
92 | struct scatterlist *assoc, | ||
93 | unsigned int assoclen) | ||
94 | { | ||
95 | aead_request_set_assoc(&req->areq, assoc, assoclen); | ||
96 | } | ||
97 | |||
98 | static inline void aead_givcrypt_set_giv(struct aead_givcrypt_request *req, | ||
99 | u8 *giv, u64 seq) | ||
100 | { | ||
101 | req->giv = giv; | ||
102 | req->seq = seq; | ||
103 | } | ||
104 | |||
105 | #endif /* _CRYPTO_AEAD_H */ | ||