/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/*
* Copyright 2013 Saso Kiselkov. All rights reserved.
*/
#ifndef _SYS_CRYPTO_COMMON_H
#define _SYS_CRYPTO_COMMON_H
/*
* Header file for the common data structures of the cryptographic framework
*/
#ifdef __cplusplus
extern "C" {
#endif
/* Cryptographic Mechanisms */
typedef struct crypto_mechanism {
#ifdef _SYSCALL32
typedef struct crypto_mechanism32 {
#endif /* _SYSCALL32 */
#ifdef _KERNEL
/* CK_AES_CTR_PARAMS provides parameters to the CKM_AES_CTR mechanism */
typedef struct CK_AES_CTR_PARAMS {
#endif
/* CK_AES_CCM_PARAMS provides parameters to the CKM_AES_CCM mechanism */
typedef struct CK_AES_CCM_PARAMS {
/* CK_AES_GCM_PARAMS provides parameters to the CKM_AES_GCM mechanism */
typedef struct CK_AES_GCM_PARAMS {
/* CK_AES_GMAC_PARAMS provides parameters to the CKM_AES_GMAC mechanism */
typedef struct CK_AES_GMAC_PARAMS {
#ifdef _KERNEL
/*
* CK_ECDH1_DERIVE_PARAMS provides the parameters to the
* CKM_ECDH1_KEY_DERIVE mechanism
*/
typedef struct CK_ECDH1_DERIVE_PARAMS {
#endif
#ifdef _KERNEL
#ifdef _SYSCALL32
/* needed for 32-bit applications running on 64-bit kernels */
typedef struct CK_AES_CTR_PARAMS32 {
/* needed for 32-bit applications running on 64-bit kernels */
typedef struct CK_AES_CCM_PARAMS32 {
/* needed for 32-bit applications running on 64-bit kernels */
typedef struct CK_AES_GCM_PARAMS32 {
/* needed for 32-bit applications running on 64-bit kernels */
typedef struct CK_AES_GMAC_PARAMS32 {
typedef struct CK_ECDH1_DERIVE_PARAMS32 {
#endif /* _SYSCALL32 */
#endif /* _KERNEL */
/*
* The measurement unit bit flag for a mechanism's minimum or maximum key size.
* The unit are mechanism dependent. It can be in bits or in bytes.
*/
/*
* The following bit flags are valid in cm_mech_flags field in
* the crypto_mech_info_t structure of the SPI.
*
* Only the first two bit flags are valid in mi_keysize_unit
* field in the crypto_mechanism_info_t structure of the API.
*/
/* Mechanisms supported out-of-the-box */
/* Shared operation context format for CKM_RC4 */
typedef struct {
#if defined(__amd64)
uint32_t i, j;
#else
uchar_t i, j;
#endif /* __amd64 */
/* Data arguments of cryptographic operations */
typedef enum crypto_data_format {
typedef struct crypto_data {
union {
/* Raw format */
/* uio scatter-gather format */
/* mblk scatter-gather format */
typedef struct crypto_dual_data {
/* The keys, and their contents */
typedef enum {
/* Attribute types to use for passing a RSA public key or a private key. */
typedef struct crypto_object_attribute {
typedef struct crypto_key {
union {
/* for CRYPTO_KEY_RAW ck_format */
struct {
/* for CRYPTO_KEY_REFERENCE ck_format */
/* for CRYPTO_KEY_ATTR_LIST ck_format */
struct {
} crypto_key_t;
#ifdef _SYSCALL32
typedef struct crypto_object_attribute32 {
typedef struct crypto_key32 {
union {
/* for CRYPTO_KEY_RAW ck_format */
struct {
/* for CRYPTO_KEY_REFERENCE ck_format */
/* for CRYPTO_KEY_ATTR_LIST ck_format */
struct {
#endif /* _SYSCALL32 */
/*
* Raw key lengths are expressed in number of bits.
* The following macro returns the minimum number of
* bytes that can contain the specified number of bits.
* Round up without overflowing the integer type.
*/
/* Providers */
typedef enum {
CRYPTO_HW_PROVIDER = 0,
typedef struct crypto_provider_entry {
typedef struct crypto_dev_list_entry {
/* User type for authentication ioctls and SPI entry points */
typedef enum crypto_user_type {
CRYPTO_SO = 0,
/* Version for provider management ioctls and SPI entry points */
typedef struct crypto_version {
/* session data structure opaque to the consumer */
typedef void *crypto_session_t;
/* provider data structure opaque to the consumer */
typedef void *crypto_provider_t;
/* Limits used by both consumers and providers */
typedef struct crypto_provider_ext_info {
typedef enum cmd_type {
} cmd_type_t;
/*
* Common cryptographic status and error codes.
*/
/*
* Don't forget to update CRYPTO_LAST_ERROR and the error_number_table[]
* in kernelUtil.c when new error code is added.
*/
/*
* Special values that can be used to indicate that information is unavailable
* or that there is not practical limit. These values can be used
* by fields of the SPI crypto_provider_ext_info(9S) structure.
* The value of CRYPTO_UNAVAILABLE_INFO should be the same as
* CK_UNAVAILABLE_INFO in the PKCS#11 spec.
*/
#ifdef __cplusplus
}
#endif
#endif /* _SYS_CRYPTO_COMMON_H */