• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) 2018 Richard Palethorpe <rpalethorpe@suse.com>
4  */
5 
6 #ifndef LAPI_CRYPTOUSER_H__
7 #define LAPI_CRYPTOUSER_H__
8 
9 #ifdef HAVE_LINUX_CRYPTOUSER_H
10 #  include <linux/cryptouser.h>
11 #else
12 #  include <stdint.h>
13 #  define CRYPTO_MAX_NAME 64
14 
15 enum {
16 	CRYPTO_MSG_BASE = 0x10,
17 	CRYPTO_MSG_NEWALG = 0x10,
18 	CRYPTO_MSG_DELALG,
19 	CRYPTO_MSG_UPDATEALG,
20 	CRYPTO_MSG_GETALG,
21 	CRYPTO_MSG_DELRNG,
22 	__CRYPTO_MSG_MAX
23 };
24 
25 enum crypto_attr_type_t {
26 	CRYPTOCFGA_UNSPEC,
27 	CRYPTOCFGA_PRIORITY_VAL,	/* uint32_t */
28 	CRYPTOCFGA_REPORT_LARVAL,	/* struct crypto_report_larval */
29 	CRYPTOCFGA_REPORT_HASH,		/* struct crypto_report_hash */
30 	CRYPTOCFGA_REPORT_BLKCIPHER,	/* struct crypto_report_blkcipher */
31 	CRYPTOCFGA_REPORT_AEAD,		/* struct crypto_report_aead */
32 	CRYPTOCFGA_REPORT_COMPRESS,	/* struct crypto_report_comp */
33 	CRYPTOCFGA_REPORT_RNG,		/* struct crypto_report_rng */
34 	CRYPTOCFGA_REPORT_CIPHER,	/* struct crypto_report_cipher */
35 	CRYPTOCFGA_REPORT_AKCIPHER,	/* struct crypto_report_akcipher */
36 	CRYPTOCFGA_REPORT_KPP,		/* struct crypto_report_kpp */
37 	CRYPTOCFGA_REPORT_ACOMP,	/* struct crypto_report_acomp */
38 	__CRYPTOCFGA_MAX
39 
40 #define CRYPTOCFGA_MAX (__CRYPTOCFGA_MAX - 1)
41 };
42 
43 struct crypto_user_alg {
44 	char cru_name[CRYPTO_MAX_NAME];
45 	char cru_driver_name[CRYPTO_MAX_NAME];
46 	char cru_module_name[CRYPTO_MAX_NAME];
47 	uint32_t cru_type;
48 	uint32_t cru_mask;
49 	uint32_t cru_refcnt;
50 	uint32_t cru_flags;
51 };
52 
53 struct crypto_report_larval {
54 	char type[CRYPTO_MAX_NAME];
55 };
56 
57 struct crypto_report_hash {
58 	char type[CRYPTO_MAX_NAME];
59 	unsigned int blocksize;
60 	unsigned int digestsize;
61 };
62 
63 struct crypto_report_cipher {
64 	char type[CRYPTO_MAX_NAME];
65 	unsigned int blocksize;
66 	unsigned int min_keysize;
67 	unsigned int max_keysize;
68 };
69 
70 struct crypto_report_blkcipher {
71 	char type[CRYPTO_MAX_NAME];
72 	char geniv[CRYPTO_MAX_NAME];
73 	unsigned int blocksize;
74 	unsigned int min_keysize;
75 	unsigned int max_keysize;
76 	unsigned int ivsize;
77 };
78 
79 struct crypto_report_aead {
80 	char type[CRYPTO_MAX_NAME];
81 	char geniv[CRYPTO_MAX_NAME];
82 	unsigned int blocksize;
83 	unsigned int maxauthsize;
84 	unsigned int ivsize;
85 };
86 
87 struct crypto_report_comp {
88 	char type[CRYPTO_MAX_NAME];
89 };
90 
91 struct crypto_report_rng {
92 	char type[CRYPTO_MAX_NAME];
93 	unsigned int seedsize;
94 };
95 
96 struct crypto_report_akcipher {
97 	char type[CRYPTO_MAX_NAME];
98 };
99 
100 struct crypto_report_kpp {
101 	char type[CRYPTO_MAX_NAME];
102 };
103 
104 struct crypto_report_acomp {
105 	char type[CRYPTO_MAX_NAME];
106 };
107 
108 #endif	/* HAVE_LINUX_CRYPTOUSER_H */
109 
110 /* These are taken from include/crypto.h in the kernel tree. They are not
111  * currently included in the user API.
112  */
113 #ifndef CRYPTO_MAX_ALG_NAME
114 #  define CRYPTO_MAX_ALG_NAME		128
115 #endif
116 
117 #ifndef CRYPTO_ALG_TYPE_MASK
118 #  define CRYPTO_ALG_TYPE_MASK		0x0000000f
119 #endif
120 #ifndef CRYPTO_ALG_TYPE_CIPHER
121 #  define CRYPTO_ALG_TYPE_CIPHER	0x00000001
122 #endif
123 #ifndef CRYPTO_ALG_TYPE_COMPRESS
124 #  define CRYPTO_ALG_TYPE_COMPRESS	0x00000002
125 #endif
126 #ifndef CRYPTO_ALG_TYPE_AEAD
127 #  define CRYPTO_ALG_TYPE_AEAD		0x00000003
128 #endif
129 #ifndef CRYPTO_ALG_TYPE_BLKCIPHER
130 #  define CRYPTO_ALG_TYPE_BLKCIPHER	0x00000004
131 #endif
132 #ifndef CRYPTO_ALG_TYPE_ABLKCIPHER
133 #  define CRYPTO_ALG_TYPE_ABLKCIPHER	0x00000005
134 #endif
135 #ifndef CRYPTO_ALG_TYPE_SKCIPHER
136 #  define CRYPTO_ALG_TYPE_SKCIPHER	0x00000005
137 #endif
138 #ifndef CRYPTO_ALG_TYPE_GIVCIPHER
139 #  define CRYPTO_ALG_TYPE_GIVCIPHER	0x00000006
140 #endif
141 #ifndef CRYPTO_ALG_TYPE_KPP
142 #  define CRYPTO_ALG_TYPE_KPP		0x00000008
143 #endif
144 #ifndef CRYPTO_ALG_TYPE_ACOMPRESS
145 #  define CRYPTO_ALG_TYPE_ACOMPRESS	0x0000000a
146 #endif
147 #ifndef CRYPTO_ALG_TYPE_SCOMPRESS
148 #  define CRYPTO_ALG_TYPE_SCOMPRESS	0x0000000b
149 #endif
150 #ifndef CRYPTO_ALG_TYPE_RNG
151 #  define CRYPTO_ALG_TYPE_RNG		0x0000000c
152 #endif
153 #ifndef CRYPTO_ALG_TYPE_AKCIPHER
154 #  define CRYPTO_ALG_TYPE_AKCIPHER	0x0000000d
155 #endif
156 #ifndef CRYPTO_ALG_TYPE_DIGEST
157 #  define CRYPTO_ALG_TYPE_DIGEST	0x0000000e
158 #endif
159 #ifndef CRYPTO_ALG_TYPE_HASH
160 #  define CRYPTO_ALG_TYPE_HASH		0x0000000e
161 #endif
162 #ifndef CRYPTO_ALG_TYPE_SHASH
163 #  define CRYPTO_ALG_TYPE_SHASH		0x0000000e
164 #endif
165 #ifndef CRYPTO_ALG_TYPE_AHASH
166 #  define CRYPTO_ALG_TYPE_AHASH		0x0000000f
167 #endif
168 
169 #ifndef CRYPTO_ALG_TYPE_HASH_MASK
170 #  define CRYPTO_ALG_TYPE_HASH_MASK	0x0000000e
171 #endif
172 #ifndef CRYPTO_ALG_TYPE_AHASH_MASK
173 #  define CRYPTO_ALG_TYPE_AHASH_MASK	0x0000000e
174 #endif
175 #ifndef CRYPTO_ALG_TYPE_BLKCIPHER_MASK
176 #  define CRYPTO_ALG_TYPE_BLKCIPHER_MASK	0x0000000c
177 #endif
178 #ifndef CRYPTO_ALG_TYPE_ACOMPRESS_MASK
179 #  define CRYPTO_ALG_TYPE_ACOMPRESS_MASK	0x0000000e
180 #endif
181 
182 #endif	/* LAPI_CRYPTOUSER_H__ */
183