security/nss/lib/pk11wrap/pk11priv.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4 #ifndef _PK11PRIV_H_
michael@0 5 #define _PK11PRIV_H_
michael@0 6 #include "plarena.h"
michael@0 7 #include "seccomon.h"
michael@0 8 #include "secoidt.h"
michael@0 9 #include "secdert.h"
michael@0 10 #include "keyt.h"
michael@0 11 #include "certt.h"
michael@0 12 #include "pkcs11t.h"
michael@0 13 #include "secmodt.h"
michael@0 14 #include "seccomon.h"
michael@0 15 #include "pkcs7t.h"
michael@0 16 #include "cmsreclist.h"
michael@0 17
michael@0 18 /*
michael@0 19 * These are the private NSS functions. They are not exported by nss.def, and
michael@0 20 * are not callable outside nss3.dll.
michael@0 21 */
michael@0 22
michael@0 23 SEC_BEGIN_PROTOS
michael@0 24
michael@0 25 /************************************************************
michael@0 26 * Generic Slot Lists Management
michael@0 27 ************************************************************/
michael@0 28 PK11SlotList * PK11_NewSlotList(void);
michael@0 29 PK11SlotList * PK11_GetPrivateKeyTokens(CK_MECHANISM_TYPE type,
michael@0 30 PRBool needRW,void *wincx);
michael@0 31 SECStatus PK11_AddSlotToList(PK11SlotList *list,PK11SlotInfo *slot, PRBool sorted);
michael@0 32 SECStatus PK11_DeleteSlotFromList(PK11SlotList *list,PK11SlotListElement *le);
michael@0 33 PK11SlotListElement *PK11_FindSlotElement(PK11SlotList *list,
michael@0 34 PK11SlotInfo *slot);
michael@0 35 PK11SlotInfo *PK11_FindSlotBySerial(char *serial);
michael@0 36 int PK11_GetMaxKeyLength(CK_MECHANISM_TYPE type);
michael@0 37
michael@0 38 /************************************************************
michael@0 39 * Generic Slot Management
michael@0 40 ************************************************************/
michael@0 41 CK_OBJECT_HANDLE PK11_CopyKey(PK11SlotInfo *slot, CK_OBJECT_HANDLE srcObject);
michael@0 42 SECStatus PK11_ReadAttribute(PK11SlotInfo *slot, CK_OBJECT_HANDLE id,
michael@0 43 CK_ATTRIBUTE_TYPE type, PLArenaPool *arena, SECItem *result);
michael@0 44 CK_ULONG PK11_ReadULongAttribute(PK11SlotInfo *slot, CK_OBJECT_HANDLE id,
michael@0 45 CK_ATTRIBUTE_TYPE type);
michael@0 46 char * PK11_MakeString(PLArenaPool *arena,char *space,char *staticSring,
michael@0 47 int stringLen);
michael@0 48 int PK11_MapError(CK_RV error);
michael@0 49 CK_SESSION_HANDLE PK11_GetRWSession(PK11SlotInfo *slot);
michael@0 50 void PK11_RestoreROSession(PK11SlotInfo *slot,CK_SESSION_HANDLE rwsession);
michael@0 51 PRBool PK11_RWSessionHasLock(PK11SlotInfo *slot,
michael@0 52 CK_SESSION_HANDLE session_handle);
michael@0 53 PK11SlotInfo *PK11_NewSlotInfo(SECMODModule *mod);
michael@0 54 void PK11_EnterSlotMonitor(PK11SlotInfo *);
michael@0 55 void PK11_ExitSlotMonitor(PK11SlotInfo *);
michael@0 56 void PK11_CleanKeyList(PK11SlotInfo *slot);
michael@0 57
michael@0 58
michael@0 59 /************************************************************
michael@0 60 * Slot Password Management
michael@0 61 ************************************************************/
michael@0 62 SECStatus PK11_DoPassword(PK11SlotInfo *slot, CK_SESSION_HANDLE session,
michael@0 63 PRBool loadCerts, void *wincx, PRBool alreadyLocked,
michael@0 64 PRBool contextSpecific);
michael@0 65 SECStatus PK11_VerifyPW(PK11SlotInfo *slot,char *pw);
michael@0 66 void PK11_HandlePasswordCheck(PK11SlotInfo *slot,void *wincx);
michael@0 67 void PK11_SetVerifyPasswordFunc(PK11VerifyPasswordFunc func);
michael@0 68 void PK11_SetIsLoggedInFunc(PK11IsLoggedInFunc func);
michael@0 69
michael@0 70 /************************************************************
michael@0 71 * Manage the built-In Slot Lists
michael@0 72 ************************************************************/
michael@0 73 SECStatus PK11_InitSlotLists(void);
michael@0 74 void PK11_DestroySlotLists(void);
michael@0 75 PK11SlotList *PK11_GetSlotList(CK_MECHANISM_TYPE type);
michael@0 76 void PK11_LoadSlotList(PK11SlotInfo *slot, PK11PreSlotInfo *psi, int count);
michael@0 77 void PK11_ClearSlotList(PK11SlotInfo *slot);
michael@0 78
michael@0 79
michael@0 80 /******************************************************************
michael@0 81 * Slot initialization
michael@0 82 ******************************************************************/
michael@0 83 SECStatus PK11_InitToken(PK11SlotInfo *slot, PRBool loadCerts);
michael@0 84 void PK11_InitSlot(SECMODModule *mod,CK_SLOT_ID slotID,PK11SlotInfo *slot);
michael@0 85 PRBool PK11_NeedPWInitForSlot(PK11SlotInfo *slot);
michael@0 86 SECStatus PK11_ReadSlotCerts(PK11SlotInfo *slot);
michael@0 87 void pk11_SetInternalKeySlot(PK11SlotInfo *slot);
michael@0 88 PK11SlotInfo *pk11_SwapInternalKeySlot(PK11SlotInfo *slot);
michael@0 89 void pk11_SetInternalKeySlotIfFirst(PK11SlotInfo *slot);
michael@0 90
michael@0 91 /*********************************************************************
michael@0 92 * Mechanism Mapping functions
michael@0 93 *********************************************************************/
michael@0 94 void PK11_AddMechanismEntry(CK_MECHANISM_TYPE type, CK_KEY_TYPE key,
michael@0 95 CK_MECHANISM_TYPE keygen, CK_MECHANISM_TYPE pad,
michael@0 96 int ivLen, int blocksize);
michael@0 97 CK_MECHANISM_TYPE PK11_GetKeyMechanism(CK_KEY_TYPE type);
michael@0 98 CK_MECHANISM_TYPE PK11_GetKeyGenWithSize(CK_MECHANISM_TYPE type, int size);
michael@0 99
michael@0 100 /**********************************************************************
michael@0 101 * Symetric, Public, and Private Keys
michael@0 102 **********************************************************************/
michael@0 103 /* Key Generation specialized for SDR (fixed DES3 key) */
michael@0 104 PK11SymKey *PK11_GenDES3TokenKey(PK11SlotInfo *slot, SECItem *keyid, void *cx);
michael@0 105 SECKEYPublicKey *PK11_ExtractPublicKey(PK11SlotInfo *slot, KeyType keyType,
michael@0 106 CK_OBJECT_HANDLE id);
michael@0 107 CK_OBJECT_HANDLE PK11_FindObjectForCert(CERTCertificate *cert,
michael@0 108 void *wincx, PK11SlotInfo **pSlot);
michael@0 109 PK11SymKey * pk11_CopyToSlot(PK11SlotInfo *slot,CK_MECHANISM_TYPE type,
michael@0 110 CK_ATTRIBUTE_TYPE operation, PK11SymKey *symKey);
michael@0 111
michael@0 112 /**********************************************************************
michael@0 113 * Certs
michael@0 114 **********************************************************************/
michael@0 115 SECStatus PK11_TraversePrivateKeysInSlot( PK11SlotInfo *slot,
michael@0 116 SECStatus(* callback)(SECKEYPrivateKey*, void*), void *arg);
michael@0 117 SECKEYPrivateKey * PK11_FindPrivateKeyFromNickname(char *nickname, void *wincx);
michael@0 118 CK_OBJECT_HANDLE * PK11_FindObjectsFromNickname(char *nickname,
michael@0 119 PK11SlotInfo **slotptr, CK_OBJECT_CLASS objclass, int *returnCount,
michael@0 120 void *wincx);
michael@0 121 CK_OBJECT_HANDLE PK11_MatchItem(PK11SlotInfo *slot,CK_OBJECT_HANDLE peer,
michael@0 122 CK_OBJECT_CLASS o_class);
michael@0 123 CK_BBOOL PK11_HasAttributeSet( PK11SlotInfo *slot,
michael@0 124 CK_OBJECT_HANDLE id,
michael@0 125 CK_ATTRIBUTE_TYPE type,
michael@0 126 PRBool haslock );
michael@0 127 CK_RV PK11_GetAttributes(PLArenaPool *arena,PK11SlotInfo *slot,
michael@0 128 CK_OBJECT_HANDLE obj,CK_ATTRIBUTE *attr, int count);
michael@0 129 int PK11_NumberCertsForCertSubject(CERTCertificate *cert);
michael@0 130 SECStatus PK11_TraverseCertsForSubject(CERTCertificate *cert,
michael@0 131 SECStatus(*callback)(CERTCertificate *, void *), void *arg);
michael@0 132 SECStatus PK11_GetKEAMatchedCerts(PK11SlotInfo *slot1,
michael@0 133 PK11SlotInfo *slot2, CERTCertificate **cert1, CERTCertificate **cert2);
michael@0 134 SECStatus PK11_TraverseCertsInSlot(PK11SlotInfo *slot,
michael@0 135 SECStatus(* callback)(CERTCertificate*, void *), void *arg);
michael@0 136 SECStatus PK11_LookupCrls(CERTCrlHeadNode *nodes, int type, void *wincx);
michael@0 137
michael@0 138
michael@0 139 /**********************************************************************
michael@0 140 * Crypto Contexts
michael@0 141 **********************************************************************/
michael@0 142 PK11Context * PK11_CreateContextByRawKey(PK11SlotInfo *slot,
michael@0 143 CK_MECHANISM_TYPE type, PK11Origin origin, CK_ATTRIBUTE_TYPE operation,
michael@0 144 SECItem *key, SECItem *param, void *wincx);
michael@0 145 PRBool PK11_HashOK(SECOidTag hashAlg);
michael@0 146
michael@0 147
michael@0 148 /**********************************************************************
michael@0 149 * Functions which are deprecated....
michael@0 150 **********************************************************************/
michael@0 151
michael@0 152 SECItem *
michael@0 153 PK11_FindCrlByName(PK11SlotInfo **slot, CK_OBJECT_HANDLE *handle,
michael@0 154 SECItem *derName, int type, char **url);
michael@0 155
michael@0 156 CK_OBJECT_HANDLE
michael@0 157 PK11_PutCrl(PK11SlotInfo *slot, SECItem *crl,
michael@0 158 SECItem *name, char *url, int type);
michael@0 159
michael@0 160 SECItem *
michael@0 161 PK11_FindSMimeProfile(PK11SlotInfo **slotp, char *emailAddr, SECItem *derSubj,
michael@0 162 SECItem **profileTime);
michael@0 163 SECStatus
michael@0 164 PK11_SaveSMimeProfile(PK11SlotInfo *slot, char *emailAddr, SECItem *derSubj,
michael@0 165 SECItem *emailProfile, SECItem *profileTime);
michael@0 166
michael@0 167 PRBool PK11_IsPermObject(PK11SlotInfo *slot, CK_OBJECT_HANDLE handle);
michael@0 168
michael@0 169 char * PK11_GetObjectNickname(PK11SlotInfo *slot, CK_OBJECT_HANDLE id) ;
michael@0 170 SECStatus PK11_SetObjectNickname(PK11SlotInfo *slot, CK_OBJECT_HANDLE id,
michael@0 171 const char *nickname) ;
michael@0 172
michael@0 173
michael@0 174 /* private */
michael@0 175 SECStatus pk11_TraverseAllSlots( SECStatus (*callback)(PK11SlotInfo *,void *),
michael@0 176 void *cbArg, PRBool forceLogin, void *pwArg);
michael@0 177
michael@0 178 /* fetch multiple CRLs for a specific issuer */
michael@0 179 SECStatus pk11_RetrieveCrls(CERTCrlHeadNode *nodes, SECItem* issuer,
michael@0 180 void *wincx);
michael@0 181
michael@0 182 /* set global options for NSS PKCS#11 module loader */
michael@0 183 SECStatus pk11_setGlobalOptions(PRBool noSingleThreadedModules,
michael@0 184 PRBool allowAlreadyInitializedModules,
michael@0 185 PRBool dontFinalizeModules);
michael@0 186
michael@0 187 /* return whether NSS is allowed to call C_Finalize */
michael@0 188 PRBool pk11_getFinalizeModulesOption(void);
michael@0 189
michael@0 190 SEC_END_PROTOS
michael@0 191
michael@0 192 #endif

mercurial