sftkdbti.h (3493B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 #ifndef SFTKDBTI_H 6 #define SFTKDBTI_H 1 7 8 /* 9 * private defines 10 */ 11 struct SFTKDBHandleStr { 12 SDB *db; 13 PRInt32 ref; 14 CK_OBJECT_HANDLE type; 15 SECItem passwordKey; 16 int defaultIterationCount; 17 SECItem *newKey; 18 int newDefaultIterationCount; 19 SECItem *oldKey; 20 SECItem *updatePasswordKey; 21 PZLock *passwordLock; 22 SFTKDBHandle *peerDB; 23 SDB *update; 24 char *updateID; 25 PRBool updateDBIsInit; 26 PRBool usesLegacyStorage; 27 }; 28 29 extern const CK_ATTRIBUTE_TYPE sftkdb_known_attributes[]; 30 extern size_t sftkdb_known_attributes_size; 31 32 #define SFTK_KEYDB_TYPE 0x40000000 33 #define SFTK_CERTDB_TYPE 0x00000000 34 #define SFTK_OBJ_TYPE_MASK 0xc0000000 35 #define SFTK_OBJ_ID_MASK (~SFTK_OBJ_TYPE_MASK) 36 #define SFTK_TOKEN_TYPE 0x80000000 37 38 /* the following is the number of id's to handle on the stack at a time, 39 * it's not an upper limit of IDS that can be stored in the database */ 40 #define SFTK_MAX_IDS 10 41 42 #define SFTK_GET_SDB(handle) \ 43 ((handle)->update ? (handle)->update : (handle)->db) 44 45 SECStatus sftkdb_DecryptAttribute(SFTKDBHandle *handle, 46 SECItem *passKey, 47 CK_OBJECT_HANDLE id, 48 CK_ATTRIBUTE_TYPE attrType, 49 SECItem *cipherText, SECItem **plainText); 50 SECStatus sftkdb_EncryptAttribute(PLArenaPool *arena, 51 SFTKDBHandle *handle, SDB *db, 52 SECItem *passKey, 53 int iterationCount, 54 CK_OBJECT_HANDLE id, 55 CK_ATTRIBUTE_TYPE attrType, 56 SECItem *plainText, SECItem **cipherText); 57 SECStatus sftkdb_SignAttribute(PLArenaPool *arena, 58 SFTKDBHandle *handle, SDB *db, 59 SECItem *passKey, 60 int iterationCount, CK_OBJECT_HANDLE objectID, 61 CK_ATTRIBUTE_TYPE attrType, 62 SECItem *plainText, SECItem **sigText); 63 SECStatus sftkdb_VerifyAttribute(SFTKDBHandle *handle, 64 SECItem *passKey, 65 CK_OBJECT_HANDLE objectID, 66 CK_ATTRIBUTE_TYPE attrType, 67 SECItem *plainText, SECItem *sigText); 68 69 PRBool sftkdb_isULONGAttribute(CK_ATTRIBUTE_TYPE type); 70 void sftk_ULong2SDBULong(unsigned char *data, CK_ULONG value); 71 CK_RV sftkdb_Update(SFTKDBHandle *handle, SECItem *key); 72 CK_RV sftkdb_PutAttributeSignature(SFTKDBHandle *handle, 73 SDB *keyTarget, CK_OBJECT_HANDLE objectID, 74 CK_ATTRIBUTE_TYPE type, SECItem *signText); 75 CK_RV sftkdb_GetAttributeSignature(SFTKDBHandle *handle, 76 SFTKDBHandle *keyHandle, 77 CK_OBJECT_HANDLE objectID, 78 CK_ATTRIBUTE_TYPE type, 79 SECItem *signText); 80 CK_RV 81 sftkdb_DestroyAttributeSignature(SFTKDBHandle *handle, SDB *db, 82 CK_OBJECT_HANDLE objectID, 83 CK_ATTRIBUTE_TYPE type); 84 85 #endif