/[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 1311 - (hide annotations)
Wed Nov 1 21:23:08 2006 UTC (17 years, 7 months ago) by stargo
File MIME type: text/plain
File size: 5506 byte(s)
Add smartcard support for mac os x

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

  ViewVC Help
Powered by ViewVC 1.1.26