nitrokey.nk3.secrets_app

Oath Authenticator client

Používa sa prostredníctvom prenosu CTAPHID prostredníctvom vlastného príkazu dodávateľa. Môže sa použiť aj priamo cez CCID.

exception nitrokey.nk3.secrets_app.SecretsAppException

Základ: Exception

SecretsAppException(kód: str, kontext: str)

__init__(code, context)
Parametre:
  • code (str)

  • context (str)

Návratový typ:

None

to_id()
Návratový typ:

SecretsAppExceptionID

to_string()
Návratový typ:

str

code: str
context: str
exception nitrokey.nk3.secrets_app.SecretsAppHealthCheckException

Základ: Exception

class nitrokey.nk3.secrets_app.Algorithm

Základ: Enum

Sha1 = 1
Sha256 = 2
Sha512 = 3
class nitrokey.nk3.secrets_app.CCIDInstruction

Základ: Enum

Select = 164
class nitrokey.nk3.secrets_app.Instruction

Základ: Enum

Calculate = 162
CalculateAll = 164
ChangePIN = 179
Delete = 2
GetCredential = 181
List = 161
Put = 1
Reset = 4
SendRemaining = 165
SetCode = 3
SetPIN = 180
UpdateCredential = 183
Validate = 163
VerifyCode = 177
VerifyPIN = 178
class nitrokey.nk3.secrets_app.Kind

Základ: Enum

classmethod from_attribute_byte(attribute_byte)
Parametre:

attribute_byte (bytes)

Návratový typ:

str

classmethod from_attribute_byte_type(a)
Parametre:

a (int)

Návratový typ:

Kind

Hmac = 64
Hotp = 16
HotpReverse = 48
NotSet = 240
Totp = 32
class nitrokey.nk3.secrets_app.ListItem

Základ: object

ListItem(druh: ‚Kind‘, algoritmus: ‚Algorithm‘, označenie: bytes, vlastnosti: Nitrokey.nk3.secrets_app.ListItemProperties)

__init__(kind, algorithm, label, properties)
Parametre:
Návratový typ:

None

classmethod get_type_name(x)
Parametre:

x (Any)

Návratový typ:

str

algorithm: Algorithm
kind: Kind
label: bytes
properties: ListItemProperties
class nitrokey.nk3.secrets_app.ListItemProperties

Základ: object

ListItemProperties(touch_required: bool, secret_encryption: bool, pws_data_exist: bool)

__init__(touch_required, secret_encryption, pws_data_exist)
Parametre:
  • touch_required (bool)

  • secret_encryption (bool)

  • pws_data_exist (bool)

Návratový typ:

None

classmethod from_byte(b)
Parametre:

b (int)

Návratový typ:

ListItemProperties

pws_data_exist: bool
secret_encryption: bool
touch_required: bool
class nitrokey.nk3.secrets_app.PasswordSafeEntry

Základ: object

PasswordSafeEntry(login: bytes], password: Optional[bytes], metadata: Optional[bytes], properties: Optional[bytes] = None, name: Optional[bytes] = None)

__init__(login, password, metadata, properties=None, name=None)
Parametre:
  • login (bytes | None)

  • password (bytes | None)

  • metadata (bytes | None)

  • properties (bytes | None)

  • name (bytes | None)

Návratový typ:

None

tlv_encode()
Návratový typ:

list[Entry]

login: bytes | None
metadata: bytes | None
name: bytes | None = None
password: bytes | None
properties: bytes | None = None
class nitrokey.nk3.secrets_app.RawBytes

Základ: object

RawBytes(data: list[int])

__init__(data)
Parametre:

data (list[int])

Návratový typ:

None

data: list[int]
class nitrokey.nk3.secrets_app.SecretsApp

Základ: object

Toto je klient aplikácie Secrets https://github.com/Nitrokey/trussed-secrets-app

__init__(dev, logfn=None)
Parametre:
  • dev (NK3)

  • logfn (Callable[[str], Any] | None)

calculate(cred_id, challenge=None)

Vypočítať OTP kód pre poverenie s názvom cred_id a s výzvou challenge.

Parametre:
  • cred_id (bytes) – The name of the credential

  • challenge (int | None) – Výzva na výpočet (len TOTP). Mala by sa rovnať: časová značka/obdobie. Bežne používaná hodnota periódy je 30.

Vracia:

