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