Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Latest commit

 

History

History
51 lines (31 loc) · 1.7 KB

README.md

File metadata and controls

51 lines (31 loc) · 1.7 KB

libpcsc-cpp

European Regional Development Fund

NB! Please note that the libpcsc-cpp code was moved to libelectronic-id repository.
We won't be accepting pull requests or responding to issues in this repository anymore. We are happy to accept your proposals in the libelectronic-id repository: https://github.com/web-eid/libelectronic-id.

C++ library for accessing smart cards using the PC/SC API.

Usage

Example how to list available readers, connect to the smart card in first reader and transmit an APDU:

auto readers = listReaders();
auto card = readers[0].connectToCard();
auto command = CommandApdu::fromBytes({0x2, 0x1, 0x3, 0x4});

auto transactionGuard = card->beginTransaction();
auto response = card->transmit(command);

See more examples in tests.

Building

In Ubuntu:

apt install build-essential pkg-config cmake libgtest-dev valgrind libpcsclite-dev
sudo bash -c 'cd /usr/src/googletest && cmake . && cmake --build . --target install'

cd build
cmake .. # optionally with -DCMAKE_BUILD_TYPE=Debug
cmake --build . # optionally with VERBOSE=1

Testing

Build as described above, then, inside the build directory, run:

ctest # or 'valgrind --leak-check=full ctest'

ctest runs tests that use the libscard-mock library to mock PC/SC API calls.

There are also integration tests that use the real operating system PC/SC service, run them inside build directory with:

./libpcsc-cpp-test-integration

Development guidelines