blob: 2eba340230a73a63e8a1472a20ff0ed0a451d981 [file] [log] [blame]
Herbert Xu5b6d2d72007-12-12 19:23:36 +08001/*
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
Steffen Klassert1e122992012-03-29 09:03:47 +020034struct crypto_alg *crypto_lookup_aead(const char *name, u32 type, u32 mask);
35
Herbert Xud29ce982007-12-12 19:24:27 +080036int crypto_grab_aead(struct crypto_aead_spawn *spawn, const char *name,
37 u32 type, u32 mask);
38
Herbert Xu5b6d2d72007-12-12 19:23:36 +080039static inline void crypto_drop_aead(struct crypto_aead_spawn *spawn)
40{
41 crypto_drop_spawn(&spawn->base);
42}
43
44static inline struct crypto_alg *crypto_aead_spawn_alg(
45 struct crypto_aead_spawn *spawn)
46{
47 return spawn->base.alg;
48}
49
50static inline struct crypto_aead *crypto_spawn_aead(
51 struct crypto_aead_spawn *spawn)
52{
53 return __crypto_aead_cast(
54 crypto_spawn_tfm(&spawn->base, CRYPTO_ALG_TYPE_AEAD,
55 CRYPTO_ALG_TYPE_MASK));
56}
57
58struct crypto_instance *aead_geniv_alloc(struct crypto_template *tmpl,
59 struct rtattr **tb, u32 type,
60 u32 mask);
61void aead_geniv_free(struct crypto_instance *inst);
62int aead_geniv_init(struct crypto_tfm *tfm);
63void aead_geniv_exit(struct crypto_tfm *tfm);
64
65static inline struct crypto_aead *aead_geniv_base(struct crypto_aead *geniv)
66{
67 return crypto_aead_crt(geniv)->base;
68}
69
70static inline void *aead_givcrypt_reqctx(struct aead_givcrypt_request *req)
71{
72 return aead_request_ctx(&req->areq);
73}
74
75static inline void aead_givcrypt_complete(struct aead_givcrypt_request *req,
76 int err)
77{
78 aead_request_complete(&req->areq, err);
79}
80
81#endif /* _CRYPTO_INTERNAL_AEAD_H */
82