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: #ifndef SFTKDBTI_H michael@0: #define SFTKDBTI_H 1 michael@0: michael@0: /* michael@0: * private defines michael@0: */ michael@0: struct SFTKDBHandleStr { michael@0: SDB *db; michael@0: PRInt32 ref; michael@0: CK_OBJECT_HANDLE type; michael@0: SECItem passwordKey; michael@0: SECItem *newKey; michael@0: SECItem *oldKey; michael@0: SECItem *updatePasswordKey; michael@0: PZLock *passwordLock; michael@0: SFTKDBHandle *peerDB; michael@0: SDB *update; michael@0: char *updateID; michael@0: PRBool updateDBIsInit; michael@0: }; michael@0: michael@0: #define SFTK_KEYDB_TYPE 0x40000000 michael@0: #define SFTK_CERTDB_TYPE 0x00000000 michael@0: #define SFTK_OBJ_TYPE_MASK 0xc0000000 michael@0: #define SFTK_OBJ_ID_MASK (~SFTK_OBJ_TYPE_MASK) michael@0: #define SFTK_TOKEN_TYPE 0x80000000 michael@0: michael@0: /* the following is the number of id's to handle on the stack at a time, michael@0: * it's not an upper limit of IDS that can be stored in the database */ michael@0: #define SFTK_MAX_IDS 10 michael@0: michael@0: #define SFTK_GET_SDB(handle) \ michael@0: ((handle)->update ? (handle)->update : (handle)->db) michael@0: michael@0: SECStatus sftkdb_DecryptAttribute(SECItem *passKey, SECItem *cipherText, michael@0: SECItem **plainText); michael@0: SECStatus sftkdb_EncryptAttribute(PLArenaPool *arena, SECItem *passKey, michael@0: SECItem *plainText, SECItem **cipherText); michael@0: SECStatus sftkdb_SignAttribute(PLArenaPool *arena, SECItem *passKey, michael@0: CK_OBJECT_HANDLE objectID, michael@0: CK_ATTRIBUTE_TYPE attrType, michael@0: SECItem *plainText, SECItem **sigText); michael@0: SECStatus sftkdb_VerifyAttribute(SECItem *passKey, michael@0: CK_OBJECT_HANDLE objectID, michael@0: CK_ATTRIBUTE_TYPE attrType, michael@0: SECItem *plainText, SECItem *sigText); michael@0: michael@0: void sftk_ULong2SDBULong(unsigned char *data, CK_ULONG value); michael@0: CK_RV sftkdb_Update(SFTKDBHandle *handle, SECItem *key); michael@0: CK_RV sftkdb_PutAttributeSignature(SFTKDBHandle *handle, michael@0: SDB *keyTarget, CK_OBJECT_HANDLE objectID, michael@0: CK_ATTRIBUTE_TYPE type, SECItem *signText); michael@0: michael@0: michael@0: michael@0: #endif