cryptnoxpy.card.basic
¶
Module containing common functionality for basic cards. Don’t use it by itself.
Module Contents¶
Classes¶
Class for basic cards containing common functionalities. |
Attributes¶
- cryptnoxpy.card.basic._BASIC_PAIRING_SECRET = b'Cryptnox Basic CommonPairingData'¶
- class cryptnoxpy.card.basic.Basic(connection: cryptnoxpy.connection.Connection, data: List[int] = None, debug: bool = False)¶
Bases:
cryptnoxpy.card.base.Base
Class for basic cards containing common functionalities.
- type¶
- pin_rule = 4-9 digits¶
- change_pin(self, new_pin: str) None ¶
Change the current pin code of the card to a new pin code.
The method will set the given pin code as the pin code of the card. For it to work the card first must be opened with the current pin code.
- Requires
PIN code or challenge-response validated
- Parameters
new_pin (str) – The desired PIN code to be set for the card (4-9 digits).
- change_puk(self, current_puk: str, new_puk: str) None ¶
Change the current pin code of the card to a new pin code.
The method will set the given pin code as the pin code of the card. For it to work the card first must be opened with the current pin code.
- Parameters
current_puk (str) – The current PUK code of the card
new_puk (str) – The desired PUK code to be set for the card
- init(self, name: str, email: str, pin: str, puk: str, pairing_secret: bytes = _BASIC_PAIRING_SECRET) bytes ¶
Initialize the Cryptnox card.
Initialize the Cryptnox card with the owners name and email address. Set the PIN and PUK codes for authenticating with the card to be able to use it.
- Parameters
name (str) – Name of the card owner
email (str) – Email of the card owner
pin (str) – PIN code that will be used to open the card
puk (str) – PUK code that will be used to open the card
pairing_secret (bytes) – Pairing secret to use with the card
- Returns
Pairing secret
- Return type
bytes
- Raises
InitializationException – There was an issue with initialization
- unblock_pin(self, puk: str, new_pin: str) None ¶
Verifies the user using the PUK code and sets a new PIN code on the card.
Method should be used when the user has forgotten this/hers PIN code. By entering the PUK code the user verifies his/hers identity and can set the new PIN code on the card. Can be used only if the card is locked.
- Requires
User PIN must be locked
PIN code authentication must be enabled
- Parameters
puk (str) – PUK code for verification of the user, before changing the PIN code.
new_pin (str) – The desired PIN code to be set for the card (4-9 digits).
- Raises
PukException – PUK code not valid
CardNotBlocked – Card is not blocked, operation can’t be done
- static valid_pin(pin: str, pin_name: str = 'pin') str ¶
Check if provided pin is valid
- Parameters
pin (str) – The pin to check if valid
pin_name (str) – Value used in DataValidationException for pin name
- Return str
Provided pin in str format if valid
- Raises
DataValidationException – Provided pin is not valid
- _change_secret(self, select_pin_puk: int, value: str)¶
Change secret, PIN or PUK code, of the card
- Parameters
select_pin_puk (int) – Change the PIN or PUK code: 0 - PIN 1 - PUK
value (str) – Value of the new secret
- static _get_coded_value(value)¶