/[rdesktop]/sourceforge.net/trunk/rdesktop/scard.h
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /sourceforge.net/trunk/rdesktop/scard.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1309 - (hide annotations)
Wed Nov 1 20:52:01 2006 UTC (17 years, 8 months ago) by stargo
File MIME type: text/plain
File size: 5528 byte(s)
Smartcard support by Alexi Volkov <alexi@pravex.kiev.ua> and additional
patches for smartcard-support by Jennings Jared <jared.jennings.ctr@eglin.af.mil>

1 stargo 1309 /************************************/
2     /* Smart Card support for RDesktop. */
3     /* Copyright (C) by Alexi Volkov */
4     /* e-mail: alexi@myrealbox.com */
5     /* ICQ: 264679502 */
6     /************************************/
7    
8     #include <pthread.h>
9     #include <pcsclite.h>
10     #include "proto.h"
11    
12     /*************************************************************************/
13     /* these are the additional types needed to split out 64-vs-32-bit APIs */
14     /* */
15    
16     /* The point of all of this is to avoid patching the existing smartcard
17     * infrastructure (PC/SC Lite, libmusclecard+libmusclepkcs11 or CoolKey, any
18     * other apps linking against any of these) because the need for patches
19     * spreads without limit. The alternative is to patch the heck out of rdesktop,
20     * which is already being done anyway.
21     *
22     * - jared.jennings@eglin.af.mil, 2 Aug 2006
23     */
24    
25     #include <stdint.h>
26    
27     /* A DWORD when dealing with the smartcard stuff. Could be 32 bits or 64. */
28     typedef DWORD MYPCSC_DWORD;
29     /* A DWORD when talking to the server. Must be exactly 32 bits all the time.*/
30     typedef uint32_t SERVER_DWORD;
31    
32     typedef SCARDCONTEXT MYPCSC_SCARDCONTEXT;
33     typedef SCARDHANDLE MYPCSC_SCARDHANDLE;
34     typedef uint32_t SERVER_SCARDCONTEXT;
35     typedef uint32_t SERVER_SCARDHANDLE;
36    
37     typedef SCARD_READERSTATE_A MYPCSC_SCARD_READERSTATE_A;
38     typedef LPSCARD_READERSTATE_A MYPCSC_LPSCARD_READERSTATE_A;
39    
40     typedef struct
41     {
42     const char *szReader;
43     void *pvUserData;
44     SERVER_DWORD dwCurrentState;
45     SERVER_DWORD dwEventState;
46     SERVER_DWORD cbAtr;
47     unsigned char rgbAtr[MAX_ATR_SIZE];
48     }
49     SERVER_SCARD_READERSTATE_A;
50    
51     typedef SERVER_SCARD_READERSTATE_A *SERVER_LPSCARD_READERSTATE_A;
52    
53     #define SERVER_SCARDSTATESIZE (sizeof(SERVER_SCARD_READERSTATE_A) - sizeof(const char *) - sizeof(void *))
54     #define MYPCSC_SCARDSTATESIZE (sizeof(MYPCSC_SCARD_READERSTATE_A) - sizeof(const char *) - sizeof(void *))
55    
56     typedef struct _SERVER_SCARD_IO_REQUEST
57     {
58     SERVER_DWORD dwProtocol; /* Protocol identifier */
59     SERVER_DWORD cbPciLength; /* Protocol Control Inf Length */
60     }
61     SERVER_SCARD_IO_REQUEST, *SERVER_LPSCARD_IO_REQUEST;
62    
63     typedef SCARD_IO_REQUEST MYPCSC_SCARD_IO_REQUEST;
64     typedef LPSCARD_IO_REQUEST MYPCSC_LPSCARD_IO_REQUEST;
65    
66    
67     /* */
68     /* */
69     /*************************************************************************/
70    
71    
72     #define SC_TRUE 1
73     #define SC_FALSE 0
74    
75     #define SC_ESTABLISH_CONTEXT 0x00090014 /* EstablishContext */
76     #define SC_RELEASE_CONTEXT 0x00090018 /* ReleaseContext */
77     #define SC_IS_VALID_CONTEXT 0x0009001C /* IsValidContext */
78     #define SC_LIST_READER_GROUPS 0x00090020 /* ListReaderGroups */
79     #define SC_LIST_READERS 0x00090028 /* ListReadersA */
80     #define SC_INTRODUCE_READER_GROUP 0x00090050 /* IntroduceReaderGroup */
81     #define SC_FORGET_READER_GROUP 0x00090058 /* ForgetReader */
82     #define SC_INTRODUCE_READER 0x00090060 /* IntroduceReader */
83     #define SC_FORGET_READER 0x00090068 /* IntroduceReader */
84     #define SC_ADD_READER_TO_GROUP 0x00090070 /* AddReaderToGroup */
85     #define SC_REMOVE_READER_FROM_GROUP 0x00090078 /* RemoveReaderFromGroup */
86     #define SC_CONNECT 0x000900AC /* ConnectA */
87     #define SC_RECONNECT 0x000900B4 /* Reconnect */
88     #define SC_DISCONNECT 0x000900B8 /* Disconnect */
89     #define SC_GET_STATUS_CHANGE 0x000900A0 /* GetStatusChangeA */
90     #define SC_CANCEL 0x000900A8 /* Cancel */
91     #define SC_BEGIN_TRANSACTION 0x000900BC /* BeginTransaction */
92     #define SC_END_TRANSACTION 0x000900C0 /* EndTransaction */
93     #define SC_STATE 0x000900C4 /* State */
94     #define SC_STATUS 0x000900C8 /* StatusA */
95     #define SC_TRANSMIT 0x000900D0 /* Transmit */
96     #define SC_CONTROL 0x000900D4 /* Control */
97     #define SC_GETATTRIB 0x000900D8 /* GetAttrib */
98     #define SC_SETATTRIB 0x000900DC /* SetAttrib */
99     #define SC_ACCESS_STARTED_EVENT 0x000900E0 /* SCardAccessStartedEvent */
100     #define SC_LOCATE_CARDS_BY_ATR 0x000900E8 /* LocateCardsByATR */
101    
102     /* #define INPUT_LINKED 0x00020000 */
103     #define INPUT_LINKED 0xFFFFFFFF
104    
105     #define SC_THREAD_FUNCTION(f) void *(*f)(void *)
106    
107     extern RDPDR_DEVICE g_rdpdr_device[];
108    
109     typedef struct _MEM_HANDLE
110     {
111     struct _MEM_HANDLE *prevHandle;
112     struct _MEM_HANDLE *nextHandle;
113     int dataSize;
114     } MEM_HANDLE, *PMEM_HANDLE;
115    
116     typedef struct _SCARD_ATRMASK_L
117     {
118     unsigned int cbAtr;
119     unsigned char rgbAtr[36];
120     unsigned char rgbMask[36];
121     } SCARD_ATRMASK_L, *PSCARD_ATRMASK_L, *LPSCARD_ATRMASK_L;
122    
123     typedef struct _TSCNameMapRec
124     {
125     char alias[128];
126     char name[128];
127     char vendor[128];
128     } TSCNameMapRec, *PSCNameMapRec;
129    
130     typedef struct _TSCHCardRec
131     {
132     DWORD hCard;
133     char *vendor;
134     struct _TSCHCardRec *next;
135     struct _TSCHCardRec *prev;
136     } TSCHCardRec, *PSCHCardRec;
137    
138     typedef struct _TSCThreadData
139     {
140     uint32 device;
141     uint32 id;
142     NTHANDLE handle;
143     uint32 request;
144     STREAM in;
145     STREAM out;
146     PMEM_HANDLE memHandle;
147     struct _TSCThreadData *next;
148     } TSCThreadData, *PSCThreadData;
149    
150     typedef struct _TThreadListElement
151     {
152     pthread_t thread;
153     pthread_mutex_t busy;
154     pthread_mutex_t nodata;
155     PSCThreadData data;
156     struct _TThreadListElement *next;
157     } TThreadListElement, *PThreadListElement;
158    
159     int scard_enum_devices(uint32 * id, char *optarg);

  ViewVC Help
Powered by ViewVC 1.1.26