Ë
    (üàgI�  ã                   ó  — d dl Z d dlmZmZmZ d dlmZmZ g d¢Zdd„Z	 G d„ de
«      Z G d„ d	e
«      Z G d
„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Zy)é    N)Úbyte_stringÚbchrÚbord)Úlong_to_bytesÚbytes_to_long)	Ú	DerObjectÚ
DerIntegerÚ
DerBooleanÚDerOctetStringÚDerNullÚDerSequenceÚDerObjectIdÚDerBitStringÚDerSetOfc                 óD   — d}	 | |z   }| xs | dk\  S # t         $ r Y yw xY w)Nr   F)Ú	TypeError)ÚxÚonly_non_negativeÚtests      úN/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/Crypto/Util/asn1.pyÚ
_is_numberr   (   s=   € Ø€DðØ�4‰xˆð !Ð Ò* A¨¡FÐ*øô ò Ùðús   „ “	žc                   ó4   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	y)	ÚBytesIO_EOFzeThis class differs from BytesIO in that a ValueError exception is
    raised whenever EOF is reached.c                 ó.   — || _         d| _        d | _        y ©Nr   )Ú_bufferÚ_indexÚ	_bookmark)ÚselfÚinitial_bytess     r   Ú__init__zBytesIO_EOF.__init__5   s   € Ø$ˆŒØˆŒØˆ�ó    c                 ó&   — | j                   | _        y ©N)r   r   ©r   s    r   Úset_bookmarkzBytesIO_EOF.set_bookmark:   s   € ØŸ™ˆ�r"   c                 ód   — | j                   €J ‚| j                  | j                   | j                   S r$   )r   r   r   r%   s    r   Údata_since_bookmarkzBytesIO_EOF.data_since_bookmark=   s+   € Ø�~‰~Ð)Ð)Ð)Ø�|‰|˜DŸN™N¨4¯;©;Ð7Ð7r"   c                 óF   — t        | j                  «      | j                  z
  S r$   )Úlenr   r   r%   s    r   Úremaining_datazBytesIO_EOF.remaining_dataA   s   € Ü�4—<‘<Ó  4§;¡;Ñ.Ð.r"   c                 óÚ   — | j                   |z   }|t        | j                  «      kD  r#t        d|t        | j                  «      fz  «      ‚| j                  | j                   | }|| _         |S )Nz@Not enough data for DER decoding: expected %d bytes and found %d)r   r*   r   Ú
ValueError)r   ÚlengthÚ	new_indexÚresults       r   ÚreadzBytesIO_EOF.readD   sr   € Ø—K‘K &Ñ(ˆ	Ø”s˜4Ÿ<™<Ó(Ò(ÜÐ_ÐclÔnqÐrv×r~Ñr~Ónð  cAñ  Aó  Bð  Bà—‘˜dŸk™k¨)Ð4ˆØˆŒØˆr"   c                 ó<   — t        | j                  d«      d   «      S )Né   r   )r   r1   r%   s    r   Ú	read_bytezBytesIO_EOF.read_byteM   s   € Ü�D—I‘I˜a“L ‘OÓ$Ð$r"   N)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r!   r&   r(   r+   r1   r4   © r"   r   r   r   1   s%   „ ñ'òò
%ò8ò/òó%r"   r   c                   óL   — e Zd ZdZ	 	 d
d„Zd„ Zed„ «       Zd„ Zd„ Z	dd„Z
d	„ Zy)r   zpBase class for defining a single DER object.

        This class should never be directly instantiated.
        Nc                 ó  — |€d| _         y| j                  |«      }|| _        |rdnd}d||fvrt        d«      ‚|�d|z  | j                  |«      z  | _         y|�$d| j                  |«      z  | _         ||z  | _        y||z  | _         y)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é    r   z1Explicit and implicit tags are mutually exclusiveé€   é    )Ú
