17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5c892ebf1Skrishna * Common Development and Distribution License (the "License"). 6c892ebf1Skrishna * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*9b009fc1SValerie Bubb Fenwick * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 237c478bd9Sstevel@tonic-gate */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate #ifndef _SYS_CRYPTO_API_H 267c478bd9Sstevel@tonic-gate #define _SYS_CRYPTO_API_H 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #ifdef __cplusplus 297c478bd9Sstevel@tonic-gate extern "C" { 307c478bd9Sstevel@tonic-gate #endif 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #include <sys/types.h> 337c478bd9Sstevel@tonic-gate #include <sys/crypto/common.h> 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate typedef long crypto_req_id_t; 367c478bd9Sstevel@tonic-gate typedef void *crypto_bc_t; 377c478bd9Sstevel@tonic-gate typedef void *crypto_context_t; 387c478bd9Sstevel@tonic-gate typedef void *crypto_ctx_template_t; 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate typedef uint32_t crypto_call_flag_t; 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate /* crypto_call_flag's values */ 437c478bd9Sstevel@tonic-gate #define CRYPTO_ALWAYS_QUEUE 0x00000001 /* ALWAYS queue the req. */ 447c478bd9Sstevel@tonic-gate #define CRYPTO_NOTIFY_OPDONE 0x00000002 /* Notify intermediate steps */ 457c478bd9Sstevel@tonic-gate #define CRYPTO_SKIP_REQID 0x00000004 /* Skip request ID generation */ 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate typedef struct { 487c478bd9Sstevel@tonic-gate crypto_call_flag_t cr_flag; 497c478bd9Sstevel@tonic-gate void (*cr_callback_func)(void *, int); 507c478bd9Sstevel@tonic-gate void *cr_callback_arg; 517c478bd9Sstevel@tonic-gate crypto_req_id_t cr_reqid; 527c478bd9Sstevel@tonic-gate } crypto_call_req_t; 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate /* 557c478bd9Sstevel@tonic-gate * Returns the mechanism type corresponding to a mechanism name. 567c478bd9Sstevel@tonic-gate */ 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate #define CRYPTO_MECH_INVALID ((uint64_t)-1) 597c478bd9Sstevel@tonic-gate extern crypto_mech_type_t crypto_mech2id(crypto_mech_name_t name); 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate /* 627c478bd9Sstevel@tonic-gate * Create and destroy context templates. 637c478bd9Sstevel@tonic-gate */ 647c478bd9Sstevel@tonic-gate extern int crypto_create_ctx_template(crypto_mechanism_t *mech, 657c478bd9Sstevel@tonic-gate crypto_key_t *key, crypto_ctx_template_t *tmpl, int kmflag); 667c478bd9Sstevel@tonic-gate extern void crypto_destroy_ctx_template(crypto_ctx_template_t tmpl); 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate /* 697c478bd9Sstevel@tonic-gate * Single and multi-part digest operations. 707c478bd9Sstevel@tonic-gate */ 717c478bd9Sstevel@tonic-gate extern int crypto_digest(crypto_mechanism_t *mech, crypto_data_t *data, 727c478bd9Sstevel@tonic-gate crypto_data_t *digest, crypto_call_req_t *cr); 73894b2776Smcpowers extern int crypto_digest_prov(crypto_provider_t, crypto_session_id_t, 74894b2776Smcpowers crypto_mechanism_t *, crypto_data_t *, crypto_data_t *, 75894b2776Smcpowers crypto_call_req_t *); 767c478bd9Sstevel@tonic-gate extern int crypto_digest_init(crypto_mechanism_t *mech, crypto_context_t *ctxp, 777c478bd9Sstevel@tonic-gate crypto_call_req_t *cr); 78894b2776Smcpowers extern int crypto_digest_init_prov(crypto_provider_t, crypto_session_id_t, 79894b2776Smcpowers crypto_mechanism_t *, crypto_context_t *, crypto_call_req_t *); 807c478bd9Sstevel@tonic-gate extern int crypto_digest_update(crypto_context_t ctx, crypto_data_t *data, 817c478bd9Sstevel@tonic-gate crypto_call_req_t *cr); 827c478bd9Sstevel@tonic-gate extern int crypto_digest_final(crypto_context_t ctx, crypto_data_t *digest, 837c478bd9Sstevel@tonic-gate crypto_call_req_t *cr); 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate /* 867c478bd9Sstevel@tonic-gate * Single and multi-part MAC operations. 877c478bd9Sstevel@tonic-gate */ 887c478bd9Sstevel@tonic-gate extern int crypto_mac(crypto_mechanism_t *mech, crypto_data_t *data, 897c478bd9Sstevel@tonic-gate crypto_key_t *key, crypto_ctx_template_t tmpl, crypto_data_t *mac, 907c478bd9Sstevel@tonic-gate crypto_call_req_t *cr); 91894b2776Smcpowers extern int crypto_mac_prov(crypto_provider_t, crypto_session_id_t, 92894b2776Smcpowers crypto_mechanism_t *, crypto_data_t *, crypto_key_t *, 93894b2776Smcpowers crypto_ctx_template_t, crypto_data_t *, crypto_call_req_t *); 947c478bd9Sstevel@tonic-gate extern int crypto_mac_verify(crypto_mechanism_t *mech, crypto_data_t *data, 957c478bd9Sstevel@tonic-gate crypto_key_t *key, crypto_ctx_template_t tmpl, crypto_data_t *mac, 967c478bd9Sstevel@tonic-gate crypto_call_req_t *cr); 97894b2776Smcpowers extern int crypto_mac_verify_prov(crypto_provider_t, crypto_session_id_t, 98894b2776Smcpowers crypto_mechanism_t *, crypto_data_t *, crypto_key_t *, 99894b2776Smcpowers crypto_ctx_template_t, crypto_data_t *, crypto_call_req_t *); 1007c478bd9Sstevel@tonic-gate extern int crypto_mac_init(crypto_mechanism_t *mech, crypto_key_t *key, 1017c478bd9Sstevel@tonic-gate crypto_ctx_template_t tmpl, crypto_context_t *ctxp, crypto_call_req_t *cr); 102894b2776Smcpowers extern int crypto_mac_init_prov(crypto_provider_t, crypto_session_id_t, 103894b2776Smcpowers crypto_mechanism_t *, crypto_key_t *, crypto_ctx_template_t, 104894b2776Smcpowers crypto_context_t *, crypto_call_req_t *); 1057c478bd9Sstevel@tonic-gate extern int crypto_mac_update(crypto_context_t ctx, crypto_data_t *data, 1067c478bd9Sstevel@tonic-gate crypto_call_req_t *cr); 1077c478bd9Sstevel@tonic-gate extern int crypto_mac_final(crypto_context_t ctx, crypto_data_t *data, 1087c478bd9Sstevel@tonic-gate crypto_call_req_t *cr); 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate /* 1117c478bd9Sstevel@tonic-gate * Single and multi-part sign with private key operations. 1127c478bd9Sstevel@tonic-gate */ 1137c478bd9Sstevel@tonic-gate extern int crypto_sign(crypto_mechanism_t *mech, crypto_key_t *key, 1147c478bd9Sstevel@tonic-gate crypto_data_t *data, crypto_ctx_template_t tmpl, 1157c478bd9Sstevel@tonic-gate crypto_data_t *signature, crypto_call_req_t *cr); 116894b2776Smcpowers extern int crypto_sign_prov(crypto_provider_t, crypto_session_id_t, 117894b2776Smcpowers crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, 118894b2776Smcpowers crypto_ctx_template_t, crypto_data_t *, crypto_call_req_t *); 1197c478bd9Sstevel@tonic-gate extern int crypto_sign_init(crypto_mechanism_t *mech, crypto_key_t *key, 1207c478bd9Sstevel@tonic-gate crypto_ctx_template_t tmpl, crypto_context_t *ctxp, crypto_call_req_t *cr); 121894b2776Smcpowers extern int crypto_sign_init_prov(crypto_provider_t, crypto_session_id_t, 122894b2776Smcpowers crypto_mechanism_t *, crypto_key_t *, crypto_ctx_template_t, 123894b2776Smcpowers crypto_context_t *, crypto_call_req_t *); 1247c478bd9Sstevel@tonic-gate extern int crypto_sign_update(crypto_context_t ctx, crypto_data_t *data, 1257c478bd9Sstevel@tonic-gate crypto_call_req_t *cr); 1267c478bd9Sstevel@tonic-gate extern int crypto_sign_final(crypto_context_t ctx, crypto_data_t *signature, 1277c478bd9Sstevel@tonic-gate crypto_call_req_t *cr); 128894b2776Smcpowers extern int crypto_sign_recover_init_prov(crypto_provider_t, 129894b2776Smcpowers crypto_session_id_t, crypto_mechanism_t *, crypto_key_t *, 130894b2776Smcpowers crypto_ctx_template_t tmpl, crypto_context_t *, crypto_call_req_t *); 1317c478bd9Sstevel@tonic-gate extern int crypto_sign_recover(crypto_mechanism_t *mech, crypto_key_t *key, 1327c478bd9Sstevel@tonic-gate crypto_data_t *data, crypto_ctx_template_t tmpl, crypto_data_t *signature, 1337c478bd9Sstevel@tonic-gate crypto_call_req_t *cr); 134894b2776Smcpowers extern int crypto_sign_recover_prov(crypto_provider_t, crypto_session_id_t, 135894b2776Smcpowers crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, 136894b2776Smcpowers crypto_ctx_template_t, crypto_data_t *, crypto_call_req_t *); 1377c478bd9Sstevel@tonic-gate 1387c478bd9Sstevel@tonic-gate /* 1397c478bd9Sstevel@tonic-gate * Single and multi-part verify with public key operations. 1407c478bd9Sstevel@tonic-gate */ 1417c478bd9Sstevel@tonic-gate extern int crypto_verify(crypto_mechanism_t *mech, crypto_key_t *key, 1427c478bd9Sstevel@tonic-gate crypto_data_t *data, crypto_ctx_template_t tmpl, crypto_data_t *signature, 1437c478bd9Sstevel@tonic-gate crypto_call_req_t *cr); 144894b2776Smcpowers extern int crypto_verify_prov(crypto_provider_t, crypto_session_id_t, 145894b2776Smcpowers crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, 146894b2776Smcpowers crypto_ctx_template_t, crypto_data_t *, crypto_call_req_t *); 1477c478bd9Sstevel@tonic-gate extern int crypto_verify_init(crypto_mechanism_t *mech, crypto_key_t *key, 1487c478bd9Sstevel@tonic-gate crypto_ctx_template_t tmpl, crypto_context_t *ctxp, crypto_call_req_t *cr); 149894b2776Smcpowers extern int crypto_verify_init_prov(crypto_provider_t, crypto_session_id_t, 150894b2776Smcpowers crypto_mechanism_t *, crypto_key_t *, crypto_ctx_template_t, 151894b2776Smcpowers crypto_context_t *, crypto_call_req_t *); 1527c478bd9Sstevel@tonic-gate extern int crypto_verify_update(crypto_context_t ctx, crypto_data_t *data, 1537c478bd9Sstevel@tonic-gate crypto_call_req_t *cr); 1547c478bd9Sstevel@tonic-gate extern int crypto_verify_final(crypto_context_t ctx, crypto_data_t *signature, 1557c478bd9Sstevel@tonic-gate crypto_call_req_t *cr); 156894b2776Smcpowers extern int crypto_verify_recover_init_prov(crypto_provider_t, 157894b2776Smcpowers crypto_session_id_t, crypto_mechanism_t *, crypto_key_t *, 158894b2776Smcpowers crypto_ctx_template_t tmpl, crypto_context_t *, crypto_call_req_t *); 1597c478bd9Sstevel@tonic-gate extern int crypto_verify_recover(crypto_mechanism_t *mech, crypto_key_t *key, 1607c478bd9Sstevel@tonic-gate crypto_data_t *signature, crypto_ctx_template_t tmpl, crypto_data_t *data, 1617c478bd9Sstevel@tonic-gate crypto_call_req_t *cr); 162894b2776Smcpowers extern int crypto_verify_recover_prov(crypto_provider_t, crypto_session_id_t, 163894b2776Smcpowers crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, 164894b2776Smcpowers crypto_ctx_template_t, crypto_data_t *, crypto_call_req_t *); 1657c478bd9Sstevel@tonic-gate 1667c478bd9Sstevel@tonic-gate /* 1677c478bd9Sstevel@tonic-gate * Single and multi-part encryption operations. 1687c478bd9Sstevel@tonic-gate */ 1697c478bd9Sstevel@tonic-gate extern int crypto_encrypt(crypto_mechanism_t *mech, crypto_data_t *plaintext, 1707c478bd9Sstevel@tonic-gate crypto_key_t *key, crypto_ctx_template_t tmpl, crypto_data_t *ciphertext, 1717c478bd9Sstevel@tonic-gate crypto_call_req_t *cr); 172894b2776Smcpowers extern int crypto_encrypt_prov(crypto_provider_t, crypto_session_id_t, 173894b2776Smcpowers crypto_mechanism_t *, crypto_data_t *, crypto_key_t *, 174894b2776Smcpowers crypto_ctx_template_t, crypto_data_t *, crypto_call_req_t *); 1757c478bd9Sstevel@tonic-gate extern int crypto_encrypt_init(crypto_mechanism_t *mech, crypto_key_t *key, 1767c478bd9Sstevel@tonic-gate crypto_ctx_template_t tmpl, crypto_context_t *ctxp, crypto_call_req_t *cr); 177894b2776Smcpowers extern int crypto_encrypt_init_prov(crypto_provider_t, crypto_session_id_t, 178894b2776Smcpowers crypto_mechanism_t *, crypto_key_t *, crypto_ctx_template_t, 179894b2776Smcpowers crypto_context_t *, crypto_call_req_t *); 1807c478bd9Sstevel@tonic-gate extern int crypto_encrypt_update(crypto_context_t ctx, 1817c478bd9Sstevel@tonic-gate crypto_data_t *plaintext, crypto_data_t *ciphertext, 1827c478bd9Sstevel@tonic-gate crypto_call_req_t *cr); 1837c478bd9Sstevel@tonic-gate extern int crypto_encrypt_final(crypto_context_t ctx, 1847c478bd9Sstevel@tonic-gate crypto_data_t *ciphertext, crypto_call_req_t *cr); 1857c478bd9Sstevel@tonic-gate 1867c478bd9Sstevel@tonic-gate /* 1877c478bd9Sstevel@tonic-gate * Single and multi-part decryption operations. 1887c478bd9Sstevel@tonic-gate */ 1897c478bd9Sstevel@tonic-gate extern int crypto_decrypt(crypto_mechanism_t *mech, crypto_data_t *ciphertext, 1907c478bd9Sstevel@tonic-gate crypto_key_t *key, crypto_ctx_template_t tmpl, crypto_data_t *plaintext, 1917c478bd9Sstevel@tonic-gate crypto_call_req_t *cr); 192894b2776Smcpowers extern int crypto_decrypt_prov(crypto_provider_t, crypto_session_id_t, 193894b2776Smcpowers crypto_mechanism_t *, crypto_data_t *, crypto_key_t *, 194894b2776Smcpowers crypto_ctx_template_t, crypto_data_t *, crypto_call_req_t *); 1957c478bd9Sstevel@tonic-gate extern int crypto_decrypt_init(crypto_mechanism_t *mech, crypto_key_t *key, 1967c478bd9Sstevel@tonic-gate crypto_ctx_template_t tmpl, crypto_context_t *ctxp, 1977c478bd9Sstevel@tonic-gate crypto_call_req_t *cr); 198894b2776Smcpowers extern int crypto_decrypt_init_prov(crypto_provider_t, crypto_session_id_t, 199894b2776Smcpowers crypto_mechanism_t *, crypto_key_t *, crypto_ctx_template_t, 200894b2776Smcpowers crypto_context_t *, crypto_call_req_t *); 2017c478bd9Sstevel@tonic-gate extern int crypto_decrypt_update(crypto_context_t ctx, 2027c478bd9Sstevel@tonic-gate crypto_data_t *ciphertext, crypto_data_t *plaintext, 2037c478bd9Sstevel@tonic-gate crypto_call_req_t *cr); 2047c478bd9Sstevel@tonic-gate extern int crypto_decrypt_final(crypto_context_t ctx, crypto_data_t *plaintext, 2057c478bd9Sstevel@tonic-gate crypto_call_req_t *cr); 2067c478bd9Sstevel@tonic-gate 2077c478bd9Sstevel@tonic-gate /* 2087c478bd9Sstevel@tonic-gate * Single and multi-part encrypt/MAC dual operations. 2097c478bd9Sstevel@tonic-gate */ 2107c478bd9Sstevel@tonic-gate extern int crypto_encrypt_mac(crypto_mechanism_t *encr_mech, 2117c478bd9Sstevel@tonic-gate crypto_mechanism_t *mac_mech, crypto_data_t *pt, 2127c478bd9Sstevel@tonic-gate crypto_key_t *encr_key, crypto_key_t *mac_key, 2137c478bd9Sstevel@tonic-gate crypto_ctx_template_t encr_tmpl, crypto_ctx_template_t mac_tmpl, 2147c478bd9Sstevel@tonic-gate crypto_dual_data_t *ct, crypto_data_t *mac, crypto_call_req_t *cr); 215894b2776Smcpowers extern int crypto_encrypt_mac_prov(crypto_provider_t, crypto_session_id_t, 216894b2776Smcpowers crypto_mechanism_t *, crypto_mechanism_t *, crypto_data_t *, 217894b2776Smcpowers crypto_key_t *, crypto_key_t *, crypto_ctx_template_t, 218894b2776Smcpowers crypto_ctx_template_t, crypto_dual_data_t *, crypto_data_t *, 219894b2776Smcpowers crypto_call_req_t *); 2207c478bd9Sstevel@tonic-gate extern int crypto_encrypt_mac_init(crypto_mechanism_t *encr_mech, 2217c478bd9Sstevel@tonic-gate crypto_mechanism_t *mac_mech, crypto_key_t *encr_key, 2227c478bd9Sstevel@tonic-gate crypto_key_t *mac_key, crypto_ctx_template_t encr_tmpl, 2237c478bd9Sstevel@tonic-gate crypto_ctx_template_t mac_tmpl, crypto_context_t *ctxp, 2247c478bd9Sstevel@tonic-gate crypto_call_req_t *cr); 225894b2776Smcpowers extern int crypto_encrypt_mac_init_prov(crypto_provider_t, crypto_session_id_t, 226894b2776Smcpowers crypto_mechanism_t *, crypto_mechanism_t *, crypto_key_t *, crypto_key_t *, 227894b2776Smcpowers crypto_ctx_template_t, crypto_ctx_template_t, crypto_context_t *, 228894b2776Smcpowers crypto_call_req_t *); 2297c478bd9Sstevel@tonic-gate extern int crypto_encrypt_mac_update(crypto_context_t ctx, 2307c478bd9Sstevel@tonic-gate crypto_data_t *pt, crypto_dual_data_t *ct, crypto_call_req_t *cr); 2317c478bd9Sstevel@tonic-gate extern int crypto_encrypt_mac_final(crypto_context_t ctx, 2327c478bd9Sstevel@tonic-gate crypto_dual_data_t *ct, crypto_data_t *mac, crypto_call_req_t *cr); 2337c478bd9Sstevel@tonic-gate 2347c478bd9Sstevel@tonic-gate /* 2357c478bd9Sstevel@tonic-gate * Single and multi-part MAC/decrypt dual operations. 2367c478bd9Sstevel@tonic-gate */ 2377c478bd9Sstevel@tonic-gate extern int crypto_mac_decrypt(crypto_mechanism_t *mac_mech, 2387c478bd9Sstevel@tonic-gate crypto_mechanism_t *decr_mech, crypto_dual_data_t *ct, 2397c478bd9Sstevel@tonic-gate crypto_key_t *mac_key, crypto_key_t *decr_key, 2407c478bd9Sstevel@tonic-gate crypto_ctx_template_t mac_tmpl, crypto_ctx_template_t decr_tmpl, 2417c478bd9Sstevel@tonic-gate crypto_data_t *mac, crypto_data_t *pt, crypto_call_req_t *cr); 242894b2776Smcpowers extern int crypto_mac_decrypt_prov(crypto_provider_t, crypto_session_id_t, 243894b2776Smcpowers crypto_mechanism_t *mac_mech, crypto_mechanism_t *decr_mech, 244894b2776Smcpowers crypto_dual_data_t *ct, crypto_key_t *mac_key, crypto_key_t *decr_key, 245894b2776Smcpowers crypto_ctx_template_t mac_tmpl, crypto_ctx_template_t decr_tmpl, 246894b2776Smcpowers crypto_data_t *mac, crypto_data_t *pt, crypto_call_req_t *cr); 2477c478bd9Sstevel@tonic-gate extern int crypto_mac_verify_decrypt(crypto_mechanism_t *mac_mech, 2487c478bd9Sstevel@tonic-gate crypto_mechanism_t *decr_mech, crypto_dual_data_t *ct, 2497c478bd9Sstevel@tonic-gate crypto_key_t *mac_key, crypto_key_t *decr_key, 2507c478bd9Sstevel@tonic-gate crypto_ctx_template_t mac_tmpl, crypto_ctx_template_t decr_tmpl, 2517c478bd9Sstevel@tonic-gate crypto_data_t *mac, crypto_data_t *pt, crypto_call_req_t *cr); 252894b2776Smcpowers extern int crypto_mac_verify_decrypt_prov(crypto_provider_t, 253894b2776Smcpowers crypto_session_id_t, crypto_mechanism_t *mac_mech, 254894b2776Smcpowers crypto_mechanism_t *decr_mech, crypto_dual_data_t *ct, 255894b2776Smcpowers crypto_key_t *mac_key, crypto_key_t *decr_key, 256894b2776Smcpowers crypto_ctx_template_t mac_tmpl, crypto_ctx_template_t decr_tmpl, 257894b2776Smcpowers crypto_data_t *mac, crypto_data_t *pt, crypto_call_req_t *cr); 2587c478bd9Sstevel@tonic-gate extern int crypto_mac_decrypt_init(crypto_mechanism_t *mac_mech, 2597c478bd9Sstevel@tonic-gate crypto_mechanism_t *decr_mech, crypto_key_t *mac_key, 2607c478bd9Sstevel@tonic-gate crypto_key_t *decr_key, crypto_ctx_template_t mac_tmpl, 2617c478bd9Sstevel@tonic-gate crypto_ctx_template_t decr_tmpl, crypto_context_t *ctxp, 2627c478bd9Sstevel@tonic-gate crypto_call_req_t *cr); 263894b2776Smcpowers extern int crypto_mac_decrypt_init_prov(crypto_provider_t, 264894b2776Smcpowers crypto_session_id_t, crypto_mechanism_t *mac_mech, 265894b2776Smcpowers crypto_mechanism_t *decr_mech, crypto_key_t *mac_key, 266894b2776Smcpowers crypto_key_t *decr_key, crypto_ctx_template_t mac_tmpl, 267894b2776Smcpowers crypto_ctx_template_t decr_tmpl, crypto_context_t *ctxp, 268894b2776Smcpowers crypto_call_req_t *cr); 2697c478bd9Sstevel@tonic-gate extern int crypto_mac_decrypt_update(crypto_context_t ctx, 2707c478bd9Sstevel@tonic-gate crypto_dual_data_t *ct, crypto_data_t *pt, crypto_call_req_t *cr); 2717c478bd9Sstevel@tonic-gate extern int crypto_mac_decrypt_final(crypto_context_t ctx, crypto_data_t *mac, 2727c478bd9Sstevel@tonic-gate crypto_data_t *pt, crypto_call_req_t *cr); 2737c478bd9Sstevel@tonic-gate 274894b2776Smcpowers /* Session Management */ 275894b2776Smcpowers extern int crypto_session_open(crypto_provider_t, crypto_session_id_t *, 276894b2776Smcpowers crypto_call_req_t *); 277894b2776Smcpowers extern int crypto_session_close(crypto_provider_t, crypto_session_id_t, 278894b2776Smcpowers crypto_call_req_t *); 279894b2776Smcpowers extern int crypto_session_login(crypto_provider_t, crypto_session_id_t, 280894b2776Smcpowers crypto_user_type_t, char *, size_t, crypto_call_req_t *); 281894b2776Smcpowers extern int crypto_session_logout(crypto_provider_t, crypto_session_id_t, 282894b2776Smcpowers crypto_call_req_t *); 283894b2776Smcpowers 284894b2776Smcpowers /* Object Management */ 285894b2776Smcpowers extern int crypto_object_copy(crypto_provider_t, crypto_session_id_t, 286894b2776Smcpowers crypto_object_id_t, crypto_object_attribute_t *, uint_t, 287894b2776Smcpowers crypto_object_id_t *, crypto_call_req_t *); 288894b2776Smcpowers extern int crypto_object_create(crypto_provider_t, crypto_session_id_t, 289894b2776Smcpowers crypto_object_attribute_t *, uint_t, crypto_object_id_t *, 290894b2776Smcpowers crypto_call_req_t *); 291894b2776Smcpowers extern int crypto_object_destroy(crypto_provider_t, crypto_session_id_t, 292894b2776Smcpowers crypto_object_id_t, crypto_call_req_t *); 293894b2776Smcpowers extern int crypto_object_get_attribute_value(crypto_provider_t, 294894b2776Smcpowers crypto_session_id_t, crypto_object_id_t, crypto_object_attribute_t *, 295894b2776Smcpowers uint_t, crypto_call_req_t *); 296894b2776Smcpowers extern int crypto_object_get_size(crypto_provider_t, crypto_session_id_t, 297894b2776Smcpowers crypto_object_id_t, size_t *, crypto_call_req_t *); 298894b2776Smcpowers extern int crypto_object_find_final(crypto_provider_t, void *, 299894b2776Smcpowers crypto_call_req_t *); 300894b2776Smcpowers extern int crypto_object_find_init(crypto_provider_t, crypto_session_id_t, 301894b2776Smcpowers crypto_object_attribute_t *, uint_t, void **, crypto_call_req_t *); 302894b2776Smcpowers extern int crypto_object_find(crypto_provider_t, void *, crypto_object_id_t *, 303894b2776Smcpowers uint_t *, uint_t, crypto_call_req_t *); 304894b2776Smcpowers extern int crypto_object_set_attribute_value(crypto_provider_t, 305894b2776Smcpowers crypto_session_id_t, crypto_object_id_t, crypto_object_attribute_t *, 306894b2776Smcpowers uint_t, crypto_call_req_t *); 307894b2776Smcpowers 308894b2776Smcpowers /* Key Management */ 309894b2776Smcpowers extern int crypto_key_derive(crypto_provider_t, crypto_session_id_t, 310894b2776Smcpowers crypto_mechanism_t *, crypto_key_t *, crypto_object_attribute_t *, 311894b2776Smcpowers uint_t, crypto_object_id_t *, crypto_call_req_t *); 312894b2776Smcpowers extern int crypto_key_generate(crypto_provider_t, crypto_session_id_t, 313894b2776Smcpowers crypto_mechanism_t *, crypto_object_attribute_t *, uint_t, 314894b2776Smcpowers crypto_object_id_t *, crypto_call_req_t *); 315894b2776Smcpowers extern int crypto_key_generate_pair(crypto_provider_t, crypto_session_id_t, 316894b2776Smcpowers crypto_mechanism_t *, crypto_object_attribute_t *, uint_t, 317894b2776Smcpowers crypto_object_attribute_t *, uint_t, crypto_object_id_t *, 318894b2776Smcpowers crypto_object_id_t *, crypto_call_req_t *); 319894b2776Smcpowers extern int crypto_key_unwrap(crypto_provider_t, crypto_session_id_t, 320894b2776Smcpowers crypto_mechanism_t *, crypto_key_t *, uchar_t *, size_t *, 321894b2776Smcpowers crypto_object_attribute_t *, uint_t, crypto_object_id_t *, 322894b2776Smcpowers crypto_call_req_t *); 323894b2776Smcpowers extern int crypto_key_wrap(crypto_provider_t, crypto_session_id_t, 324894b2776Smcpowers crypto_mechanism_t *, crypto_key_t *, crypto_object_id_t *, uchar_t *, 325894b2776Smcpowers size_t *, crypto_call_req_t *); 326894b2776Smcpowers extern int crypto_key_check_prov(crypto_provider_t, crypto_mechanism_t *mech, 327894b2776Smcpowers crypto_key_t *key); 328894b2776Smcpowers extern int crypto_key_check(crypto_mechanism_t *mech, crypto_key_t *key); 329894b2776Smcpowers 330894b2776Smcpowers 3317c478bd9Sstevel@tonic-gate /* 3327c478bd9Sstevel@tonic-gate * Routines to cancel a single asynchronous request or all asynchronous 3337c478bd9Sstevel@tonic-gate * requests associated with a particular context. 3347c478bd9Sstevel@tonic-gate */ 3357c478bd9Sstevel@tonic-gate extern void crypto_cancel_req(crypto_req_id_t req); 3367c478bd9Sstevel@tonic-gate extern void crypto_cancel_ctx(crypto_context_t ctx); 3377c478bd9Sstevel@tonic-gate 3387c478bd9Sstevel@tonic-gate /* 3397c478bd9Sstevel@tonic-gate * crypto_get_mech_list(9F) allocates and returns the list of currently 3407c478bd9Sstevel@tonic-gate * supported cryptographic mechanisms. 3417c478bd9Sstevel@tonic-gate */ 3427c478bd9Sstevel@tonic-gate extern crypto_mech_name_t *crypto_get_mech_list(uint_t *count, int kmflag); 3437c478bd9Sstevel@tonic-gate extern void crypto_free_mech_list(crypto_mech_name_t *mech_names, 3447c478bd9Sstevel@tonic-gate uint_t count); 3457c478bd9Sstevel@tonic-gate 346894b2776Smcpowers extern crypto_provider_t crypto_get_provider(char *, char *, char *); 347c892ebf1Skrishna extern int crypto_get_provinfo(crypto_provider_t, crypto_provider_ext_info_t *); 348894b2776Smcpowers extern void crypto_release_provider(crypto_provider_t); 349894b2776Smcpowers 3507c478bd9Sstevel@tonic-gate /* 3517c478bd9Sstevel@tonic-gate * A kernel consumer can request to be notified when some particular event 3527c478bd9Sstevel@tonic-gate * occurs. The valid events, callback function type, and functions to 3537c478bd9Sstevel@tonic-gate * be called to register or unregister for notification are defined below. 3547c478bd9Sstevel@tonic-gate */ 3557c478bd9Sstevel@tonic-gate 356c892ebf1Skrishna #define CRYPTO_EVENT_MECHS_CHANGED 0x00000001 357c892ebf1Skrishna #define CRYPTO_EVENT_PROVIDER_REGISTERED 0x00000002 358c892ebf1Skrishna #define CRYPTO_EVENT_PROVIDER_UNREGISTERED 0x00000004 3597c478bd9Sstevel@tonic-gate 360c892ebf1Skrishna typedef enum { 361c892ebf1Skrishna CRYPTO_MECH_ADDED = 1, 362c892ebf1Skrishna CRYPTO_MECH_REMOVED 3637c478bd9Sstevel@tonic-gate } crypto_event_change_t; 3647c478bd9Sstevel@tonic-gate 3657c478bd9Sstevel@tonic-gate /* The event_arg argument structure for CRYPTO_EVENT_PROVIDERS_CHANGE event */ 3667c478bd9Sstevel@tonic-gate typedef struct crypto_notify_event_change { 3677c478bd9Sstevel@tonic-gate crypto_mech_name_t ec_mech_name; 3687c478bd9Sstevel@tonic-gate crypto_provider_type_t ec_provider_type; 3697c478bd9Sstevel@tonic-gate crypto_event_change_t ec_change; 3707c478bd9Sstevel@tonic-gate } crypto_notify_event_change_t; 3717c478bd9Sstevel@tonic-gate 3727c478bd9Sstevel@tonic-gate typedef void *crypto_notify_handle_t; 3737c478bd9Sstevel@tonic-gate typedef void (*crypto_notify_callback_t)(uint32_t event_mask, void *event_arg); 3747c478bd9Sstevel@tonic-gate 3757c478bd9Sstevel@tonic-gate extern crypto_notify_handle_t crypto_notify_events( 3767c478bd9Sstevel@tonic-gate crypto_notify_callback_t nf, uint32_t event_mask); 3777c478bd9Sstevel@tonic-gate extern void crypto_unnotify_events(crypto_notify_handle_t); 3787c478bd9Sstevel@tonic-gate 3797c478bd9Sstevel@tonic-gate /* 3807c478bd9Sstevel@tonic-gate * crypto_bufcall(9F) group of routines. 3817c478bd9Sstevel@tonic-gate */ 3827c478bd9Sstevel@tonic-gate extern crypto_bc_t crypto_bufcall_alloc(void); 3837c478bd9Sstevel@tonic-gate extern int crypto_bufcall_free(crypto_bc_t bc); 3847c478bd9Sstevel@tonic-gate extern int crypto_bufcall(crypto_bc_t bc, void (*func)(void *arg), void *arg); 3857c478bd9Sstevel@tonic-gate extern int crypto_unbufcall(crypto_bc_t bc); 3867c478bd9Sstevel@tonic-gate 3877c478bd9Sstevel@tonic-gate /* 3887c478bd9Sstevel@tonic-gate * To obtain the list of key size ranges supported by a mechanism. 3897c478bd9Sstevel@tonic-gate */ 3907c478bd9Sstevel@tonic-gate 3917c478bd9Sstevel@tonic-gate #define CRYPTO_MECH_USAGE_ENCRYPT 0x00000001 3927c478bd9Sstevel@tonic-gate #define CRYPTO_MECH_USAGE_DECRYPT 0x00000002 3937c478bd9Sstevel@tonic-gate #define CRYPTO_MECH_USAGE_MAC 0x00000004 3947c478bd9Sstevel@tonic-gate 3957c478bd9Sstevel@tonic-gate typedef uint32_t crypto_mech_usage_t; 3967c478bd9Sstevel@tonic-gate 3977c478bd9Sstevel@tonic-gate typedef struct crypto_mechanism_info { 3987c478bd9Sstevel@tonic-gate size_t mi_min_key_size; 3997c478bd9Sstevel@tonic-gate size_t mi_max_key_size; 4007c478bd9Sstevel@tonic-gate crypto_keysize_unit_t mi_keysize_unit; /* for mi_xxx_key_size */ 4017c478bd9Sstevel@tonic-gate crypto_mech_usage_t mi_usage; 4027c478bd9Sstevel@tonic-gate } crypto_mechanism_info_t; 4037c478bd9Sstevel@tonic-gate 4047d82f0f8SDina K Nimeh #ifdef _SYSCALL32 4057d82f0f8SDina K Nimeh 4067d82f0f8SDina K Nimeh typedef struct crypto_mechanism_info32 { 4077d82f0f8SDina K Nimeh size32_t mi_min_key_size; 4087d82f0f8SDina K Nimeh size32_t mi_max_key_size; 4097d82f0f8SDina K Nimeh crypto_keysize_unit_t mi_keysize_unit; /* for mi_xxx_key_size */ 4107d82f0f8SDina K Nimeh crypto_mech_usage_t mi_usage; 4117d82f0f8SDina K Nimeh } crypto_mechanism_info32_t; 4127d82f0f8SDina K Nimeh 4137d82f0f8SDina K Nimeh #endif /* _SYSCALL32 */ 4147d82f0f8SDina K Nimeh 4157c478bd9Sstevel@tonic-gate extern int crypto_get_all_mech_info(crypto_mech_type_t, 4167c478bd9Sstevel@tonic-gate crypto_mechanism_info_t **, uint_t *, int); 4177d82f0f8SDina K Nimeh extern void crypto_free_all_mech_info(crypto_mechanism_info_t *, uint_t); 4187c478bd9Sstevel@tonic-gate 4197c478bd9Sstevel@tonic-gate #ifdef __cplusplus 4207c478bd9Sstevel@tonic-gate } 4217c478bd9Sstevel@tonic-gate #endif 4227c478bd9Sstevel@tonic-gate 4237c478bd9Sstevel@tonic-gate #endif /* _SYS_CRYPTO_API_H */ 424