PageRenderTime 47ms CodeModel.GetById 16ms app.highlight 23ms RepoModel.GetById 2ms app.codeStats 0ms

/security/nss/lib/pk11wrap/secmod.h

http://github.com/zpao/v8monkey
C Header | 196 lines | 84 code | 25 blank | 87 comment | 0 complexity | dee575b806d11ca3eaf29d099cd9aa17 MD5 | raw file
  1/* ***** BEGIN LICENSE BLOCK *****
  2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3 *
  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/
  8 *
  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.
 13 *
 14 * The Original Code is the Netscape security libraries.
 15 *
 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.
 20 *
 21 * Contributor(s):
 22 *
 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.
 34 *
 35 * ***** END LICENSE BLOCK ***** */
 36#ifndef _SECMOD_H_
 37#define _SEDMOD_H_
 38#include "seccomon.h"
 39#include "secmodt.h"
 40#include "prinrval.h"
 41
 42/* These mechanisms flags are visible to all other libraries. */
 43/* They must be converted to internal SECMOD_*_FLAG */
 44/* if used inside the functions of the security library */
 45#define PUBLIC_MECH_RSA_FLAG         0x00000001ul
 46#define PUBLIC_MECH_DSA_FLAG         0x00000002ul
 47#define PUBLIC_MECH_RC2_FLAG         0x00000004ul
 48#define PUBLIC_MECH_RC4_FLAG         0x00000008ul
 49#define PUBLIC_MECH_DES_FLAG         0x00000010ul
 50#define PUBLIC_MECH_DH_FLAG          0x00000020ul
 51#define PUBLIC_MECH_FORTEZZA_FLAG    0x00000040ul
 52#define PUBLIC_MECH_RC5_FLAG         0x00000080ul
 53#define PUBLIC_MECH_SHA1_FLAG        0x00000100ul
 54#define PUBLIC_MECH_MD5_FLAG         0x00000200ul
 55#define PUBLIC_MECH_MD2_FLAG         0x00000400ul
 56#define PUBLIC_MECH_SSL_FLAG         0x00000800ul
 57#define PUBLIC_MECH_TLS_FLAG         0x00001000ul
 58#define PUBLIC_MECH_AES_FLAG         0x00002000ul
 59#define PUBLIC_MECH_SHA256_FLAG      0x00004000ul
 60#define PUBLIC_MECH_SHA512_FLAG      0x00008000ul
 61#define PUBLIC_MECH_CAMELLIA_FLAG    0x00010000ul
 62#define PUBLIC_MECH_SEED_FLAG        0x00020000ul
 63
 64#define PUBLIC_MECH_RANDOM_FLAG      0x08000000ul
 65#define PUBLIC_MECH_FRIENDLY_FLAG    0x10000000ul
 66#define PUBLIC_OWN_PW_DEFAULTS       0X20000000ul
 67#define PUBLIC_DISABLE_FLAG          0x40000000ul
 68
 69/* warning: reserved means reserved */
 70#define PUBLIC_MECH_RESERVED_FLAGS   0x87FF0000ul
 71
 72/* These cipher flags are visible to all other libraries, */
 73/* But they must be converted before used in functions */
 74/* withing the security module */
 75#define PUBLIC_CIPHER_FORTEZZA_FLAG  0x00000001ul
 76
 77/* warning: reserved means reserved */
 78#define PUBLIC_CIPHER_RESERVED_FLAGS 0xFFFFFFFEul
 79
 80SEC_BEGIN_PROTOS
 81
 82/*
 83 * the following functions are going to be deprecated in NSS 4.0 in
 84 * favor of the new stan functions.
 85 */
 86
 87/* Initialization */
 88extern SECMODModule *SECMOD_LoadModule(char *moduleSpec,SECMODModule *parent,
 89							PRBool recurse);
 90
 91extern SECMODModule *SECMOD_LoadUserModule(char *moduleSpec,SECMODModule *parent,
 92							PRBool recurse);
 93
 94SECStatus SECMOD_UnloadUserModule(SECMODModule *mod);
 95
 96SECMODModule * SECMOD_CreateModule(const char *lib, const char *name,
 97					const char *param, const char *nss);
 98/*
 99 * After a fork(), PKCS #11 says we need to call C_Initialize again in
100 * the child before we can use the module. This function causes this 
101 * reinitialization.
102 * NOTE: Any outstanding handles will become invalid, which means your
103 * keys and contexts will fail, but new ones can be created.
104 *
105 * Setting 'force' to true means to do the reinitialization even if the 
106 * PKCS #11 module does not seem to need it. This allows software modules 
107 * which ignore fork to preserve their keys across the fork().
108 */
109SECStatus SECMOD_RestartModules(PRBool force);
110
111
112/* Module Management */
113char **SECMOD_GetModuleSpecList(SECMODModule *module);
114SECStatus SECMOD_FreeModuleSpecList(SECMODModule *module,char **moduleSpecList);
115
116 
117/* protoypes */
118/* Get a list of active PKCS #11 modules */
119extern SECMODModuleList *SECMOD_GetDefaultModuleList(void); 
120/* Get a list of defined but not loaded PKCS #11 modules */
121extern SECMODModuleList *SECMOD_GetDeadModuleList(void);
122/* Get a list of Modules which define PKCS #11 modules to load */
123extern SECMODModuleList *SECMOD_GetDBModuleList(void);
124
125/* lock to protect all three module lists above */
126extern SECMODListLock *SECMOD_GetDefaultModuleListLock(void);
127
128extern SECStatus SECMOD_UpdateModule(SECMODModule *module);
129
130/* lock management */
131extern void SECMOD_GetReadLock(SECMODListLock *);
132extern void SECMOD_ReleaseReadLock(SECMODListLock *);
133
134/* Operate on modules by name */
135extern SECMODModule *SECMOD_FindModule(const char *name);
136extern SECStatus SECMOD_DeleteModule(const char *name, int *type);
137extern SECStatus SECMOD_DeleteModuleEx(const char * name, 
138                                       SECMODModule *mod, 
139                                       int *type, 
140                                       PRBool permdb);
141extern SECStatus SECMOD_DeleteInternalModule(const char *name);
142extern PRBool SECMOD_CanDeleteInternalModule(void);
143extern SECStatus SECMOD_AddNewModule(const char* moduleName, 
144			      const char* dllPath,
145                              unsigned long defaultMechanismFlags,
146                              unsigned long cipherEnableFlags);
147extern SECStatus SECMOD_AddNewModuleEx(const char* moduleName,
148			      const char* dllPath,
149                              unsigned long defaultMechanismFlags,
150                              unsigned long cipherEnableFlags,
151                              char* modparms,
152                              char* nssparms);
153
154/* database/memory management */
155extern SECMODModule *SECMOD_GetInternalModule(void);
156extern SECMODModule *SECMOD_ReferenceModule(SECMODModule *module);
157extern void SECMOD_DestroyModule(SECMODModule *module);
158extern PK11SlotInfo *SECMOD_LookupSlot(SECMODModuleID module,
159							unsigned long slotID);
160extern PK11SlotInfo *SECMOD_FindSlot(SECMODModule *module,const char *name);
161
162/* Funtion reports true if at least one of the modules */
163/* of modType has been installed */
164PRBool SECMOD_IsModulePresent( unsigned long int pubCipherEnableFlags );
165
166/* accessors */
167PRBool SECMOD_GetSkipFirstFlag(SECMODModule *mod);
168PRBool SECMOD_GetDefaultModDBFlag(SECMODModule *mod);
169
170/* Functions used to convert between internal & public representation
171 * of Mechanism Flags and Cipher Enable Flags */
172extern unsigned long SECMOD_PubMechFlagstoInternal(unsigned long publicFlags);
173extern unsigned long SECMOD_PubCipherFlagstoInternal(unsigned long publicFlags);
174
175PRBool SECMOD_HasRemovableSlots(SECMODModule *mod);
176PK11SlotInfo *SECMOD_WaitForAnyTokenEvent(SECMODModule *mod, 
177				unsigned long flags, PRIntervalTime latency);
178/*
179 * Warning: the SECMOD_CancelWait function is highly destructive, potentially 
180 * finalizing  the module 'mod' (causing inprogress operations to fail, 
181 * and session key material to disappear). It should only be called when 
182 * shutting down  the module. 
183 */
184SECStatus SECMOD_CancelWait(SECMODModule *mod);
185/*
186 * check to see if the module has added new slots. PKCS 11 v2.20 allows for
187 * modules to add new slots, but never remove them. Slots not be added between 
188 * a call to C_GetSlotLlist(Flag, NULL, &count) and the corresponding
189 * C_GetSlotList(flag, &data, &count) so that the array doesn't accidently
190 * grow on the caller. It is permissible for the slots to increase between
191 * corresponding calls with NULL to get the size.
192 */
193SECStatus SECMOD_UpdateSlotList(SECMODModule *mod);
194SEC_END_PROTOS
195
196#endif