Files
2021-04-28 02:13:40 +02:00
..
2021-04-28 02:13:40 +02:00

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>PC/SC Relay &#8212; vsmartcard 2021-04-28 documentation</title>
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <link rel="stylesheet" href="../_static/bootstrap-sphinx.css" type="text/css" />
    <link rel="stylesheet" type="text/css" href="../_static/graphviz.css" />
    <script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script src="../_static/jquery.js"></script>
    <script src="../_static/underscore.js"></script>
    <script src="../_static/doctools.js"></script>
    <script src="../_static/js/jquery-1.11.0.min.js"></script>
    <script src="../_static/js/jquery-fix.js"></script>
    <script src="../_static/bootstrap-3.3.7/js/bootstrap.min.js"></script>
    <script src="../_static/bootstrap-sphinx.js"></script>
    <link rel="shortcut icon" href="../_static/chip.ico"/>
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="USB CCID Emulator" href="../ccid/README.html" />
    <link rel="prev" title="Tizen Smart Card Emulator" href="../TCardEmulator/README.html" />
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1'>
<meta name="apple-mobile-web-app-capable" content="yes">

  </head><body>
  
  <a href="https://github.com/frankmorgner/vsmartcard"
     class="visible-desktop hidden-xs"><img
    id="gh-banner"
    style="position: absolute; top: 50px; right: 0; border: 0;"
    src="https://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png"
    alt="Fork me on GitHub"></a>
  <script>
    // Adjust banner height.
    $(function () {
      var navHeight = $(".navbar .container").css("height");
      $("#gh-banner").css("top", navHeight);
    });
  </script>


  <div id="navbar" class="navbar navbar-default ">
    <div class="container">
      <div class="navbar-header">
        <!-- .btn-navbar is used as the toggle for collapsed navbar content -->
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="../index.html">
          vsmartcard</a>
        <span class="navbar-text navbar-version pull-left"><b></b></span>
      </div>

        <div class="collapse navbar-collapse nav-collapse">
          <ul class="nav navbar-nav">
            
            
              <li class="dropdown globaltoc-container">
  <a role="button"
     id="dLabelGlobalToc"
     data-toggle="dropdown"
     data-target="#"
     href="../index.html">Site <b class="caret"></b></a>
  <ul class="dropdown-menu globaltoc"
      role="menu"
      aria-labelledby="dLabelGlobalToc"><ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../virtualsmartcard/README.html">Virtual Smart Card</a></li>
<li class="toctree-l1"><a class="reference internal" href="../remote-reader/README.html">Remote Smart Card Reader</a></li>
<li class="toctree-l1"><a class="reference internal" href="../ACardEmulator/README.html">Android Smart Card Emulator</a></li>
<li class="toctree-l1"><a class="reference internal" href="../TCardEmulator/README.html">Tizen Smart Card Emulator</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">PC/SC Relay</a></li>
<li class="toctree-l1"><a class="reference internal" href="../ccid/README.html">USB CCID Emulator</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../virtualsmartcard/api.html">Creating a Virtual Smart Card</a></li>
</ul>
</ul>
</li>
              
                <li class="dropdown">
  <a role="button"
     id="dLabelLocalToc"
     data-toggle="dropdown"
     data-target="#"
     href="#">Page <b class="caret"></b></a>
  <ul class="dropdown-menu localtoc"
      role="menu"
      aria-labelledby="dLabelLocalToc"><ul>
