xref: /illumos-gate/usr/src/uts/common/sys/crypto/ioctl.h (revision 350effc1e940138efb65a89b633f586280437495)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_CRYPTO_IOCTL_H
28 #define	_SYS_CRYPTO_IOCTL_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 #include <sys/types.h>
35 #include <sys/crypto/api.h>
36 #include <sys/crypto/spi.h>
37 #include <sys/crypto/common.h>
38 
39 #define	CRYPTO_MAX_ATTRIBUTE_COUNT	128
40 
41 #define	CRYPTO_IOFLAGS_RW_SESSION	0x00000001
42 
43 #define	CRYPTO(x)		(('y' << 8) | (x))
44 
45 #define	MAX_NUM_THRESHOLD	7
46 
47 /* the PKCS11 Mechanisms */
48 #define	CKM_RC4			0x00000111
49 #define	CKM_DES3_ECB		0x00000132
50 #define	CKM_DES3_CBC		0x00000133
51 #define	CKM_MD5			0x00000210
52 #define	CKM_SHA_1		0x00000220
53 #define	CKM_AES_ECB		0x00001081
54 #define	CKM_AES_CBC		0x00001082
55 
56 /*
57  * General Purpose Ioctls
58  */
59 
60 typedef struct fl_mechs_threshold {
61 	int		mech_type;
62 	uint32_t	mech_threshold;
63 } fl_mechs_threshold_t;
64 
65 typedef struct crypto_function_list {
66 	boolean_t fl_digest_init;
67 	boolean_t fl_digest;
68 	boolean_t fl_digest_update;
69 	boolean_t fl_digest_key;
70 	boolean_t fl_digest_final;
71 
72 	boolean_t fl_encrypt_init;
73 	boolean_t fl_encrypt;
74 	boolean_t fl_encrypt_update;
75 	boolean_t fl_encrypt_final;
76 
77 	boolean_t fl_decrypt_init;
78 	boolean_t fl_decrypt;
79 	boolean_t fl_decrypt_update;
80 	boolean_t fl_decrypt_final;
81 
82 	boolean_t fl_mac_init;
83 	boolean_t fl_mac;
84 	boolean_t fl_mac_update;
85 	boolean_t fl_mac_final;
86 
87 	boolean_t fl_sign_init;
88 	boolean_t fl_sign;
89 	boolean_t fl_sign_update;
90 	boolean_t fl_sign_final;
91 	boolean_t fl_sign_recover_init;
92 	boolean_t fl_sign_recover;
93 
94 	boolean_t fl_verify_init;
95 	boolean_t fl_verify;
96 	boolean_t fl_verify_update;
97 	boolean_t fl_verify_final;
98 	boolean_t fl_verify_recover_init;
99 	boolean_t fl_verify_recover;
100 
101 	boolean_t fl_digest_encrypt_update;
102 	boolean_t fl_decrypt_digest_update;
103 	boolean_t fl_sign_encrypt_update;
104 	boolean_t fl_decrypt_verify_update;
105 
106 	boolean_t fl_seed_random;
107 	boolean_t fl_generate_random;
108 
109 	boolean_t fl_session_open;
110 	boolean_t fl_session_close;
111 	boolean_t fl_session_login;
112 	boolean_t fl_session_logout;
113 
114 	boolean_t fl_object_create;
115 	boolean_t fl_object_copy;
116 	boolean_t fl_object_destroy;
117 	boolean_t fl_object_get_size;
118 	boolean_t fl_object_get_attribute_value;
119 	boolean_t fl_object_set_attribute_value;
120 	boolean_t fl_object_find_init;
121 	boolean_t fl_object_find;
122 	boolean_t fl_object_find_final;
123 
124 	boolean_t fl_key_generate;
125 	boolean_t fl_key_generate_pair;
126 	boolean_t fl_key_wrap;
127 	boolean_t fl_key_unwrap;
128 	boolean_t fl_key_derive;
129 
130 	boolean_t fl_init_token;
131 	boolean_t fl_init_pin;
132 	boolean_t fl_set_pin;
133 
134 	boolean_t prov_is_limited;
135 	uint32_t prov_hash_threshold;
136 	uint32_t prov_hash_limit;
137 
138 	int total_threshold_count;
139 	fl_mechs_threshold_t	fl_threshold[MAX_NUM_THRESHOLD];
140 } crypto_function_list_t;
141 
142 typedef struct crypto_get_function_list {
143 	uint_t			fl_return_value;
144 	crypto_provider_id_t	fl_provider_id;
145 	crypto_function_list_t	fl_list;
146 } crypto_get_function_list_t;
147 
148 typedef struct crypto_get_mechanism_number {
149 	uint_t			pn_return_value;
150 	caddr_t			pn_mechanism_string;
151 	size_t			pn_mechanism_len;
152 	crypto_mech_type_t	pn_internal_number;
153 } crypto_get_mechanism_number_t;
154 
155 #ifdef	_KERNEL
156 #ifdef	_SYSCALL32
157 
158 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
159 #pragma pack(4)
160 #endif
161 
162 typedef struct crypto_get_mechanism_number32 {
163 	uint32_t		pn_return_value;
164 	caddr32_t		pn_mechanism_string;
165 	size32_t		pn_mechanism_len;
166 	crypto_mech_type_t	pn_internal_number;
167 } crypto_get_mechanism_number32_t;
168 
169 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
170 #pragma pack()
171 #endif
172 
173 #endif	/* _SYSCALL32 */
174 #endif	/* _KERNEL */
175 
176 #define	CRYPTO_GET_FUNCTION_LIST	CRYPTO(20)
177 #define	CRYPTO_GET_MECHANISM_NUMBER	CRYPTO(21)
178 
179 /*
180  * Session Ioctls
181  */
182 
183 typedef uint32_t	crypto_flags_t;
184 
185 typedef struct crypto_open_session {
186 	uint_t			os_return_value;
187 	crypto_session_id_t	os_session;
188 	crypto_flags_t		os_flags;
189 	crypto_provider_id_t	os_provider_id;
190 } crypto_open_session_t;
191 
192 typedef struct crypto_close_session {
193 	uint_t			cs_return_value;
194 	crypto_session_id_t	cs_session;
195 } crypto_close_session_t;
196 
197 typedef struct crypto_close_all_sessions {
198 	uint_t			as_return_value;
199 	crypto_provider_id_t	as_provider_id;
200 } crypto_close_all_sessions_t;
201 
202 #define	CRYPTO_OPEN_SESSION		CRYPTO(30)
203 #define	CRYPTO_CLOSE_SESSION		CRYPTO(31)
204 #define	CRYPTO_CLOSE_ALL_SESSIONS	CRYPTO(32)
205 
206 /*
207  * Login Ioctls
208  */
209 typedef struct crypto_login {
210 	uint_t			co_return_value;
211 	crypto_session_id_t	co_session;
212 	uint_t			co_user_type;
213 	uint_t			co_pin_len;
214 	caddr_t			co_pin;
215 } crypto_login_t;
216 
217 typedef struct crypto_logout {
218 	uint_t			cl_return_value;
219 	crypto_session_id_t	cl_session;
220 } crypto_logout_t;
221 
222 #ifdef	_KERNEL
223 #ifdef	_SYSCALL32
224 
225 typedef struct crypto_login32 {
226 	uint32_t		co_return_value;
227 	crypto_session_id_t	co_session;
228 	uint32_t		co_user_type;
229 	uint32_t		co_pin_len;
230 	caddr32_t		co_pin;
231 } crypto_login32_t;
232 
233 typedef struct crypto_logout32 {
234 	uint32_t		cl_return_value;
235 	crypto_session_id_t	cl_session;
236 } crypto_logout32_t;
237 
238 #endif	/* _SYSCALL32 */
239 #endif	/* _KERNEL */
240 
241 #define	CRYPTO_LOGIN			CRYPTO(40)
242 #define	CRYPTO_LOGOUT			CRYPTO(41)
243 
244 /* flag for encrypt and decrypt operations */
245 #define	CRYPTO_INPLACE_OPERATION	0x00000001
246 
247 /*
248  * Cryptographic Ioctls
249  */
250 typedef struct crypto_encrypt {
251 	uint_t			ce_return_value;
252 	crypto_session_id_t	ce_session;
253 	size_t			ce_datalen;
254 	caddr_t			ce_databuf;
255 	size_t			ce_encrlen;
256 	caddr_t			ce_encrbuf;
257 	uint_t			ce_flags;
258 } crypto_encrypt_t;
259 
260 typedef struct crypto_encrypt_init {
261 	uint_t			ei_return_value;
262 	crypto_session_id_t	ei_session;
263 	crypto_mechanism_t	ei_mech;
264 	crypto_key_t		ei_key;
265 } crypto_encrypt_init_t;
266 
267 typedef struct crypto_encrypt_update {
268 	uint_t			eu_return_value;
269 	crypto_session_id_t	eu_session;
270 	size_t			eu_datalen;
271 	caddr_t			eu_databuf;
272 	size_t			eu_encrlen;
273 	caddr_t			eu_encrbuf;
274 	uint_t			eu_flags;
275 } crypto_encrypt_update_t;
276 
277 typedef struct crypto_encrypt_final {
278 	uint_t			ef_return_value;
279 	crypto_session_id_t	ef_session;
280 	size_t			ef_encrlen;
281 	caddr_t			ef_encrbuf;
282 } crypto_encrypt_final_t;
283 
284 typedef struct crypto_decrypt {
285 	uint_t			cd_return_value;
286 	crypto_session_id_t	cd_session;
287 	size_t			cd_encrlen;
288 	caddr_t			cd_encrbuf;
289 	size_t			cd_datalen;
290 	caddr_t			cd_databuf;
291 	uint_t			cd_flags;
292 } crypto_decrypt_t;
293 
294 typedef struct crypto_decrypt_init {
295 	uint_t			di_return_value;
296 	crypto_session_id_t	di_session;
297 	crypto_mechanism_t	di_mech;
298 	crypto_key_t		di_key;
299 } crypto_decrypt_init_t;
300 
301 typedef struct crypto_decrypt_update {
302 	uint_t			du_return_value;
303 	crypto_session_id_t	du_session;
304 	size_t			du_encrlen;
305 	caddr_t			du_encrbuf;
306 	size_t			du_datalen;
307 	caddr_t			du_databuf;
308 	uint_t			du_flags;
309 } crypto_decrypt_update_t;
310 
311 typedef struct crypto_decrypt_final {
312 	uint_t			df_return_value;
313 	crypto_session_id_t	df_session;
314 	size_t			df_datalen;
315 	caddr_t			df_databuf;
316 } crypto_decrypt_final_t;
317 
318 typedef struct crypto_digest {
319 	uint_t			cd_return_value;
320 	crypto_session_id_t	cd_session;
321 	size_t			cd_datalen;
322 	caddr_t			cd_databuf;
323 	size_t			cd_digestlen;
324 	caddr_t			cd_digestbuf;
325 } crypto_digest_t;
326 
327 typedef struct crypto_digest_init {
328 	uint_t			di_return_value;
329 	crypto_session_id_t	di_session;
330 	crypto_mechanism_t	di_mech;
331 } crypto_digest_init_t;
332 
333 typedef struct crypto_digest_update {
334 	uint_t			du_return_value;
335 	crypto_session_id_t	du_session;
336 	size_t			du_datalen;
337 	caddr_t			du_databuf;
338 } crypto_digest_update_t;
339 
340 typedef struct crypto_digest_key {
341 	uint_t			dk_return_value;
342 	crypto_session_id_t	dk_session;
343 	crypto_key_t		dk_key;
344 } crypto_digest_key_t;
345 
346 typedef struct crypto_digest_final {
347 	uint_t			df_return_value;
348 	crypto_session_id_t	df_session;
349 	size_t			df_digestlen;
350 	caddr_t			df_digestbuf;
351 } crypto_digest_final_t;
352 
353 typedef struct crypto_mac {
354 	uint_t			cm_return_value;
355 	crypto_session_id_t	cm_session;
356 	size_t			cm_datalen;
357 	caddr_t			cm_databuf;
358 	size_t			cm_maclen;
359 	caddr_t			cm_macbuf;
360 } crypto_mac_t;
361 
362 typedef struct crypto_mac_init {
363 	uint_t			mi_return_value;
364 	crypto_session_id_t	mi_session;
365 	crypto_mechanism_t	mi_mech;
366 	crypto_key_t		mi_key;
367 } crypto_mac_init_t;
368 
369 typedef struct crypto_mac_update {
370 	uint_t			mu_return_value;
371 	crypto_session_id_t	mu_session;
372 	size_t			mu_datalen;
373 	caddr_t			mu_databuf;
374 } crypto_mac_update_t;
375 
376 typedef struct crypto_mac_final {
377 	uint_t			mf_return_value;
378 	crypto_session_id_t	mf_session;
379 	size_t			mf_maclen;
380 	caddr_t			mf_macbuf;
381 } crypto_mac_final_t;
382 
383 typedef struct crypto_sign {
384 	uint_t			cs_return_value;
385 	crypto_session_id_t	cs_session;
386 	size_t			cs_datalen;
387 	caddr_t			cs_databuf;
388 	size_t			cs_signlen;
389 	caddr_t			cs_signbuf;
390 } crypto_sign_t;
391 
392 typedef struct crypto_sign_init {
393 	uint_t			si_return_value;
394 	crypto_session_id_t	si_session;
395 	crypto_mechanism_t	si_mech;
396 	crypto_key_t		si_key;
397 } crypto_sign_init_t;
398 
399 typedef struct crypto_sign_update {
400 	uint_t			su_return_value;
401 	crypto_session_id_t	su_session;
402 	size_t			su_datalen;
403 	caddr_t			su_databuf;
404 } crypto_sign_update_t;
405 
406 typedef struct crypto_sign_final {
407 	uint_t			sf_return_value;
408 	crypto_session_id_t	sf_session;
409 	size_t			sf_signlen;
410 	caddr_t			sf_signbuf;
411 } crypto_sign_final_t;
412 
413 typedef struct crypto_sign_recover_init {
414 	uint_t			ri_return_value;
415 	crypto_session_id_t	ri_session;
416 	crypto_mechanism_t	ri_mech;
417 	crypto_key_t		ri_key;
418 } crypto_sign_recover_init_t;
419 
420 typedef struct crypto_sign_recover {
421 	uint_t			sr_return_value;
422 	crypto_session_id_t	sr_session;
423 	size_t			sr_datalen;
424 	caddr_t			sr_databuf;
425 	size_t			sr_signlen;
426 	caddr_t			sr_signbuf;
427 } crypto_sign_recover_t;
428 
429 typedef struct crypto_verify {
430 	uint_t			cv_return_value;
431 	crypto_session_id_t	cv_session;
432 	size_t			cv_datalen;
433 	caddr_t			cv_databuf;
434 	size_t			cv_signlen;
435 	caddr_t			cv_signbuf;
436 } crypto_verify_t;
437 
438 typedef struct crypto_verify_init {
439 	uint_t			vi_return_value;
440 	crypto_session_id_t	vi_session;
441 	crypto_mechanism_t	vi_mech;
442 	crypto_key_t		vi_key;
443 } crypto_verify_init_t;
444 
445 typedef struct crypto_verify_update {
446 	uint_t			vu_return_value;
447 	crypto_session_id_t	vu_session;
448 	size_t			vu_datalen;
449 	caddr_t			vu_databuf;
450 } crypto_verify_update_t;
451 
452 typedef struct crypto_verify_final {
453 	uint_t			vf_return_value;
454 	crypto_session_id_t	vf_session;
455 	size_t			vf_signlen;
456 	caddr_t			vf_signbuf;
457 } crypto_verify_final_t;
458 
459 typedef struct crypto_verify_recover_init {
460 	uint_t			ri_return_value;
461 	crypto_session_id_t	ri_session;
462 	crypto_mechanism_t	ri_mech;
463 	crypto_key_t		ri_key;
464 } crypto_verify_recover_init_t;
465 
466 typedef struct crypto_verify_recover {
467 	uint_t			vr_return_value;
468 	crypto_session_id_t	vr_session;
469 	size_t			vr_signlen;
470 	caddr_t			vr_signbuf;
471 	size_t			vr_datalen;
472 	caddr_t			vr_databuf;
473 } crypto_verify_recover_t;
474 
475 typedef struct crypto_digest_encrypt_update {
476 	uint_t			eu_return_value;
477 	crypto_session_id_t	eu_session;
478 	size_t			eu_datalen;
479 	caddr_t			eu_databuf;
480 	size_t			eu_encrlen;
481 	caddr_t			eu_encrbuf;
482 } crypto_digest_encrypt_update_t;
483 
484 typedef struct crypto_decrypt_digest_update {
485 	uint_t			du_return_value;
486 	crypto_session_id_t	du_session;
487 	size_t			du_encrlen;
488 	caddr_t			du_encrbuf;
489 	size_t			du_datalen;
490 	caddr_t			du_databuf;
491 } crypto_decrypt_digest_update_t;
492 
493 typedef struct crypto_sign_encrypt_update {
494 	uint_t			eu_return_value;
495 	crypto_session_id_t	eu_session;
496 	size_t			eu_datalen;
497 	caddr_t			eu_databuf;
498 	size_t			eu_encrlen;
499 	caddr_t			eu_encrbuf;
500 } crypto_sign_encrypt_update_t;
501 
502 typedef struct crypto_decrypt_verify_update {
503 	uint_t			vu_return_value;
504 	crypto_session_id_t	vu_session;
505 	size_t			vu_encrlen;
506 	caddr_t			vu_encrbuf;
507 	size_t			vu_datalen;
508 	caddr_t			vu_databuf;
509 } crypto_decrypt_verify_update_t;
510 
511 #ifdef	_KERNEL
512 #ifdef	_SYSCALL32
513 
514 typedef struct crypto_encrypt32 {
515 	uint32_t		ce_return_value;
516 	crypto_session_id_t	ce_session;
517 	size32_t		ce_datalen;
518 	caddr32_t		ce_databuf;
519 	size32_t		ce_encrlen;
520 	caddr32_t		ce_encrbuf;
521 	uint32_t		ce_flags;
522 } crypto_encrypt32_t;
523 
524 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
525 #pragma pack(4)
526 #endif
527 
528 typedef struct crypto_encrypt_init32 {
529 	uint32_t		ei_return_value;
530 	crypto_session_id_t	ei_session;
531 	crypto_mechanism32_t	ei_mech;
532 	crypto_key32_t		ei_key;
533 } crypto_encrypt_init32_t;
534 
535 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
536 #pragma pack()
537 #endif
538 
539 typedef struct crypto_encrypt_update32 {
540 	uint32_t		eu_return_value;
541 	crypto_session_id_t	eu_session;
542 	size32_t		eu_datalen;
543 	caddr32_t		eu_databuf;
544 	size32_t		eu_encrlen;
545 	caddr32_t		eu_encrbuf;
546 	uint_t			eu_flags;
547 } crypto_encrypt_update32_t;
548 
549 typedef struct crypto_encrypt_final32 {
550 	uint32_t		ef_return_value;
551 	crypto_session_id_t	ef_session;
552 	size32_t		ef_encrlen;
553 	caddr32_t		ef_encrbuf;
554 } crypto_encrypt_final32_t;
555 
556 typedef struct crypto_decrypt32 {
557 	uint32_t		cd_return_value;
558 	crypto_session_id_t	cd_session;
559 	size32_t		cd_encrlen;
560 	caddr32_t		cd_encrbuf;
561 	size32_t		cd_datalen;
562 	caddr32_t		cd_databuf;
563 	uint32_t		cd_flags;
564 } crypto_decrypt32_t;
565 
566 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
567 #pragma pack(4)
568 #endif
569 
570 typedef struct crypto_decrypt_init32 {
571 	uint32_t		di_return_value;
572 	crypto_session_id_t	di_session;
573 	crypto_mechanism32_t	di_mech;
574 	crypto_key32_t		di_key;
575 } crypto_decrypt_init32_t;
576 
577 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
578 #pragma pack()
579 #endif
580 
581 typedef struct crypto_decrypt_update32 {
582 	uint32_t		du_return_value;
583 	crypto_session_id_t	du_session;
584 	size32_t		du_encrlen;
585 	caddr32_t		du_encrbuf;
586 	size32_t		du_datalen;
587 	caddr32_t		du_databuf;
588 	uint_t			du_flags;
589 } crypto_decrypt_update32_t;
590 
591 typedef struct crypto_decrypt_final32 {
592 	uint32_t		df_return_value;
593 	crypto_session_id_t	df_session;
594 	size32_t		df_datalen;
595 	caddr32_t		df_databuf;
596 } crypto_decrypt_final32_t;
597 
598 typedef struct crypto_digest32 {
599 	uint32_t		cd_return_value;
600 	crypto_session_id_t	cd_session;
601 	size32_t		cd_datalen;
602 	caddr32_t		cd_databuf;
603 	size32_t		cd_digestlen;
604 	caddr32_t		cd_digestbuf;
605 } crypto_digest32_t;
606 
607 typedef struct crypto_digest_init32 {
608 	uint32_t		di_return_value;
609 	crypto_session_id_t	di_session;
610 	crypto_mechanism32_t	di_mech;
611 } crypto_digest_init32_t;
612 
613 typedef struct crypto_digest_update32 {
614 	uint32_t		du_return_value;
615 	crypto_session_id_t	du_session;
616 	size32_t		du_datalen;
617 	caddr32_t		du_databuf;
618 } crypto_digest_update32_t;
619 
620 typedef struct crypto_digest_key32 {
621 	uint32_t		dk_return_value;
622 	crypto_session_id_t	dk_session;
623 	crypto_key32_t		dk_key;
624 } crypto_digest_key32_t;
625 
626 typedef struct crypto_digest_final32 {
627 	uint32_t		df_return_value;
628 	crypto_session_id_t	df_session;
629 	size32_t		df_digestlen;
630 	caddr32_t		df_digestbuf;
631 } crypto_digest_final32_t;
632 
633 typedef struct crypto_mac32 {
634 	uint32_t		cm_return_value;
635 	crypto_session_id_t	cm_session;
636 	size32_t		cm_datalen;
637 	caddr32_t		cm_databuf;
638 	size32_t		cm_maclen;
639 	caddr32_t		cm_macbuf;
640 } crypto_mac32_t;
641 
642 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
643 #pragma pack(4)
644 #endif
645 
646 typedef struct crypto_mac_init32 {
647 	uint32_t		mi_return_value;
648 	crypto_session_id_t	mi_session;
649 	crypto_mechanism32_t	mi_mech;
650 	crypto_key32_t		mi_key;
651 } crypto_mac_init32_t;
652 
653 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
654 #pragma pack()
655 #endif
656 
657 typedef struct crypto_mac_update32 {
658 	uint32_t		mu_return_value;
659 	crypto_session_id_t	mu_session;
660 	size32_t		mu_datalen;
661 	caddr32_t		mu_databuf;
662 } crypto_mac_update32_t;
663 
664 typedef struct crypto_mac_final32 {
665 	uint32_t		mf_return_value;
666 	crypto_session_id_t	mf_session;
667 	size32_t		mf_maclen;
668 	caddr32_t		mf_macbuf;
669 } crypto_mac_final32_t;
670 
671 typedef struct crypto_sign32 {
672 	uint32_t		cs_return_value;
673 	crypto_session_id_t	cs_session;
674 	size32_t		cs_datalen;
675 	caddr32_t		cs_databuf;
676 	size32_t		cs_signlen;
677 	caddr32_t		cs_signbuf;
678 } crypto_sign32_t;
679 
680 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
681 #pragma pack(4)
682 #endif
683 
684 typedef struct crypto_sign_init32 {
685 	uint32_t		si_return_value;
686 	crypto_session_id_t	si_session;
687 	crypto_mechanism32_t	si_mech;
688 	crypto_key32_t		si_key;
689 } crypto_sign_init32_t;
690 
691 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
692 #pragma pack()
693 #endif
694 
695 typedef struct crypto_sign_update32 {
696 	uint32_t		su_return_value;
697 	crypto_session_id_t	su_session;
698 	size32_t		su_datalen;
699 	caddr32_t		su_databuf;
700 } crypto_sign_update32_t;
701 
702 typedef struct crypto_sign_final32 {
703 	uint32_t		sf_return_value;
704 	crypto_session_id_t	sf_session;
705 	size32_t		sf_signlen;
706 	caddr32_t		sf_signbuf;
707 } crypto_sign_final32_t;
708 
709 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
710 #pragma pack(4)
711 #endif
712 
713 typedef struct crypto_sign_recover_init32 {
714 	uint32_t		ri_return_value;
715 	crypto_session_id_t	ri_session;
716 	crypto_mechanism32_t	ri_mech;
717 	crypto_key32_t		ri_key;
718 } crypto_sign_recover_init32_t;
719 
720 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
721 #pragma pack()
722 #endif
723 
724 typedef struct crypto_sign_recover32 {
725 	uint32_t		sr_return_value;
726 	crypto_session_id_t	sr_session;
727 	size32_t		sr_datalen;
728 	caddr32_t		sr_databuf;
729 	size32_t		sr_signlen;
730 	caddr32_t		sr_signbuf;
731 } crypto_sign_recover32_t;
732 
733 typedef struct crypto_verify32 {
734 	uint32_t		cv_return_value;
735 	crypto_session_id_t	cv_session;
736 	size32_t		cv_datalen;
737 	caddr32_t		cv_databuf;
738 	size32_t		cv_signlen;
739 	caddr32_t		cv_signbuf;
740 } crypto_verify32_t;
741 
742 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
743 #pragma pack(4)
744 #endif
745 
746 typedef struct crypto_verify_init32 {
747 	uint32_t		vi_return_value;
748 	crypto_session_id_t	vi_session;
749 	crypto_mechanism32_t	vi_mech;
750 	crypto_key32_t		vi_key;
751 } crypto_verify_init32_t;
752 
753 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
754 #pragma pack()
755 #endif
756 
757 typedef struct crypto_verify_update32 {
758 	uint32_t		vu_return_value;
759 	crypto_session_id_t	vu_session;
760 	size32_t		vu_datalen;
761 	caddr32_t		vu_databuf;
762 } crypto_verify_update32_t;
763 
764 typedef struct crypto_verify_final32 {
765 	uint32_t		vf_return_value;
766 	crypto_session_id_t	vf_session;
767 	size32_t		vf_signlen;
768 	caddr32_t		vf_signbuf;
769 } crypto_verify_final32_t;
770 
771 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
772 #pragma pack(4)
773 #endif
774 
775 typedef struct crypto_verify_recover_init32 {
776 	uint32_t		ri_return_value;
777 	crypto_session_id_t	ri_session;
778 	crypto_mechanism32_t	ri_mech;
779 	crypto_key32_t		ri_key;
780 } crypto_verify_recover_init32_t;
781 
782 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
783 #pragma pack()
784 #endif
785 
786 typedef struct crypto_verify_recover32 {
787 	uint32_t		vr_return_value;
788 	crypto_session_id_t	vr_session;
789 	size32_t		vr_signlen;
790 	caddr32_t		vr_signbuf;
791 	size32_t		vr_datalen;
792 	caddr32_t		vr_databuf;
793 } crypto_verify_recover32_t;
794 
795 typedef struct crypto_digest_encrypt_update32 {
796 	uint32_t		eu_return_value;
797 	crypto_session_id_t	eu_session;
798 	size32_t		eu_datalen;
799 	caddr32_t		eu_databuf;
800 	size32_t		eu_encrlen;
801 	caddr32_t		eu_encrbuf;
802 } crypto_digest_encrypt_update32_t;
803 
804 typedef struct crypto_decrypt_digest_update32 {
805 	uint32_t		du_return_value;
806 	crypto_session_id_t	du_session;
807 	size32_t		du_encrlen;
808 	caddr32_t		du_encrbuf;
809 	size32_t		du_datalen;
810 	caddr32_t		du_databuf;
811 } crypto_decrypt_digest_update32_t;
812 
813 typedef struct crypto_sign_encrypt_update32 {
814 	uint32_t		eu_return_value;
815 	crypto_session_id_t	eu_session;
816 	size32_t		eu_datalen;
817 	caddr32_t		eu_databuf;
818 	size32_t		eu_encrlen;
819 	caddr32_t		eu_encrbuf;
820 } crypto_sign_encrypt_update32_t;
821 
822 typedef struct crypto_decrypt_verify_update32 {
823 	uint32_t		vu_return_value;
824 	crypto_session_id_t	vu_session;
825 	size32_t		vu_encrlen;
826 	caddr32_t		vu_encrbuf;
827 	size32_t		vu_datalen;
828 	caddr32_t		vu_databuf;
829 } crypto_decrypt_verify_update32_t;
830 
831 #endif	/* _SYSCALL32 */
832 #endif	/* _KERNEL */
833 
834 #define	CRYPTO_ENCRYPT			CRYPTO(50)
835 #define	CRYPTO_ENCRYPT_INIT		CRYPTO(51)
836 #define	CRYPTO_ENCRYPT_UPDATE		CRYPTO(52)
837 #define	CRYPTO_ENCRYPT_FINAL		CRYPTO(53)
838 #define	CRYPTO_DECRYPT			CRYPTO(54)
839 #define	CRYPTO_DECRYPT_INIT		CRYPTO(55)
840 #define	CRYPTO_DECRYPT_UPDATE		CRYPTO(56)
841 #define	CRYPTO_DECRYPT_FINAL		CRYPTO(57)
842 
843 #define	CRYPTO_DIGEST			CRYPTO(58)
844 #define	CRYPTO_DIGEST_INIT		CRYPTO(59)
845 #define	CRYPTO_DIGEST_UPDATE		CRYPTO(60)
846 #define	CRYPTO_DIGEST_KEY		CRYPTO(61)
847 #define	CRYPTO_DIGEST_FINAL		CRYPTO(62)
848 #define	CRYPTO_MAC			CRYPTO(63)
849 #define	CRYPTO_MAC_INIT			CRYPTO(64)
850 #define	CRYPTO_MAC_UPDATE		CRYPTO(65)
851 #define	CRYPTO_MAC_FINAL		CRYPTO(66)
852 
853 #define	CRYPTO_SIGN			CRYPTO(67)
854 #define	CRYPTO_SIGN_INIT		CRYPTO(68)
855 #define	CRYPTO_SIGN_UPDATE		CRYPTO(69)
856 #define	CRYPTO_SIGN_FINAL		CRYPTO(70)
857 #define	CRYPTO_SIGN_RECOVER_INIT	CRYPTO(71)
858 #define	CRYPTO_SIGN_RECOVER		CRYPTO(72)
859 #define	CRYPTO_VERIFY			CRYPTO(73)
860 #define	CRYPTO_VERIFY_INIT		CRYPTO(74)
861 #define	CRYPTO_VERIFY_UPDATE		CRYPTO(75)
862 #define	CRYPTO_VERIFY_FINAL		CRYPTO(76)
863 #define	CRYPTO_VERIFY_RECOVER_INIT	CRYPTO(77)
864 #define	CRYPTO_VERIFY_RECOVER		CRYPTO(78)
865 
866 #define	CRYPTO_DIGEST_ENCRYPT_UPDATE	CRYPTO(79)
867 #define	CRYPTO_DECRYPT_DIGEST_UPDATE	CRYPTO(80)
868 #define	CRYPTO_SIGN_ENCRYPT_UPDATE	CRYPTO(81)
869 #define	CRYPTO_DECRYPT_VERIFY_UPDATE	CRYPTO(82)
870 
871 /*
872  * Random Number Ioctls
873  */
874 typedef struct crypto_seed_random {
875 	uint_t			sr_return_value;
876 	crypto_session_id_t	sr_session;
877 	size_t			sr_seedlen;
878 	caddr_t			sr_seedbuf;
879 } crypto_seed_random_t;
880 
881 typedef struct crypto_generate_random {
882 	uint_t			gr_return_value;
883 	crypto_session_id_t	gr_session;
884 	caddr_t			gr_buf;
885 	size_t			gr_buflen;
886 } crypto_generate_random_t;
887 
888 #ifdef	_KERNEL
889 #ifdef	_SYSCALL32
890 
891 typedef struct crypto_seed_random32 {
892 	uint32_t		sr_return_value;
893 	crypto_session_id_t	sr_session;
894 	size32_t		sr_seedlen;
895 	caddr32_t		sr_seedbuf;
896 } crypto_seed_random32_t;
897 
898 typedef struct crypto_generate_random32 {
899 	uint32_t		gr_return_value;
900 	crypto_session_id_t	gr_session;
901 	caddr32_t		gr_buf;
902 	size32_t		gr_buflen;
903 } crypto_generate_random32_t;
904 
905 #endif	/* _SYSCALL32 */
906 #endif	/* _KERNEL */
907 
908 #define	CRYPTO_SEED_RANDOM		CRYPTO(90)
909 #define	CRYPTO_GENERATE_RANDOM		CRYPTO(91)
910 
911 /*
912  * Object Management Ioctls
913  */
914 typedef struct crypto_object_create {
915 	uint_t			oc_return_value;
916 	crypto_session_id_t	oc_session;
917 	crypto_object_id_t	oc_handle;
918 	uint_t			oc_count;
919 	caddr_t			oc_attributes;
920 } crypto_object_create_t;
921 
922 typedef struct crypto_object_copy {
923 	uint_t			oc_return_value;
924 	crypto_session_id_t	oc_session;
925 	crypto_object_id_t	oc_handle;
926 	crypto_object_id_t	oc_new_handle;
927 	uint_t			oc_count;
928 	caddr_t			oc_new_attributes;
929 } crypto_object_copy_t;
930 
931 typedef struct crypto_object_destroy {
932 	uint_t			od_return_value;
933 	crypto_session_id_t	od_session;
934 	crypto_object_id_t	od_handle;
935 } crypto_object_destroy_t;
936 
937 typedef struct crypto_object_get_attribute_value {
938 	uint_t			og_return_value;
939 	crypto_session_id_t	og_session;
940 	crypto_object_id_t	og_handle;
941 	uint_t			og_count;
942 	caddr_t			og_attributes;
943 } crypto_object_get_attribute_value_t;
944 
945 typedef struct crypto_object_get_size {
946 	uint_t			gs_return_value;
947 	crypto_session_id_t	gs_session;
948 	crypto_object_id_t	gs_handle;
949 	size_t			gs_size;
950 } crypto_object_get_size_t;
951 
952 typedef struct crypto_object_set_attribute_value {
953 	uint_t			sa_return_value;
954 	crypto_session_id_t	sa_session;
955 	crypto_object_id_t	sa_handle;
956 	uint_t			sa_count;
957 	caddr_t			sa_attributes;
958 } crypto_object_set_attribute_value_t;
959 
960 typedef struct crypto_object_find_init {
961 	uint_t			fi_return_value;
962 	crypto_session_id_t	fi_session;
963 	uint_t			fi_count;
964 	caddr_t			fi_attributes;
965 } crypto_object_find_init_t;
966 
967 typedef struct crypto_object_find_update {
968 	uint_t			fu_return_value;
969 	crypto_session_id_t	fu_session;
970 	uint_t			fu_max_count;
971 	uint_t			fu_count;
972 	caddr_t			fu_handles;
973 } crypto_object_find_update_t;
974 
975 typedef struct crypto_object_find_final {
976 	uint_t			ff_return_value;
977 	crypto_session_id_t	ff_session;
978 } crypto_object_find_final_t;
979 
980 #ifdef	_KERNEL
981 #ifdef	_SYSCALL32
982 
983 typedef struct crypto_object_create32 {
984 	uint32_t		oc_return_value;
985 	crypto_session_id_t	oc_session;
986 	crypto_object_id_t	oc_handle;
987 	uint32_t		oc_count;
988 	caddr32_t		oc_attributes;
989 } crypto_object_create32_t;
990 
991 typedef struct crypto_object_copy32 {
992 	uint32_t		oc_return_value;
993 	crypto_session_id_t	oc_session;
994 	crypto_object_id_t	oc_handle;
995 	crypto_object_id_t	oc_new_handle;
996 	uint32_t		oc_count;
997 	caddr32_t		oc_new_attributes;
998 } crypto_object_copy32_t;
999 
1000 typedef struct crypto_object_destroy32 {
1001 	uint32_t		od_return_value;
1002 	crypto_session_id_t	od_session;
1003 	crypto_object_id_t	od_handle;
1004 } crypto_object_destroy32_t;
1005 
1006 typedef struct crypto_object_get_attribute_value32 {
1007 	uint32_t		og_return_value;
1008 	crypto_session_id_t	og_session;
1009 	crypto_object_id_t	og_handle;
1010 	uint32_t		og_count;
1011 	caddr32_t		og_attributes;
1012 } crypto_object_get_attribute_value32_t;
1013 
1014 typedef struct crypto_object_get_size32 {
1015 	uint32_t		gs_return_value;
1016 	crypto_session_id_t	gs_session;
1017 	crypto_object_id_t	gs_handle;
1018 	size32_t		gs_size;
1019 } crypto_object_get_size32_t;
1020 
1021 typedef struct crypto_object_set_attribute_value32 {
1022 	uint32_t		sa_return_value;
1023 	crypto_session_id_t	sa_session;
1024 	crypto_object_id_t	sa_handle;
1025 	uint32_t		sa_count;
1026 	caddr32_t		sa_attributes;
1027 } crypto_object_set_attribute_value32_t;
1028 
1029 typedef struct crypto_object_find_init32 {
1030 	uint32_t		fi_return_value;
1031 	crypto_session_id_t	fi_session;
1032 	uint32_t		fi_count;
1033 	caddr32_t		fi_attributes;
1034 } crypto_object_find_init32_t;
1035 
1036 typedef struct crypto_object_find_update32 {
1037 	uint32_t		fu_return_value;
1038 	crypto_session_id_t	fu_session;
1039 	uint32_t		fu_max_count;
1040 	uint32_t		fu_count;
1041 	caddr32_t		fu_handles;
1042 } crypto_object_find_update32_t;
1043 
1044 typedef struct crypto_object_find_final32 {
1045 	uint32_t		ff_return_value;
1046 	crypto_session_id_t	ff_session;
1047 } crypto_object_find_final32_t;
1048 
1049 #endif	/* _SYSCALL32 */
1050 #endif	/* _KERNEL */
1051 
1052 #define	CRYPTO_OBJECT_CREATE			CRYPTO(100)
1053 #define	CRYPTO_OBJECT_COPY			CRYPTO(101)
1054 #define	CRYPTO_OBJECT_DESTROY			CRYPTO(102)
1055 #define	CRYPTO_OBJECT_GET_ATTRIBUTE_VALUE	CRYPTO(103)
1056 #define	CRYPTO_OBJECT_GET_SIZE			CRYPTO(104)
1057 #define	CRYPTO_OBJECT_SET_ATTRIBUTE_VALUE	CRYPTO(105)
1058 #define	CRYPTO_OBJECT_FIND_INIT			CRYPTO(106)
1059 #define	CRYPTO_OBJECT_FIND_UPDATE		CRYPTO(107)
1060 #define	CRYPTO_OBJECT_FIND_FINAL		CRYPTO(108)
1061 
1062 /*
1063  * Key Generation Ioctls
1064  */
1065 typedef struct crypto_object_generate_key {
1066 	uint_t			gk_return_value;
1067 	crypto_session_id_t	gk_session;
1068 	crypto_object_id_t	gk_handle;
1069 	crypto_mechanism_t	gk_mechanism;
1070 	uint_t			gk_count;
1071 	caddr_t			gk_attributes;
1072 } crypto_object_generate_key_t;
1073 
1074 typedef struct crypto_object_generate_key_pair {
1075 	uint_t			kp_return_value;
1076 	crypto_session_id_t	kp_session;
1077 	crypto_object_id_t	kp_public_handle;
1078 	crypto_object_id_t	kp_private_handle;
1079 	uint_t			kp_public_count;
1080 	uint_t			kp_private_count;
1081 	caddr_t			kp_public_attributes;
1082 	caddr_t			kp_private_attributes;
1083 	crypto_mechanism_t	kp_mechanism;
1084 } crypto_object_generate_key_pair_t;
1085 
1086 typedef struct crypto_object_wrap_key {
1087 	uint_t			wk_return_value;
1088 	crypto_session_id_t	wk_session;
1089 	crypto_mechanism_t	wk_mechanism;
1090 	crypto_key_t		wk_wrapping_key;
1091 	crypto_object_id_t	wk_object_handle;
1092 	size_t			wk_wrapped_key_len;
1093 	caddr_t			wk_wrapped_key;
1094 } crypto_object_wrap_key_t;
1095 
1096 typedef struct crypto_object_unwrap_key {
1097 	uint_t			uk_return_value;
1098 	crypto_session_id_t	uk_session;
1099 	crypto_mechanism_t	uk_mechanism;
1100 	crypto_key_t		uk_unwrapping_key;
1101 	crypto_object_id_t	uk_object_handle;
1102 	size_t			uk_wrapped_key_len;
1103 	caddr_t			uk_wrapped_key;
1104 	uint_t			uk_count;
1105 	caddr_t			uk_attributes;
1106 } crypto_object_unwrap_key_t;
1107 
1108 typedef struct crypto_derive_key {
1109 	uint_t			dk_return_value;
1110 	crypto_session_id_t	dk_session;
1111 	crypto_mechanism_t	dk_mechanism;
1112 	crypto_key_t		dk_base_key;
1113 	crypto_object_id_t	dk_object_handle;
1114 	uint_t			dk_count;
1115 	caddr_t			dk_attributes;
1116 } crypto_derive_key_t;
1117 
1118 #ifdef	_KERNEL
1119 #ifdef	_SYSCALL32
1120 
1121 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
1122 #pragma pack(4)
1123 #endif
1124 
1125 typedef struct crypto_object_generate_key32 {
1126 	uint32_t		gk_return_value;
1127 	crypto_session_id_t	gk_session;
1128 	crypto_object_id_t	gk_handle;
1129 	crypto_mechanism32_t	gk_mechanism;
1130 	uint32_t		gk_count;
1131 	caddr32_t		gk_attributes;
1132 } crypto_object_generate_key32_t;
1133 
1134 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
1135 #pragma pack()
1136 #endif
1137 
1138 typedef struct crypto_object_generate_key_pair32 {
1139 	uint32_t		kp_return_value;
1140 	crypto_session_id_t	kp_session;
1141 	crypto_object_id_t	kp_public_handle;
1142 	crypto_object_id_t	kp_private_handle;
1143 	uint32_t		kp_public_count;
1144 	uint32_t		kp_private_count;
1145 	caddr32_t		kp_public_attributes;
1146 	caddr32_t		kp_private_attributes;
1147 	crypto_mechanism32_t	kp_mechanism;
1148 } crypto_object_generate_key_pair32_t;
1149 
1150 typedef struct crypto_object_wrap_key32 {
1151 	uint32_t		wk_return_value;
1152 	crypto_session_id_t	wk_session;
1153 	crypto_mechanism32_t	wk_mechanism;
1154 	crypto_key32_t		wk_wrapping_key;
1155 	crypto_object_id_t	wk_object_handle;
1156 	size32_t		wk_wrapped_key_len;
1157 	caddr32_t		wk_wrapped_key;
1158 } crypto_object_wrap_key32_t;
1159 
1160 typedef struct crypto_object_unwrap_key32 {
1161 	uint32_t		uk_return_value;
1162 	crypto_session_id_t	uk_session;
1163 	crypto_mechanism32_t	uk_mechanism;
1164 	crypto_key32_t		uk_unwrapping_key;
1165 	crypto_object_id_t	uk_object_handle;
1166 	size32_t		uk_wrapped_key_len;
1167 	caddr32_t		uk_wrapped_key;
1168 	uint32_t		uk_count;
1169 	caddr32_t		uk_attributes;
1170 } crypto_object_unwrap_key32_t;
1171 
1172 typedef struct crypto_derive_key32 {
1173 	uint32_t		dk_return_value;
1174 	crypto_session_id_t	dk_session;
1175 	crypto_mechanism32_t	dk_mechanism;
1176 	crypto_key32_t		dk_base_key;
1177 	crypto_object_id_t	dk_object_handle;
1178 	uint32_t		dk_count;
1179 	caddr32_t		dk_attributes;
1180 } crypto_derive_key32_t;
1181 
1182 #endif	/* _SYSCALL32 */
1183 #endif	/* _KERNEL */
1184 
1185 #define	CRYPTO_GENERATE_KEY		CRYPTO(110)
1186 #define	CRYPTO_GENERATE_KEY_PAIR	CRYPTO(111)
1187 #define	CRYPTO_WRAP_KEY			CRYPTO(112)
1188 #define	CRYPTO_UNWRAP_KEY		CRYPTO(113)
1189 #define	CRYPTO_DERIVE_KEY		CRYPTO(114)
1190 
1191 /*
1192  * Provider Management Ioctls
1193  */
1194 
1195 typedef struct crypto_get_provider_list {
1196 	uint_t			pl_return_value;
1197 	uint_t			pl_count;
1198 	crypto_provider_entry_t	pl_list[1];
1199 } crypto_get_provider_list_t;
1200 
1201 typedef struct crypto_provider_data {
1202 	uchar_t			pd_prov_desc[CRYPTO_PROVIDER_DESCR_MAX_LEN];
1203 	uchar_t			pd_label[CRYPTO_EXT_SIZE_LABEL];
1204 	uchar_t			pd_manufacturerID[CRYPTO_EXT_SIZE_MANUF];
1205 	uchar_t			pd_model[CRYPTO_EXT_SIZE_MODEL];
1206 	uchar_t			pd_serial_number[CRYPTO_EXT_SIZE_SERIAL];
1207 	ulong_t			pd_flags;
1208 	ulong_t			pd_max_session_count;
1209 	ulong_t			pd_session_count;
1210 	ulong_t			pd_max_rw_session_count;
1211 	ulong_t			pd_rw_session_count;
1212 	ulong_t			pd_max_pin_len;
1213 	ulong_t			pd_min_pin_len;
1214 	ulong_t			pd_total_public_memory;
1215 	ulong_t			pd_free_public_memory;
1216 	ulong_t			pd_total_private_memory;
1217 	ulong_t			pd_free_private_memory;
1218 	crypto_version_t	pd_hardware_version;
1219 	crypto_version_t	pd_firmware_version;
1220 	uchar_t			pd_time[CRYPTO_EXT_SIZE_TIME];
1221 } crypto_provider_data_t;
1222 
1223 typedef struct crypto_get_provider_info {
1224 	uint_t			gi_return_value;
1225 	crypto_provider_id_t	gi_provider_id;
1226 	crypto_provider_data_t	gi_provider_data;
1227 } crypto_get_provider_info_t;
1228 
1229 typedef struct crypto_get_provider_mechanisms {
1230 	uint_t			pm_return_value;
1231 	crypto_provider_id_t	pm_provider_id;
1232 	uint_t			pm_count;
1233 	crypto_mech_name_t	pm_list[1];
1234 } crypto_get_provider_mechanisms_t;
1235 
1236 typedef struct crypto_get_provider_mechanism_info {
1237 	uint_t			mi_return_value;
1238 	crypto_provider_id_t	mi_provider_id;
1239 	crypto_mech_name_t	mi_mechanism_name;
1240 	uint32_t		mi_min_key_size;
1241 	uint32_t		mi_max_key_size;
1242 	uint32_t		mi_flags;
1243 } crypto_get_provider_mechanism_info_t;
1244 
1245 typedef struct crypto_init_token {
1246 	uint_t			it_return_value;
1247 	crypto_provider_id_t	it_provider_id;
1248 	caddr_t			it_pin;
1249 	size_t			it_pin_len;
1250 	caddr_t			it_label;
1251 } crypto_init_token_t;
1252 
1253 typedef struct crypto_init_pin {
1254 	uint_t			ip_return_value;
1255 	crypto_session_id_t	ip_session;
1256 	caddr_t			ip_pin;
1257 	size_t			ip_pin_len;
1258 } crypto_init_pin_t;
1259 
1260 typedef struct crypto_set_pin {
1261 	uint_t			sp_return_value;
1262 	crypto_session_id_t	sp_session;
1263 	caddr_t			sp_old_pin;
1264 	size_t			sp_old_len;
1265 	caddr_t			sp_new_pin;
1266 	size_t			sp_new_len;
1267 } crypto_set_pin_t;
1268 
1269 #ifdef	_KERNEL
1270 #ifdef	_SYSCALL32
1271 
1272 typedef struct crypto_get_provider_list32 {
1273 	uint32_t		pl_return_value;
1274 	uint32_t		pl_count;
1275 	crypto_provider_entry_t pl_list[1];
1276 } crypto_get_provider_list32_t;
1277 
1278 typedef struct crypto_version32 {
1279 	uchar_t	cv_major;
1280 	uchar_t	cv_minor;
1281 } crypto_version32_t;
1282 
1283 typedef struct crypto_provider_data32 {
1284 	uchar_t			pd_prov_desc[CRYPTO_PROVIDER_DESCR_MAX_LEN];
1285 	uchar_t			pd_label[CRYPTO_EXT_SIZE_LABEL];
1286 	uchar_t			pd_manufacturerID[CRYPTO_EXT_SIZE_MANUF];
1287 	uchar_t			pd_model[CRYPTO_EXT_SIZE_MODEL];
1288 	uchar_t			pd_serial_number[CRYPTO_EXT_SIZE_SERIAL];
1289 	uint32_t		pd_flags;
1290 	uint32_t		pd_max_session_count;
1291 	uint32_t		pd_session_count;
1292 	uint32_t		pd_max_rw_session_count;
1293 	uint32_t		pd_rw_session_count;
1294 	uint32_t		pd_max_pin_len;
1295 	uint32_t		pd_min_pin_len;
1296 	uint32_t		pd_total_public_memory;
1297 	uint32_t		pd_free_public_memory;
1298 	uint32_t		pd_total_private_memory;
1299 	uint32_t		pd_free_private_memory;
1300 	crypto_version32_t	pd_hardware_version;
1301 	crypto_version32_t	pd_firmware_version;
1302 	uchar_t			pd_time[CRYPTO_EXT_SIZE_TIME];
1303 } crypto_provider_data32_t;
1304 
1305 typedef struct crypto_get_provider_info32 {
1306 	uint32_t		gi_return_value;
1307 	crypto_provider_id_t	gi_provider_id;
1308 	crypto_provider_data32_t gi_provider_data;
1309 } crypto_get_provider_info32_t;
1310 
1311 typedef struct crypto_get_provider_mechanisms32 {
1312 	uint32_t		pm_return_value;
1313 	crypto_provider_id_t	pm_provider_id;
1314 	uint32_t		pm_count;
1315 	crypto_mech_name_t	pm_list[1];
1316 } crypto_get_provider_mechanisms32_t;
1317 
1318 typedef struct crypto_init_token32 {
1319 	uint32_t		it_return_value;
1320 	crypto_provider_id_t	it_provider_id;
1321 	caddr32_t		it_pin;
1322 	size32_t		it_pin_len;
1323 	caddr32_t		it_label;
1324 } crypto_init_token32_t;
1325 
1326 typedef struct crypto_init_pin32 {
1327 	uint32_t		ip_return_value;
1328 	crypto_session_id_t	ip_session;
1329 	caddr32_t		ip_pin;
1330 	size32_t		ip_pin_len;
1331 } crypto_init_pin32_t;
1332 
1333 typedef struct crypto_set_pin32 {
1334 	uint32_t		sp_return_value;
1335 	crypto_session_id_t	sp_session;
1336 	caddr32_t		sp_old_pin;
1337 	size32_t		sp_old_len;
1338 	caddr32_t		sp_new_pin;
1339 	size32_t		sp_new_len;
1340 } crypto_set_pin32_t;
1341 
1342 #endif	/* _SYSCALL32 */
1343 #endif	/* _KERNEL */
1344 
1345 #define	CRYPTO_GET_PROVIDER_LIST		CRYPTO(120)
1346 #define	CRYPTO_GET_PROVIDER_INFO		CRYPTO(121)
1347 #define	CRYPTO_GET_PROVIDER_MECHANISMS		CRYPTO(122)
1348 #define	CRYPTO_GET_PROVIDER_MECHANISM_INFO	CRYPTO(123)
1349 #define	CRYPTO_INIT_TOKEN			CRYPTO(124)
1350 #define	CRYPTO_INIT_PIN				CRYPTO(125)
1351 #define	CRYPTO_SET_PIN				CRYPTO(126)
1352 
1353 /*
1354  * No (Key) Store Key Generation Ioctls
1355  */
1356 typedef struct crypto_nostore_generate_key {
1357 	uint_t			ngk_return_value;
1358 	crypto_session_id_t	ngk_session;
1359 	crypto_mechanism_t	ngk_mechanism;
1360 	uint_t			ngk_in_count;
1361 	uint_t			ngk_out_count;
1362 	caddr_t			ngk_in_attributes;
1363 	caddr_t			ngk_out_attributes;
1364 } crypto_nostore_generate_key_t;
1365 
1366 typedef struct crypto_nostore_generate_key_pair {
1367 	uint_t			nkp_return_value;
1368 	crypto_session_id_t	nkp_session;
1369 	uint_t			nkp_in_public_count;
1370 	uint_t			nkp_in_private_count;
1371 	uint_t			nkp_out_public_count;
1372 	uint_t			nkp_out_private_count;
1373 	caddr_t			nkp_in_public_attributes;
1374 	caddr_t			nkp_in_private_attributes;
1375 	caddr_t			nkp_out_public_attributes;
1376 	caddr_t			nkp_out_private_attributes;
1377 	crypto_mechanism_t	nkp_mechanism;
1378 } crypto_nostore_generate_key_pair_t;
1379 
1380 typedef struct crypto_nostore_derive_key {
1381 	uint_t			ndk_return_value;
1382 	crypto_session_id_t	ndk_session;
1383 	crypto_mechanism_t	ndk_mechanism;
1384 	crypto_key_t		ndk_base_key;
1385 	uint_t			ndk_in_count;
1386 	uint_t			ndk_out_count;
1387 	caddr_t			ndk_in_attributes;
1388 	caddr_t			ndk_out_attributes;
1389 } crypto_nostore_derive_key_t;
1390 
1391 #ifdef	_KERNEL
1392 #ifdef	_SYSCALL32
1393 
1394 typedef struct crypto_nostore_generate_key32 {
1395 	uint32_t		ngk_return_value;
1396 	crypto_session_id_t	ngk_session;
1397 	crypto_mechanism32_t	ngk_mechanism;
1398 	uint32_t		ngk_in_count;
1399 	uint32_t		ngk_out_count;
1400 	caddr32_t		ngk_in_attributes;
1401 	caddr32_t		ngk_out_attributes;
1402 } crypto_nostore_generate_key32_t;
1403 
1404 typedef struct crypto_nostore_generate_key_pair32 {
1405 	uint32_t		nkp_return_value;
1406 	crypto_session_id_t	nkp_session;
1407 	uint32_t		nkp_in_public_count;
1408 	uint32_t		nkp_in_private_count;
1409 	uint32_t		nkp_out_public_count;
1410 	uint32_t		nkp_out_private_count;
1411 	caddr32_t		nkp_in_public_attributes;
1412 	caddr32_t		nkp_in_private_attributes;
1413 	caddr32_t		nkp_out_public_attributes;
1414 	caddr32_t		nkp_out_private_attributes;
1415 	crypto_mechanism32_t	nkp_mechanism;
1416 } crypto_nostore_generate_key_pair32_t;
1417 
1418 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
1419 #pragma pack(4)
1420 #endif
1421 
1422 typedef struct crypto_nostore_derive_key32 {
1423 	uint32_t		ndk_return_value;
1424 	crypto_session_id_t	ndk_session;
1425 	crypto_mechanism32_t	ndk_mechanism;
1426 	crypto_key32_t		ndk_base_key;
1427 	uint32_t		ndk_in_count;
1428 	uint32_t		ndk_out_count;
1429 	caddr32_t		ndk_in_attributes;
1430 	caddr32_t		ndk_out_attributes;
1431 } crypto_nostore_derive_key32_t;
1432 
1433 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
1434 #pragma pack()
1435 #endif
1436 
1437 #endif	/* _SYSCALL32 */
1438 #endif	/* _KERNEL */
1439 
1440 #define	CRYPTO_NOSTORE_GENERATE_KEY		CRYPTO(127)
1441 #define	CRYPTO_NOSTORE_GENERATE_KEY_PAIR	CRYPTO(128)
1442 #define	CRYPTO_NOSTORE_DERIVE_KEY		CRYPTO(129)
1443 
1444 /*
1445  * Mechanism Ioctls
1446  */
1447 
1448 typedef struct crypto_get_mechanism_list {
1449 	uint_t			ml_return_value;
1450 	uint_t			ml_count;
1451 	crypto_mech_name_t	ml_list[1];
1452 } crypto_get_mechanism_list_t;
1453 
1454 typedef struct crypto_get_all_mechanism_info {
1455 	uint_t			mi_return_value;
1456 	crypto_mech_name_t	mi_mechanism_name;
1457 	uint_t			mi_count;
1458 	crypto_mechanism_info_t	mi_list[1];
1459 } crypto_get_all_mechanism_info_t;
1460 
1461 #ifdef	_KERNEL
1462 #ifdef	_SYSCALL32
1463 
1464 typedef struct crypto_get_mechanism_list32 {
1465 	uint32_t		ml_return_value;
1466 	uint32_t		ml_count;
1467 	crypto_mech_name_t	ml_list[1];
1468 } crypto_get_mechanism_list32_t;
1469 
1470 typedef struct crypto_get_all_mechanism_info32 {
1471 	uint32_t		mi_return_value;
1472 	crypto_mech_name_t	mi_mechanism_name;
1473 	uint32_t		mi_count;
1474 	crypto_mechanism_info32_t mi_list[1];
1475 } crypto_get_all_mechanism_info32_t;
1476 
1477 #endif	/* _SYSCALL32 */
1478 #endif	/* _KERNEL */
1479 
1480 #define	CRYPTO_GET_MECHANISM_LIST		CRYPTO(140)
1481 #define	CRYPTO_GET_ALL_MECHANISM_INFO		CRYPTO(141)
1482 
1483 #ifdef	__cplusplus
1484 }
1485 #endif
1486 
1487 #endif	/* _SYS_CRYPTO_IOCTL_H */
1488