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