<li><a class="reference internal" href="#">PC/SC Relay</a><ul>
<li><a class="reference internal" href="#download">Download</a></li>
<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-libnfc">Hints on libnfc</a></li>
<li><a class="reference internal" href="#hints-on-android-smart-card-emulator">Hints on Android Smart Card Emulator</a></li>
<li><a class="reference internal" href="#hints-on-pc-sc-middleware">Hints on PC/SC middleware</a></li>
</ul>
</li>
<li><a class="reference internal" href="#usage">Usage</a></li>
<li><a class="reference internal" href="#question">Question</a></li>
<li><a class="reference internal" href="#notes-and-references">Notes and References</a></li>
</ul>
</li>
</ul>
</ul>
</li>
              
            
            
              
                
  <li>
    <a href="../TCardEmulator/README.html" title="Previous Chapter: Tizen Smart Card Emulator"><span class="glyphicon glyphicon-chevron-left visible-sm"></span><span class="hidden-sm hidden-tablet">&laquo; Tizen Smart C...</span>
    </a>
  </li>
  <li>
    <a href="../ccid/README.html" title="Next Chapter: USB CCID Emulator"><span class="glyphicon glyphicon-chevron-right visible-sm"></span><span class="hidden-sm hidden-tablet">USB CCID Emulator &raquo;</span>
    </a>
  </li>
              
            
            
            
            
              <li class="hidden-sm"></li>
            
          </ul>

          
            
<form class="navbar-form navbar-right" action="../search.html" method="get">
 <div class="form-group">
  <input type="text" name="q" class="form-control" placeholder="Search" />
 </div>
  <input type="hidden" name="check_keywords" value="yes" />
  <input type="hidden" name="area" value="default" />
</form>
          
        </div>
    </div>
  </div>

<div class="container">
  <div class="row">
    <div class="col-md-12 content">
      
  <div class="section" id="pc-sc-relay">
