# VirtualSmartcard Module

class `virtualsmartcard.VirtualSmartcard.``Iso7816OS`(mf, sam, ins2handler=None, extended_length=False)

  Bases: `virtualsmartcard.VirtualSmartcard.SmartcardOS`

  `SAM`

    secure access module

  `execute`(msg)
  `formatResult`(seekable, le, data, sw, sm)
  `getATR`()
  `getResponse`(p1, p2, data)
  static `makeATR`(**args)

    Calculate Answer to Reset (ATR) and returns the bitstring.

    > - directConvention (bool): Whether to use direct convention or

    >     inverse convention.

    > - TAi, TBi, TCi (optional): Value between 0 and 0xff. Interface

    >     Characters (for meaning see ISO 7816-3). Note that if no transmission protocol is given, it is automatically selected with T=max{j-1|TAj in args OR TBj in args OR TCj in args}.

    > - T (optional): Value between 0 and 15. Transmission Protocol.

    >     Note that if T is set, TAi/TBi/TCi for i>T are omitted.

    > - histChars (optional): Bitstring with 0 <= len(histChars) <= 15.

    >     Historical Characters T1 to T15 (for meaning see ISO 7816-4).

    T0, TDi and TCK are automatically calculated.

  static `makeThirdSoftwareFunctionTable`(commandChainging=False, extendedLe=False, assignLogicalChannel=0, maximumChannels=0)

    Returns a byte according to the third software function table from the historical bytes of the card capabilities.

  `mf`

    master file

  `powerDown`()

    Powers down the card

  `powerUp`()
  `reset`()
  static `seekable`(ins)

class `virtualsmartcard.VirtualSmartcard.``SmartcardOS`

  Bases: `object`

  Base class for a smart card OS

  `execute`(msg)

    Returns response to the given APDU as string of characters

    Parameters: | msg – the APDU as string of characters

  `getATR`()

    Returns the ATR of the card as string of characters

  `powerDown`()

    Powers down the card

  `powerUp`()

    Powers up the card

  `reset`()

    Performs a warm reset of the card (no power down)

class `virtualsmartcard.VirtualSmartcard.``VirtualICC`(datasetfile, card_type, host, port, readernum=None, ef_cardsecurity=None, ef_cardaccess=None, ca_key=None, cvca=None, disable_checks=False, esign_key=None, esign_ca_cert=None, esign_cert=None, logginglevel=20)

  Bases: `object`

  This class is responsible for maintaining the communication of the virtual PCD and the emulated smartcard. vpicc and vpcd communicate via a socket. The vpcd sends command APDUs (which it receives from an application) to the vicc. The vicc passes these CAPDUs on to an emulated smartcard, which produces a response APDU. This RAPDU is then passed back by the vicc to the vpcd, which forwards it to the application.

  `_VirtualICC__recvFromVPICC`()

    Receive a message from the vpcd

  `_VirtualICC__sendToVPICC`(msg)

    Send a message to the vpcd

  static `connectToPort`(host, port)

    Open a connection to a given host on a given port.

  static `openPort`(port)
  `run`()

    Main loop of the vpicc. Receives command APDUs via a socket from the vpcd, dispatches them to the emulated smartcard and sends the resulting respsonse APDU back to the vpcd.

  `signalHandler`(sig=None, frame=None)

    Basically this signal handler just surpresses a traceback from being printed when the user presses crtl-c

  `stop`()