cryptnoxpy.connection
¶
Module for keeping the connection to the reader.
Sending and receiving information from the card through the reader.
Module Contents¶
Classes¶
Connection to the reader. |
- class cryptnoxpy.connection.Connection(index: int = 0, debug: bool = False)¶
Bases:
contextlib.ContextDecorator
Connection to the reader.
Sends and receives messages from the card using the reader.
- Parameters
index (int) – Index of the reader to initialize the connection with
debug (bool) – Show debug information during requests
- Variables
self.card (Card) – Information about the card.
- _init_reader(self, index)¶
- __del__(self)¶
- send_apdu(self, apdu: List[int]) Tuple[List[int], int, int] ¶
Send data to the card in plain format
- Parameters
apdu (int) – list of the APDU header
- Return bytes
Result of the query that was sent to the card
- Return type
bytes
- Raises
ConnectionException – Issue in the connection
- send_encrypted(self, apdu: List[int], data: bytes, receive_long: bool = False) bytes ¶
Send data to the card in encrypted format
- Parameters
apdu (int) – list of the APDU header
data – bytes of the data payload (in clear, will be encrypted)
receive_long (bool) –
- Return bytes
Result of the query that was sent to the card
- Return type
bytes
- Raises
CryptnoxException – General exceptions
- static _check_response_code(code1: int, code2: int) None ¶
- _decode(self, rep: bytes, mac_value: bytes) bytes ¶
- _encrypt(self, apdu: List[int], data: bytes, receive_long: bool) Tuple[List[int], Union[int, bytes]] ¶
- _open_secure_channel(self, pairing_secret: bytes = b'', pairing_key_index: int = 0) None ¶