_tag_octetÚ_convertTagÚpayloadr-   Ú_inner_tag_octet)r   Úasn1IdrA   ÚimplicitÚconstructedÚexplicitÚconstructed_bits          r   r!   zDerObject.__init__W   s±   € ð> �>à&*�D”OØØ×)Ñ)¨&Ó1�à&�”ñ  +6¡$¸4�à ¨(Ð3Ñ3Ü$ð &;ó <ð <ð Ð'à&*¨_Ñ&<¸t×?OÑ?OÐPXÓ?YÑ&Y�D•OØÐ)à&1°D×4DÑ4DÀXÓ4NÑ&N�D”OØ,;¸fÑ,D�DÕ)ð '6¸Ñ&>�D•Or"   c                 ó®   — t        |«      st        |«      dk(  rt        |d   «      }t        |«      rd|cxk  rdk  st        d«      ‚ t        d«      ‚|S )zCheck if *tag* is a real DER tag (5 bits).
                Convert it from a character to number if necessary.
                r3   r   é   zWrong DER tag)r   r*   r   r-   )r   Útags     r   r@   zDerObject._convertTag�   sT   € ô " #”Ü˜3“x 1’}Ü" 3 q¡6›l˜ä" 3œ¨A°¬O°tªOÜ$ _Ó5Ð5ð -<Ü$ _Ó5Ð5Ø�
r"   c                 ól   — | dkD  r%t        | «      }t        t        |«      dz   «      |z   S t        | «      S )zXBuild length octets according to BER/DER
                definite form.
                é   r=   )r   r   r*   )r.   Úencodings     r   Ú_definite_formzDerObject._definite_form©   s8   € ð
 ˜C’<Ü#0°Ó#8˜Ü#¤C¨£M°CÑ$7Ó8¸8ÑCÐCÜ˜F“|Ð#r"   c                 ó&  — | j                   }t        | d«      rGt        | j                  «      | j	                  t        | j                   «      «      z   | j                   z   }t        | j                  «      | j	                  t        |«      «      z   |z   S )z?Return this DER element, fully encoded as a binary byte string.rB   )rA   Úhasattrr   rB   rN   r*   r?   )r   Úoutput_payloads     r   ÚencodezDerObject.encode³   s‡   € ð "&§¡�ô ˜4Ð!3Ô4Ü&*¨4×+@Ñ+@Ó&AØ&*×&9Ñ&9¼#¸d¿l¹lÓ:KÓ&Lñ'Mà&*§l¡lñ'3�Nô ˜TŸ_™_Ó-Ø×+Ñ+¬C°Ó,?Ó@ñAà&ñ'ð (r"   c                 óÆ   — |j                  «       }|dkD  rK|j                  |dz  «      }t        |d   «      dk(  rt        d«      ‚t	        |«      }|dk  rt        d«      ‚|S )z%Decode DER length octets from a file.rL   r   z$Invalid DER: length has leading zeroz5Invalid DER: length in long form but smaller than 128)r4   r1   r   r-   r   )r   Úsr.   Úencoded_lengths       r   Ú
