PageRenderTime 177ms CodeModel.GetById 73ms app.highlight 17ms RepoModel.GetById 81ms app.codeStats 0ms

/gecko_api/include/pk11priv.h

http://firefox-mac-pdf.googlecode.com/
C++ Header | 220 lines | 118 code | 28 blank | 74 comment | 0 complexity | 487420767b9bfabbe6744915f5c3863f MD5 | raw file
  1/* ***** BEGIN LICENSE BLOCK *****
  2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3 *
  4 * The contents of this file are subject to the Mozilla Public License Version
  5 * 1.1 (the "License"); you may not use this file except in compliance with
  6 * the License. You may obtain a copy of the License at
  7 * http://www.mozilla.org/MPL/
  8 *
  9 * Software distributed under the License is distributed on an "AS IS" basis,
 10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 11 * for the specific language governing rights and limitations under the
 12 * License.
 13 *
 14 * The Original Code is the Netscape security libraries.
 15 *
 16 * The Initial Developer of the Original Code is
 17 * Netscape Communications Corporation.
 18 * Portions created by the Initial Developer are Copyright (C) 1994-2000
 19 * the Initial Developer. All Rights Reserved.
 20 *
 21 * Contributor(s):
 22 *
 23 * Alternatively, the contents of this file may be used under the terms of
 24 * either the GNU General Public License Version 2 or later (the "GPL"), or
 25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 26 * in which case the provisions of the GPL or the LGPL are applicable instead
 27 * of those above. If you wish to allow use of your version of this file only
 28 * under the terms of either the GPL or the LGPL, and not to allow others to
 29 * use your version of this file under the terms of the MPL, indicate your
 30 * decision by deleting the provisions above and replace them with the notice
 31 * and other provisions required by the GPL or the LGPL. If you do not delete
 32 * the provisions above, a recipient may use your version of this file under
 33 * the terms of any one of the MPL, the GPL or the LGPL.
 34 *
 35 * ***** END LICENSE BLOCK ***** */
 36#ifndef _PK11PRIV_H_
 37#define _PK11PRIV_H_
 38#include "plarena.h"
 39#include "seccomon.h"
 40#include "secoidt.h"
 41#include "secdert.h"
 42#include "keyt.h"
 43#include "certt.h"
 44#include "pkcs11t.h"
 45#include "secmodt.h"
 46#include "seccomon.h"
 47#include "pkcs7t.h"
 48#include "cmsreclist.h"
 49
 50/*
 51 * These are the private NSS functions. They are not exported by nss.def, and
 52 * are not callable outside nss3.dll. 
 53 */
 54
 55SEC_BEGIN_PROTOS
 56
 57/************************************************************
 58 * Generic Slot Lists Management
 59 ************************************************************/
 60PK11SlotList * PK11_NewSlotList(void);
 61PK11SlotList * PK11_GetPrivateKeyTokens(CK_MECHANISM_TYPE type,
 62						PRBool needRW,void *wincx);
 63SECStatus PK11_AddSlotToList(PK11SlotList *list,PK11SlotInfo *slot);
 64SECStatus PK11_DeleteSlotFromList(PK11SlotList *list,PK11SlotListElement *le);
 65PK11SlotListElement *PK11_FindSlotElement(PK11SlotList *list,
 66							PK11SlotInfo *slot);
 67PK11SlotInfo *PK11_FindSlotBySerial(char *serial);
 68int PK11_GetMaxKeyLength(CK_MECHANISM_TYPE type);
 69
 70/************************************************************
 71 * Generic Slot Management
 72 ************************************************************/
 73CK_OBJECT_HANDLE PK11_CopyKey(PK11SlotInfo *slot, CK_OBJECT_HANDLE srcObject);
 74SECStatus PK11_ReadAttribute(PK11SlotInfo *slot, CK_OBJECT_HANDLE id,
 75         CK_ATTRIBUTE_TYPE type, PRArenaPool *arena, SECItem *result);
 76CK_ULONG PK11_ReadULongAttribute(PK11SlotInfo *slot, CK_OBJECT_HANDLE id,
 77         CK_ATTRIBUTE_TYPE type);
 78char * PK11_MakeString(PRArenaPool *arena,char *space,char *staticSring,
 79								int stringLen);
 80int PK11_MapError(CK_RV error);
 81CK_SESSION_HANDLE PK11_GetRWSession(PK11SlotInfo *slot);
 82void PK11_RestoreROSession(PK11SlotInfo *slot,CK_SESSION_HANDLE rwsession);
 83PRBool PK11_RWSessionHasLock(PK11SlotInfo *slot,
 84					 CK_SESSION_HANDLE session_handle);
 85PK11SlotInfo *PK11_NewSlotInfo(SECMODModule *mod);
 86void PK11_EnterSlotMonitor(PK11SlotInfo *);
 87void PK11_ExitSlotMonitor(PK11SlotInfo *);
 88void PK11_CleanKeyList(PK11SlotInfo *slot);
 89
 90
 91/************************************************************
 92 *  Slot Password Management
 93 ************************************************************/
 94SECStatus PK11_DoPassword(PK11SlotInfo *slot, PRBool loadCerts, void *wincx);
 95SECStatus PK11_VerifyPW(PK11SlotInfo *slot,char *pw);
 96void PK11_HandlePasswordCheck(PK11SlotInfo *slot,void *wincx);
 97void PK11_SetVerifyPasswordFunc(PK11VerifyPasswordFunc func);
 98void PK11_SetIsLoggedInFunc(PK11IsLoggedInFunc func);
 99
