/security/nss/lib/pk11wrap/secmod.h

http://github.com/zpao/v8monkey · C Header · 196 lines · 84 code · 25 blank · 87 comment · 0 complexity · dee575b806d11ca3eaf29d099cd9aa17 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 _SECMOD_H_
  37. #define _SEDMOD_H_
  38. #include "seccomon.h"
  39. #include "secmodt.h"
  40. #include "prinrval.h"
  41. /* These mechanisms flags are visible to all other libraries. */
  42. /* They must be converted to internal SECMOD_*_FLAG */
  43. /* if used inside the functions of the security library */
  44. #define PUBLIC_MECH_RSA_FLAG 0x00000001ul
  45. #define PUBLIC_MECH_DSA_FLAG 0x00000002ul
  46. #define PUBLIC_MECH_RC2_FLAG 0x00000004ul
  47. #define PUBLIC_MECH_RC4_FLAG 0x00000008ul
  48. #define PUBLIC_MECH_DES_FLAG 0x00000010ul
  49. #define PUBLIC_MECH_DH_FLAG 0x00000020ul
  50. #define PUBLIC_MECH_FORTEZZA_FLAG 0x00000040ul
  51. #define PUBLIC_MECH_RC5_FLAG 0x00000080ul
  52. #define PUBLIC_MECH_SHA1_FLAG 0x00000100ul
  53. #define PUBLIC_MECH_MD5_FLAG 0x00000200ul
  54. #define PUBLIC_MECH_MD2_FLAG 0x00000400ul
  55. #define PUBLIC_MECH_SSL_FLAG 0x00000800ul
  56. #define PUBLIC_MECH_TLS_FLAG 0x00001000ul
  57. #define PUBLIC_MECH_AES_FLAG 0x00002000ul
  58. #define PUBLIC_MECH_SHA256_FLAG 0x00004000ul
  59. #define PUBLIC_MECH_SHA512_FLAG 0x00008000ul
  60. #define PUBLIC_MECH_CAMELLIA_FLAG 0x00010000ul
  61. #define PUBLIC_MECH_SEED_FLAG 0x00020000ul
  62. #define PUBLIC_MECH_RANDOM_FLAG 0x08000000ul
  63. #define PUBLIC_MECH_FRIENDLY_FLAG 0x10000000ul
  64. #define PUBLIC_OWN_PW_DEFAULTS 0X20000000ul
  65. #define PUBLIC_DISABLE_FLAG 0x40000000ul
  66. /* warning: reserved means reserved */
  67. #define PUBLIC_MECH_RESERVED_FLAGS 0x87FF0000ul
  68. /* These cipher flags are visible to all other libraries, */
  69. /* But they must be converted before used in functions */
  70. /* withing the security module */
  71. #define PUBLIC_CIPHER_FORTEZZA_FLAG 0x00000001ul
  72. /* warning: reserved means reserved */
  73. #define PUBLIC_CIPHER_RESERVED_FLAGS 0xFFFFFFFEul
  74. SEC_BEGIN_PROTOS
  75. /*
  76. * the following functions are going to be deprecated in NSS 4.0 in
  77. * favor of the new stan functions.
  78. */
  79. /* Initialization */
  80. extern SECMODModule *SECMOD_LoadModule(char *moduleSpec,SECMODModule *parent,
  81. PRBool recurse);
  82. extern SECMODModule *SECMOD_LoadUserModule(char *moduleSpec,SECMODModule *parent,
  83. PRBool recurse);
  84. SECStatus SECMOD_UnloadUserModule(SECMODModule *mod);
  85. SECMODModule * SECMOD_CreateModule(const char *lib, const char *name,
  86. const char *param, const char *nss);
  87. /*
  88. * After a fork(), PKCS #11 says we need to call C_Initialize again in
  89. * the child before we can use the module. This function causes this
  90. * reinitialization.
  91. * NOTE: Any outstanding handles will become invalid, which means your
  92. * keys and contexts will fail, but new ones can be created.
  93. *
  94. * Setting 'force' to true means to do the reinitialization even if the
  95. * PKCS #11 module does not seem to need it. This allows software modules
  96. * which ignore fork to preserve their keys across the fork().
  97. */
  98. SECStatus SECMOD_RestartModules(PRBool force);
  99. /* Module Management */
  100. char **SECMOD_GetModuleSpecList(SECMODModule *module);
  101. SECStatus SECMOD_FreeModuleSpecList(SECMODModule *module,char **moduleSpecList);
  102. /* protoypes */
  103. /* Get a list of active PKCS #11 modules */
  104. extern SECMODModuleList *SECMOD_GetDefaultModuleList(void);
  105. /* Get a list of defined but not loaded PKCS #11 modules */
  106. extern SECMODModuleList *SECMOD_GetDeadModuleList(void);
  107. /* Get a list of Modules which define PKCS #11 modules to load */
  108. extern SECMODModuleList *SECMOD_GetDBModuleList(void);
  109. /* lock to protect all three module lists above */
  110. extern SECMODListLock *SECMOD_GetDefaultModuleListLock(void);
  111. extern SECStatus SECMOD_UpdateModule(SECMODModule *module);
  112. /* lock management */
  113. extern void SECMOD_GetReadLock(SECMODListLock *);
  114. extern void SECMOD_ReleaseReadLock(SECMODListLock *);
  115. /* Operate on modules by name */
  116. extern SECMODModule *SECMOD_FindModule(const char *name);
  117. extern SECStatus SECMOD_DeleteModule(const char *name, int *type);
  118. extern SECStatus SECMOD_DeleteModuleEx(const char * name,
  119. SECMODModule *mod,
  120. int *type,
  121. PRBool permdb);
  122. extern SECStatus SECMOD_DeleteInternalModule(const char *name);
  123. extern PRBool SECMOD_CanDeleteInternalModule(void);
  124. extern SECStatus SECMOD_AddNewModule(const char* moduleName,
  125. const char* dllPath,
  126. unsigned long defaultMechanismFlags,
  127. unsigned long cipherEnableFlags);
  128. extern SECStatus SECMOD_AddNewModuleEx(const char* moduleName,
  129. const char* dllPath,
  130. unsigned long defaultMechanismFlags,
  131. unsigned long cipherEnableFlags,
  132. char* modparms,
  133. char* nssparms);
  134. /* database/memory management */
  135. extern SECMODModule *SECMOD_GetInternalModule(void);
  136. extern SECMODModule *SECMOD_ReferenceModule(SECMODModule *module);
  137. extern void SECMOD_DestroyModule(SECMODModule *module);
  138. extern PK11SlotInfo *SECMOD_LookupSlot(SECMODModuleID module,
  139. unsigned long slotID);
  140. extern PK11SlotInfo *SECMOD_FindSlot(SECMODModule *module,const char *name);
  141. /* Funtion reports true if at least one of the modules */
  142. /* of modType has been installed */
  143. PRBool SECMOD_IsModulePresent( unsigned long int pubCipherEnableFlags );
  144. /* accessors */
  145. PRBool SECMOD_GetSkipFirstFlag(SECMODModule *mod);
  146. PRBool SECMOD_GetDefaultModDBFlag(SECMODModule *mod);
  147. /* Functions used to convert between internal & public representation
  148. * of Mechanism Flags and Cipher Enable Flags */
  149. extern unsigned long SECMOD_PubMechFlagstoInternal(unsigned long publicFlags);
  150. extern unsigned long SECMOD_PubCipherFlagstoInternal(unsigned long publicFlags);
  151. PRBool SECMOD_HasRemovableSlots(SECMODModule *mod);
  152. PK11SlotInfo *SECMOD_WaitForAnyTokenEvent(SECMODModule *mod,
  153. unsigned long flags, PRIntervalTime latency);
  154. /*
  155. * Warning: the SECMOD_CancelWait function is highly destructive, potentially
  156. * finalizing the module 'mod' (causing inprogress operations to fail,
  157. * and session key material to disappear). It should only be called when
  158. * shutting down the module.
  159. */
  160. SECStatus SECMOD_CancelWait(SECMODModule *mod);
  161. /*
  162. * check to see if the module has added new slots. PKCS 11 v2.20 allows for
  163. * modules to add new slots, but never remove them. Slots not be added between
  164. * a call to C_GetSlotLlist(Flag, NULL, &count) and the corresponding
  165. * C_GetSlotList(flag, &data, &count) so that the array doesn't accidently
  166. * grow on the caller. It is permissible for the slots to increase between
  167. * corresponding calls with NULL to get the size.
  168. */
  169. SECStatus SECMOD_UpdateSlotList(SECMODModule *mod);
  170. SEC_END_PROTOS
  171. #endif