2014-04-04 23:30:03 +04:00
|
|
|
/**
|
|
|
|
* WinPR: Windows Portable Runtime
|
|
|
|
* Smart Card API
|
|
|
|
*
|
|
|
|
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
2020-02-17 16:07:20 +03:00
|
|
|
* Copyright 2020 Armin Novak <armin.novak@thincast.com>
|
|
|
|
* Copyright 2020 Thincast Technologies GmbH
|
2014-04-04 23:30:03 +04:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef WINPR_SMARTCARD_PCSC_PRIVATE_H
|
|
|
|
#define WINPR_SMARTCARD_PCSC_PRIVATE_H
|
|
|
|
|
2014-04-26 02:49:57 +04:00
|
|
|
#ifndef _WIN32
|
|
|
|
|
2014-04-09 02:55:50 +04:00
|
|
|
#include <winpr/platform.h>
|
2014-04-04 23:30:03 +04:00
|
|
|
#include <winpr/smartcard.h>
|
|
|
|
|
2014-05-03 21:49:50 +04:00
|
|
|
/**
|
|
|
|
* On Windows, DWORD and ULONG are defined to unsigned long.
|
|
|
|
* However, 64-bit Windows uses the LLP64 model which defines
|
|
|
|
* unsigned long as a 4-byte type, while most non-Windows
|
|
|
|
* systems use the LP64 model where unsigned long is 8 bytes.
|
|
|
|
*
|
|
|
|
* WinPR correctly defines DWORD and ULONG to be 4-byte types
|
|
|
|
* regardless of LLP64/LP64, but this has the side effect of
|
|
|
|
* breaking compatibility with the broken pcsc-lite types.
|
|
|
|
*
|
|
|
|
* To make matters worse, pcsc-lite correctly defines
|
|
|
|
* the data types on OS X, but not on other platforms.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef __APPLE__
|
2020-02-17 16:07:20 +03:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#ifndef BYTE
|
|
|
|
typedef uint8_t PCSC_BYTE;
|
|
|
|
#endif
|
|
|
|
typedef uint8_t PCSC_UCHAR;
|
|
|
|
typedef PCSC_UCHAR* PCSC_PUCHAR;
|
|
|
|
typedef uint16_t PCSC_USHORT;
|
|
|
|
|
|
|
|
#ifndef __COREFOUNDATION_CFPLUGINCOM__
|
|
|
|
typedef uint32_t PCSC_ULONG;
|
|
|
|
typedef void* PCSC_LPVOID;
|
|
|
|
typedef int16_t PCSC_BOOL;
|
|
|
|
#endif
|
|
|
|
|
2017-05-15 14:43:51 +03:00
|
|
|
typedef PCSC_ULONG* PCSC_PULONG;
|
2020-02-17 16:07:20 +03:00
|
|
|
typedef const void* PCSC_LPCVOID;
|
|
|
|
typedef uint32_t PCSC_DWORD;
|
|
|
|
typedef PCSC_DWORD* PCSC_PDWORD;
|
|
|
|
typedef uint16_t PCSC_WORD;
|
|
|
|
typedef int32_t PCSC_LONG;
|
|
|
|
typedef const char* PCSC_LPCSTR;
|
|
|
|
typedef const PCSC_BYTE* PCSC_LPCBYTE;
|
|
|
|
typedef PCSC_BYTE* PCSC_LPBYTE;
|
|
|
|
typedef PCSC_DWORD* PCSC_LPDWORD;
|
|
|
|
typedef char* PCSC_LPSTR;
|
|
|
|
|
2014-05-03 21:49:50 +04:00
|
|
|
#else
|
2020-02-17 16:07:20 +03:00
|
|
|
|
|
|
|
#ifndef BYTE
|
|
|
|
typedef unsigned char PCSC_BYTE;
|
|
|
|
#endif
|
|
|
|
typedef unsigned char PCSC_UCHAR;
|
|
|
|
typedef PCSC_UCHAR* PCSC_PUCHAR;
|
|
|
|
typedef unsigned short PCSC_USHORT;
|
|
|
|
|
|
|
|
#ifndef __COREFOUNDATION_CFPLUGINCOM__
|
2014-05-03 21:49:50 +04:00
|
|
|
typedef unsigned long PCSC_ULONG;
|
2020-02-17 16:07:20 +03:00
|
|
|
typedef void* PCSC_LPVOID;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef const void* PCSC_LPCVOID;
|
|
|
|
typedef unsigned long PCSC_DWORD;
|
|
|
|
typedef PCSC_DWORD* PCSC_PDWORD;
|
2014-05-03 21:49:50 +04:00
|
|
|
typedef long PCSC_LONG;
|
2020-02-17 16:07:20 +03:00
|
|
|
typedef const char* PCSC_LPCSTR;
|
|
|
|
typedef const PCSC_BYTE* PCSC_LPCBYTE;
|
|
|
|
typedef PCSC_BYTE* PCSC_LPBYTE;
|
|
|
|
typedef PCSC_DWORD* PCSC_LPDWORD;
|
|
|
|
typedef char* PCSC_LPSTR;
|
|
|
|
|
|
|
|
/* these types were deprecated but still used by old drivers and
|
|
|
|
* applications. So just declare and use them. */
|
|
|
|
typedef PCSC_LPSTR PCSC_LPTSTR;
|
|
|
|
typedef PCSC_LPCSTR PCSC_LPCTSTR;
|
|
|
|
|
|
|
|
/* types unused by pcsc-lite */
|
|
|
|
typedef short PCSC_BOOL;
|
|
|
|
typedef unsigned short PCSC_WORD;
|
|
|
|
typedef PCSC_ULONG* PCSC_PULONG;
|
|
|
|
|
2014-05-03 21:49:50 +04:00
|
|
|
#endif
|
2020-02-17 16:07:20 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
#define PCSC_SCARD_UNKNOWN 0x0001
|
|
|
|
#define PCSC_SCARD_ABSENT 0x0002
|
|
|
|
#define PCSC_SCARD_PRESENT 0x0004
|
|
|
|
#define PCSC_SCARD_SWALLOWED 0x0008
|
|
|
|
#define PCSC_SCARD_POWERED 0x0010
|
|
|
|
#define PCSC_SCARD_NEGOTIABLE 0x0020
|
|
|
|
#define PCSC_SCARD_SPECIFIC 0x0040
|
2014-04-13 00:45:06 +04:00
|
|
|
|
2020-02-20 15:42:54 +03:00
|
|
|
#define PCSC_SCARD_PROTOCOL_RAW 0x00000004u
|
|
|
|
#define PCSC_SCARD_PROTOCOL_T15 0x00000008u
|
2014-04-13 02:13:18 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
#define PCSC_MAX_BUFFER_SIZE 264
|
|
|
|
#define PCSC_MAX_BUFFER_SIZE_EXTENDED (4 + 3 + (1 << 16) + 3 + 2)
|
2014-04-16 01:51:39 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
#define PCSC_MAX_ATR_SIZE 33
|
2014-04-26 04:07:29 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
#define PCSC_SCARD_AUTOALLOCATE (PCSC_DWORD)(-1)
|
2014-05-03 21:49:50 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
#define PCSC_SCARD_CTL_CODE(code) (0x42000000 + (code))
|
|
|
|
#define PCSC_CM_IOCTL_GET_FEATURE_REQUEST PCSC_SCARD_CTL_CODE(3400)
|
2014-05-04 03:02:17 +04:00
|
|
|
|
2014-11-11 01:40:22 +03:00
|
|
|
/**
|
|
|
|
* pcsc-lite defines SCARD_READERSTATE, SCARD_IO_REQUEST as packed
|
|
|
|
* on Mac OS X only and uses default packing everywhere else.
|
|
|
|
*/
|
|
|
|
|
2014-11-10 00:42:35 +03:00
|
|
|
#ifdef __APPLE__
|
2014-11-11 01:40:22 +03:00
|
|
|
#pragma pack(push, 1)
|
2014-11-10 00:42:35 +03:00
|
|
|
#endif
|
2014-05-04 03:02:17 +04:00
|
|
|
|
2014-04-26 04:07:29 +04:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
LPCSTR szReader;
|
|
|
|
LPVOID pvUserData;
|
2014-05-03 21:49:50 +04:00
|
|
|
PCSC_DWORD dwCurrentState;
|
|
|
|
PCSC_DWORD dwEventState;
|
|
|
|
PCSC_DWORD cbAtr;
|
2014-04-26 04:07:29 +04:00
|
|
|
BYTE rgbAtr[PCSC_MAX_ATR_SIZE]; /* WinSCard: 36, PCSC: 33 */
|
2019-11-06 17:24:51 +03:00
|
|
|
} PCSC_SCARD_READERSTATE;
|
2014-04-26 04:07:29 +04:00
|
|
|
|
2014-05-03 22:20:17 +04:00
|
|
|
typedef struct
|
2014-05-03 21:49:50 +04:00
|
|
|
{
|
|
|
|
PCSC_DWORD dwProtocol;
|
|
|
|
PCSC_DWORD cbPciLength;
|
2014-05-03 22:20:17 +04:00
|
|
|
} PCSC_SCARD_IO_REQUEST;
|
2014-05-03 21:49:50 +04:00
|
|
|
|
2014-11-10 00:42:35 +03:00
|
|
|
#ifdef __APPLE__
|
2014-11-11 01:40:22 +03:00
|
|
|
#pragma pack(pop)
|
2014-11-10 00:42:35 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
|
2014-05-04 03:02:17 +04:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
BYTE tag;
|
|
|
|
BYTE length;
|
|
|
|
UINT32 value;
|
|
|
|
} PCSC_TLV_STRUCTURE;
|
|
|
|
|
2014-10-18 04:40:11 +04:00
|
|
|
#pragma pack(pop)
|
2014-05-04 03:02:17 +04:00
|
|
|
|
2014-04-04 23:30:03 +04:00
|
|
|
int PCSC_InitializeSCardApi(void);
|
2020-02-17 12:53:02 +03:00
|
|
|
const SCardApiFunctionTable* PCSC_GetSCardApiFunctionTable(void);
|
2014-04-04 23:30:03 +04:00
|
|
|
|
2014-04-26 02:49:57 +04:00
|
|
|
#endif
|
|
|
|
|
2014-04-04 23:30:03 +04:00
|
|
|
#endif /* WINPR_SMARTCARD_PCSC_PRIVATE_H */
|