Simulator
=========
The simulator provides a virtual card for testing purposes.
It is enabled by default in all SDKs. This will be indicated by a :ref:`reader`
message with the parameter **name** being `Simulator`.
This virtual card can be inserted by :ref:`set_card` or can be automatically
used in :ref:`automatic` mode.
The default values of that virtual card are hardcoded and can only be changed
by the **files** and **keys** parameter in the **simulator** parameter.


.. note::
  The simulated card can only be used in a test environment.



.. _filesystem:

Filesystem
----------
The content of the filesystem can be provided as a JSON array of objects.
The ``fileId`` and ``shortFileId`` are specified in `TR-03110_part4`_. The
``content`` is an ASN.1 structure in DER encoding. All fields are hex encoded.

These are the default values if your application does not provide other values
as **simulator** parameter in :ref:`set_card` or if you use the :ref:`automatic`
mode of :doc:`desktop` or the :doc:`container` variant.

.. code-block:: json

  "files":
   [
      {"fileId": "0101", "shortFileId": "01", "content": "610413024944"},
      {"fileId": "0102", "shortFileId": "02", "content": "6203130144"},
      {"fileId": "0103", "shortFileId": "03", "content": "630a12083230323931303331"},
      {"fileId": "0104", "shortFileId": "04", "content": "64070c054552494b41"},
      {"fileId": "0105", "shortFileId": "05", "content": "650c0c0a4d55535445524d414e4e"},
      {"fileId": "0106", "shortFileId": "06", "content": "66020c00"},
      {"fileId": "0107", "shortFileId": "07", "content": "67020c00"},
      {"fileId": "0108", "shortFileId": "08", "content": "680a12083139363430383132"},
      {"fileId": "0109", "shortFileId": "09", "content": "690aa1080c064245524c494e"},
      {"fileId": "010a", "shortFileId": "0a", "content": "6a03130144"},
      {"fileId": "010b", "shortFileId": "0b", "content": "6b03130146"},
      {"fileId": "010c", "shortFileId": "0c", "content": "6c30312e302c06072a8648ce3d0101022100a9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377"},
      {"fileId": "010d", "shortFileId": "0d", "content": "6d080c064741424c4552"},
      {"fileId": "010f", "shortFileId": "0f", "content": "6f0a12083230313931313031"},
      {"fileId": "0111", "shortFileId": "11", "content": "712d302baa120c10484549444553545241e1ba9e45203137ab070c054bc3964c4ead03130144ae0713053531313437"},
      {"fileId": "0112", "shortFileId": "12", "content": "7209040702760503150000"},
      {"fileId": "0113", "shortFileId": "13", "content": "7316a1140c125245534944454e4345205045524d49542031"},
      {"fileId": "0114", "shortFileId": "14", "content": "7416a1140c125245534944454e4345205045524d49542032"},
      {"fileId": "0115", "shortFileId": "15", "content": "7515131374656c3a2b34392d3033302d31323334353637"},
      {"fileId": "0116", "shortFileId": "16", "content": "761516136572696b61406d75737465726d616e6e2e6465"}
   ],
   "keys":
   [
      {"id": 1, "private": "0353859c2ec67780ba39015de8c682af2326d43de9ce1e07737087bd1e17cb22"},
      {"id": 2, "private": "9ad0ad7f4dfaaa06988339fc31d3a111f4c7964ac7f377373a2454327c43e2ff"}
   ]



All keys and also the files from :ref:`advanced` will always be present and
can be overwritten as they are required for successful authentication. The
other files will not exist until they are specified so it is possible to
simulate a missing piece of personal data.

The keys are used to calculate the pseudonym. Key ``1`` is used to check the
blacklist while key ``2`` is used to calculate the pseudonym for the service
provider.

New keys can be generated with OpenSSL.

.. code-block:: console

  openssl ecparam -name brainpoolP256r1 -genkey -out riKey.pem
  openssl ec -in riKey.pem -text -noout



.. _TR-03110_part4: https://www.bsi.bund.de/SharedDocs/Downloads/EN/BSI/Publications/TechGuidelines/TR03110/BSI_TR-03110_Part-4_V2-2.pdf



.. _advanced:

Advanced
--------
In addition the following files and keys can be overridden to change the
technical behavior of the virtual card. This does not affect the personal
data and is only required for eID-Client or eID-Server development.

.. code-block:: json

  "files":
   [
      {"fileId": "2f00", "shortFileId": "1e", "content": "61324f0fe828bd080fa000000167455349474e500f434941207a752044462e655369676e5100730c4f0aa000000167455349474e61094f07a0000002471001610b4f09e80704007f00070302610c4f0aa000000167455349474e"},
      {"fileId": "011c", "shortFileId": "1c", "content": "3181c13012060a04007f0007020204020202010202010d300d060804007f00070202020201023012060a04007f00070202030202020102020129301c060904007f000702020302300c060704007f0007010202010d020129303e060804007f000702020831323012060a04007f0007020203020202010202012d301c060904007f000702020302300c060704007f0007010202010d02012d302a060804007f0007020206161e687474703a2f2f6273692e62756e642e64652f6369662f6e70612e786d6c"},
      {"fileId": "011d", "shortFileId": "1d", "content": " "}
   ],
  "keys":
   [
      {"id": 41, "private": "a07eb62e891daa84643e0afcc1af006891b669b8f51e379477dbeab8c987a610"}
   ]



.. seealso::
  ISO 7816-4:2005 8.2.1.1

  `TR-03110_part3`_, part 3: Section A.1.2. Storage on the Chip

  .. _TR-03110_part3: https://www.bsi.bund.de/SharedDocs/Downloads/EN/BSI/Publications/TechGuidelines/TR03110/BSI_TR-03110_Part-3-V2_2.pdf
