aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2007-12-01 02:35:38 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2008-01-10 16:16:49 -0500
commit03bf712fb4defc7831c727d1e32d0269f7f96de0 (patch)
tree44a7c169b6988cbb86cbe93fc33692691a9f24a9 /include
parent0a270321dbf948963aeb0e8382fe17d2c2eb3771 (diff)
[CRYPTO] skcipher: Add top-level givencrypt/givdecrypt calls
This patch finally makes the givencrypt/givdecrypt operations available to users by adding crypto_skcipher_givencrypt and crypto_skcipher_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/skcipher.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/include/crypto/skcipher.h b/include/crypto/skcipher.h
index c283fab5eddb..25fd6126522d 100644
--- a/include/crypto/skcipher.h
+++ b/include/crypto/skcipher.h
@@ -14,6 +14,8 @@
14#define _CRYPTO_SKCIPHER_H 14#define _CRYPTO_SKCIPHER_H
15 15
16#include <linux/crypto.h> 16#include <linux/crypto.h>
17#include <linux/kernel.h>
18#include <linux/slab.h>
17 19
18/** 20/**
19 * struct skcipher_givcrypt_request - Crypto request with IV generation 21 * struct skcipher_givcrypt_request - Crypto request with IV generation
@@ -34,5 +36,75 @@ static inline struct crypto_ablkcipher *skcipher_givcrypt_reqtfm(
34 return crypto_ablkcipher_reqtfm(&req->creq); 36 return crypto_ablkcipher_reqtfm(&req->creq);
35} 37}
36 38
39static inline int crypto_skcipher_givencrypt(
40 struct skcipher_givcrypt_request *req)
41{
42 struct ablkcipher_tfm *crt =
43 crypto_ablkcipher_crt(skcipher_givcrypt_reqtfm(req));
44 return crt->givencrypt(req);
45};
46
47static inline int crypto_skcipher_givdecrypt(
48 struct skcipher_givcrypt_request *req)
49{
50 struct ablkcipher_tfm *crt =
51 crypto_ablkcipher_crt(skcipher_givcrypt_reqtfm(req));
52 return crt->givdecrypt(req);
53};
54
55static inline void skcipher_givcrypt_set_tfm(
56 struct skcipher_givcrypt_request *req, struct crypto_ablkcipher *tfm)
57{
58 req->creq.base.tfm = crypto_ablkcipher_tfm(tfm);
59}
60
61static inline struct skcipher_givcrypt_request *skcipher_givcrypt_cast(
62 struct crypto_async_request *req)
63{
64 return container_of(ablkcipher_request_cast(req),
65 struct skcipher_givcrypt_request, creq);
66}
67
68static inline struct skcipher_givcrypt_request *skcipher_givcrypt_alloc(
69 struct crypto_ablkcipher *tfm, gfp_t gfp)
70{
71 struct skcipher_givcrypt_request *req;
72
73 req = kmalloc(sizeof(struct skcipher_givcrypt_request) +
74 crypto_ablkcipher_reqsize(tfm), gfp);
75
76 if (likely(req))
77 skcipher_givcrypt_set_tfm(req, tfm);
78
79 return req;
80}
81
82static inline void skcipher_givcrypt_free(struct skcipher_givcrypt_request *req)
83{
84 kfree(req);
85}
86
87static inline void skcipher_givcrypt_set_callback(
88 struct skcipher_givcrypt_request *req, u32 flags,
89 crypto_completion_t complete, void *data)
90{
91 ablkcipher_request_set_callback(&req->creq, flags, complete, data);
92}
93
94static inline void skcipher_givcrypt_set_crypt(
95 struct skcipher_givcrypt_request *req,
96 struct scatterlist *src, struct scatterlist *dst,
97 unsigned int nbytes, void *iv)
98{
99 ablkcipher_request_set_crypt(&req->creq, src, dst, nbytes, iv);
100}
101
102static inline void skcipher_givcrypt_set_giv(
103 struct skcipher_givcrypt_request *req, u8 *giv, u64 seq)
104{
105 req->giv = giv;
106 req->seq = seq;
107}
108
37#endif /* _CRYPTO_SKCIPHER_H */ 109#endif /* _CRYPTO_SKCIPHER_H */
38 110