forked from open-eid/qt-common
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQPCSC_p.h
163 lines (143 loc) · 3.89 KB
/
QPCSC_p.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*
* QEstEidCommon
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#pragma once
#include <QtCore/QHash>
#ifdef Q_OS_WIN
#undef UNICODE
#define NOMINMAX
#include <winsock2.h>
#include <winscard.h>
#else
#include <PCSC/wintypes.h>
#include <PCSC/winscard.h>
#include <arpa/inet.h>
#endif
#ifndef SCARD_CTL_CODE
#define SCARD_CTL_CODE(code) (0x42000000 + (code))
#endif
// http://www.pcscworkgroup.com/specifications/files/pcsc10_v2.02.09.pdf
#define CM_IOCTL_GET_FEATURE_REQUEST SCARD_CTL_CODE(3400)
enum DRIVER_FEATURES {
FEATURE_VERIFY_PIN_START = 0x01,
FEATURE_VERIFY_PIN_FINISH = 0x02,
FEATURE_MODIFY_PIN_START = 0x03,
FEATURE_MODIFY_PIN_FINISH = 0x04,
FEATURE_GET_KEY_PRESSED = 0x05,
FEATURE_VERIFY_PIN_DIRECT = 0x06,
FEATURE_MODIFY_PIN_DIRECT = 0x07,
FEATURE_MCT_READER_DIRECT = 0x08,
FEATURE_MCT_UNIVERSAL = 0x09,
FEATURE_IFD_PIN_PROPERTIES = 0x0A,
FEATURE_ABORT = 0x0B,
FEATURE_SET_SPE_MESSAGE = 0x0C,
FEATURE_VERIFY_PIN_DIRECT_APP_ID = 0x0D,
FEATURE_MODIFY_PIN_DIRECT_APP_ID = 0x0E,
FEATURE_WRITE_DISPLAY = 0x0F,
FEATURE_GET_KEY = 0x10,
FEATURE_IFD_DISPLAY_PROPERTIES = 0x11,
FEATURE_GET_TLV_PROPERTIES = 0x12,
FEATURE_CCID_ESC_COMMAND = 0x13
};
#ifdef Q_OS_MAC
#pragma pack(1)
#else
#pragma pack(push, 1)
#endif
typedef struct
{
quint8 tag;
quint8 length;
quint32 value;
} PCSC_TLV_STRUCTURE;
typedef struct
{
quint8 bTimerOut;
quint8 bTimerOut2;
quint8 bmFormatString;
quint8 bmPINBlockString;
quint8 bmPINLengthFormat;
quint16 wPINMaxExtraDigit;
quint8 bEntryValidationCondition;
quint8 bNumberMessage;
quint16 wLangId;
quint8 bMsgIndex;
quint8 bTeoPrologue[3];
quint32 ulDataLength;
quint8 abData[1];
} PIN_VERIFY_STRUCTURE;
typedef struct
{
quint8 bTimerOut;
quint8 bTimerOut2;
quint8 bmFormatString;
quint8 bmPINBlockString;
quint8 bmPINLengthFormat;
quint8 bInsertionOffsetOld;
quint8 bInsertionOffsetNew;
quint16 wPINMaxExtraDigit;
quint8 bConfirmPIN;
quint8 bEntryValidationCondition;
quint8 bNumberMessage;
quint16 wLangId;
quint8 bMsgIndex1;
quint8 bMsgIndex2;
quint8 bMsgIndex3;
quint8 bTeoPrologue[3];
quint32 ulDataLength;
quint8 abData[1];
} PIN_MODIFY_STRUCTURE;
typedef struct {
quint16 wLcdLayout;
quint8 bEntryValidationCondition;
quint8 bTimeOut2;
} PIN_PROPERTIES_STRUCTURE;
typedef struct {
quint16 wLcdMaxCharacters;
quint16 wLcdMaxLines;
} DISPLAY_PROPERTIES_STRUCTURE;
#ifdef Q_OS_MAC
#pragma pack()
#else
#pragma pack(pop)
#endif
#ifndef SCARD_ATTR_DEVICE_FRIENDLY_NAME_A
#define SCARD_ATTR_VALUE(Class, Tag) ((((ULONG)(Class)) << 16) | ((ULONG)(Tag)))
#define SCARD_CLASS_SYSTEM 0x7fff
#define SCARD_ATTR_DEVICE_FRIENDLY_NAME_A SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0003)
#define SCARD_ATTR_DEVICE_FRIENDLY_NAME SCARD_ATTR_DEVICE_FRIENDLY_NAME_A
#endif
class QPCSCPrivate
{
public:
QPCSCPrivate(): context(0), running(false) {}
SCARDCONTEXT context;
bool running;
};
class QPCSCReaderPrivate
{
public:
QPCSCReaderPrivate( QPCSCPrivate *d );
QByteArray attrib( DWORD id ) const;
QPCSCPrivate *d;
SCARDHANDLE card;
DWORD proto;
SCARD_READERSTATE state;
QByteArray reader, friendlyName;
QHash<DRIVER_FEATURES,DWORD> ioctl;
};