10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51937Sizick * Common Development and Distribution License (the "License"). 61937Sizick * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*12256SPeter.Shoults@Sun.COM * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 230Sstevel@tonic-gate */ 240Sstevel@tonic-gate 250Sstevel@tonic-gate #ifndef _SOFTKEYSTOREUTIL_H 260Sstevel@tonic-gate #define _SOFTKEYSTOREUTIL_H 270Sstevel@tonic-gate 280Sstevel@tonic-gate /* 290Sstevel@tonic-gate * Structures and function prototypes for the keystore 300Sstevel@tonic-gate */ 310Sstevel@tonic-gate 320Sstevel@tonic-gate #ifdef __cplusplus 330Sstevel@tonic-gate extern "C" { 340Sstevel@tonic-gate #endif 350Sstevel@tonic-gate 360Sstevel@tonic-gate #include <sys/types.h> 370Sstevel@tonic-gate 381937Sizick /* Keystore State values */ 391937Sizick #define KEYSTORE_UNINITIALIZED 0 401937Sizick #define KEYSTORE_PRESENT 1 41*12256SPeter.Shoults@Sun.COM #define KEYSTORE_LOAD 2 421937Sizick #define KEYSTORE_INITIALIZED 3 431937Sizick #define KEYSTORE_UNAVAILABLE 4 441937Sizick 450Sstevel@tonic-gate typedef enum { 460Sstevel@tonic-gate ALL_TOKENOBJS = 0, 470Sstevel@tonic-gate PUB_TOKENOBJS = 1, 480Sstevel@tonic-gate PRI_TOKENOBJS = 2 490Sstevel@tonic-gate } ks_search_type_t; 500Sstevel@tonic-gate 510Sstevel@tonic-gate typedef struct ks_obj_handle { 520Sstevel@tonic-gate unsigned char name[256]; /* obj[monotonic-counter] */ 530Sstevel@tonic-gate boolean_t public; /* true if public obj, false for private obj */ 540Sstevel@tonic-gate } ks_obj_handle_t; 550Sstevel@tonic-gate 560Sstevel@tonic-gate typedef struct ks_obj { 570Sstevel@tonic-gate 580Sstevel@tonic-gate /* handle for accessing this object */ 590Sstevel@tonic-gate ks_obj_handle_t ks_handle; 600Sstevel@tonic-gate 610Sstevel@tonic-gate /* version number of object file */ 620Sstevel@tonic-gate uint_t obj_version; 630Sstevel@tonic-gate 640Sstevel@tonic-gate /* contains decrypted binary data for obj */ 650Sstevel@tonic-gate uchar_t *buf; 660Sstevel@tonic-gate 670Sstevel@tonic-gate /* size of binary data */ 680Sstevel@tonic-gate size_t size; 690Sstevel@tonic-gate 700Sstevel@tonic-gate /* pointer to next item in list */ 710Sstevel@tonic-gate struct ks_obj *next; 720Sstevel@tonic-gate } ks_obj_t; 730Sstevel@tonic-gate 740Sstevel@tonic-gate /* 750Sstevel@tonic-gate * Prototype for functions in softKeystore.c 760Sstevel@tonic-gate */ 770Sstevel@tonic-gate int soft_keystore_readlock(boolean_t set_lock); 780Sstevel@tonic-gate int soft_keystore_writelock(boolean_t set_lock); 790Sstevel@tonic-gate int soft_keystore_lock_object(ks_obj_handle_t *ks_handle, boolean_t read_lock); 800Sstevel@tonic-gate int soft_keystore_unlock_object(int fd); 810Sstevel@tonic-gate int soft_keystore_get_version(uint_t *version, boolean_t lock_held); 820Sstevel@tonic-gate int soft_keystore_get_object_version(ks_obj_handle_t *ks_handle, 830Sstevel@tonic-gate uint_t *version, boolean_t lock_held); 840Sstevel@tonic-gate int soft_keystore_getpin(char **hashed_pin, boolean_t lock_held); 850Sstevel@tonic-gate int soft_keystore_setpin(uchar_t *oldpin, uchar_t *newpin, boolean_t lock_held); 860Sstevel@tonic-gate int soft_keystore_authpin(uchar_t *pin); 870Sstevel@tonic-gate CK_RV soft_keystore_get_objs(ks_search_type_t search_type, 880Sstevel@tonic-gate ks_obj_t **result_objs, boolean_t lock_held); 890Sstevel@tonic-gate CK_RV soft_keystore_get_single_obj(ks_obj_handle_t *ks_handle, 900Sstevel@tonic-gate ks_obj_t **result_obj, boolean_t lock_held); 910Sstevel@tonic-gate int soft_keystore_put_new_obj(uchar_t *buf, size_t len, boolean_t public, 920Sstevel@tonic-gate boolean_t lock_held, ks_obj_handle_t *keyhandle); 930Sstevel@tonic-gate int soft_keystore_modify_obj(ks_obj_handle_t *ks_handle, uchar_t *buf, 940Sstevel@tonic-gate size_t len, boolean_t lock_held); 950Sstevel@tonic-gate int soft_keystore_del_obj(ks_obj_handle_t *ks_handle, boolean_t lock_held); 960Sstevel@tonic-gate int soft_keystore_get_pin_salt(char **salt); 970Sstevel@tonic-gate CK_RV soft_keystore_pin_initialized(boolean_t *initialized, char **hashed_pin, 980Sstevel@tonic-gate boolean_t lock_held); 991937Sizick boolean_t soft_keystore_status(int desired_state); 100*12256SPeter.Shoults@Sun.COM int soft_keystore_init(int desired_state); 101*12256SPeter.Shoults@Sun.COM int create_keystore(); 1020Sstevel@tonic-gate 1030Sstevel@tonic-gate #ifdef __cplusplus 1040Sstevel@tonic-gate } 1050Sstevel@tonic-gate #endif 1060Sstevel@tonic-gate 1070Sstevel@tonic-gate #endif /* _SOFTKEYSTOREUTIL_H */ 108