xref: /onnv-gate/usr/src/uts/common/sys/crypto/api.h (revision 12596:d42e6e6980b3)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
52800Skrishna  * Common Development and Distribution License (the "License").
62800Skrishna  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*12304SValerie.Fenwick@Oracle.COM  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
230Sstevel@tonic-gate  */
240Sstevel@tonic-gate 
250Sstevel@tonic-gate #ifndef	_SYS_CRYPTO_API_H
260Sstevel@tonic-gate #define	_SYS_CRYPTO_API_H
270Sstevel@tonic-gate 
280Sstevel@tonic-gate #ifdef	__cplusplus
290Sstevel@tonic-gate extern "C" {
300Sstevel@tonic-gate #endif
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #include <sys/types.h>
330Sstevel@tonic-gate #include <sys/crypto/common.h>
340Sstevel@tonic-gate 
350Sstevel@tonic-gate typedef long crypto_req_id_t;
360Sstevel@tonic-gate typedef void *crypto_bc_t;
370Sstevel@tonic-gate typedef void *crypto_context_t;
380Sstevel@tonic-gate typedef void *crypto_ctx_template_t;
390Sstevel@tonic-gate 
400Sstevel@tonic-gate typedef uint32_t crypto_call_flag_t;
410Sstevel@tonic-gate 
420Sstevel@tonic-gate /* crypto_call_flag's values */
430Sstevel@tonic-gate #define	CRYPTO_ALWAYS_QUEUE	0x00000001	/* ALWAYS queue the req. */
440Sstevel@tonic-gate #define	CRYPTO_NOTIFY_OPDONE	0x00000002	/* Notify intermediate steps */
450Sstevel@tonic-gate #define	CRYPTO_SKIP_REQID	0x00000004	/* Skip request ID generation */
460Sstevel@tonic-gate 
470Sstevel@tonic-gate typedef struct {
480Sstevel@tonic-gate 	crypto_call_flag_t	cr_flag;
490Sstevel@tonic-gate 	void			(*cr_callback_func)(void *, int);
500Sstevel@tonic-gate 	void			*cr_callback_arg;
510Sstevel@tonic-gate 	crypto_req_id_t		cr_reqid;
520Sstevel@tonic-gate } crypto_call_req_t;
530Sstevel@tonic-gate 
540Sstevel@tonic-gate /*
550Sstevel@tonic-gate  * Returns the mechanism type corresponding to a mechanism name.
560Sstevel@tonic-gate  */
570Sstevel@tonic-gate 
580Sstevel@tonic-gate #define	CRYPTO_MECH_INVALID	((uint64_t)-1)
590Sstevel@tonic-gate extern crypto_mech_type_t crypto_mech2id(crypto_mech_name_t name);
600Sstevel@tonic-gate 
610Sstevel@tonic-gate /*
620Sstevel@tonic-gate  * Create and destroy context templates.
630Sstevel@tonic-gate  */
640Sstevel@tonic-gate extern int crypto_create_ctx_template(crypto_mechanism_t *mech,
650Sstevel@tonic-gate     crypto_key_t *key, crypto_ctx_template_t *tmpl, int kmflag);
660Sstevel@tonic-gate extern void crypto_destroy_ctx_template(crypto_ctx_template_t tmpl);
670Sstevel@tonic-gate 
680Sstevel@tonic-gate /*
690Sstevel@tonic-gate  * Single and multi-part digest operations.
700Sstevel@tonic-gate  */
710Sstevel@tonic-gate extern int crypto_digest(crypto_mechanism_t *mech, crypto_data_t *data,
720Sstevel@tonic-gate     crypto_data_t *digest, crypto_call_req_t *cr);
73904Smcpowers extern int crypto_digest_prov(crypto_provider_t, crypto_session_id_t,
74904Smcpowers     crypto_mechanism_t *, crypto_data_t *, crypto_data_t *,
75904Smcpowers     crypto_call_req_t *);
760Sstevel@tonic-gate extern int crypto_digest_init(crypto_mechanism_t *mech, crypto_context_t *ctxp,
770Sstevel@tonic-gate     crypto_call_req_t *cr);
78904Smcpowers extern int crypto_digest_init_prov(crypto_provider_t, crypto_session_id_t,
79904Smcpowers     crypto_mechanism_t *, crypto_context_t *, crypto_call_req_t *);
800Sstevel@tonic-gate extern int crypto_digest_update(crypto_context_t ctx, crypto_data_t *data,
810Sstevel@tonic-gate     crypto_call_req_t *cr);
820Sstevel@tonic-gate extern int crypto_digest_final(crypto_context_t ctx, crypto_data_t *digest,
830Sstevel@tonic-gate     crypto_call_req_t *cr);
840Sstevel@tonic-gate 
850Sstevel@tonic-gate /*
860Sstevel@tonic-gate  * Single and multi-part MAC operations.
870Sstevel@tonic-gate  */
880Sstevel@tonic-gate extern int crypto_mac(crypto_mechanism_t *mech, crypto_data_t *data,
890Sstevel@tonic-gate     crypto_key_t *key, crypto_ctx_template_t tmpl, crypto_data_t *mac,
900Sstevel@tonic-gate     crypto_call_req_t *cr);
91904Smcpowers extern int crypto_mac_prov(crypto_provider_t, crypto_session_id_t,
92904Smcpowers     crypto_mechanism_t *, crypto_data_t *, crypto_key_t *,
93904Smcpowers     crypto_ctx_template_t, crypto_data_t *, crypto_call_req_t *);
940Sstevel@tonic-gate extern int crypto_mac_verify(crypto_mechanism_t *mech, crypto_data_t *data,
950Sstevel@tonic-gate     crypto_key_t *key, crypto_ctx_template_t tmpl, crypto_data_t *mac,
960Sstevel@tonic-gate     crypto_call_req_t *cr);
97904Smcpowers extern int crypto_mac_verify_prov(crypto_provider_t, crypto_session_id_t,
98904Smcpowers     crypto_mechanism_t *, crypto_data_t *, crypto_key_t *,
99904Smcpowers     crypto_ctx_template_t, crypto_data_t *, crypto_call_req_t *);
1000Sstevel@tonic-gate extern int crypto_mac_init(crypto_mechanism_t *mech, crypto_key_t *key,
1010Sstevel@tonic-gate     crypto_ctx_template_t tmpl, crypto_context_t *ctxp, crypto_call_req_t *cr);
102904Smcpowers extern int crypto_mac_init_prov(crypto_provider_t, crypto_session_id_t,
103904Smcpowers     crypto_mechanism_t *, crypto_key_t *, crypto_ctx_template_t,
104904Smcpowers     crypto_context_t *, crypto_call_req_t *);
1050Sstevel@tonic-gate extern int crypto_mac_update(crypto_context_t ctx, crypto_data_t *data,
1060Sstevel@tonic-gate     crypto_call_req_t *cr);
1070Sstevel@tonic-gate extern int crypto_mac_final(crypto_context_t ctx, crypto_data_t *data,
1080Sstevel@tonic-gate     crypto_call_req_t *cr);
1090Sstevel@tonic-gate 
1100Sstevel@tonic-gate /*
1110Sstevel@tonic-gate  * Single and multi-part sign with private key operations.
1120Sstevel@tonic-gate  */
1130Sstevel@tonic-gate extern int crypto_sign(crypto_mechanism_t *mech, crypto_key_t *key,
1140Sstevel@tonic-gate     crypto_data_t *data, crypto_ctx_template_t tmpl,
1150Sstevel@tonic-gate     crypto_data_t *signature, crypto_call_req_t *cr);
116904Smcpowers extern int crypto_sign_prov(crypto_provider_t, crypto_session_id_t,
117904Smcpowers     crypto_mechanism_t *, crypto_key_t *, crypto_data_t *,
118904Smcpowers     crypto_ctx_template_t, crypto_data_t *, crypto_call_req_t *);
1190Sstevel@tonic-gate extern int crypto_sign_init(crypto_mechanism_t *mech, crypto_key_t *key,
1200Sstevel@tonic-gate     crypto_ctx_template_t tmpl, crypto_context_t *ctxp, crypto_call_req_t *cr);
121904Smcpowers extern int crypto_sign_init_prov(crypto_provider_t, crypto_session_id_t,
122904Smcpowers     crypto_mechanism_t *, crypto_key_t *, crypto_ctx_template_t,
123904Smcpowers     crypto_context_t *, crypto_call_req_t *);
1240Sstevel@tonic-gate extern int crypto_sign_update(crypto_context_t ctx, crypto_data_t *data,
1250Sstevel@tonic-gate     crypto_call_req_t *cr);
1260Sstevel@tonic-gate extern int crypto_sign_final(crypto_context_t ctx, crypto_data_t *signature,
1270Sstevel@tonic-gate     crypto_call_req_t *cr);
128904Smcpowers extern int crypto_sign_recover_init_prov(crypto_provider_t,
129904Smcpowers     crypto_session_id_t, crypto_mechanism_t *, crypto_key_t *,
130904Smcpowers     crypto_ctx_template_t tmpl, crypto_context_t *, crypto_call_req_t *);
1310Sstevel@tonic-gate extern int crypto_sign_recover(crypto_mechanism_t *mech, crypto_key_t *key,
1320Sstevel@tonic-gate     crypto_data_t *data, crypto_ctx_template_t tmpl, crypto_data_t *signature,
1330Sstevel@tonic-gate     crypto_call_req_t *cr);
134904Smcpowers extern int crypto_sign_recover_prov(crypto_provider_t, crypto_session_id_t,
135904Smcpowers     crypto_mechanism_t *, crypto_key_t *, crypto_data_t *,
136904Smcpowers     crypto_ctx_template_t, crypto_data_t *, crypto_call_req_t *);
1370Sstevel@tonic-gate 
1380Sstevel@tonic-gate /*
1390Sstevel@tonic-gate  * Single and multi-part verify with public key operations.
1400Sstevel@tonic-gate  */
1410Sstevel@tonic-gate extern int crypto_verify(crypto_mechanism_t *mech, crypto_key_t *key,
1420Sstevel@tonic-gate     crypto_data_t *data, crypto_ctx_template_t tmpl, crypto_data_t *signature,
1430Sstevel@tonic-gate     crypto_call_req_t *cr);
144904Smcpowers extern int crypto_verify_prov(crypto_provider_t, crypto_session_id_t,
145904Smcpowers     crypto_mechanism_t *, crypto_key_t *, crypto_data_t *,
146904Smcpowers     crypto_ctx_template_t, crypto_data_t *, crypto_call_req_t *);
1470Sstevel@tonic-gate extern int crypto_verify_init(crypto_mechanism_t *mech, crypto_key_t *key,
1480Sstevel@tonic-gate     crypto_ctx_template_t tmpl, crypto_context_t *ctxp, crypto_call_req_t *cr);
149904Smcpowers extern int crypto_verify_init_prov(crypto_provider_t, crypto_session_id_t,
150904Smcpowers     crypto_mechanism_t *, crypto_key_t *, crypto_ctx_template_t,
151904Smcpowers     crypto_context_t *, crypto_call_req_t *);
1520Sstevel@tonic-gate extern int crypto_verify_update(crypto_context_t ctx, crypto_data_t *data,
1530Sstevel@tonic-gate     crypto_call_req_t *cr);
1540Sstevel@tonic-gate extern int crypto_verify_final(crypto_context_t ctx, crypto_data_t *signature,
1550Sstevel@tonic-gate     crypto_call_req_t *cr);
156904Smcpowers extern int crypto_verify_recover_init_prov(crypto_provider_t,
157904Smcpowers     crypto_session_id_t, crypto_mechanism_t *, crypto_key_t *,
158904Smcpowers     crypto_ctx_template_t tmpl, crypto_context_t *, crypto_call_req_t *);
1590Sstevel@tonic-gate extern int crypto_verify_recover(crypto_mechanism_t *mech, crypto_key_t *key,
1600Sstevel@tonic-gate     crypto_data_t *signature, crypto_ctx_template_t tmpl, crypto_data_t *data,
1610Sstevel@tonic-gate     crypto_call_req_t *cr);
162904Smcpowers extern int crypto_verify_recover_prov(crypto_provider_t, crypto_session_id_t,
163904Smcpowers     crypto_mechanism_t *, crypto_key_t *, crypto_data_t *,
164904Smcpowers     crypto_ctx_template_t, crypto_data_t *, crypto_call_req_t *);
1650Sstevel@tonic-gate 
1660Sstevel@tonic-gate /*
1670Sstevel@tonic-gate  * Single and multi-part encryption operations.
1680Sstevel@tonic-gate  */
1690Sstevel@tonic-gate extern int crypto_encrypt(crypto_mechanism_t *mech, crypto_data_t *plaintext,
1700Sstevel@tonic-gate     crypto_key_t *key, crypto_ctx_template_t tmpl, crypto_data_t *ciphertext,
1710Sstevel@tonic-gate     crypto_call_req_t *cr);
172904Smcpowers extern int crypto_encrypt_prov(crypto_provider_t, crypto_session_id_t,
173904Smcpowers     crypto_mechanism_t *, crypto_data_t *, crypto_key_t *,
174904Smcpowers     crypto_ctx_template_t, crypto_data_t *, crypto_call_req_t *);
1750Sstevel@tonic-gate extern int crypto_encrypt_init(crypto_mechanism_t *mech, crypto_key_t *key,
1760Sstevel@tonic-gate     crypto_ctx_template_t tmpl, crypto_context_t *ctxp, crypto_call_req_t *cr);
177904Smcpowers extern int crypto_encrypt_init_prov(crypto_provider_t, crypto_session_id_t,
178904Smcpowers     crypto_mechanism_t *, crypto_key_t *, crypto_ctx_template_t,
179904Smcpowers     crypto_context_t *, crypto_call_req_t *);
1800Sstevel@tonic-gate extern int crypto_encrypt_update(crypto_context_t ctx,
1810Sstevel@tonic-gate     crypto_data_t *plaintext, crypto_data_t *ciphertext,
1820Sstevel@tonic-gate     crypto_call_req_t *cr);
1830Sstevel@tonic-gate extern int crypto_encrypt_final(crypto_context_t ctx,
1840Sstevel@tonic-gate     crypto_data_t *ciphertext, crypto_call_req_t *cr);
1850Sstevel@tonic-gate 
1860Sstevel@tonic-gate /*
1870Sstevel@tonic-gate  * Single and multi-part decryption operations.
1880Sstevel@tonic-gate  */
1890Sstevel@tonic-gate extern int crypto_decrypt(crypto_mechanism_t *mech, crypto_data_t *ciphertext,
1900Sstevel@tonic-gate     crypto_key_t *key, crypto_ctx_template_t tmpl, crypto_data_t *plaintext,
1910Sstevel@tonic-gate     crypto_call_req_t *cr);
192904Smcpowers extern int crypto_decrypt_prov(crypto_provider_t, crypto_session_id_t,
193904Smcpowers     crypto_mechanism_t *, crypto_data_t *, crypto_key_t *,
194904Smcpowers     crypto_ctx_template_t, crypto_data_t *, crypto_call_req_t *);
1950Sstevel@tonic-gate extern int crypto_decrypt_init(crypto_mechanism_t *mech, crypto_key_t *key,
1960Sstevel@tonic-gate     crypto_ctx_template_t tmpl, crypto_context_t *ctxp,
1970Sstevel@tonic-gate     crypto_call_req_t *cr);
198904Smcpowers extern int crypto_decrypt_init_prov(crypto_provider_t, crypto_session_id_t,
199904Smcpowers     crypto_mechanism_t *, crypto_key_t *, crypto_ctx_template_t,
200904Smcpowers     crypto_context_t *, crypto_call_req_t *);
2010Sstevel@tonic-gate extern int crypto_decrypt_update(crypto_context_t ctx,
2020Sstevel@tonic-gate     crypto_data_t *ciphertext, crypto_data_t *plaintext,
2030Sstevel@tonic-gate     crypto_call_req_t *cr);
2040Sstevel@tonic-gate extern int crypto_decrypt_final(crypto_context_t ctx, crypto_data_t *plaintext,
2050Sstevel@tonic-gate     crypto_call_req_t *cr);
2060Sstevel@tonic-gate 
2070Sstevel@tonic-gate /*
2080Sstevel@tonic-gate  * Single and multi-part encrypt/MAC dual operations.
2090Sstevel@tonic-gate  */
2100Sstevel@tonic-gate extern int crypto_encrypt_mac(crypto_mechanism_t *encr_mech,
2110Sstevel@tonic-gate     crypto_mechanism_t *mac_mech, crypto_data_t *pt,
2120Sstevel@tonic-gate     crypto_key_t *encr_key, crypto_key_t *mac_key,
2130Sstevel@tonic-gate     crypto_ctx_template_t encr_tmpl, crypto_ctx_template_t mac_tmpl,
2140Sstevel@tonic-gate     crypto_dual_data_t *ct, crypto_data_t *mac, crypto_call_req_t *cr);
215904Smcpowers extern int crypto_encrypt_mac_prov(crypto_provider_t, crypto_session_id_t,
216904Smcpowers     crypto_mechanism_t *, crypto_mechanism_t *, crypto_data_t *,
217904Smcpowers     crypto_key_t *, crypto_key_t *, crypto_ctx_template_t,
218904Smcpowers     crypto_ctx_template_t, crypto_dual_data_t *, crypto_data_t *,
219904Smcpowers     crypto_call_req_t *);
2200Sstevel@tonic-gate extern int crypto_encrypt_mac_init(crypto_mechanism_t *encr_mech,
2210Sstevel@tonic-gate     crypto_mechanism_t *mac_mech, crypto_key_t *encr_key,
2220Sstevel@tonic-gate     crypto_key_t *mac_key, crypto_ctx_template_t encr_tmpl,
2230Sstevel@tonic-gate     crypto_ctx_template_t mac_tmpl, crypto_context_t *ctxp,
2240Sstevel@tonic-gate     crypto_call_req_t *cr);
225904Smcpowers extern int crypto_encrypt_mac_init_prov(crypto_provider_t, crypto_session_id_t,
226904Smcpowers     crypto_mechanism_t *, crypto_mechanism_t *, crypto_key_t *, crypto_key_t *,
227904Smcpowers     crypto_ctx_template_t, crypto_ctx_template_t, crypto_context_t *,
228904Smcpowers     crypto_call_req_t *);
2290Sstevel@tonic-gate extern int crypto_encrypt_mac_update(crypto_context_t ctx,
2300Sstevel@tonic-gate     crypto_data_t *pt, crypto_dual_data_t *ct, crypto_call_req_t *cr);
2310Sstevel@tonic-gate extern int crypto_encrypt_mac_final(crypto_context_t ctx,
2320Sstevel@tonic-gate     crypto_dual_data_t *ct, crypto_data_t *mac, crypto_call_req_t *cr);
2330Sstevel@tonic-gate 
2340Sstevel@tonic-gate /*
2350Sstevel@tonic-gate  * Single and multi-part MAC/decrypt dual operations.
2360Sstevel@tonic-gate  */
2370Sstevel@tonic-gate extern int crypto_mac_decrypt(crypto_mechanism_t *mac_mech,
2380Sstevel@tonic-gate     crypto_mechanism_t *decr_mech, crypto_dual_data_t *ct,
2390Sstevel@tonic-gate     crypto_key_t *mac_key, crypto_key_t *decr_key,
2400Sstevel@tonic-gate     crypto_ctx_template_t mac_tmpl, crypto_ctx_template_t decr_tmpl,
2410Sstevel@tonic-gate     crypto_data_t *mac, crypto_data_t *pt, crypto_call_req_t *cr);
242904Smcpowers extern int crypto_mac_decrypt_prov(crypto_provider_t, crypto_session_id_t,
243904Smcpowers     crypto_mechanism_t *mac_mech, crypto_mechanism_t *decr_mech,
244904Smcpowers     crypto_dual_data_t *ct, crypto_key_t *mac_key, crypto_key_t *decr_key,
245904Smcpowers     crypto_ctx_template_t mac_tmpl, crypto_ctx_template_t decr_tmpl,
246904Smcpowers     crypto_data_t *mac, crypto_data_t *pt, crypto_call_req_t *cr);
2470Sstevel@tonic-gate extern int crypto_mac_verify_decrypt(crypto_mechanism_t *mac_mech,
2480Sstevel@tonic-gate     crypto_mechanism_t *decr_mech, crypto_dual_data_t *ct,
2490Sstevel@tonic-gate     crypto_key_t *mac_key, crypto_key_t *decr_key,
2500Sstevel@tonic-gate     crypto_ctx_template_t mac_tmpl, crypto_ctx_template_t decr_tmpl,
2510Sstevel@tonic-gate     crypto_data_t *mac, crypto_data_t *pt, crypto_call_req_t *cr);
252904Smcpowers extern int crypto_mac_verify_decrypt_prov(crypto_provider_t,
253904Smcpowers     crypto_session_id_t, crypto_mechanism_t *mac_mech,
254904Smcpowers     crypto_mechanism_t *decr_mech, crypto_dual_data_t *ct,
255904Smcpowers     crypto_key_t *mac_key, crypto_key_t *decr_key,
256904Smcpowers     crypto_ctx_template_t mac_tmpl, crypto_ctx_template_t decr_tmpl,
257904Smcpowers     crypto_data_t *mac, crypto_data_t *pt, crypto_call_req_t *cr);
2580Sstevel@tonic-gate extern int crypto_mac_decrypt_init(crypto_mechanism_t *mac_mech,
2590Sstevel@tonic-gate     crypto_mechanism_t *decr_mech, crypto_key_t *mac_key,
2600Sstevel@tonic-gate     crypto_key_t *decr_key, crypto_ctx_template_t mac_tmpl,
2610Sstevel@tonic-gate     crypto_ctx_template_t decr_tmpl, crypto_context_t *ctxp,
2620Sstevel@tonic-gate     crypto_call_req_t *cr);
263904Smcpowers extern int crypto_mac_decrypt_init_prov(crypto_provider_t,
264904Smcpowers     crypto_session_id_t, crypto_mechanism_t *mac_mech,
265904Smcpowers     crypto_mechanism_t *decr_mech, crypto_key_t *mac_key,
266904Smcpowers     crypto_key_t *decr_key, crypto_ctx_template_t mac_tmpl,
267904Smcpowers     crypto_ctx_template_t decr_tmpl, crypto_context_t *ctxp,
268904Smcpowers     crypto_call_req_t *cr);
2690Sstevel@tonic-gate extern int crypto_mac_decrypt_update(crypto_context_t ctx,
2700Sstevel@tonic-gate     crypto_dual_data_t *ct, crypto_data_t *pt, crypto_call_req_t *cr);
2710Sstevel@tonic-gate extern int crypto_mac_decrypt_final(crypto_context_t ctx, crypto_data_t *mac,
2720Sstevel@tonic-gate     crypto_data_t *pt, crypto_call_req_t *cr);
2730Sstevel@tonic-gate 
274904Smcpowers /* Session Management */
275904Smcpowers extern int crypto_session_open(crypto_provider_t, crypto_session_id_t *,
276904Smcpowers     crypto_call_req_t *);
277904Smcpowers extern int crypto_session_close(crypto_provider_t, crypto_session_id_t,
278904Smcpowers     crypto_call_req_t *);
279904Smcpowers extern int crypto_session_login(crypto_provider_t, crypto_session_id_t,
280904Smcpowers     crypto_user_type_t, char *, size_t, crypto_call_req_t *);
281904Smcpowers extern int crypto_session_logout(crypto_provider_t, crypto_session_id_t,
282904Smcpowers     crypto_call_req_t *);
283904Smcpowers 
284904Smcpowers /* Object Management */
285904Smcpowers extern int crypto_object_copy(crypto_provider_t, crypto_session_id_t,
286904Smcpowers     crypto_object_id_t, crypto_object_attribute_t *, uint_t,
287904Smcpowers     crypto_object_id_t *, crypto_call_req_t *);
288904Smcpowers extern int crypto_object_create(crypto_provider_t, crypto_session_id_t,
289904Smcpowers     crypto_object_attribute_t *, uint_t, crypto_object_id_t *,
290904Smcpowers     crypto_call_req_t *);
291904Smcpowers extern int crypto_object_destroy(crypto_provider_t, crypto_session_id_t,
292904Smcpowers     crypto_object_id_t, crypto_call_req_t *);
293904Smcpowers extern int crypto_object_get_attribute_value(crypto_provider_t,
294904Smcpowers     crypto_session_id_t, crypto_object_id_t, crypto_object_attribute_t *,
295904Smcpowers     uint_t, crypto_call_req_t *);
296904Smcpowers extern int crypto_object_get_size(crypto_provider_t, crypto_session_id_t,
297904Smcpowers     crypto_object_id_t, size_t *, crypto_call_req_t *);
298904Smcpowers extern int crypto_object_find_final(crypto_provider_t, void *,
299904Smcpowers     crypto_call_req_t *);
300904Smcpowers extern int crypto_object_find_init(crypto_provider_t, crypto_session_id_t,
301904Smcpowers     crypto_object_attribute_t *, uint_t, void **, crypto_call_req_t *);
302904Smcpowers extern int crypto_object_find(crypto_provider_t, void *, crypto_object_id_t *,
303904Smcpowers     uint_t *, uint_t, crypto_call_req_t *);
304904Smcpowers extern int crypto_object_set_attribute_value(crypto_provider_t,
305904Smcpowers     crypto_session_id_t, crypto_object_id_t, crypto_object_attribute_t *,
306904Smcpowers     uint_t, crypto_call_req_t *);
307904Smcpowers 
308904Smcpowers /* Key Management */
309904Smcpowers extern int crypto_key_derive(crypto_provider_t, crypto_session_id_t,
310904Smcpowers     crypto_mechanism_t *, crypto_key_t *, crypto_object_attribute_t *,
311904Smcpowers     uint_t, crypto_object_id_t *, crypto_call_req_t *);
312904Smcpowers extern int crypto_key_generate(crypto_provider_t, crypto_session_id_t,
313904Smcpowers     crypto_mechanism_t *, crypto_object_attribute_t *, uint_t,
314904Smcpowers     crypto_object_id_t *, crypto_call_req_t *);
315904Smcpowers extern int crypto_key_generate_pair(crypto_provider_t, crypto_session_id_t,
316904Smcpowers     crypto_mechanism_t *, crypto_object_attribute_t *, uint_t,
317904Smcpowers     crypto_object_attribute_t *, uint_t, crypto_object_id_t *,
318904Smcpowers     crypto_object_id_t *, crypto_call_req_t *);
319904Smcpowers extern int crypto_key_unwrap(crypto_provider_t, crypto_session_id_t,
320904Smcpowers     crypto_mechanism_t *, crypto_key_t *, uchar_t *, size_t *,
321904Smcpowers     crypto_object_attribute_t *, uint_t, crypto_object_id_t *,
322904Smcpowers     crypto_call_req_t *);
323904Smcpowers extern int crypto_key_wrap(crypto_provider_t, crypto_session_id_t,
324904Smcpowers     crypto_mechanism_t *, crypto_key_t *, crypto_object_id_t *, uchar_t *,
325904Smcpowers     size_t *, crypto_call_req_t *);
326904Smcpowers extern int crypto_key_check_prov(crypto_provider_t, crypto_mechanism_t *mech,
327904Smcpowers     crypto_key_t *key);
328904Smcpowers extern int crypto_key_check(crypto_mechanism_t *mech, crypto_key_t *key);
329904Smcpowers 
330904Smcpowers 
3310Sstevel@tonic-gate /*
3320Sstevel@tonic-gate  * Routines to cancel a single asynchronous request or all asynchronous
3330Sstevel@tonic-gate  * requests associated with a particular context.
3340Sstevel@tonic-gate  */
3350Sstevel@tonic-gate extern void crypto_cancel_req(crypto_req_id_t req);
3360Sstevel@tonic-gate extern void crypto_cancel_ctx(crypto_context_t ctx);
3370Sstevel@tonic-gate 
3380Sstevel@tonic-gate /*
3390Sstevel@tonic-gate  * crypto_get_mech_list(9F) allocates and returns the list of currently
3400Sstevel@tonic-gate  * supported cryptographic mechanisms.
3410Sstevel@tonic-gate  */
3420Sstevel@tonic-gate extern crypto_mech_name_t *crypto_get_mech_list(uint_t *count, int kmflag);
3430Sstevel@tonic-gate extern void crypto_free_mech_list(crypto_mech_name_t *mech_names,
3440Sstevel@tonic-gate     uint_t count);
3450Sstevel@tonic-gate 
346904Smcpowers extern crypto_provider_t crypto_get_provider(char *, char *, char *);
3472800Skrishna extern int crypto_get_provinfo(crypto_provider_t, crypto_provider_ext_info_t *);
348904Smcpowers extern void crypto_release_provider(crypto_provider_t);
349904Smcpowers 
3500Sstevel@tonic-gate /*
3510Sstevel@tonic-gate  * A kernel consumer can request to be notified when some particular event
3520Sstevel@tonic-gate  * occurs. The valid events, callback function type, and functions to
3530Sstevel@tonic-gate  * be called to register or unregister for notification are defined below.
3540Sstevel@tonic-gate  */
3550Sstevel@tonic-gate 
3562800Skrishna #define	CRYPTO_EVENT_MECHS_CHANGED		0x00000001
3572800Skrishna #define	CRYPTO_EVENT_PROVIDER_REGISTERED	0x00000002
3582800Skrishna #define	CRYPTO_EVENT_PROVIDER_UNREGISTERED	0x00000004
3590Sstevel@tonic-gate 
3602800Skrishna typedef enum {
3612800Skrishna 	CRYPTO_MECH_ADDED = 1,
3622800Skrishna 	CRYPTO_MECH_REMOVED
3630Sstevel@tonic-gate } crypto_event_change_t;
3640Sstevel@tonic-gate 
3650Sstevel@tonic-gate /* The event_arg argument structure for CRYPTO_EVENT_PROVIDERS_CHANGE event */
3660Sstevel@tonic-gate typedef struct crypto_notify_event_change {
3670Sstevel@tonic-gate 	crypto_mech_name_t ec_mech_name;
3680Sstevel@tonic-gate 	crypto_provider_type_t ec_provider_type;
3690Sstevel@tonic-gate 	crypto_event_change_t ec_change;
3700Sstevel@tonic-gate } crypto_notify_event_change_t;
3710Sstevel@tonic-gate 
3720Sstevel@tonic-gate typedef void *crypto_notify_handle_t;
3730Sstevel@tonic-gate typedef void (*crypto_notify_callback_t)(uint32_t event_mask, void *event_arg);
3740Sstevel@tonic-gate 
3750Sstevel@tonic-gate extern crypto_notify_handle_t crypto_notify_events(
3760Sstevel@tonic-gate     crypto_notify_callback_t nf, uint32_t event_mask);
3770Sstevel@tonic-gate extern void crypto_unnotify_events(crypto_notify_handle_t);
3780Sstevel@tonic-gate 
3790Sstevel@tonic-gate /*
3800Sstevel@tonic-gate  * crypto_bufcall(9F) group of routines.
3810Sstevel@tonic-gate  */
3820Sstevel@tonic-gate extern crypto_bc_t crypto_bufcall_alloc(void);
3830Sstevel@tonic-gate extern int crypto_bufcall_free(crypto_bc_t bc);
3840Sstevel@tonic-gate extern int crypto_bufcall(crypto_bc_t bc, void (*func)(void *arg), void *arg);
3850Sstevel@tonic-gate extern int crypto_unbufcall(crypto_bc_t bc);
3860Sstevel@tonic-gate 
3870Sstevel@tonic-gate /*
3880Sstevel@tonic-gate  * To obtain the list of key size ranges supported by a mechanism.
3890Sstevel@tonic-gate  */
3900Sstevel@tonic-gate 
3910Sstevel@tonic-gate #define	CRYPTO_MECH_USAGE_ENCRYPT	0x00000001
3920Sstevel@tonic-gate #define	CRYPTO_MECH_USAGE_DECRYPT	0x00000002
3930Sstevel@tonic-gate #define	CRYPTO_MECH_USAGE_MAC		0x00000004
3940Sstevel@tonic-gate 
3950Sstevel@tonic-gate typedef	uint32_t crypto_mech_usage_t;
3960Sstevel@tonic-gate 
3970Sstevel@tonic-gate typedef struct crypto_mechanism_info {
3980Sstevel@tonic-gate 	size_t mi_min_key_size;
3990Sstevel@tonic-gate 	size_t mi_max_key_size;
4000Sstevel@tonic-gate 	crypto_keysize_unit_t mi_keysize_unit; /* for mi_xxx_key_size */
4010Sstevel@tonic-gate 	crypto_mech_usage_t mi_usage;
4020Sstevel@tonic-gate } crypto_mechanism_info_t;
4030Sstevel@tonic-gate 
4048313SDina.Nimeh@Sun.Com #ifdef	_SYSCALL32
4058313SDina.Nimeh@Sun.Com 
4068313SDina.Nimeh@Sun.Com typedef struct crypto_mechanism_info32 {
4078313SDina.Nimeh@Sun.Com 	size32_t mi_min_key_size;
4088313SDina.Nimeh@Sun.Com 	size32_t mi_max_key_size;
4098313SDina.Nimeh@Sun.Com 	crypto_keysize_unit_t mi_keysize_unit; /* for mi_xxx_key_size */
4108313SDina.Nimeh@Sun.Com 	crypto_mech_usage_t mi_usage;
4118313SDina.Nimeh@Sun.Com } crypto_mechanism_info32_t;
4128313SDina.Nimeh@Sun.Com 
4138313SDina.Nimeh@Sun.Com #endif	/* _SYSCALL32 */
4148313SDina.Nimeh@Sun.Com 
4150Sstevel@tonic-gate extern int crypto_get_all_mech_info(crypto_mech_type_t,
4160Sstevel@tonic-gate     crypto_mechanism_info_t **, uint_t *, int);
4178313SDina.Nimeh@Sun.Com extern void crypto_free_all_mech_info(crypto_mechanism_info_t *, uint_t);
4180Sstevel@tonic-gate 
4190Sstevel@tonic-gate #ifdef	__cplusplus
4200Sstevel@tonic-gate }
4210Sstevel@tonic-gate #endif
4220Sstevel@tonic-gate 
4230Sstevel@tonic-gate #endif	/* _SYS_CRYPTO_API_H */
424