/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. * These are the private NSS functions. They are not exported by nss.def, and
  51. * are not callable outside nss3.dll.
  52. */
  53. SEC_BEGIN_PROTOS
  54. /************************************************************
  55. * Generic Slot Lists Management
  56. ************************************************************/
  57. PK11SlotList * PK11_NewSlotList(void);
  58. PK11SlotList * PK11_GetPrivateKeyTokens(CK_MECHANISM_TYPE type,
  59. PRBool needRW,void *wincx);
  60. SECStatus PK11_AddSlotToList(PK11SlotList *list,PK11SlotInfo *slot);
  61. SECStatus PK11_DeleteSlotFromList(PK11SlotList *list,PK11SlotListElement *le);
  62. PK11SlotListElement *PK11_FindSlotElement(PK11SlotList *list,
  63. PK11SlotInfo *slot);
  64. PK11SlotInfo *PK11_FindSlotBySerial(char *serial);
  65. int PK11_GetMaxKeyLength(CK_MECHANISM_TYPE type);
  66. /************************************************************
  67. * Generic Slot Management
  68. ************************************************************/
  69. CK_OBJECT_HANDLE PK11_CopyKey(PK11SlotInfo *slot, CK_OBJECT_HANDLE srcObject);
  70. SECStatus PK11_ReadAttribute(PK11SlotInfo *slot, CK_OBJECT_HANDLE id,
  71. CK_ATTRIBUTE_TYPE type, PRArenaPool *arena, SECItem *result);
  72. CK_ULONG PK11_ReadULongAttribute(PK11SlotInfo *slot, CK_OBJECT_HANDLE id,
  73. CK_ATTRIBUTE_TYPE type);
  74. char * PK11_MakeString(PRArenaPool *arena,char *space,char *staticSring,
  75. int stringLen);
  76. int PK11_MapError(CK_RV error);
  77. CK_SESSION_HANDLE PK11_GetRWSession(PK11SlotInfo *slot);
  78. void PK11_RestoreROSession(PK11SlotInfo *slot,CK_SESSION_HANDLE rwsession);
  79. PRBool PK11_RWSessionHasLock(PK11SlotInfo *slot,
  80. CK_SESSION_HANDLE session_handle);
  81. PK11SlotInfo *PK11_NewSlotInfo(SECMODModule *mod);
  82. void PK11_EnterSlotMonitor(PK11SlotInfo *);
  83. void PK11_ExitSlotMonitor(PK11SlotInfo *);
  84. void PK11_CleanKeyList(PK11SlotInfo *slot);
  85. /************************************************************
  86. * Slot Password Management
  87. ************************************************************/
  88. SECStatus PK11_DoPassword(PK11SlotInfo *slot, PRBool loadCerts, void *wincx);
  89. SECStatus PK11_VerifyPW(PK11SlotInfo *slot,char *pw);
  90. void PK11_HandlePasswordCheck(PK11SlotInfo *slot,void *wincx);
  91. void PK11_SetVerifyPasswordFunc(PK11VerifyPasswordFunc func);
  92. void PK11_SetIsLoggedInFunc(PK11IsLoggedInFunc func);
  93. /************************************************************
  94. * Manage the built-In Slot Lists
  95. ************************************************************/
  96. SECStatus PK11_InitSlotLists(void);
  97. void PK11_DestroySlotLists(void);
  98. PK11SlotList *PK11_GetSlotList(CK_MECHANISM_TYPE type);
  99. void PK11_LoadSlotList(PK11SlotInfo *slot, PK11PreSlotInfo *psi, int count);
  100. void PK11_ClearSlotList(PK11SlotInfo *slot);
  101. /******************************************************************
  102. * Slot initialization
  103. ******************************************************************/
  104. SECStatus PK11_InitToken(PK11SlotInfo *slot, PRBool loadCerts);
  105. void PK11_InitSlot(SECMODModule *mod,CK_SLOT_ID slotID,PK11SlotInfo *slot);
  106. PRBool PK11_NeedPWInitForSlot(PK11SlotInfo *slot);
  107. SECStatus PK11_ReadSlotCerts(PK11SlotInfo *slot);
  108. /*********************************************************************
  109. * Mechanism Mapping functions
  110. *********************************************************************/
  111. void PK11_AddMechanismEntry(CK_MECHANISM_TYPE type, CK_KEY_TYPE key,
  112. CK_MECHANISM_TYPE keygen, CK_MECHANISM_TYPE pad,
  113. int ivLen, int blocksize);
  114. CK_MECHANISM_TYPE PK11_GetKeyMechanism(CK_KEY_TYPE type);
  115. CK_MECHANISM_TYPE PK11_GetKeyGenWithSize(CK_MECHANISM_TYPE type, int size);
  116. /**********************************************************************
  117. * Symetric, Public, and Private Keys
  118. **********************************************************************/
  119. /* Key Generation specialized for SDR (fixed DES3 key) */
  120. PK11SymKey *PK11_GenDES3TokenKey(PK11SlotInfo *slot, SECItem *keyid, void *cx);
  121. SECKEYPublicKey *PK11_ExtractPublicKey(PK11SlotInfo *slot, KeyType keyType,
  122. CK_OBJECT_HANDLE id);
  123. CK_OBJECT_HANDLE PK11_FindObjectForCert(CERTCertificate *cert,
  124. void *wincx, PK11SlotInfo **pSlot);
  125. PK11SymKey * pk11_CopyToSlot(PK11SlotInfo *slot,CK_MECHANISM_TYPE type,
  126. CK_ATTRIBUTE_TYPE operation, PK11SymKey *symKey);
  127. /**********************************************************************
  128. * Certs
  129. **********************************************************************/
  130. SECStatus PK11_TraversePrivateKeysInSlot( PK11SlotInfo *slot,
  131. SECStatus(* callback)(SECKEYPrivateKey*, void*), void *arg);
  132. SECKEYPrivateKey * PK11_FindPrivateKeyFromNickname(char *nickname, void *wincx);
  133. CK_OBJECT_HANDLE * PK11_FindObjectsFromNickname(char *nickname,
  134. PK11SlotInfo **slotptr, CK_OBJECT_CLASS objclass, int *returnCount,
  135. void *wincx);
  136. CK_OBJECT_HANDLE PK11_MatchItem(PK11SlotInfo *slot,CK_OBJECT_HANDLE peer,
  137. CK_OBJECT_CLASS o_class);
  138. CK_BBOOL PK11_HasAttributeSet( PK11SlotInfo *slot,
  139. CK_OBJECT_HANDLE id,
  140. CK_ATTRIBUTE_TYPE type );
  141. CK_RV PK11_GetAttributes(PRArenaPool *arena,PK11SlotInfo *slot,
  142. CK_OBJECT_HANDLE obj,CK_ATTRIBUTE *attr, int count);
  143. int PK11_NumberCertsForCertSubject(CERTCertificate *cert);
  144. SECStatus PK11_TraverseCertsForSubject(CERTCertificate *cert,
  145. SECStatus(*callback)(CERTCertificate *, void *), void *arg);
  146. CERTCertificate *PK11_FindCertFromDERCertItem(PK11SlotInfo *slot,
  147. SECItem *derCert, void *wincx);
  148. SECStatus PK11_GetKEAMatchedCerts(PK11SlotInfo *slot1,
  149. PK11SlotInfo *slot2, CERTCertificate **cert1, CERTCertificate **cert2);
  150. SECStatus PK11_TraverseCertsInSlot(PK11SlotInfo *slot,
  151. SECStatus(* callback)(CERTCertificate*, void *), void *arg);
  152. SECStatus PK11_LookupCrls(CERTCrlHeadNode *nodes, int type, void *wincx);
  153. /**********************************************************************
  154. * Crypto Contexts
  155. **********************************************************************/
  156. PK11Context * PK11_CreateContextByRawKey(PK11SlotInfo *slot,
  157. CK_MECHANISM_TYPE type, PK11Origin origin, CK_ATTRIBUTE_TYPE operation,
  158. SECItem *key, SECItem *param, void *wincx);
  159. PRBool PK11_HashOK(SECOidTag hashAlg);
  160. /**********************************************************************
  161. * Functions which are depricated....
  162. **********************************************************************/
  163. SECItem *
  164. PK11_FindCrlByName(PK11SlotInfo **slot, CK_OBJECT_HANDLE *handle,
  165. SECItem *derName, int type, char **url);
  166. CK_OBJECT_HANDLE
  167. PK11_PutCrl(PK11SlotInfo *slot, SECItem *crl,
  168. SECItem *name, char *url, int type);
  169. SECItem *
  170. PK11_FindSMimeProfile(PK11SlotInfo **slotp, char *emailAddr, SECItem *derSubj,
  171. SECItem **profileTime);
  172. SECStatus
  173. PK11_SaveSMimeProfile(PK11SlotInfo *slot, char *emailAddr, SECItem *derSubj,
  174. SECItem *emailProfile, SECItem *profileTime);
  175. PRBool PK11_IsPermObject(PK11SlotInfo *slot, CK_OBJECT_HANDLE handle);
  176. char * PK11_GetObjectNickname(PK11SlotInfo *slot, CK_OBJECT_HANDLE id) ;
  177. SECStatus PK11_SetObjectNickname(PK11SlotInfo *slot, CK_OBJECT_HANDLE id,
  178. const char *nickname) ;
  179. /* private */
  180. SECStatus pk11_TraverseAllSlots( SECStatus (*callback)(PK11SlotInfo *,void *),
  181. void *cbArg, PRBool forceLogin, void *pwArg);
  182. /* fetch multiple CRLs for a specific issuer */
  183. SECStatus pk11_RetrieveCrls(CERTCrlHeadNode *nodes, SECItem* issuer,
  184. void *wincx);
  185. /* set global options for NSS PKCS#11 module loader */
  186. SECStatus pk11_setGlobalOptions(PRBool noSingleThreadedModules,
  187. PRBool allowAlreadyInitializedModules,
  188. PRBool dontFinalizeModules);
  189. /* return whether NSS is allowed to call C_Finalize */
  190. PRBool pk11_getFinalizeModulesOption(void);
  191. SEC_END_PROTOS
  192. #endif