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