/src/nss/lib/pk11wrap/secmodi.h
Line | Count | Source (jump to first uncovered line) |
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 | | /* |
5 | | * Internal header file included only by files in pkcs11 dir, or in |
6 | | * pkcs11 specific client and server files. |
7 | | */ |
8 | | #ifndef _SECMODI_H_ |
9 | | #define _SECMODI_H_ 1 |
10 | | |
11 | | #include <stddef.h> |
12 | | |
13 | | #include "pkcs11.h" |
14 | | #include "nssilock.h" |
15 | | #include "secoidt.h" |
16 | | #include "secdert.h" |
17 | | #include "certt.h" |
18 | | #include "secmodt.h" |
19 | | #include "keythi.h" |
20 | | |
21 | | SEC_BEGIN_PROTOS |
22 | | |
23 | | /* proto-types */ |
24 | | extern SECStatus SECMOD_DeletePermDB(SECMODModule *module); |
25 | | extern SECStatus SECMOD_AddPermDB(SECMODModule *module); |
26 | | extern SECStatus SECMOD_Shutdown(void); |
27 | | void nss_DumpModuleLog(void); |
28 | | |
29 | | extern int secmod_PrivateModuleCount; |
30 | | |
31 | | extern void SECMOD_Init(void); |
32 | | SECStatus secmod_ModuleInit(SECMODModule *mod, SECMODModule **oldModule, |
33 | | PRBool *alreadyLoaded); |
34 | | |
35 | | /* list managment */ |
36 | | extern SECStatus SECMOD_AddModuleToList(SECMODModule *newModule); |
37 | | extern SECStatus SECMOD_AddModuleToDBOnlyList(SECMODModule *newModule); |
38 | | extern SECStatus SECMOD_AddModuleToUnloadList(SECMODModule *newModule); |
39 | | extern void SECMOD_RemoveList(SECMODModuleList **, SECMODModuleList *); |
40 | | extern void SECMOD_AddList(SECMODModuleList *, SECMODModuleList *, SECMODListLock *); |
41 | | extern SECMODListLock *SECMOD_NewListLock(void); |
42 | | extern void SECMOD_DestroyListLock(SECMODListLock *); |
43 | | extern void SECMOD_GetWriteLock(SECMODListLock *); |
44 | | extern void SECMOD_ReleaseWriteLock(SECMODListLock *); |
45 | | |
46 | | /* Operate on modules by name */ |
47 | | extern SECMODModule *SECMOD_FindModuleByID(SECMODModuleID); |
48 | | extern SECMODModule *secmod_FindModuleByFuncPtr(void *funcPtr); |
49 | | |
50 | | /* database/memory management */ |
51 | | extern SECMODModuleList *SECMOD_NewModuleListElement(void); |
52 | | extern SECMODModuleList *SECMOD_DestroyModuleListElement(SECMODModuleList *); |
53 | | extern void SECMOD_DestroyModuleList(SECMODModuleList *); |
54 | | extern SECStatus SECMOD_AddModule(SECMODModule *newModule); |
55 | | |
56 | | extern unsigned long SECMOD_InternaltoPubCipherFlags(unsigned long internalFlags); |
57 | | |
58 | | /* Library functions */ |
59 | | SECStatus secmod_LoadPKCS11Module(SECMODModule *, SECMODModule **oldModule); |
60 | | SECStatus secmod_LoadPKCS11ModuleFromFunction(SECMODModule *, SECMODModule **oldModule, CK_C_GetFunctionList f); |
61 | | |
62 | | SECStatus SECMOD_UnloadModule(SECMODModule *); |
63 | | void SECMOD_SetInternalModule(SECMODModule *); |
64 | | PRBool secmod_IsInternalKeySlot(SECMODModule *); |
65 | | void secmod_SetInternalKeySlotFlag(SECMODModule *mod, PRBool val); |
66 | | |
67 | | /* tools for checking if we are loading the same database twice */ |
68 | | typedef struct SECMODConfigListStr SECMODConfigList; |
69 | | /* collect all the databases in a given spec */ |
70 | | SECMODConfigList *secmod_GetConfigList(PRBool isFIPS, char *spec, int *count); |
71 | | /* see is a spec matches a database on the list */ |
72 | | PRBool secmod_MatchConfigList(const char *spec, |
73 | | SECMODConfigList *conflist, int count); |
74 | | /* returns the slot id from a module and modulespec */ |
75 | | CK_SLOT_ID secmod_GetSlotIDFromModuleSpec(const char *moduleSpec, SECMODModule *module); |
76 | | /* free our list of databases */ |
77 | | void secmod_FreeConfigList(SECMODConfigList *conflist, int count); |
78 | | |
79 | | /* parsing parameters */ |
80 | | /* returned char * must be freed by caller with PORT_Free */ |
81 | | /* children and ids are null terminated arrays which must be freed with |
82 | | * secmod_FreeChildren */ |
83 | | char *secmod_ParseModuleSpecForTokens(PRBool convert, |
84 | | PRBool isFIPS, |
85 | | const char *moduleSpec, |
86 | | char ***children, |
87 | | CK_SLOT_ID **ids); |
88 | | void secmod_FreeChildren(char **children, CK_SLOT_ID *ids); |
89 | | char *secmod_MkAppendTokensList(PLArenaPool *arena, char *origModuleSpec, |
90 | | char *newModuleSpec, CK_SLOT_ID newID, |
91 | | char **children, CK_SLOT_ID *ids); |
92 | | |
93 | | void SECMOD_SlotDestroyModule(SECMODModule *module, PRBool fromSlot); |
94 | | CK_RV pk11_notify(CK_SESSION_HANDLE session, CK_NOTIFICATION event, |
95 | | CK_VOID_PTR pdata); |
96 | | void pk11_SignedToUnsigned(CK_ATTRIBUTE *attrib); |
97 | | CK_OBJECT_HANDLE pk11_FindObjectByTemplate(PK11SlotInfo *slot, |
98 | | CK_ATTRIBUTE *inTemplate, size_t tsize); |
99 | | CK_OBJECT_HANDLE *pk11_FindObjectsByTemplate(PK11SlotInfo *slot, |
100 | | CK_ATTRIBUTE *inTemplate, size_t tsize, int *objCount); |
101 | | |
102 | 0 | #define PK11_GETTAB(x) ((CK_FUNCTION_LIST_3_0_PTR)((x)->functionList)) |
103 | | #define PK11_SETATTRS(x, id, v, l) \ |
104 | 0 | (x)->type = (id); \ |
105 | 0 | (x)->pValue = (v); \ |
106 | 0 | (x)->ulValueLen = (l); |
107 | | SECStatus PK11_CreateNewObject(PK11SlotInfo *slot, CK_SESSION_HANDLE session, |
108 | | const CK_ATTRIBUTE *theTemplate, int count, |
109 | | PRBool token, CK_OBJECT_HANDLE *objectID); |
110 | | |
111 | | SECStatus pbe_PK11AlgidToParam(SECAlgorithmID *algid, SECItem *mech); |
112 | | SECStatus PBE_PK11ParamToAlgid(SECOidTag algTag, SECItem *param, |
113 | | PLArenaPool *arena, SECAlgorithmID *algId); |
114 | | |
115 | | PK11SymKey *pk11_TokenKeyGenWithFlagsAndKeyType(PK11SlotInfo *slot, |
116 | | CK_MECHANISM_TYPE type, SECItem *param, CK_KEY_TYPE keyType, |
117 | | int keySize, SECItem *keyId, CK_FLAGS opFlags, |
118 | | PK11AttrFlags attrFlags, void *wincx); |
119 | | |
120 | | CK_MECHANISM_TYPE pk11_GetPBECryptoMechanism(SECAlgorithmID *algid, |
121 | | SECItem **param, SECItem *pwd, PRBool faulty3DES); |
122 | | |
123 | | extern void pk11sdr_Init(void); |
124 | | extern void pk11sdr_Shutdown(void); |
125 | | |
126 | | /* |
127 | | * Private to pk11wrap. |
128 | | */ |
129 | | |
130 | | PRBool pk11_LoginStillRequired(PK11SlotInfo *slot, void *wincx); |
131 | | CK_SESSION_HANDLE pk11_GetNewSession(PK11SlotInfo *slot, PRBool *owner); |
132 | | void pk11_CloseSession(PK11SlotInfo *slot, CK_SESSION_HANDLE sess, PRBool own); |
133 | | PK11SymKey *pk11_ForceSlot(PK11SymKey *symKey, CK_MECHANISM_TYPE type, |
134 | | CK_ATTRIBUTE_TYPE operation); |
135 | | /* Convert key operation flags to PKCS #11 attributes. */ |
136 | | unsigned int pk11_OpFlagsToAttributes(CK_FLAGS flags, |
137 | | CK_ATTRIBUTE *attrs, CK_BBOOL *ckTrue); |
138 | | /* Check for bad (conflicting) attribute flags */ |
139 | | PRBool pk11_BadAttrFlags(PK11AttrFlags attrFlags); |
140 | | /* Convert key attribute flags to PKCS #11 attributes. */ |
141 | | unsigned int pk11_AttrFlagsToAttributes(PK11AttrFlags attrFlags, |
142 | | CK_ATTRIBUTE *attrs, CK_BBOOL *ckTrue, CK_BBOOL *ckFalse); |
143 | | PRBool pk11_FindAttrInTemplate(CK_ATTRIBUTE *attr, unsigned int numAttrs, |
144 | | CK_ATTRIBUTE_TYPE target); |
145 | | |
146 | | CK_MECHANISM_TYPE pk11_mapWrapKeyType(KeyType keyType); |
147 | | PK11SymKey *pk11_KeyExchange(PK11SlotInfo *slot, CK_MECHANISM_TYPE type, |
148 | | CK_ATTRIBUTE_TYPE operation, CK_FLAGS flags, PRBool isPerm, |
149 | | PK11SymKey *symKey); |
150 | | |
151 | | PRBool pk11_HandleTrustObject(PK11SlotInfo *slot, CERTCertificate *cert, |
152 | | CERTCertTrust *trust); |
153 | | CK_OBJECT_HANDLE pk11_FindPubKeyByAnyCert(CERTCertificate *cert, |
154 | | PK11SlotInfo **slot, void *wincx); |
155 | | SECStatus pk11_AuthenticateUnfriendly(PK11SlotInfo *slot, PRBool loadCerts, |
156 | | void *wincx); |
157 | | int PK11_NumberObjectsFor(PK11SlotInfo *slot, CK_ATTRIBUTE *findTemplate, |
158 | | int templateCount); |
159 | | SECItem *pk11_GetLowLevelKeyFromHandle(PK11SlotInfo *slot, |
160 | | CK_OBJECT_HANDLE handle); |
161 | | SECStatus PK11_TraverseSlot(PK11SlotInfo *slot, void *arg); |
162 | | CK_OBJECT_HANDLE pk11_FindPrivateKeyFromCertID(PK11SlotInfo *slot, |
163 | | SECItem *keyID); |
164 | | SECKEYPrivateKey *PK11_MakePrivKey(PK11SlotInfo *slot, KeyType keyType, |
165 | | PRBool isTemp, CK_OBJECT_HANDLE privID, void *wincx); |
166 | | CERTCertificate *PK11_MakeCertFromHandle(PK11SlotInfo *slot, |
167 | | CK_OBJECT_HANDLE certID, CK_ATTRIBUTE *privateLabel); |
168 | | |
169 | | SECItem *pk11_GenerateNewParamWithKeyLen(CK_MECHANISM_TYPE type, int keyLen); |
170 | | SECItem *pk11_ParamFromIVWithLen(CK_MECHANISM_TYPE type, |
171 | | SECItem *iv, int keyLen); |
172 | | SECItem *pk11_mkcertKeyID(CERTCertificate *cert); |
173 | | |
174 | | SEC_END_PROTOS |
175 | | |
176 | | #endif |