Import from 1.9a8 tarball
[mozilla-nss.git] / security / nss / lib / pk11wrap / secmodi.h
blobb425e908103c88ecc3fa66679f967fc6852463a2
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 ***** */
37 * Internal header file included only by files in pkcs11 dir, or in
38 * pkcs11 specific client and server files.
40 #ifndef _SECMODI_H_
41 #define _SECMODI_H_ 1
42 #include "pkcs11.h"
43 #include "nssilock.h"
44 #include "mcom_db.h"
45 #include "secoidt.h"
46 #include "secdert.h"
47 #include "certt.h"
48 #include "secmodt.h"
49 #include "keyt.h"
51 SEC_BEGIN_PROTOS
53 /* proto-types */
54 extern SECStatus SECMOD_DeletePermDB(SECMODModule *module);
55 extern SECStatus SECMOD_AddPermDB(SECMODModule *module);
56 extern SECStatus SECMOD_Shutdown(void);
57 void nss_DumpModuleLog(void);
59 extern int secmod_PrivateModuleCount;
61 extern void SECMOD_Init(void);
62 SECStatus secmod_ModuleInit(SECMODModule *mod, PRBool* alreadyLoaded);
64 /* list managment */
65 extern SECStatus SECMOD_AddModuleToList(SECMODModule *newModule);
66 extern SECStatus SECMOD_AddModuleToDBOnlyList(SECMODModule *newModule);
67 extern SECStatus SECMOD_AddModuleToUnloadList(SECMODModule *newModule);
68 extern void SECMOD_RemoveList(SECMODModuleList **,SECMODModuleList *);
69 extern void SECMOD_AddList(SECMODModuleList *,SECMODModuleList *,SECMODListLock *);
70 extern SECMODListLock *SECMOD_NewListLock(void);
71 extern void SECMOD_DestroyListLock(SECMODListLock *);
72 extern void SECMOD_GetWriteLock(SECMODListLock *);
73 extern void SECMOD_ReleaseWriteLock(SECMODListLock *);
75 /* Operate on modules by name */
76 extern SECMODModule *SECMOD_FindModuleByID(SECMODModuleID);
78 /* database/memory management */
79 extern SECMODModuleList *SECMOD_NewModuleListElement(void);
80 extern SECMODModuleList *SECMOD_DestroyModuleListElement(SECMODModuleList *);
81 extern void SECMOD_DestroyModuleList(SECMODModuleList *);
82 extern SECStatus SECMOD_AddModule(SECMODModule *newModule);
84 extern unsigned long SECMOD_InternaltoPubMechFlags(unsigned long internalFlags);
85 extern unsigned long SECMOD_InternaltoPubCipherFlags(unsigned long internalFlags);
87 /* Library functions */
88 SECStatus SECMOD_LoadPKCS11Module(SECMODModule *);
89 SECStatus SECMOD_UnloadModule(SECMODModule *);
90 void SECMOD_SetInternalModule(SECMODModule *);
92 void SECMOD_SlotDestroyModule(SECMODModule *module, PRBool fromSlot);
93 CK_RV pk11_notify(CK_SESSION_HANDLE session, CK_NOTIFICATION event,
94 CK_VOID_PTR pdata);
95 void pk11_SignedToUnsigned(CK_ATTRIBUTE *attrib);
96 CK_OBJECT_HANDLE pk11_FindObjectByTemplate(PK11SlotInfo *slot,
97 CK_ATTRIBUTE *inTemplate,int tsize);
98 CK_OBJECT_HANDLE *pk11_FindObjectsByTemplate(PK11SlotInfo *slot,
99 CK_ATTRIBUTE *inTemplate,int tsize, int *objCount);
100 SECStatus PK11_UpdateSlotAttribute(PK11SlotInfo *slot,
101 PK11DefaultArrayEntry *entry, PRBool add);
103 #define PK11_GETTAB(x) ((CK_FUNCTION_LIST_PTR)((x)->functionList))
104 #define PK11_SETATTRS(x,id,v,l) (x)->type = (id); \
105 (x)->pValue=(v); (x)->ulValueLen = (l);
106 SECStatus PK11_CreateNewObject(PK11SlotInfo *slot, CK_SESSION_HANDLE session,
107 CK_ATTRIBUTE *theTemplate, int count,
108 PRBool token, CK_OBJECT_HANDLE *objectID);
110 SECStatus pbe_PK11AlgidToParam(SECAlgorithmID *algid,SECItem *mech);
111 SECStatus PBE_PK11ParamToAlgid(SECOidTag algTag, SECItem *param,
112 PRArenaPool *arena, SECAlgorithmID *algId);
114 extern void pk11sdr_Init(void);
115 extern void pk11sdr_Shutdown(void);
118 * Private to pk11wrap.
121 PRBool pk11_LoginStillRequired(PK11SlotInfo *slot, void *wincx);
122 CK_SESSION_HANDLE pk11_GetNewSession(PK11SlotInfo *slot, PRBool *owner);
123 void pk11_CloseSession(PK11SlotInfo *slot, CK_SESSION_HANDLE sess, PRBool own);
124 PK11SymKey *pk11_ForceSlot(PK11SymKey *symKey, CK_MECHANISM_TYPE type,
125 CK_ATTRIBUTE_TYPE operation);
126 /* Convert key operation flags to PKCS #11 attributes. */
127 unsigned int pk11_OpFlagsToAttributes(CK_FLAGS flags,
128 CK_ATTRIBUTE *attrs, CK_BBOOL *ckTrue);
129 /* Check for bad (conflicting) attribute flags */
130 PRBool pk11_BadAttrFlags(PK11AttrFlags attrFlags);
131 /* Convert key attribute flags to PKCS #11 attributes. */
132 unsigned int pk11_AttrFlagsToAttributes(PK11AttrFlags attrFlags,
133 CK_ATTRIBUTE *attrs, CK_BBOOL *ckTrue, CK_BBOOL *ckFalse);
134 PRBool pk11_FindAttrInTemplate(CK_ATTRIBUTE *attr, unsigned int numAttrs,
135 CK_ATTRIBUTE_TYPE target);
137 CK_MECHANISM_TYPE pk11_mapWrapKeyType(KeyType keyType);
138 PK11SymKey *pk11_KeyExchange(PK11SlotInfo *slot, CK_MECHANISM_TYPE type,
139 CK_ATTRIBUTE_TYPE operation, CK_FLAGS flags, PRBool isPerm,
140 PK11SymKey *symKey);
142 PRBool pk11_HandleTrustObject(PK11SlotInfo *slot, CERTCertificate *cert,
143 CERTCertTrust *trust);
144 CK_OBJECT_HANDLE pk11_FindPubKeyByAnyCert(CERTCertificate *cert,
145 PK11SlotInfo **slot, void *wincx);
146 SECStatus pk11_AuthenticateUnfriendly(PK11SlotInfo *slot, PRBool loadCerts,
147 void *wincx);
148 int PK11_NumberObjectsFor(PK11SlotInfo *slot, CK_ATTRIBUTE *findTemplate,
149 int templateCount);
150 SECItem *pk11_GetLowLevelKeyFromHandle(PK11SlotInfo *slot,
151 CK_OBJECT_HANDLE handle);
152 SECStatus PK11_TraverseSlot(PK11SlotInfo *slot, void *arg);
153 CK_OBJECT_HANDLE pk11_FindPrivateKeyFromCertID(PK11SlotInfo *slot,
154 SECItem *keyID);
155 SECKEYPrivateKey *PK11_MakePrivKey(PK11SlotInfo *slot, KeyType keyType,
156 PRBool isTemp, CK_OBJECT_HANDLE privID, void *wincx);
157 SEC_END_PROTOS
159 #endif