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_MAX
33 };
34 #define CRYPTO_MSG_MAX (__CRYPTO_MSG_MAX - 1)
35 #define CRYPTO_NR_MSGTYPES (CRYPTO_MSG_MAX + 1 - CRYPTO_MSG_BASE)
36 
37 #define CRYPTO_MAX_NAME 64
38 
39 /* Netlink message attributes.  */
40 enum crypto_attr_type_t {
41 	CRYPTOCFGA_UNSPEC,
42 	CRYPTOCFGA_PRIORITY_VAL,	/* __u32 */
43 	CRYPTOCFGA_REPORT_LARVAL,	/* struct crypto_report_larval */
44 	CRYPTOCFGA_REPORT_HASH,		/* struct crypto_report_hash */
45 	CRYPTOCFGA_REPORT_BLKCIPHER,	/* struct crypto_report_blkcipher */
46 	CRYPTOCFGA_REPORT_AEAD,		/* struct crypto_report_aead */
47 	CRYPTOCFGA_REPORT_COMPRESS,	/* struct crypto_report_comp */
48 	CRYPTOCFGA_REPORT_RNG,		/* struct crypto_report_rng */
49 	CRYPTOCFGA_REPORT_CIPHER,	/* struct crypto_report_cipher */
50 	CRYPTOCFGA_REPORT_AKCIPHER,	/* struct crypto_report_akcipher */
51 	CRYPTOCFGA_REPORT_KPP,		/* struct crypto_report_kpp */
52 	CRYPTOCFGA_REPORT_ACOMP,	/* struct crypto_report_acomp */
53 	__CRYPTOCFGA_MAX
54 
55 #define CRYPTOCFGA_MAX (__CRYPTOCFGA_MAX - 1)
56 };
57 
58 struct crypto_user_alg {
59 	char cru_name[CRYPTO_MAX_NAME];
60 	char cru_driver_name[CRYPTO_MAX_NAME];
61 	char cru_module_name[CRYPTO_MAX_NAME];
62 	__u32 cru_type;
63 	__u32 cru_mask;
64 	__u32 cru_refcnt;
65 	__u32 cru_flags;
66 };
67 
68 struct crypto_report_larval {
69 	char type[CRYPTO_MAX_NAME];
70 };
71 
72 struct crypto_report_hash {
73 	char type[CRYPTO_MAX_NAME];
74 	unsigned int blocksize;
75 	unsigned int digestsize;
76 };
77 
78 struct crypto_report_cipher {
79 	char type[CRYPTO_MAX_NAME];
80 	unsigned int blocksize;
81 	unsigned int min_keysize;
82 	unsigned int max_keysize;
83 };
84 
85 struct crypto_report_blkcipher {
86 	char type[CRYPTO_MAX_NAME];
87 	char geniv[CRYPTO_MAX_NAME];
88 	unsigned int blocksize;
89 	unsigned int min_keysize;
90 	unsigned int max_keysize;
91 	unsigned int ivsize;
92 };
93 
94 struct crypto_report_aead {
95 	char type[CRYPTO_MAX_NAME];
96 	char geniv[CRYPTO_MAX_NAME];
97 	unsigned int blocksize;
98 	unsigned int maxauthsize;
99 	unsigned int ivsize;
100 };
101 
102 struct crypto_report_comp {
103 	char type[CRYPTO_MAX_NAME];
104 };
105 
106 struct crypto_report_rng {
107 	char type[CRYPTO_MAX_NAME];
108 	unsigned int seedsize;
109 };
110 
111 struct crypto_report_akcipher {
112 	char type[CRYPTO_MAX_NAME];
113 };
114 
115 struct crypto_report_kpp {
116 	char type[CRYPTO_MAX_NAME];
117 };
118 
119 struct crypto_report_acomp {
120 	char type[CRYPTO_MAX_NAME];
121 };
122 
123 #define CRYPTO_REPORT_MAXSIZE (sizeof(struct crypto_user_alg) + \
124 			       sizeof(struct crypto_report_blkcipher))
125