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 58047c9fbSmcpowers * Common Development and Distribution License (the "License"). 68047c9fbSmcpowers * 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 /* 2273556491SAnthony Scarpino * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_CRYPTO_SPI_H 277c478bd9Sstevel@tonic-gate #define _SYS_CRYPTO_SPI_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate /* 307c478bd9Sstevel@tonic-gate * CSPI: Cryptographic Service Provider Interface. 317c478bd9Sstevel@tonic-gate */ 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include <sys/types.h> 347c478bd9Sstevel@tonic-gate #include <sys/dditypes.h> 357c478bd9Sstevel@tonic-gate #include <sys/ddi.h> 367c478bd9Sstevel@tonic-gate #include <sys/kmem.h> 377c478bd9Sstevel@tonic-gate #include <sys/crypto/common.h> 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #ifdef __cplusplus 407c478bd9Sstevel@tonic-gate extern "C" { 417c478bd9Sstevel@tonic-gate #endif 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #ifdef _KERNEL 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate #define CRYPTO_SPI_VERSION_1 1 46894b2776Smcpowers #define CRYPTO_SPI_VERSION_2 2 47034448feSmcpowers #define CRYPTO_SPI_VERSION_3 3 4873556491SAnthony Scarpino #define CRYPTO_SPI_VERSION_4 4 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate /* 517c478bd9Sstevel@tonic-gate * Provider-private handle. This handle is specified by a provider 527c478bd9Sstevel@tonic-gate * when it registers by means of the pi_provider_handle field of 537c478bd9Sstevel@tonic-gate * the crypto_provider_info structure, and passed to the provider 547c478bd9Sstevel@tonic-gate * when its entry points are invoked. 557c478bd9Sstevel@tonic-gate */ 567c478bd9Sstevel@tonic-gate typedef void *crypto_provider_handle_t; 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate /* 597c478bd9Sstevel@tonic-gate * Context templates can be used to by software providers to pre-process 607c478bd9Sstevel@tonic-gate * keying material, such as key schedules. They are allocated by 617c478bd9Sstevel@tonic-gate * a software provider create_ctx_template(9E) entry point, and passed 627c478bd9Sstevel@tonic-gate * as argument to initialization and atomic provider entry points. 637c478bd9Sstevel@tonic-gate */ 647c478bd9Sstevel@tonic-gate typedef void *crypto_spi_ctx_template_t; 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate /* 677c478bd9Sstevel@tonic-gate * Request handles are used by the kernel to identify an asynchronous 687c478bd9Sstevel@tonic-gate * request being processed by a provider. It is passed by the kernel 697c478bd9Sstevel@tonic-gate * to a hardware provider when submitting a request, and must be 707c478bd9Sstevel@tonic-gate * specified by a provider when calling crypto_op_notification(9F) 717c478bd9Sstevel@tonic-gate */ 727c478bd9Sstevel@tonic-gate typedef void *crypto_req_handle_t; 737c478bd9Sstevel@tonic-gate 746a1073f8Skrishna /* Values for cc_flags field */ 756a1073f8Skrishna #define CRYPTO_INIT_OPSTATE 0x00000001 /* allocate and init cc_opstate */ 766a1073f8Skrishna #define CRYPTO_USE_OPSTATE 0x00000002 /* .. start using it as context */ 776a1073f8Skrishna 787c478bd9Sstevel@tonic-gate /* 797c478bd9Sstevel@tonic-gate * The context structure is passed from the kernel to a provider. 807c478bd9Sstevel@tonic-gate * It contains the information needed to process a multi-part or 817c478bd9Sstevel@tonic-gate * single part operation. The context structure is not used 827c478bd9Sstevel@tonic-gate * by atomic operations. 837c478bd9Sstevel@tonic-gate * 847c478bd9Sstevel@tonic-gate * Parameters needed to perform a cryptographic operation, such 857c478bd9Sstevel@tonic-gate * as keys, mechanisms, input and output buffers, are passed 867c478bd9Sstevel@tonic-gate * as separate arguments to Provider routines. 877c478bd9Sstevel@tonic-gate */ 887c478bd9Sstevel@tonic-gate typedef struct crypto_ctx { 897c478bd9Sstevel@tonic-gate crypto_provider_handle_t cc_provider; 907c478bd9Sstevel@tonic-gate crypto_session_id_t cc_session; 917c478bd9Sstevel@tonic-gate void *cc_provider_private; /* owned by provider */ 927c478bd9Sstevel@tonic-gate void *cc_framework_private; /* owned by framework */ 936a1073f8Skrishna uint32_t cc_flags; /* flags */ 946a1073f8Skrishna void *cc_opstate; /* state */ 957c478bd9Sstevel@tonic-gate } crypto_ctx_t; 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate /* 987c478bd9Sstevel@tonic-gate * Extended provider information. 997c478bd9Sstevel@tonic-gate */ 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate /* 1027c478bd9Sstevel@tonic-gate * valid values for ei_flags field of extended info structure 1037c478bd9Sstevel@tonic-gate * They match the RSA Security, Inc PKCS#11 tokenInfo flags. 1047c478bd9Sstevel@tonic-gate */ 1057c478bd9Sstevel@tonic-gate #define CRYPTO_EXTF_RNG 0x00000001 1067c478bd9Sstevel@tonic-gate #define CRYPTO_EXTF_WRITE_PROTECTED 0x00000002 1077c478bd9Sstevel@tonic-gate #define CRYPTO_EXTF_LOGIN_REQUIRED 0x00000004 1087c478bd9Sstevel@tonic-gate #define CRYPTO_EXTF_USER_PIN_INITIALIZED 0x00000008 1097c478bd9Sstevel@tonic-gate #define CRYPTO_EXTF_CLOCK_ON_TOKEN 0x00000040 1107c478bd9Sstevel@tonic-gate #define CRYPTO_EXTF_PROTECTED_AUTHENTICATION_PATH 0x00000100 1117c478bd9Sstevel@tonic-gate #define CRYPTO_EXTF_DUAL_CRYPTO_OPERATIONS 0x00000200 1127c478bd9Sstevel@tonic-gate #define CRYPTO_EXTF_TOKEN_INITIALIZED 0x00000400 1137c478bd9Sstevel@tonic-gate #define CRYPTO_EXTF_USER_PIN_COUNT_LOW 0x00010000 1147c478bd9Sstevel@tonic-gate #define CRYPTO_EXTF_USER_PIN_FINAL_TRY 0x00020000 1157c478bd9Sstevel@tonic-gate #define CRYPTO_EXTF_USER_PIN_LOCKED 0x00040000 1167c478bd9Sstevel@tonic-gate #define CRYPTO_EXTF_USER_PIN_TO_BE_CHANGED 0x00080000 1177c478bd9Sstevel@tonic-gate #define CRYPTO_EXTF_SO_PIN_COUNT_LOW 0x00100000 1187c478bd9Sstevel@tonic-gate #define CRYPTO_EXTF_SO_PIN_FINAL_TRY 0x00200000 1197c478bd9Sstevel@tonic-gate #define CRYPTO_EXTF_SO_PIN_LOCKED 0x00400000 1207c478bd9Sstevel@tonic-gate #define CRYPTO_EXTF_SO_PIN_TO_BE_CHANGED 0x00800000 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate /* 1237c478bd9Sstevel@tonic-gate * The crypto_control_ops structure contains pointers to control 1247c478bd9Sstevel@tonic-gate * operations for cryptographic providers. It is passed through 1257c478bd9Sstevel@tonic-gate * the crypto_ops(9S) structure when providers register with the 1267c478bd9Sstevel@tonic-gate * kernel using crypto_register_provider(9F). 1277c478bd9Sstevel@tonic-gate */ 1287c478bd9Sstevel@tonic-gate typedef struct crypto_control_ops { 1297c478bd9Sstevel@tonic-gate void (*provider_status)(crypto_provider_handle_t, uint_t *); 1307c478bd9Sstevel@tonic-gate } crypto_control_ops_t; 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gate /* 1337c478bd9Sstevel@tonic-gate * The crypto_ctx_ops structure contains points to context and context 1347c478bd9Sstevel@tonic-gate * templates management operations for cryptographic providers. It is 1357c478bd9Sstevel@tonic-gate * passed through the crypto_ops(9S) structure when providers register 1367c478bd9Sstevel@tonic-gate * with the kernel using crypto_register_provider(9F). 1377c478bd9Sstevel@tonic-gate */ 1387c478bd9Sstevel@tonic-gate typedef struct crypto_ctx_ops { 1397c478bd9Sstevel@tonic-gate int (*create_ctx_template)(crypto_provider_handle_t, 1407c478bd9Sstevel@tonic-gate crypto_mechanism_t *, crypto_key_t *, 1417c478bd9Sstevel@tonic-gate crypto_spi_ctx_template_t *, size_t *, crypto_req_handle_t); 1427c478bd9Sstevel@tonic-gate int (*free_context)(crypto_ctx_t *); 1437c478bd9Sstevel@tonic-gate } crypto_ctx_ops_t; 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate /* 1467c478bd9Sstevel@tonic-gate * The crypto_digest_ops structure contains pointers to digest 1477c478bd9Sstevel@tonic-gate * operations for cryptographic providers. It is passed through 1487c478bd9Sstevel@tonic-gate * the crypto_ops(9S) structure when providers register with the 1497c478bd9Sstevel@tonic-gate * kernel using crypto_register_provider(9F). 1507c478bd9Sstevel@tonic-gate */ 1517c478bd9Sstevel@tonic-gate typedef struct crypto_digest_ops { 1527c478bd9Sstevel@tonic-gate int (*digest_init)(crypto_ctx_t *, crypto_mechanism_t *, 1537c478bd9Sstevel@tonic-gate crypto_req_handle_t); 1547c478bd9Sstevel@tonic-gate int (*digest)(crypto_ctx_t *, crypto_data_t *, crypto_data_t *, 1557c478bd9Sstevel@tonic-gate crypto_req_handle_t); 1567c478bd9Sstevel@tonic-gate int (*digest_update)(crypto_ctx_t *, crypto_data_t *, 1577c478bd9Sstevel@tonic-gate crypto_req_handle_t); 1587c478bd9Sstevel@tonic-gate int (*digest_key)(crypto_ctx_t *, crypto_key_t *, crypto_req_handle_t); 1597c478bd9Sstevel@tonic-gate int (*digest_final)(crypto_ctx_t *, crypto_data_t *, 1607c478bd9Sstevel@tonic-gate crypto_req_handle_t); 1617c478bd9Sstevel@tonic-gate int (*digest_atomic)(crypto_provider_handle_t, crypto_session_id_t, 1627c478bd9Sstevel@tonic-gate crypto_mechanism_t *, crypto_data_t *, 1637c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_req_handle_t); 1647c478bd9Sstevel@tonic-gate } crypto_digest_ops_t; 1657c478bd9Sstevel@tonic-gate 1667c478bd9Sstevel@tonic-gate /* 1677c478bd9Sstevel@tonic-gate * The crypto_cipher_ops structure contains pointers to encryption 1687c478bd9Sstevel@tonic-gate * and decryption operations for cryptographic providers. It is 1697c478bd9Sstevel@tonic-gate * passed through the crypto_ops(9S) structure when providers register 1707c478bd9Sstevel@tonic-gate * with the kernel using crypto_register_provider(9F). 1717c478bd9Sstevel@tonic-gate */ 1727c478bd9Sstevel@tonic-gate typedef struct crypto_cipher_ops { 1737c478bd9Sstevel@tonic-gate int (*encrypt_init)(crypto_ctx_t *, 1747c478bd9Sstevel@tonic-gate crypto_mechanism_t *, crypto_key_t *, 1757c478bd9Sstevel@tonic-gate crypto_spi_ctx_template_t, crypto_req_handle_t); 1767c478bd9Sstevel@tonic-gate int (*encrypt)(crypto_ctx_t *, 1777c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_data_t *, crypto_req_handle_t); 1787c478bd9Sstevel@tonic-gate int (*encrypt_update)(crypto_ctx_t *, 1797c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_data_t *, crypto_req_handle_t); 1807c478bd9Sstevel@tonic-gate int (*encrypt_final)(crypto_ctx_t *, 1817c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_req_handle_t); 1827c478bd9Sstevel@tonic-gate int (*encrypt_atomic)(crypto_provider_handle_t, crypto_session_id_t, 1837c478bd9Sstevel@tonic-gate crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, 1847c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_spi_ctx_template_t, crypto_req_handle_t); 1857c478bd9Sstevel@tonic-gate 1867c478bd9Sstevel@tonic-gate int (*decrypt_init)(crypto_ctx_t *, 1877c478bd9Sstevel@tonic-gate crypto_mechanism_t *, crypto_key_t *, 1887c478bd9Sstevel@tonic-gate crypto_spi_ctx_template_t, crypto_req_handle_t); 1897c478bd9Sstevel@tonic-gate int (*decrypt)(crypto_ctx_t *, 1907c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_data_t *, crypto_req_handle_t); 1917c478bd9Sstevel@tonic-gate int (*decrypt_update)(crypto_ctx_t *, 1927c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_data_t *, crypto_req_handle_t); 1937c478bd9Sstevel@tonic-gate int (*decrypt_final)(crypto_ctx_t *, 1947c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_req_handle_t); 1957c478bd9Sstevel@tonic-gate int (*decrypt_atomic)(crypto_provider_handle_t, crypto_session_id_t, 1967c478bd9Sstevel@tonic-gate crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, 1977c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_spi_ctx_template_t, crypto_req_handle_t); 1987c478bd9Sstevel@tonic-gate } crypto_cipher_ops_t; 1997c478bd9Sstevel@tonic-gate 2007c478bd9Sstevel@tonic-gate /* 2017c478bd9Sstevel@tonic-gate * The crypto_mac_ops structure contains pointers to MAC 2027c478bd9Sstevel@tonic-gate * operations for cryptographic providers. It is passed through 2037c478bd9Sstevel@tonic-gate * the crypto_ops(9S) structure when providers register with the 2047c478bd9Sstevel@tonic-gate * kernel using crypto_register_provider(9F). 2057c478bd9Sstevel@tonic-gate */ 2067c478bd9Sstevel@tonic-gate typedef struct crypto_mac_ops { 2077c478bd9Sstevel@tonic-gate int (*mac_init)(crypto_ctx_t *, 2087c478bd9Sstevel@tonic-gate crypto_mechanism_t *, crypto_key_t *, 2097c478bd9Sstevel@tonic-gate crypto_spi_ctx_template_t, crypto_req_handle_t); 2107c478bd9Sstevel@tonic-gate int (*mac)(crypto_ctx_t *, 2117c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_data_t *, crypto_req_handle_t); 2127c478bd9Sstevel@tonic-gate int (*mac_update)(crypto_ctx_t *, 2137c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_req_handle_t); 2147c478bd9Sstevel@tonic-gate int (*mac_final)(crypto_ctx_t *, 2157c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_req_handle_t); 2167c478bd9Sstevel@tonic-gate int (*mac_atomic)(crypto_provider_handle_t, crypto_session_id_t, 2177c478bd9Sstevel@tonic-gate crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, 2187c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_spi_ctx_template_t, 2197c478bd9Sstevel@tonic-gate crypto_req_handle_t); 2207c478bd9Sstevel@tonic-gate int (*mac_verify_atomic)(crypto_provider_handle_t, crypto_session_id_t, 2217c478bd9Sstevel@tonic-gate crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, 2227c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_spi_ctx_template_t, 2237c478bd9Sstevel@tonic-gate crypto_req_handle_t); 2247c478bd9Sstevel@tonic-gate } crypto_mac_ops_t; 2257c478bd9Sstevel@tonic-gate 2267c478bd9Sstevel@tonic-gate /* 2277c478bd9Sstevel@tonic-gate * The crypto_sign_ops structure contains pointers to signing 2287c478bd9Sstevel@tonic-gate * operations for cryptographic providers. It is passed through 2297c478bd9Sstevel@tonic-gate * the crypto_ops(9S) structure when providers register with the 2307c478bd9Sstevel@tonic-gate * kernel using crypto_register_provider(9F). 2317c478bd9Sstevel@tonic-gate */ 2327c478bd9Sstevel@tonic-gate typedef struct crypto_sign_ops { 2337c478bd9Sstevel@tonic-gate int (*sign_init)(crypto_ctx_t *, 2347c478bd9Sstevel@tonic-gate crypto_mechanism_t *, crypto_key_t *, crypto_spi_ctx_template_t, 2357c478bd9Sstevel@tonic-gate crypto_req_handle_t); 2367c478bd9Sstevel@tonic-gate int (*sign)(crypto_ctx_t *, 2377c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_data_t *, crypto_req_handle_t); 2387c478bd9Sstevel@tonic-gate int (*sign_update)(crypto_ctx_t *, 2397c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_req_handle_t); 2407c478bd9Sstevel@tonic-gate int (*sign_final)(crypto_ctx_t *, 2417c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_req_handle_t); 2427c478bd9Sstevel@tonic-gate int (*sign_atomic)(crypto_provider_handle_t, crypto_session_id_t, 2437c478bd9Sstevel@tonic-gate crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, 2447c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_spi_ctx_template_t, 2457c478bd9Sstevel@tonic-gate crypto_req_handle_t); 2467c478bd9Sstevel@tonic-gate int (*sign_recover_init)(crypto_ctx_t *, crypto_mechanism_t *, 2477c478bd9Sstevel@tonic-gate crypto_key_t *, crypto_spi_ctx_template_t, 2487c478bd9Sstevel@tonic-gate crypto_req_handle_t); 2497c478bd9Sstevel@tonic-gate int (*sign_recover)(crypto_ctx_t *, 2507c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_data_t *, crypto_req_handle_t); 2517c478bd9Sstevel@tonic-gate int (*sign_recover_atomic)(crypto_provider_handle_t, 2527c478bd9Sstevel@tonic-gate crypto_session_id_t, crypto_mechanism_t *, crypto_key_t *, 2537c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_data_t *, crypto_spi_ctx_template_t, 2547c478bd9Sstevel@tonic-gate crypto_req_handle_t); 2557c478bd9Sstevel@tonic-gate } crypto_sign_ops_t; 2567c478bd9Sstevel@tonic-gate 2577c478bd9Sstevel@tonic-gate /* 2587c478bd9Sstevel@tonic-gate * The crypto_verify_ops structure contains pointers to verify 2597c478bd9Sstevel@tonic-gate * operations for cryptographic providers. It is passed through 2607c478bd9Sstevel@tonic-gate * the crypto_ops(9S) structure when providers register with the 2617c478bd9Sstevel@tonic-gate * kernel using crypto_register_provider(9F). 2627c478bd9Sstevel@tonic-gate */ 2637c478bd9Sstevel@tonic-gate typedef struct crypto_verify_ops { 2647c478bd9Sstevel@tonic-gate int (*verify_init)(crypto_ctx_t *, 2657c478bd9Sstevel@tonic-gate crypto_mechanism_t *, crypto_key_t *, crypto_spi_ctx_template_t, 2667c478bd9Sstevel@tonic-gate crypto_req_handle_t); 2677c478bd9Sstevel@tonic-gate int (*verify)(crypto_ctx_t *, 2687c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_data_t *, crypto_req_handle_t); 2697c478bd9Sstevel@tonic-gate int (*verify_update)(crypto_ctx_t *, 2707c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_req_handle_t); 2717c478bd9Sstevel@tonic-gate int (*verify_final)(crypto_ctx_t *, 2727c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_req_handle_t); 2737c478bd9Sstevel@tonic-gate int (*verify_atomic)(crypto_provider_handle_t, crypto_session_id_t, 2747c478bd9Sstevel@tonic-gate crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, 2757c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_spi_ctx_template_t, 2767c478bd9Sstevel@tonic-gate crypto_req_handle_t); 2777c478bd9Sstevel@tonic-gate int (*verify_recover_init)(crypto_ctx_t *, crypto_mechanism_t *, 2787c478bd9Sstevel@tonic-gate crypto_key_t *, crypto_spi_ctx_template_t, 2797c478bd9Sstevel@tonic-gate crypto_req_handle_t); 2807c478bd9Sstevel@tonic-gate int (*verify_recover)(crypto_ctx_t *, 2817c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_data_t *, crypto_req_handle_t); 2827c478bd9Sstevel@tonic-gate int (*verify_recover_atomic)(crypto_provider_handle_t, 2837c478bd9Sstevel@tonic-gate crypto_session_id_t, crypto_mechanism_t *, crypto_key_t *, 2847c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_data_t *, crypto_spi_ctx_template_t, 2857c478bd9Sstevel@tonic-gate crypto_req_handle_t); 2867c478bd9Sstevel@tonic-gate } crypto_verify_ops_t; 2877c478bd9Sstevel@tonic-gate 2887c478bd9Sstevel@tonic-gate /* 2897c478bd9Sstevel@tonic-gate * The crypto_dual_ops structure contains pointers to dual 2907c478bd9Sstevel@tonic-gate * cipher and sign/verify operations for cryptographic providers. 2917c478bd9Sstevel@tonic-gate * It is passed through the crypto_ops(9S) structure when 2927c478bd9Sstevel@tonic-gate * providers register with the kernel using 2937c478bd9Sstevel@tonic-gate * crypto_register_provider(9F). 2947c478bd9Sstevel@tonic-gate */ 2957c478bd9Sstevel@tonic-gate typedef struct crypto_dual_ops { 2967c478bd9Sstevel@tonic-gate int (*digest_encrypt_update)( 2977c478bd9Sstevel@tonic-gate crypto_ctx_t *, crypto_ctx_t *, crypto_data_t *, 2987c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_req_handle_t); 2997c478bd9Sstevel@tonic-gate int (*decrypt_digest_update)( 3007c478bd9Sstevel@tonic-gate crypto_ctx_t *, crypto_ctx_t *, crypto_data_t *, 3017c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_req_handle_t); 3027c478bd9Sstevel@tonic-gate int (*sign_encrypt_update)( 3037c478bd9Sstevel@tonic-gate crypto_ctx_t *, crypto_ctx_t *, crypto_data_t *, 3047c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_req_handle_t); 3057c478bd9Sstevel@tonic-gate int (*decrypt_verify_update)( 3067c478bd9Sstevel@tonic-gate crypto_ctx_t *, crypto_ctx_t *, crypto_data_t *, 3077c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_req_handle_t); 3087c478bd9Sstevel@tonic-gate } crypto_dual_ops_t; 3097c478bd9Sstevel@tonic-gate 3107c478bd9Sstevel@tonic-gate /* 3117c478bd9Sstevel@tonic-gate * The crypto_dual_cipher_mac_ops structure contains pointers to dual 3127c478bd9Sstevel@tonic-gate * cipher and MAC operations for cryptographic providers. 3137c478bd9Sstevel@tonic-gate * It is passed through the crypto_ops(9S) structure when 3147c478bd9Sstevel@tonic-gate * providers register with the kernel using 3157c478bd9Sstevel@tonic-gate * crypto_register_provider(9F). 3167c478bd9Sstevel@tonic-gate */ 3177c478bd9Sstevel@tonic-gate typedef struct crypto_dual_cipher_mac_ops { 3187c478bd9Sstevel@tonic-gate int (*encrypt_mac_init)(crypto_ctx_t *, 3197c478bd9Sstevel@tonic-gate crypto_mechanism_t *, crypto_key_t *, crypto_mechanism_t *, 3207c478bd9Sstevel@tonic-gate crypto_key_t *, crypto_spi_ctx_template_t, 3217c478bd9Sstevel@tonic-gate crypto_spi_ctx_template_t, crypto_req_handle_t); 3227c478bd9Sstevel@tonic-gate int (*encrypt_mac)(crypto_ctx_t *, 3237c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_dual_data_t *, crypto_data_t *, 3247c478bd9Sstevel@tonic-gate crypto_req_handle_t); 3257c478bd9Sstevel@tonic-gate int (*encrypt_mac_update)(crypto_ctx_t *, 3267c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_dual_data_t *, crypto_req_handle_t); 3277c478bd9Sstevel@tonic-gate int (*encrypt_mac_final)(crypto_ctx_t *, 3287c478bd9Sstevel@tonic-gate crypto_dual_data_t *, crypto_data_t *, crypto_req_handle_t); 3297c478bd9Sstevel@tonic-gate int (*encrypt_mac_atomic)(crypto_provider_handle_t, crypto_session_id_t, 3307c478bd9Sstevel@tonic-gate crypto_mechanism_t *, crypto_key_t *, crypto_mechanism_t *, 3317c478bd9Sstevel@tonic-gate crypto_key_t *, crypto_data_t *, crypto_dual_data_t *, 3327c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_spi_ctx_template_t, 3337c478bd9Sstevel@tonic-gate crypto_spi_ctx_template_t, crypto_req_handle_t); 3347c478bd9Sstevel@tonic-gate 3357c478bd9Sstevel@tonic-gate int (*mac_decrypt_init)(crypto_ctx_t *, 3367c478bd9Sstevel@tonic-gate crypto_mechanism_t *, crypto_key_t *, crypto_mechanism_t *, 3377c478bd9Sstevel@tonic-gate crypto_key_t *, crypto_spi_ctx_template_t, 3387c478bd9Sstevel@tonic-gate crypto_spi_ctx_template_t, crypto_req_handle_t); 3397c478bd9Sstevel@tonic-gate int (*mac_decrypt)(crypto_ctx_t *, 3407c478bd9Sstevel@tonic-gate crypto_dual_data_t *, crypto_data_t *, crypto_data_t *, 3417c478bd9Sstevel@tonic-gate crypto_req_handle_t); 3427c478bd9Sstevel@tonic-gate int (*mac_decrypt_update)(crypto_ctx_t *, 3437c478bd9Sstevel@tonic-gate crypto_dual_data_t *, crypto_data_t *, crypto_req_handle_t); 3447c478bd9Sstevel@tonic-gate int (*mac_decrypt_final)(crypto_ctx_t *, 3457c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_data_t *, crypto_req_handle_t); 3467c478bd9Sstevel@tonic-gate int (*mac_decrypt_atomic)(crypto_provider_handle_t, 3477c478bd9Sstevel@tonic-gate crypto_session_id_t, crypto_mechanism_t *, crypto_key_t *, 3487c478bd9Sstevel@tonic-gate crypto_mechanism_t *, crypto_key_t *, crypto_dual_data_t *, 3497c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_data_t *, crypto_spi_ctx_template_t, 3507c478bd9Sstevel@tonic-gate crypto_spi_ctx_template_t, crypto_req_handle_t); 3517c478bd9Sstevel@tonic-gate int (*mac_verify_decrypt_atomic)(crypto_provider_handle_t, 3527c478bd9Sstevel@tonic-gate crypto_session_id_t, crypto_mechanism_t *, crypto_key_t *, 3537c478bd9Sstevel@tonic-gate crypto_mechanism_t *, crypto_key_t *, crypto_dual_data_t *, 3547c478bd9Sstevel@tonic-gate crypto_data_t *, crypto_data_t *, crypto_spi_ctx_template_t, 3557c478bd9Sstevel@tonic-gate crypto_spi_ctx_template_t, crypto_req_handle_t); 3567c478bd9Sstevel@tonic-gate } crypto_dual_cipher_mac_ops_t; 3577c478bd9Sstevel@tonic-gate 3587c478bd9Sstevel@tonic-gate /* 3597c478bd9Sstevel@tonic-gate * The crypto_random_number_ops structure contains pointers to random 3607c478bd9Sstevel@tonic-gate * number operations for cryptographic providers. It is passed through 3617c478bd9Sstevel@tonic-gate * the crypto_ops(9S) structure when providers register with the 3627c478bd9Sstevel@tonic-gate * kernel using crypto_register_provider(9F). 3637c478bd9Sstevel@tonic-gate */ 3647c478bd9Sstevel@tonic-gate typedef struct crypto_random_number_ops { 3657c478bd9Sstevel@tonic-gate int (*seed_random)(crypto_provider_handle_t, crypto_session_id_t, 3668047c9fbSmcpowers uchar_t *, size_t, uint_t, uint32_t, crypto_req_handle_t); 3677c478bd9Sstevel@tonic-gate int (*generate_random)(crypto_provider_handle_t, crypto_session_id_t, 3687c478bd9Sstevel@tonic-gate uchar_t *, size_t, crypto_req_handle_t); 3697c478bd9Sstevel@tonic-gate } crypto_random_number_ops_t; 3707c478bd9Sstevel@tonic-gate 3717c478bd9Sstevel@tonic-gate /* 3728047c9fbSmcpowers * Flag values for seed_random. 3738047c9fbSmcpowers */ 3748047c9fbSmcpowers #define CRYPTO_SEED_NOW 0x00000001 3758047c9fbSmcpowers 3768047c9fbSmcpowers /* 3777c478bd9Sstevel@tonic-gate * The crypto_session_ops structure contains pointers to session 3787c478bd9Sstevel@tonic-gate * operations for cryptographic providers. It is passed through 3797c478bd9Sstevel@tonic-gate * the crypto_ops(9S) structure when providers register with the 3807c478bd9Sstevel@tonic-gate * kernel using crypto_register_provider(9F). 3817c478bd9Sstevel@tonic-gate */ 3827c478bd9Sstevel@tonic-gate typedef struct crypto_session_ops { 3837c478bd9Sstevel@tonic-gate int (*session_open)(crypto_provider_handle_t, crypto_session_id_t *, 3847c478bd9Sstevel@tonic-gate crypto_req_handle_t); 3857c478bd9Sstevel@tonic-gate int (*session_close)(crypto_provider_handle_t, crypto_session_id_t, 3867c478bd9Sstevel@tonic-gate crypto_req_handle_t); 3877c478bd9Sstevel@tonic-gate int (*session_login)(crypto_provider_handle_t, crypto_session_id_t, 3887c478bd9Sstevel@tonic-gate crypto_user_type_t, char *, size_t, crypto_req_handle_t); 3897c478bd9Sstevel@tonic-gate int (*session_logout)(crypto_provider_handle_t, crypto_session_id_t, 3907c478bd9Sstevel@tonic-gate crypto_req_handle_t); 3917c478bd9Sstevel@tonic-gate } crypto_session_ops_t; 3927c478bd9Sstevel@tonic-gate 3937c478bd9Sstevel@tonic-gate /* 3947c478bd9Sstevel@tonic-gate * The crypto_object_ops structure contains pointers to object 3957c478bd9Sstevel@tonic-gate * operations for cryptographic providers. It is passed through 3967c478bd9Sstevel@tonic-gate * the crypto_ops(9S) structure when providers register with the 3977c478bd9Sstevel@tonic-gate * kernel using crypto_register_provider(9F). 3987c478bd9Sstevel@tonic-gate */ 3997c478bd9Sstevel@tonic-gate typedef struct crypto_object_ops { 4007c478bd9Sstevel@tonic-gate int (*object_create)(crypto_provider_handle_t, crypto_session_id_t, 4017c478bd9Sstevel@tonic-gate crypto_object_attribute_t *, uint_t, crypto_object_id_t *, 4027c478bd9Sstevel@tonic-gate crypto_req_handle_t); 4037c478bd9Sstevel@tonic-gate int (*object_copy)(crypto_provider_handle_t, crypto_session_id_t, 4047c478bd9Sstevel@tonic-gate crypto_object_id_t, crypto_object_attribute_t *, uint_t, 4057c478bd9Sstevel@tonic-gate crypto_object_id_t *, crypto_req_handle_t); 4067c478bd9Sstevel@tonic-gate int (*object_destroy)(crypto_provider_handle_t, crypto_session_id_t, 4077c478bd9Sstevel@tonic-gate crypto_object_id_t, crypto_req_handle_t); 4087c478bd9Sstevel@tonic-gate int (*object_get_size)(crypto_provider_handle_t, crypto_session_id_t, 4097c478bd9Sstevel@tonic-gate crypto_object_id_t, size_t *, crypto_req_handle_t); 4107c478bd9Sstevel@tonic-gate int (*object_get_attribute_value)(crypto_provider_handle_t, 4117c478bd9Sstevel@tonic-gate crypto_session_id_t, crypto_object_id_t, 4127c478bd9Sstevel@tonic-gate crypto_object_attribute_t *, uint_t, crypto_req_handle_t); 4137c478bd9Sstevel@tonic-gate int (*object_set_attribute_value)(crypto_provider_handle_t, 4147c478bd9Sstevel@tonic-gate crypto_session_id_t, crypto_object_id_t, 4157c478bd9Sstevel@tonic-gate crypto_object_attribute_t *, uint_t, crypto_req_handle_t); 4167c478bd9Sstevel@tonic-gate int (*object_find_init)(crypto_provider_handle_t, crypto_session_id_t, 4177c478bd9Sstevel@tonic-gate crypto_object_attribute_t *, uint_t, void **, 4187c478bd9Sstevel@tonic-gate crypto_req_handle_t); 4197c478bd9Sstevel@tonic-gate int (*object_find)(crypto_provider_handle_t, void *, 4207c478bd9Sstevel@tonic-gate crypto_object_id_t *, uint_t, uint_t *, crypto_req_handle_t); 4217c478bd9Sstevel@tonic-gate int (*object_find_final)(crypto_provider_handle_t, void *, 4227c478bd9Sstevel@tonic-gate crypto_req_handle_t); 4237c478bd9Sstevel@tonic-gate } crypto_object_ops_t; 4247c478bd9Sstevel@tonic-gate 4257c478bd9Sstevel@tonic-gate /* 4267c478bd9Sstevel@tonic-gate * The crypto_key_ops structure contains pointers to key 4277c478bd9Sstevel@tonic-gate * operations for cryptographic providers. It is passed through 4287c478bd9Sstevel@tonic-gate * the crypto_ops(9S) structure when providers register with the 4297c478bd9Sstevel@tonic-gate * kernel using crypto_register_provider(9F). 4307c478bd9Sstevel@tonic-gate */ 4317c478bd9Sstevel@tonic-gate typedef struct crypto_key_ops { 4327c478bd9Sstevel@tonic-gate int (*key_generate)(crypto_provider_handle_t, crypto_session_id_t, 4337c478bd9Sstevel@tonic-gate crypto_mechanism_t *, crypto_object_attribute_t *, uint_t, 4347c478bd9Sstevel@tonic-gate crypto_object_id_t *, crypto_req_handle_t); 4357c478bd9Sstevel@tonic-gate int (*key_generate_pair)(crypto_provider_handle_t, crypto_session_id_t, 4367c478bd9Sstevel@tonic-gate crypto_mechanism_t *, crypto_object_attribute_t *, uint_t, 4377c478bd9Sstevel@tonic-gate crypto_object_attribute_t *, uint_t, crypto_object_id_t *, 4387c478bd9Sstevel@tonic-gate crypto_object_id_t *, crypto_req_handle_t); 4397c478bd9Sstevel@tonic-gate int (*key_wrap)(crypto_provider_handle_t, crypto_session_id_t, 4407c478bd9Sstevel@tonic-gate crypto_mechanism_t *, crypto_key_t *, crypto_object_id_t *, 4417c478bd9Sstevel@tonic-gate uchar_t *, size_t *, crypto_req_handle_t); 4427c478bd9Sstevel@tonic-gate int (*key_unwrap)(crypto_provider_handle_t, crypto_session_id_t, 4437c478bd9Sstevel@tonic-gate crypto_mechanism_t *, crypto_key_t *, uchar_t *, size_t *, 4447c478bd9Sstevel@tonic-gate crypto_object_attribute_t *, uint_t, 4457c478bd9Sstevel@tonic-gate crypto_object_id_t *, crypto_req_handle_t); 4467c478bd9Sstevel@tonic-gate int (*key_derive)(crypto_provider_handle_t, crypto_session_id_t, 4477c478bd9Sstevel@tonic-gate crypto_mechanism_t *, crypto_key_t *, crypto_object_attribute_t *, 4487c478bd9Sstevel@tonic-gate uint_t, crypto_object_id_t *, crypto_req_handle_t); 4497c478bd9Sstevel@tonic-gate int (*key_check)(crypto_provider_handle_t, crypto_mechanism_t *, 4507c478bd9Sstevel@tonic-gate crypto_key_t *); 4517c478bd9Sstevel@tonic-gate } crypto_key_ops_t; 4527c478bd9Sstevel@tonic-gate 4537c478bd9Sstevel@tonic-gate /* 4547c478bd9Sstevel@tonic-gate * The crypto_provider_management_ops structure contains pointers 4557c478bd9Sstevel@tonic-gate * to management operations for cryptographic providers. It is passed 4567c478bd9Sstevel@tonic-gate * through the crypto_ops(9S) structure when providers register with the 4577c478bd9Sstevel@tonic-gate * kernel using crypto_register_provider(9F). 4587c478bd9Sstevel@tonic-gate */ 4597c478bd9Sstevel@tonic-gate typedef struct crypto_provider_management_ops { 4607c478bd9Sstevel@tonic-gate int (*ext_info)(crypto_provider_handle_t, 4617c478bd9Sstevel@tonic-gate crypto_provider_ext_info_t *, crypto_req_handle_t); 4627c478bd9Sstevel@tonic-gate int (*init_token)(crypto_provider_handle_t, char *, size_t, 4637c478bd9Sstevel@tonic-gate char *, crypto_req_handle_t); 4647c478bd9Sstevel@tonic-gate int (*init_pin)(crypto_provider_handle_t, crypto_session_id_t, 4657c478bd9Sstevel@tonic-gate char *, size_t, crypto_req_handle_t); 4667c478bd9Sstevel@tonic-gate int (*set_pin)(crypto_provider_handle_t, crypto_session_id_t, 4677c478bd9Sstevel@tonic-gate char *, size_t, char *, size_t, crypto_req_handle_t); 4687c478bd9Sstevel@tonic-gate } crypto_provider_management_ops_t; 4697c478bd9Sstevel@tonic-gate 470894b2776Smcpowers typedef struct crypto_mech_ops { 471894b2776Smcpowers int (*copyin_mechanism)(crypto_provider_handle_t, 472894b2776Smcpowers crypto_mechanism_t *, crypto_mechanism_t *, int *, int); 473894b2776Smcpowers int (*copyout_mechanism)(crypto_provider_handle_t, 474894b2776Smcpowers crypto_mechanism_t *, crypto_mechanism_t *, int *, int); 475894b2776Smcpowers int (*free_mechanism)(crypto_provider_handle_t, crypto_mechanism_t *); 476894b2776Smcpowers } crypto_mech_ops_t; 477894b2776Smcpowers 478034448feSmcpowers typedef struct crypto_nostore_key_ops { 479034448feSmcpowers int (*nostore_key_generate)(crypto_provider_handle_t, 480034448feSmcpowers crypto_session_id_t, crypto_mechanism_t *, 481034448feSmcpowers crypto_object_attribute_t *, uint_t, crypto_object_attribute_t *, 482034448feSmcpowers uint_t, crypto_req_handle_t); 483034448feSmcpowers int (*nostore_key_generate_pair)(crypto_provider_handle_t, 484034448feSmcpowers crypto_session_id_t, crypto_mechanism_t *, 485034448feSmcpowers crypto_object_attribute_t *, uint_t, crypto_object_attribute_t *, 486034448feSmcpowers uint_t, crypto_object_attribute_t *, uint_t, 487034448feSmcpowers crypto_object_attribute_t *, uint_t, crypto_req_handle_t); 488034448feSmcpowers int (*nostore_key_derive)(crypto_provider_handle_t, crypto_session_id_t, 489034448feSmcpowers crypto_mechanism_t *, crypto_key_t *, crypto_object_attribute_t *, 490034448feSmcpowers uint_t, crypto_object_attribute_t *, uint_t, crypto_req_handle_t); 491034448feSmcpowers } crypto_nostore_key_ops_t; 492034448feSmcpowers 4937c478bd9Sstevel@tonic-gate /* 49473556491SAnthony Scarpino * crypto_fips140_ops provides a function for FIPS 140 Power-On Self Test for 49573556491SAnthony Scarpino * those providers that are part of the Cryptographic Framework bounday. See 49673556491SAnthony Scarpino * crypto_fips140_ops(9s) for details. 49773556491SAnthony Scarpino */ 49873556491SAnthony Scarpino typedef struct crypto_fips140_ops { 49973556491SAnthony Scarpino void (*fips140_post)(int *); 50073556491SAnthony Scarpino } crypto_fips140_ops_t; 50173556491SAnthony Scarpino 50273556491SAnthony Scarpino /* 5037c478bd9Sstevel@tonic-gate * The crypto_ops(9S) structure contains the structures containing 5047c478bd9Sstevel@tonic-gate * the pointers to functions implemented by cryptographic providers. 5057c478bd9Sstevel@tonic-gate * It is specified as part of the crypto_provider_info(9S) 5067c478bd9Sstevel@tonic-gate * supplied by a provider when it registers with the kernel 5077c478bd9Sstevel@tonic-gate * by calling crypto_register_provider(9F). 5087c478bd9Sstevel@tonic-gate */ 509894b2776Smcpowers typedef struct crypto_ops_v1 { 510894b2776Smcpowers crypto_control_ops_t *co_control_ops; 511894b2776Smcpowers crypto_digest_ops_t *co_digest_ops; 512894b2776Smcpowers crypto_cipher_ops_t *co_cipher_ops; 513894b2776Smcpowers crypto_mac_ops_t *co_mac_ops; 514894b2776Smcpowers crypto_sign_ops_t *co_sign_ops; 515894b2776Smcpowers crypto_verify_ops_t *co_verify_ops; 516894b2776Smcpowers crypto_dual_ops_t *co_dual_ops; 517894b2776Smcpowers crypto_dual_cipher_mac_ops_t *co_dual_cipher_mac_ops; 518894b2776Smcpowers crypto_random_number_ops_t *co_random_ops; 519894b2776Smcpowers crypto_session_ops_t *co_session_ops; 520894b2776Smcpowers crypto_object_ops_t *co_object_ops; 521894b2776Smcpowers crypto_key_ops_t *co_key_ops; 522894b2776Smcpowers crypto_provider_management_ops_t *co_provider_ops; 523894b2776Smcpowers crypto_ctx_ops_t *co_ctx_ops; 524894b2776Smcpowers } crypto_ops_v1_t; 525894b2776Smcpowers 526894b2776Smcpowers typedef struct crypto_ops_v2 { 527894b2776Smcpowers crypto_ops_v1_t v1_ops; 528894b2776Smcpowers crypto_mech_ops_t *co_mech_ops; 529894b2776Smcpowers } crypto_ops_v2_t; 530894b2776Smcpowers 531034448feSmcpowers typedef struct crypto_ops_v3 { 532034448feSmcpowers crypto_ops_v2_t v2_ops; 533034448feSmcpowers crypto_nostore_key_ops_t *co_nostore_key_ops; 534034448feSmcpowers } crypto_ops_v3_t; 535034448feSmcpowers 53673556491SAnthony Scarpino typedef struct crypto_ops_v4 { 53773556491SAnthony Scarpino crypto_ops_v3_t v3_ops; 53873556491SAnthony Scarpino crypto_fips140_ops_t *co_fips140_ops; 53973556491SAnthony Scarpino } crypto_ops_v4_t; 54073556491SAnthony Scarpino 5417c478bd9Sstevel@tonic-gate typedef struct crypto_ops { 542894b2776Smcpowers union { 54373556491SAnthony Scarpino crypto_ops_v4_t cou_v4; 544034448feSmcpowers crypto_ops_v3_t cou_v3; 545894b2776Smcpowers crypto_ops_v2_t cou_v2; 546894b2776Smcpowers crypto_ops_v1_t cou_v1; 547894b2776Smcpowers } cou; 5487c478bd9Sstevel@tonic-gate } crypto_ops_t; 5497c478bd9Sstevel@tonic-gate 550894b2776Smcpowers #define co_control_ops cou.cou_v1.co_control_ops 551894b2776Smcpowers #define co_digest_ops cou.cou_v1.co_digest_ops 552894b2776Smcpowers #define co_cipher_ops cou.cou_v1.co_cipher_ops 553894b2776Smcpowers #define co_mac_ops cou.cou_v1.co_mac_ops 554894b2776Smcpowers #define co_sign_ops cou.cou_v1.co_sign_ops 555894b2776Smcpowers #define co_verify_ops cou.cou_v1.co_verify_ops 556894b2776Smcpowers #define co_dual_ops cou.cou_v1.co_dual_ops 557894b2776Smcpowers #define co_dual_cipher_mac_ops cou.cou_v1.co_dual_cipher_mac_ops 558894b2776Smcpowers #define co_random_ops cou.cou_v1.co_random_ops 559894b2776Smcpowers #define co_session_ops cou.cou_v1.co_session_ops 560894b2776Smcpowers #define co_object_ops cou.cou_v1.co_object_ops 561894b2776Smcpowers #define co_key_ops cou.cou_v1.co_key_ops 562894b2776Smcpowers #define co_provider_ops cou.cou_v1.co_provider_ops 563894b2776Smcpowers #define co_ctx_ops cou.cou_v1.co_ctx_ops 564894b2776Smcpowers #define co_mech_ops cou.cou_v2.co_mech_ops 565034448feSmcpowers #define co_nostore_key_ops cou.cou_v3.co_nostore_key_ops 56673556491SAnthony Scarpino #define co_fips140_ops cou.cou_v4.co_fips140_ops 567894b2776Smcpowers 5687c478bd9Sstevel@tonic-gate /* 5697c478bd9Sstevel@tonic-gate * Provider device specification passed during registration. 5707c478bd9Sstevel@tonic-gate * 5717c478bd9Sstevel@tonic-gate * Software providers set the pi_provider_type field of provider_info_t 5727c478bd9Sstevel@tonic-gate * to CRYPTO_SW_PROVIDER, and set the pd_sw field of 5737c478bd9Sstevel@tonic-gate * crypto_provider_dev_t to the address of their modlinkage. 5747c478bd9Sstevel@tonic-gate * 5757c478bd9Sstevel@tonic-gate * Hardware providers set the pi_provider_type field of provider_info_t 5767c478bd9Sstevel@tonic-gate * to CRYPTO_HW_PROVIDER, and set the pd_hw field of 5777c478bd9Sstevel@tonic-gate * crypto_provider_dev_t to the dev_info structure corresponding 5787c478bd9Sstevel@tonic-gate * to the device instance being registered. 5797c478bd9Sstevel@tonic-gate * 5807c478bd9Sstevel@tonic-gate * Logical providers set the pi_provider_type field of provider_info_t 5817c478bd9Sstevel@tonic-gate * to CRYPTO_LOGICAL_PROVIDER, and set the pd_hw field of 5827c478bd9Sstevel@tonic-gate * crypto_provider_dev_t to the dev_info structure corresponding 5837c478bd9Sstevel@tonic-gate * to the device instance being registered. 5847c478bd9Sstevel@tonic-gate */ 5857c478bd9Sstevel@tonic-gate 5867c478bd9Sstevel@tonic-gate typedef union crypto_provider_dev { 5877c478bd9Sstevel@tonic-gate struct modlinkage *pd_sw; /* for CRYPTO_SW_PROVIDER */ 5887c478bd9Sstevel@tonic-gate dev_info_t *pd_hw; /* for CRYPTO_HW_PROVIDER */ 5897c478bd9Sstevel@tonic-gate } crypto_provider_dev_t; 5907c478bd9Sstevel@tonic-gate 5917c478bd9Sstevel@tonic-gate /* 5927c478bd9Sstevel@tonic-gate * The mechanism info structure crypto_mech_info_t contains a function group 5937c478bd9Sstevel@tonic-gate * bit mask cm_func_group_mask. This field, of type crypto_func_group_t, 5947c478bd9Sstevel@tonic-gate * specifies the provider entry point that can be used a particular 5957c478bd9Sstevel@tonic-gate * mechanism. The function group mask is a combination of the following values. 5967c478bd9Sstevel@tonic-gate */ 5977c478bd9Sstevel@tonic-gate 5987c478bd9Sstevel@tonic-gate typedef uint32_t crypto_func_group_t; 5997c478bd9Sstevel@tonic-gate 6007c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 6017c478bd9Sstevel@tonic-gate 6027c478bd9Sstevel@tonic-gate #define CRYPTO_FG_ENCRYPT 0x00000001 /* encrypt_init() */ 6037c478bd9Sstevel@tonic-gate #define CRYPTO_FG_DECRYPT 0x00000002 /* decrypt_init() */ 6047c478bd9Sstevel@tonic-gate #define CRYPTO_FG_DIGEST 0x00000004 /* digest_init() */ 6057c478bd9Sstevel@tonic-gate #define CRYPTO_FG_SIGN 0x00000008 /* sign_init() */ 6067c478bd9Sstevel@tonic-gate #define CRYPTO_FG_SIGN_RECOVER 0x00000010 /* sign_recover_init() */ 6077c478bd9Sstevel@tonic-gate #define CRYPTO_FG_VERIFY 0x00000020 /* verify_init() */ 6087c478bd9Sstevel@tonic-gate #define CRYPTO_FG_VERIFY_RECOVER 0x00000040 /* verify_recover_init() */ 6097c478bd9Sstevel@tonic-gate #define CRYPTO_FG_GENERATE 0x00000080 /* key_generate() */ 6107c478bd9Sstevel@tonic-gate #define CRYPTO_FG_GENERATE_KEY_PAIR 0x00000100 /* key_generate_pair() */ 6117c478bd9Sstevel@tonic-gate #define CRYPTO_FG_WRAP 0x00000200 /* key_wrap() */ 6127c478bd9Sstevel@tonic-gate #define CRYPTO_FG_UNWRAP 0x00000400 /* key_unwrap() */ 6137c478bd9Sstevel@tonic-gate #define CRYPTO_FG_DERIVE 0x00000800 /* key_derive() */ 6147c478bd9Sstevel@tonic-gate #define CRYPTO_FG_MAC 0x00001000 /* mac_init() */ 6157c478bd9Sstevel@tonic-gate #define CRYPTO_FG_ENCRYPT_MAC 0x00002000 /* encrypt_mac_init() */ 6167c478bd9Sstevel@tonic-gate #define CRYPTO_FG_MAC_DECRYPT 0x00004000 /* decrypt_mac_init() */ 6177c478bd9Sstevel@tonic-gate #define CRYPTO_FG_ENCRYPT_ATOMIC 0x00008000 /* encrypt_atomic() */ 6187c478bd9Sstevel@tonic-gate #define CRYPTO_FG_DECRYPT_ATOMIC 0x00010000 /* decrypt_atomic() */ 6197c478bd9Sstevel@tonic-gate #define CRYPTO_FG_MAC_ATOMIC 0x00020000 /* mac_atomic() */ 6207c478bd9Sstevel@tonic-gate #define CRYPTO_FG_DIGEST_ATOMIC 0x00040000 /* digest_atomic() */ 6217c478bd9Sstevel@tonic-gate #define CRYPTO_FG_SIGN_ATOMIC 0x00080000 /* sign_atomic() */ 6227c478bd9Sstevel@tonic-gate #define CRYPTO_FG_SIGN_RECOVER_ATOMIC 0x00100000 /* sign_recover_atomic() */ 6237c478bd9Sstevel@tonic-gate #define CRYPTO_FG_VERIFY_ATOMIC 0x00200000 /* verify_atomic() */ 6247c478bd9Sstevel@tonic-gate #define CRYPTO_FG_VERIFY_RECOVER_ATOMIC 0x00400000 /* verify_recover_atomic() */ 6257c478bd9Sstevel@tonic-gate #define CRYPTO_FG_ENCRYPT_MAC_ATOMIC 0x00800000 /* encrypt_mac_atomic() */ 6267c478bd9Sstevel@tonic-gate #define CRYPTO_FG_MAC_DECRYPT_ATOMIC 0x01000000 /* mac_decrypt_atomic() */ 6277c478bd9Sstevel@tonic-gate #define CRYPTO_FG_RESERVED 0x80000000 6287c478bd9Sstevel@tonic-gate 6297c478bd9Sstevel@tonic-gate /* 6307c478bd9Sstevel@tonic-gate * Maximum length of the pi_provider_description field of the 6317c478bd9Sstevel@tonic-gate * crypto_provider_info structure. 6327c478bd9Sstevel@tonic-gate */ 6337c478bd9Sstevel@tonic-gate #define CRYPTO_PROVIDER_DESCR_MAX_LEN 64 6347c478bd9Sstevel@tonic-gate 6357c478bd9Sstevel@tonic-gate #ifdef _KERNEL 6367c478bd9Sstevel@tonic-gate 6377c478bd9Sstevel@tonic-gate /* Bit mask for all the simple operations */ 6387c478bd9Sstevel@tonic-gate #define CRYPTO_FG_SIMPLEOP_MASK (CRYPTO_FG_ENCRYPT | CRYPTO_FG_DECRYPT | \ 6397c478bd9Sstevel@tonic-gate CRYPTO_FG_DIGEST | CRYPTO_FG_SIGN | CRYPTO_FG_VERIFY | CRYPTO_FG_MAC | \ 6407c478bd9Sstevel@tonic-gate CRYPTO_FG_ENCRYPT_ATOMIC | CRYPTO_FG_DECRYPT_ATOMIC | \ 6417c478bd9Sstevel@tonic-gate CRYPTO_FG_MAC_ATOMIC | CRYPTO_FG_DIGEST_ATOMIC | CRYPTO_FG_SIGN_ATOMIC | \ 6427c478bd9Sstevel@tonic-gate CRYPTO_FG_VERIFY_ATOMIC) 6437c478bd9Sstevel@tonic-gate 6447c478bd9Sstevel@tonic-gate /* Bit mask for all the dual operations */ 6457c478bd9Sstevel@tonic-gate #define CRYPTO_FG_MAC_CIPHER_MASK (CRYPTO_FG_ENCRYPT_MAC | \ 6467c478bd9Sstevel@tonic-gate CRYPTO_FG_MAC_DECRYPT | CRYPTO_FG_ENCRYPT_MAC_ATOMIC | \ 6477c478bd9Sstevel@tonic-gate CRYPTO_FG_MAC_DECRYPT_ATOMIC) 6487c478bd9Sstevel@tonic-gate 6497c478bd9Sstevel@tonic-gate /* Add other combos to CRYPTO_FG_DUAL_MASK */ 6507c478bd9Sstevel@tonic-gate #define CRYPTO_FG_DUAL_MASK CRYPTO_FG_MAC_CIPHER_MASK 6517c478bd9Sstevel@tonic-gate 6527c478bd9Sstevel@tonic-gate /* 6537c478bd9Sstevel@tonic-gate * The crypto_mech_info structure specifies one of the mechanisms 6547c478bd9Sstevel@tonic-gate * supported by a cryptographic provider. The pi_mechanisms field of 6557c478bd9Sstevel@tonic-gate * the crypto_provider_info structure contains a pointer to an array 6567c478bd9Sstevel@tonic-gate * of crypto_mech_info's. 6577c478bd9Sstevel@tonic-gate */ 6587c478bd9Sstevel@tonic-gate typedef struct crypto_mech_info { 6597c478bd9Sstevel@tonic-gate crypto_mech_name_t cm_mech_name; 6607c478bd9Sstevel@tonic-gate crypto_mech_type_t cm_mech_number; 6617c478bd9Sstevel@tonic-gate crypto_func_group_t cm_func_group_mask; 6627c478bd9Sstevel@tonic-gate ssize_t cm_min_key_length; 6637c478bd9Sstevel@tonic-gate ssize_t cm_max_key_length; 6646a1073f8Skrishna uint32_t cm_mech_flags; 6657c478bd9Sstevel@tonic-gate } crypto_mech_info_t; 6667c478bd9Sstevel@tonic-gate 6676a1073f8Skrishna /* Alias the old name to the new name for compatibility. */ 6686a1073f8Skrishna #define cm_keysize_unit cm_mech_flags 6696a1073f8Skrishna 6707c478bd9Sstevel@tonic-gate /* 6717c478bd9Sstevel@tonic-gate * crypto_kcf_provider_handle_t is a handle allocated by the kernel. 6727c478bd9Sstevel@tonic-gate * It is returned after the provider registers with 6737c478bd9Sstevel@tonic-gate * crypto_register_provider(), and must be specified by the provider 6747c478bd9Sstevel@tonic-gate * when calling crypto_unregister_provider(), and 6757c478bd9Sstevel@tonic-gate * crypto_provider_notification(). 6767c478bd9Sstevel@tonic-gate */ 6777c478bd9Sstevel@tonic-gate typedef uint_t crypto_kcf_provider_handle_t; 6787c478bd9Sstevel@tonic-gate 6797c478bd9Sstevel@tonic-gate /* 6807c478bd9Sstevel@tonic-gate * Provider information. Passed as argument to crypto_register_provider(9F). 6817c478bd9Sstevel@tonic-gate * Describes the provider and its capabilities. Multiple providers can 6827c478bd9Sstevel@tonic-gate * register for the same device instance. In this case, the same 6837c478bd9Sstevel@tonic-gate * pi_provider_dev must be specified with a different pi_provider_handle. 6847c478bd9Sstevel@tonic-gate */ 685894b2776Smcpowers typedef struct crypto_provider_info_v1 { 6867c478bd9Sstevel@tonic-gate uint_t pi_interface_version; 6877c478bd9Sstevel@tonic-gate char *pi_provider_description; 6887c478bd9Sstevel@tonic-gate crypto_provider_type_t pi_provider_type; 6897c478bd9Sstevel@tonic-gate crypto_provider_dev_t pi_provider_dev; 6907c478bd9Sstevel@tonic-gate crypto_provider_handle_t pi_provider_handle; 6917c478bd9Sstevel@tonic-gate crypto_ops_t *pi_ops_vector; 6927c478bd9Sstevel@tonic-gate uint_t pi_mech_list_count; 6937c478bd9Sstevel@tonic-gate crypto_mech_info_t *pi_mechanisms; 6947c478bd9Sstevel@tonic-gate uint_t pi_logical_provider_count; 6957c478bd9Sstevel@tonic-gate crypto_kcf_provider_handle_t *pi_logical_providers; 696894b2776Smcpowers } crypto_provider_info_v1_t; 697894b2776Smcpowers 698894b2776Smcpowers typedef struct crypto_provider_info_v2 { 699894b2776Smcpowers crypto_provider_info_v1_t v1_info; 700894b2776Smcpowers uint_t pi_flags; 701894b2776Smcpowers } crypto_provider_info_v2_t; 702894b2776Smcpowers 703894b2776Smcpowers typedef struct crypto_provider_info { 704894b2776Smcpowers union { 705894b2776Smcpowers crypto_provider_info_v2_t piu_v2; 706894b2776Smcpowers crypto_provider_info_v1_t piu_v1; 707894b2776Smcpowers } piu; 7087c478bd9Sstevel@tonic-gate } crypto_provider_info_t; 7097c478bd9Sstevel@tonic-gate 710894b2776Smcpowers #define pi_interface_version piu.piu_v1.pi_interface_version 711894b2776Smcpowers #define pi_provider_description piu.piu_v1.pi_provider_description 712894b2776Smcpowers #define pi_provider_type piu.piu_v1.pi_provider_type 713894b2776Smcpowers #define pi_provider_dev piu.piu_v1.pi_provider_dev 714894b2776Smcpowers #define pi_provider_handle piu.piu_v1.pi_provider_handle 715894b2776Smcpowers #define pi_ops_vector piu.piu_v1.pi_ops_vector 716894b2776Smcpowers #define pi_mech_list_count piu.piu_v1.pi_mech_list_count 717894b2776Smcpowers #define pi_mechanisms piu.piu_v1.pi_mechanisms 718894b2776Smcpowers #define pi_logical_provider_count piu.piu_v1.pi_logical_provider_count 719894b2776Smcpowers #define pi_logical_providers piu.piu_v1.pi_logical_providers 720894b2776Smcpowers #define pi_flags piu.piu_v2.pi_flags 721894b2776Smcpowers 722894b2776Smcpowers /* hidden providers can only be accessed via a logical provider */ 723c892ebf1Skrishna #define CRYPTO_HIDE_PROVIDER 0x00000001 724ba5f469cSkrishna /* 725ba5f469cSkrishna * provider can not do multi-part digest (updates) and has a limit 726*4df55fdeSJanie Lu * on maximum input data that it can digest. The provider sets 727*4df55fdeSJanie Lu * this value in crypto_provider_ext_info_t by implementing 728*4df55fdeSJanie Lu * the ext_info entry point in the co_provider_ops vector. 729ba5f469cSkrishna */ 730ba5f469cSkrishna #define CRYPTO_HASH_NO_UPDATE 0x00000002 731*4df55fdeSJanie Lu /* 732*4df55fdeSJanie Lu * provider can not do multi-part HMAC (updates) and has a limit 733*4df55fdeSJanie Lu * on maximum input data that it can hmac. The provider sets 734*4df55fdeSJanie Lu * this value in crypto_provider_ext_info_t by implementing 735*4df55fdeSJanie Lu * the ext_info entry point in the co_provider_ops vector. 736*4df55fdeSJanie Lu */ 737*4df55fdeSJanie Lu #define CRYPTO_HMAC_NO_UPDATE 0x00000008 738c1591d22SKrishna Yenduri 739c1591d22SKrishna Yenduri /* provider can handle the request without returning a CRYPTO_QUEUED */ 740c1591d22SKrishna Yenduri #define CRYPTO_SYNCHRONOUS 0x00000004 741c1591d22SKrishna Yenduri 7426a1073f8Skrishna #define CRYPTO_PIFLAGS_RESERVED2 0x40000000 7436a1073f8Skrishna #define CRYPTO_PIFLAGS_RESERVED1 0x80000000 744894b2776Smcpowers 7457c478bd9Sstevel@tonic-gate /* 7467c478bd9Sstevel@tonic-gate * Provider status passed by a provider to crypto_provider_notification(9F) 7477c478bd9Sstevel@tonic-gate * and returned by the provider_stauts(9E) entry point. 7487c478bd9Sstevel@tonic-gate */ 7497c478bd9Sstevel@tonic-gate #define CRYPTO_PROVIDER_READY 0 7507c478bd9Sstevel@tonic-gate #define CRYPTO_PROVIDER_BUSY 1 7517c478bd9Sstevel@tonic-gate #define CRYPTO_PROVIDER_FAILED 2 7527c478bd9Sstevel@tonic-gate 7537c478bd9Sstevel@tonic-gate /* 7547c478bd9Sstevel@tonic-gate * Functions exported by Solaris to cryptographic providers. Providers 7557c478bd9Sstevel@tonic-gate * call these functions to register and unregister, notify the kernel 7567c478bd9Sstevel@tonic-gate * of state changes, and notify the kernel when a asynchronous request 7577c478bd9Sstevel@tonic-gate * completed. 7587c478bd9Sstevel@tonic-gate */ 7597c478bd9Sstevel@tonic-gate extern int crypto_register_provider(crypto_provider_info_t *, 7607c478bd9Sstevel@tonic-gate crypto_kcf_provider_handle_t *); 7617c478bd9Sstevel@tonic-gate extern int crypto_unregister_provider(crypto_kcf_provider_handle_t); 7627c478bd9Sstevel@tonic-gate extern void crypto_provider_notification(crypto_kcf_provider_handle_t, uint_t); 7637c478bd9Sstevel@tonic-gate extern void crypto_op_notification(crypto_req_handle_t, int); 7647c478bd9Sstevel@tonic-gate extern int crypto_kmflag(crypto_req_handle_t); 7657c478bd9Sstevel@tonic-gate 7667c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 7677c478bd9Sstevel@tonic-gate 7687c478bd9Sstevel@tonic-gate #ifdef __cplusplus 7697c478bd9Sstevel@tonic-gate } 7707c478bd9Sstevel@tonic-gate #endif 7717c478bd9Sstevel@tonic-gate 7727c478bd9Sstevel@tonic-gate #endif /* _SYS_CRYPTO_SPI_H */ 773