|
Packit Service |
aee942 |
/*
|
|
Packit Service |
aee942 |
PCSCv2part10.h: helper functions for PC/SC v2 part 10 services
|
|
Packit Service |
aee942 |
Copyright (C) 2012 Ludovic Rousseau
|
|
Packit Service |
aee942 |
|
|
Packit Service |
aee942 |
This library is free software; you can redistribute it and/or
|
|
Packit Service |
aee942 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
aee942 |
License as published by the Free Software Foundation; either
|
|
Packit Service |
aee942 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
aee942 |
|
|
Packit Service |
aee942 |
This library is distributed in the hope that it will be useful,
|
|
Packit Service |
aee942 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
aee942 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
aee942 |
Lesser General Public License for more details.
|
|
Packit Service |
aee942 |
|
|
Packit Service |
aee942 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
aee942 |
License along with this library; if not, write to the Free Software
|
|
Packit Service |
aee942 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
Packit Service |
aee942 |
*/
|
|
Packit Service |
aee942 |
|
|
Packit Service |
aee942 |
#ifndef __reader_h__
|
|
Packit Service |
aee942 |
|
|
Packit Service |
aee942 |
#ifdef HAVE_CONFIG_H
|
|
Packit Service |
aee942 |
#include "config.h"
|
|
Packit Service |
aee942 |
#endif
|
|
Packit Service |
aee942 |
|
|
Packit Service |
aee942 |
#ifdef HAVE_READER_H
|
|
Packit Service |
aee942 |
#include <reader.h>
|
|
Packit Service |
aee942 |
#else
|
|
Packit Service |
aee942 |
|
|
Packit Service |
aee942 |
/**
|
|
Packit Service |
aee942 |
* Provide source compatibility on different platforms
|
|
Packit Service |
aee942 |
*/
|
|
Packit Service |
aee942 |
#define SCARD_CTL_CODE(code) (0x42000000 + (code))
|
|
Packit Service |
aee942 |
|
|
Packit Service |
aee942 |
/**
|
|
Packit Service |
aee942 |
* PC/SC part 10 v2.02.07 March 2010 reader tags
|
|
Packit Service |
aee942 |
*/
|
|
Packit Service |
aee942 |
#define CM_IOCTL_GET_FEATURE_REQUEST SCARD_CTL_CODE(3400)
|
|
Packit Service |
aee942 |
|
|
Packit Service |
aee942 |
#define FEATURE_GET_TLV_PROPERTIES 0x12 /**< Get TLV properties */
|
|
Packit Service |
aee942 |
|
|
Packit Service |
aee942 |
#include <inttypes.h>
|
|
Packit Service |
aee942 |
|
|
Packit Service |
aee942 |
/* Set structure elements aligment on bytes
|
|
Packit Service |
aee942 |
* http://gcc.gnu.org/onlinedocs/gcc/Structure_002dPacking-Pragmas.html */
|
|
Packit Service |
aee942 |
#if defined(__APPLE__) | defined(sun)
|
|
Packit Service |
aee942 |
#pragma pack(1)
|
|
Packit Service |
aee942 |
#else
|
|
Packit Service |
aee942 |
#pragma pack(push, 1)
|
|
Packit Service |
aee942 |
#endif
|
|
Packit Service |
aee942 |
|
|
Packit Service |
aee942 |
/** the structure must be 6-bytes long */
|
|
Packit Service |
aee942 |
typedef struct
|
|
Packit Service |
aee942 |
{
|
|
Packit Service |
aee942 |
uint8_t tag; /**< Tag */
|
|
Packit Service |
aee942 |
uint8_t length; /**< Length */
|
|
Packit Service |
aee942 |
uint32_t value; /**< This value is always in BIG ENDIAN format as documented in PCSC v2 part 10 ch 2.2 page 2. You can use ntohl() for example */
|
|
Packit Service |
aee942 |
} PCSC_TLV_STRUCTURE;
|
|
Packit Service |
aee942 |
|
|
Packit Service |
aee942 |
/* restore default structure elements alignment */
|
|
Packit Service |
aee942 |
#if defined(__APPLE__) | defined(sun)
|
|
Packit Service |
aee942 |
#pragma pack()
|
|
Packit Service |
aee942 |
#else
|
|
Packit Service |
aee942 |
#pragma pack(pop)
|
|
Packit Service |
aee942 |
#endif
|
|
Packit Service |
aee942 |
|
|
Packit Service |
aee942 |
/* properties returned by FEATURE_GET_TLV_PROPERTIES */
|
|
Packit Service |
aee942 |
#define PCSCv2_PART10_PROPERTY_wLcdLayout 1 /**< wLcdLayout */
|
|
Packit Service |
aee942 |
#define PCSCv2_PART10_PROPERTY_bEntryValidationCondition 2 /**< bEntryValidationCondition */
|
|
Packit Service |
aee942 |
#define PCSCv2_PART10_PROPERTY_bTimeOut2 3 /**< bTimeOut2 */
|
|
Packit Service |
aee942 |
#define PCSCv2_PART10_PROPERTY_wLcdMaxCharacters 4 /**< wLcdMaxCharacters */
|
|
Packit Service |
aee942 |
#define PCSCv2_PART10_PROPERTY_wLcdMaxLines 5 /**< wLcdMaxLines */
|
|
Packit Service |
aee942 |
#define PCSCv2_PART10_PROPERTY_bMinPINSize 6 /**< bMinPINSize */
|
|
Packit Service |
aee942 |
#define PCSCv2_PART10_PROPERTY_bMaxPINSize 7 /**< bMaxPINSize */
|
|
Packit Service |
aee942 |
#define PCSCv2_PART10_PROPERTY_sFirmwareID 8 /**< sFirmwareID */
|
|
Packit Service |
aee942 |
#define PCSCv2_PART10_PROPERTY_bPPDUSupport 9 /**< bPPDUSupport */
|
|
Packit Service |
aee942 |
#define PCSCv2_PART10_PROPERTY_dwMaxAPDUDataSize 10 /**< dwMaxAPDUDataSize */
|
|
Packit Service |
aee942 |
#define PCSCv2_PART10_PROPERTY_wIdVendor 11 /**< wIdVendor */
|
|
Packit Service |
aee942 |
#define PCSCv2_PART10_PROPERTY_wIdProduct 12 /**< wIdProduct */
|
|
Packit Service |
aee942 |
|
|
Packit Service |
aee942 |
#endif
|
|
Packit Service |
aee942 |
#endif
|
|
Packit Service |
aee942 |
|
|
Packit Service |
aee942 |
/**
|
|
Packit Service |
aee942 |
* @file
|
|
Packit Service |
aee942 |
* @defgroup API API
|
|
Packit Service |
aee942 |
*
|
|
Packit Service |
aee942 |
* The available PC/SC v2 part 10 tags are (from pcsc-lite 1.8.5):
|
|
Packit Service |
aee942 |
*
|
|
Packit Service |
aee942 |
* - \ref PCSCv2_PART10_PROPERTY_wLcdLayout
|
|
Packit Service |
aee942 |
* - \ref PCSCv2_PART10_PROPERTY_bEntryValidationCondition
|
|
Packit Service |
aee942 |
* - \ref PCSCv2_PART10_PROPERTY_bTimeOut2
|
|
Packit Service |
aee942 |
* - \ref PCSCv2_PART10_PROPERTY_wLcdMaxCharacters
|
|
Packit Service |
aee942 |
* - \ref PCSCv2_PART10_PROPERTY_wLcdMaxLines
|
|
Packit Service |
aee942 |
* - \ref PCSCv2_PART10_PROPERTY_bMinPINSize
|
|
Packit Service |
aee942 |
* - \ref PCSCv2_PART10_PROPERTY_bMaxPINSize
|
|
Packit Service |
aee942 |
* - \ref PCSCv2_PART10_PROPERTY_sFirmwareID
|
|
Packit Service |
aee942 |
* - \ref PCSCv2_PART10_PROPERTY_bPPDUSupport
|
|
Packit Service |
aee942 |
* - \ref PCSCv2_PART10_PROPERTY_dwMaxAPDUDataSize
|
|
Packit Service |
aee942 |
* - \ref PCSCv2_PART10_PROPERTY_wIdVendor
|
|
Packit Service |
aee942 |
* - \ref PCSCv2_PART10_PROPERTY_wIdProduct
|
|
Packit Service |
aee942 |
*
|
|
Packit Service |
aee942 |
* Example of code:
|
|
Packit Service |
aee942 |
* @include sample.c
|
|
Packit Service |
aee942 |
*/
|
|
Packit Service |
aee942 |
|
|
Packit Service |
aee942 |
/**
|
|
Packit Service |
aee942 |
* @brief Find an integer value by tag from TLV buffer
|
|
Packit Service |
aee942 |
* @ingroup API
|
|
Packit Service |
aee942 |
*
|
|
Packit Service |
aee942 |
* @param buffer buffer received from FEATURE_GET_TLV_PROPERTIES
|
|
Packit Service |
aee942 |
* @param length buffer length
|
|
Packit Service |
aee942 |
* @param property tag searched
|
|
Packit Service |
aee942 |
* @param[out] value value found
|
|
Packit Service |
aee942 |
* @return Error code
|
|
Packit Service |
aee942 |
*
|
|
Packit Service |
aee942 |
* @retval 0 success
|
|
Packit Service |
aee942 |
* @retval -1 not found
|
|
Packit Service |
aee942 |
* @retval -2 invalid length in the TLV
|
|
Packit Service |
aee942 |
*
|
|
Packit Service |
aee942 |
*/
|
|
Packit Service |
aee942 |
int PCSCv2Part10_find_TLV_property_by_tag_from_buffer(
|
|
Packit Service |
aee942 |
unsigned char *buffer, int length, int property, int * value);
|
|
Packit Service |
aee942 |
|
|
Packit Service |
aee942 |
/**
|
|
Packit Service |
aee942 |
* @brief Find a integer value by tag from a PC/SC card handle
|
|
Packit Service |
aee942 |
* @ingroup API
|
|
Packit Service |
aee942 |
*
|
|
Packit Service |
aee942 |
* @param hCard card handle as returned by SCardConnect()
|
|
Packit Service |
aee942 |
* @param property tag searched
|
|
Packit Service |
aee942 |
* @param[out] value value found
|
|
Packit Service |
aee942 |
* @return Error code (see PCSCv2Part10_find_TLV_property_by_tag_from_buffer())
|
|
Packit Service |
aee942 |
*/
|
|
Packit Service |
aee942 |
int PCSCv2Part10_find_TLV_property_by_tag_from_hcard(SCARDHANDLE hCard,
|
|
Packit Service |
aee942 |
int property, int * value);
|
|
Packit Service |
aee942 |
|