Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | #ifndef _SECMOD_H_ |
michael@0 | 5 | #define _SECMOD_H_ |
michael@0 | 6 | #include "seccomon.h" |
michael@0 | 7 | #include "secmodt.h" |
michael@0 | 8 | #include "prinrval.h" |
michael@0 | 9 | |
michael@0 | 10 | /* These mechanisms flags are visible to all other libraries. */ |
michael@0 | 11 | /* They must be converted to internal SECMOD_*_FLAG */ |
michael@0 | 12 | /* if used inside the functions of the security library */ |
michael@0 | 13 | #define PUBLIC_MECH_RSA_FLAG 0x00000001ul |
michael@0 | 14 | #define PUBLIC_MECH_DSA_FLAG 0x00000002ul |
michael@0 | 15 | #define PUBLIC_MECH_RC2_FLAG 0x00000004ul |
michael@0 | 16 | #define PUBLIC_MECH_RC4_FLAG 0x00000008ul |
michael@0 | 17 | #define PUBLIC_MECH_DES_FLAG 0x00000010ul |
michael@0 | 18 | #define PUBLIC_MECH_DH_FLAG 0x00000020ul |
michael@0 | 19 | #define PUBLIC_MECH_FORTEZZA_FLAG 0x00000040ul |
michael@0 | 20 | #define PUBLIC_MECH_RC5_FLAG 0x00000080ul |
michael@0 | 21 | #define PUBLIC_MECH_SHA1_FLAG 0x00000100ul |
michael@0 | 22 | #define PUBLIC_MECH_MD5_FLAG 0x00000200ul |
michael@0 | 23 | #define PUBLIC_MECH_MD2_FLAG 0x00000400ul |
michael@0 | 24 | #define PUBLIC_MECH_SSL_FLAG 0x00000800ul |
michael@0 | 25 | #define PUBLIC_MECH_TLS_FLAG 0x00001000ul |
michael@0 | 26 | #define PUBLIC_MECH_AES_FLAG 0x00002000ul |
michael@0 | 27 | #define PUBLIC_MECH_SHA256_FLAG 0x00004000ul |
michael@0 | 28 | #define PUBLIC_MECH_SHA512_FLAG 0x00008000ul |
michael@0 | 29 | #define PUBLIC_MECH_CAMELLIA_FLAG 0x00010000ul |
michael@0 | 30 | #define PUBLIC_MECH_SEED_FLAG 0x00020000ul |
michael@0 | 31 | #define PUBLIC_MECH_ECC_FLAG 0x00040000ul |
michael@0 | 32 | |
michael@0 | 33 | #define PUBLIC_MECH_RANDOM_FLAG 0x08000000ul |
michael@0 | 34 | #define PUBLIC_MECH_FRIENDLY_FLAG 0x10000000ul |
michael@0 | 35 | #define PUBLIC_OWN_PW_DEFAULTS 0X20000000ul |
michael@0 | 36 | #define PUBLIC_DISABLE_FLAG 0x40000000ul |
michael@0 | 37 | |
michael@0 | 38 | /* warning: reserved means reserved */ |
michael@0 | 39 | #define PUBLIC_MECH_RESERVED_FLAGS 0x87FF0000ul |
michael@0 | 40 | |
michael@0 | 41 | /* These cipher flags are visible to all other libraries, */ |
michael@0 | 42 | /* But they must be converted before used in functions */ |
michael@0 | 43 | /* withing the security module */ |
michael@0 | 44 | #define PUBLIC_CIPHER_FORTEZZA_FLAG 0x00000001ul |
michael@0 | 45 | |
michael@0 | 46 | /* warning: reserved means reserved */ |
michael@0 | 47 | #define PUBLIC_CIPHER_RESERVED_FLAGS 0xFFFFFFFEul |
michael@0 | 48 | |
michael@0 | 49 | SEC_BEGIN_PROTOS |
michael@0 | 50 | |
michael@0 | 51 | /* |
michael@0 | 52 | * the following functions are going to be deprecated in NSS 4.0 in |
michael@0 | 53 | * favor of the new stan functions. |
michael@0 | 54 | */ |
michael@0 | 55 | |
michael@0 | 56 | /* Initialization */ |
michael@0 | 57 | extern SECMODModule *SECMOD_LoadModule(char *moduleSpec,SECMODModule *parent, |
michael@0 | 58 | PRBool recurse); |
michael@0 | 59 | |
michael@0 | 60 | extern SECMODModule *SECMOD_LoadUserModule(char *moduleSpec,SECMODModule *parent, |
michael@0 | 61 | PRBool recurse); |
michael@0 | 62 | |
michael@0 | 63 | SECStatus SECMOD_UnloadUserModule(SECMODModule *mod); |
michael@0 | 64 | |
michael@0 | 65 | SECMODModule * SECMOD_CreateModule(const char *lib, const char *name, |
michael@0 | 66 | const char *param, const char *nss); |
michael@0 | 67 | /* |
michael@0 | 68 | * After a fork(), PKCS #11 says we need to call C_Initialize again in |
michael@0 | 69 | * the child before we can use the module. This function causes this |
michael@0 | 70 | * reinitialization. |
michael@0 | 71 | * NOTE: Any outstanding handles will become invalid, which means your |
michael@0 | 72 | * keys and contexts will fail, but new ones can be created. |
michael@0 | 73 | * |
michael@0 | 74 | * Setting 'force' to true means to do the reinitialization even if the |
michael@0 | 75 | * PKCS #11 module does not seem to need it. This allows software modules |
michael@0 | 76 | * which ignore fork to preserve their keys across the fork(). |
michael@0 | 77 | */ |
michael@0 | 78 | SECStatus SECMOD_RestartModules(PRBool force); |
michael@0 | 79 | |
michael@0 | 80 | |
michael@0 | 81 | /* Module Management */ |
michael@0 | 82 | char **SECMOD_GetModuleSpecList(SECMODModule *module); |
michael@0 | 83 | SECStatus SECMOD_FreeModuleSpecList(SECMODModule *module,char **moduleSpecList); |
michael@0 | 84 | |
michael@0 | 85 | |
michael@0 | 86 | /* protoypes */ |
michael@0 | 87 | /* Get a list of active PKCS #11 modules */ |
michael@0 | 88 | extern SECMODModuleList *SECMOD_GetDefaultModuleList(void); |
michael@0 | 89 | /* Get a list of defined but not loaded PKCS #11 modules */ |
michael@0 | 90 | extern SECMODModuleList *SECMOD_GetDeadModuleList(void); |
michael@0 | 91 | /* Get a list of Modules which define PKCS #11 modules to load */ |
michael@0 | 92 | extern SECMODModuleList *SECMOD_GetDBModuleList(void); |
michael@0 | 93 | |
michael@0 | 94 | /* lock to protect all three module lists above */ |
michael@0 | 95 | extern SECMODListLock *SECMOD_GetDefaultModuleListLock(void); |
michael@0 | 96 | |
michael@0 | 97 | extern SECStatus SECMOD_UpdateModule(SECMODModule *module); |
michael@0 | 98 | |
michael@0 | 99 | /* lock management */ |
michael@0 | 100 | extern void SECMOD_GetReadLock(SECMODListLock *); |
michael@0 | 101 | extern void SECMOD_ReleaseReadLock(SECMODListLock *); |
michael@0 | 102 | |
michael@0 | 103 | /* Operate on modules by name */ |
michael@0 | 104 | extern SECMODModule *SECMOD_FindModule(const char *name); |
michael@0 | 105 | extern SECStatus SECMOD_DeleteModule(const char *name, int *type); |
michael@0 | 106 | extern SECStatus SECMOD_DeleteModuleEx(const char * name, |
michael@0 | 107 | SECMODModule *mod, |
michael@0 | 108 | int *type, |
michael@0 | 109 | PRBool permdb); |
michael@0 | 110 | extern SECStatus SECMOD_DeleteInternalModule(const char *name); |
michael@0 | 111 | extern PRBool SECMOD_CanDeleteInternalModule(void); |
michael@0 | 112 | extern SECStatus SECMOD_AddNewModule(const char* moduleName, |
michael@0 | 113 | const char* dllPath, |
michael@0 | 114 | unsigned long defaultMechanismFlags, |
michael@0 | 115 | unsigned long cipherEnableFlags); |
michael@0 | 116 | extern SECStatus SECMOD_AddNewModuleEx(const char* moduleName, |
michael@0 | 117 | const char* dllPath, |
michael@0 | 118 | unsigned long defaultMechanismFlags, |
michael@0 | 119 | unsigned long cipherEnableFlags, |
michael@0 | 120 | char* modparms, |
michael@0 | 121 | char* nssparms); |
michael@0 | 122 | |
michael@0 | 123 | /* database/memory management */ |
michael@0 | 124 | extern SECMODModule *SECMOD_GetInternalModule(void); |
michael@0 | 125 | extern SECMODModule *SECMOD_ReferenceModule(SECMODModule *module); |
michael@0 | 126 | extern void SECMOD_DestroyModule(SECMODModule *module); |
michael@0 | 127 | extern PK11SlotInfo *SECMOD_LookupSlot(SECMODModuleID module, |
michael@0 | 128 | unsigned long slotID); |
michael@0 | 129 | extern PK11SlotInfo *SECMOD_FindSlot(SECMODModule *module,const char *name); |
michael@0 | 130 | |
michael@0 | 131 | /* Funtion reports true if at least one of the modules */ |
michael@0 | 132 | /* of modType has been installed */ |
michael@0 | 133 | PRBool SECMOD_IsModulePresent( unsigned long int pubCipherEnableFlags ); |
michael@0 | 134 | |
michael@0 | 135 | /* accessors */ |
michael@0 | 136 | PRBool SECMOD_GetSkipFirstFlag(SECMODModule *mod); |
michael@0 | 137 | PRBool SECMOD_GetDefaultModDBFlag(SECMODModule *mod); |
michael@0 | 138 | |
michael@0 | 139 | /* Functions used to convert between internal & public representation |
michael@0 | 140 | * of Mechanism Flags and Cipher Enable Flags */ |
michael@0 | 141 | extern unsigned long SECMOD_PubMechFlagstoInternal(unsigned long publicFlags); |
michael@0 | 142 | extern unsigned long SECMOD_InternaltoPubMechFlags(unsigned long internalFlags); |
michael@0 | 143 | extern unsigned long SECMOD_PubCipherFlagstoInternal(unsigned long publicFlags); |
michael@0 | 144 | |
michael@0 | 145 | PRBool SECMOD_HasRemovableSlots(SECMODModule *mod); |
michael@0 | 146 | PK11SlotInfo *SECMOD_WaitForAnyTokenEvent(SECMODModule *mod, |
michael@0 | 147 | unsigned long flags, PRIntervalTime latency); |
michael@0 | 148 | /* |
michael@0 | 149 | * Warning: the SECMOD_CancelWait function is highly destructive, potentially |
michael@0 | 150 | * finalizing the module 'mod' (causing inprogress operations to fail, |
michael@0 | 151 | * and session key material to disappear). It should only be called when |
michael@0 | 152 | * shutting down the module. |
michael@0 | 153 | */ |
michael@0 | 154 | SECStatus SECMOD_CancelWait(SECMODModule *mod); |
michael@0 | 155 | /* |
michael@0 | 156 | * check to see if the module has added new slots. PKCS 11 v2.20 allows for |
michael@0 | 157 | * modules to add new slots, but never remove them. Slots not be added between |
michael@0 | 158 | * a call to C_GetSlotLlist(Flag, NULL, &count) and the corresponding |
michael@0 | 159 | * C_GetSlotList(flag, &data, &count) so that the array doesn't accidently |
michael@0 | 160 | * grow on the caller. It is permissible for the slots to increase between |
michael@0 | 161 | * corresponding calls with NULL to get the size. |
michael@0 | 162 | */ |
michael@0 | 163 | SECStatus SECMOD_UpdateSlotList(SECMODModule *mod); |
michael@0 | 164 | SEC_END_PROTOS |
michael@0 | 165 | |
michael@0 | 166 | #endif |