Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions yubikit/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,8 @@ def require_version(


def int2bytes(value: int, min_len: int = 0) -> bytes:
buf = []
while value > 0xFF:
buf.append(value & 0xFF)
value >>= 8
buf.append(value)
return bytes(reversed(buf)).rjust(min_len, b"\0")
min_len = max(min_len, (value.bit_length() + 7) // 8)
return value.to_bytes(min_len, "big")


def bytes2int(data: bytes) -> int:
Expand Down