_decodeLenzDerObject._decodeLenÆ   sh   € ð Ÿ™›�à˜C’<Ø%&§V¡V¨F°T©MÓ%:�NÜ˜N¨1Ñ-Ó.°!Ò3Ü(Ð)OÓPÐPÜ*¨>Ó:�FØ ’}Ü(Ð)`ÓaÐaà�r"   c                 ó¨   — t        |«      st        d«      ‚t        |«      }| j                  ||«       |j	                  «       dkD  rt        d«      ‚| S )a  Decode 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.
                zInput is not a byte stringr   ú-Unexpected extra data after the DER structure)r   r-   r   Ú_decodeFromStreamr+   )r   Úder_encodedÚstrictrT   s       r   ÚdecodezDerObject.decodeÕ   sV   € ô # ;Ô/Ü$Ð%AÓBÐBä Ó,�Ø×&Ñ& q¨&Ô1ð ×#Ñ#Ó%¨Ò)Ü$Ð%TÓUÐUà�r"   c                 óî  — |j                  «       }| j                  �|| j                  k7  rt        d«      ‚|| _        | j                  |«      }|j	                  |«      | _        t        | d«      r…t        | j
                  «      }|j                  «       }|| j                  k7  rt        d«      ‚| j                  |«      }|j	                  |«      | _        |j                  «       dkD  rt        d«      ‚yy)z*Decode a complete DER element from a file.NzUnexpected DER tagrB   zUnexpected internal DER tagr   rX   )
r4   r?   r-   rV   r1   rA   rP   r   rB   r+   )r   rT   r[   ÚidOctetr.   ÚpÚinner_octets          r   rY   zDerObject._decodeFromStreamì   sÛ   € ð Ÿ+™+›-�Ø—?‘?Ð.Ø $§/¡/Ò1Ü(Ð)=Ó>Ð>à&-�D”OØŸ™¨Ó+�Ø Ÿv™v f›~�”ô ˜4Ð!3Ô4Ü# D§L¡LÓ1�AØ"#§+¡+£-�KØ" d×&;Ñ&;Ò;Ü(Ð)FÓGÐGØ!Ÿ_™_¨QÓ/�FØ#$§6¡6¨&£>�D”Lð ×'Ñ'Ó)¨AÒ-Ü(Ð)XÓYÐYð .ð 5r"   )Nr"   NFN©F)r5   r6   r7   r8   r!   r@   ÚstaticmethodrN   rR   rV   r\   rY   r9   r"   r   r   r   Q   sE   „ ñ	ð
 ?CØ15óD	?òL
	ð 
ñ	$ó 
ð	$ò	(ò&	ó	ó.	Zr"   r   c                   ó,   — e Zd ZdZdd„Zd„ Zdd„Zd„ Zy)	r	   aÈ  Class to model a DER INTEGER.

        An example of encoding is::

          >>> from Crypto.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
        Nc                 óF   — t         j                  | dd|d|«       || _        y)aU  Initialize 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).
                é   r"   FN©r   r!   Úvalue©r   rg   rD   rF   s       r   r!   zDerInteger.__init__#  s&   € ô ×"Ñ" 4¨¨s°HØ#(¨(ô4à"�•
r"   c                 ó&  — | j                   }d| _        	 t        t        |dz  «      «      | j                  z   | _        d|cxk  rdk  r n nt        d«      | j                  z   | _        d|cxk  rdk  rn nn|dz  }Œit        j                  | «      S )zIReturn the DER INTEGER, fully encoded as a
                binary string.r"   éÿ   r=   r   i€ÿÿÿé   )rg   rA   r   Úintr   rR   )r   Únumbers     r   rR   zDerInteger.encode3  s‡   € ð Ÿ™�Ø"�”ØÜ#'¬¨F°S©LÓ(9Ó#:¸T¿\¹\Ñ#I�D”LØ˜fÔ+¨Õ+Ü'+¨D£z°D·L±LÑ'@˜œØ˜vÔ,¨Õ,ØØ˜q‘L�Fð ô !×'Ñ'¨Ó-Ð-r"   c                 ó2   — t         j                  | ||¬«      S )a  Decode 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.
                ©r[   ©r   r\   ©r   rZ   r[   s      r   r\   zDerInteger.decodeB  s   € ô !×'Ñ'¨¨kÀ&Ð'ÓIÐIr"   c                 ó4  — t         j                  | ||«       |rot        | j                  «      dk(  rt	        d«      ‚t        | j                  «      dk\  r4t        j                  d| j                  dd «      d   dk  rt	        d«      ‚d| _        d}| j                  D ]:  }| xj                  d	z  c_        | xj                  t        |«      z  c_        |d
z  }Œ< | j                  r2t        | j                  d   «      dz  r| xj                  |z  c_        yyy)z*Decode a complete DER INTEGER from a file.r   z/Invalid encoding for DER INTEGER: empty payloadre   z>HNr=   z.Invalid encoding for DER INTEGER: leading zeror3   é   rk   )	r   rY   r*   rA   r-   ÚstructÚunpackrg   r   )r   rT   r[   ÚbitsÚis        r   rY   zDerInteger._decodeFromStreamO  sö   € ô ×+Ñ+¨D°!°VÔ<áÜ˜4Ÿ<™<Ó(¨AÒ-Ü(Ð)ZÓ[Ð[Ü˜4Ÿ<™<Ó(¨AÒ-´&·-±-ÀÀdÇlÁlÐSUÐTUÐFVÓ2WÐXYÑ2ZÐ]aÒ2aÜ(Ð)YÓZÐZð �”
Ø�ØŸ™ò �AØ—J’J #Ñ%•JØ—J’J¤$ q£'Ñ)•JØ˜Q‘J‘Dðð —<’<¤D¨¯©°a©Ó$9¸DÒ$@Ø—J’J $Ñ&–Jð %A�<r"   )r   NNra   ©r5   r6   r7   r8   r!   rR   r\   rY   r9   r"   r   r	   r	     s   „ ñ	ó6	#ò 	.ó	Jó	'r"   r	   c                   ó,   — e Zd ZdZdd„Zd„ Zdd„Zd„ Zy)	r
   aR  Class to model a DER-encoded BOOLEAN.

    An example of encoding is::

    >>> from Crypto.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
    Nc                 óF   — t         j                  | dd|d|«       || _        y)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.
        r3   r"   FNrf   rh   s       r   r!   zDerBoolean.__init__€  s#   € ô& 	×Ñ˜4  s¨H°e¸XÔFØˆ�
r"   c                 óV   — | j                   rdnd| _        t        j                  | «      S )z9Return the DER BOOLEAN, fully encoded as a binary string.ó   ÿó    ©rg   rA   r   rR   r%   s    r   rR   zDerBoolean.encode–  s$   € ð #'§*¢*‘w°'ˆŒÜ×Ñ Ó%Ð%r"   c                 ó0   — t         j                  | ||«      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.
        rp   rq   s      r   r\   zDerBoolean.decodeœ  s   € ô ×Ñ  k°6Ó:Ð:r"   c                 ó  — t         j                  | ||«       t        | j                  «      dk7  rt	        d«      ‚t        | j                  d   «      dk(  rd| _        yt        | j                  d   «      dk(  rd| _        yt	        d«      ‚)	z)Decode a DER-encoded BOOLEAN from a file.r3   z7Invalid encoding for DER BOOLEAN: payload is not 1 byter   Frj   TzInvalid payload for DER BOOLEANN)r   rY   r*   rA   r-   r   rg   ©r   rT   r[   s      r   rY   zDerBoolean._decodeFromStream¨  sw   € ô 	×#Ñ# D¨!¨VÔ4äˆt�|‰|Ó Ò!ÜÐVÓWÐWä�—‘˜Q‘Ó  AÒ%ØˆD�JÜ�$—,‘,˜q‘/Ó" dÒ*ØˆD�JäÐ>Ó?Ð?r"   )FNNra   rx   r9   r"   r   r
   r
   f  s   „ ñó2ò,&ó
;ó@r"   r
   c                   óx   — e Zd ZdZdd„Zd„ Zd„ Zd„ Zd„ Zd„ Z	d	„ Z
d
„ Zd„ Zd„ Zd„ Zdd„Zdd„Zd„ Zdd„Zd„ Zy)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 Crypto.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'']

        Nc                 óZ   — t         j                  | dd|d|«       |€g | _        y|| _        y)aC  Initialize 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.
                é   r"   TN)r   r!   Ú_seq)r   ÚstartSeqrD   rF   s       r   r!   zDerSequence.__init__ä  s0   € ô( ×"Ñ" 4¨¨s°H¸dÀHÔMØÐ#Ø "�D•Ià (�D•Ir"   c                 ó   — | j                   |= y r$   ©r…   ©r   Úns     r   Ú__delitem__zDerSequence.__delitem__   s   € Ø—I‘I˜a‘Lr"   c                 ó    — | j                   |   S r$   rˆ   r‰   s     r   Ú__getitem__zDerSequence.__getitem__  s   € Ø—y‘y ‘|Ð#r"   c                 ó"   — || j                   |<   y r$   rˆ   )r   Úkeyrg   s      r   Ú__setitem__zDerSequence.__setitem__  s   € Ø!&�—	‘	˜#’r"   c                 ó"   — || j                   || y r$   rˆ   )r   rw   ÚjÚsequences       r   Ú__setslice__zDerSequence.__setslice__	  s   € Ø!)�—	‘	˜!˜A‘r"   c                 ó"   — | j                   ||…= y r$   rˆ   ©r   rw   r’   s      r   Ú__delslice__zDerSequence.__delslice__  s   € Ø—I‘I˜a ˜c‘Nr"   c                 óH   — | j                   t        d|«      t        d|«       S r   )r…   Úmaxr–   s      r   Ú__getslice__zDerSequence.__getslice__  s   € Ø—y‘y¤ Q¨£¬3¨q°!«9Ð5Ð5r"   c                 ó,   — t        | j                  «      S r$   ©r*   r…   r%   s    r   Ú__len__zDerSequence.__len__  s   € Ü˜4Ÿ9™9“~Ð%r"   c                 ó<   — | j                   j                  |«       | S r$   ©r…   Úappend©r   Úitems     r   Ú__iadd__zDerSequence.__iadd__  ó   € Ø—	‘	× Ñ  Ô&Ø�r"   c                 ó<   — | j                   j                  |«       | S r$   rŸ   r¡   s     r   r    zDerSequence.append  r¤   r"   c                 ó>   — | j                   j                  ||«       | S r$   )r…   Úinsert)r   Úindexr¢   s      r   r§   zDerSequence.insert  s   € Ø—	‘	× Ñ  ¨Ô-Ø�r"   c                 ón   — | j                   D �cg c]  }t        ||«      sŒ|‘Œ }}t        |«      S c c}w )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.
                )r…   r   r*   )r   r   r   Úitemss       r   ÚhasIntszDerSequence.hasInts!  s5   € ð %)§I¡IÖR˜q´¸AÐ?PÕ1QšÐR�ÐRÜ˜5“zÐ!ùò Ss   �2¡2c                 ól   — | j                   xr' | j                  |«      t        | j                   «      k(  S )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``.)r…   r«   r*   )r   r   s     r   ÚhasOnlyIntszDerSequence.hasOnlyInts-  s*   € ð —y‘yÒV T§\¡\Ð2CÓ%DÌÈDÏIÉIËÑ%VÐVr"   c                 óT  — d| _         | j                  D ]~  }t        |«      r| xj                   |z  c_         Œ$t        |«      r-| xj                   t	        |«      j                  «       z  c_         Œ\| xj                   |j                  «       z  c_         Œ€ t        j                  | «      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.
                r"   )rA   r…   r   r   r	   rR   r   r¡   s     r   rR   zDerSequence.encode:  s   € ð  #�”Ø ŸI™Iò 6�DÜ" 4Ô(ØŸš¨Ñ,žÜ# DÔ)ØŸš¬
°4Ó(8×(?Ñ(?Ó(AÑAžàŸš¨¯©«Ñ5žð6ô !×'Ñ'¨Ó-Ð-r"   c                 ó~   — || _         t        j                  | ||¬«      }|r| j                  «       st	        d«      ‚|S )a9  Decode 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.
                ro   zSome members are not INTEGERs)Ú_nr_elementsr   r\   r­   r-   )r   rZ   r[   Únr_elementsÚonly_ints_expectedr0   s         r   r\   zDerSequence.decodeL  sB   € ð* %0�Ô!Ü"×)Ñ)¨$°ÀFÐ)ÓK�á%¨d×.>Ñ.>Ô.@Ü$Ð%DÓEÐEà�r"   c                 ó.  — g | _         t        j                  | ||«       t        | j                  «      }|j                  «       dkD  rË|j                  «        t        «       }|j                  ||«       |j                  dk7  r*| j                   j                  |j                  «       «       nRt        «       }|j                  «       }|j                  ||¬«       | j                   j                  |j                  «       |j                  «       dkD  rŒËd}| j                  �"	 t        | j                   «      | j                  v }|s!t!        dt        | j                   «      z  «      ‚y# t        $ r% t        | j                   «      | j                  k(  }Y ŒQw xY w)z+Decode a complete DER SEQUENCE from a file.r   re   ro   TNz1Unexpected number of members (%d) in the sequence)r…   r   rY   r   rA   r+   r&   r?   r    r(   r	   r\   rg   r°   r*   r   r-   )r   rT   r[   r_   ÚderÚderIntÚdataÚoks           r   rY   zDerSequence._decodeFromStreami  sc  € ð �”	ô ×+Ñ+¨D°!°VÔ<ô   §¡Ó-�Ø×&Ñ&Ó(¨1Ò,Ø—N‘NÔ$ä#›+�CØ×)Ñ)¨!¨VÔ4ð —~‘~¨Ò-ØŸ	™	×(Ñ(¨×)>Ñ)>Ó)@ÕAä!+£˜Ø ×4Ñ4Ó6˜ØŸ™ d°6˜Ô:ØŸ	™	×(Ñ(¨¯©Ô6ð ×&Ñ&Ó(¨1Ó,ð �Ø×$Ñ$Ð0ðAÜ  §¡›^¨t×/@Ñ/@Ð@˜ñ Ü$ð &8Ü:=¸d¿i¹i».ñ&Ió Jð Jð øô %ò AÜ  §¡›^¨t×/@Ñ/@Ñ@šðAús   Ä!!E& Å&+FÆF)NNN)T)FNF)r5   r6   r7   r8   r!   r‹   r�   r�   r”   r—   rš   r�   r£   r    r§   r«   r­   rR   r\   rY   r9   r"   r   r   r   ¹  sZ   „ ñ(	óT	)ò8	!ò	$ò	'ò	*ò	#ò	6ò	&ò	ò	ò	ó
	"ó	Wò	.ó$	ó:"	Jr"   r   c                   ó   — e Zd ZdZdd„Zy)r   aâ  Class to model a DER OCTET STRING.

    An example of encoding is:

    >>> from Crypto.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
    Nc                 ó6   — t         j                  | d||d«       y)ah  Initialize 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©r   r!   )r   rg   rD   s      r   r!   zDerOctetString.__init__¬  s   € ô 	×Ñ˜4  u¨h¸Õ>r"   )r"   N©r5   r6   r7   r8   r!   r9   r"   r   r   r   Ž  s   „ ñô:?r"   r   c                   ó   — e Zd ZdZd„ Zy)r   z"Class to model a DER NULL element.c                 ó6   — t         j                  | dddd«       y)z$Initialize the DER object as a NULL.é   r"   NFr»   r%   s    r   r!   zDerNull.__init__¾  s   € ô 	×Ñ˜4  s¨D°%Õ8r"   Nr¼   r9   r"   r   r   r   »  s
   „ Ù,ó9r"   r   c                   ó,   — e Zd ZdZdd„Zd„ Zdd„Zd„ Zy)	r   a(  Class to model a DER OBJECT ID.

    An example of encoding is:

    >>> from Crypto.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
    Nc                 óF   — t         j                  | dd|d|«       || _        y)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.
        é   r"   FNrf   rh   s       r   r!   zDerObjectId.__init__â  s#   € ô 	×Ñ˜4  s¨H°e¸XÔFØˆ�
r"   c                 ó`  — | j                   j                  d«      D �cg c]  }t        |«      ‘Œ }}t        |«      dk  rt	        d«      ‚|d   dkD  rt	        d«      ‚|d   dk  r|d   dkD  rt	        d«      ‚d	|d   z  |d   z   g|dd
 z   }g }t        |«      D ]=  }|j                  |dz  «       |dz  }|sŒ|j                  |dz  dz  «       |dz  }|rŒŒ? dj                  t        |«      D �cg c]  }t        |«      ‘Œ c}«      | _	        t        j                  | «      S c c}w c c}w )zCReturn the DER OBJECT ID, fully encoded as a
        binary string.ú.re   z$Not a valid Object Identifier stringr   z!First component must be 0, 1 or 2r3   é'   z#Second component must be 39 at mosté(   NrL   é   r=   r"   )rg   Úsplitrl   r*   r-   Úreversedr    Újoinr   rA   r   rR   )r   r   ÚcompsÚsubcompsrM   Úvs         r   rR   zDerObjectId.encodeñ  s7  € ð "&§¡×!1Ñ!1°#Ó!6Ö7˜A”�Q•Ð7ˆÐ7äˆu‹:˜Š>ÜÐCÓDÐDØ�‰8�aŠ<ÜÐ@ÓAÐAØ�‰8�aŠ<˜E !™H ršMÜÐBÓCÐCà˜˜q™‘M E¨!¡HÑ,Ð-°°a°b°	Ñ9ˆàˆÜ˜(Ó#ò 	ˆAØ�O‰O˜A ™HÔ%Ø�!‰GˆAÚØ—‘  T¡¨TÑ 1Ô2Ø�a‘�ó ð	ð —x‘x´(¸8Ó2DÖ E¨Q¤ a¥Ò EÓFˆŒÜ×Ñ Ó%Ð%ùò) 8ùò& !Fs   žD&Ã3D+c                 ó0   — t         j                  | ||«      S )ab  Decode 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.
        rp   rq   s      r   r\   zDerObjectId.decode  s   € ô ×Ñ  k°6Ó:Ð:r"   c                 ó  — t         j                  | ||«       t        | j                  «      }g }d}|j	                  «       rD|j                  «       }|dz  |dz  z   }|dz  s|j                  |«       d}|j	                  «       rŒDt        |«      dk(  rt        d«      ‚|d   dk  rd|d   g|dd n#|d   d	k  rd|d   dz
  g|dd nd
