utils Module — vsmartcard 2017-01-16 documentation

# utils Module

class `virtualsmartcard.utils.` `APDU`(*args, **kwargs)

  Bases: `object`

  Base class for an APDU

  `_deldata`()
  `_format_parts`(fields)

    utility function to be used in __str__ and __repr__

  `_getdata`()
  `_setbyte`(name, value)
  `_setdata`(value)
  `data`

    The data contents of this APDU

class `virtualsmartcard.utils.` `C_APDU`(*args, **kwargs)

  Bases: `virtualsmartcard.utils.APDU`

  Class for a command APDU

  `CLA`

    The CLA attribute of the APDU

  `INS`

    The INS attribute of the APDU

  `Lc`

    The Lc attribute of the APDU

  `Le`

    The Le attribute of the APDU

  `P1`

    The P1 attribute of the APDU

  `P2`

    The P2 attribute of the APDU

  `_deldata`()
  `_format_fields`()
  `_format_parts`(fields)

    utility function to be used in __str__ and __repr__

  `_getdata`()
  `_setbyte`(name, value)
  `_setdata`(value)
  `case`()

    Return 1, 2, 3 or 4, depending on which ISO case we represent.

  `cla`

    The CLA attribute of the APDU

  `data`

    The data contents of this APDU

  `effective_Le`
  `ins`

    The INS attribute of the APDU

  `lc`

    The Lc attribute of the APDU

  `le`

    The Le attribute of the APDU

  `p1`

    The P1 attribute of the APDU

  `p2`

    The P2 attribute of the APDU

  `parse`(apdu)

    Parse a full command APDU and assign the values to our object, overwriting whatever there was.

  `render`()

    Return this APDU as a binary string

class `virtualsmartcard.utils.` `R_APDU`(*args, **kwargs)

  Bases: `virtualsmartcard.utils.APDU`

  Class for a response APDU

  `SW`

    The Status Word of this response APDU

  `SW1`

    The SW1 attribute of the APDU

  `SW2`

    The SW2 attribute of the APDU

  `_deldata`()
  `_format_fields`()
  `_format_parts`(fields)

    utility function to be used in __str__ and __repr__

  `_getdata`()
  `_getsw`()
  `_setbyte`(name, value)
  `_setdata`(value)
  `_setsw`(value)
  `data`

    The data contents of this APDU

  `parse`(apdu)

    Parse a full response APDU and assign the values to our object, overwriting whatever there was.

  `render`()

    Return this APDU as a binary string

  `sw`

    The Status Word of this response APDU

  `sw1`

    The SW1 attribute of the APDU

  `sw2`

    The SW2 attribute of the APDU

`virtualsmartcard.utils.` `_make_byte_property`(prop)

  Make a byte property(). This is meta code.

`virtualsmartcard.utils.` `_unformat_hexdump`(dump)

`virtualsmartcard.utils.` `hexdump`(data, indent=0, short=False, linelen=16, offset=0)

  Generates a nice hexdump of data and returns it. Consecutive lines will be indented with indent spaces. When short is true, will instead generate hexdump without adresses and on one line.

  Examples: hexdump(‘A’) -> ‘0000: 00 41 .A ‘ hexdump(‘A’, short=True) -> ‘00 41 (.A)’

`virtualsmartcard.utils.` `inttostring`(i, length=None)

`virtualsmartcard.utils.` `parse_status`(data)

  Parses the Response APDU of a GetStatus command.

`virtualsmartcard.utils.` `stringtoint`(str)