Import 1.9b4 NSS tag from cvs
[mozilla-nss.git] / security / nss / lib / pk11wrap / secmod.h
blobde6d8fb6dabf12570ee44ee972225a1a398d6073
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 _SECMOD_H_
37 #define _SEDMOD_H_
38 #include "seccomon.h"
39 #include "secmodt.h"
40 #include "prinrval.h"
42 /* These mechanisms flags are visible to all other libraries. */
43 /* They must be converted to internal SECMOD_*_FLAG */
44 /* if used inside the functions of the security library */
45 #define PUBLIC_MECH_RSA_FLAG 0x00000001ul
46 #define PUBLIC_MECH_DSA_FLAG 0x00000002ul
47 #define PUBLIC_MECH_RC2_FLAG 0x00000004ul
48 #define PUBLIC_MECH_RC4_FLAG 0x00000008ul
49 #define PUBLIC_MECH_DES_FLAG 0x00000010ul
50 #define PUBLIC_MECH_DH_FLAG 0x00000020ul
51 #define PUBLIC_MECH_FORTEZZA_FLAG 0x00000040ul
52 #define PUBLIC_MECH_RC5_FLAG 0x00000080ul
53 #define PUBLIC_MECH_SHA1_FLAG 0x00000100ul
54 #define PUBLIC_MECH_MD5_FLAG 0x00000200ul
55 #define PUBLIC_MECH_MD2_FLAG 0x00000400ul
56 #define PUBLIC_MECH_SSL_FLAG 0x00000800ul
57 #define PUBLIC_MECH_TLS_FLAG 0x00001000ul
58 #define PUBLIC_MECH_AES_FLAG 0x00002000ul
59 #define PUBLIC_MECH_SHA256_FLAG 0x00004000ul
60 #define PUBLIC_MECH_SHA512_FLAG 0x00008000ul
61 #define PUBLIC_MECH_CAMELLIA_FLAG 0x00010000ul
63 #define PUBLIC_MECH_RANDOM_FLAG 0x08000000ul
64 #define PUBLIC_MECH_FRIENDLY_FLAG 0x10000000ul
65 #define PUBLIC_OWN_PW_DEFAULTS 0X20000000ul
66 #define PUBLIC_DISABLE_FLAG 0x40000000ul
68 /* warning: reserved means reserved */
69 #define PUBLIC_MECH_RESERVED_FLAGS 0x87FF0000ul
71 /* These cipher flags are visible to all other libraries, */
72 /* But they must be converted before used in functions */
73 /* withing the security module */
74 #define PUBLIC_CIPHER_FORTEZZA_FLAG 0x00000001ul
76 /* warning: reserved means reserved */
77 #define PUBLIC_CIPHER_RESERVED_FLAGS 0xFFFFFFFEul
79 SEC_BEGIN_PROTOS
82 * the following functions are going to be depricated in NSS 4.0 in
83 * favor of the new stan functions.
86 /* Initialization */
87 extern SECMODModule *SECMOD_LoadModule(char *moduleSpec,SECMODModule *parent,
88 PRBool recurse);
90 extern SECMODModule *SECMOD_LoadUserModule(char *moduleSpec,SECMODModule *parent,
91 PRBool recurse);
93 SECStatus SECMOD_UnloadUserModule(SECMODModule *mod);
95 SECMODModule * SECMOD_CreateModule(const char *lib, const char *name,
96 const char *param, const char *nss);
99 /* Module Management */
100 char **SECMOD_GetModuleSpecList(SECMODModule *module);
101 SECStatus SECMOD_FreeModuleSpecList(SECMODModule *module,char **moduleSpecList);
104 /* protoypes */
105 /* Get a list of active PKCS #11 modules */
106 extern SECMODModuleList *SECMOD_GetDefaultModuleList(void);
107 /* Get a list of defined but not loaded PKCS #11 modules */
108 extern SECMODModuleList *SECMOD_GetDeadModuleList(void);
109 /* Get a list of Modules which define PKCS #11 modules to load */
110 extern SECMODModuleList *SECMOD_GetDBModuleList(void);
112 /* lock to protect all three module lists above */
113 extern SECMODListLock *SECMOD_GetDefaultModuleListLock(void);
115 extern SECStatus SECMOD_UpdateModule(SECMODModule *module);
117 /* lock management */
118 extern void SECMOD_GetReadLock(SECMODListLock *);
119 extern void SECMOD_ReleaseReadLock(SECMODListLock *);
121 /* Operate on modules by name */
122 extern SECMODModule *SECMOD_FindModule(const char *name);
123 extern SECStatus SECMOD_DeleteModule(const char *name, int *type);
124 extern SECStatus SECMOD_DeleteModuleEx(const char * name,
125 SECMODModule *mod,
126 int *type,
127 PRBool permdb);
128 extern SECStatus SECMOD_DeleteInternalModule(const char *name);
129 extern PRBool SECMOD_CanDeleteInternalModule(void);
130 extern SECStatus SECMOD_AddNewModule(const char* moduleName,
131 const char* dllPath,
132 unsigned long defaultMechanismFlags,
133 unsigned long cipherEnableFlags);
134 extern SECStatus SECMOD_AddNewModuleEx(const char* moduleName,
135 const char* dllPath,
136 unsigned long defaultMechanismFlags,
137 unsigned long cipherEnableFlags,
138 char* modparms,
139 char* nssparms);
141 /* database/memory management */
142 extern SECMODModule *SECMOD_GetInternalModule(void);
143 extern SECMODModule *SECMOD_ReferenceModule(SECMODModule *module);
144 extern void SECMOD_DestroyModule(SECMODModule *module);
145 extern PK11SlotInfo *SECMOD_LookupSlot(SECMODModuleID module,
146 unsigned long slotID);
147 extern PK11SlotInfo *SECMOD_FindSlot(SECMODModule *module,const char *name);
149 /* Funtion reports true if at least one of the modules */
150 /* of modType has been installed */
151 PRBool SECMOD_IsModulePresent( unsigned long int pubCipherEnableFlags );
153 /* Functions used to convert between internal & public representation
154 * of Mechanism Flags and Cipher Enable Flags */
155 extern unsigned long SECMOD_PubMechFlagstoInternal(unsigned long publicFlags);
156 extern unsigned long SECMOD_PubCipherFlagstoInternal(unsigned long publicFlags);
158 PRBool SECMOD_HasRemovableSlots(SECMODModule *mod);
159 PK11SlotInfo *SECMOD_WaitForAnyTokenEvent(SECMODModule *mod,
160 unsigned long flags, PRIntervalTime latency);
162 * Warning: the SECMOD_CancelWait function is highly destructive, potentially
163 * finalizing the module 'mod' (causing inprogress operations to fail,
164 * and session key material to disappear). It should only be called when
165 * shutting down the module.
167 SECStatus SECMOD_CancelWait(SECMODModule *mod);
169 * check to see if the module has added new slots. PKCS 11 v2.20 allows for
170 * modules to add new slots, but never remove them. Slots not be added between
171 * a call to C_GetSlotLlist(Flag, NULL, &count) and the corresponding
172 * C_GetSlotList(flag, &data, &count) so that the array doesn't accidently
173 * grow on the caller. It is permissible for the slots to increase between
174 * corresponding calls with NULL to get the size.
176 SECStatus SECMOD_UpdateSlotList(SECMODModule *mod);
177 SEC_END_PROTOS
179 #endif