|d   d	z
  g|dd dj                  |D �cg c]  }t        |«      ‘Œ c}«      | _        yc c}w )z,Decode a complete DER OBJECT ID from a file.r   rÇ   rL   r=   zEmpty payloadrÆ   Nr3   éP   re   rÄ   )r   rY   r   rA   r+   r4   r    r*   r-   rÊ   Ústrrg   )r   rT   r[   r_   rÌ   rÍ   Úcr   s           r   rY   zDerObjectId._decodeFromStream  s  € ô 	×#Ñ# D¨!¨VÔ4ô ˜Ÿ™Ó%ˆàˆØˆØ×ÑÔ Ø—‘“ˆAØ�a‘˜A ™HÑ%ˆAØ˜’HØ—‘ Ô"Ø�ð ×ÑÕ ô ˆx‹=˜AÒÜ˜_Ó-Ð-à�A‰;˜ÒØ˜x¨™{Ð+ˆH�R�a‰LØ�a‰[˜2ÒØ˜x¨™{¨RÑ/Ð0ˆH�R�a‰Là˜x¨™{¨RÑ/Ð0ˆH�R�aˆLà—X‘X¨xÖ8¨!œs 1�vÒ8Ó9ˆ�
ùÒ8s   Ã#D)Ú NNra   rx   r9   r"   r   r   r   Ä  s   „ ñó:ò&ó4;ó :r"   r   c                   ó,   — e Zd ZdZdd„Zd„ Zdd„Zd„ Zy)	r   a¢  Class to model a DER BIT STRING.

    An example of encoding is:

    >>> from Crypto.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
    Nc                 ó’   — t         j                  | dd|d|«       t        |t         «      r|j                  «       | _        y|| _        y)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.
        é   r"   FN)r   r!   Ú
