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