Kód OTP ako reťazec bajtov

Návratový typ:

bytes

change_pin_raw(password, new_password)
Parametre:
  • password (str)

  • new_password (str)

Návratový typ:

None

clear_code()

Vymažte prístupovú frázu používanú na overovanie iných príkazov.

Návratový typ:

None

delete(cred_id)

Delete credential with the given id. Does not fail, if the given credential does not exist. :param credid: Credential ID

Parametre:

cred_id (bytes)

Návratový typ:

None

classmethod encode_properties_to_send(touch_button_required, pin_based_encryption, tlv=False)

Encode properties structure into a single byte @param touch_button_required: whether the touch button use is required @param pin_based_encryption: whether the PIN-encryption is requested (only during registration) @param tlv: set True, if this should be encoded as TLV, as opposed to the default „TV“, w/o L

Parametre:
  • touch_button_required (bool)

  • pin_based_encryption (bool)

  • tlv (bool)

Návratový typ:

RawBytes

feature_active_PIN_authentication()
Návratový typ:

bool

feature_challenge_response_support()
Návratový typ:

bool

feature_extended_list()
Návratový typ:

bool

feature_old_application_version()
Návratový typ:

bool

feature_pws_support()
Návratový typ:

bool

get_credential(cred_id)
Parametre:

cred_id (bytes)

Návratový typ:

PasswordSafeEntry

get_feature_status_cached()
Návratový typ:

SelectResponse

get_response_for_secret(challenge, secret)
Parametre:
  • challenge (bytes)

  • secret (bytes)

Návratový typ:

bytes

get_secret_for_passphrase(passphrase)
Parametre:

passphrase (str)

Návratový typ:

bytes

is_pin_healthy()
Návratový typ:

bool

list(extended=False)

Return a list of the registered credentials :return: List of bytestrings, or tuple of bytestrings, if „extended“ switch is provided @deprecated

Parametre:

extended (bool)

Návratový typ:

list[Tuple[bytes, bytes] | bytes]

list_with_properties(version=1)

Return a list of the registered credentials with properties :return: List of ListItems

Parametre:

version (int)

Návratový typ:

List[ListItem]

protocol_v2_confirm_all_requests_with_pin()
Návratový typ:

bool

protocol_v3_separate_pin_and_no_pin_space()
Návratový typ:

bool

register(credid, secret=b'00000000000000000000', digits=6, kind=Kind.NotSet, algo=Algorithm.Sha1, initial_counter_value=0, touch_button_required=False, pin_based_encryption=False, login=None, password=None, metadata=None)

Register new OTP Credential :param credid: Credential ID :param secret: The shared key :param digits: Digits of the produced code :param kind: OTP variant - HOTP or TOTP :param algo: The hash algorithm to use - SHA1, SHA256 or SHA512 :param initial_counter_value: The counter’s initial value for the HOTP Credential (HOTP only) :param touch_button_required: User Presence confirmation is required to use this Credential :param pin_based_encryption: User preference for additional PIN-based encryption :param login: Login field for Password Safe :param password: Password field for Password Safe :param metadata: Metadata field for Password Safe :return: None

Parametre:
  • credid (bytes)

  • secret (bytes)

  • digits (int)

  • kind (Kind)

  • algo (Algorithm)

  • initial_counter_value (int)

  • touch_button_required (bool)

  • pin_based_encryption (bool)

  • login (bytes | None)

  • password (bytes | None)

  • metadata (bytes | None)

Návratový typ:

None

register_yk_hmac(slot, secret)

Register a Yubikey-compatible challenge-response slot. @param slot: challenge-response slot @param secret: the secret

Parametre:
  • slot (int)

  • secret (bytes)

Návratový typ:

None

rename_credential(cred_id, new_name)

Rename credential. An alias for the update_credential() call. @param cred_id: The credential ID to modify @param new_name: New ID for the credential

Parametre:
  • cred_id (bytes)

  • new_name (bytes)

Návratový typ:

None

reset()

Remove all credentials from the database

Návratový typ:

None

select()

Execute SELECT command, which returns details about the device, including the challenge needed for the authentication. :return SelectResponse Status structure. Challenge and Algorithm fields are None, if the passphrase is not set.

Návratový typ:

SelectResponse

set_code(passphrase)

Set the code with the defaults as suggested in the protocol specification: - https://developers.yubico.com/OATH/YKOATH_Protocol.html

