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: #include "sftkdbt.h" michael@0: #include "sdb.h" michael@0: #include "pkcs11i.h" michael@0: #include "pkcs11t.h" michael@0: michael@0: /* raw database stuff */ michael@0: CK_RV sftkdb_write(SFTKDBHandle *handle, SFTKObject *,CK_OBJECT_HANDLE *); michael@0: CK_RV sftkdb_FindObjectsInit(SFTKDBHandle *sdb, const CK_ATTRIBUTE *template, michael@0: CK_ULONG count, SDBFind **find); michael@0: CK_RV sftkdb_FindObjects(SFTKDBHandle *sdb, SDBFind *find, michael@0: CK_OBJECT_HANDLE *ids, int arraySize, CK_ULONG *count); michael@0: CK_RV sftkdb_FindObjectsFinal(SFTKDBHandle *sdb, SDBFind *find); michael@0: CK_RV sftkdb_GetAttributeValue(SFTKDBHandle *handle, michael@0: CK_OBJECT_HANDLE object_id, CK_ATTRIBUTE *template, CK_ULONG count); michael@0: CK_RV sftkdb_SetAttributeValue(SFTKDBHandle *handle, SFTKObject *object, michael@0: const CK_ATTRIBUTE *template, CK_ULONG count); michael@0: CK_RV sftkdb_DestroyObject(SFTKDBHandle *handle, CK_OBJECT_HANDLE object_id); michael@0: CK_RV sftkdb_closeDB(SFTKDBHandle *handle); michael@0: michael@0: /* keydb functions */ michael@0: michael@0: SECStatus sftkdb_PWIsInitialized(SFTKDBHandle *keydb); michael@0: SECStatus sftkdb_CheckPassword(SFTKDBHandle *keydb, const char *pw, michael@0: PRBool *tokenRemoved); michael@0: SECStatus sftkdb_PWCached(SFTKDBHandle *keydb); michael@0: SECStatus sftkdb_HasPasswordSet(SFTKDBHandle *keydb); michael@0: SECStatus sftkdb_ResetKeyDB(SFTKDBHandle *keydb); michael@0: SECStatus sftkdb_ChangePassword(SFTKDBHandle *keydb, michael@0: char *oldPin, char *newPin, michael@0: PRBool *tokenRemoved); michael@0: SECStatus sftkdb_ClearPassword(SFTKDBHandle *keydb); michael@0: PRBool sftkdb_InUpdateMerge(SFTKDBHandle *keydb); michael@0: PRBool sftkdb_NeedUpdateDBPassword(SFTKDBHandle *keydb); michael@0: const char *sftkdb_GetUpdateID(SFTKDBHandle *keydb); michael@0: SECItem *sftkdb_GetUpdatePasswordKey(SFTKDBHandle *keydb); michael@0: void sftkdb_FreeUpdatePasswordKey(SFTKDBHandle *keydb); michael@0: michael@0: /* Utility functions */ michael@0: /* michael@0: * OK there are now lots of options here, lets go through them all: michael@0: * michael@0: * configdir - base directory where all the cert, key, and module datbases live. michael@0: * certPrefix - prefix added to the beginning of the cert database example: " michael@0: * "https-server1-" michael@0: * keyPrefix - prefix added to the beginning of the key database example: " michael@0: * "https-server1-" michael@0: * secmodName - name of the security module database (usually "secmod.db"). michael@0: * readOnly - Boolean: true if the databases are to be openned read only. michael@0: * nocertdb - Don't open the cert DB and key DB's, just initialize the michael@0: * Volatile certdb. michael@0: * nomoddb - Don't open the security module DB, just initialize the michael@0: * PKCS #11 module. michael@0: * forceOpen - Continue to force initializations even if the databases cannot michael@0: * be opened. michael@0: */ michael@0: CK_RV sftk_DBInit(const char *configdir, const char *certPrefix, michael@0: const char *keyPrefix, const char *updatedir, michael@0: const char *updCertPrefix, const char *updKeyPrefix, michael@0: const char *updateID, PRBool readOnly, PRBool noCertDB, michael@0: PRBool noKeyDB, PRBool forceOpen, PRBool isFIPS, michael@0: SFTKDBHandle **certDB, SFTKDBHandle **keyDB); michael@0: CK_RV sftkdb_Shutdown(void); michael@0: michael@0: SFTKDBHandle *sftk_getCertDB(SFTKSlot *slot); michael@0: SFTKDBHandle *sftk_getKeyDB(SFTKSlot *slot); michael@0: SFTKDBHandle *sftk_getDBForTokenObject(SFTKSlot *slot, michael@0: CK_OBJECT_HANDLE objectID); michael@0: void sftk_freeDB(SFTKDBHandle *certHandle);