ccid-emulator: Build libopensc from source code
There is no longer an external (or stable) interface for libopensc. Linking this program with an existing version of libopensc that is pre-installed in the system library paths is not practical. However, a specific snapshot of the OpenSC source code is embedded here as a Git submodule (and included in the source distributions). Build libopensc from this and statically link it into this program. (Options such as '--enable-openpace' that are passed to ./configure will be forwarded to control the build configuration of libopensc.) Remove code that existed for compatibility when dynamically linking with older versions of libopensc.
This commit is contained in:
11
.travis.yml
11
.travis.yml
@@ -52,15 +52,6 @@ before_script:
|
||||
./configure --prefix=$PREFIX --enable-openssl-install --enable-python || cat config.log;
|
||||
make install;
|
||||
fi
|
||||
# ccid requires OpenSC
|
||||
- git clone https://github.com/frankmorgner/OpenSC
|
||||
- cd OpenSC && autoreconf -vsi
|
||||
- if [ -z "$HOST" ]; then
|
||||
./configure --prefix=$PREFIX --with-completiondir=/tmp || cat config.log;
|
||||
else
|
||||
./configure --prefix=$PREFIX --with-completiondir=/tmp --host=$HOST || cat config.log;
|
||||
fi
|
||||
- make install
|
||||
# Configure virtualsmartcard
|
||||
- cd $TRAVIS_BUILD_DIR/virtualsmartcard && autoreconf -vsi
|
||||
- if [ -z "$HOST" ]; then
|
||||
@@ -85,7 +76,7 @@ before_script:
|
||||
# Configure ccid
|
||||
- if [ $TRAVIS_OS_NAME == linux -a -z "$HOST" ]; then
|
||||
cd $TRAVIS_BUILD_DIR/ccid && autoreconf -vsi;
|
||||
./configure OPENSC_LIBS="-L$PREFIX/lib -lopensc" || cat config.log;
|
||||
./configure || cat config.log;
|
||||
fi
|
||||
# Optionally try to upload to Coverity Scan
|
||||
# On error (propably quota is exhausted), just continue
|
||||
|
||||
@@ -1,5 +1,28 @@
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
SUBDIRS = src doc
|
||||
SUBDIRS = . src doc
|
||||
|
||||
DIST_SUBDIRS = $(SUBDIRS) src/OpenSC
|
||||
|
||||
EXTRA_DIST = docs patches
|
||||
|
||||
all-local:
|
||||
cd src/OpenSC/src/common && $(MAKE) $(AM_MAKEFLAGS) all
|
||||
cd src/OpenSC/src/scconf && $(MAKE) $(AM_MAKEFLAGS) all
|
||||
cd src/OpenSC/src/pkcs15init && $(MAKE) $(AM_MAKEFLAGS) all
|
||||
cd src/OpenSC/src/sm && $(MAKE) $(AM_MAKEFLAGS) all
|
||||
cd src/OpenSC/src/libopensc && $(MAKE) $(AM_MAKEFLAGS) all
|
||||
|
||||
check-local:
|
||||
cd src/OpenSC/src/common && $(MAKE) $(AM_MAKEFLAGS) check
|
||||
cd src/OpenSC/src/scconf && $(MAKE) $(AM_MAKEFLAGS) check
|
||||
cd src/OpenSC/src/pkcs15init && $(MAKE) $(AM_MAKEFLAGS) check
|
||||
cd src/OpenSC/src/sm && $(MAKE) $(AM_MAKEFLAGS) check
|
||||
cd src/OpenSC/src/libopensc && $(MAKE) $(AM_MAKEFLAGS) check
|
||||
|
||||
clean-local:
|
||||
cd src/OpenSC/src/common && $(MAKE) $(AM_MAKEFLAGS) clean
|
||||
cd src/OpenSC/src/scconf && $(MAKE) $(AM_MAKEFLAGS) clean
|
||||
cd src/OpenSC/src/pkcs15init && $(MAKE) $(AM_MAKEFLAGS) clean
|
||||
cd src/OpenSC/src/sm && $(MAKE) $(AM_MAKEFLAGS) clean
|
||||
cd src/OpenSC/src/libopensc && $(MAKE) $(AM_MAKEFLAGS) clean
|
||||
|
||||
@@ -59,21 +59,6 @@ AC_TRY_LINK_FUNC(EVP_read_pw_string_min, [ AC_MSG_RESULT([yes]) ], [ AC_MSG_ERRO
|
||||
CPPFLAGS="$saved_CPPFLAGS"
|
||||
LIBS="$saved_LIBS"
|
||||
|
||||
saved_CPPFLAGS="$CPPFLAGS"
|
||||
saved_LIBS="$LIBS"
|
||||
PKG_CHECK_EXISTS([libopensc],
|
||||
[PKG_CHECK_MODULES([OPENSC], [libopensc >= 0.12.1])],
|
||||
[AC_MSG_WARN([libopensc >= 0.12.1 not found by pkg-config])])
|
||||
test -z "$OPENSC_LIBS" && OPENSC_LIBS="-lopensc $OPENSSL_LIBS"
|
||||
LIBS="$LDFLAGS $OPENSC_LIBS"
|
||||
AC_MSG_CHECKING([for sc_bytes2apdu])
|
||||
AC_TRY_LINK_FUNC(sc_bytes2apdu, [ AC_MSG_RESULT([yes]) ],
|
||||
[ AC_MSG_ERROR([libopensc >= 0.12.1 not found, use ./configure OPENSC_LIBS=...]) ])
|
||||
AC_CHECK_FUNCS([sc_apdu_set_resp sc_apdu_get_octets _sc_match_atr boxing_buf_to_pace_input])
|
||||
CPPFLAGS="$saved_CPPFLAGS"
|
||||
LIBS="$saved_LIBS"
|
||||
|
||||
|
||||
PACKAGE_SUMMARY="Emulate a USB CCID compliant smart card reader"
|
||||
AC_SUBST(PACKAGE_SUMMARY)
|
||||
|
||||
@@ -102,6 +87,8 @@ AC_CONFIG_FILES([
|
||||
doc/Makefile
|
||||
])
|
||||
|
||||
AC_CONFIG_SUBDIRS([src/OpenSC])
|
||||
|
||||
AC_OUTPUT
|
||||
|
||||
cat << EOF
|
||||
@@ -122,7 +109,6 @@ Libraries: ${LIBS}
|
||||
|
||||
PTHREAD_CFLAGS: ${PTHREAD_CFLAGS}
|
||||
PTHREAD_LIBS: ${PTHREAD_LIBS}
|
||||
OPENSC_LIBS: ${OPENSC_LIBS}
|
||||
OPENSSL_CFLAGS: ${OPENSSL_CFLAGS}
|
||||
OPENSSL_LIBS: ${OPENSSL_LIBS}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ do_subst = $(SED) \
|
||||
-e 's,[@]libdir[@],$(libdir),g' \
|
||||
-e 's,[@]includedir[@],$(includedir),g' \
|
||||
-e 's,[@]VERSION[@],$(VERSION),g' \
|
||||
-e 's,[@]OPENSC_LIBS[@],$(OPENSC_LIBS),g' \
|
||||
-e 's,[@]abs_top_srcdir[@],$(abs_top_srcdir),g' \
|
||||
-e 's,[@]top_srcdir[@],$(top_srcdir),g'
|
||||
|
||||
|
||||
@@ -265,6 +265,9 @@ modern Windows and Unix-like systems by default.
|
||||
|
||||
.. include:: autotools.txt
|
||||
|
||||
The @PACKAGE_NAME@ depends on :program:`libopensc`, which is automatically
|
||||
built from a snapshot of the OpenSC source code and then statically linked.
|
||||
|
||||
|
||||
=================
|
||||
Hints on GadgetFS
|
||||
@@ -302,33 +305,6 @@ loading the module, you maybe want to check out `this patch
|
||||
<http://comments.gmane.org/gmane.linux.usb.general/47440>`_.
|
||||
|
||||
|
||||
===============
|
||||
Hints on OpenSC
|
||||
===============
|
||||
|
||||
@PACKAGE_NAME@ needs the OpenSC components to be
|
||||
installed (especially :file:`libopensc.so`). Here is an example of how to get
|
||||
the standard installation of OpenSC without |PACE|::
|
||||
|
||||
PREFIX=/tmp/install
|
||||
VSMARTCARD=$PWD/vsmartcard
|
||||
git clone https://github.com/frankmorgner/vsmartcard.git $VSMARTCARD
|
||||
cd $VSMARTCARD
|
||||
git submodule init
|
||||
git submodule update
|
||||
cd $VSMARTCARD/ccid/src/opensc
|
||||
autoreconf --verbose --install
|
||||
./configure --prefix=$PREFIX
|
||||
make install && cd -
|
||||
|
||||
Now :file:`libopensc.so` should be located in ``$PREFIX/lib``. Here is how to
|
||||
configure the @PACKAGE_NAME@ to use it::
|
||||
|
||||
cd $VSMARTCARD/ccid
|
||||
./configure --prefix=$PREFIX OPENSC_LIBS="-L$PREFIX/lib -lopensc"
|
||||
make install && cd -
|
||||
|
||||
|
||||
*****
|
||||
Usage
|
||||
*****
|
||||
|
||||
@@ -10,13 +10,13 @@ do_subst = $(SED) \
|
||||
BUILT_SOURCES = cmdline.h cmdline.c
|
||||
|
||||
EXTRA_DIST = ccid-emulator.ggo ccid-emulator.ggo.in
|
||||
EXTRA_DIST += $(shell find $(top_srcdir)/src/OpenSC/src -path '*/.git' -prune -o -type f -a \( -name '*.h' -o -name 'apdu.c' -o -name 'card.c' \) -print)
|
||||
MAINTAINERCLEANFILES = $(BUILT_SOURCES) ccid-emulator.ggo $(dist_man1_MANS)
|
||||
|
||||
dist_man1_MANS = ccid-emulator.1
|
||||
|
||||
ccid_emulator_SOURCES = cmdline.c ccid.c usbstring.c usb.c scutil.c
|
||||
ccid_emulator_LDADD = $(OPENSC_LIBS) $(OPENSSL_LIBS) $(PTHREAD_LIBS)
|
||||
ccid_emulator_LDADD = OpenSC/src/libopensc/libopensc.la
|
||||
ccid_emulator_LDFLAGS = $(OPENSSL_LIBS) $(PTHREAD_LIBS) -static
|
||||
ccid_emulator_CFLAGS = $(OPENSSL_CFLAGS) $(PTHREAD_CFLAGS) -I$(top_srcdir)/src/OpenSC/src
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ bin_PROGRAMS = ccid-emulator
|
||||
|
||||
noinst_HEADERS = \
|
||||
ccid.h \
|
||||
ccid-types.h \
|
||||
cmdline.h \
|
||||
scutil.h \
|
||||
usbstring.h
|
||||
|
||||
@@ -1,276 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2009 Frank Morgner
|
||||
*
|
||||
* This file is part of ccid.
|
||||
*
|
||||
* ccid is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* ccid 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 General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* ccid. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
#ifndef _CCID_TYPES_H
|
||||
#define _CCID_TYPES_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define USB_REQ_CCID 0xA1
|
||||
|
||||
#define CCID_CONTROL_ABORT 0x01
|
||||
#define CCID_CONTROL_GET_CLOCK_FREQUENCIES 0x02
|
||||
#define CCID_CONTROL_GET_DATA_RATES 0x03
|
||||
|
||||
#define CCID_OPERATION_VERIFY 0x00;
|
||||
#define CCID_OPERATION_MODIFY 0x01;
|
||||
#define CCID_ENTRY_VALIDATE 0x02
|
||||
|
||||
#define CCID_BERROR_CMD_ABORTED 0xff /** Host aborted the current activity */
|
||||
#define CCID_BERROR_ICC_MUTE 0xfe /** CCID timed out while talking to the ICC */
|
||||
#define CCID_BERROR_XFR_PARITY_ERROR 0xfd /** Parity error while talking to the ICC */
|
||||
#define CCID_BERROR_XFR_OVERRUN 0xfc /** Overrun error while talking to the ICC */
|
||||
#define CCID_BERROR_HW_ERROR 0xfb /** An all inclusive hardware error occurred */
|
||||
#define CCID_BERROR_BAD_ATR_TS 0xf
|
||||
#define CCID_BERROR_BAD_ATR_TCK 0xf
|
||||
#define CCID_BERROR_ICC_PROTOCOL_NOT_SUPPORTED 0xf6
|
||||
#define CCID_BERROR_ICC_CLASS_NOT_SUPPORTED 0xf5
|
||||
#define CCID_BERROR_PROCEDURE_BYTE_CONFLICT 0xf4
|
||||
#define CCID_BERROR_DEACTIVATED_PROTOCOL 0xf3
|
||||
#define CCID_BERROR_BUSY_WITH_AUTO_SEQUENCE 0xf2 /** Automatic Sequence Ongoing */
|
||||
#define CCID_BERROR_PIN_TIMEOUT 0xf0
|
||||
#define CCID_BERROR_PIN_CANCELLED 0xef
|
||||
#define CCID_BERROR_CMD_SLOT_BUSY 0xe0 /** A second command was sent to a slot which was already processing a command. */
|
||||
#define CCID_BERROR_CMD_NOT_SUPPORTED 0x00
|
||||
#define CCID_BERROR_OK 0x00
|
||||
|
||||
#define CCID_BSTATUS_OK_ACTIVE 0x00 /** No error. An ICC is present and active */
|
||||
#define CCID_BSTATUS_OK_INACTIVE 0x01 /** No error. ICC is present and inactive */
|
||||
#define CCID_BSTATUS_OK_NOICC 0x02 /** No error. No ICC is present */
|
||||
#define CCID_BSTATUS_ERROR_ACTIVE 0x40 /** Failed. An ICC is present and active */
|
||||
#define CCID_BSTATUS_ERROR_INACTIVE 0x41 /** Failed. ICC is present and inactive */
|
||||
#define CCID_BSTATUS_ERROR_NOICC 0x42 /** Failed. No ICC is present */
|
||||
|
||||
#define CCID_WLEVEL_DIRECT __constant_cpu_to_le16(0) /** APDU begins and ends with this command */
|
||||
#define CCID_WLEVEL_CHAIN_NEXT_XFRBLOCK __constant_cpu_to_le16(1) /** APDU begins with this command, and continue in the next PC_to_RDR_XfrBlock */
|
||||
#define CCID_WLEVEL_CHAIN_END __constant_cpu_to_le16(2) /** abData field continues a command APDU and ends the APDU command */
|
||||
#define CCID_WLEVEL_CHAIN_CONTINUE __constant_cpu_to_le16(3) /** abData field continues a command APDU and another block is to follow */
|
||||
#define CCID_WLEVEL_RESPONSE_IN_DATABLOCK __constant_cpu_to_le16(0x10) /** empty abData field, continuation of response APDU is expected in the next RDR_to_PC_DataBlock */
|
||||
|
||||
#define CCID_PIN_ENCODING_BIN 0x00
|
||||
#define CCID_PIN_ENCODING_BCD 0x01
|
||||
#define CCID_PIN_ENCODING_ASCII 0x02
|
||||
#define CCID_PIN_UNITS_BYTES 0x80
|
||||
#define CCID_PIN_JUSTIFY_RIGHT 0x04
|
||||
#define CCID_PIN_CONFIRM_NEW 0x01
|
||||
#define CCID_PIN_INSERT_OLD 0x02
|
||||
#define CCID_PIN_NO_MSG 0x00
|
||||
#define CCID_PIN_MSG1 0x01
|
||||
#define CCID_PIN_MSG2 0x02
|
||||
#define CCID_PIN_MSG_REF 0x03
|
||||
#define CCID_PIN_MSG_DEFAULT 0xff
|
||||
|
||||
#define CCID_SLOTS_UNCHANGED 0x00
|
||||
#define CCID_SLOT1_CARD_PRESENT 0x01
|
||||
#define CCID_SLOT1_CHANGED 0x02
|
||||
#define CCID_SLOT2_CARD_PRESENT 0x04
|
||||
#define CCID_SLOT2_CHANGED 0x08
|
||||
#define CCID_SLOT3_CARD_PRESENT 0x10
|
||||
#define CCID_SLOT3_CHANGED 0x20
|
||||
#define CCID_SLOT4_CARD_PRESENT 0x40
|
||||
#define CCID_SLOT4_CHANGED 0x80
|
||||
|
||||
#define CCID_EXT_APDU_MAX (4 + 3 + 0xffff + 3)
|
||||
#define CCID_SHORT_APDU_MAX (4 + 1 + 0xff + 1)
|
||||
|
||||
struct ccid_class_descriptor {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint16_t bcdCCID;
|
||||
uint8_t bMaxSlotIndex;
|
||||
uint8_t bVoltageSupport;
|
||||
uint32_t dwProtocols;
|
||||
uint32_t dwDefaultClock;
|
||||
uint32_t dwMaximumClock;
|
||||
uint8_t bNumClockSupport;
|
||||
uint32_t dwDataRate;
|
||||
uint32_t dwMaxDataRate;
|
||||
uint8_t bNumDataRatesSupported;
|
||||
uint32_t dwMaxIFSD;
|
||||
uint32_t dwSynchProtocols;
|
||||
uint32_t dwMechanical;
|
||||
uint32_t dwFeatures;
|
||||
uint32_t dwMaxCCIDMessageLength;
|
||||
uint8_t bClassGetResponse;
|
||||
uint8_t bclassEnvelope;
|
||||
uint16_t wLcdLayout;
|
||||
uint8_t bPINSupport;
|
||||
uint8_t bMaxCCIDBusySlots;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
typedef struct {
|
||||
uint8_t bmFindexDindex;
|
||||
uint8_t bmTCCKST0;
|
||||
uint8_t bGuardTimeT0;
|
||||
uint8_t bWaitingIntegerT0;
|
||||
uint8_t bClockStop;
|
||||
} __attribute__ ((packed)) abProtocolDataStructure_T0_t;
|
||||
typedef struct {
|
||||
uint8_t bmFindexDindex;
|
||||
uint8_t bmTCCKST1;
|
||||
uint8_t bGuardTimeT1;
|
||||
uint8_t bWaitingIntegersT1;
|
||||
uint8_t bClockStop;
|
||||
uint8_t bIFSC;
|
||||
uint8_t bNadValue;
|
||||
} __attribute__ ((packed)) abProtocolDataStructure_T1_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t bTimeOut;
|
||||
uint8_t bmFormatString;
|
||||
uint8_t bmPINBlockString;
|
||||
uint8_t bmPINLengthFormat;
|
||||
uint16_t wPINMaxExtraDigit;
|
||||
uint8_t bEntryValidationCondition;
|
||||
uint8_t bNumberMessage;
|
||||
uint16_t wLangId;
|
||||
uint8_t bMsgIndex;
|
||||
uint8_t bTeoPrologue1;
|
||||
uint16_t bTeoPrologue2;
|
||||
} __attribute__ ((packed)) abPINDataStucture_Verification_t;
|
||||
typedef struct {
|
||||
uint8_t bTimeOut;
|
||||
uint8_t bmFormatString;
|
||||
uint8_t bmPINBlockString;
|
||||
uint8_t bmPINLengthFormat;
|
||||
uint8_t bInsertionOffsetOld;
|
||||
uint8_t bInsertionOffsetNew;
|
||||
uint16_t wPINMaxExtraDigit;
|
||||
uint8_t bConfirmPIN;
|
||||
uint8_t bEntryValidationCondition;
|
||||
uint8_t bNumberMessage;
|
||||
uint16_t wLangId;
|
||||
uint8_t bMsgIndex1;
|
||||
} __attribute__ ((packed)) abPINDataStucture_Modification_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t bMessageType;
|
||||
uint32_t dwLength;
|
||||
uint8_t bSlot;
|
||||
uint8_t bSeq;
|
||||
uint8_t bBWI;
|
||||
uint16_t wLevelParameter;
|
||||
} __attribute__ ((packed)) PC_to_RDR_XfrBlock_t;
|
||||
typedef struct {
|
||||
uint8_t bMessageType;
|
||||
uint32_t dwLength;
|
||||
uint8_t bSlot;
|
||||
uint8_t bSeq;
|
||||
uint8_t abRFU1;
|
||||
uint16_t abRFU2;
|
||||
} __attribute__ ((packed)) PC_to_RDR_IccPowerOff_t;
|
||||
typedef struct {
|
||||
uint8_t bMessageType;
|
||||
uint32_t dwLength;
|
||||
uint8_t bSlot;
|
||||
uint8_t bSeq;
|
||||
uint8_t abRFU1;
|
||||
uint16_t abRFU2;
|
||||
} __attribute__ ((packed)) PC_to_RDR_GetSlotStatus_t;
|
||||
typedef struct {
|
||||
uint8_t bMessageType;
|
||||
uint32_t dwLength;
|
||||
uint8_t bSlot;
|
||||
uint8_t bSeq;
|
||||
uint8_t abRFU1;
|
||||
uint16_t abRFU2;
|
||||
} __attribute__ ((packed)) PC_to_RDR_GetParameters_t;
|
||||
typedef struct {
|
||||
uint8_t bMessageType;
|
||||
uint32_t dwLength;
|
||||
uint8_t bSlot;
|
||||
uint8_t bSeq;
|
||||
uint8_t abRFU1;
|
||||
uint16_t abRFU2;
|
||||
} __attribute__ ((packed)) PC_to_RDR_ResetParameters_t;
|
||||
typedef struct {
|
||||
uint8_t bMessageType;
|
||||
uint32_t dwLength;
|
||||
uint8_t bSlot;
|
||||
uint8_t bSeq;
|
||||
uint8_t bProtocolNum;
|
||||
uint16_t abRFU;
|
||||
} __attribute__ ((packed)) PC_to_RDR_SetParameters_t;
|
||||
typedef struct {
|
||||
uint8_t bMessageType;
|
||||
uint32_t dwLength;
|
||||
uint8_t bSlot;
|
||||
uint8_t bSeq;
|
||||
uint8_t bBWI;
|
||||
uint16_t wLevelParameter;
|
||||
} __attribute__ ((packed)) PC_to_RDR_Secure_t;
|
||||
typedef struct {
|
||||
uint8_t bMessageType;
|
||||
uint32_t dwLength;
|
||||
uint8_t bSlot;
|
||||
uint8_t bSeq;
|
||||
uint8_t bPowerSelect;
|
||||
uint16_t abRFU;
|
||||
} __attribute__ ((packed)) PC_to_RDR_IccPowerOn_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t bMessageType;
|
||||
uint32_t dwLength;
|
||||
uint8_t bSlot;
|
||||
uint8_t bSeq;
|
||||
uint8_t bStatus;
|
||||
uint8_t bError;
|
||||
uint8_t bClockStatus;
|
||||
} __attribute__ ((packed)) RDR_to_PC_SlotStatus_t;
|
||||
typedef struct {
|
||||
uint8_t bMessageType;
|
||||
uint32_t dwLength;
|
||||
uint8_t bSlot;
|
||||
uint8_t bSeq;
|
||||
uint8_t bStatus;
|
||||
uint8_t bError;
|
||||
uint8_t bChainParameter;
|
||||
} __attribute__ ((packed)) RDR_to_PC_DataBlock_t;
|
||||
typedef struct {
|
||||
uint8_t bMessageType;
|
||||
uint32_t dwLength;
|
||||
uint8_t bSlot;
|
||||
uint8_t bSeq;
|
||||
uint8_t bStatus;
|
||||
uint8_t bError;
|
||||
uint8_t bProtocolNum;
|
||||
} __attribute__ ((packed)) RDR_to_PC_Parameters_t;
|
||||
typedef struct {
|
||||
uint8_t bMessageType;
|
||||
uint8_t bmSlotICCState; /* we support 1 slots, so we need 2*1 bits = 1 byte */
|
||||
} __attribute__ ((packed)) RDR_to_PC_NotifySlotChange_t;
|
||||
|
||||
struct hid_class_descriptor {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint16_t bcdHID;
|
||||
uint32_t bCountryCode;
|
||||
uint8_t bNumDescriptors;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -34,10 +34,6 @@
|
||||
#include "config.h"
|
||||
#include "scutil.h"
|
||||
|
||||
#ifndef HAVE_BOXING_BUF_TO_PACE_INPUT
|
||||
#include <libopensc/reader-boxing.c>
|
||||
#endif
|
||||
|
||||
static sc_context_t *ctx = NULL;
|
||||
static sc_card_t *card = NULL;
|
||||
static sc_reader_t *reader = NULL;
|
||||
@@ -464,11 +460,6 @@ perform_PC_to_RDR_IccPowerOn(const __u8 *in, size_t inlen, __u8 **out, size_t *o
|
||||
}
|
||||
|
||||
if (sc_result >= 0) {
|
||||
#ifdef WITH_PACE
|
||||
#ifndef DISABLE_GLOBAL_BOXING_INITIALIZATION
|
||||
sc_initialize_boxing_cmds(ctx);
|
||||
#endif
|
||||
#endif
|
||||
return get_RDR_to_PC_SlotStatus(request->bSeq,
|
||||
sc_result, out, outlen, card->atr.value, card->atr.len);
|
||||
} else {
|
||||
|
||||
@@ -23,8 +23,7 @@
|
||||
#define _CCID_H
|
||||
|
||||
#include <linux/usb/ch9.h>
|
||||
#include <libopensc/opensc.h>
|
||||
#include "ccid-types.h"
|
||||
#include <libopensc/ccid-types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -20,29 +20,7 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "libopensc/internal.h"
|
||||
|
||||
#ifndef HAVE__SC_MATCH_ATR
|
||||
int sc_dlclose(void *handle) {}
|
||||
const char *sc_dlerror() {}
|
||||
void *sc_dlsym(void *handle, const char *symbol) {}
|
||||
size_t strlcpy(char *dst, const char *src, size_t siz) {}
|
||||
int sc_mutex_create(const sc_context_t *ctx, void **mutex) {}
|
||||
int sc_mutex_destroy(const sc_context_t *ctx, void *mutex) {}
|
||||
int _sc_parse_atr(sc_reader_t *reader) {}
|
||||
void *sc_dlopen(const char *filename) {}
|
||||
int sc_mutex_lock(const sc_context_t *ctx, void *mutex) {}
|
||||
int sc_mutex_unlock(const sc_context_t *ctx, void *mutex) {}
|
||||
#include "libopensc/card.c"
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_SC_APDU_GET_OCTETS) || !defined(HAVE_SC_APDU_SET_RESP)
|
||||
#ifdef HAVE__SC_MATCH_ATR
|
||||
size_t sc_get_max_send_size(const sc_card_t *card) {return 0;}
|
||||
#endif
|
||||
#include "libopensc/apdu.c"
|
||||
#endif
|
||||
|
||||
#include <libopensc/internal.h>
|
||||
#include <libopensc/log.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -88,38 +88,5 @@ void _bin_log(sc_context_t *ctx, int type, const char *file, int line,
|
||||
*/
|
||||
int print_avail(int verbose);
|
||||
|
||||
/*
|
||||
* OPENSC functions that do not get exported (sometimes)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the encoded APDU in newly created buffer.
|
||||
* @param ctx sc_context_t object
|
||||
* @param apdu sc_apdu_t object with the APDU to encode
|
||||
* @param buf pointer to the newly allocated buffer
|
||||
* @param len length of the encoded APDU
|
||||
* @param proto protocol to be used
|
||||
* @return SC_SUCCESS on success and an error code otherwise
|
||||
*/
|
||||
int sc_apdu_get_octets(sc_context_t *ctx, const sc_apdu_t *apdu, u8 **buf,
|
||||
size_t *len, unsigned int proto);
|
||||
|
||||
/**
|
||||
* Sets the status bytes and return data in the APDU
|
||||
* @param ctx sc_context_t object
|
||||
* @param apdu the apdu to which the data should be written
|
||||
* @param buf returned data
|
||||
* @param len length of the returned data
|
||||
* @return SC_SUCCESS on success and an error code otherwise
|
||||
*/
|
||||
int sc_apdu_set_resp(sc_context_t *ctx, sc_apdu_t *apdu, const u8 *buf,
|
||||
size_t len);
|
||||
|
||||
/* Returns an index number if a match was found, -1 otherwise. table has to
|
||||
* be null terminated. */
|
||||
int _sc_match_atr(struct sc_card *card, struct sc_atr_table *table, int *type_out);
|
||||
|
||||
int fread_to_eof(const char *file, unsigned char **buf, size_t *buflen);
|
||||
|
||||
#endif
|
||||
/* @} */
|
||||
|
||||
@@ -18,6 +18,7 @@ os.system("make doc -C virtualsmartcard")
|
||||
os.system("make doc -C ccid")
|
||||
os.system("make doc -C pcsc-relay")
|
||||
|
||||
os.environ['PATH'] = os.path.abspath('../ccid/src') + os.pathsep + os.environ['PATH']
|
||||
os.environ['PATH'] = os.path.abspath('../pcsc-relay/src') + os.pathsep + os.environ['PATH']
|
||||
os.environ['PATH'] = os.path.abspath('../virtualsmartcard/src/vpicc') + os.pathsep + os.environ['PATH']
|
||||
|
||||
|
||||
@@ -265,6 +265,9 @@ modern Windows and Unix-like systems by default.
|
||||
|
||||
.. include:: autotools.txt
|
||||
|
||||
The USB CCID Emulator depends on :program:`libopensc`, which is automatically
|
||||
built from a snapshot of the OpenSC source code and then statically linked.
|
||||
|
||||
|
||||
=================
|
||||
Hints on GadgetFS
|
||||
@@ -302,33 +305,6 @@ loading the module, you maybe want to check out `this patch
|
||||
<http://comments.gmane.org/gmane.linux.usb.general/47440>`_.
|
||||
|
||||
|
||||
===============
|
||||
Hints on OpenSC
|
||||
===============
|
||||
|
||||
USB CCID Emulator needs the OpenSC components to be
|
||||
installed (especially :file:`libopensc.so`). Here is an example of how to get
|
||||
the standard installation of OpenSC without |PACE|::
|
||||
|
||||
PREFIX=/tmp/install
|
||||
VSMARTCARD=$PWD/vsmartcard
|
||||
git clone https://github.com/frankmorgner/vsmartcard.git $VSMARTCARD
|
||||
cd $VSMARTCARD
|
||||
git submodule init
|
||||
git submodule update
|
||||
cd $VSMARTCARD/ccid/src/opensc
|
||||
autoreconf --verbose --install
|
||||
./configure --prefix=$PREFIX
|
||||
make install && cd -
|
||||
|
||||
Now :file:`libopensc.so` should be located in ``$PREFIX/lib``. Here is how to
|
||||
configure the USB CCID Emulator to use it::
|
||||
|
||||
cd $VSMARTCARD/ccid
|
||||
./configure --prefix=$PREFIX OPENSC_LIBS="-L$PREFIX/lib -lopensc"
|
||||
make install && cd -
|
||||
|
||||
|
||||
*****
|
||||
Usage
|
||||
*****
|
||||
|
||||
@@ -109,7 +109,6 @@
|
||||
<li><a class="reference internal" href="#installation">Installation</a><ul>
|
||||
<li><a class="reference internal" href="#installation-on-linux-unix-and-similar">Installation on Linux, Unix and similar</a></li>
|
||||
<li><a class="reference internal" href="#hints-on-gadgetfs">Hints on GadgetFS</a></li>
|
||||
<li><a class="reference internal" href="#hints-on-opensc">Hints on OpenSC</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference internal" href="#usage">Usage</a></li>
|
||||
@@ -491,6 +490,8 @@ make
|
||||
make install
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>The USB CCID Emulator depends on <strong class="program">libopensc</strong>, which is automatically
|
||||
built from a snapshot of the OpenSC source code and then statically linked.</p>
|
||||
</div>
|
||||
<div class="section" id="hints-on-gadgetfs">
|
||||
<h3>Hints on GadgetFS<a class="headerlink" href="#hints-on-gadgetfs" title="Permalink to this headline">¶</a></h3>
|
||||
@@ -522,31 +523,6 @@ patch is needed</a>.</p>
|
||||
<p>If you are using a more recent version of <strong class="program">dummy_hcd</strong> and get an error
|
||||
loading the module, you maybe want to check out <a class="reference external" href="http://comments.gmane.org/gmane.linux.usb.general/47440">this patch</a>.</p>
|
||||
</div>
|
||||
<div class="section" id="hints-on-opensc">
|
||||
<h3>Hints on OpenSC<a class="headerlink" href="#hints-on-opensc" title="Permalink to this headline">¶</a></h3>
|
||||
<p>USB CCID Emulator needs the OpenSC components to be
|
||||
installed (especially <tt class="file docutils literal"><span class="pre">libopensc.so</span></tt>). Here is an example of how to get
|
||||
the standard installation of OpenSC without <abbr title="Password Authenticated Connection Establishment">PACE</abbr>:</p>
|
||||
<div class="highlight-sh"><div class="highlight"><pre><span class="nv">PREFIX</span><span class="o">=</span>/tmp/install
|
||||
<span class="nv">VSMARTCARD</span><span class="o">=</span><span class="nv">$PWD</span>/vsmartcard
|
||||
git clone https://github.com/frankmorgner/vsmartcard.git <span class="nv">$VSMARTCARD</span>
|
||||
<span class="nb">cd</span> <span class="nv">$VSMARTCARD</span>
|
||||
git submodule init
|
||||
git submodule update
|
||||
<span class="nb">cd</span> <span class="nv">$VSMARTCARD</span>/ccid/src/opensc
|
||||
autoreconf --verbose --install
|
||||
./configure --prefix<span class="o">=</span><span class="nv">$PREFIX</span>
|
||||
make install <span class="o">&&</span> <span class="nb">cd</span> -
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Now <tt class="file docutils literal"><span class="pre">libopensc.so</span></tt> should be located in <tt class="docutils literal"><span class="pre">$PREFIX/lib</span></tt>. Here is how to
|
||||
configure the USB CCID Emulator to use it:</p>
|
||||
<div class="highlight-sh"><div class="highlight"><pre><span class="nb">cd</span> <span class="nv">$VSMARTCARD</span>/ccid
|
||||
./configure --prefix<span class="o">=</span><span class="nv">$PREFIX</span> <span class="nv">OPENSC_LIBS</span><span class="o">=</span><span class="s2">"-L</span><span class="nv">$PREFIX</span><span class="s2">/lib -lopensc"</span>
|
||||
make install <span class="o">&&</span> <span class="nb">cd</span> -
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="usage">
|
||||
<h2>Usage<a class="headerlink" href="#usage" title="Permalink to this headline">¶</a></h2>
|
||||
|
||||
@@ -13,7 +13,6 @@ do_subst = $(SED) \
|
||||
-e 's,[@]libdir[@],$(libdir),g' \
|
||||
-e 's,[@]includedir[@],$(includedir),g' \
|
||||
-e 's,[@]VERSION[@],$(VERSION),g' \
|
||||
-e 's,[@]OPENSC_LIBS[@],$(OPENSC_LIBS),g' \
|
||||
-e 's,[@]abs_top_srcdir[@],$(abs_top_srcdir),g' \
|
||||
-e 's,[@]top_srcdir[@],$(top_srcdir),g'
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ do_subst = $(SED) \
|
||||
-e 's,[@]libdir[@],$(libdir),g' \
|
||||
-e 's,[@]includedir[@],$(includedir),g' \
|
||||
-e 's,[@]VERSION[@],$(VERSION),g' \
|
||||
-e 's,[@]OPENSC_LIBS[@],$(OPENSC_LIBS),g' \
|
||||
-e 's,[@]abs_top_srcdir[@],$(abs_top_srcdir),g' \
|
||||
-e 's,[@]top_srcdir[@],$(top_srcdir),g'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user