<span id="pcsc-relay"></span><h1>PC/SC Relay<a class="headerlink" href="#pc-sc-relay" title="Permalink to this headline">¶</a></h1>
<div class="sidebar">
<p class="sidebar-title">Relay a smart card to a contactless interface</p>
<dl class="field-list simple">
<dt class="field-odd">License</dt>
<dd class="field-odd"><p>GPL version 3</p>
</dd>
<dt class="field-even">Tested Platforms</dt>
<dd class="field-even"><ul class="simple">
<li><p>Windows</p></li>
<li><p>Linux (Debian, Ubuntu, OpenMoko)</p></li>
</ul>
</dd>
</dl>
</div>
<p>Welcome to PC/SC Relay. The purpose of PC/SC Relay is to relay a smart
card using an contact-less interface. Currently the following contact-less
emulators are supported:</p>
<ul class="simple">
<li><p><a class="reference external" href="http://nfc-tools.org/index.php?title=Devices_compatibility_matrix">Hardware supported by libnfc</a> <a class="footnote-reference brackets" href="#id3" id="id4">1</a></p></li>
<li><p><a class="reference external" href="http://www.openpcd.org/OpenPICC">OpenPICC</a> <a class="footnote-reference brackets" href="#id5" id="id6">2</a></p></li>
<li><p><a class="reference internal" href="../ACardEmulator/README.html#acardemulator"><span class="std std-ref">Android Smart Card Emulator</span></a></p></li>
</ul>
<p>Command APDUs are received with the contact-less interface and relayed. The
Response APDUs are then sent back via RFID. The contact-less data will be
relayed to one of the following:</p>
<ul class="simple">
<li><p>to a <em>real</em> smart card inserted into one of the systems smart card readers.
The smart card reader must be accessible with PC/SC. The smart card may be
contact-based <em>or</em> contact-less.</p></li>
<li><p>to a <a class="reference internal" href="../virtualsmartcard/README.html#vicc"><span class="std std-ref">Virtual Smart Card</span></a> that directly connects to <strong class="command">pcsc-relay</strong>. The virtual
smart cards native interface is used and (despite its name) PC/SC Relay
does not need to access PC/SC in this case.</p></li>
</ul>
<div class="figure" id="id1" style="text-align: center">
<p><img  src="../_images/tikz-115ce7f91e19ed28b7af35a9f18aa096148209ea.svg" alt="Figure made with TikZ" /></p>
<p class="caption"><span class="caption-text">Debug, Analyze and Emulate with PC/SC Relay</span></p>
</div><p>With PC/SC Relay you can relay a contact-less or contact based smart card
over a long distance. Also you can use it in combination with the <a class="reference internal" href="../virtualsmartcard/README.html#vicc"><span class="std std-ref">Virtual Smart Card</span></a>
to completely emulate an ISO/IEC 14443 smart card.</p>
<div class="figure" id="id2" style="text-align: center">
<p><img  src="../_images/tikz-0405e52eb98193c32482e91a30737e1e9684bad0.svg" alt="Figure made with TikZ" /></p>
<p class="caption"><span class="caption-text">Emulate a contact-less German ID card to perform sanity checks</span></p>
</div><p>PC/SC Relay has the following dependencies:</p>
<ul class="simple">
<li><p>PC/SC middleware</p></li>
</ul>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>This software can actually be used in a relay attack allowing full access
to the card. We discussed the impact especially on the <a class="reference external" href="http://media.ccc.de/browse/congress/2010/27c3-4297-de-die_gesamte_technik_ist_sicher.html">Relay attack
against the German ID card</a>,
but it generally concerns <em>all</em> contact-less smart cards.</p>
</div>
<div class="section" id="download">
<h2>Download<a class="headerlink" href="#download" title="Permalink to this headline">¶</a></h2>
<p>You can find the latest release of PC/SC Relay on <a class="reference external" href="https://github.com/frankmorgner/vsmartcard/releases">Github</a>. Older releases are
still available on <a class="reference external" href="http://sourceforge.net/projects/vsmartcard/files">Sourceforge</a>.</p>
<p>Alternatively, you can clone our git repository:</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>git clone https://github.com/frankmorgner/vsmartcard.git
</pre></div>
</div>
</div>
<div class="section" id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline">¶</a></h2>
<div class="section" id="installation-on-linux-unix-and-similar">
<h3>Installation on Linux, Unix and similar<a class="headerlink" href="#installation-on-linux-unix-and-similar" title="Permalink to this headline">¶</a></h3>
<p>The PC/SC Relay uses the GNU Build System to compile and install. If you are
unfamiliar with it, please have a look at <code class="file docutils literal notranslate"><span class="pre">INSTALL</span></code>. If you can not find
it, you are probably working bleeding edge in the repository. To generate the
missing standard auxiliary files you need to additionally install <cite>libtool</cite> and
<cite>pkg-config</cite> and run the following command in <code class="file docutils literal notranslate"><span class="pre">pcsc-relay</span></code>:</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>autoreconf --verbose --install
</pre></div>
</div>
<p>To configure (<strong class="command">configure --help</strong> lists possible options), build and
install the PC/SC Relay now do the following:</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>./configure
make
make install
</pre></div>
</div>
</div>
<div class="section" id="hints-on-libnfc">
<h3>Hints on libnfc<a class="headerlink" href="#hints-on-libnfc" title="Permalink to this headline">¶</a></h3>
<p>Here is an example of how to get the standard
installation of libnfc:</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span><span class="nv">PREFIX</span><span class="o">=</span>/tmp/install
<span class="nv">LIBNFC</span><span class="o">=</span>libnfc
git clone https://github.com/nfc-tools/libnfc <span class="nv">$LIBNFC</span>
<span class="nb">cd</span> <span class="nv">$LIBNFC</span>
autoreconf -i
<span class="c1"># See `./configure --help` for enabling support of additional hardware</span>
./configure --prefix<span class="o">=</span><span class="nv">$PREFIX</span>
make
make install
</pre></div>
</div>
<p>Building PC/SC Relay with libnfc is done best using <strong class="command">pkg-config</strong>.  The file
<code class="file docutils literal notranslate"><span class="pre">libnfc.pc</span></code> should be located in <code class="docutils literal notranslate"><span class="pre">$INSTALL/lib/pkgconfig</span></code>. Here is how to
configure PC/SC Relay to use it:</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>./configure <span class="nv">PKG_CONFIG_PATH</span><span class="o">=</span><span class="nv">$PREFIX</span>/lib/pkgconfig
</pre></div>
</div>
</div>
<div class="section" id="hints-on-android-smart-card-emulator">
<h3>Hints on Android Smart Card Emulator<a class="headerlink" href="#hints-on-android-smart-card-emulator" title="Permalink to this headline">¶</a></h3>
<p>The Android Smart Card Emulator is build around the host card emulation mode of
Android 4.4 and later. This mode activates the app if the terminal issues a
SELECT command with one of the apps application identifiers. By default, the
app only registers for the AIDs for which it has a built-in emulator (see
<code class="file docutils literal notranslate"><span class="pre">ACardEmulator/app/src/main/res/xml/aid_list.xml</span></code>).</p>
<p>If used together with PC/SC Relay, you need to change add AIDs to match the
applications on the relayed card.  Otherwise the app will not be activated when
it should relay command APDUs to PC/SC Relay.</p>
<p>Modify the Smart Card Emulator settings to use <code class="docutils literal notranslate"><span class="pre">Remote</span> <span class="pre">Virtual</span> <span class="pre">Smart</span> <span class="pre">Card</span></code> as
<span class="guilabel">Smart Card Emulator</span>. Now start <strong class="command">pcsc-relay</strong> by specifying
usage of the vpcd emulator:</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>pcsc-relay --emulator vpcd
</pre></div>
</div>
<p>In the app, change the <span class="guilabel">VICC Hostname</span> and <span class="guilabel">VICC Port</span> to
match the location where <strong class="command">pcsc-relay</strong> is waiting for an incoming
connection. When the app receives a SELECT command to one of the configured
AIDs, it will connect to <strong class="command">pcsc-relay</strong>, which will then relay the
command for processing.</p>
<p>Compiling and installing Android Smart Card Emulator is covered in its
<a class="reference internal" href="../ACardEmulator/README.html#acardemulator-install"><span class="std std-ref">Download and Install</span></a> section.</p>
</div>
<div class="section" id="hints-on-pc-sc-middleware">
<h3>Hints on PC/SC middleware<a class="headerlink" href="#hints-on-pc-sc-middleware" title="Permalink to this headline">¶</a></h3>
<p>A PC/SC middleware is included by default in most modern operating systems. On
Unix-like systems (Linux, OS X, Sun OS) it is realized by <a class="reference external" href="https://pcsclite.apdu.fr/">PCSC-Lite</a> <a class="footnote-reference brackets" href="#id7" id="id8">3</a>. To
compile PC/SC Relay you will need to install the PCSC-Lite headers from
your distribution.</p>
<p>Windows also ships with a PC/SC middleware in form of the Winscard module.
PC/SC Relay can be (cross) compiled with MinGW-w64. Also, Microsofts
developement environment Visual Studio includes all necessary data for building
PC/SC Relay.</p>
</div>
</div>
<div class="section" id="usage">
<h2>Usage<a class="headerlink" href="#usage" title="Permalink to this headline">¶</a></h2>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>Usage: pcsc-relay [OPTION]...
Relay a smart card to a contactless interface

