aboutsummaryrefslogtreecommitdiffstats
path: root/include/crypto/internal
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2007-12-12 06:23:36 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2008-01-10 16:16:51 -0500
commit5b6d2d7fdf806f2b5a9352416f9e670911fc4748 (patch)
treed2eda87839e1b5de18c691ecff6e6074a35c09f0 /include/crypto/internal
parentaedb30dc49eeecd48558b601c47e0b3f9e42c602 (diff)
[CRYPTO] aead: Add aead_geniv_alloc/aead_geniv_free
This patch creates the infrastructure to help the construction of IV generator templates that wrap around AEAD algorithms by adding an IV generator to them. This is useful for AEAD algorithms with no built-in IV generator or to replace their built-in generator. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'include/crypto/internal')
-rw-r--r--include/crypto/internal/aead.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/include/crypto/internal/aead.h b/include/crypto/internal/aead.h
new file mode 100644
index 000000000000..eb4eee7a7804
--- /dev/null
+++ b/include/crypto/internal/aead.h
@@ -0,0 +1,77 @@
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
20struct rtattr;
21
22struct crypto_aead_spawn {
23 struct crypto_spawn base;
24};
25
26extern const struct crypto_type crypto_nivaead_type;
27
28static inline void crypto_set_aead_spawn(
29 struct crypto_aead_spawn *spawn, struct crypto_instance *inst)
30{
31 crypto_set_spawn(&spawn->base, inst);
32}
33
34static inline void crypto_drop_aead(struct crypto_aead_spawn *spawn)
35{
36 crypto_drop_spawn(&spawn->base);
37}
38
39static inline struct crypto_alg *crypto_aead_spawn_alg(
40 struct crypto_aead_spawn *spawn)
41{
42 return spawn->base.alg;
43}
44
45static inline struct crypto_aead *crypto_spawn_aead(
46 struct crypto_aead_spawn *spawn)
47{
48 return __crypto_aead_cast(
49 crypto_spawn_tfm(&spawn->base, CRYPTO_ALG_TYPE_AEAD,
50 CRYPTO_ALG_TYPE_MASK));
51}
52
53struct crypto_instance *aead_geniv_alloc(struct crypto_template *tmpl,
54 struct rtattr **tb, u32 type,
55 u32 mask);
56void aead_geniv_free(struct crypto_instance *inst);
57int aead_geniv_init(struct crypto_tfm *tfm);
58void aead_geniv_exit(struct crypto_tfm *tfm);
59
60static inline struct crypto_aead *aead_geniv_base(struct crypto_aead *geniv)
61{
62 return crypto_aead_crt(geniv)->base;
63}
64
65static inline void *aead_givcrypt_reqctx(struct aead_givcrypt_request *req)
66{
67 return aead_request_ctx(&req->areq);
68}
69
70static inline void aead_givcrypt_complete(struct aead_givcrypt_request *req,
71 int err)
72{
73 aead_request_complete(&req->areq, err);
74}
75
76#endif /* _CRYPTO_INTERNAL_AEAD_H */
77