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: andre@0: #ifndef DEVT_H andre@0: #define DEVT_H andre@0: andre@0: /* andre@0: * devt.h andre@0: * andre@0: * This file contains definitions for the low-level cryptoki devices. andre@0: */ andre@0: andre@0: #ifndef NSSBASET_H andre@0: #include "nssbaset.h" andre@0: #endif /* NSSBASET_H */ andre@0: andre@0: #ifndef NSSPKIT_H andre@0: #include "nsspkit.h" andre@0: #endif /* NSSPKIT_H */ andre@0: andre@0: #ifndef NSSDEVT_H andre@0: #include "nssdevt.h" andre@0: #endif /* NSSDEVT_H */ andre@0: andre@0: #ifndef BASET_H andre@0: #include "baset.h" andre@0: #endif /* BASET_H */ andre@0: andre@0: #include "secmodt.h" andre@0: andre@0: PR_BEGIN_EXTERN_C andre@0: andre@0: typedef struct nssSessionStr nssSession; andre@0: andre@0: /* XXX until NSSTokenStr is moved */ andre@0: struct nssDeviceBaseStr andre@0: { andre@0: NSSArena *arena; andre@0: PZLock *lock; andre@0: PRInt32 refCount; andre@0: NSSUTF8 *name; andre@0: PRUint32 flags; andre@0: }; andre@0: andre@0: typedef struct nssTokenObjectCacheStr nssTokenObjectCache; andre@0: andre@0: /* XXX until devobject.c goes away */ andre@0: struct NSSTokenStr andre@0: { andre@0: struct nssDeviceBaseStr base; andre@0: NSSSlot *slot; /* Parent (or peer, if you will) */ andre@0: CK_FLAGS ckFlags; /* from CK_TOKEN_INFO.flags */ andre@0: PRUint32 flags; andre@0: void *epv; andre@0: nssSession *defaultSession; andre@0: NSSTrustDomain *trustDomain; andre@0: PRIntervalTime lastTime; andre@0: nssTokenObjectCache *cache; andre@0: PK11SlotInfo *pk11slot; andre@0: }; andre@0: andre@0: typedef enum { andre@0: nssSlotAskPasswordTimes_FirstTime = 0, andre@0: nssSlotAskPasswordTimes_EveryTime = 1, andre@0: nssSlotAskPasswordTimes_Timeout = 2 andre@0: } andre@0: nssSlotAskPasswordTimes; andre@0: andre@0: struct nssSlotAuthInfoStr andre@0: { andre@0: PRTime lastLogin; andre@0: nssSlotAskPasswordTimes askTimes; andre@0: PRIntervalTime askPasswordTimeout; andre@0: }; andre@0: andre@0: struct NSSSlotStr andre@0: { andre@0: struct nssDeviceBaseStr base; andre@0: NSSModule *module; /* Parent */ andre@0: NSSToken *token; /* Peer */ andre@0: CK_SLOT_ID slotID; andre@0: CK_FLAGS ckFlags; /* from CK_SLOT_INFO.flags */ andre@0: struct nssSlotAuthInfoStr authInfo; andre@0: PRIntervalTime lastTokenPing; andre@0: PZLock *lock; andre@0: void *epv; andre@0: PK11SlotInfo *pk11slot; andre@0: }; andre@0: andre@0: struct nssSessionStr andre@0: { andre@0: PZLock *lock; andre@0: CK_SESSION_HANDLE handle; andre@0: NSSSlot *slot; andre@0: PRBool isRW; andre@0: PRBool ownLock; andre@0: }; andre@0: andre@0: typedef enum { andre@0: NSSCertificateType_Unknown = 0, andre@0: NSSCertificateType_PKIX = 1 andre@0: } NSSCertificateType; andre@0: andre@0: typedef enum { andre@0: nssTrustLevel_Unknown = 0, andre@0: nssTrustLevel_NotTrusted = 1, andre@0: nssTrustLevel_Trusted = 2, andre@0: nssTrustLevel_TrustedDelegator = 3, andre@0: nssTrustLevel_MustVerify = 4, andre@0: nssTrustLevel_ValidDelegator = 5 andre@0: } nssTrustLevel; andre@0: andre@0: typedef struct nssCryptokiInstanceStr nssCryptokiInstance; andre@0: andre@0: struct nssCryptokiInstanceStr andre@0: { andre@0: CK_OBJECT_HANDLE handle; andre@0: NSSToken *token; andre@0: PRBool isTokenObject; andre@0: NSSUTF8 *label; andre@0: }; andre@0: andre@0: typedef struct nssCryptokiInstanceStr nssCryptokiObject; andre@0: andre@0: typedef struct nssTokenCertSearchStr nssTokenCertSearch; andre@0: andre@0: typedef enum { andre@0: nssTokenSearchType_AllObjects = 0, andre@0: nssTokenSearchType_SessionOnly = 1, andre@0: nssTokenSearchType_TokenOnly = 2, andre@0: nssTokenSearchType_TokenForced = 3 andre@0: } nssTokenSearchType; andre@0: andre@0: struct nssTokenCertSearchStr andre@0: { andre@0: nssTokenSearchType searchType; andre@0: PRStatus (* callback)(NSSCertificate *c, void *arg); andre@0: void *cbarg; andre@0: nssList *cached; andre@0: /* TODO: add a cache query callback if the list would be large andre@0: * (traversal) andre@0: */ andre@0: }; andre@0: andre@0: struct nssSlotListStr; andre@0: typedef struct nssSlotListStr nssSlotList; andre@0: andre@0: struct NSSAlgorithmAndParametersStr andre@0: { andre@0: CK_MECHANISM mechanism; andre@0: }; andre@0: andre@0: PR_END_EXTERN_C andre@0: andre@0: #endif /* DEVT_H */