HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/Cryptodome/Util/__pycache__/asn1.cpython-310.pyc
o

�N�gm��@s�ddlZddlmZmZmZddlmZmZgd�Zddd�Z	Gdd	�d	e
�ZGd
d�de
�ZGdd
�d
e�Z
Gdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)�N)�byte_string�bchr�bord)�
long_to_bytes�
bytes_to_long)	�	DerObject�
DerInteger�
DerBoolean�DerOctetString�DerNull�DerSequence�DerObjectId�DerBitString�DerSetOfFcCs4d}z||}Wn
tyYdSw|p|dkS)NrF)�	TypeError)�x�only_non_negative�test�r�H/opt/saltstack/salt/lib/python3.10/site-packages/Cryptodome/Util/asn1.py�
_is_number(s�rc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�BytesIO_EOFzeThis class differs from BytesIO in that a ValueError exception is
    raised whenever EOF is reached.cCs||_d|_d|_dS�Nr)�_buffer�_index�	_bookmark)�selfZ
initial_bytesrrr�__init__5s
zBytesIO_EOF.__init__cCs|j|_dS�N)rr�rrrr�set_bookmark:�zBytesIO_EOF.set_bookmarkcCs |jdusJ�|j|j|j�Sr)rrrrrrr�data_since_bookmark=szBytesIO_EOF.data_since_bookmarkcCst|j�|jSr)�lenrrrrrr�remaining_dataA�zBytesIO_EOF.remaining_datacCsH|j|}|t|j�krtd|t|j�f��|j|j|�}||_|S)Nz@Not enough data for DER decoding: expected %d bytes and found %d)rr#r�
ValueError)r�lengthZ	new_index�resultrrr�readDs
zBytesIO_EOF.readcCst|�d�d�S)N�r)rr)rrrr�	read_byteM�zBytesIO_EOF.read_byteN)
�__name__�
__module__�__qualname__�__doc__rr r"r$r)r+rrrrr1s	rc@sTeZdZdZ		ddd�Zdd�Zed	d
��Zdd�Zd
d�Z	ddd�Z
dd�ZdS)rzpBase class for defining a single DER object.

        This class should never be directly instantiated.
        N�FcCs�|dur	d|_dS|�|�}||_|rdnd}d||fvr!td��|dur1d|B|�|�B|_dS|durDd|�|�B|_||B|_dS||B|_dS)a�Initialize the DER object according to a specific ASN.1 type.

                :Parameters:
                  asn1Id : integer or byte
                    The universal DER tag number for this object
                    (e.g. 0x10 for a SEQUENCE).
                    If None, the tag is not known yet.

                  payload : byte string
                    The initial payload of the object (that it,
                    the content octets).
                    If not specified, the payload is empty.

                  implicit : integer or byte
                    The IMPLICIT tag number (< 0x1F) to use for the encoded object.
                    It overrides the universal tag *asn1Id*.
                    It cannot be combined with the ``explicit`` parameter.
                    By default, there is no IMPLICIT tag.

                  constructed : bool
                    True when the ASN.1 type is *constructed*.
                    False when it is *primitive* (default).

                  explicit : integer or byte
                    The EXPLICIT tag number (< 0x1F) to use for the encoded object.
                    It cannot be combined with the ``implicit`` parameter.
                    By default, there is no EXPLICIT tag.
                N� rz1Explicit and implicit tags are mutually exclusive��)�
_tag_octet�_convertTag�payloadr&�_inner_tag_octet)rZasn1Idr7�implicitZconstructed�explicitZconstructed_bitrrrrWs
zDerObject.__init__cCsPt|�st|�dkrt|d�}t|�r"d|kr!dks&td��td��|S)zCheck if *tag* is a real DER tag (5 bits).
                Convert it from a character to number if necessary.
                r*r�z
