Bug 460926 A11y hierachy is broken on Ubuntu 8.10 (GNOME 2.24), r=Evan.Yan sr=roc
[wine-gecko.git] / security / nss / lib / pk11wrap / pk11priv.h
blob6b90c25d7e50f5a11c06fc2046b274d558ee6f10
1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
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/
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.
14 * The Original Code is the Netscape security libraries.
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.
21 * Contributor(s):
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.
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"
51 * These are the private NSS functions. They are not exported by nss.def, and
52 * are not callable outside nss3.dll.
55 SEC_BEGIN_PROTOS
57 /************************************************************
58 * Generic Slot Lists Management
59 ************************************************************/
60 PK11SlotList * PK11_NewSlotList(void);
61 PK11SlotList * PK11_GetPrivateKeyTokens(CK_MECHANISM_TYPE type,
62 PRBool needRW,void *wincx);
63 SECStatus PK11_AddSlotToList(PK11SlotList *list,PK11SlotInfo *slot);
64 SECStatus PK11_DeleteSlotFromList(PK11SlotList *list,PK11SlotListElement *le);
65 PK11SlotListElement *PK11_FindSlotElement(PK11SlotList *list,
66 PK11SlotInfo *slot);
67 PK11SlotInfo *PK11_FindSlotBySerial(char *serial);
68 int PK11_GetMaxKeyLength(CK_MECHANISM_TYPE type);
70 /************************************************************
71 * Generic Slot Management
72 ************************************************************/
73 CK_OBJECT_HANDLE PK11_CopyKey(PK11SlotInfo *slot, CK_OBJECT_HANDLE srcObject);
74 SECStatus PK11_ReadAttribute(PK11SlotInfo *slot, CK_OBJECT_HANDLE id,
75 CK_ATTRIBUTE_TYPE type, PLArenaPool *arena, SECItem *result);
76 CK_ULONG PK11_ReadULongAttribute(PK11SlotInfo *slot, CK_OBJECT_HANDLE id,
77 CK_ATTRIBUTE_TYPE type);
78 char * PK11_MakeString(PLArenaPool *arena,char *space,char *staticSring,
79 int stringLen);
80 int PK11_MapError(CK_RV error);
81 CK_SESSION_HANDLE PK11_GetRWSession(PK11SlotInfo *slot);
82 void PK11_RestoreROSession(PK11SlotInfo *slot,CK_SESSION_HANDLE rwsession);
83 PRBool PK11_RWSessionHasLock(PK11SlotInfo *slot,
84 CK_SESSION_HANDLE session_handle);
85 PK11SlotInfo *PK11_NewSlotInfo(SECMODModule *mod);
86 void PK11_EnterSlotMonitor(PK11SlotInfo *);
87 void PK11_ExitSlotMonitor(PK11SlotInfo *);
88 void PK11_CleanKeyList(PK11SlotInfo *slot);
91 /************************************************************
92 * Slot Password Management
93 ************************************************************/
94 SECStatus PK11_DoPassword(PK11SlotInfo *slot, PRBool loadCerts, void *wincx);
95 SECStatus PK11_VerifyPW(PK11SlotInfo *slot,char *pw);
96 void PK11_HandlePasswordCheck(PK11SlotInfo *slot,void *wincx);
97 void PK11_SetVerifyPasswordFunc(PK11VerifyPasswordFunc func);
98 void PK11_SetIsLoggedInFunc(PK11IsLoggedInFunc func);
100 /************************************************************
101 * Manage the built-In Slot Lists
102 ************************************************************/
103 SECStatus PK11_InitSlotLists(void);
104 void PK11_DestroySlotLists(void);
105 PK11SlotList *PK11_GetSlotList(CK_MECHANISM_TYPE type);
106 void PK11_LoadSlotList(PK11SlotInfo *slot, PK11PreSlotInfo *psi, int count);
107 void PK11_ClearSlotList(PK11SlotInfo *slot);
110 /******************************************************************
111 * Slot initialization
112 ******************************************************************/
113 SECStatus PK11_InitToken(PK11SlotInfo *slot, PRBool loadCerts);
114 void PK11_InitSlot(SECMODModule *mod,CK_SLOT_ID slotID,PK11SlotInfo *slot);
115 PRBool PK11_NeedPWInitForSlot(PK11SlotInfo *slot);
116 SECStatus PK11_ReadSlotCerts(PK11SlotInfo *slot);
118 /*********************************************************************
119 * Mechanism Mapping functions
120 *********************************************************************/
121 void PK11_AddMechanismEntry(CK_MECHANISM_TYPE type, CK_KEY_TYPE key,
122 CK_MECHANISM_TYPE keygen, CK_MECHANISM_TYPE pad,
123 int ivLen, int blocksize);
124 CK_MECHANISM_TYPE PK11_GetKeyMechanism(CK_KEY_TYPE type);
125 CK_MECHANISM_TYPE PK11_GetKeyGenWithSize(CK_MECHANISM_TYPE type, int size);
127 /**********************************************************************
128 * Symetric, Public, and Private Keys
129 **********************************************************************/
130 /* Key Generation specialized for SDR (fixed DES3 key) */
131 PK11SymKey *PK11_GenDES3TokenKey(PK11SlotInfo *slot, SECItem *keyid, void *cx);
132 SECKEYPublicKey *PK11_ExtractPublicKey(PK11SlotInfo *slot, KeyType keyType,
133 CK_OBJECT_HANDLE id);
134 CK_OBJECT_HANDLE PK11_FindObjectForCert(CERTCertificate *cert,
135 void *wincx, PK11SlotInfo **pSlot);
136 PK11SymKey * pk11_CopyToSlot(PK11SlotInfo *slot,CK_MECHANISM_TYPE type,
137 CK_ATTRIBUTE_TYPE operation, PK11SymKey *symKey);
139 /**********************************************************************
140 * Certs
141 **********************************************************************/
142 SECStatus PK11_TraversePrivateKeysInSlot( PK11SlotInfo *slot,
143 SECStatus(* callback)(SECKEYPrivateKey*, void*), void *arg);
144 SECKEYPrivateKey * PK11_FindPrivateKeyFromNickname(char *nickname, void *wincx);
145 CK_OBJECT_HANDLE * PK11_FindObjectsFromNickname(char *nickname,
146 PK11SlotInfo **slotptr, CK_OBJECT_CLASS objclass, int *returnCount,
147 void *wincx);
148 CK_OBJECT_HANDLE PK11_MatchItem(PK11SlotInfo *slot,CK_OBJECT_HANDLE peer,
149 CK_OBJECT_CLASS o_class);
150 CK_BBOOL PK11_HasAttributeSet( PK11SlotInfo *slot,
151 CK_OBJECT_HANDLE id,
152 CK_ATTRIBUTE_TYPE type );
153 CK_RV PK11_GetAttributes(PLArenaPool *arena,PK11SlotInfo *slot,
154 CK_OBJECT_HANDLE obj,CK_ATTRIBUTE *attr, int count);
155 int PK11_NumberCertsForCertSubject(CERTCertificate *cert);
156 SECStatus PK11_TraverseCertsForSubject(CERTCertificate *cert,
157 SECStatus(*callback)(CERTCertificate *, void *), void *arg);
158 SECStatus PK11_GetKEAMatchedCerts(PK11SlotInfo *slot1,
159 PK11SlotInfo *slot2, CERTCertificate **cert1, CERTCertificate **cert2);
160 SECStatus PK11_TraverseCertsInSlot(PK11SlotInfo *slot,
161 SECStatus(* callback)(CERTCertificate*, void *), void *arg);
162 SECStatus PK11_LookupCrls(CERTCrlHeadNode *nodes, int type, void *wincx);
165 /**********************************************************************
166 * Crypto Contexts
167 **********************************************************************/
168 PK11Context * PK11_CreateContextByRawKey(PK11SlotInfo *slot,
169 CK_MECHANISM_TYPE type, PK11Origin origin, CK_ATTRIBUTE_TYPE operation,
170 SECItem *key, SECItem *param, void *wincx);
171 PRBool PK11_HashOK(SECOidTag hashAlg);
174 /**********************************************************************
175 * Functions which are deprecated....
176 **********************************************************************/
178 SECItem *
179 PK11_FindCrlByName(PK11SlotInfo **slot, CK_OBJECT_HANDLE *handle,
180 SECItem *derName, int type, char **url);
182 CK_OBJECT_HANDLE
183 PK11_PutCrl(PK11SlotInfo *slot, SECItem *crl,
184 SECItem *name, char *url, int type);
186 SECItem *
187 PK11_FindSMimeProfile(PK11SlotInfo **slotp, char *emailAddr, SECItem *derSubj,
188 SECItem **profileTime);
189 SECStatus
190 PK11_SaveSMimeProfile(PK11SlotInfo *slot, char *emailAddr, SECItem *derSubj,
191 SECItem *emailProfile, SECItem *profileTime);
193 PRBool PK11_IsPermObject(PK11SlotInfo *slot, CK_OBJECT_HANDLE handle);
195 char * PK11_GetObjectNickname(PK11SlotInfo *slot, CK_OBJECT_HANDLE id) ;
196 SECStatus PK11_SetObjectNickname(PK11SlotInfo *slot, CK_OBJECT_HANDLE id,
197 const char *nickname) ;
200 /* private */
201 SECStatus pk11_TraverseAllSlots( SECStatus (*callback)(PK11SlotInfo *,void *),
202 void *cbArg, PRBool forceLogin, void *pwArg);
204 /* fetch multiple CRLs for a specific issuer */
205 SECStatus pk11_RetrieveCrls(CERTCrlHeadNode *nodes, SECItem* issuer,
206 void *wincx);
208 /* set global options for NSS PKCS#11 module loader */
209 SECStatus pk11_setGlobalOptions(PRBool noSingleThreadedModules,
210 PRBool allowAlreadyInitializedModules,
211 PRBool dontFinalizeModules);
213 /* return whether NSS is allowed to call C_Finalize */
214 PRBool pk11_getFinalizeModulesOption(void);
216 SEC_END_PROTOS
218 #endif