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