PageRenderTime 583ms CodeModel.GetById 572ms RepoModel.GetById 0ms app.codeStats 0ms

/gecko_api/include/nss.h

http://firefox-mac-pdf.googlecode.com/
C Header | 265 lines | 66 code | 23 blank | 176 comment | 0 complexity | ebe123ffa9bf247745b26ce452540199 MD5 | raw file
  1. /*
  2. * NSS utility functions
  3. *
  4. * ***** BEGIN LICENSE BLOCK *****
  5. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  6. *
  7. * The contents of this file are subject to the Mozilla Public License Version
  8. * 1.1 (the "License"); you may not use this file except in compliance with
  9. * the License. You may obtain a copy of the License at
  10. * http://www.mozilla.org/MPL/
  11. *
  12. * Software distributed under the License is distributed on an "AS IS" basis,
  13. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  14. * for the specific language governing rights and limitations under the
  15. * License.
  16. *
  17. * The Original Code is the Netscape security libraries.
  18. *
  19. * The Initial Developer of the Original Code is
  20. * Netscape Communications Corporation.
  21. * Portions created by the Initial Developer are Copyright (C) 1994-2000
  22. * the Initial Developer. All Rights Reserved.
  23. *
  24. * Contributor(s):
  25. *
  26. * Alternatively, the contents of this file may be used under the terms of
  27. * either the GNU General Public License Version 2 or later (the "GPL"), or
  28. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  29. * in which case the provisions of the GPL or the LGPL are applicable instead
  30. * of those above. If you wish to allow use of your version of this file only
  31. * under the terms of either the GPL or the LGPL, and not to allow others to
  32. * use your version of this file under the terms of the MPL, indicate your
  33. * decision by deleting the provisions above and replace them with the notice
  34. * and other provisions required by the GPL or the LGPL. If you do not delete
  35. * the provisions above, a recipient may use your version of this file under
  36. * the terms of any one of the MPL, the GPL or the LGPL.
  37. *
  38. * ***** END LICENSE BLOCK ***** */
  39. /* $Id: nss.h,v 1.56.2.1 2008/04/17 20:18:48 christophe.ravel.bugs%sun.com Exp $ */
  40. #ifndef __nss_h_
  41. #define __nss_h_
  42. #include "seccomon.h"
  43. SEC_BEGIN_PROTOS
  44. /* The private macro _NSS_ECC_STRING is for NSS internal use only. */
  45. #ifdef NSS_ENABLE_ECC
  46. #ifdef NSS_ECC_MORE_THAN_SUITE_B
  47. #define _NSS_ECC_STRING " Extended ECC"
  48. #else
  49. #define _NSS_ECC_STRING " Basic ECC"
  50. #endif
  51. #else
  52. #define _NSS_ECC_STRING ""
  53. #endif
  54. /* The private macro _NSS_CUSTOMIZED is for NSS internal use only. */
  55. #if defined(NSS_ALLOW_UNSUPPORTED_CRITICAL)
  56. #define _NSS_CUSTOMIZED " (Customized build)"
  57. #else
  58. #define _NSS_CUSTOMIZED
  59. #endif
  60. /*
  61. * NSS's major version, minor version, patch level, and whether
  62. * this is a beta release.
  63. *
  64. * The format of the version string should be
  65. * "<major version>.<minor version>[.<patch level>][ <ECC>][ <Beta>]"
  66. */
  67. #define NSS_VERSION "3.12.0.2" _NSS_ECC_STRING _NSS_CUSTOMIZED
  68. #define NSS_VMAJOR 3
  69. #define NSS_VMINOR 12
  70. #define NSS_VPATCH 0
  71. #define NSS_BETA PR_FALSE
  72. /*
  73. * Return a boolean that indicates whether the underlying library
  74. * will perform as the caller expects.
  75. *
  76. * The only argument is a string, which should be the verson
  77. * identifier of the NSS library. That string will be compared
  78. * against a string that represents the actual build version of
  79. * the NSS library. It also invokes the version checking functions
  80. * of the dependent libraries such as NSPR.
  81. */
  82. extern PRBool NSS_VersionCheck(const char *importedVersion);
  83. /*
  84. * Open the Cert, Key, and Security Module databases, read only.
  85. * Initialize the Random Number Generator.
  86. * Does not initialize the cipher policies or enables.
  87. * Default policy settings disallow all ciphers.
  88. */
  89. extern SECStatus NSS_Init(const char *configdir);
  90. /*
  91. * Returns whether NSS has already been initialized or not.
  92. */
  93. extern PRBool NSS_IsInitialized(void);
  94. /*
  95. * Open the Cert, Key, and Security Module databases, read/write.
  96. * Initialize the Random Number Generator.
  97. * Does not initialize the cipher policies or enables.
  98. * Default policy settings disallow all ciphers.
  99. */
  100. extern SECStatus NSS_InitReadWrite(const char *configdir);
  101. /*
  102. * Open the Cert, Key, and Security Module databases, read/write.
  103. * Initialize the Random Number Generator.
  104. * Does not initialize the cipher policies or enables.
  105. * Default policy settings disallow all ciphers.
  106. *
  107. * This allows using application defined prefixes for the cert and key db's
  108. * and an alternate name for the secmod database. NOTE: In future releases,
  109. * the database prefixes my not necessarily map to database names.
  110. *
  111. * configdir - base directory where all the cert, key, and module datbases live.
  112. * certPrefix - prefix added to the beginning of the cert database example: "
  113. * "https-server1-"
  114. * keyPrefix - prefix added to the beginning of the key database example: "
  115. * "https-server1-"
  116. * secmodName - name of the security module database (usually "secmod.db").
  117. * flags - change the open options of NSS_Initialize as follows:
  118. * NSS_INIT_READONLY - Open the databases read only.
  119. * NSS_INIT_NOCERTDB - Don't open the cert DB and key DB's, just
  120. * initialize the volatile certdb.
  121. * NSS_INIT_NOMODDB - Don't open the security module DB, just
  122. * initialize the PKCS #11 module.
  123. * NSS_INIT_FORCEOPEN - Continue to force initializations even if the
  124. * databases cannot be opened.
  125. * NSS_INIT_NOROOTINIT - Don't try to look for the root certs module
  126. * automatically.
  127. * NSS_INIT_OPTIMIZESPACE - Use smaller tables and caches.
  128. * NSS_INIT_PK11THREADSAFE - only load PKCS#11 modules that are
  129. * thread-safe, ie. that support locking - either OS
  130. * locking or NSS-provided locks . If a PKCS#11
  131. * module isn't thread-safe, don't serialize its
  132. * calls; just don't load it instead. This is necessary
  133. * if another piece of code is using the same PKCS#11
  134. * modules that NSS is accessing without going through
  135. * NSS, for example the Java SunPKCS11 provider.
  136. * NSS_INIT_PK11RELOAD - ignore the CKR_CRYPTOKI_ALREADY_INITIALIZED
  137. * error when loading PKCS#11 modules. This is necessary
  138. * if another piece of code is using the same PKCS#11
  139. * modules that NSS is accessing without going through
  140. * NSS, for example Java SunPKCS11 provider.
  141. * NSS_INIT_NOPK11FINALIZE - never call C_Finalize on any
  142. * PKCS#11 module. This may be necessary in order to
  143. * ensure continuous operation and proper shutdown
  144. * sequence if another piece of code is using the same
  145. * PKCS#11 modules that NSS is accessing without going
  146. * through NSS, for example Java SunPKCS11 provider.
  147. * The following limitation applies when this is set :
  148. * SECMOD_WaitForAnyTokenEvent will not use
  149. * C_WaitForSlotEvent, in order to prevent the need for
  150. * C_Finalize. This call will be emulated instead.
  151. * NSS_INIT_RESERVED - Currently has no effect, but may be used in the
  152. * future to trigger better cooperation between PKCS#11
  153. * modules used by both NSS and the Java SunPKCS11
  154. * provider. This should occur after a new flag is defined
  155. * for C_Initialize by the PKCS#11 working group.
  156. * NSS_INIT_COOPERATE - Sets 4 recommended options for applications that
  157. * use both NSS and the Java SunPKCS11 provider.
  158. *
  159. * Also NOTE: This is not the recommended method for initializing NSS.
  160. * The prefered method is NSS_init().
  161. */
  162. #define NSS_INIT_READONLY 0x1
  163. #define NSS_INIT_NOCERTDB 0x2
  164. #define NSS_INIT_NOMODDB 0x4
  165. #define NSS_INIT_FORCEOPEN 0x8
  166. #define NSS_INIT_NOROOTINIT 0x10
  167. #define NSS_INIT_OPTIMIZESPACE 0x20
  168. #define NSS_INIT_PK11THREADSAFE 0x40
  169. #define NSS_INIT_PK11RELOAD 0x80
  170. #define NSS_INIT_NOPK11FINALIZE 0x100
  171. #define NSS_INIT_RESERVED 0x200
  172. #define NSS_INIT_COOPERATE NSS_INIT_PK11THREADSAFE | \
  173. NSS_INIT_PK11RELOAD | \
  174. NSS_INIT_NOPK11FINALIZE | \
  175. NSS_INIT_RESERVED
  176. #ifdef macintosh
  177. #define SECMOD_DB "Security Modules"
  178. #else
  179. #define SECMOD_DB "secmod.db"
  180. #endif
  181. extern SECStatus NSS_Initialize(const char *configdir,
  182. const char *certPrefix, const char *keyPrefix,
  183. const char *secmodName, PRUint32 flags);
  184. /*
  185. * same as NSS_Init, but checks to see if we need to merge an
  186. * old database in.
  187. * updatedir is the directory where the old database lives.
  188. * updCertPrefix is the certPrefix for the old database.
  189. * updKeyPrefix is the keyPrefix for the old database.
  190. * updateID is a unique identifier chosen by the application for
  191. * the specific database.
  192. * updatName is the name the user will be prompted for when
  193. * asking to authenticate to the old database */
  194. extern SECStatus NSS_InitWithMerge(const char *configdir,
  195. const char *certPrefix, const char *keyPrefix, const char *secmodName,
  196. const char *updatedir, const char *updCertPrefix,
  197. const char *updKeyPrefix, const char *updateID,
  198. const char *updateName, PRUint32 flags);
  199. /*
  200. * initialize NSS without a creating cert db's, key db's, or secmod db's.
  201. */
  202. SECStatus NSS_NoDB_Init(const char *configdir);
  203. /*
  204. * Allow applications and libraries to register with NSS so that they are called
  205. * when NSS shuts down.
  206. *
  207. * void *appData application specific data passed in by the application at
  208. * NSS_RegisterShutdown() time.
  209. * void *nssData is NULL in this release, but is reserved for future versions of
  210. * NSS to pass some future status information * back to the shutdown function.
  211. *
  212. * If the shutdown function returns SECFailure,
  213. * Shutdown will still complete, but NSS_Shutdown() will return SECFailure.
  214. */
  215. typedef SECStatus (*NSS_ShutdownFunc)(void *appData, void *nssData);
  216. /*
  217. * Register a shutdown function.
  218. */
  219. SECStatus NSS_RegisterShutdown(NSS_ShutdownFunc sFunc, void *appData);
  220. /*
  221. * Remove an existing shutdown function (you may do this if your library is
  222. * complete and going away, but NSS is still running).
  223. */
  224. SECStatus NSS_UnregisterShutdown(NSS_ShutdownFunc sFunc, void *appData);
  225. /*
  226. * Close the Cert, Key databases.
  227. */
  228. extern SECStatus NSS_Shutdown(void);
  229. /*
  230. * set the PKCS #11 strings for the internal token.
  231. */
  232. void PK11_ConfigurePKCS11(const char *man, const char *libdes,
  233. const char *tokdes, const char *ptokdes, const char *slotdes,
  234. const char *pslotdes, const char *fslotdes, const char *fpslotdes,
  235. int minPwd, int pwRequired);
  236. /*
  237. * Dump the contents of the certificate cache and the temporary cert store.
  238. * Use to detect leaked references of certs at shutdown time.
  239. */
  240. void nss_DumpCertificateCacheInfo(void);
  241. SEC_END_PROTOS
  242. #endif /* __nss_h_ */