blob: 3a70f025e27d6827a45735a741b4b21761689f38 [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
Nicolas Dichtel9078b4e2017-03-27 14:20:11 +020022#include <linux/types.h>
23
Steffen Klasserta38f7902011-09-27 07:23:50 +020024/* Netlink configuration messages. */
25enum {
26 CRYPTO_MSG_BASE = 0x10,
27 CRYPTO_MSG_NEWALG = 0x10,
28 CRYPTO_MSG_DELALG,
29 CRYPTO_MSG_UPDATEALG,
30 CRYPTO_MSG_GETALG,
Herbert Xu9aa867e2015-06-21 19:11:45 +080031 CRYPTO_MSG_DELRNG,
Corentin Labbecac58182018-09-19 10:10:54 +000032 CRYPTO_MSG_GETSTAT,
Steffen Klasserta38f7902011-09-27 07:23:50 +020033 __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
Herbert Xu44737102017-04-06 16:16:08 +080038#define CRYPTO_MAX_NAME 64
Steffen Klasserta38f7902011-09-27 07:23:50 +020039
40/* Netlink message attributes. */
41enum crypto_attr_type_t {
42 CRYPTOCFGA_UNSPEC,
43 CRYPTOCFGA_PRIORITY_VAL, /* __u32 */
Steffen Klassert6c5a86f52011-09-27 07:25:05 +020044 CRYPTOCFGA_REPORT_LARVAL, /* struct crypto_report_larval */
Steffen Klassertf4d663c2011-09-27 07:26:10 +020045 CRYPTOCFGA_REPORT_HASH, /* struct crypto_report_hash */
Steffen Klassert50496a12011-09-27 07:41:54 +020046 CRYPTOCFGA_REPORT_BLKCIPHER, /* struct crypto_report_blkcipher */
Steffen Klassert6ad414f2011-09-27 07:44:27 +020047 CRYPTOCFGA_REPORT_AEAD, /* struct crypto_report_aead */
Steffen Klasserta55465d2011-09-27 07:46:32 +020048 CRYPTOCFGA_REPORT_COMPRESS, /* struct crypto_report_comp */
Steffen Klassert792608e2011-09-27 07:47:11 +020049 CRYPTOCFGA_REPORT_RNG, /* struct crypto_report_rng */
Steffen Klassert07a5fa42011-09-27 07:48:01 +020050 CRYPTOCFGA_REPORT_CIPHER, /* struct crypto_report_cipher */
Tadeusz Struk3c339ab2015-06-16 10:30:55 -070051 CRYPTOCFGA_REPORT_AKCIPHER, /* struct crypto_report_akcipher */
Salvatore Benedetto4e5f2c42016-06-22 17:49:13 +010052 CRYPTOCFGA_REPORT_KPP, /* struct crypto_report_kpp */
Giovanni Cabiddu2ebda742016-10-21 13:19:47 +010053 CRYPTOCFGA_REPORT_ACOMP, /* struct crypto_report_acomp */
Corentin Labbecac58182018-09-19 10:10:54 +000054 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 */
Steffen Klasserta38f7902011-09-27 07:23:50 +020064 __CRYPTOCFGA_MAX
65
66#define CRYPTOCFGA_MAX (__CRYPTOCFGA_MAX - 1)
67};
68
69struct crypto_user_alg {
Herbert Xu44737102017-04-06 16:16:08 +080070 char cru_name[CRYPTO_MAX_NAME];
71 char cru_driver_name[CRYPTO_MAX_NAME];
72 char cru_module_name[CRYPTO_MAX_NAME];
Steffen Klasserta38f7902011-09-27 07:23:50 +020073 __u32 cru_type;
74 __u32 cru_mask;
75 __u32 cru_refcnt;
76 __u32 cru_flags;
77};
Steffen Klassert6c5a86f52011-09-27 07:25:05 +020078
Corentin Labbe7f0a9d52018-11-29 14:42:19 +000079struct crypto_stat_aead {
Corentin Labbecac58182018-09-19 10:10:54 +000080 char type[CRYPTO_MAX_NAME];
Corentin Labbe7f0a9d52018-11-29 14:42:19 +000081 __u64 stat_encrypt_cnt;
82 __u64 stat_encrypt_tlen;
83 __u64 stat_decrypt_cnt;
84 __u64 stat_decrypt_tlen;
85 __u64 stat_aead_err_cnt;
86};
87
88struct 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;
Corentin Labbe6e8e72c2018-11-29 14:42:18 +000095 __u64 stat_sign_cnt;
Corentin Labbe7f0a9d52018-11-29 14:42:19 +000096 __u64 stat_akcipher_err_cnt;
97};
98
99struct 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_cipher_err_cnt;
106};
107
108struct 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_compress_err_cnt;
115};
116
117struct crypto_stat_hash {
118 char type[CRYPTO_MAX_NAME];
119 __u64 stat_hash_cnt;
120 __u64 stat_hash_tlen;
121 __u64 stat_hash_err_cnt;
122};
123
124struct 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_kpp_err_cnt;
130};
131
132struct 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_rng_err_cnt;
138};
139
140struct crypto_stat_larval {
141 char type[CRYPTO_MAX_NAME];
Corentin Labbecac58182018-09-19 10:10:54 +0000142};
143
Steffen Klassert6c5a86f52011-09-27 07:25:05 +0200144struct crypto_report_larval {
145 char type[CRYPTO_MAX_NAME];
146};
Steffen Klassertf4d663c2011-09-27 07:26:10 +0200147
148struct crypto_report_hash {
149 char type[CRYPTO_MAX_NAME];
150 unsigned int blocksize;
151 unsigned int digestsize;
152};
Steffen Klassert50496a12011-09-27 07:41:54 +0200153
Steffen Klassert07a5fa42011-09-27 07:48:01 +0200154struct crypto_report_cipher {
Herbert Xu44737102017-04-06 16:16:08 +0800155 char type[CRYPTO_MAX_NAME];
Steffen Klassert07a5fa42011-09-27 07:48:01 +0200156 unsigned int blocksize;
157 unsigned int min_keysize;
158 unsigned int max_keysize;
159};
160
Steffen Klassert50496a12011-09-27 07:41:54 +0200161struct 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};
Steffen Klassert6ad414f2011-09-27 07:44:27 +0200169
170struct 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};
Steffen Klasserta55465d2011-09-27 07:46:32 +0200177
178struct crypto_report_comp {
179 char type[CRYPTO_MAX_NAME];
180};
Steffen Klassert792608e2011-09-27 07:47:11 +0200181
182struct crypto_report_rng {
183 char type[CRYPTO_MAX_NAME];
184 unsigned int seedsize;
185};
Steffen Klassert5219a532012-03-29 09:04:46 +0200186
Tadeusz Struk3c339ab2015-06-16 10:30:55 -0700187struct crypto_report_akcipher {
188 char type[CRYPTO_MAX_NAME];
189};
190
Salvatore Benedetto4e5f2c42016-06-22 17:49:13 +0100191struct crypto_report_kpp {
192 char type[CRYPTO_MAX_NAME];
193};
194
Giovanni Cabiddu2ebda742016-10-21 13:19:47 +0100195struct crypto_report_acomp {
196 char type[CRYPTO_MAX_NAME];
197};
198
Steffen Klassert5219a532012-03-29 09:04:46 +0200199#define CRYPTO_REPORT_MAXSIZE (sizeof(struct crypto_user_alg) + \
200 sizeof(struct crypto_report_blkcipher))