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 590e0e8c4Sizick * Common Development and Distribution License (the "License"). 690e0e8c4Sizick * 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 /* 22*c5866e1dSPeter Shoults * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 237c478bd9Sstevel@tonic-gate */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate #ifndef _SOFTKEYSTOREUTIL_H 267c478bd9Sstevel@tonic-gate #define _SOFTKEYSTOREUTIL_H 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate /* 297c478bd9Sstevel@tonic-gate * Structures and function prototypes for the keystore 307c478bd9Sstevel@tonic-gate */ 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #ifdef __cplusplus 337c478bd9Sstevel@tonic-gate extern "C" { 347c478bd9Sstevel@tonic-gate #endif 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #include <sys/types.h> 377c478bd9Sstevel@tonic-gate 3890e0e8c4Sizick /* Keystore State values */ 3990e0e8c4Sizick #define KEYSTORE_UNINITIALIZED 0 4090e0e8c4Sizick #define KEYSTORE_PRESENT 1 41*c5866e1dSPeter Shoults #define KEYSTORE_LOAD 2 4290e0e8c4Sizick #define KEYSTORE_INITIALIZED 3 4390e0e8c4Sizick #define KEYSTORE_UNAVAILABLE 4 4490e0e8c4Sizick 457c478bd9Sstevel@tonic-gate typedef enum { 467c478bd9Sstevel@tonic-gate ALL_TOKENOBJS = 0, 477c478bd9Sstevel@tonic-gate PUB_TOKENOBJS = 1, 487c478bd9Sstevel@tonic-gate PRI_TOKENOBJS = 2 497c478bd9Sstevel@tonic-gate } ks_search_type_t; 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate typedef struct ks_obj_handle { 527c478bd9Sstevel@tonic-gate unsigned char name[256]; /* obj[monotonic-counter] */ 537c478bd9Sstevel@tonic-gate boolean_t public; /* true if public obj, false for private obj */ 547c478bd9Sstevel@tonic-gate } ks_obj_handle_t; 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate typedef struct ks_obj { 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate /* handle for accessing this object */ 597c478bd9Sstevel@tonic-gate ks_obj_handle_t ks_handle; 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate /* version number of object file */ 627c478bd9Sstevel@tonic-gate uint_t obj_version; 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate /* contains decrypted binary data for obj */ 657c478bd9Sstevel@tonic-gate uchar_t *buf; 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate /* size of binary data */ 687c478bd9Sstevel@tonic-gate size_t size; 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate /* pointer to next item in list */ 717c478bd9Sstevel@tonic-gate struct ks_obj *next; 727c478bd9Sstevel@tonic-gate } ks_obj_t; 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate /* 757c478bd9Sstevel@tonic-gate * Prototype for functions in softKeystore.c 767c478bd9Sstevel@tonic-gate */ 777c478bd9Sstevel@tonic-gate int soft_keystore_readlock(boolean_t set_lock); 787c478bd9Sstevel@tonic-gate int soft_keystore_writelock(boolean_t set_lock); 797c478bd9Sstevel@tonic-gate int soft_keystore_lock_object(ks_obj_handle_t *ks_handle, boolean_t read_lock); 807c478bd9Sstevel@tonic-gate int soft_keystore_unlock_object(int fd); 817c478bd9Sstevel@tonic-gate int soft_keystore_get_version(uint_t *version, boolean_t lock_held); 827c478bd9Sstevel@tonic-gate int soft_keystore_get_object_version(ks_obj_handle_t *ks_handle, 837c478bd9Sstevel@tonic-gate uint_t *version, boolean_t lock_held); 847c478bd9Sstevel@tonic-gate int soft_keystore_getpin(char **hashed_pin, boolean_t lock_held); 857c478bd9Sstevel@tonic-gate int soft_keystore_setpin(uchar_t *oldpin, uchar_t *newpin, boolean_t lock_held); 867c478bd9Sstevel@tonic-gate int soft_keystore_authpin(uchar_t *pin); 877c478bd9Sstevel@tonic-gate CK_RV soft_keystore_get_objs(ks_search_type_t search_type, 887c478bd9Sstevel@tonic-gate ks_obj_t **result_objs, boolean_t lock_held); 897c478bd9Sstevel@tonic-gate CK_RV soft_keystore_get_single_obj(ks_obj_handle_t *ks_handle, 907c478bd9Sstevel@tonic-gate ks_obj_t **result_obj, boolean_t lock_held); 917c478bd9Sstevel@tonic-gate int soft_keystore_put_new_obj(uchar_t *buf, size_t len, boolean_t public, 927c478bd9Sstevel@tonic-gate boolean_t lock_held, ks_obj_handle_t *keyhandle); 937c478bd9Sstevel@tonic-gate int soft_keystore_modify_obj(ks_obj_handle_t *ks_handle, uchar_t *buf, 947c478bd9Sstevel@tonic-gate size_t len, boolean_t lock_held); 957c478bd9Sstevel@tonic-gate int soft_keystore_del_obj(ks_obj_handle_t *ks_handle, boolean_t lock_held); 967c478bd9Sstevel@tonic-gate int soft_keystore_get_pin_salt(char **salt); 977c478bd9Sstevel@tonic-gate CK_RV soft_keystore_pin_initialized(boolean_t *initialized, char **hashed_pin, 987c478bd9Sstevel@tonic-gate boolean_t lock_held); 9990e0e8c4Sizick boolean_t soft_keystore_status(int desired_state); 100*c5866e1dSPeter Shoults int soft_keystore_init(int desired_state); 101*c5866e1dSPeter Shoults int create_keystore(); 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1047c478bd9Sstevel@tonic-gate } 1057c478bd9Sstevel@tonic-gate #endif 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate #endif /* _SOFTKEYSTOREUTIL_H */ 108