Turns BER/CER/DER octet stream into an ASN.1 object. Takes BER/CER/DER octet-stream in form of :py:class:`bytes` and decode it into an ASN.1 object (e.g. :py:class:`~pyasn1.type.base.PyAsn1Item` derivative) which may be a scalar or an arbitrary nested structure.
(cls, substrate, asn1Spec=None, **options)
| 2013 | |
| 2014 | @classmethod |
| 2015 | def __call__(cls, substrate, asn1Spec=None, **options): |
| 2016 | """Turns BER/CER/DER octet stream into an ASN.1 object. |
| 2017 | |
| 2018 | Takes BER/CER/DER octet-stream in form of :py:class:`bytes` |
| 2019 | and decode it into an ASN.1 object |
| 2020 | (e.g. :py:class:`~pyasn1.type.base.PyAsn1Item` derivative) which |
| 2021 | may be a scalar or an arbitrary nested structure. |
| 2022 | |
| 2023 | Parameters |
| 2024 | ---------- |
| 2025 | substrate: :py:class:`bytes` |
| 2026 | BER/CER/DER octet-stream to parse |
| 2027 | |
| 2028 | Keyword Args |
| 2029 | ------------ |
| 2030 | asn1Spec: :py:class:`~pyasn1.type.base.PyAsn1Item` |
| 2031 | A pyasn1 type object (:py:class:`~pyasn1.type.base.PyAsn1Item` |
| 2032 | derivative) to act as a template guiding the decoder. |
| 2033 | Depending on the ASN.1 structure being decoded, `asn1Spec` may or |
| 2034 | may not be required. Most common reason for it to require is that |
| 2035 | ASN.1 structure is encoded in *IMPLICIT* tagging mode. |
| 2036 | |
| 2037 | substrateFun: :py:class:`Union[ |
| 2038 | Callable[[pyasn1.type.base.PyAsn1Item, bytes, int], |
| 2039 | Tuple[pyasn1.type.base.PyAsn1Item, bytes]], |
| 2040 | Callable[[pyasn1.type.base.PyAsn1Item, io.BytesIO, int, dict], |
| 2041 | Generator[Union[pyasn1.type.base.PyAsn1Item, |
| 2042 | pyasn1.error.SubstrateUnderrunError], |
| 2043 | None, None]] |
| 2044 | ]` |
| 2045 | User callback meant to generalize special use cases like non-recursive or |
| 2046 | partial decoding. A 3-arg non-streaming variant is supported for backwards |
| 2047 | compatiblilty in addition to the newer 4-arg streaming variant. |
| 2048 | The callback will receive the uninitialized object recovered from substrate |
| 2049 | as 1st argument, the uninterpreted payload as 2nd argument, and the length |
| 2050 | of the uninterpreted payload as 3rd argument. The streaming variant will |
| 2051 | additionally receive the decode(..., **options) kwargs as 4th argument. |
| 2052 | The non-streaming variant shall return an object that will be propagated |
| 2053 | as decode() return value as 1st item, and the remainig payload for further |
| 2054 | decode passes as 2nd item. |
| 2055 | The streaming variant shall yield an object that will be propagated as |
| 2056 | decode() return value, and leave the remaining payload in the stream. |
| 2057 | |
| 2058 | Returns |
| 2059 | ------- |
| 2060 | : :py:class:`tuple` |
| 2061 | A tuple of :py:class:`~pyasn1.type.base.PyAsn1Item` object |
| 2062 | recovered from BER/CER/DER substrate and the unprocessed trailing |
| 2063 | portion of the `substrate` (may be empty) |
| 2064 | |
| 2065 | Raises |
| 2066 | ------ |
| 2067 | : :py:class:`~pyasn1.error.PyAsn1Error` |
| 2068 | :py:class:`~pyasn1.error.SubstrateUnderrunError` on insufficient |
| 2069 | input or :py:class:`~pyasn1.error.PyAsn1Error` on decoding error. |
| 2070 | |
| 2071 | Examples |
| 2072 | -------- |
nothing calls this directly
no test coverage detected