isinstancerR   rg   rh   s       r   r!   zDerBitString.__init__W  s<   € ô 	×Ñ˜4  s¨H°e¸XÔFô �eœYÔ'ØŸ™›ˆD�JàˆD�Jr"   c                 óT   — d| j                   z   | _        t        j                  | «      S )zBReturn the DER BIT STRING, fully encoded as a
        byte string.r}   r~   r%   s    r   rR   zDerBitString.encodel  s%   € ð
  §¡Ñ+ˆŒÜ×Ñ Ó%Ð%r"   c                 ó0   — t         j                  | ||«      S )aT  Decode 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.
        rp   rq   s      r   r\   zDerBitString.decodet  s   € ô ×Ñ  k°6Ó:Ð:r"   c                 óæ   — t         j                  | ||«       | j                  r&t        | j                  d   «      dk7  rt	        d«      ‚d| _        | j                  r| j                  dd | _        yy)z1Decode a complete DER BIT STRING DER from a file.r   zNot a valid BIT STRINGr"   r3   N)r   rY   rA   r   r-   rg   r�   s      r   rY   zDerBitString._decodeFromStreamƒ  sd   € ô 	×#Ñ# D¨!¨VÔ4à�<Š<œD §¡¨a¡Ó1°QÒ6ÜÐ5Ó6Ð6ð ˆŒ
