Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 | |
michael@0 | 5 | #ifndef DEVT_H |
michael@0 | 6 | #define DEVT_H |
michael@0 | 7 | |
michael@0 | 8 | /* |
michael@0 | 9 | * devt.h |
michael@0 | 10 | * |
michael@0 | 11 | * This file contains definitions for the low-level cryptoki devices. |
michael@0 | 12 | */ |
michael@0 | 13 | |
michael@0 | 14 | #ifndef NSSBASET_H |
michael@0 | 15 | #include "nssbaset.h" |
michael@0 | 16 | #endif /* NSSBASET_H */ |
michael@0 | 17 | |
michael@0 | 18 | #ifndef NSSPKIT_H |
michael@0 | 19 | #include "nsspkit.h" |
michael@0 | 20 | #endif /* NSSPKIT_H */ |
michael@0 | 21 | |
michael@0 | 22 | #ifndef NSSDEVT_H |
michael@0 | 23 | #include "nssdevt.h" |
michael@0 | 24 | #endif /* NSSDEVT_H */ |
michael@0 | 25 | |
michael@0 | 26 | #ifndef BASET_H |
michael@0 | 27 | #include "baset.h" |
michael@0 | 28 | #endif /* BASET_H */ |
michael@0 | 29 | |
michael@0 | 30 | #include "secmodt.h" |
michael@0 | 31 | |
michael@0 | 32 | PR_BEGIN_EXTERN_C |
michael@0 | 33 | |
michael@0 | 34 | typedef struct nssSessionStr nssSession; |
michael@0 | 35 | |
michael@0 | 36 | /* XXX until NSSTokenStr is moved */ |
michael@0 | 37 | struct nssDeviceBaseStr |
michael@0 | 38 | { |
michael@0 | 39 | NSSArena *arena; |
michael@0 | 40 | PZLock *lock; |
michael@0 | 41 | PRInt32 refCount; |
michael@0 | 42 | NSSUTF8 *name; |
michael@0 | 43 | PRUint32 flags; |
michael@0 | 44 | }; |
michael@0 | 45 | |
michael@0 | 46 | typedef struct nssTokenObjectCacheStr nssTokenObjectCache; |
michael@0 | 47 | |
michael@0 | 48 | /* XXX until devobject.c goes away */ |
michael@0 | 49 | struct NSSTokenStr |
michael@0 | 50 | { |
michael@0 | 51 | struct nssDeviceBaseStr base; |
michael@0 | 52 | NSSSlot *slot; /* Parent (or peer, if you will) */ |
michael@0 | 53 | CK_FLAGS ckFlags; /* from CK_TOKEN_INFO.flags */ |
michael@0 | 54 | PRUint32 flags; |
michael@0 | 55 | void *epv; |
michael@0 | 56 | nssSession *defaultSession; |
michael@0 | 57 | NSSTrustDomain *trustDomain; |
michael@0 | 58 | PRIntervalTime lastTime; |
michael@0 | 59 | nssTokenObjectCache *cache; |
michael@0 | 60 | PK11SlotInfo *pk11slot; |
michael@0 | 61 | }; |
michael@0 | 62 | |
michael@0 | 63 | typedef enum { |
michael@0 | 64 | nssSlotAskPasswordTimes_FirstTime = 0, |
michael@0 | 65 | nssSlotAskPasswordTimes_EveryTime = 1, |
michael@0 | 66 | nssSlotAskPasswordTimes_Timeout = 2 |
michael@0 | 67 | } |
michael@0 | 68 | nssSlotAskPasswordTimes; |
michael@0 | 69 | |
michael@0 | 70 | struct nssSlotAuthInfoStr |
michael@0 | 71 | { |
michael@0 | 72 | PRTime lastLogin; |
michael@0 | 73 | nssSlotAskPasswordTimes askTimes; |
michael@0 | 74 | PRIntervalTime askPasswordTimeout; |
michael@0 | 75 | }; |
michael@0 | 76 | |
michael@0 | 77 | struct NSSSlotStr |
michael@0 | 78 | { |
michael@0 | 79 | struct nssDeviceBaseStr base; |
michael@0 | 80 | NSSModule *module; /* Parent */ |
michael@0 | 81 | NSSToken *token; /* Peer */ |
michael@0 | 82 | CK_SLOT_ID slotID; |
michael@0 | 83 | CK_FLAGS ckFlags; /* from CK_SLOT_INFO.flags */ |
michael@0 | 84 | struct nssSlotAuthInfoStr authInfo; |
michael@0 | 85 | PRIntervalTime lastTokenPing; |
michael@0 | 86 | PZLock *lock; |
michael@0 | 87 | void *epv; |
michael@0 | 88 | PK11SlotInfo *pk11slot; |
michael@0 | 89 | }; |
michael@0 | 90 | |
michael@0 | 91 | struct nssSessionStr |
michael@0 | 92 | { |
michael@0 | 93 | PZLock *lock; |
michael@0 | 94 | CK_SESSION_HANDLE handle; |
michael@0 | 95 | NSSSlot *slot; |
michael@0 | 96 | PRBool isRW; |
michael@0 | 97 | PRBool ownLock; |
michael@0 | 98 | }; |
michael@0 | 99 | |
michael@0 | 100 | typedef enum { |
michael@0 | 101 | NSSCertificateType_Unknown = 0, |
michael@0 | 102 | NSSCertificateType_PKIX = 1 |
michael@0 | 103 | } NSSCertificateType; |
michael@0 | 104 | |
michael@0 | 105 | typedef enum { |
michael@0 | 106 | nssTrustLevel_Unknown = 0, |
michael@0 | 107 | nssTrustLevel_NotTrusted = 1, |
michael@0 | 108 | nssTrustLevel_Trusted = 2, |
michael@0 | 109 | nssTrustLevel_TrustedDelegator = 3, |
michael@0 | 110 | nssTrustLevel_MustVerify = 4, |
michael@0 | 111 | nssTrustLevel_ValidDelegator = 5 |
michael@0 | 112 | } nssTrustLevel; |
michael@0 | 113 | |
michael@0 | 114 | typedef struct nssCryptokiInstanceStr nssCryptokiInstance; |
michael@0 | 115 | |
michael@0 | 116 | struct nssCryptokiInstanceStr |
michael@0 | 117 | { |
michael@0 | 118 | CK_OBJECT_HANDLE handle; |
michael@0 | 119 | NSSToken *token; |
michael@0 | 120 | PRBool isTokenObject; |
michael@0 | 121 | NSSUTF8 *label; |
michael@0 | 122 | }; |
michael@0 | 123 | |
michael@0 | 124 | typedef struct nssCryptokiInstanceStr nssCryptokiObject; |
michael@0 | 125 | |
michael@0 | 126 | typedef struct nssTokenCertSearchStr nssTokenCertSearch; |
michael@0 | 127 | |
michael@0 | 128 | typedef enum { |
michael@0 | 129 | nssTokenSearchType_AllObjects = 0, |
michael@0 | 130 | nssTokenSearchType_SessionOnly = 1, |
michael@0 | 131 | nssTokenSearchType_TokenOnly = 2, |
michael@0 | 132 | nssTokenSearchType_TokenForced = 3 |
michael@0 | 133 | } nssTokenSearchType; |
michael@0 | 134 | |
michael@0 | 135 | struct nssTokenCertSearchStr |
michael@0 | 136 | { |
michael@0 | 137 | nssTokenSearchType searchType; |
michael@0 | 138 | PRStatus (* callback)(NSSCertificate *c, void *arg); |
michael@0 | 139 | void *cbarg; |
michael@0 | 140 | nssList *cached; |
michael@0 | 141 | /* TODO: add a cache query callback if the list would be large |
michael@0 | 142 | * (traversal) |
michael@0 | 143 | */ |
michael@0 | 144 | }; |
michael@0 | 145 | |
michael@0 | 146 | struct nssSlotListStr; |
michael@0 | 147 | typedef struct nssSlotListStr nssSlotList; |
michael@0 | 148 | |
michael@0 | 149 | struct NSSAlgorithmAndParametersStr |
michael@0 | 150 | { |
michael@0 | 151 | CK_MECHANISM mechanism; |
michael@0 | 152 | }; |
michael@0 | 153 | |
michael@0 | 154 | PR_END_EXTERN_C |
michael@0 | 155 | |
michael@0 | 156 | #endif /* DEVT_H */ |