Using an contact-less interface (currently OpenPICC or libnfc) pcsc-relay
receives command APDUs which are forwared to an existing smart card via PC/SC.
pcsc-relay sends the response APDU back to the contact-less interface.

  -h, --help                  Print help and exit
  -V, --version               Print version and exit
  -e, --emulator=ENUM         Contact-less emulator backend  (possible
                                values=&quot;libnfc&quot;, &quot;vpcd&quot;, &quot;openpicc&quot;
                                default=`libnfc&#39;)
  -c, --connector=ENUM        Smart card connector backend  (possible
                                values=&quot;pcsc&quot;, &quot;vicc&quot; default=`pcsc&#39;)
  -f, --foreground            Stay in foreground  (default=on)
  -v, --verbose               Use (several times) to be more verbose

PC/SC connector:
  -r, --reader=INT            Number of the PC/SC reader to use (-1 for
                                autodetect)  (default=`-1&#39;)

Virtual Smart Card connector:
  -p, --vpcd-port=INT         Port for communicating virtual smart card
                                (default=`35963&#39;)
  -n, --vpcd-hostname=STRING  Hostname for connecting to virtual smart card
                                (default=`wait for an incoming connection&#39;)

Virtual Smart Card Reader emulator:
  -P, --vicc-port=INT         Port to listen for virtual smart card reader
                                (default=`35963&#39;)
  -N, --vicc-hostname=STRING  Hostname for connecting to virtual smart card
                                reader  (default=`wait for an incoming
                                connection&#39;)
  -A, --vicc-atr=STRING       ATR  (default=`3B80800101&#39;)

Report bugs to https://github.com/frankmorgner/vsmartcard/issues

Written by Frank Morgner and Dominik Oepen
</pre></div>
</div>
<p>Below we explain what option to choose for the emulator which receives a
command APDU and transmits a response APDU back to the terminal:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 78%" />
<col style="width: 22%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Option</p></th>
<th class="head"><p><code class="docutils literal notranslate"><span class="pre">--emulator</span></code></p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>Emulation hardware supported via libnfc</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">libnfc</span></code></p></td>
</tr>
<tr class="row-odd"><td><p>Emulation with OpenPICC</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">openpicc</span></code></p></td>
</tr>
<tr class="row-even"><td><p>Android Smart Card Emulator</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">vpcd</span></code></p></td>
</tr>
<tr class="row-odd"><td><p>Virtual Smart Card</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">vpcd</span></code></p></td>
</tr>
</tbody>
</table>
<p>Below we explain what option to choose for the connector which calculates
a response APDU from a given command APDU:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 77%" />
<col style="width: 23%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Option</p></th>
<th class="head"><p><code class="docutils literal notranslate"><span class="pre">--connector</span></code></p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>Contact-based Smart Card in PC/SC Reader</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">pcsc</span></code></p></td>
</tr>
<tr class="row-odd"><td><p>Contact-less Smart Card in PC/SC Reader</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">pcsc</span></code></p></td>
</tr>
<tr class="row-even"><td><p>Contact-less Smart Card in Remote Smart Card Reader</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">vicc</span></code></p></td>
</tr>
<tr class="row-odd"><td><p>Virtual Smart Card</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">vicc</span></code></p></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="question">
<h2>Question<a class="headerlink" href="#question" title="Permalink to this headline">¶</a></h2>
<p>Do you have questions, suggestions or contributions? Feedback of any kind is
more than welcome! Please use our <a class="reference external" href="https://github.com/frankmorgner/vsmartcard/issues">project trackers</a>.</p>
</div>
<div class="section" id="notes-and-references">
<h2>Notes and References<a class="headerlink" href="#notes-and-references" title="Permalink to this headline">¶</a></h2>
<dl class="footnote brackets">
<dt class="label" id="id3"><span class="brackets"><a class="fn-backref" href="#id4">1</a></span></dt>
<dd><p><a class="reference external" href="http://nfc-tools.org/index.php?title=Devices_compatibility_matrix">http://nfc-tools.org/index.php?title=Devices_compatibility_matrix</a></p>
</dd>
<dt class="label" id="id5"><span class="brackets"><a class="fn-backref" href="#id6">2</a></span></dt>
<dd><p><a class="reference external" href="http://www.openpcd.org/OpenPICC">http://www.openpcd.org/OpenPICC</a></p>
</dd>
<dt class="label" id="id7"><span class="brackets"><a class="fn-backref" href="#id8">3</a></span></dt>
<dd><p><a class="reference external" href="https://pcsclite.apdu.fr/">https://pcsclite.apdu.fr/</a></p>
</dd>
</dl>
</div>
</div>


    </div>
      
  </div>
</div>
<footer class="footer">
  <div class="container">
    <p class="pull-right">
      <a href="#">Back to top</a>
      
    </p>
    <p>
        &copy; Copyright 2009-2021 by Dominik Oepen and Frank Morgner.<br/>
    </p>
  </div>
</footer>
  </body>
</html>