Skip to content
Merged
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
6 changes: 3 additions & 3 deletions src/erc7730/common/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def tlv(tag: int | IntEnum, value: bytes | str | None = None) -> bytes:


def length_value(
value: bytes | str | None,
value: bytes | bytearray | str | None,
) -> bytes:
"""
Prepend the length (DER encoded) of the value encoded to the value itself.
Expand All @@ -46,8 +46,8 @@ def length_value(
if value is None:
return (0).to_bytes(1, "big")
match value:
case bytes():
value_encoded = value
case bytes() | bytearray():
value_encoded = bytes(value)
case str():
value_encoded = value.encode("ascii", errors="strict")
return der_encode_int(len(value_encoded)) + value_encoded
Expand Down
Loading