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.
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.
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
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
- Format code with
scripts/clang-format.sh
before committing - See docs/DEVELOPMENT.md