Merge branch 'for-5.0' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie...
[linux-2.6-block.git] / include / uapi / linux / cryptouser.h
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3  * Crypto user configuration API.
4  *
5  * Copyright (C) 2011 secunet Security Networks AG
6  * Copyright (C) 2011 Steffen Klassert <steffen.klassert@secunet.com>
7  *
8  * This program is free software; you can redistribute it and/or modify it
9  * under the terms and conditions of the GNU General Public License,
10  * version 2, as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15  * more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #include <linux/types.h>
23
24 /* Netlink configuration messages.  */
25 enum {
26         CRYPTO_MSG_BASE = 0x10,
27         CRYPTO_MSG_NEWALG = 0x10,
28         CRYPTO_MSG_DELALG,
29         CRYPTO_MSG_UPDATEALG,
30         CRYPTO_MSG_GETALG,
31         CRYPTO_MSG_DELRNG,
32         CRYPTO_MSG_GETSTAT,
33         __CRYPTO_MSG_MAX
34 };
35 #define CRYPTO_MSG_MAX (__CRYPTO_MSG_MAX - 1)
36 #define CRYPTO_NR_MSGTYPES (CRYPTO_MSG_MAX + 1 - CRYPTO_MSG_BASE)
37
38 #define CRYPTO_MAX_NAME 64
39
40 /* Netlink message attributes.  */
41 enum crypto_attr_type_t {
42         CRYPTOCFGA_UNSPEC,
43         CRYPTOCFGA_PRIORITY_VAL,        /* __u32 */
44         CRYPTOCFGA_REPORT_LARVAL,       /* struct crypto_report_larval */
45         CRYPTOCFGA_REPORT_HASH,         /* struct crypto_report_hash */
46         CRYPTOCFGA_REPORT_BLKCIPHER,    /* struct crypto_report_blkcipher */
47         CRYPTOCFGA_REPORT_AEAD,         /* struct crypto_report_aead */
48         CRYPTOCFGA_REPORT_COMPRESS,     /* struct crypto_report_comp */
49         CRYPTOCFGA_REPORT_RNG,          /* struct crypto_report_rng */
50         CRYPTOCFGA_REPORT_CIPHER,       /* struct crypto_report_cipher */
51         CRYPTOCFGA_REPORT_AKCIPHER,     /* struct crypto_report_akcipher */
52         CRYPTOCFGA_REPORT_KPP,          /* struct crypto_report_kpp */
53         CRYPTOCFGA_REPORT_ACOMP,        /* struct crypto_report_acomp */
54         CRYPTOCFGA_STAT_LARVAL,         /* struct crypto_stat */
55         CRYPTOCFGA_STAT_HASH,           /* struct crypto_stat */
56         CRYPTOCFGA_STAT_BLKCIPHER,      /* struct crypto_stat */
57         CRYPTOCFGA_STAT_AEAD,           /* struct crypto_stat */
58         CRYPTOCFGA_STAT_COMPRESS,       /* struct crypto_stat */
59         CRYPTOCFGA_STAT_RNG,            /* struct crypto_stat */
60         CRYPTOCFGA_STAT_CIPHER,         /* struct crypto_stat */
61         CRYPTOCFGA_STAT_AKCIPHER,       /* struct crypto_stat */
62         CRYPTOCFGA_STAT_KPP,            /* struct crypto_stat */
63         CRYPTOCFGA_STAT_ACOMP,          /* struct crypto_stat */
64         __CRYPTOCFGA_MAX
65
66 #define CRYPTOCFGA_MAX (__CRYPTOCFGA_MAX - 1)
67 };
68
69 struct crypto_user_alg {
70         char cru_name[CRYPTO_MAX_NAME];
71         char cru_driver_name[CRYPTO_MAX_NAME];
72         char cru_module_name[CRYPTO_MAX_NAME];
73         __u32 cru_type;
74         __u32 cru_mask;
75         __u32 cru_refcnt;
76         __u32 cru_flags;
77 };
78
79 struct crypto_stat_aead {
80         char type[CRYPTO_MAX_NAME];
81         __u64 stat_encrypt_cnt;
82         __u64 stat_encrypt_tlen;
83         __u64 stat_decrypt_cnt;
84         __u64 stat_decrypt_tlen;
85         __u64 stat_err_cnt;
86 };
87
88 struct crypto_stat_akcipher {
89         char type[CRYPTO_MAX_NAME];
90         __u64 stat_encrypt_cnt;
91         __u64 stat_encrypt_tlen;
92         __u64 stat_decrypt_cnt;
93         __u64 stat_decrypt_tlen;
94         __u64 stat_verify_cnt;
95         __u64 stat_sign_cnt;
96         __u64 stat_err_cnt;
97 };
98
99 struct crypto_stat_cipher {
100         char type[CRYPTO_MAX_NAME];
101         __u64 stat_encrypt_cnt;
102         __u64 stat_encrypt_tlen;
103         __u64 stat_decrypt_cnt;
104         __u64 stat_decrypt_tlen;
105         __u64 stat_err_cnt;
106 };
107
108 struct crypto_stat_compress {
109         char type[CRYPTO_MAX_NAME];
110         __u64 stat_compress_cnt;
111         __u64 stat_compress_tlen;
112         __u64 stat_decompress_cnt;
113         __u64 stat_decompress_tlen;
114         __u64 stat_err_cnt;
115 };
116
117 struct crypto_stat_hash {
118         char type[CRYPTO_MAX_NAME];
119         __u64 stat_hash_cnt;
120         __u64 stat_hash_tlen;
121         __u64 stat_err_cnt;
122 };
123
124 struct crypto_stat_kpp {
125         char type[CRYPTO_MAX_NAME];
126         __u64 stat_setsecret_cnt;
127         __u64 stat_generate_public_key_cnt;
128         __u64 stat_compute_shared_secret_cnt;
129         __u64 stat_err_cnt;
130 };
131
132 struct crypto_stat_rng {
133         char type[CRYPTO_MAX_NAME];
134         __u64 stat_generate_cnt;
135         __u64 stat_generate_tlen;
136         __u64 stat_seed_cnt;
137         __u64 stat_err_cnt;
138 };
139
140 struct crypto_stat_larval {
141         char type[CRYPTO_MAX_NAME];
142 };
143
144 struct crypto_report_larval {
145         char type[CRYPTO_MAX_NAME];
146 };
147
148 struct crypto_report_hash {
149         char type[CRYPTO_MAX_NAME];
150         unsigned int blocksize;
151         unsigned int digestsize;
152 };
153
154 struct crypto_report_cipher {
155         char type[CRYPTO_MAX_NAME];
156         unsigned int blocksize;
157         unsigned int min_keysize;
158         unsigned int max_keysize;
159 };
160
161 struct crypto_report_blkcipher {
162         char type[CRYPTO_MAX_NAME];
163         char geniv[CRYPTO_MAX_NAME];
164         unsigned int blocksize;
165         unsigned int min_keysize;
166         unsigned int max_keysize;
167         unsigned int ivsize;
168 };
169
170 struct crypto_report_aead {
171         char type[CRYPTO_MAX_NAME];
172         char geniv[CRYPTO_MAX_NAME];
173         unsigned int blocksize;
174         unsigned int maxauthsize;
175         unsigned int ivsize;
176 };
177
178 struct crypto_report_comp {
179         char type[CRYPTO_MAX_NAME];
180 };
181
182 struct crypto_report_rng {
183         char type[CRYPTO_MAX_NAME];
184         unsigned int seedsize;
185 };
186
187 struct crypto_report_akcipher {
188         char type[CRYPTO_MAX_NAME];
189 };
190
191 struct crypto_report_kpp {
192         char type[CRYPTO_MAX_NAME];
193 };
194
195 struct crypto_report_acomp {
196         char type[CRYPTO_MAX_NAME];
197 };
198
199 #define CRYPTO_REPORT_MAXSIZE (sizeof(struct crypto_user_alg) + \
200                                sizeof(struct crypto_report_blkcipher))