à�<Š<ØŸ™ a bÐ)ˆD�Jð r"   )r"   NNra   rx   r9   r"   r   r   r   :  s   „ ñó8ò*&ó;ó*r"   r   c                   óD   — e Zd ZdZdd„Zd„ Zd„ Zd„ Zd„ Zdd„Z	d	„ Z
d
„ Zy)r   a…  Class to model a DER SET OF.

    An example of encoding is:

    >>> from Crypto.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]``.
    Nc                 óˆ   — t         j                  | dd|d«       g | _        d| _        |r|D ]  }| j	                  |«       Œ yy)a9  Initialize 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).
        é   r"   TN)r   r!   r…   Ú
_elemOctetÚadd)r   ÚstartSetrD   Úes       r   r!   zDerSetOf.__init__®  sL   € ô 	×Ñ˜4  s¨H°dÔ;ØˆŒ	ð ˆŒáØò �Ø—‘˜•ñð r"   c                 ó    — | j                   |   S r$   rˆ   r‰   s     r   r�   zDerSetOf.__getitem__Ã  s   € Ø�y‰y˜‰|Ðr"   c                 ó,   — t        | j                  «      S r$   )Úiterr…   r%   s    r   Ú__iter__zDerSetOf.__iter__Æ  s   € Ü�D—I‘I‹Ðr"   c                 ó,   — t        | j                  «      S r$   rœ   r%   s    r   r�   zDerSetOf.__len__É  s   € Ü�4—9‘9‹~Ðr"   c                 ó$  — t        |«      rd}n+t        |t        «      r| j                  }nt	        |d   «      }| j
                  |k7  r| j
                  �t        d«      ‚|| _        || j                  vr| j                  j                  |«       yy)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.
        re   r   Nz&New element does not belong to the set)	r   r×   r   r?   r   rÞ   r-   r…   r    )r   ÚelemÚeos      r   rß   zDerSetOf.addÌ  s}   € ô �dÔØ‰BÜ˜œiÔ(Ø—‘‰Bä�d˜1‘g“ˆBà�?‰?˜bÒ Ø�‰Ð*Ü Ð!IÓJÐJØ ˆDŒOà�t—y‘yÑ Ø�I‰I×Ñ˜TÕ"ð !r"   c                 ó0   — t         j                  | ||«      S )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.
        rp   rq   s      r   r\   zDerSetOf.decodeä  s   € ô  ×Ñ  k°6Ó:Ð:r"   c                 ój  — g | _         t        j                  | ||«       t        | j                  «      }d}|j                  «       dkD  rë|j                  «        t        «       }|j                  ||«       |dk  r|j                  }n||j                  k7  rt        d«      ‚|dk7  r*| j                   j                  |j                  «       «       nOt        «       }|j                  |j                  «       |«       | j                   j                  |j                  «       |j                  «       dkD  rŒêyy)z)Decode a complete DER SET OF from a file.éÿÿÿÿr   z)Not all elements are of the same DER typere   N)r…   r   rY   r   rA   r+   r&   r?   r-   r    r(   r	   r\   rg   )r   rT   r[   r_   Ú
