andre@0: /* This Source Code Form is subject to the terms of the Mozilla Public andre@0: * License, v. 2.0. If a copy of the MPL was not distributed with this andre@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ andre@0: #ifndef _SECMOD_H_ andre@0: #define _SECMOD_H_ andre@0: #include "seccomon.h" andre@0: #include "secmodt.h" andre@0: #include "prinrval.h" andre@0: andre@0: /* These mechanisms flags are visible to all other libraries. */ andre@0: /* They must be converted to internal SECMOD_*_FLAG */ andre@0: /* if used inside the functions of the security library */ andre@0: #define PUBLIC_MECH_RSA_FLAG 0x00000001ul andre@0: #define PUBLIC_MECH_DSA_FLAG 0x00000002ul andre@0: #define PUBLIC_MECH_RC2_FLAG 0x00000004ul andre@0: #define PUBLIC_MECH_RC4_FLAG 0x00000008ul andre@0: #define PUBLIC_MECH_DES_FLAG 0x00000010ul andre@0: #define PUBLIC_MECH_DH_FLAG 0x00000020ul andre@0: #define PUBLIC_MECH_FORTEZZA_FLAG 0x00000040ul andre@0: #define PUBLIC_MECH_RC5_FLAG 0x00000080ul andre@0: #define PUBLIC_MECH_SHA1_FLAG 0x00000100ul andre@0: #define PUBLIC_MECH_MD5_FLAG 0x00000200ul andre@0: #define PUBLIC_MECH_MD2_FLAG 0x00000400ul andre@0: #define PUBLIC_MECH_SSL_FLAG 0x00000800ul andre@0: #define PUBLIC_MECH_TLS_FLAG 0x00001000ul andre@0: #define PUBLIC_MECH_AES_FLAG 0x00002000ul andre@0: #define PUBLIC_MECH_SHA256_FLAG 0x00004000ul andre@0: #define PUBLIC_MECH_SHA512_FLAG 0x00008000ul andre@0: #define PUBLIC_MECH_CAMELLIA_FLAG 0x00010000ul andre@0: #define PUBLIC_MECH_SEED_FLAG 0x00020000ul andre@0: #define PUBLIC_MECH_ECC_FLAG 0x00040000ul andre@0: andre@0: #define PUBLIC_MECH_RANDOM_FLAG 0x08000000ul andre@0: #define PUBLIC_MECH_FRIENDLY_FLAG 0x10000000ul andre@0: #define PUBLIC_OWN_PW_DEFAULTS 0X20000000ul andre@0: #define PUBLIC_DISABLE_FLAG 0x40000000ul andre@0: andre@0: /* warning: reserved means reserved */ andre@0: #define PUBLIC_MECH_RESERVED_FLAGS 0x87FF0000ul andre@0: andre@0: /* These cipher flags are visible to all other libraries, */ andre@0: /* But they must be converted before used in functions */ andre@0: /* withing the security module */ andre@0: #define PUBLIC_CIPHER_FORTEZZA_FLAG 0x00000001ul andre@0: andre@0: /* warning: reserved means reserved */ andre@0: #define PUBLIC_CIPHER_RESERVED_FLAGS 0xFFFFFFFEul andre@0: andre@0: SEC_BEGIN_PROTOS andre@0: andre@0: /* andre@0: * the following functions are going to be deprecated in NSS 4.0 in andre@0: * favor of the new stan functions. andre@0: */ andre@0: andre@0: /* Initialization */ andre@0: extern SECMODModule *SECMOD_LoadModule(char *moduleSpec,SECMODModule *parent, andre@0: PRBool recurse); andre@0: andre@0: extern SECMODModule *SECMOD_LoadUserModule(char *moduleSpec,SECMODModule *parent, andre@0: PRBool recurse); andre@0: andre@0: SECStatus SECMOD_UnloadUserModule(SECMODModule *mod); andre@0: andre@0: SECMODModule * SECMOD_CreateModule(const char *lib, const char *name, andre@0: const char *param, const char *nss); andre@0: /* andre@0: * After a fork(), PKCS #11 says we need to call C_Initialize again in andre@0: * the child before we can use the module. This function causes this andre@0: * reinitialization. andre@0: * NOTE: Any outstanding handles will become invalid, which means your andre@0: * keys and contexts will fail, but new ones can be created. andre@0: * andre@0: * Setting 'force' to true means to do the reinitialization even if the andre@0: * PKCS #11 module does not seem to need it. This allows software modules andre@0: * which ignore fork to preserve their keys across the fork(). andre@0: */ andre@0: SECStatus SECMOD_RestartModules(PRBool force); andre@0: andre@0: andre@0: /* Module Management */ andre@0: char **SECMOD_GetModuleSpecList(SECMODModule *module); andre@0: SECStatus SECMOD_FreeModuleSpecList(SECMODModule *module,char **moduleSpecList); andre@0: andre@0: andre@0: /* protoypes */ andre@0: /* Get a list of active PKCS #11 modules */ andre@0: extern SECMODModuleList *SECMOD_GetDefaultModuleList(void); andre@0: /* Get a list of defined but not loaded PKCS #11 modules */ andre@0: extern SECMODModuleList *SECMOD_GetDeadModuleList(void); andre@0: /* Get a list of Modules which define PKCS #11 modules to load */ andre@0: extern SECMODModuleList *SECMOD_GetDBModuleList(void); andre@0: andre@0: /* lock to protect all three module lists above */ andre@0: extern SECMODListLock *SECMOD_GetDefaultModuleListLock(void); andre@0: andre@0: extern SECStatus SECMOD_UpdateModule(SECMODModule *module); andre@0: andre@0: /* lock management */ andre@0: extern void SECMOD_GetReadLock(SECMODListLock *); andre@0: extern void SECMOD_ReleaseReadLock(SECMODListLock *); andre@0: andre@0: /* Operate on modules by name */ andre@0: extern SECMODModule *SECMOD_FindModule(const char *name); andre@0: extern SECStatus SECMOD_DeleteModule(const char *name, int *type); andre@0: extern SECStatus SECMOD_DeleteModuleEx(const char * name, andre@0: SECMODModule *mod, andre@0: int *type, andre@0: PRBool permdb); andre@0: extern SECStatus SECMOD_DeleteInternalModule(const char *name); andre@0: extern PRBool SECMOD_CanDeleteInternalModule(void); andre@0: extern SECStatus SECMOD_AddNewModule(const char* moduleName, andre@0: const char* dllPath, andre@0: unsigned long defaultMechanismFlags, andre@0: unsigned long cipherEnableFlags); andre@0: extern SECStatus SECMOD_AddNewModuleEx(const char* moduleName, andre@0: const char* dllPath, andre@0: unsigned long defaultMechanismFlags, andre@0: unsigned long cipherEnableFlags, andre@0: char* modparms, andre@0: char* nssparms); andre@0: andre@0: /* database/memory management */ andre@0: extern SECMODModule *SECMOD_GetInternalModule(void); andre@0: extern SECMODModule *SECMOD_ReferenceModule(SECMODModule *module); andre@0: extern void SECMOD_DestroyModule(SECMODModule *module); andre@0: extern PK11SlotInfo *SECMOD_LookupSlot(SECMODModuleID module, andre@0: unsigned long slotID); andre@0: extern PK11SlotInfo *SECMOD_FindSlot(SECMODModule *module,const char *name); andre@0: andre@0: /* Funtion reports true if at least one of the modules */ andre@0: /* of modType has been installed */ andre@0: PRBool SECMOD_IsModulePresent( unsigned long int pubCipherEnableFlags ); andre@0: andre@0: /* accessors */ andre@0: PRBool SECMOD_GetSkipFirstFlag(SECMODModule *mod); andre@0: PRBool SECMOD_GetDefaultModDBFlag(SECMODModule *mod); andre@0: andre@0: /* Functions used to convert between internal & public representation andre@0: * of Mechanism Flags and Cipher Enable Flags */ andre@0: extern unsigned long SECMOD_PubMechFlagstoInternal(unsigned long publicFlags); andre@0: extern unsigned long SECMOD_InternaltoPubMechFlags(unsigned long internalFlags); andre@0: extern unsigned long SECMOD_PubCipherFlagstoInternal(unsigned long publicFlags); andre@0: andre@0: PRBool SECMOD_HasRemovableSlots(SECMODModule *mod); andre@0: PK11SlotInfo *SECMOD_WaitForAnyTokenEvent(SECMODModule *mod, andre@0: unsigned long flags, PRIntervalTime latency); andre@0: /* andre@0: * Warning: the SECMOD_CancelWait function is highly destructive, potentially andre@0: * finalizing the module 'mod' (causing inprogress operations to fail, andre@0: * and session key material to disappear). It should only be called when andre@0: * shutting down the module. andre@0: */ andre@0: SECStatus SECMOD_CancelWait(SECMODModule *mod); andre@0: /* andre@0: * check to see if the module has added new slots. PKCS 11 v2.20 allows for andre@0: * modules to add new slots, but never remove them. Slots not be added between andre@0: * a call to C_GetSlotLlist(Flag, NULL, &count) and the corresponding andre@0: * C_GetSlotList(flag, &data, &count) so that the array doesn't accidently andre@0: * grow on the caller. It is permissible for the slots to increase between andre@0: * corresponding calls with NULL to get the size. andre@0: */ andre@0: SECStatus SECMOD_UpdateSlotList(SECMODModule *mod); andre@0: SEC_END_PROTOS andre@0: andre@0: #endif