Back to index

lightning-sunbird  0.9+nobinonly
secmodi.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is the Netscape security libraries.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Netscape Communications Corporation.
00018  * Portions created by the Initial Developer are Copyright (C) 1994-2000
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either the GNU General Public License Version 2 or later (the "GPL"), or
00025  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00026  * in which case the provisions of the GPL or the LGPL are applicable instead
00027  * of those above. If you wish to allow use of your version of this file only
00028  * under the terms of either the GPL or the LGPL, and not to allow others to
00029  * use your version of this file under the terms of the MPL, indicate your
00030  * decision by deleting the provisions above and replace them with the notice
00031  * and other provisions required by the GPL or the LGPL. If you do not delete
00032  * the provisions above, a recipient may use your version of this file under
00033  * the terms of any one of the MPL, the GPL or the LGPL.
00034  *
00035  * ***** END LICENSE BLOCK ***** */
00036 /*
00037  * Internal header file included only by files in pkcs11 dir, or in
00038  * pkcs11 specific client and server files.
00039  */
00040 #ifndef _SECMODI_H_
00041 #define _SECMODI_H_ 1
00042 #include "pkcs11.h"
00043 #include "nssilock.h"
00044 #include "mcom_db.h"
00045 #include "secoidt.h"
00046 #include "secdert.h"
00047 #include "certt.h"
00048 #include "secmodt.h"
00049 #include "keyt.h"
00050 
00051 SEC_BEGIN_PROTOS
00052 
00053 /* proto-types */
00054 extern SECStatus SECMOD_DeletePermDB(SECMODModule *module);
00055 extern SECStatus SECMOD_AddPermDB(SECMODModule *module);
00056 extern SECStatus SECMOD_Shutdown(void);
00057 void nss_DumpModuleLog(void);
00058 
00059 extern int secmod_PrivateModuleCount;
00060 
00061 extern void SECMOD_Init(void);
00062 SECStatus secmod_ModuleInit(SECMODModule *mod, PRBool* alreadyLoaded);
00063 
00064 /* list managment */
00065 extern SECStatus SECMOD_AddModuleToList(SECMODModule *newModule);
00066 extern SECStatus SECMOD_AddModuleToDBOnlyList(SECMODModule *newModule);
00067 extern SECStatus SECMOD_AddModuleToUnloadList(SECMODModule *newModule);
00068 extern void SECMOD_RemoveList(SECMODModuleList **,SECMODModuleList *);
00069 extern void SECMOD_AddList(SECMODModuleList *,SECMODModuleList *,SECMODListLock *);
00070 extern SECMODListLock *SECMOD_NewListLock(void);
00071 extern void SECMOD_DestroyListLock(SECMODListLock *);
00072 extern void SECMOD_GetWriteLock(SECMODListLock *);
00073 extern void SECMOD_ReleaseWriteLock(SECMODListLock *);
00074 
00075 /* Operate on modules by name */
00076 extern SECMODModule *SECMOD_FindModuleByID(SECMODModuleID);
00077 
00078 /* database/memory management */
00079 extern SECMODModuleList *SECMOD_NewModuleListElement(void);
00080 extern SECMODModuleList *SECMOD_DestroyModuleListElement(SECMODModuleList *);
00081 extern void SECMOD_DestroyModuleList(SECMODModuleList *);
00082 extern SECStatus SECMOD_AddModule(SECMODModule *newModule);
00083 SECStatus SECMOD_DeleteModuleEx(const char * name, SECMODModule *mod, int *type, PRBool permdb);
00084 
00085 extern unsigned long SECMOD_InternaltoPubMechFlags(unsigned long internalFlags);
00086 extern unsigned long SECMOD_InternaltoPubCipherFlags(unsigned long internalFlags);
00087 
00088 /* Library functions */
00089 SECStatus SECMOD_LoadPKCS11Module(SECMODModule *);
00090 SECStatus SECMOD_UnloadModule(SECMODModule *);
00091 void SECMOD_SetInternalModule(SECMODModule *);
00092 
00093 void SECMOD_SlotDestroyModule(SECMODModule *module, PRBool fromSlot);
00094 CK_RV pk11_notify(CK_SESSION_HANDLE session, CK_NOTIFICATION event,
00095                                                          CK_VOID_PTR pdata);
00096 void pk11_SignedToUnsigned(CK_ATTRIBUTE *attrib);
00097 CK_OBJECT_HANDLE pk11_FindObjectByTemplate(PK11SlotInfo *slot,
00098                                    CK_ATTRIBUTE *inTemplate,int tsize);
00099 CK_OBJECT_HANDLE *pk11_FindObjectsByTemplate(PK11SlotInfo *slot,
00100                      CK_ATTRIBUTE *inTemplate,int tsize, int *objCount);
00101 SECStatus PK11_UpdateSlotAttribute(PK11SlotInfo *slot,
00102                              PK11DefaultArrayEntry *entry, PRBool add);
00103 
00104 #define PK11_GETTAB(x) ((CK_FUNCTION_LIST_PTR)((x)->functionList))
00105 #define PK11_SETATTRS(x,id,v,l) (x)->type = (id); \
00106               (x)->pValue=(v); (x)->ulValueLen = (l);
00107 SECStatus PK11_CreateNewObject(PK11SlotInfo *slot, CK_SESSION_HANDLE session,
00108                                CK_ATTRIBUTE *theTemplate, int count,
00109                                 PRBool token, CK_OBJECT_HANDLE *objectID);
00110 
00111 SECStatus pbe_PK11AlgidToParam(SECAlgorithmID *algid,SECItem *mech);
00112 SECStatus PBE_PK11ParamToAlgid(SECOidTag algTag, SECItem *param, 
00113                             PRArenaPool *arena, SECAlgorithmID *algId);
00114 
00115 extern void pk11sdr_Init(void);
00116 extern void pk11sdr_Shutdown(void);
00117 
00118 /*
00119  * Private to pk11wrap.
00120  */
00121 
00122 PRBool pk11_LoginStillRequired(PK11SlotInfo *slot, void *wincx);
00123 CK_SESSION_HANDLE pk11_GetNewSession(PK11SlotInfo *slot, PRBool *owner);
00124 void pk11_CloseSession(PK11SlotInfo *slot, CK_SESSION_HANDLE sess, PRBool own);
00125 PK11SymKey *pk11_ForceSlot(PK11SymKey *symKey, CK_MECHANISM_TYPE type,
00126                                           CK_ATTRIBUTE_TYPE operation);
00127 /* Convert key operation flags to PKCS #11 attributes. */
00128 unsigned int pk11_OpFlagsToAttributes(CK_FLAGS flags, 
00129                             CK_ATTRIBUTE *attrs, CK_BBOOL *ckTrue);
00130 /* Check for bad (conflicting) attribute flags */
00131 PRBool pk11_BadAttrFlags(PK11AttrFlags attrFlags);
00132 /* Convert key attribute flags to PKCS #11 attributes. */
00133 unsigned int pk11_AttrFlagsToAttributes(PK11AttrFlags attrFlags,
00134               CK_ATTRIBUTE *attrs, CK_BBOOL *ckTrue, CK_BBOOL *ckFalse);
00135 PRBool pk11_FindAttrInTemplate(CK_ATTRIBUTE *attr, unsigned int numAttrs,
00136                                    CK_ATTRIBUTE_TYPE target);
00137 
00138 CK_MECHANISM_TYPE pk11_mapWrapKeyType(KeyType keyType);
00139 PK11SymKey *pk11_KeyExchange(PK11SlotInfo *slot, CK_MECHANISM_TYPE type,
00140               CK_ATTRIBUTE_TYPE operation, CK_FLAGS flags, PRBool isPerm,
00141                                           PK11SymKey *symKey);
00142 
00143 PRBool pk11_HandleTrustObject(PK11SlotInfo *slot, CERTCertificate *cert,
00144                                                   CERTCertTrust *trust);
00145 CK_OBJECT_HANDLE pk11_FindPubKeyByAnyCert(CERTCertificate *cert,
00146                                     PK11SlotInfo **slot, void *wincx);
00147 SECStatus pk11_AuthenticateUnfriendly(PK11SlotInfo *slot, PRBool loadCerts,
00148                                                  void *wincx);
00149 int PK11_NumberObjectsFor(PK11SlotInfo *slot, CK_ATTRIBUTE *findTemplate,
00150                                           int templateCount);
00151 SECItem *pk11_GetLowLevelKeyFromHandle(PK11SlotInfo *slot, 
00152                                           CK_OBJECT_HANDLE handle);
00153 SECStatus PK11_TraverseSlot(PK11SlotInfo *slot, void *arg);
00154 CK_OBJECT_HANDLE pk11_FindPrivateKeyFromCertID(PK11SlotInfo *slot, 
00155                                                  SECItem *keyID);
00156 SECKEYPrivateKey *PK11_MakePrivKey(PK11SlotInfo *slot, KeyType keyType, 
00157                      PRBool isTemp, CK_OBJECT_HANDLE privID, void *wincx);
00158 SEC_END_PROTOS
00159 
00160 #endif
00161