VirtualBox

source: vbox/trunk/include/VBox/RemoteDesktop/VRDESCard.h@ 86296

Last change on this file since 86296 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 15.6 KB
Line 
1/** @file
2 * VBox Remote Desktop Extension (VRDE) - SmartCard interface.
3 */
4
5/*
6 * Copyright (C) 2011-2020 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef VBOX_INCLUDED_RemoteDesktop_VRDESCard_h
27#define VBOX_INCLUDED_RemoteDesktop_VRDESCard_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <VBox/RemoteDesktop/VRDE.h>
33
34/*
35 * Interface for accessing the smart card reader devices on the client.
36 *
37 * Async callbacks are used for providing feedback, reporting errors, etc.
38 *
39 * The caller prepares a VRDESCARD*REQ structure and submits it.
40 */
41
42#define VRDE_SCARD_INTERFACE_NAME "SCARD"
43
44/** The VRDE server smart card access interface entry points. Interface version 1. */
45typedef struct VRDESCARDINTERFACE
46{
47 /** The header. */
48 VRDEINTERFACEHDR header;
49
50 /** Submit an async IO request to the client.
51 *
52 * @param hServer The VRDE server instance.
53 * @param pvUser The callers context of this request.
54 * @param u32Function The function: VRDE_SCARD_FN_*.
55 * @param pvData Function specific data: VRDESCARD*REQ.
56 * @param cbData Size of data.
57 *
58 * @return IPRT status code.
59 */
60 DECLR3CALLBACKMEMBER(int, VRDESCardRequest, (HVRDESERVER hServer,
61 void *pvUser,
62 uint32_t u32Function,
63 const void *pvData,
64 uint32_t cbData));
65
66} VRDESCARDINTERFACE;
67
68/* Smartcard interface callbacks. */
69typedef struct VRDESCARDCALLBACKS
70{
71 /** The header. */
72 VRDEINTERFACEHDR header;
73
74 /** Notifications.
75 *
76 * @param pvContext The callbacks context specified in VRDEGetInterface.
77 * @param u32Id The notification identifier: VRDE_SCARD_NOTIFY_*.
78 * @param pvData The notification specific data.
79 * @param cbData The size of buffer pointed by pvData.
80 *
81 * @return IPRT status code.
82 */
83 DECLR3CALLBACKMEMBER(int, VRDESCardCbNotify, (void *pvContext,
84 uint32_t u32Id,
85 void *pvData,
86 uint32_t cbData));
87
88 /** IO response.
89 *
90 * @param pvContext The callbacks context specified in VRDEGetInterface.
91 * @param rcRequest The IPRT status code for the request.
92 * @param pvUser The pvUser parameter of VRDESCardRequest.
93 * @param u32Function The completed function: VRDE_SCARD_FN_*.
94 * @param pvData Function specific response data: VRDESCARD*RSP.
95 * @param cbData The size of the buffer pointed by pvData.
96 *
97 * @return IPRT status code.
98 */
99 DECLR3CALLBACKMEMBER(int, VRDESCardCbResponse, (void *pvContext,
100 int rcRequest,
101 void *pvUser,
102 uint32_t u32Function,
103 void *pvData,
104 uint32_t cbData));
105} VRDESCARDCALLBACKS;
106
107
108/*
109 * Notifications.
110 * u32Id parameter of VRDESCARDCALLBACKS::VRDESCardCbNotify.
111 */
112
113#define VRDE_SCARD_NOTIFY_ATTACH 1 /* A SCARD RDPDR device has been attached. */
114#define VRDE_SCARD_NOTIFY_DETACH 2 /* A SCARD RDPDR device has been detached. */
115
116/*
117 * Notifications.
118 * Data structures: pvData of VRDESCARDCALLBACKS::VRDESCardCbNotify.
119 */
120typedef struct VRDESCARDNOTIFYATTACH
121{
122 uint32_t u32ClientId;
123 uint32_t u32DeviceId;
124} VRDESCARDNOTIFYATTACH;
125
126typedef struct VRDESCARDNOTIFYDETACH
127{
128 uint32_t u32ClientId;
129 uint32_t u32DeviceId;
130} VRDESCARDNOTIFYDETACH;
131
132
133/*
134 * IO request codes.
135 * Must be not 0, which is used internally.
136 */
137
138#define VRDE_SCARD_FN_ESTABLISHCONTEXT 1
139#define VRDE_SCARD_FN_LISTREADERS 2
140#define VRDE_SCARD_FN_RELEASECONTEXT 3
141#define VRDE_SCARD_FN_GETSTATUSCHANGE 4
142#define VRDE_SCARD_FN_CANCEL 5
143#define VRDE_SCARD_FN_CONNECT 6
144#define VRDE_SCARD_FN_RECONNECT 7
145#define VRDE_SCARD_FN_DISCONNECT 8
146#define VRDE_SCARD_FN_BEGINTRANSACTION 9
147#define VRDE_SCARD_FN_ENDTRANSACTION 10
148#define VRDE_SCARD_FN_STATE 11
149#define VRDE_SCARD_FN_STATUS 12
150#define VRDE_SCARD_FN_TRANSMIT 13
151#define VRDE_SCARD_FN_CONTROL 14
152#define VRDE_SCARD_FN_GETATTRIB 15
153#define VRDE_SCARD_FN_SETATTRIB 16
154
155#define VRDE_SCARD_MAX_READERS 10
156#define VRDE_SCARD_MAX_ATR_LENGTH 36
157#define VRDE_SCARD_MAX_PCI_DATA 1024
158
159#define VRDE_SCARD_S_SUCCESS 0x00000000
160#define VRDE_SCARD_F_INTERNAL_ERROR 0x80100001
161#define VRDE_SCARD_E_CANCELLED 0x80100002
162#define VRDE_SCARD_E_INVALID_HANDLE 0x80100003
163#define VRDE_SCARD_E_INVALID_PARAMETER 0x80100004
164#define VRDE_SCARD_E_INVALID_TARGET 0x80100005
165#define VRDE_SCARD_E_NO_MEMORY 0x80100006
166#define VRDE_SCARD_F_WAITED_TOO_LONG 0x80100007
167#define VRDE_SCARD_E_INSUFFICIENT_BUFFER 0x80100008
168#define VRDE_SCARD_E_UNKNOWN_READER 0x80100009
169#define VRDE_SCARD_E_TIMEOUT 0x8010000A
170#define VRDE_SCARD_E_SHARING_VIOLATION 0x8010000B
171#define VRDE_SCARD_E_NO_SMARTCARD 0x8010000C
172#define VRDE_SCARD_E_UNKNOWN_CARD 0x8010000D
173#define VRDE_SCARD_E_CANT_DISPOSE 0x8010000E
174#define VRDE_SCARD_E_PROTO_MISMATCH 0x8010000F
175#define VRDE_SCARD_E_NOT_READY 0x80100010
176#define VRDE_SCARD_E_INVALID_VALUE 0x80100011
177#define VRDE_SCARD_E_SYSTEM_CANCELLED 0x80100012
178#define VRDE_SCARD_F_COMM_ERROR 0x80100013
179#define VRDE_SCARD_F_UNKNOWN_ERROR 0x80100014
180#define VRDE_SCARD_E_INVALID_ATR 0x80100015
181#define VRDE_SCARD_E_NOT_TRANSACTED 0x80100016
182#define VRDE_SCARD_E_READER_UNAVAILABLE 0x80100017
183#define VRDE_SCARD_P_SHUTDOWN 0x80100018
184#define VRDE_SCARD_E_PCI_TOO_SMALL 0x80100019
185#define VRDE_SCARD_E_ICC_INSTALLATION 0x80100020
186#define VRDE_SCARD_E_ICC_CREATEORDER 0x80100021
187#define VRDE_SCARD_E_UNSUPPORTED_FEATURE 0x80100022
188#define VRDE_SCARD_E_DIR_NOT_FOUND 0x80100023
189#define VRDE_SCARD_E_FILE_NOT_FOUND 0x80100024
190#define VRDE_SCARD_E_NO_DIR 0x80100025
191#define VRDE_SCARD_E_READER_UNSUPPORTED 0x8010001A
192#define VRDE_SCARD_E_DUPLICATE_READER 0x8010001B
193#define VRDE_SCARD_E_CARD_UNSUPPORTED 0x8010001C
194#define VRDE_SCARD_E_NO_SERVICE 0x8010001D
195#define VRDE_SCARD_E_SERVICE_STOPPED 0x8010001E
196#define VRDE_SCARD_E_UNEXPECTED 0x8010001F
197#define VRDE_SCARD_E_NO_FILE 0x80100026
198#define VRDE_SCARD_E_NO_ACCESS 0x80100027
199#define VRDE_SCARD_E_WRITE_TOO_MANY 0x80100028
200#define VRDE_SCARD_E_BAD_SEEK 0x80100029
201#define VRDE_SCARD_E_INVALID_CHV 0x8010002A
202#define VRDE_SCARD_E_UNKNOWN_RES_MSG 0x8010002B
203#define VRDE_SCARD_E_NO_SUCH_CERTIFICATE 0x8010002C
204#define VRDE_SCARD_E_CERTIFICATE_UNAVAILABLE 0x8010002D
205#define VRDE_SCARD_E_NO_READERS_AVAILABLE 0x8010002E
206#define VRDE_SCARD_E_COMM_DATA_LOST 0x8010002F
207#define VRDE_SCARD_E_NO_KEY_CONTAINER 0x80100030
208#define VRDE_SCARD_E_SERVER_TOO_BUSY 0x80100031
209#define VRDE_SCARD_E_PIN_CACHE_EXPIRED 0x80100032
210#define VRDE_SCARD_E_NO_PIN_CACHE 0x80100033
211#define VRDE_SCARD_E_READ_ONLY_CARD 0x80100034
212#define VRDE_SCARD_W_UNSUPPORTED_CARD 0x80100065
213#define VRDE_SCARD_W_UNRESPONSIVE_CARD 0x80100066
214#define VRDE_SCARD_W_UNPOWERED_CARD 0x80100067
215#define VRDE_SCARD_W_RESET_CARD 0x80100068
216#define VRDE_SCARD_W_REMOVED_CARD 0x80100069
217#define VRDE_SCARD_W_SECURITY_VIOLATION 0x8010006A
218#define VRDE_SCARD_W_WRONG_CHV 0x8010006B
219#define VRDE_SCARD_W_CHV_BLOCKED 0x8010006C
220#define VRDE_SCARD_W_EOF 0x8010006D
221#define VRDE_SCARD_W_CANCELLED_BY_USER 0x8010006E
222#define VRDE_SCARD_W_CARD_NOT_AUTHENTICATED 0x8010006F
223#define VRDE_SCARD_W_CACHE_ITEM_NOT_FOUND 0x80100070
224#define VRDE_SCARD_W_CACHE_ITEM_STALE 0x80100071
225#define VRDE_SCARD_W_CACHE_ITEM_TOO_BIG 0x80100072
226
227#define VRDE_SCARD_STATE_UNAWARE 0x0000
228#define VRDE_SCARD_STATE_IGNORE 0x0001
229#define VRDE_SCARD_STATE_CHANGED 0x0002
230#define VRDE_SCARD_STATE_UNKNOWN 0x0004
231#define VRDE_SCARD_STATE_UNAVAILABLE 0x0008
232#define VRDE_SCARD_STATE_EMPTY 0x0010
233#define VRDE_SCARD_STATE_PRESENT 0x0020
234#define VRDE_SCARD_STATE_ATRMATCH 0x0040
235#define VRDE_SCARD_STATE_EXCLUSIVE 0x0080
236#define VRDE_SCARD_STATE_INUSE 0x0100
237#define VRDE_SCARD_STATE_MUTE 0x0200
238#define VRDE_SCARD_STATE_UNPOWERED 0x0400
239#define VRDE_SCARD_STATE_MASK UINT32_C(0x0000FFFF)
240#define VRDE_SCARD_STATE_COUNT_MASK UINT32_C(0xFFFF0000)
241
242#define VRDE_SCARD_PROTOCOL_UNDEFINED 0x00000000
243#define VRDE_SCARD_PROTOCOL_T0 0x00000001
244#define VRDE_SCARD_PROTOCOL_T1 0x00000002
245#define VRDE_SCARD_PROTOCOL_Tx 0x00000003
246#define VRDE_SCARD_PROTOCOL_RAW 0x00010000
247
248#define VRDE_SCARD_PROTOCOL_DEFAULT 0x80000000
249#define VRDE_SCARD_PROTOCOL_OPTIMAL 0x00000000
250
251#define VRDE_SCARD_SHARE_EXCLUSIVE 0x00000001
252#define VRDE_SCARD_SHARE_SHARED 0x00000002
253#define VRDE_SCARD_SHARE_DIRECT 0x00000003
254
255/* u32Initialization, u32Disposition */
256#define VRDE_SCARD_LEAVE_CARD 0x00000000
257#define VRDE_SCARD_RESET_CARD 0x00000001
258#define VRDE_SCARD_UNPOWER_CARD 0x00000002
259#define VRDE_SCARD_EJECT_CARD 0x00000003
260
261/* VRDESCARDSTATUSRSP::u32State */
262#define VRDE_SCARD_UNKNOWN 0x00000000
263#define VRDE_SCARD_ABSENT 0x00000001
264#define VRDE_SCARD_PRESENT 0x00000002
265#define VRDE_SCARD_SWALLOWED 0x00000003
266#define VRDE_SCARD_POWERED 0x00000004
267#define VRDE_SCARD_NEGOTIABLE 0x00000005
268#define VRDE_SCARD_SPECIFICMODE 0x00000006
269
270
271/*
272 * IO request data structures.
273 */
274typedef struct VRDESCARDCONTEXT
275{
276 uint32_t u32ContextSize;
277 uint8_t au8Context[16];
278} VRDESCARDCONTEXT;
279
280typedef struct VRDESCARDHANDLE
281{
282 VRDESCARDCONTEXT Context;
283 uint32_t u32HandleSize;
284 uint8_t au8Handle[16];
285} VRDESCARDHANDLE;
286
287typedef struct VRDESCARDREADERSTATECALL
288{
289 char *pszReader; /* UTF8 */
290 uint32_t u32CurrentState; /* VRDE_SCARD_STATE_* */
291} VRDESCARDREADERSTATECALL;
292
293typedef struct VRDESCARDREADERSTATERETURN
294{
295 uint32_t u32CurrentState; /* VRDE_SCARD_STATE_* */
296 uint32_t u32EventState; /* VRDE_SCARD_STATE_* */
297 uint32_t u32AtrLength;
298 uint8_t au8Atr[VRDE_SCARD_MAX_ATR_LENGTH];
299} VRDESCARDREADERSTATERETURN;
300
301typedef struct VRDESCARDPCI
302{
303 uint32_t u32Protocol; /* VRDE_SCARD_PROTOCOL_* */
304 uint32_t u32PciLength; /* Includes u32Protocol and u32PciLength fields. 8 if no data in au8PciData. */
305 uint8_t au8PciData[VRDE_SCARD_MAX_PCI_DATA];
306} VRDESCARDPCI;
307
308typedef struct VRDESCARDESTABLISHCONTEXTREQ
309{
310 uint32_t u32ClientId;
311 uint32_t u32DeviceId;
312} VRDESCARDESTABLISHCONTEXTREQ;
313
314typedef struct VRDESCARDESTABLISHCONTEXTRSP
315{
316 uint32_t u32ReturnCode;
317 VRDESCARDCONTEXT Context;
318} VRDESCARDESTABLISHCONTEXTRSP;
319
320typedef struct VRDESCARDLISTREADERSREQ
321{
322 VRDESCARDCONTEXT Context;
323} VRDESCARDLISTREADERSREQ;
324
325typedef struct VRDESCARDLISTREADERSRSP
326{
327 uint32_t u32ReturnCode;
328 uint32_t cReaders;
329 char *apszNames[VRDE_SCARD_MAX_READERS]; /* UTF8 */
330} VRDESCARDLISTREADERSRSP;
331
332typedef struct VRDESCARDRELEASECONTEXTREQ
333{
334 VRDESCARDCONTEXT Context;
335} VRDESCARDRELEASECONTEXTREQ;
336
337typedef struct VRDESCARDRELEASECONTEXTRSP
338{
339 uint32_t u32ReturnCode;
340} VRDESCARDRELEASECONTEXTRSP;
341
342typedef struct VRDESCARDGETSTATUSCHANGEREQ
343{
344 VRDESCARDCONTEXT Context;
345 uint32_t u32Timeout; /* Milliseconds. 0xFFFFFFFF = INFINITE */
346 uint32_t cReaders;
347 VRDESCARDREADERSTATECALL aReaderStates[VRDE_SCARD_MAX_READERS];
348} VRDESCARDGETSTATUSCHANGEREQ;
349
350typedef struct VRDESCARDGETSTATUSCHANGERSP
351{
352 uint32_t u32ReturnCode;
353 uint32_t cReaders;
354 VRDESCARDREADERSTATERETURN aReaderStates[VRDE_SCARD_MAX_READERS];
355} VRDESCARDGETSTATUSCHANGERSP;
356
357typedef struct VRDESCARDCANCELREQ
358{
359 VRDESCARDCONTEXT Context;
360} VRDESCARDCANCELREQ;
361
362typedef struct VRDESCARDCANCELRSP
363{
364 uint32_t u32ReturnCode;
365} VRDESCARDCANCELRSP;
366
367typedef struct VRDESCARDCONNECTREQ
368{
369 VRDESCARDCONTEXT Context;
370 char *pszReader; /* UTF8 */
371 uint32_t u32ShareMode; /* VRDE_SCARD_SHARE_* */
372 uint32_t u32PreferredProtocols;
373} VRDESCARDCONNECTREQ;
374
375typedef struct VRDESCARDCONNECTRSP
376{
377 uint32_t u32ReturnCode;
378 VRDESCARDHANDLE hCard;
379 uint32_t u32ActiveProtocol;
380} VRDESCARDCONNECTRSP;
381
382typedef struct VRDESCARDRECONNECTREQ
383{
384 VRDESCARDHANDLE hCard;
385 uint32_t u32ShareMode;
386 uint32_t u32PreferredProtocols;
387 uint32_t u32Initialization;
388} VRDESCARDRECONNECTREQ;
389
390typedef struct VRDESCARDRECONNECTRSP
391{
392 uint32_t u32ReturnCode;
393 uint32_t u32ActiveProtocol;
394} VRDESCARDRECONNECTRSP;
395
396typedef struct VRDESCARDDISCONNECTREQ
397{
398 VRDESCARDHANDLE hCard;
399 uint32_t u32Disposition;
400} VRDESCARDDISCONNECTREQ;
401
402typedef struct VRDESCARDDISCONNECTRSP
403{
404 uint32_t u32ReturnCode;
405} VRDESCARDDISCONNECTRSP;
406
407typedef struct VRDESCARDBEGINTRANSACTIONREQ
408{
409 VRDESCARDHANDLE hCard;
410 uint32_t u32Disposition;
411} VRDESCARDBEGINTRANSACTIONREQ;
412
413typedef struct VRDESCARDBEGINTRANSACTIONRSP
414{
415 uint32_t u32ReturnCode;
416} VRDESCARDBEGINTRANSACTIONRSP;
417
418typedef struct VRDESCARDENDTRANSACTIONREQ
419{
420 VRDESCARDHANDLE hCard;
421 uint32_t u32Disposition;
422} VRDESCARDENDTRANSACTIONREQ;
423
424typedef struct VRDESCARDENDTRANSACTIONRSP
425{
426 uint32_t u32ReturnCode;
427} VRDESCARDENDTRANSACTIONRSP;
428
429typedef struct VRDESCARDSTATEREQ
430{
431 VRDESCARDHANDLE hCard;
432} VRDESCARDSTATEREQ;
433
434typedef struct VRDESCARDSTATERSP
435{
436 uint32_t u32ReturnCode;
437 uint32_t u32State;
438 uint32_t u32Protocol;
439 uint32_t u32AtrLength;
440 uint8_t au8Atr[VRDE_SCARD_MAX_ATR_LENGTH];
441} VRDESCARDSTATERSP;
442
443typedef struct VRDESCARDSTATUSREQ
444{
445 VRDESCARDHANDLE hCard;
446} VRDESCARDSTATUSREQ;
447
448typedef struct VRDESCARDSTATUSRSP
449{
450 uint32_t u32ReturnCode;
451 char *szReader;
452 uint32_t u32State;
453 uint32_t u32Protocol;
454 uint32_t u32AtrLength;
455 uint8_t au8Atr[VRDE_SCARD_MAX_ATR_LENGTH];
456} VRDESCARDSTATUSRSP;
457
458typedef struct VRDESCARDTRANSMITREQ
459{
460 VRDESCARDHANDLE hCard;
461 VRDESCARDPCI ioSendPci;
462 uint32_t u32SendLength;
463 uint8_t *pu8SendBuffer;
464 uint32_t u32RecvLength;
465} VRDESCARDTRANSMITREQ;
466
467typedef struct VRDESCARDTRANSMITRSP
468{
469 uint32_t u32ReturnCode;
470 VRDESCARDPCI ioRecvPci;
471 uint32_t u32RecvLength;
472 uint8_t *pu8RecvBuffer;
473} VRDESCARDTRANSMITRSP;
474
475typedef struct VRDESCARDCONTROLREQ
476{
477 VRDESCARDHANDLE hCard;
478 uint32_t u32ControlCode;
479 uint32_t u32InBufferSize;
480 uint8_t *pu8InBuffer;
481 uint32_t u32OutBufferSize;
482} VRDESCARDCONTROLREQ;
483
484typedef struct VRDESCARDCONTROLRSP
485{
486 uint32_t u32ReturnCode;
487 uint32_t u32OutBufferSize;
488 uint8_t *pu8OutBuffer;
489} VRDESCARDCONTROLRSP;
490
491typedef struct VRDESCARDGETATTRIBREQ
492{
493 VRDESCARDHANDLE hCard;
494 uint32_t u32AttrId;
495 uint32_t u32AttrLen;
496} VRDESCARDGETATTRIBREQ;
497
498typedef struct VRDESCARDGETATTRIBRSP
499{
500 uint32_t u32ReturnCode;
501 uint32_t u32AttrLength;
502 uint8_t *pu8Attr;
503} VRDESCARDGETATTRIBRSP;
504
505typedef struct VRDESCARDSETATTRIBREQ
506{
507 VRDESCARDHANDLE hCard;
508 uint32_t u32AttrId;
509 uint32_t u32AttrLen;
510 uint8_t *pu8Attr;
511} VRDESCARDSETATTRIBREQ;
512
513typedef struct VRDESCARDSETATTRIBRSP
514{
515 uint32_t u32ReturnCode;
516} VRDESCARDSETATTRIBRSP;
517
518#endif /* !VBOX_INCLUDED_RemoteDesktop_VRDESCard_h */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette