aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2007-12-08 07:13:15 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2008-01-10 16:16:50 -0500
commit3a282bd2e77966e7361fffbd5d1cea6eb0499b6c (patch)
tree45c86e62c2212757d1553874ec916de39b375a16 /include
parente56dd56418fcc024683d1638564a494d9e9aab85 (diff)
[CRYPTO] aead: Add top-level givencrypt/givdecrypt calls
This patch finally makes the givencrypt/givdecrypt operations available to users by adding crypto_aead_givencrypt and crypto_aead_givdecrypt. A suite of helpers to allocate and fill in the request is also available. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'include')
-rw-r--r--include/crypto/aead.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/include/crypto/aead.h b/include/crypto/aead.h
index 083920312da0..0edf949f6369 100644
--- a/include/crypto/aead.h
+++ b/include/crypto/aead.h
@@ -15,6 +15,7 @@
15 15
16#include <linux/crypto.h> 16#include <linux/crypto.h>
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/slab.h>
18 19
19/** 20/**
20 * struct aead_givcrypt_request - AEAD request with IV generation 21 * struct aead_givcrypt_request - AEAD request with IV generation
@@ -35,4 +36,70 @@ static inline struct crypto_aead *aead_givcrypt_reqtfm(
35 return crypto_aead_reqtfm(&req->areq); 36 return crypto_aead_reqtfm(&req->areq);
36} 37}
37 38
39static 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
45static 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
51static 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
57static 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
71static inline void aead_givcrypt_free(struct aead_givcrypt_request *req)
72{
73 kfree(req);
74}
75
76static 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
83static 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
91static 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
98static 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
38#endif /* _CRYPTO_AEAD_H */ 105#endif /* _CRYPTO_AEAD_H */