Wrong DER tag)rr#rr&)r�tagrrrr6�s�zDerObject._convertTagcCs,|dkrt|�}tt|�d�|St|�S)zXBuild length octets according to BER/DER
                definite form.
                �r3)rrr#)r'�encodingrrr�_definite_form�szDerObject._definite_formcCsL|j}t|d�rt|j�|�t|j��|j}t|j�|�t|��|S)z?Return this DER element, fully encoded as a binary byte string.r8)r7�hasattrrr8r?r#r5)rZoutput_payloadrrr�encode�s
����zDerObject.encodecCsR|��}|dkr'|�|d@�}t|d�dkrtd��t|�}|dkr'td��|S)z%Decode DER length octets from a file.r=rz$Invalid DER: length has leading zeroz5Invalid DER: length in long form but smaller than 128)r+r)rr&r)r�sr'Zencoded_lengthrrr�
_decodeLen�szDerObject._decodeLencCs<t|�std��t|�}|�||�|��dkrtd��|S)aDecode a complete DER element, and re-initializes this
                object with it.

                Args:
                  der_encoded (byte string): A complete DER element.

                Raises:
                  ValueError: in case of parsing errors.
                zInput is not a byte stringr�-Unexpected extra data after the DER structure)rr&r�_decodeFromStreamr$)r�der_encoded�strictrBrrr�decode�szDerObject.decodecCs�|��}|jdur||jkrtd��n||_|�|�}|�|�|_t|d�rMt|j�}|��}||jkr8td��|�|�}|�|�|_|�	�dkrOtd��dSdS)z*Decode a complete DER element from a file.NzUnexpected DER tagr8zUnexpected internal DER tagrrD)
r+r5r&rCr)r7r@rr8r$)rrBrGZidOctetr'�pZinner_octetrrrrE�s&

�




�	zDerObject._decodeFromStream)Nr1NFN�F)r-r.r/r0rr6�staticmethodr?rArCrHrErrrrrQs
�F
	
rc@�4eZdZdZd
dd�Zdd�Zdd	d
�Zdd�ZdS)ra�Class to model a DER INTEGER.

        An example of encoding is::

          >>> from Cryptodome.Util.asn1 import DerInteger
          >>> from binascii import hexlify, unhexlify
          >>> int_der = DerInteger(9)
          >>> print hexlify(int_der.encode())

        which will show ``020109``, the DER encoding of 9.

        And for decoding::

          >>> s = unhexlify(b'020109')
          >>> try:
          >>>   int_der = DerInteger()
          >>>   int_der.decode(s)
          >>>   print int_der.value
          >>> except ValueError:
          >>>   print "Not a valid DER INTEGER"

        the output will be ``9``.

        :ivar value: The integer value
        :vartype value: integer
        rNcC�t�|dd|d|�||_dS)aUInitialize the DER object as an INTEGER.

                :Parameters:
                  value : integer
                    The value of the integer.

                  implicit : integer
                    The IMPLICIT tag to use for the encoded object.
                    It overrides the universal tag for INTEGER (2).
                �r1FN�rr�value�rrPr9r:rrrr#s�
zDerInteger.__init__cCs||j}d|_	tt|d@��|j|_d|krdkr'nntd�|j|_d|kr1dkr4nnn|dL}qt�|�S)zIReturn the DER INTEGER, fully encoded as a
                binary string.r1T�r3ri�����)rPr7r�intrrA)r�numberrrrrA3s�
zDerInteger.encodeFcCstj|||d�S)aDecode a DER-encoded INTEGER, and re-initializes this
                object with it.

                Args:
                  der_encoded (byte string): A complete INTEGER DER element.

                Raises:
                  ValueError: in case of parsing errors.
                �rG�rrH�rrFrGrrrrHBszDerInteger.decodecCs�t�|||�|r.t|j�dkrtd��t|j�dkr.t�d|jdd��ddkr.td��d|_d}|jD]}|jd	9_|jt|�7_|d