100/************************************************************
101 * Manage the built-In Slot Lists
102 ************************************************************/
103SECStatus PK11_InitSlotLists(void);
104void PK11_DestroySlotLists(void);
105PK11SlotList *PK11_GetSlotList(CK_MECHANISM_TYPE type);
106void PK11_LoadSlotList(PK11SlotInfo *slot, PK11PreSlotInfo *psi, int count);
107void PK11_ClearSlotList(PK11SlotInfo *slot);
108
109
110/******************************************************************
111 *           Slot initialization
112 ******************************************************************/
113SECStatus PK11_InitToken(PK11SlotInfo *slot, PRBool loadCerts);
114void PK11_InitSlot(SECMODModule *mod,CK_SLOT_ID slotID,PK11SlotInfo *slot);
115PRBool PK11_NeedPWInitForSlot(PK11SlotInfo *slot);
116SECStatus PK11_ReadSlotCerts(PK11SlotInfo *slot);
117
118/*********************************************************************
119 *       Mechanism Mapping functions
120 *********************************************************************/
121void PK11_AddMechanismEntry(CK_MECHANISM_TYPE type, CK_KEY_TYPE key,
122	 	CK_MECHANISM_TYPE keygen, CK_MECHANISM_TYPE pad, 
123		int ivLen, int blocksize);
124CK_MECHANISM_TYPE PK11_GetKeyMechanism(CK_KEY_TYPE type);
125CK_MECHANISM_TYPE PK11_GetKeyGenWithSize(CK_MECHANISM_TYPE type, int size);
126
127/**********************************************************************
128 *                   Symetric, Public, and Private Keys 
129 **********************************************************************/
130/* Key Generation specialized for SDR (fixed DES3 key) */
131PK11SymKey *PK11_GenDES3TokenKey(PK11SlotInfo *slot, SECItem *keyid, void *cx);
132SECKEYPublicKey *PK11_ExtractPublicKey(PK11SlotInfo *slot, KeyType keyType,
133					 CK_OBJECT_HANDLE id);
134CK_OBJECT_HANDLE PK11_FindObjectForCert(CERTCertificate *cert,
135					void *wincx, PK11SlotInfo **pSlot);
136PK11SymKey * pk11_CopyToSlot(PK11SlotInfo *slot,CK_MECHANISM_TYPE type,
137		 	CK_ATTRIBUTE_TYPE operation, PK11SymKey *symKey);
138
139/**********************************************************************
140 *                   Certs
141 **********************************************************************/
142SECStatus PK11_TraversePrivateKeysInSlot( PK11SlotInfo *slot,
143    SECStatus(* callback)(SECKEYPrivateKey*, void*), void *arg);
144SECKEYPrivateKey * PK11_FindPrivateKeyFromNickname(char *nickname, void *wincx);
145CK_OBJECT_HANDLE * PK11_FindObjectsFromNickname(char *nickname,
146	PK11SlotInfo **slotptr, CK_OBJECT_CLASS objclass, int *returnCount, 
147								void *wincx);
148CK_OBJECT_HANDLE PK11_MatchItem(PK11SlotInfo *slot,CK_OBJECT_HANDLE peer,
149						CK_OBJECT_CLASS o_class); 
150CK_BBOOL PK11_HasAttributeSet( PK11SlotInfo *slot,
151			       CK_OBJECT_HANDLE id,
152			       CK_ATTRIBUTE_TYPE type );
153CK_RV PK11_GetAttributes(PRArenaPool *arena,PK11SlotInfo *slot,
154			 CK_OBJECT_HANDLE obj,CK_ATTRIBUTE *attr, int count);
155int PK11_NumberCertsForCertSubject(CERTCertificate *cert);
156SECStatus PK11_TraverseCertsForSubject(CERTCertificate *cert, 
157	SECStatus(*callback)(CERTCertificate *, void *), void *arg);
158CERTCertificate *PK11_FindCertFromDERCertItem(PK11SlotInfo *slot, 
159					  SECItem *derCert, void *wincx);
160SECStatus PK11_GetKEAMatchedCerts(PK11SlotInfo *slot1,
161   PK11SlotInfo *slot2, CERTCertificate **cert1, CERTCertificate **cert2);
162SECStatus PK11_TraverseCertsInSlot(PK11SlotInfo *slot,
163       SECStatus(* callback)(CERTCertificate*, void *), void *arg);
164SECStatus PK11_LookupCrls(CERTCrlHeadNode *nodes, int type, void *wincx);
165
166
167/**********************************************************************
168 *                   Crypto Contexts
169 **********************************************************************/
170PK11Context * PK11_CreateContextByRawKey(PK11SlotInfo *slot, 
171    CK_MECHANISM_TYPE type, PK11Origin origin, CK_ATTRIBUTE_TYPE operation,
172			 	SECItem *key, SECItem *param, void *wincx);
173PRBool PK11_HashOK(SECOidTag hashAlg);
174
175
176/**********************************************************************
177 * Functions which are  depricated....
178 **********************************************************************/
179
180SECItem *
181PK11_FindCrlByName(PK11SlotInfo **slot, CK_OBJECT_HANDLE *handle,
182					SECItem *derName, int type, char **url);
183
184CK_OBJECT_HANDLE
185PK11_PutCrl(PK11SlotInfo *slot, SECItem *crl, 
186				SECItem *name, char *url, int type);
187
188SECItem *
189PK11_FindSMimeProfile(PK11SlotInfo **slotp, char *emailAddr, SECItem *derSubj,
190					SECItem **profileTime);
191SECStatus
192PK11_SaveSMimeProfile(PK11SlotInfo *slot, char *emailAddr, SECItem *derSubj,
193			SECItem *emailProfile, SECItem *profileTime);
194
195PRBool PK11_IsPermObject(PK11SlotInfo *slot, CK_OBJECT_HANDLE handle);
196
197char * PK11_GetObjectNickname(PK11SlotInfo *slot, CK_OBJECT_HANDLE id) ;
198SECStatus PK11_SetObjectNickname(PK11SlotInfo *slot, CK_OBJECT_HANDLE id, 
199						const char *nickname) ;
200
201
202/* private */
203SECStatus pk11_TraverseAllSlots( SECStatus (*callback)(PK11SlotInfo *,void *),
204	void *cbArg, PRBool forceLogin, void *pwArg);
205
206/* fetch multiple CRLs for a specific issuer */
207SECStatus pk11_RetrieveCrls(CERTCrlHeadNode *nodes, SECItem* issuer,
208                                   void *wincx);
209
210/* set global options for NSS PKCS#11 module loader */
211SECStatus pk11_setGlobalOptions(PRBool noSingleThreadedModules,
212                                PRBool allowAlreadyInitializedModules,
213                                PRBool dontFinalizeModules);
214
215/* return whether NSS is allowed to call C_Finalize */
216PRBool pk11_getFinalizeModulesOption(void);
217
218SEC_END_PROTOS
219
220#endif