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 56f3f1c68Skrishna * Common Development and Distribution License (the "License"). 66f3f1c68Skrishna * 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 /* 22034448feSmcpowers * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 24cc543d0fSJason King * Copyright 2018, Joyent, Inc. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _KERNELGLOBAL_H 287c478bd9Sstevel@tonic-gate #define _KERNELGLOBAL_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #ifdef __cplusplus 317c478bd9Sstevel@tonic-gate extern "C" { 327c478bd9Sstevel@tonic-gate #endif 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #include <sys/crypto/common.h> 357c478bd9Sstevel@tonic-gate #include <security/cryptoki.h> 367c478bd9Sstevel@tonic-gate #include <security/pkcs11t.h> 37cc543d0fSJason King #include <cryptoutil.h> 387c478bd9Sstevel@tonic-gate #include "kernelObject.h" 397c478bd9Sstevel@tonic-gate 406f3f1c68Skrishna typedef struct kmh_elem { 416f3f1c68Skrishna CK_MECHANISM_TYPE type; 426f3f1c68Skrishna crypto_mech_type_t kmech; /* kCF mech number */ 436f3f1c68Skrishna struct kmh_elem *knext; /* Next in hash chain */ 446f3f1c68Skrishna } kmh_elem_t; 456f3f1c68Skrishna 466f3f1c68Skrishna extern kmh_elem_t **kernel_mechhash; 477c478bd9Sstevel@tonic-gate extern boolean_t kernel_initialized; 487c478bd9Sstevel@tonic-gate extern int kernel_fd; 497c478bd9Sstevel@tonic-gate 506f3f1c68Skrishna #define KMECH_HASHTABLE_SIZE 67 516f3f1c68Skrishna 527c478bd9Sstevel@tonic-gate #define CRYPTO_DEVICE "/dev/crypto" 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate /* CK_INFO: Information about cryptoki */ 557c478bd9Sstevel@tonic-gate #define CRYPTOKI_VERSION_MAJOR 2 56b106467fSJason King #define CRYPTOKI_VERSION_MINOR 40 577c478bd9Sstevel@tonic-gate #define MANUFACTURER_ID "Sun Microsystems, Inc. " 587c478bd9Sstevel@tonic-gate #define LIBRARY_DESCRIPTION "Sun Crypto pkcs11_kernel " 597c478bd9Sstevel@tonic-gate #define LIBRARY_VERSION_MAJOR 1 607c478bd9Sstevel@tonic-gate #define LIBRARY_VERSION_MINOR 1 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate /* CK_SLOT_INFO: Information about our slot */ 647c478bd9Sstevel@tonic-gate #define SLOT_DESCRIPTION "Sun Crypto pkcs11_kernel " \ 657c478bd9Sstevel@tonic-gate " " 667c478bd9Sstevel@tonic-gate #define HARDWARE_VERSION_MAJOR 0 677c478bd9Sstevel@tonic-gate #define HARDWARE_VERSION_MINOR 0 687c478bd9Sstevel@tonic-gate #define FIRMWARE_VERSION_MAJOR 0 697c478bd9Sstevel@tonic-gate #define FIRMWARE_VERSION_MINOR 0 707c478bd9Sstevel@tonic-gate 7187fa5c53Smcpowers #define INPLACE_MECHANISM(m) ((m) == CKM_DES_ECB || (m) == CKM_DES_CBC || \ 7287fa5c53Smcpowers (m) == CKM_DES3_ECB || (m) == CKM_DES3_CBC || (m) == CKM_AES_ECB || \ 7387fa5c53Smcpowers (m) == CKM_AES_CBC || (m) == CKM_RC4 || (m) == CKM_BLOWFISH_CBC) 7487fa5c53Smcpowers 757c478bd9Sstevel@tonic-gate CK_RV kernel_mech(CK_MECHANISM_TYPE, crypto_mech_type_t *); 767c478bd9Sstevel@tonic-gate unsigned char *get_symmetric_key_value(kernel_object_t *); 777c478bd9Sstevel@tonic-gate CK_RV get_rsa_public_key(kernel_object_t *, crypto_key_t *); 787c478bd9Sstevel@tonic-gate CK_RV get_rsa_private_key(kernel_object_t *, crypto_key_t *); 797c478bd9Sstevel@tonic-gate CK_RV get_dsa_public_key(kernel_object_t *, crypto_key_t *); 807c478bd9Sstevel@tonic-gate CK_RV get_dsa_private_key(kernel_object_t *, crypto_key_t *); 81034448feSmcpowers CK_RV get_ec_public_key(kernel_object_t *, crypto_key_t *); 82034448feSmcpowers CK_RV get_ec_private_key(kernel_object_t *, crypto_key_t *); 837c478bd9Sstevel@tonic-gate void free_key_attributes(crypto_key_t *); 84034448feSmcpowers void get_ulong_attr_from_template(CK_ULONG *, CK_ATTRIBUTE_PTR); 857c478bd9Sstevel@tonic-gate CK_RV process_object_attributes(CK_ATTRIBUTE_PTR, CK_ULONG, caddr_t *, 867c478bd9Sstevel@tonic-gate CK_BBOOL *); 877c478bd9Sstevel@tonic-gate CK_RV get_object_attributes(CK_ATTRIBUTE_PTR, CK_ULONG, caddr_t); 887c478bd9Sstevel@tonic-gate void free_object_attributes(caddr_t, CK_ULONG); 897c478bd9Sstevel@tonic-gate CK_RV get_cka_private_value(kernel_session_t *, crypto_object_id_t, 907c478bd9Sstevel@tonic-gate CK_BBOOL *); 917c478bd9Sstevel@tonic-gate CK_RV process_found_objects(kernel_session_t *, CK_OBJECT_HANDLE *, 927c478bd9Sstevel@tonic-gate CK_ULONG *, crypto_object_find_update_t); 937c478bd9Sstevel@tonic-gate CK_RV get_mechanism_info(kernel_slot_t *, CK_MECHANISM_TYPE, 947c478bd9Sstevel@tonic-gate CK_MECHANISM_INFO_PTR, uint32_t *); 957c478bd9Sstevel@tonic-gate CK_RV kernel_decrypt_init(kernel_session_t *, kernel_object_t *, 967c478bd9Sstevel@tonic-gate CK_MECHANISM_PTR); 977c478bd9Sstevel@tonic-gate CK_RV kernel_decrypt(kernel_session_t *, CK_BYTE_PTR, CK_ULONG, CK_BYTE_PTR, 987c478bd9Sstevel@tonic-gate CK_ULONG_PTR); 99034448feSmcpowers CK_RV kernel_add_extra_attr(CK_ATTRIBUTE_PTR, kernel_object_t *); 1007c478bd9Sstevel@tonic-gate 101*fb261280SJason King void p11_to_kernel_ccm_params(const CK_CCM_PARAMS *, CK_AES_CCM_PARAMS *); 102*fb261280SJason King 1037c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1047c478bd9Sstevel@tonic-gate } 1057c478bd9Sstevel@tonic-gate #endif 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate #endif /* _KERNELGLOBAL_H */ 108