K}q6|jrbt|jd�d@rd|j|8_dSdSdS)z*Decode a complete DER INTEGER from a file.rz/Invalid encoding for DER INTEGER: empty payloadrNz>HNr3z.Invalid encoding for DER INTEGER: leading zeror*�rS)	rrEr#r7r&�struct�unpackrPr)rrBrG�bits�irrrrEOs,

�zDerInteger._decodeFromStream)rNNrJ�r-r.r/r0rrArHrErrrrrs


rc@s4eZdZdZddd�Zdd�Zd
dd	�Zd
d�ZdS)r	aVClass to model a DER-encoded BOOLEAN.

    An example of encoding is::

    >>> from Cryptodome.Util.asn1 import DerBoolean
    >>> bool_der = DerBoolean(True)
    >>> print(bool_der.encode().hex())

    which will show ``0101ff``, the DER encoding of True.

    And for decoding::

    >>> s = bytes.fromhex('0101ff')
    >>> try:
    >>>   bool_der = DerBoolean()
    >>>   bool_der.decode(s)
    >>>   print(bool_der.value)
    >>> except ValueError:
    >>>   print "Not a valid DER BOOLEAN"

    the output will be ``True``.

    :ivar value: The boolean value
    :vartype value: boolean
    FNcCrM)a�Initialize the DER object as a BOOLEAN.

        Args:
          value (boolean):
            The value of the boolean. Default is False.

          implicit (integer or byte):
            The IMPLICIT tag number (< 0x1F) to use for the encoded object.
            It overrides the universal tag for BOOLEAN (1).
            It cannot be combined with the ``explicit`` parameter.
            By default, there is no IMPLICIT tag.

          explicit (integer or byte):
            The EXPLICIT tag number (< 0x1F) to use for the encoded object.
            It cannot be combined with the ``implicit`` parameter.
            By default, there is no EXPLICIT tag.
        r*r1FNrOrQrrrr�s
zDerBoolean.__init__cCs|jrdnd|_t�|�S)z9Return the DER BOOLEAN, fully encoded as a binary string.����rPr7rrArrrrrA�s
zDerBoolean.encodecC�t�|||�S)z�Decode a DER-encoded BOOLEAN, and re-initializes this object with it.

        Args:
            der_encoded (byte string): A DER-encoded BOOLEAN.

        Raises:
            ValueError: in case of parsing errors.
        rWrXrrrrH�s
zDerBoolean.decodecCsdt�|||�t|j�dkrtd��t|jd�dkr d|_dSt|jd�dkr.d|_dStd��)	z)Decode a DER-encoded BOOLEAN from a file.r*z7Invalid encoding for DER BOOLEAN: payload is not 1 byterFrRTzInvalid payload for DER BOOLEANN)rrEr#r7r&rrP�rrBrGrrrrE�s

zDerBoolean._decodeFromStream)FNNrJr^rrrrr	fs

