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.

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

mercurial