Virtual Smart Card Architecture

repository·master·Indexed 21 days ago

https://github.com/frankmorgner/vsmartcard

An umbrella project for emulating smart cards and readers across various platforms. It includes the Android and Tizen Smart Card Emulators for contactless emulation via HCE, the Virtual Smart Card (vpicc/vpcd) for PC/SC API access, PC/SC Relay for communication relaying, and a USB CCID Emulator for forwarding local PC/SC readers as standard USB CCID devices. Supported card types include generic ISO-7816, German electronic identity cards (nPA), and electronic passports.

Tokens
24K
Snippets
71
Records
127
Agent score
74%

What's inside vsmartcard

  1. Overview of the Tizen Smart Card Emulator

    master

    The Tizen Smart Card Emulator enables the emulation of a contactless smart card. It functions by using Tizen's Host Card Emulation (HCE) to intercept APDUs (Application Protocol Data Units) from a contactless reader.

    Workflow Architecture:

    1. Tizen Service: A headless Tizen service receives Command APDUs via HCE.
    2. Delegation: The service delegates these commands to the Android Smart Card Emulator using Samsung's Accessory Protocol.
    3. Android App: The Android application processes the received commands and generates responses.
    4. Response Loop: The responses are sent back to the contactless reader through the Tizen Smart Card Emulator.
  2. Overview of Virtual Smart Card Architecture

    master
    Virtual Smart Card Architecture is an umbrella project providing various tools for emulating smart card readers and smart cards. It includes specialized projects for different emulation needs, such as remote readers, Android emulators, and USB CCID emulators.
  3. Overview of Virtual Smart Card emulation

    master

    Virtual Smart Card emulates physical smart cards and makes them accessible via the PC/SC API. It uses the vpcd driver to interface with PCSC-Lite and the Windows smart card service, allowing standard smart card applications to interact with virtual cards (vpicc) as if they were physical hardware.

    Supported smart card types include:

    • Generic ISO-7816 smart card: Includes support for secure messaging.
    • German electronic identity card (nPA): Complete support for EAC (PACE, TA, CA).
    • Electronic passport (ePass/MRTD): Support for BAC.
    • Cryptoflex smart card: (Incomplete support).
  4. Overview of the USB CCID Emulator

    master

    The USB CCID Emulator forwards a locally present PC/SC smart card reader as a standard USB CCID reader. It acts as a trusted intermediary, enabling secure PIN entry and PIN modification.

    Key Capabilities:

    • Forwarding: If the machine running ccid-emulator is in USB device mode, a local reader is forwarded via USB to another machine. If in USB host mode, the USB CCID reader is locally present.
    • Security: Supports secure PIN entry and PIN modification. In combination with OpenSC, it can perform PACE (Password Authenticated Connection Establishment).
    • Compatibility: Applications on Windows and Unix-like systems can access the emulator through PC/SC as if it were a real smart card reader. No special smart card driver installation is required on the host as modern OSs include USB CCID drivers.
  5. Overview of Virtual Smart Card Architecture

    master

    Virtual Smart Card consists of two main components:

    1. vpicc (virtual smart card): A Python-based smart card emulator. It supports various card types including Generic ISO-7816, German electronic identity cards (nPA) with EAC support, Electronic passports (ePass/MRTD) with BAC support, and Cryptoflex cards.
    2. vpcd (virtual smart card reader): A driver that makes the emulated card accessible via the standard PC/SC API.

    By default, vpcd opens sockets on localhost (ports 35963 and 35964) to communicate with vpicc. Because they communicate over sockets, vpicc does not need to run on the same machine as vpcd and can be connected over a network.

    Supported Card Types:

    • Generic ISO-7816: Includes secure messaging.
    • German nPA: Full support for EAC (PACE, TA, CA).
    • Electronic passport (ePass/MRTD): Support for BAC.
    • Cryptoflex: Incomplete support.
  6. Overview of the Android Smart Card Emulator

    master

    The Android Smart Card Emulator enables the emulation of a contactless smart card using Android's Host Card Emulation (HCE) technology. It allows an Android device to fetch APDUs (Application Protocol Data Units) from a contactless reader.

    There are two primary ways the emulator processes Command APDUs:

    1. Remote Delegation: Commands are sent to a remote virtual smart card.
    2. Built-in Simulation: Commands are processed by an integrated Java Card simulator using the jCardSim runtime.
  7. Overview of Tizen Smart Card Emulator

    master

    The Tizen Smart Card Emulator enables a Tizen smartwatch (such as a Samsung Gear S2) to act as a contact-less smart card.

    It works by using Tizen's Host Card Emulation (HCE) to intercept APDUs from a contact-less reader. The architecture follows this flow:

    1. The Contact-less Reader sends commands.
    2. The Tizen HCE fetches these APDUs.
    3. A headless Tizen service delegates the Command APDUs via the Samsung Accessory Protocol to the acardemulator.
    4. The Android app processes the commands and sends responses back through the Tizen service to the reader.

    Developers can also attach their own custom simulations by using the Samsung Accessory Protocol to communicate directly with the Tizen service.

  8. Supported Emulators and Connectors in PC/SC Relay

    master

    PC/SC Relay supports several types of contactless emulators and target connectors:

    Supported Emulators (Contactless Interfaces)

    • Hardware supported by libnfc
    • OpenPICC
    • Android Smart Card Emulator

    Supported Connectors (Targets)

    • Real Smart Cards: A physical card inserted into a system's smart card reader. The reader must be accessible via PC/SC. The card itself can be contact-based or contactless.
    • Virtual Smart Cards: A virtual smart card that connects directly to pcsc-relay using its native interface. In this mode, pcsc-relay does not require PC/SC access.
  9. How PC/SC Relay works

    master

    PC/SC Relay is a tool designed to relay smart card communication over a contactless interface. It acts as a bridge between an Emulator and a Connector.

    1. Emulator: Receives Command APDUs from a terminal via a contactless interface (e.g., NFC hardware, Android device, or virtual emulator) and sends them to pcsc-relay.
    2. pcsc-relay: Receives the Command APDU from the emulator and forwards it to the connector.
    3. Connector: Processes the command (e.g., by sending it to a real smart card or a virtual smart card) and returns a Response APDU to pcsc-relay.
    4. pcsc-relay: Receives the Response APDU from the connector and sends it back to the emulator to be transmitted to the terminal.

    This allows for relaying smart cards over long distances or emulating ISO/IEC 14443 smart cards using the vicc virtual smart card.

  10. How the Tizen Smart Card Emulator works

    master

    The Tizen Smart Card Emulator enables a Tizen smartwatch (such as a Samsung Gear S2) to act as a contactless smart card using Host Card Emulation (HCE).

    Workflow:

    1. A Contact-less Reader sends APDUs to the smartwatch.
    2. The Tizen HCE layer on the watch fetches these APDUs.
    3. A headless Tizen service receives the APDUs and delegates them via the Samsung Accessory Protocol to the acardemulator.
    4. The Android app (ACardEmulator) processes the commands and sends the responses back to the reader through the Tizen service.

    Developers can also attach their own custom simulations by implementing the Samsung Accessory Protocol to communicate directly with the Tizen service.

  11. Available emulation projects in Virtual Smart Card Architecture

    master

    The architecture consists of several distinct projects depending on your emulation requirements:

    • Virtual Smart Card: Emulation of smart cards.
    • Remote Smart Card Reader: Emulation of smart card readers remotely.
    • Android Smart Card Emulator: Emulation of smart cards on Android devices.
    • PC/SC Relay: Relaying PC/SC (Personal Computer/Smart Card) communications.
    • USB CCID Emulator: Emulation of USB CCID (Chip Card Interface Device) readers.