r	c@s�eZdZdZd%dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zd&dd�Zd&dd�Zdd�Zd'd!d"�Zd#d$�ZdS)(ra�Class to model a DER SEQUENCE.

        This object behaves like a dynamic Python sequence.

        Sub-elements that are INTEGERs behave like Python integers.

        Any other sub-element is a binary string encoded as a complete DER
        sub-element (TLV).

        An example of encoding is:

          >>> from Cryptodome.Util.asn1 import DerSequence, DerInteger
          >>> from binascii import hexlify, unhexlify
          >>> obj_der = unhexlify('070102')
          >>> seq_der = DerSequence([4])
          >>> seq_der.append(9)
          >>> seq_der.append(obj_der.encode())
          >>> print hexlify(seq_der.encode())

        which will show ``3009020104020109070102``, the DER encoding of the
        sequence containing ``4``, ``9``, and the object with payload ``02``.

        For decoding:

          >>> s = unhexlify(b'3009020104020109070102')
          >>> try:
          >>>   seq_der = DerSequence()
          >>>   seq_der.decode(s)
          >>>   print len(seq_der)
          >>>   print seq_der[0]
          >>>   print seq_der[:]
          >>> except ValueError:
          >>>   print "Not a valid DER SEQUENCE"

        the output will be::

          3
          4
          [4, 9, b'']

        NcCs0t�|dd|d|�|durg|_dS||_dS)aCInitialize the DER object as a SEQUENCE.

                :Parameters:
                  startSeq : Python sequence
                    A sequence whose element are either integers or
                    other DER objects.

                  implicit : integer or byte
                    The IMPLICIT tag number (< 0x1F) to use for the encoded object.
                    It overrides the universal tag for SEQUENCE (16).
                    It cannot be combined with the ``explicit`` parameter.
                    By default, there is no IMPLICIT tag.

                  explicit : integer or byte
                    The EXPLICIT tag number (< 0x1F) to use for the encoded object.
                    It cannot be combined with the ``implicit`` parameter.
                    By default, there is no EXPLICIT tag.
                �r1TN)rr�_seq)rZstartSeqr9r:rrrr�s

zDerSequence.__init__cCs|j|=dSr�re�r�nrrr�__delitem__r!zDerSequence.__delitem__cC�
|j|Srrfrgrrr�__getitem__�
zDerSequence.__getitem__cCs||j|<dSrrf)r�keyrPrrr�__setitem__szDerSequence.__setitem__cCs||j||�<dSrrf)rr]�jZsequencerrr�__setslice__	r,zDerSequence.__setslice__cCs|j||�=dSrrf�rr]rorrr�__delslice__r%zDerSequence.__delslice__cCs|jtd|�td|��Sr)re�maxrqrrr�__getslice__szDerSequence.__getslice__cC�
t|j�Sr�r#rerrrr�__len__rlzDerSequence.__len__cC�|j�|�|Sr�re�append�r�itemrrr�__iadd__�zDerSequence.__iadd__cCrxrryr{rrrrzr~zDerSequence.appendcCs|j�||�|Sr)re�insert)r�indexr|rrrrszDerSequence.insertTcs�fdd�|jD�}t|�S)z�Return the number of items in this sequence that are
                integers.

                Args:
                  only_non_negative (boolean):
                    If ``True``, negative integers are not counted in.
                csg|]	}t|��r|�qSr)r��.0r�rrr�
<listcomp>*sz'DerSequence.hasInts.<locals>.<listcomp>)rer#)rr�itemsrr�r�hasInts!s	zDerSequence.hasIntscCs|jo|�|�t|j�kS)a�Return ``True`` if all items in this sequence are integers
                or non-negative integers.

                This function returns False is the sequence is empty,
                or at least one member is not an integer.

                Args:
                  only_non_negative (boolean):
                    If ``True``, the presence of negative integers
                    causes the method to return ``False``.)rer�r#)rrrrr�hasOnlyInts-szDerSequence.hasOnlyIntscCsfd|_|jD]'}t|�r|j|7_qt|�r$|jt|���7_q|j|��7_qt�|�S)z�Return this DER SEQUENCE, fully encoded as a
                binary string.

                Raises:
                  ValueError: if some elements in the sequence are neither integers
                              nor byte strings.
                r1)r7rerrrrArr{rrrrA:s

zDerSequence.encodeFcCs.||_tj|||d�}|r|��std��|S)a9Decode a complete DER SEQUENCE, and re-initializes this
                object with it.

                Args:
                  der_encoded (byte string):
                    A complete SEQUENCE DER element.
                  nr_elements (None or integer or list of integers):
                    The number of members the SEQUENCE can have
                  only_ints_expected (boolean):
                    Whether the SEQUENCE is expected to contain only integers.
                  strict (boolean):
                    Whether decoding must check for strict DER compliancy.

                Raises:
                  ValueError: in case of parsing errors.

                DER INTEGERs are decoded into Python integers. Any other DER
                element is not decoded. Its validity is not checked.
                rVzSome members are not INTEGERs)�_nr_elementsrrHr�r&)rrFrGZnr_elementsZonly_ints_expectedr(rrrrHLs
zDerSequence.decodecCs�g|_t�|||�t|j�}|��dkrK|��t�}|�||�|jdkr0|j�|�	��nt
�}|�	�}|j||d�|j�|j�|��dksd}|j
durnz
t|j�|j
v}Wntymt|j�|j
k}Ynw|sytdt|j���dS)z+Decode a complete DER SEQUENCE from a file.rrNrVTNz1Unexpected number of members (%d) in the sequence)rerrErr7r$r r5rzr"rrHrPr�r#rr&)rrBrGrI�der�derInt�data�okrrrrEis4

