Bit and Octet Strings
OctetString
ASN.1 tag 0x04.
Constructor
OctetString(data: bytes)
Methods
| Method | Returns |
|---|---|
to_bytes() | bytes |
__len__() | int |
__eq__(other) | bool |
Full class stub
class OctetString:
def __init__(self, data: bytes) -> None: ...
def to_bytes(self) -> bytes: ...
def __len__(self) -> int: ...
def __eq__(self, other: OctetString) -> bool: ...
BitString
ASN.1 tag 0x03.
Constructor
BitString(data: bytes, unused_bits: int) # unused_bits in 0–7
Methods
| Method | Returns | Description |
|---|---|---|
to_bytes() | bytes | Raw content bytes (excluding unused-bits octet). |
unused_bits() | int | Number of padding bits in the last byte. |
bit_len() | int | Total significant bits (len(data) * 8 - unused_bits). |
__len__() | int | Same as bit_len(). |
__eq__(other) | bool |
Full class stub
class BitString:
def __init__(self, data: bytes, unused_bits: int) -> None: ...
def to_bytes(self) -> bytes: ...
def unused_bits(self) -> int: ...
def bit_len(self) -> int: ...
def __len__(self) -> int: ... # byte length (same as len(to_bytes()))
def __eq__(self, other: BitString) -> bool: ...