1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/nss/lib/softoken/sftkdbti.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,60 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#ifndef SFTKDBTI_H 1.9 +#define SFTKDBTI_H 1 1.10 + 1.11 +/* 1.12 + * private defines 1.13 + */ 1.14 +struct SFTKDBHandleStr { 1.15 + SDB *db; 1.16 + PRInt32 ref; 1.17 + CK_OBJECT_HANDLE type; 1.18 + SECItem passwordKey; 1.19 + SECItem *newKey; 1.20 + SECItem *oldKey; 1.21 + SECItem *updatePasswordKey; 1.22 + PZLock *passwordLock; 1.23 + SFTKDBHandle *peerDB; 1.24 + SDB *update; 1.25 + char *updateID; 1.26 + PRBool updateDBIsInit; 1.27 +}; 1.28 + 1.29 +#define SFTK_KEYDB_TYPE 0x40000000 1.30 +#define SFTK_CERTDB_TYPE 0x00000000 1.31 +#define SFTK_OBJ_TYPE_MASK 0xc0000000 1.32 +#define SFTK_OBJ_ID_MASK (~SFTK_OBJ_TYPE_MASK) 1.33 +#define SFTK_TOKEN_TYPE 0x80000000 1.34 + 1.35 +/* the following is the number of id's to handle on the stack at a time, 1.36 + * it's not an upper limit of IDS that can be stored in the database */ 1.37 +#define SFTK_MAX_IDS 10 1.38 + 1.39 +#define SFTK_GET_SDB(handle) \ 1.40 + ((handle)->update ? (handle)->update : (handle)->db) 1.41 + 1.42 +SECStatus sftkdb_DecryptAttribute(SECItem *passKey, SECItem *cipherText, 1.43 + SECItem **plainText); 1.44 +SECStatus sftkdb_EncryptAttribute(PLArenaPool *arena, SECItem *passKey, 1.45 + SECItem *plainText, SECItem **cipherText); 1.46 +SECStatus sftkdb_SignAttribute(PLArenaPool *arena, SECItem *passKey, 1.47 + CK_OBJECT_HANDLE objectID, 1.48 + CK_ATTRIBUTE_TYPE attrType, 1.49 + SECItem *plainText, SECItem **sigText); 1.50 +SECStatus sftkdb_VerifyAttribute(SECItem *passKey, 1.51 + CK_OBJECT_HANDLE objectID, 1.52 + CK_ATTRIBUTE_TYPE attrType, 1.53 + SECItem *plainText, SECItem *sigText); 1.54 + 1.55 +void sftk_ULong2SDBULong(unsigned char *data, CK_ULONG value); 1.56 +CK_RV sftkdb_Update(SFTKDBHandle *handle, SECItem *key); 1.57 +CK_RV sftkdb_PutAttributeSignature(SFTKDBHandle *handle, 1.58 + SDB *keyTarget, CK_OBJECT_HANDLE objectID, 1.59 + CK_ATTRIBUTE_TYPE type, SECItem *signText); 1.60 + 1.61 + 1.62 + 1.63 +#endif