�
���zDerSequence._decodeFromStream)NNN)T)FNF)r-r.r/r0rrirkrnrprrrtrwr}rzrr�r�rArHrErrrrr�s$
*


rc@seZdZdZddd�ZdS)r
a�Class to model a DER OCTET STRING.

    An example of encoding is:

    >>> from Cryptodome.Util.asn1 import DerOctetString
    >>> from binascii import hexlify, unhexlify
    >>> os_der = DerOctetString(b'\xaa')
    >>> os_der.payload += b'\xbb'
    >>> print hexlify(os_der.encode())

    which will show ``0402aabb``, the DER encoding for the byte string
    ``b'\xAA\xBB'``.

    For decoding:

    >>> s = unhexlify(b'0402aabb')
    >>> try:
    >>>   os_der = DerOctetString()
    >>>   os_der.decode(s)
    >>>   print hexlify(os_der.payload)
    >>> except ValueError:
    >>>   print "Not a valid DER OCTET STRING"

    the output will be ``aabb``.

    :ivar payload: The content of the string
    :vartype payload: byte string
    r1NcCst�|d||d�dS)ahInitialize the DER object as an OCTET STRING.

        :Parameters:
          value : byte string
            The initial payload of the object.
            If not specified, the payload is empty.

          implicit : integer
            The IMPLICIT tag to use for the encoded object.
            It overrides the universal tag for OCTET STRING (4).
        �FN�rr)rrPr9rrrr�szDerOctetString.__init__)r1N�r-r.r/r0rrrrrr
�sr
c@seZdZdZdd�ZdS)rz"Class to model a DER NULL element.cCst�|dddd�dS)z$Initialize the DER object as a NULL.�r1NFr�rrrrr�szDerNull.__init__Nr�rrrrr�src@rL)r
a,Class to model a DER OBJECT ID.

    An example of encoding is:

    >>> from Cryptodome.Util.asn1 import DerObjectId
    >>> from binascii import hexlify, unhexlify
    >>> oid_der = DerObjectId("1.2")
    >>> oid_der.value += ".840.113549.1.1.1"
    >>> print hexlify(oid_der.encode())

    which will show ``06092a864886f70d010101``, the DER encoding for the
    RSA Object Identifier ``1.2.840.113549.1.1.1``.

    For decoding:

    >>> s = unhexlify(b'06092a864886f70d010101')
    >>> try:
    >>>   oid_der = DerObjectId()
    >>>   oid_der.decode(s)
    >>>   print oid_der.value
    >>> except ValueError:
    >>>   print "Not a valid DER OBJECT ID"

    the output will be ``1.2.840.113549.1.1.1``.

    :ivar value: The Object ID (OID), a dot separated list of integers
    :vartype value: string
    �NcCrM)a�Initialize the DER object as an OBJECT ID.

        :Parameters:
          value : string
            The initial Object Identifier (e.g. "1.2.0.0.6.2").
          implicit : integer
            The IMPLICIT tag to use for the encoded object.
            It overrides the universal tag for OBJECT ID (6).
          explicit : integer
            The EXPLICIT tag to use for the encoded object.
        �r1FNrOrQrrrr�s
