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