asn1.pyi 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. from typing import Optional, Sequence, Union, Set, Iterable
  2. __all__ = ['DerObject', 'DerInteger', 'DerOctetString', 'DerNull',
  3. 'DerSequence', 'DerObjectId', 'DerBitString', 'DerSetOf']
  4. # TODO: Make the encoded DerObjects their own type, so that DerSequence and
  5. # DerSetOf can check their contents better
  6. class BytesIO_EOF:
  7. def __init__(self, initial_bytes: bytes) -> None: ...
  8. def set_bookmark(self) -> None: ...
  9. def data_since_bookmark(self) -> bytes: ...
  10. def remaining_data(self) -> int: ...
  11. def read(self, length: int) -> bytes: ...
  12. def read_byte(self) -> bytes: ...
  13. class DerObject:
  14. payload: bytes
  15. def __init__(self, asn1Id: Optional[int]=None, payload: Optional[bytes]=..., implicit: Optional[int]=None,
  16. constructed: Optional[bool]=False, explicit: Optional[int]=None) -> None: ...
  17. def encode(self) -> bytes: ...
  18. def decode(self, der_encoded: bytes, strict: Optional[bool]=False) -> DerObject: ...
  19. class DerInteger(DerObject):
  20. value: int
  21. def __init__(self, value: Optional[int]= 0, implicit: Optional[int]=None, explicit: Optional[int]=None) -> None: ...
  22. def encode(self) -> bytes: ...
  23. def decode(self, der_encoded: bytes, strict: Optional[bool]=False) -> DerInteger: ...
  24. class DerSequence(DerObject):
  25. def __init__(self, startSeq: Optional[Sequence[Union[int, DerInteger, DerObject]]]=None, implicit: Optional[int]=None) -> None: ...
  26. def __delitem__(self, n: int) -> None: ...
  27. def __getitem__(self, n: int) -> None: ...
  28. def __setitem__(self, key: int, value: DerObject) -> None: ...
  29. def __setslice__(self, i: int, j: int, sequence: Sequence) -> None: ...
  30. def __delslice__(self, i: int, j: int) -> None: ...
  31. def __getslice__(self, i: int, j: int) -> DerSequence: ...
  32. def __len__(self) -> int: ...
  33. def __iadd__(self, item: DerObject) -> DerSequence: ...
  34. def append(self, item: DerObject) -> DerSequence: ...
  35. def hasInts(self, only_non_negative: Optional[bool]=True) -> int: ...
  36. def hasOnlyInts(self, only_non_negative: Optional[bool]=True) -> bool: ...
  37. def encode(self) -> bytes: ...
  38. def decode(self, der_encoded: bytes, strict: Optional[bool]=False, nr_elements: Optional[int]=None, only_ints_expected: Optional[bool]=False) -> DerSequence: ...
  39. class DerOctetString(DerObject):
  40. payload: bytes
  41. def __init__(self, value: Optional[bytes]=..., implicit: Optional[int]=None) -> None: ...
  42. class DerNull(DerObject):
  43. def __init__(self) -> None: ...
  44. class DerObjectId(DerObject):
  45. value: str
  46. def __init__(self, value: Optional[str]=..., implicit: Optional[int]=None, explicit: Optional[int]=None) -> None: ...
  47. def encode(self) -> bytes: ...
  48. def decode(self, der_encoded: bytes, strict: Optional[bool]=False) -> DerObjectId: ...
  49. class DerBitString(DerObject):
  50. value: bytes
  51. def __init__(self, value: Optional[bytes]=..., implicit: Optional[int]=None, explicit: Optional[int]=None) -> None: ...
  52. def encode(self) -> bytes: ...
  53. def decode(self, der_encoded: bytes, strict: Optional[bool]=False) -> DerBitString: ...
  54. DerSetElement = Union[bytes, int]
  55. class DerSetOf(DerObject):
  56. def __init__(self, startSet: Optional[Set[DerSetElement]]=None, implicit: Optional[int]=None) -> None: ...
  57. def __getitem__(self, n: int) -> DerSetElement: ...
  58. def __iter__(self) -> Iterable: ...
  59. def __len__(self) -> int: ...
  60. def add(self, elem: DerSetElement) -> None: ...
  61. def decode(self, der_encoded: bytes, strict: Optional[bool]=False) -> DerObject: ...
  62. def encode(self) -> bytes: ...