zDerObjectId.__init__cCs�dd�|j�d�D�}t|�dkrtd��|ddkrtd��|ddkr/|dd	kr/td
��d|d|dg|dd�}g}t|�D]}|�|d
@�|dL}|rd|�|d
@dB�|dL}|sUqFd�dd�t|�D��|_t�	|�S)zCReturn the DER OBJECT ID, fully encoded as a
        binary string.cS�g|]}t|��qSr)rTr�rrrr���z&DerObjectId.encode.<locals>.<listcomp>�.rNz$Not a valid Object Identifier stringrz!First component must be 0, 1 or 2r*�'z#Second component must be 39 at most�(Nr=�r3r1cSr�r)rr�rrrr�r�)
rP�splitr#r&�reversedrz�joinr7rrA)r�comps�subcompsr>�vrrrrA�s&"��
zDerObjectId.encodeFcCrb)abDecode a complete DER OBJECT ID, and re-initializes this
        object with it.

        Args:
            der_encoded (byte string):
                A complete DER OBJECT ID.
            strict (boolean):
                Whether decoding must check for strict DER compliancy.

        Raises:
            ValueError: in case of parsing errors.
        rWrXrrrrHszDerObjectId.decodecCs�t�|||�t|j�}g}d}|��r/|��}|d>|d@}|d@s+|�|�d}|��st|�dkr9td��|ddkrJd|dg|dd�<n|dd	kr]d|ddg|dd�<nd
|dd	g|dd�<d�	dd
�|D��|_
dS)z,Decode a complete DER OBJECT ID from a file.rr�r=r3z
Empty payloadr�Nr*�PrNr�cSr�r)�strr�rrrr�7r�z1DerObjectId._decodeFromStream.<locals>.<listcomp>)rrErr7r$r+rzr#r&r�rP)rrBrGrIr�r��crrrrEs&

�zDerObjectId._decodeFromStream)r�NNrJr^rrrrr
�s

r
c@rL)ra�Class to model a DER BIT STRING.

    An example of encoding is:

    >>> from Cryptodome.Util.asn1 import DerBitString
    >>> bs_der = DerBitString(b'\xAA')
    >>> bs_der.value += b'\xBB'
    >>> print(bs_der.encode().hex())

    which will show ``030300aabb``, the DER encoding for the bit string
    ``b'\xAA\xBB'``.

    For decoding:

    >>> s = bytes.fromhex('030300aabb')
    >>> try:
    >>>   bs_der = DerBitString()
    >>>   bs_der.decode(s)
    >>>   print(bs_der.value.hex())
    >>> except ValueError:
    >>>   print "Not a valid DER BIT STRING"

    the output will be ``aabb``.

    :ivar value: The content of the string
    :vartype value: byte string
    r1NcCs6t�|dd|d|�t|t�r|��|_dS||_dS)a�Initialize the DER object as a BIT STRING.

        :Parameters:
          value : byte string or DER object
            The initial, packed bit string.
            If not specified, the bit string is empty.
          implicit : integer
            The IMPLICIT tag to use for the encoded object.
            It overrides the universal tag for BIT STRING (3).
          explicit : integer
            The EXPLICIT tag to use for the encoded object.
        �r1FN)rr�
isinstancerArPrQrrrrWs

