blob: 1a598f8294176a11182deb1be2c1b33bc5764429 [file] [log] [blame]
Herbert Xucce9e062006-08-21 21:08:13 +10001/*
2 * Cryptographic API for algorithms (i.e., low-level API).
3 *
4 * Copyright (c) 2006 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#ifndef _CRYPTO_ALGAPI_H
13#define _CRYPTO_ALGAPI_H
14
15#include <linux/crypto.h>
16
Herbert Xu4cc77202006-08-06 21:16:34 +100017struct module;
18
19struct crypto_instance {
20 struct crypto_alg alg;
21
22 struct crypto_template *tmpl;
23 struct hlist_node list;
24
25 void *__ctx[] CRYPTO_MINALIGN_ATTR;
26};
27
28struct crypto_template {
29 struct list_head list;
30 struct hlist_head instances;
31 struct module *module;
32
33 struct crypto_instance *(*alloc)(void *param, unsigned int len);
34 void (*free)(struct crypto_instance *inst);
35
36 char name[CRYPTO_MAX_ALG_NAME];
37};
38
Herbert Xu6bfd4802006-09-21 11:39:29 +100039struct crypto_spawn {
40 struct list_head list;
41 struct crypto_alg *alg;
42 struct crypto_instance *inst;
43};
44
Herbert Xu4cc77202006-08-06 21:16:34 +100045int crypto_register_template(struct crypto_template *tmpl);
46void crypto_unregister_template(struct crypto_template *tmpl);
47struct crypto_template *crypto_lookup_template(const char *name);
48
Herbert Xu6bfd4802006-09-21 11:39:29 +100049int crypto_init_spawn(struct crypto_spawn *spawn, struct crypto_alg *alg,
50 struct crypto_instance *inst);
51void crypto_drop_spawn(struct crypto_spawn *spawn);
52struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn);
53
Herbert Xu7fed0bf2006-08-06 23:10:45 +100054struct crypto_alg *crypto_get_attr_alg(void *param, unsigned int len,
55 u32 type, u32 mask);
56struct crypto_instance *crypto_alloc_instance(const char *name,
57 struct crypto_alg *alg);
58
Herbert Xu4cc77202006-08-06 21:16:34 +100059static inline void *crypto_instance_ctx(struct crypto_instance *inst)
60{
61 return inst->__ctx;
62}
63
Herbert Xucce9e062006-08-21 21:08:13 +100064#endif /* _CRYPTO_ALGAPI_H */
65