GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / include / crypto / skcipher.h
blob8a499981d416b2515a24d3e8ced2c70c67a9d98c
1 /*
2 * Symmetric key ciphers.
3 *
4 * Copyright (c) 2007 Herbert Xu <herbert@gondor.apana.org.au>
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.
13 #ifndef _CRYPTO_SKCIPHER_H
14 #define _CRYPTO_SKCIPHER_H
16 #include <linux/crypto.h>
17 #include <linux/kernel.h>
18 #include <linux/slab.h>
20 /**
21 * struct skcipher_givcrypt_request - Crypto request with IV generation
22 * @seq: Sequence number for IV generation
23 * @giv: Space for generated IV
24 * @creq: The crypto request itself
26 struct skcipher_givcrypt_request {
27 u64 seq;
28 u8 *giv;
30 struct ablkcipher_request creq;
33 static inline struct crypto_ablkcipher *skcipher_givcrypt_reqtfm(
34 struct skcipher_givcrypt_request *req)
36 return crypto_ablkcipher_reqtfm(&req->creq);
39 static inline int crypto_skcipher_givencrypt(
40 struct skcipher_givcrypt_request *req)
42 struct ablkcipher_tfm *crt =
43 crypto_ablkcipher_crt(skcipher_givcrypt_reqtfm(req));
44 return crt->givencrypt(req);
47 static inline int crypto_skcipher_givdecrypt(
48 struct skcipher_givcrypt_request *req)
50 struct ablkcipher_tfm *crt =
51 crypto_ablkcipher_crt(skcipher_givcrypt_reqtfm(req));
52 return crt->givdecrypt(req);
55 static inline void skcipher_givcrypt_set_tfm(
56 struct skcipher_givcrypt_request *req, struct crypto_ablkcipher *tfm)
58 req->creq.base.tfm = crypto_ablkcipher_tfm(tfm);
61 static inline struct skcipher_givcrypt_request *skcipher_givcrypt_cast(
62 struct crypto_async_request *req)
64 return container_of(ablkcipher_request_cast(req),
65 struct skcipher_givcrypt_request, creq);
68 static inline struct skcipher_givcrypt_request *skcipher_givcrypt_alloc(
69 struct crypto_ablkcipher *tfm, gfp_t gfp)
71 struct skcipher_givcrypt_request *req;
73 req = kmalloc(sizeof(struct skcipher_givcrypt_request) +
74 crypto_ablkcipher_reqsize(tfm), gfp);
76 if (likely(req))
77 skcipher_givcrypt_set_tfm(req, tfm);
79 return req;
82 static inline void skcipher_givcrypt_free(struct skcipher_givcrypt_request *req)
84 kfree(req);
87 static inline void skcipher_givcrypt_set_callback(
88 struct skcipher_givcrypt_request *req, u32 flags,
89 crypto_completion_t complete, void *data)
91 ablkcipher_request_set_callback(&req->creq, flags, complete, data);
94 static 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)
99 ablkcipher_request_set_crypt(&req->creq, src, dst, nbytes, iv);
102 static inline void skcipher_givcrypt_set_giv(
103 struct skcipher_givcrypt_request *req, u8 *giv, u64 seq)
105 req->giv = giv;
106 req->seq = seq;
109 #endif /* _CRYPTO_SKCIPHER_H */