Commit | Line | Data |
---|---|---|
5b6d2d7f HX |
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_INTERNAL_AEAD_H | |
14 | #define _CRYPTO_INTERNAL_AEAD_H | |
15 | ||
16 | #include <crypto/aead.h> | |
17 | #include <crypto/algapi.h> | |
18 | #include <linux/types.h> | |
19 | ||
20 | struct rtattr; | |
21 | ||
22 | struct crypto_aead_spawn { | |
23 | struct crypto_spawn base; | |
24 | }; | |
25 | ||
5d1d65f8 | 26 | extern const struct crypto_type crypto_aead_type; |
5b6d2d7f HX |
27 | extern const struct crypto_type crypto_nivaead_type; |
28 | ||
2d0f230f HX |
29 | static inline struct old_aead_alg *crypto_old_aead_alg(struct crypto_aead *tfm) |
30 | { | |
31 | return &crypto_aead_tfm(tfm)->__crt_alg->cra_aead; | |
32 | } | |
33 | ||
5d1d65f8 HX |
34 | static inline struct aead_alg *crypto_aead_alg(struct crypto_aead *tfm) |
35 | { | |
36 | return &crypto_aead_tfm(tfm)->__crt_alg->cra_aead; | |
37 | } | |
38 | ||
39 | static inline void *crypto_aead_ctx(struct crypto_aead *tfm) | |
40 | { | |
41 | return crypto_tfm_ctx(&tfm->base); | |
42 | } | |
43 | ||
44 | static inline struct crypto_instance *crypto_aead_alg_instance( | |
45 | struct crypto_aead *aead) | |
46 | { | |
47 | return crypto_tfm_alg_instance(&aead->base); | |
48 | } | |
49 | ||
50 | static inline void *aead_request_ctx(struct aead_request *req) | |
51 | { | |
52 | return req->__ctx; | |
53 | } | |
54 | ||
55 | static inline void aead_request_complete(struct aead_request *req, int err) | |
56 | { | |
57 | req->base.complete(&req->base, err); | |
58 | } | |
59 | ||
60 | static inline u32 aead_request_flags(struct aead_request *req) | |
61 | { | |
62 | return req->base.flags; | |
63 | } | |
64 | ||
5b6d2d7f HX |
65 | static inline void crypto_set_aead_spawn( |
66 | struct crypto_aead_spawn *spawn, struct crypto_instance *inst) | |
67 | { | |
68 | crypto_set_spawn(&spawn->base, inst); | |
69 | } | |
70 | ||
1e122994 SK |
71 | struct crypto_alg *crypto_lookup_aead(const char *name, u32 type, u32 mask); |
72 | ||
d29ce988 HX |
73 | int crypto_grab_aead(struct crypto_aead_spawn *spawn, const char *name, |
74 | u32 type, u32 mask); | |
75 | ||
5b6d2d7f HX |
76 | static inline void crypto_drop_aead(struct crypto_aead_spawn *spawn) |
77 | { | |
78 | crypto_drop_spawn(&spawn->base); | |
79 | } | |
80 | ||
81 | static inline struct crypto_alg *crypto_aead_spawn_alg( | |
82 | struct crypto_aead_spawn *spawn) | |
83 | { | |
84 | return spawn->base.alg; | |
85 | } | |
86 | ||
87 | static inline struct crypto_aead *crypto_spawn_aead( | |
88 | struct crypto_aead_spawn *spawn) | |
89 | { | |
5d1d65f8 | 90 | return crypto_spawn_tfm2(&spawn->base); |
5b6d2d7f HX |
91 | } |
92 | ||
93 | struct crypto_instance *aead_geniv_alloc(struct crypto_template *tmpl, | |
94 | struct rtattr **tb, u32 type, | |
95 | u32 mask); | |
96 | void aead_geniv_free(struct crypto_instance *inst); | |
97 | int aead_geniv_init(struct crypto_tfm *tfm); | |
98 | void aead_geniv_exit(struct crypto_tfm *tfm); | |
99 | ||
100 | static inline struct crypto_aead *aead_geniv_base(struct crypto_aead *geniv) | |
101 | { | |
5d1d65f8 | 102 | return geniv->child; |
5b6d2d7f HX |
103 | } |
104 | ||
105 | static inline void *aead_givcrypt_reqctx(struct aead_givcrypt_request *req) | |
106 | { | |
107 | return aead_request_ctx(&req->areq); | |
108 | } | |
109 | ||
110 | static inline void aead_givcrypt_complete(struct aead_givcrypt_request *req, | |
111 | int err) | |
112 | { | |
113 | aead_request_complete(&req->areq, err); | |
114 | } | |
115 | ||
21b70134 HX |
116 | static inline void crypto_aead_set_reqsize(struct crypto_aead *aead, |
117 | unsigned int reqsize) | |
118 | { | |
119 | crypto_aead_crt(aead)->reqsize = reqsize; | |
120 | } | |
121 | ||
5b6d2d7f HX |
122 | #endif /* _CRYPTO_INTERNAL_AEAD_H */ |
123 |