]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/crypto/algapi.h
[CRYPTO] scatterwalk: Prepare for block ciphers
[mirror_ubuntu-bionic-kernel.git] / include / crypto / algapi.h
CommitLineData
cce9e06d
HX
1/*
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
4cc7720c 17struct module;
e853c3cf
HX
18struct seq_file;
19
20struct crypto_type {
21 unsigned int (*ctxsize)(struct crypto_alg *alg);
22 int (*init)(struct crypto_tfm *tfm);
23 void (*exit)(struct crypto_tfm *tfm);
24 void (*show)(struct seq_file *m, struct crypto_alg *alg);
25};
4cc7720c
HX
26
27struct crypto_instance {
28 struct crypto_alg alg;
29
30 struct crypto_template *tmpl;
31 struct hlist_node list;
32
33 void *__ctx[] CRYPTO_MINALIGN_ATTR;
34};
35
36struct crypto_template {
37 struct list_head list;
38 struct hlist_head instances;
39 struct module *module;
40
41 struct crypto_instance *(*alloc)(void *param, unsigned int len);
42 void (*free)(struct crypto_instance *inst);
43
44 char name[CRYPTO_MAX_ALG_NAME];
45};
46
6bfd4809
HX
47struct crypto_spawn {
48 struct list_head list;
49 struct crypto_alg *alg;
50 struct crypto_instance *inst;
51};
52
5c64097a
HX
53struct scatter_walk {
54 struct scatterlist *sg;
55 unsigned int offset;
56};
57
4cc7720c
HX
58int crypto_register_template(struct crypto_template *tmpl);
59void crypto_unregister_template(struct crypto_template *tmpl);
60struct crypto_template *crypto_lookup_template(const char *name);
61
6bfd4809
HX
62int crypto_init_spawn(struct crypto_spawn *spawn, struct crypto_alg *alg,
63 struct crypto_instance *inst);
64void crypto_drop_spawn(struct crypto_spawn *spawn);
65struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn);
66
7fed0bf2
HX
67struct crypto_alg *crypto_get_attr_alg(void *param, unsigned int len,
68 u32 type, u32 mask);
69struct crypto_instance *crypto_alloc_instance(const char *name,
70 struct crypto_alg *alg);
71
4cc7720c
HX
72static inline void *crypto_instance_ctx(struct crypto_instance *inst)
73{
74 return inst->__ctx;
75}
76
f28776a3
HX
77static inline struct cipher_alg *crypto_cipher_alg(struct crypto_cipher *tfm)
78{
79 return &crypto_cipher_tfm(tfm)->__crt_alg->cra_cipher;
80}
81
cce9e06d
HX
82#endif /* _CRYPTO_ALGAPI_H */
83