blob: 5730c67f0617c5f3f8b7b4a0e4c11a2ab00d7dd0 [file] [log] [blame]
Greg Kroah-Hartmane2be04c2017-11-01 15:09:13 +01001/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
Steffen Klasserta38f7902011-09-27 07:23:50 +02002/*
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
Masahiro Yamada68289c62019-07-23 20:43:43 +090022#ifndef _UAPI_LINUX_CRYPTOUSER_H
23#define _UAPI_LINUX_CRYPTOUSER_H
24
Nicolas Dichtel9078b4e2017-03-27 14:20:11 +020025#include <linux/types.h>
26
Steffen Klasserta38f7902011-09-27 07:23:50 +020027/* Netlink configuration messages. */
28enum {
29 CRYPTO_MSG_BASE = 0x10,
30 CRYPTO_MSG_NEWALG = 0x10,
31 CRYPTO_MSG_DELALG,
32 CRYPTO_MSG_UPDATEALG,
33 CRYPTO_MSG_GETALG,
Herbert Xu9aa867e2015-06-21 19:11:45 +080034 CRYPTO_MSG_DELRNG,
Corentin Labbecac58182018-09-19 10:10:54 +000035 CRYPTO_MSG_GETSTAT,
Steffen Klasserta38f7902011-09-27 07:23:50 +020036 __CRYPTO_MSG_MAX
37};
38#define CRYPTO_MSG_MAX (__CRYPTO_MSG_MAX - 1)
39#define CRYPTO_NR_MSGTYPES (CRYPTO_MSG_MAX + 1 - CRYPTO_MSG_BASE)
40
Herbert Xu44737102017-04-06 16:16:08 +080041#define CRYPTO_MAX_NAME 64
Steffen Klasserta38f7902011-09-27 07:23:50 +020042
43/* Netlink message attributes. */
44enum crypto_attr_type_t {
45 CRYPTOCFGA_UNSPEC,
46 CRYPTOCFGA_PRIORITY_VAL, /* __u32 */
Steffen Klassert6c5a86f52011-09-27 07:25:05 +020047 CRYPTOCFGA_REPORT_LARVAL, /* struct crypto_report_larval */
Steffen Klassertf4d663c2011-09-27 07:26:10 +020048 CRYPTOCFGA_REPORT_HASH, /* struct crypto_report_hash */
Steffen Klassert50496a12011-09-27 07:41:54 +020049 CRYPTOCFGA_REPORT_BLKCIPHER, /* struct crypto_report_blkcipher */
Steffen Klassert6ad414f2011-09-27 07:44:27 +020050 CRYPTOCFGA_REPORT_AEAD, /* struct crypto_report_aead */
Steffen Klasserta55465d2011-09-27 07:46:32 +020051 CRYPTOCFGA_REPORT_COMPRESS, /* struct crypto_report_comp */
Steffen Klassert792608e2011-09-27 07:47:11 +020052 CRYPTOCFGA_REPORT_RNG, /* struct crypto_report_rng */
Steffen Klassert07a5fa42011-09-27 07:48:01 +020053 CRYPTOCFGA_REPORT_CIPHER, /* struct crypto_report_cipher */
Tadeusz Struk3c339ab2015-06-16 10:30:55 -070054 CRYPTOCFGA_REPORT_AKCIPHER, /* struct crypto_report_akcipher */
Salvatore Benedetto4e5f2c42016-06-22 17:49:13 +010055 CRYPTOCFGA_REPORT_KPP, /* struct crypto_report_kpp */
Giovanni Cabiddu2ebda742016-10-21 13:19:47 +010056 CRYPTOCFGA_REPORT_ACOMP, /* struct crypto_report_acomp */
Corentin Labbecac58182018-09-19 10:10:54 +000057 CRYPTOCFGA_STAT_LARVAL, /* struct crypto_stat */
58 CRYPTOCFGA_STAT_HASH, /* struct crypto_stat */
59 CRYPTOCFGA_STAT_BLKCIPHER, /* struct crypto_stat */
60 CRYPTOCFGA_STAT_AEAD, /* struct crypto_stat */
61 CRYPTOCFGA_STAT_COMPRESS, /* struct crypto_stat */
62 CRYPTOCFGA_STAT_RNG, /* struct crypto_stat */
63 CRYPTOCFGA_STAT_CIPHER, /* struct crypto_stat */
64 CRYPTOCFGA_STAT_AKCIPHER, /* struct crypto_stat */
65 CRYPTOCFGA_STAT_KPP, /* struct crypto_stat */
66 CRYPTOCFGA_STAT_ACOMP, /* struct crypto_stat */
Steffen Klasserta38f7902011-09-27 07:23:50 +020067 __CRYPTOCFGA_MAX
68
69#define CRYPTOCFGA_MAX (__CRYPTOCFGA_MAX - 1)
70};
71
72struct crypto_user_alg {
Herbert Xu44737102017-04-06 16:16:08 +080073 char cru_name[CRYPTO_MAX_NAME];
74 char cru_driver_name[CRYPTO_MAX_NAME];
75 char cru_module_name[CRYPTO_MAX_NAME];
Steffen Klasserta38f7902011-09-27 07:23:50 +020076 __u32 cru_type;
77 __u32 cru_mask;
78 __u32 cru_refcnt;
79 __u32 cru_flags;
80};
Steffen Klassert6c5a86f52011-09-27 07:25:05 +020081
Corentin Labbe7f0a9d52018-11-29 14:42:19 +000082struct crypto_stat_aead {
Corentin Labbecac58182018-09-19 10:10:54 +000083 char type[CRYPTO_MAX_NAME];
Corentin Labbe7f0a9d52018-11-29 14:42:19 +000084 __u64 stat_encrypt_cnt;
85 __u64 stat_encrypt_tlen;
86 __u64 stat_decrypt_cnt;
87 __u64 stat_decrypt_tlen;
Corentin Labbe44f13132018-11-29 14:42:25 +000088 __u64 stat_err_cnt;
Corentin Labbe7f0a9d52018-11-29 14:42:19 +000089};
90
91struct crypto_stat_akcipher {
92 char type[CRYPTO_MAX_NAME];
93 __u64 stat_encrypt_cnt;
94 __u64 stat_encrypt_tlen;
95 __u64 stat_decrypt_cnt;
96 __u64 stat_decrypt_tlen;
97 __u64 stat_verify_cnt;
Corentin Labbe6e8e72c2018-11-29 14:42:18 +000098 __u64 stat_sign_cnt;
Corentin Labbe44f13132018-11-29 14:42:25 +000099 __u64 stat_err_cnt;
Corentin Labbe7f0a9d52018-11-29 14:42:19 +0000100};
101
102struct crypto_stat_cipher {
103 char type[CRYPTO_MAX_NAME];
104 __u64 stat_encrypt_cnt;
105 __u64 stat_encrypt_tlen;
106 __u64 stat_decrypt_cnt;
107 __u64 stat_decrypt_tlen;
Corentin Labbe44f13132018-11-29 14:42:25 +0000108 __u64 stat_err_cnt;
Corentin Labbe7f0a9d52018-11-29 14:42:19 +0000109};
110
111struct crypto_stat_compress {
112 char type[CRYPTO_MAX_NAME];
113 __u64 stat_compress_cnt;
114 __u64 stat_compress_tlen;
115 __u64 stat_decompress_cnt;
116 __u64 stat_decompress_tlen;
Corentin Labbe44f13132018-11-29 14:42:25 +0000117 __u64 stat_err_cnt;
Corentin Labbe7f0a9d52018-11-29 14:42:19 +0000118};
119
120struct crypto_stat_hash {
121 char type[CRYPTO_MAX_NAME];
122 __u64 stat_hash_cnt;
123 __u64 stat_hash_tlen;
Corentin Labbe44f13132018-11-29 14:42:25 +0000124 __u64 stat_err_cnt;
Corentin Labbe7f0a9d52018-11-29 14:42:19 +0000125};
126
127struct crypto_stat_kpp {
128 char type[CRYPTO_MAX_NAME];
129 __u64 stat_setsecret_cnt;
130 __u64 stat_generate_public_key_cnt;
131 __u64 stat_compute_shared_secret_cnt;
Corentin Labbe44f13132018-11-29 14:42:25 +0000132 __u64 stat_err_cnt;
Corentin Labbe7f0a9d52018-11-29 14:42:19 +0000133};
134
135struct crypto_stat_rng {
136 char type[CRYPTO_MAX_NAME];
137 __u64 stat_generate_cnt;
138 __u64 stat_generate_tlen;
139 __u64 stat_seed_cnt;
Corentin Labbe44f13132018-11-29 14:42:25 +0000140 __u64 stat_err_cnt;
Corentin Labbe7f0a9d52018-11-29 14:42:19 +0000141};
142
143struct crypto_stat_larval {
144 char type[CRYPTO_MAX_NAME];
Corentin Labbecac58182018-09-19 10:10:54 +0000145};
146
Steffen Klassert6c5a86f52011-09-27 07:25:05 +0200147struct crypto_report_larval {
148 char type[CRYPTO_MAX_NAME];
149};
Steffen Klassertf4d663c2011-09-27 07:26:10 +0200150
151struct crypto_report_hash {
152 char type[CRYPTO_MAX_NAME];
153 unsigned int blocksize;
154 unsigned int digestsize;
155};
Steffen Klassert50496a12011-09-27 07:41:54 +0200156
Steffen Klassert07a5fa42011-09-27 07:48:01 +0200157struct crypto_report_cipher {
Herbert Xu44737102017-04-06 16:16:08 +0800158 char type[CRYPTO_MAX_NAME];
Steffen Klassert07a5fa42011-09-27 07:48:01 +0200159 unsigned int blocksize;
160 unsigned int min_keysize;
161 unsigned int max_keysize;
162};
163
Steffen Klassert50496a12011-09-27 07:41:54 +0200164struct crypto_report_blkcipher {
165 char type[CRYPTO_MAX_NAME];
166 char geniv[CRYPTO_MAX_NAME];
167 unsigned int blocksize;
168 unsigned int min_keysize;
169 unsigned int max_keysize;
170 unsigned int ivsize;
171};
Steffen Klassert6ad414f2011-09-27 07:44:27 +0200172
173struct crypto_report_aead {
174 char type[CRYPTO_MAX_NAME];
175 char geniv[CRYPTO_MAX_NAME];
176 unsigned int blocksize;
177 unsigned int maxauthsize;
178 unsigned int ivsize;
179};
Steffen Klasserta55465d2011-09-27 07:46:32 +0200180
181struct crypto_report_comp {
182 char type[CRYPTO_MAX_NAME];
183};
Steffen Klassert792608e2011-09-27 07:47:11 +0200184
185struct crypto_report_rng {
186 char type[CRYPTO_MAX_NAME];
187 unsigned int seedsize;
188};
Steffen Klassert5219a532012-03-29 09:04:46 +0200189
Tadeusz Struk3c339ab2015-06-16 10:30:55 -0700190struct crypto_report_akcipher {
191 char type[CRYPTO_MAX_NAME];
192};
193
Salvatore Benedetto4e5f2c42016-06-22 17:49:13 +0100194struct crypto_report_kpp {
195 char type[CRYPTO_MAX_NAME];
196};
197
Giovanni Cabiddu2ebda742016-10-21 13:19:47 +0100198struct crypto_report_acomp {
199 char type[CRYPTO_MAX_NAME];
200};
201
Steffen Klassert5219a532012-03-29 09:04:46 +0200202#define CRYPTO_REPORT_MAXSIZE (sizeof(struct crypto_user_alg) + \
203 sizeof(struct crypto_report_blkcipher))
Masahiro Yamada68289c62019-07-23 20:43:43 +0900204
205#endif /* _UAPI_LINUX_CRYPTOUSER_H */