michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: /* michael@0: * This file implements PKCS 11 on top of our existing security modules michael@0: * michael@0: * For more information about PKCS 11 See PKCS 11 Token Inteface Standard. michael@0: * This implementation has two slots: michael@0: * slot 1 is our generic crypto support. It does not require login. michael@0: * It supports Public Key ops, and all they bulk ciphers and hashes. michael@0: * It can also support Private Key ops for imported Private keys. It does michael@0: * not have any token storage. michael@0: * slot 2 is our private key support. It requires a login before use. It michael@0: * can store Private Keys and Certs as token objects. Currently only private michael@0: * keys and their associated Certificates are saved on the token. michael@0: * michael@0: * In this implementation, session objects are only visible to the session michael@0: * that created or generated them. michael@0: */ michael@0: michael@0: /* michael@0: * the following data structures should be moved to a 'rdb.h'. michael@0: */ michael@0: michael@0: #ifndef _SDB_H michael@0: #define _SDB_H 1 michael@0: #include "pkcs11t.h" michael@0: #include "secitem.h" michael@0: #include "sftkdbt.h" michael@0: michael@0: #define STATIC_CMD_SIZE 2048 michael@0: michael@0: typedef struct SDBFindStr SDBFind; michael@0: typedef struct SDBStr SDB; michael@0: michael@0: struct SDBStr { michael@0: void *private; michael@0: int version; michael@0: int reserved; michael@0: int sdb_flags; michael@0: void *app_private; michael@0: CK_RV (*sdb_FindObjectsInit)(SDB *sdb, const CK_ATTRIBUTE *template, michael@0: CK_ULONG count, SDBFind **find); michael@0: CK_RV (*sdb_FindObjects)(SDB *sdb, SDBFind *find, CK_OBJECT_HANDLE *ids, michael@0: CK_ULONG arraySize, CK_ULONG *count); michael@0: CK_RV (*sdb_FindObjectsFinal)(SDB *sdb, SDBFind *find); michael@0: CK_RV (*sdb_GetAttributeValue)(SDB *sdb, CK_OBJECT_HANDLE object, michael@0: CK_ATTRIBUTE *template, CK_ULONG count); michael@0: CK_RV (*sdb_SetAttributeValue)(SDB *sdb, CK_OBJECT_HANDLE object, michael@0: const CK_ATTRIBUTE *template, CK_ULONG count); michael@0: CK_RV (*sdb_CreateObject)(SDB *sdb, CK_OBJECT_HANDLE *object, michael@0: const CK_ATTRIBUTE *template, CK_ULONG count); michael@0: CK_RV (*sdb_DestroyObject)(SDB *sdb, CK_OBJECT_HANDLE object); michael@0: CK_RV (*sdb_GetMetaData)(SDB *sdb, const char *id, michael@0: SECItem *item1, SECItem *item2); michael@0: CK_RV (*sdb_PutMetaData)(SDB *sdb, const char *id, michael@0: const SECItem *item1, const SECItem *item2); michael@0: CK_RV (*sdb_Begin)(SDB *sdb); michael@0: CK_RV (*sdb_Commit)(SDB *sdb); michael@0: CK_RV (*sdb_Abort)(SDB *sdb); michael@0: CK_RV (*sdb_Reset)(SDB *sdb); michael@0: CK_RV (*sdb_Close)(SDB *sdb); michael@0: void (*sdb_SetForkState)(PRBool forked); michael@0: }; michael@0: michael@0: CK_RV s_open(const char *directory, const char *certPrefix, michael@0: const char *keyPrefix, michael@0: int cert_version, int key_version, michael@0: int flags, SDB **certdb, SDB **keydb, int *newInit); michael@0: CK_RV s_shutdown(); michael@0: michael@0: /* flags */ michael@0: #define SDB_RDONLY 1 michael@0: #define SDB_RDWR 2 michael@0: #define SDB_CREATE 4 michael@0: #define SDB_HAS_META 8 michael@0: michael@0: #endif