zDerBitString.__init__cCsd|j|_t�|�S)zBReturn the DER BIT STRING, fully encoded as a
        byte string.r`rarrrrrAls
zDerBitString.encodeFcCrb)aTDecode a complete DER BIT STRING, and re-initializes this
        object with it.

        Args:
            der_encoded (byte string): a complete DER BIT STRING.
            strict (boolean):
                Whether decoding must check for strict DER compliancy.

        Raises:
            ValueError: in case of parsing errors.
        rWrXrrrrHts
zDerBitString.decodecCsRt�|||�|jrt|jd�dkrtd��d|_|jr'|jdd�|_dSdS)z1Decode a complete DER BIT STRING DER from a file.rzNot a valid BIT STRINGr1r*N)rrEr7rr&rPrcrrrrE�s�zDerBitString._decodeFromStream)r1NNrJr^rrrrr:s

rc@sTeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zddd�Z	dd�Z
dd�ZdS)ra�Class to model a DER SET OF.

    An example of encoding is:

    >>> from Cryptodome.Util.asn1 import DerBitString
    >>> from binascii import hexlify, unhexlify
    >>> so_der = DerSetOf([4,5])
    >>> so_der.add(6)
    >>> print hexlify(so_der.encode())

    which will show ``3109020104020105020106``, the DER encoding
    of a SET OF with items 4,5, and 6.

    For decoding:

    >>> s = unhexlify(b'3109020104020105020106')
    >>> try:
    >>>   so_der = DerSetOf()
    >>>   so_der.decode(s)
    >>>   print [x for x in so_der]
    >>> except ValueError:
    >>>   print "Not a valid DER SET OF"

    the output will be ``[4, 5, 6]``.
    NcCs>t�|dd|d�g|_d|_|r|D]	}|�|�qdSdS)a9Initialize the DER object as a SET OF.

        :Parameters:
          startSet : container
            The initial set of integers or DER encoded objects.
          implicit : integer
            The IMPLICIT tag to use for the encoded object.
            It overrides the universal tag for SET OF (17).
        �r1TN)rrre�
_elemOctet�add)rZstartSetr9�errrr�s
�zDerSetOf.__init__cCrjrrfrgrrrrk�rlzDerSetOf.__getitem__cCrur)�iterrerrrr�__iter__�rlzDerSetOf.__iter__cCrurrvrrrrrw�rlzDerSetOf.__len__cCslt|�rd}nt|t�r|j}nt|d�}|j|kr'|jdur$td��||_||jvr4|j�|�dSdS)z�Add an element to the set.

        Args:
            elem (byte string or integer):
              An element of the same type of objects already in the set.
              It can be an integer or a DER encoded object.
        rNrNz&New element does not belong to the set)	rr�rr5rr�r&rerz)r�elem�eorrrr��s	



�zDerSetOf.addFcCrb)a�Decode a complete SET OF DER element, and re-initializes this
        object with it.

        DER INTEGERs are decoded into Python integers. Any other DER
        element is left undecoded; its validity is not checked.

        Args:
            der_encoded (byte string): a complete DER BIT SET OF.
            strict (boolean):
                Whether decoding must check for strict DER compliancy.

        Raises:
            ValueError: in case of parsing errors.
        rWrXrrrrH�szDerSetOf.decodecCs�g|_t�|||�t|j�}d}|��dkr\|��t�}|�||�|dkr,|j}n	||jkr5td��|dkrB|j�	|�
��nt�}|�|�
�|�|j�	|j
�|��dksdSdS)z)Decode a complete DER SET OF from a file.���rz)Not all elements are of the same DER typerNN)rerrErr7r$r r5r&rzr"rrHrP)rrBrGrIZ
setIdOctetr�r�rrrrE�s$

�zDerSetOf._decodeFromStreamcCsfg}|jD]}t|�rt|���}nt|t�r|��}n|}|�|�q|��d�|�|_	t�|�S)zRReturn this SET OF DER element, fully encoded as a
        binary string.
        r1)
rerrrAr�rrz�sortr�r7)rZorderedr|ZbysrrrrAs



zDerSetOf.encode)NNrJ)r-r.r/r0rrkr�rwr�rHrErArrrrr�s

!rrJ)rZZCryptodome.Util.py3compatrrrZCryptodome.Util.numberrr�__all__r�objectrrrr	rr
rr
rrrrrr�<module>s"
	 7_SV-	vY