c9402dd12d0388f5596a2ee5b61bd2c0cef483ad
[safe/jmp/linux-2.6] / include / crypto / internal / skcipher.h
1 /*
2  * Symmetric key ciphers.
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_INTERNAL_SKCIPHER_H
14 #define _CRYPTO_INTERNAL_SKCIPHER_H
15
16 #include <crypto/algapi.h>
17 #include <crypto/skcipher.h>
18
19 struct crypto_skcipher_spawn {
20         struct crypto_spawn base;
21 };
22
23 extern const struct crypto_type crypto_givcipher_type;
24
25 static inline void crypto_set_skcipher_spawn(
26         struct crypto_skcipher_spawn *spawn, struct crypto_instance *inst)
27 {
28         crypto_set_spawn(&spawn->base, inst);
29 }
30
31 int crypto_grab_skcipher(struct crypto_skcipher_spawn *spawn, const char *name,
32                          u32 type, u32 mask);
33
34 static inline void crypto_drop_skcipher(struct crypto_skcipher_spawn *spawn)
35 {
36         crypto_drop_spawn(&spawn->base);
37 }
38
39 static inline struct crypto_alg *crypto_skcipher_spawn_alg(
40         struct crypto_skcipher_spawn *spawn)
41 {
42         return spawn->base.alg;
43 }
44
45 static inline struct crypto_ablkcipher *crypto_spawn_skcipher(
46         struct crypto_skcipher_spawn *spawn)
47 {
48         return __crypto_ablkcipher_cast(
49                 crypto_spawn_tfm(&spawn->base, crypto_skcipher_type(0),
50                                  crypto_skcipher_mask(0)));
51 }
52
53 static inline void *skcipher_givcrypt_reqctx(
54         struct skcipher_givcrypt_request *req)
55 {
56         return ablkcipher_request_ctx(&req->creq);
57 }
58
59 #endif  /* _CRYPTO_INTERNAL_SKCIPHER_H */
60