Parametre:

passphrase (str)

Návratový typ:

None

set_code_raw(key, challenge, response)

Set or clear the passphrase used to authenticate to other commands. Raw interface. :param key: User passphrase processed through PBKDF2(ID,1000), and limited to the first 16 bytes. :param challenge: The current challenge taken from the SELECT command. :param response: The data calculated on the client, as a proof of a correct setup.

Parametre:
  • key (bytes)

  • challenge (bytes)

  • response (bytes)

Návratový typ:

None

set_pin_raw(password)
Parametre:

password (str)

Návratový typ:

None

update_credential(cred_id, new_name=None, login=None, password=None, metadata=None, touch_button=None)

Update credential fields - name, attributes, and PWS fields. Unpopulated fields will not be encoded and used during the update process (won’t change the current value). @param cred_id: The credential ID to modify @param new_name: New ID for the credential @param login: New login field content @param password: New password field content @param metadata: New metadata field content @param touch_button: Set if the touch button use should be required

Parametre:
  • cred_id (bytes)

  • new_name (bytes | None)

  • login (bytes | None)

  • password (bytes | None)

  • metadata (bytes | None)

  • touch_button (bool | None)

Návratový typ:

None

validate(passphrase)

Authenticate using a passphrase

Parametre:

passphrase (str)

Návratový typ:

None

validate_raw(challenge, response)

Authenticate using a passphrase. Raw interface. :param challenge: The current challenge taken from the SELECT command. :param response: The response calculated against the challenge and the secret

Parametre:
  • challenge (bytes)

  • response (bytes)

Návratový typ:

bytes

verify_code(cred_id, code)

Proceed with the incoming OTP code verification (aka reverse HOTP). :param cred_id: The name of the credential :param code: The HOTP code to verify. u32 representation. :return: fails with OTPAppException error; returns True if code matches the value calculated internally.

Parametre:
  • cred_id (bytes)

  • code (int)

Návratový typ:

bool

verify_pin_raw(password)
Parametre:

password (str)

Návratový typ:

None

dev: NK3
log: Logger
logfn: Callable[[str], Any]
write_corpus_fn: Callable[[Instruction | CCIDInstruction, bytes], Any] | None
class nitrokey.nk3.secrets_app.SecretsAppExceptionID

Základ: IntEnum

__new__(value)
ClassNotSupported = 28160
CommandChainingNotSupported = 26756
ConditionsOfUseNotSatisfied = 27013
FunctionNotSupported = 27265
IncorrectDataParameter = 27264
IncorrectP1OrP2Parameter = 27270
InstructionNotSupportedOrInvalid = 27904
KeyReferenceNotFound = 27272
LogicalChannelNotSupported = 26753
MoreDataAvailable = 25087
NotEnoughMemory = 27268
NotFound = 27266
OperationBlocked = 27011
SecureMessagingNotSupported = 26754
SecurityStatusNotSatisfied = 27010
Success = 36864
UnspecifiedCheckingError = 28416
UnspecifiedNonpersistentExecutionError = 25600
UnspecifiedPersistentExecutionError = 25856
VerificationFailed = 25344
WrongLength = 26368
class nitrokey.nk3.secrets_app.SelectResponse

Základ: object

SelectResponse(version: Optional[bytes], pin_attempt_counter: Optional[int], salt: Optional[bytes], challenge: Optional[bytes], algorithm: Optional[bytes], serial_number: Optional[bytes])

__init__(version, pin_attempt_counter, salt, challenge, algorithm, serial_number)
Parametre:
  • version (bytes | None)

  • pin_attempt_counter (int | None)

  • salt (bytes | None)

  • challenge (bytes | None)

  • algorithm (bytes | None)

  • serial_number (bytes | None)

Návratový typ:

None

version_str()
Návratový typ:

str

algorithm: bytes | None
challenge: bytes | None
pin_attempt_counter: int | None
salt: bytes | None
serial_number: bytes | None
version: bytes | None
class nitrokey.nk3.secrets_app.Tag

Základ: Enum

Algorithm = 123
Challenge = 116
CredentialId = 113
InitialCounter = 122
Key = 115
NameList = 114
NewPassword = 129
PINCounter = 130
Password = 128
Properties = 120
PwsLogin = 131
PwsMetadata = 133
PwsPassword = 132
Response = 117
SerialNumber = 143
Version = 121