Back to index

lightning-sunbird  0.9+nobinonly
devt.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 #ifndef DEVT_H
00038 #define DEVT_H
00039 
00040 #ifdef DEBUG
00041 static const char DEVT_CVS_ID[] = "@(#) $RCSfile: devt.h,v $ $Revision: 1.22 $ $Date: 2005/01/20 02:25:47 $";
00042 #endif /* DEBUG */
00043 
00044 /*
00045  * devt.h
00046  *
00047  * This file contains definitions for the low-level cryptoki devices.
00048  */
00049 
00050 #ifndef NSSBASET_H
00051 #include "nssbaset.h"
00052 #endif /* NSSBASET_H */
00053 
00054 #ifndef NSSPKIT_H
00055 #include "nsspkit.h"
00056 #endif /* NSSPKIT_H */
00057 
00058 #ifndef NSSDEVT_H
00059 #include "nssdevt.h"
00060 #endif /* NSSDEVT_H */
00061 
00062 #ifndef NSSCKT_H
00063 #include "nssckt.h"
00064 #endif /* NSSCKT_H */
00065 
00066 #ifndef BASET_H
00067 #include "baset.h"
00068 #endif /* BASET_H */
00069 
00070 #ifdef NSS_3_4_CODE
00071 #include "secmodt.h"
00072 #endif /* NSS_3_4_CODE */
00073 
00074 PR_BEGIN_EXTERN_C
00075 
00076 typedef struct nssSessionStr nssSession;
00077 
00078 /* XXX until NSSTokenStr is moved */
00079 struct nssDeviceBaseStr
00080 {
00081   NSSArena *arena;
00082   PZLock *lock;
00083   PRInt32 refCount;
00084   NSSUTF8 *name;
00085   PRUint32 flags;
00086 };
00087 
00088 typedef struct nssTokenObjectCacheStr nssTokenObjectCache;
00089 
00090 /* XXX until devobject.c goes away */
00091 struct NSSTokenStr
00092 {
00093     struct nssDeviceBaseStr base;
00094     NSSSlot *slot;  /* Parent (or peer, if you will) */
00095     CK_FLAGS ckFlags; /* from CK_TOKEN_INFO.flags */
00096     PRUint32 flags;
00097     void *epv;
00098     nssSession *defaultSession;
00099     NSSTrustDomain *trustDomain;
00100     PRIntervalTime lastTime;
00101     nssTokenObjectCache *cache;
00102 #ifdef NSS_3_4_CODE
00103     PK11SlotInfo *pk11slot;
00104 #endif
00105 };
00106 
00107 typedef enum {
00108   nssSlotAskPasswordTimes_FirstTime = 0,
00109   nssSlotAskPasswordTimes_EveryTime = 1,
00110   nssSlotAskPasswordTimes_Timeout = 2
00111 } 
00112 nssSlotAskPasswordTimes;
00113 
00114 struct nssSlotAuthInfoStr
00115 {
00116   PRTime lastLogin;
00117   nssSlotAskPasswordTimes askTimes;
00118   PRIntervalTime askPasswordTimeout;
00119 };
00120 
00121 struct NSSSlotStr
00122 {
00123   struct nssDeviceBaseStr base;
00124   NSSModule *module; /* Parent */
00125   NSSToken *token;  /* Peer */
00126   CK_SLOT_ID slotID;
00127   CK_FLAGS ckFlags; /* from CK_SLOT_INFO.flags */
00128   struct nssSlotAuthInfoStr authInfo;
00129   PRIntervalTime lastTokenPing;
00130   PZLock *lock;
00131 #ifdef NSS_3_4_CODE
00132   void *epv;
00133   PK11SlotInfo *pk11slot;
00134 #endif
00135 };
00136 
00137 struct nssSessionStr
00138 {
00139   PZLock *lock;
00140   CK_SESSION_HANDLE handle;
00141   NSSSlot *slot;
00142   PRBool isRW;
00143   PRBool ownLock;
00144 };
00145 
00146 typedef enum {
00147     NSSCertificateType_Unknown = 0,
00148     NSSCertificateType_PKIX = 1
00149 } NSSCertificateType;
00150 
00151 typedef enum {
00152     nssTrustLevel_Unknown = 0,
00153     nssTrustLevel_NotTrusted = 1,
00154     nssTrustLevel_Trusted = 2,
00155     nssTrustLevel_TrustedDelegator = 3,
00156     nssTrustLevel_Valid = 4,
00157     nssTrustLevel_ValidDelegator = 5
00158 } nssTrustLevel;
00159 
00160 typedef struct nssCryptokiInstanceStr nssCryptokiInstance;
00161 
00162 struct nssCryptokiInstanceStr
00163 {
00164     CK_OBJECT_HANDLE handle;
00165     NSSToken *token;
00166     PRBool isTokenObject;
00167     NSSUTF8 *label;
00168 };
00169 
00170 typedef struct nssCryptokiInstanceStr nssCryptokiObject;
00171 
00172 typedef struct nssTokenCertSearchStr nssTokenCertSearch;
00173 
00174 typedef enum {
00175     nssTokenSearchType_AllObjects = 0,
00176     nssTokenSearchType_SessionOnly = 1,
00177     nssTokenSearchType_TokenOnly = 2,
00178     nssTokenSearchType_TokenForced = 3
00179 } nssTokenSearchType;
00180 
00181 struct nssTokenCertSearchStr
00182 {
00183     nssTokenSearchType searchType;
00184     PRStatus (* callback)(NSSCertificate *c, void *arg);
00185     void *cbarg;
00186     nssList *cached;
00187     /* TODO: add a cache query callback if the list would be large 
00188      *       (traversal) 
00189      */
00190 };
00191 
00192 struct nssSlotListStr;
00193 typedef struct nssSlotListStr nssSlotList;
00194 
00195 struct NSSAlgorithmAndParametersStr
00196 {
00197     CK_MECHANISM mechanism;
00198 };
00199 
00200 PR_END_EXTERN_C
00201 
00202 #endif /* DEVT_H */