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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SOFTKEYSTOREUTIL_H
28 #define	_SOFTKEYSTOREUTIL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * Structures and function prototypes for the keystore
34  */
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 #include <sys/types.h>
41 
42 typedef enum {
43 	ALL_TOKENOBJS = 0,
44 	PUB_TOKENOBJS = 1,
45 	PRI_TOKENOBJS = 2
46 } ks_search_type_t;
47 
48 typedef struct ks_obj_handle {
49 	unsigned char name[256]; /* obj[monotonic-counter] */
50 	boolean_t public;	/* true if public obj, false for private obj */
51 } ks_obj_handle_t;
52 
53 typedef struct ks_obj {
54 
55 	/* handle for accessing this object */
56 	ks_obj_handle_t ks_handle;
57 
58 	/* version number of object file */
59 	uint_t obj_version;
60 
61 	/* contains decrypted binary data for obj */
62 	uchar_t *buf;
63 
64 	/* size of binary data */
65 	size_t size;
66 
67 	/* pointer to next item in list */
68 	struct ks_obj *next;
69 } ks_obj_t;
70 
71 
72 /*
73  * Prototype for functions in softKeystore.c
74  */
75 int soft_keystore_readlock(boolean_t set_lock);
76 int soft_keystore_writelock(boolean_t set_lock);
77 int soft_keystore_lock_object(ks_obj_handle_t *ks_handle, boolean_t read_lock);
78 int soft_keystore_unlock_object(int fd);
79 int soft_keystore_get_version(uint_t *version, boolean_t lock_held);
80 int soft_keystore_get_object_version(ks_obj_handle_t *ks_handle,
81     uint_t *version, boolean_t lock_held);
82 int soft_keystore_getpin(char **hashed_pin, boolean_t lock_held);
83 int soft_keystore_setpin(uchar_t *oldpin, uchar_t *newpin, boolean_t lock_held);
84 int soft_keystore_authpin(uchar_t *pin);
85 CK_RV soft_keystore_get_objs(ks_search_type_t search_type,
86     ks_obj_t **result_objs, boolean_t lock_held);
87 CK_RV soft_keystore_get_single_obj(ks_obj_handle_t *ks_handle,
88     ks_obj_t **result_obj, boolean_t lock_held);
89 int soft_keystore_put_new_obj(uchar_t *buf, size_t len, boolean_t public,
90     boolean_t lock_held, ks_obj_handle_t *keyhandle);
91 int soft_keystore_modify_obj(ks_obj_handle_t *ks_handle, uchar_t *buf,
92     size_t len, boolean_t lock_held);
93 int soft_keystore_del_obj(ks_obj_handle_t *ks_handle, boolean_t lock_held);
94 int soft_keystore_get_pin_salt(char **salt);
95 CK_RV soft_keystore_pin_initialized(boolean_t *initialized, char **hashed_pin,
96     boolean_t lock_held);
97 
98 #ifdef __cplusplus
99 }
100 #endif
101 
102 #endif /* _SOFTKEYSTOREUTIL_H */
103