ykman.otp

Attributes

DEFAULT_PW_CHAR_BLOCKLIST

Functions

is_in_fips_mode(session)

Check if the OTP application of a FIPS YubiKey is in FIPS approved mode.

generate_static_pw(length[, keyboard_layout, blocklist])

Generate a random password.

parse_oath_key(val)

Parse a secret key encoded as either Hex or Base32.

format_oath_code(response[, digits])

Format an OATH code from a hash response.

time_challenge(timestamp[, period])

Format a HMAC-SHA1 challenge based on an OATH timestamp and period.

format_csv(serial, public_id, private_id, key[, ...])

Produce a CSV line in the "Yubico" format.

Module Contents

ykman.otp.is_in_fips_mode(session)[source]

Check if the OTP application of a FIPS YubiKey is in FIPS approved mode.

Parameters:

session (yubikit.yubiotp.YubiOtpSession) – The YubiOTP session.

Return type:

bool

ykman.otp.DEFAULT_PW_CHAR_BLOCKLIST
ykman.otp.generate_static_pw(length, keyboard_layout=KEYBOARD_LAYOUT.MODHEX, blocklist=DEFAULT_PW_CHAR_BLOCKLIST)[source]

Generate a random password.

Parameters:
Return type:

str

ykman.otp.parse_oath_key(val)[source]

Parse a secret key encoded as either Hex or Base32.

Parameters:

val (str) – The secret key.

Return type:

bytes

ykman.otp.format_oath_code(response, digits=6)[source]

Format an OATH code from a hash response.

Parameters:
  • response (bytes) – The response.

  • digits (int) – The number of digits in the OATH code.

Return type:

str

ykman.otp.time_challenge(timestamp, period=30)[source]

Format a HMAC-SHA1 challenge based on an OATH timestamp and period.

Parameters:
  • timestamp (int) – The timestamp.

  • period (int) – The period.

Return type:

bytes

ykman.otp.format_csv(serial, public_id, private_id, key, access_code=None, timestamp=None)[source]

Produce a CSV line in the “Yubico” format.

Parameters:
  • serial (int) – The serial number.

  • public_id (bytes) – The public ID.

  • private_id (bytes) – The private ID.

  • key (bytes) – The secret key.

  • access_code (Optional[bytes]) – The access code.

  • timestamp (Optional[datetime.datetime])

Return type:

str