setIdOctetr´   rµ   s          r   rY   zDerSetOf._decodeFromStreamö  sü   € ð ˆŒ	ô 	×#Ñ# D¨!¨VÔ4ô ˜Ÿ™Ó%ˆØˆ
Ø×ÑÓ  1Ò$Ø�N‰NÔä“+ˆCØ×!Ñ! ! VÔ,ð ˜AŠ~Ø Ÿ^™^‘
à §¡Ò/Ü$Ð%PÓQÐQð ˜TÒ!Ø—	‘	× Ñ  ×!6Ñ!6Ó!8Õ9ä#›�Ø—‘˜a×3Ñ3Ó5°vÔ>Ø—	‘	× Ñ  §¡Ô.ð' ×ÑÓ  1Õ$r"   c                 óP  — g }| j                   D ][  }t        |«      rt        |«      j                  «       }n#t	        |t
        «      r|j                  «       }n|}|j                  |«       Œ] |j                  «        dj                  |«      | _	        t
        j                  | «      S )zRReturn this SET OF DER element, fully encoded as a
        binary string.
        r"   )
r…   r   r	   rR   r×   r   r    ÚsortrÊ   rA   )r   Úorderedr¢   Úbyss       r   rR   zDerSetOf.encode  s‰   € ð ˆØ—I‘Iò 	 ˆDÜ˜$ÔÜ  Ó&×-Ñ-Ó/‘Ü˜D¤)Ô,Ø—k‘k“m‘à�Ø�N‰N˜3Õð	 ð 	�‰ŒØ—x‘x Ó(ˆŒÜ×Ñ Ó%Ð%r"   )NNra   )r5   r6   r7   r8   r!   r�   rå   r�   rß   r\   rY   rR   r9   r"   r   r   r   “  s0   „ ñó4ò*òòò#ó0;ò$/óB&r"   r   ra   )rt   ÚCrypto.Util.py3compatr   r   r   ÚCrypto.Util.numberr   r   Ú__all__r   Úobjectr   r   r	   r
   r   r   r   r   r   r   r9   r"   r   ú<module>rö      s´   ðó. ç 9Ñ 9ç ;òP€ó+ô%�&ô %ô@sZ�ô sZôl\'�ô \'ô~P@�ô P@ôfRJ�)ô RJôj*?�Yô *?ôZ9ˆiô 9ôs:�)ô s:ôlV*�9ô V*ôrU&ˆyõ U&r"   