1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
22 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
23 */
24
25#ifndef _KMSGLOBAL_H
26#define	_KMSGLOBAL_H
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32#include <sys/crypto/common.h>
33#include <security/cryptoki.h>
34#include <security/pkcs11t.h>
35#include "kmsObject.h"
36
37typedef struct kms_elem {
38	CK_MECHANISM_TYPE type;
39	struct kms_elem *knext;		/* Next in hash chain */
40} kms_elem_t;
41
42extern kms_elem_t **kms_mechhash;
43extern boolean_t kms_initialized;
44
45#define	KMECH_HASHTABLE_SIZE	67
46
47/* CK_INFO: Information about cryptoki */
48#define	CRYPTOKI_VERSION_MAJOR	2
49#define	CRYPTOKI_VERSION_MINOR	20
50#define	MANUFACTURER_ID		"Oracle Corporation     "
51#define	LIBRARY_DESCRIPTION	"Oracle Key Management System    "
52#define	LIBRARY_VERSION_MAJOR	1
53#define	LIBRARY_VERSION_MINOR	0
54
55/* CK_SLOT_INFO: Information about our slot */
56#define	SLOT_DESCRIPTION	"Oracle Key Management System    " \
57				"                                "
58#define	KMS_TOKEN_LABEL		"KMS                             "
59#define	KMS_TOKEN_MODEL		"                "
60#define	KMS_TOKEN_SERIAL	"                "
61#define	KMS_TOKEN_FLAGS		CKF_LOGIN_REQUIRED
62#define	MAX_PIN_LEN		256
63#define	MIN_PIN_LEN		1
64#define	HARDWARE_VERSION_MAJOR	0
65#define	HARDWARE_VERSION_MINOR	0
66#define	FIRMWARE_VERSION_MAJOR	0
67#define	FIRMWARE_VERSION_MINOR	0
68
69CK_RV crypto2pkcs11_error_number(uint_t);
70CK_RV kms_mech(CK_MECHANISM_TYPE);
71unsigned char *get_symmetric_key_value(kms_object_t *);
72void free_key_attributes();
73
74CK_RV process_object_attributes(CK_ATTRIBUTE_PTR, CK_ULONG, caddr_t *,
75    CK_BBOOL *);
76CK_RV get_object_attributes(CK_ATTRIBUTE_PTR, CK_ULONG, caddr_t);
77void free_object_attributes(caddr_t, CK_ULONG);
78CK_RV process_found_objects(kms_session_t *, CK_OBJECT_HANDLE *,
79    CK_ULONG *);
80CK_RV get_mechanism_info(kms_slot_t *, CK_MECHANISM_TYPE,
81    CK_MECHANISM_INFO_PTR, uint32_t *);
82CK_RV kms_add_extra_attr(CK_ATTRIBUTE_PTR, kms_object_t *);
83
84#ifdef	__cplusplus
85}
86#endif
87
88#endif /* _KMSGLOBAL_H */
89