+
    ^eòjI�  ã                   ó   € ^ RI t ^ RIHtHtHt ^ RIHtHt . ROtRR lt	 ! R R]
4      t ! R R]
4      t ! R R]4      t ! R R]4      t ! R R	]4      t ! R R]4      t ! R R]4      t ! R R
]4      t ! R R]4      t ! R R]4      tR# )é    N)Úbyte_stringÚbchrÚbord)Úlong_to_bytesÚbytes_to_longÚ	DerObjectÚ
DerIntegerÚ
DerBooleanÚDerOctetStringÚDerNullÚDerSequenceÚDerObjectIdÚDerBitStringÚDerSetOfc                 ód   € ^ p W,           pT'       * ;'       g    T ^ 8¬  #   \          d     R# i ; i)r   F)Ú	TypeError)ÚxÚonly_non_negativeÚtests   && Ú‡/opt/data/installs/351f81cc06284494/environments/aa258815729c481f8402f54f4c368f83/venv/lib/python3.14/site-packages/Crypto/Util/asn1.pyÚ
_is_numberr   (   s>   € Ø€DðØ�xˆð !Ô ×*Ð* A¨¡FÐ*øô ô Úðús   „   /®/c                   óH   a € ] tR t^1t o RtR tR tR tR tR t	R t
RtV tR	# )
ÚBytesIO_EOFzaThis class differs from BytesIO in that a ValueError exception is
raised whenever EOF is reached.c                ó.   € Wn         ^ V n        RV n        R# )r   N)Ú_bufferÚ_indexÚ	_bookmark)ÚselfÚinitial_bytess   &&r   Ú__init__ÚBytesIO_EOF.__init__5   s   € Ø$ŒØˆŒØˆŽó    c                ó(   € V P                   V n        R # ©N)r   r   ©r   s   &r   Úset_bookmarkÚBytesIO_EOF.set_bookmark:   s   € ØŸ™ˆŽr"   c                óh   € V P                   f   Q hV P                  V P                   V P                   # r$   ©r   r   r   r%   s   &r   Údata_since_bookmarkÚBytesIO_EOF.data_since_bookmark=   s+   € Ø�~‰~Ò)Ð)Ð)Ø�|‰|˜DŸN™N¨4¯;©;Ð7Ð7r"   c                óN   € \        V P                  4      V P                  ,
          # r$   )Úlenr   r   r%   s   &r   Úremaining_dataÚBytesIO_EOF.remaining_dataA   s   € Ü�4—<‘<Ó  4§;¡;Õ.Ð.r"   c                óì   € V P                   V,           pV\        V P                  4      8”  d(   \        R V\        V P                  4      3,          4      hV P                  V P                   V pW n         V# )z@Not enough data for DER decoding: expected %d bytes and found %d)r   r-   r   Ú
ValueError)r   ÚlengthÚ	new_indexÚresults   &&  r   ÚreadÚBytesIO_EOF.readD   sp   € Ø—K‘K &Õ(ˆ	Ø”s˜4Ÿ<™<Ó(Ô(ÜÐ_ÐclÔnqÐrv×r~Ñr~Ónð  cAõ  Aó  Bð  Bà—‘˜dŸk™k¨)Ð4ˆØŒØˆr"   c                óD   € \        V P                  ^4      ^ ,          4      # )é   )r   r5   r%   s   &r   Ú	read_byteÚBytesIO_EOF.read_byteM   s   € Ü�D—I‘I˜a“L •OÓ$Ð$r"   r)   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r    r&   r*   r.   r5   r9   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @r   r   r   1   s-   ø‡ € ñ'òò
%ò8ò/ò÷%ð %r"   r   c                   ó`   a € ] tR t^Qt o RtRR ltR t]R 4       tR t	R t
RR ltR	 tR
tV tR# )r   z`Base class for defining a single DER object.

This class should never be directly instantiated.
Nc                óZ  € Vf
   RV n         R# V P                  V4      pW n        V'       d   ^ M^ pRWS39  d   \        R4      hVe'   ^€V,          V P                  V4      ,          V n         R# Ve-   ^ V P                  V4      ,          V n         Wa,          V n        R# Wa,          V n         R# )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.
Nz1Explicit and implicit tags are mutually exclusive)Ú
_tag_octetÚ_convertTagÚpayloadr1   Ú_inner_tag_octet)r   Úasn1IdrH   ÚimplicitÚconstructedÚexplicitÚconstructed_bits   &&&&&& r   r    Ú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Ø,;Õ,D�DÖ)ð '6Õ&>�D–Or"   c                óÆ   € \        V4      '       g#   \        V4      ^8X  d   \        V^ ,          4      p\        V4      '       d   ^ Tu;8:  d   ^8  g   M \        R4      hV# )z_Check if *tag* is a real DER tag (5 bits).
Convert it from a character to number if necessary.
zWrong DER tag)r   r-   r   r1   )r   Útags   &&r   rG   ÚDerObject._convertTag�   sH   € ô " #—’Ü˜3“x 1”}Ü" 3 q¥6›l˜ä" 3Ÿš¨A°®O°t®OÜ$ _Ó5Ð5Ø�
r"   c                ó€   € V ^8”  d.   \        V 4      p\        \        V4      ^€,           4      V,           # \        V 4      # )z8Build length octets according to BER/DER
definite form.
)r   r   r-   )r2   Úencodings   & r   Ú_definite_formÚDerObject._definite_form©   s8   € ð
 ˜C”<Ü#0°Ó#8˜Ü#¤C¨£M°CÕ$7Ó8¸8ÕCÐCÜ˜F“|Ð#r"   c                óR  € V P                   p\        V R4      '       dP   \        V P                  4      V P	                  \        V P                   4      4      ,           V P                   ,           p\        V P                  4      V P	                  \        V4      4      ,           V,           # )z?Return this DER element, fully encoded as a binary byte string.rI   )rH   Úhasattrr   rI   rU   r-   rF   )r   Úoutput_payloads   & r   ÚencodeÚDerObject.encode³   sŠ   € ð "&§¡�ô ˜4Ð!3×4Ò4Ü&*¨4×+@Ñ+@Ó&AØ&*×&9Ñ&9¼#¸d¿l¹lÓ:KÓ&Lõ'Mà&*§l¡lõ'3�Nô ˜TŸ_™_Ó-Ø×+Ñ+¬C°Ó,?Ó@õAà&õ'ð (r"   c                óâ   € VP                  4       pV^8”  dX   VP                  V^,          4      p\        V^ ,          4      ^ 8X  d   \        R4      h\	        V4      pV^8:  d   \        R4      hV# )z%Decode DER length octets from a file.z$Invalid DER: length has leading zeroz5Invalid DER: length in long form but smaller than 128)r9   r5   r   r1   r   )r   Úsr2   Úencoded_lengths   &&  r   Ú
_decodeLenÚDerObject._decodeLenÆ   sh   € ð Ÿ™›�à˜C”<Ø%&§V¡V¨F°T­MÓ%:�NÜ˜N¨1Õ-Ó.°!Ô3Ü(Ð)OÓPÐPÜ*¨>Ó:�FØ ”}Ü(Ð)`ÓaÐaà�r"   c                ó¶   € \        V4      '       g   \        R4      h\        V4      pV P                  W24       VP	                  4       ^ 8”  d   \        R4      hV # )zµ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 stringú-Unexpected extra data after the DER structure)r   r1   r   Ú_decodeFromStreamr.   )r   Úder_encodedÚstrictr]   s   &&& r   ÚdecodeÚDerObject.decodeÕ   sW   € ô # ;×/Ò/Ü$Ð%AÓBÐBä Ó,�Ø×&Ñ& qÔ1ð ×#Ñ#Ó%¨Ô)Ü$Ð%TÓUÐUà�r"   c                ó
  € VP                  4       pV P                  e   W0P                  8w  d   \        R4      hMW0n        V P                  V4      pVP	                  V4      V n        \        V R4      '       dŠ   \        V P
                  4      pVP                  4       pW`P                  8w  d   \        R4      hV P                  V4      pVP	                  V4      V n        VP                  4       ^ 8”  d   \        R4      hR# R# )z*Decode a complete DER element from a file.NzUnexpected DER tagrI   zUnexpected internal DER tagrb   )
r9   rF   r1   r_   r5   rH   rX   r   rI   r.   )r   r]   re   ÚidOctetr2   ÚpÚinner_octets   &&&    r   rc   ÚDerObject._decodeFromStreamì   sß   € ð Ÿ+™+›-�Ø—?‘?Ò.Ø§/¡/Ô1Ü(Ð)=Ó>Ð>ð 2ð '.”OØŸ™¨Ó+�Ø Ÿv™v f›~�”ô ˜4Ð!3×4Ò4Ü# D§L¡LÓ1�AØ"#§+¡+£-�KØ"×&;Ñ&;Ô;Ü(Ð)FÓGÐGØ!Ÿ_™_¨QÓ/�FØ#$§6¡6¨&£>�D”Lð ×'Ñ'Ó)¨AÔ-Ü(Ð)XÓYÐYñ .ñ 5r"   )rI   rF   rH   )Nr"   NFN©F)r;   r<   r=   r>   r?   r    rG   ÚstaticmethodrU   rZ   r_   rf   rc   r@   rA   rB   s   @r   r   r   Q   sE   ø‡ € ñ	ô
D	?òL
	ð 
ñ	$ó 
ð	$ò	(ò&	ô	÷.	Zð 	Zr"   c                   óD   a € ] tR tRt o RtR	R ltR tR
R ltR tRt	V t
R# )r	   i  a8  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   € \         P                  V ^RVRV4       Wn        R# )zå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   rr   rK   rM   s   &&&&r   r    ÚDerInteger.__init__#  s$   € ô ×"Ñ" 4¨¨s°HØ#(¨(ô4à"–
r"   c                óX  € V P                   pRV n         \        \        V^ÿ,          4      4      V P                  ,           V n        ^€Tu;8:  d   ^ÿ8:  d%   M M!\        ^ 4      V P                  ,           V n        RTu;8:  d   ^ÿ8:  d   M MMV^,          pKƒ  \        P                  V 4      # )z9Return the DER INTEGER, fully encoded as a
binary string.r"   i€ÿÿÿ)rr   rH   r   Úintr   rZ   )r   Únumbers   & r   rZ   ÚDerInteger.encode3  s€   € ð Ÿ™�Ø"�”ØÜ#'¬¨F°S­LÓ(9Ó#:¸T¿\¹\Õ#I�D”LØ˜fÖ+¨×+Ü'+¨D£z°D·L±LÕ'@˜œØ˜vÖ,¨×,ØØ˜q•L’FÜ ×'Ñ'¨Ó-Ð-r"   c                ó0   € \         P                  WVR7      # )z¼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.
©re   ©r   rf   ©r   rd   re   s   &&&r   rf   ÚDerInteger.decodeB  s   € ô !×'Ñ'¨À&Ð'ÓIÐIr"   c                ó®  € \         P                  WV4       V'       d   \        V P                  4      ^ 8X  d   \	        R4      h\        V P                  4      ^8¼  d@   \
        P                  ! RV P                  R,          4      ^ ,          ^€8  d   \	        R4      h^ V n        ^pV P                   FG  pV ;P                  R,          un        V ;P                  \        V4      ,          un        V^,          pKI  	  V P                  '       dG   \        V P                  ^ ,          4      ^€,          '       d   V ;P                  V,          un        R# R# R# )z*Decode a complete DER INTEGER from a file.z/Invalid encoding for DER INTEGER: empty payloadz>H:Né   Nz.Invalid encoding for DER INTEGER: leading zeroé   N)	r   rc   r-   rH   r1   ÚstructÚunpackrr   r   )r   r]   re   ÚbitsÚis   &&&  r   rc   ÚDerInteger._decodeFromStreamO  sñ   € ô ×+Ñ+¨D°VÔ<çÜ˜4Ÿ<™<Ó(¨AÔ-Ü(Ð)ZÓ[Ð[Ü˜4Ÿ<™<Ó(¨AÔ-´&·-²-ÀÀdÇlÁlÐSUÕ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"   ©rH   rr   )r   NNrm   ©r;   r<   r=   r>   r?   r    rZ   rf   rc   r@   rA   rB   s   @r   r	   r	     s$   ø‡ € ñ	ô6	#ò 	.ô	J÷	'ð 	'r"   c                   óD   a € ] tR tRt o RtR	R ltR tR
R ltR tRt	V t
R# )r
   if  a  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   € \         P                  V ^RVRV4       Wn        R# )a6  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"   FNrq   rs   s   &&&&r   r    ÚDerBoolean.__init__€  s!   € ô& 	×Ñ˜4  s¨H°e¸XÔFØŽ
r"   c                ób   € V P                   '       d   RMRV n        \        P                  V 4      # )z9Return the DER BOOLEAN, fully encoded as a binary string.ó   ÿó    ©rr   rH   r   rZ   r%   s   &r   rZ   ÚDerBoolean.encode–  s&   € ð #'§*§* *‘w°'ˆŒÜ×Ñ Ó%Ð%r"   c                ó.   € \         P                  WV4      # )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.
r{   r|   s   &&&r   rf   ÚDerBoolean.decodeœ  s   € ô ×Ñ °6Ó:Ð:r"   c                ó6  € \         P                  WV4       \        V P                  4      ^8w  d   \	        R4      h\        V P                  ^ ,          4      ^ 8X  d
   RV n        R# \        V P                  ^ ,          4      ^ÿ8X  d
   RV n        R# \	        R4      h)z)Decode a DER-encoded BOOLEAN from a file.z7Invalid encoding for DER BOOLEAN: payload is not 1 byteFTzInvalid payload for DER BOOLEANN)r   rc   r-   rH   r1   r   rr   ©r   r]   re   s   &&&r   rc   ÚDerBoolean._decodeFromStream¨  su   € ô 	×#Ñ# D¨VÔ4äˆt�|‰|Ó Ô!ÜÐVÓWÐWä�—‘˜Q•Ó  AÔ%ØˆDŽJÜ�$—,‘,˜q•/Ó" dÔ*ØˆDŽJäÐ>Ó?Ð?r"   r†   )FNNrm   r‡   rB   s   @r   r
   r
   f  s%   ø‡ € ñô2ò,&ô
;÷@ð @r"   c                   ó”   a € ] tR tRt o RtRR ltR tR tR tR t	R	 t
R
 tR tR tR tR tRR ltRR ltR tRR ltR tRtV tR# )r   i¹  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                ó`   € \         P                  V ^RVRV4       Vf
   . V n        R# Wn        R# )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   ÚstartSeqrK   rM   s   &&&&r   r    ÚDerSequence.__init__ä  s.   € ô( ×"Ñ" 4¨¨s°H¸dÀHÔMØÒ#Ø "�D–Ià (–Ir"   c                ó    € V P                   V R # r$   ©r—   ©r   Úns   &&r   Ú__delitem__ÚDerSequence.__delitem__   s   € Ø—I‘I˜a’Lr"   c                ó(   € V P                   V,          # r$   r›   rœ   s   &&r   Ú__getitem__ÚDerSequence.__getitem__  s   € Ø—y‘y •|Ð#r"   c                ó"   € W P                   V&   R # r$   r›   )r   Úkeyrr   s   &&&r   Ú__setitem__ÚDerSequence.__setitem__  s   € Ø!&—	‘	˜#“r"   c                ó    € W0P                   W% R # r$   r›   )r   r„   ÚjÚsequences   &&&&r   Ú__setslice__ÚDerSequence.__setslice__	  s   € Ø!)—	‘	˜!’r"   c                ó"   € V P                   W1 R # r$   r›   ©r   r„   r¨   s   &&&r   Ú__delslice__ÚDerSequence.__delslice__  s   € Ø—I‘I˜a˜c’Nr"   c                óH   € V P                   \        ^ V4      \        ^ V4       # )r   )r—   Úmaxr­   s   &&&r   Ú__getslice__ÚDerSequence.__getslice__  s   € Ø—y‘y¤ Q¨£¬3¨q°!«9Ð5Ð5r"   c                ó,   € \        V P                  4      # r$   ©r-   r—   r%   s   &r   Ú__len__ÚDerSequence.__len__  s   € Ü˜4Ÿ9™9“~Ð%r"   c                ó<   € V P                   P                  V4       V # r$   ©r—   Úappend©r   Úitems   &&r   Ú__iadd__ÚDerSequence.__iadd__  ó   € Ø—	‘	× Ñ  Ô&Ø�r"   c                ó<   € V P                   P                  V4       V # r$   r¹   r»   s   &&r   rº   ÚDerSequence.append  r¿   r"   c                ó<   € V P                   P                  W4       V # r$   )r—   Úinsert)r   Úindexr¼   s   &&&r   rÃ   ÚDerSequence.insert  s   € Ø—	‘	× Ñ  Ô-Ø�r"   c                ó~   € V P                    Uu. uF  p\        W!4      '       g   K  VNK  	  pp\        V4      # u upi )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   ÚhasIntsÚDerSequence.hasInts!  s5   € ð %)§I¢IÓR¡I˜q´¸A×1QŸ˜¡I�ÐRÜ˜5“zÐ!ùò Ss   �:§:c                óx   € V P                   ;'       d(    V P                  V4      \        V P                   4      8H  # )a9  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   ÚhasOnlyIntsÚDerSequence.hasOnlyInts-  s-   € ð —y‘y×VÐV T§\¡\Ð2CÓ%DÌÈDÏIÉIËÑ%VÐVr"   c                óŒ  € RV n         V P                   F™  p\        V4      '       d   V ;P                   V,          un         K/  \        V4      '       d3   V ;P                   \	        V4      P                  4       ,          un         Kr  V ;P                   VP                  4       ,          un         K›  	  \        P                  V 4      # )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"   )rH   r—   r   r   r	   rZ   r   r»   s   & r   rZ   ÚDerSequence.encode:  s€   € ð  #�”Ø ŸIœI�DÜ" 4×(Ò(ØŸš¨Õ,ŸÜ# D×)Ò)ØŸš¬
°4Ó(8×(?Ñ(?Ó(AÕAŸàŸš¨¯©«Õ5Ÿñ &ô !×'Ñ'¨Ó-Ð-r"   c                ó’   € W0n         \        P                  WVR7      pV'       d"   V P                  4       '       g   \	        R4      hV# )aI  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.
rz   zSome members are not INTEGERs)Ú_nr_elementsr   rf   rË   r1   )r   rd   re   Únr_elementsÚonly_ints_expectedr4   s   &&&&& r   rf   ÚDerSequence.decodeL  sA   € ð* %0Ô!Ü"×)Ñ)¨$ÀFÐ)ÓK�ç%¨d×.>Ñ.>×.@Ò.@Ü$Ð%DÓEÐEà�r"   c                ó.  € . V n         \        P                  WV4       \        V P                  4      pVP                  4       ^ 8”  d»   VP                  4        \        4       pVP                  W24       VP                  ^8w  d,   V P                   P                  VP                  4       4       K|  \        4       pVP                  4       pVP                  WbR7       V P                   P                  VP                  4       KÏ  RpV P                  e$    \        V P                   4      V P                  9   pV'       g&   \!        R\        V P                   4      ,          4      hR#   \         d&    \        T P                   4      T P                  8H  p L^i ; i)z+Decode a complete DER SEQUENCE from a file.rz   TNz1Unexpected number of members (%d) in the sequence)r—   r   rc   r   rH   r.   r&   rF   rº   r*   r	   rf   rr   rÐ   r-   r   r1   )r   r]   re   rj   ÚderÚderIntÚdataÚoks   &&&     r   rc   ÚDerSequence._decodeFromStreami  sH  € ð �”	ô ×+Ñ+¨D°VÔ<ô   §¡Ó-�Ø×&Ñ&Ó(¨1Ô,Ø—N‘NÔ$ä#›+�CØ×)Ñ)¨!Ô4ð —~‘~¨Ô-ØŸ	™	×(Ñ(¨×)>Ñ)>Ó)@ÖAä!+£˜Ø ×4Ñ4Ó6˜ØŸ™ d˜Ô:ØŸ	™	×(Ñ(¨¯©Ö6à�Ø×$Ñ$Ò0ðAÜ  §¡›^¨t×/@Ñ/@Ñ@˜÷ Ü$ð &8Ü:=¸d¿i¹i».õ&Ió Jð Jñ øô %ô AÜ  §¡›^¨t×/@Ñ/@Ñ@šðAús   Ä"E$ Å$-FÆF)rÐ   r—   rH   )NNN)T)FNF)r;   r<   r=   r>   r?   r    rž   r¡   r¥   rª   r®   r²   r¶   r½   rº   rÃ   rÈ   rË   rZ   rf   rc   r@   rA   rB   s   @r   r   r   ¹  sc   ø‡ € ñ(	ôT	)ò8	!ò	$ò	'ò	*ò	#ò	6ò	&ò	ò	ò	ô
	"ô	Wò	.ô$	÷:"	Jð "	Jr"   c                   ó.   a € ] tR tRt o RtRR ltRtV tR# )r   iŽ  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   € \         P                  V ^WR4       R# )a(  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   rr   rK   s   &&&r   r    ÚDerOctetString.__init__¬  s   € ô 	×Ñ˜4  u¸Ö>r"   © )r"   N©r;   r<   r=   r>   r?   r    r@   rA   rB   s   @r   r   r   Ž  s   ø‡ € ñ÷:?ò ?r"   c                   ó*   a € ] tR tRt o RtR tRtV tR# )r   i»  z"Class to model a DER NULL element.c                ó8   € \         P                  V ^RRR4       R# )z$Initialize the DER object as a NULL.r"   NFrÜ   r%   s   &r   r    ÚDerNull.__init__¾  s   € ô 	×Ñ˜4  s¨D°%Ö8r"   rÞ   Nrß   rB   s   @r   r   r   »  s   ø‡ € Ù,÷9ð 9r"   c                   óD   a € ] tR tRt o RtR	R ltR tR
R ltR tRt	V t
R# )r   iÄ  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   € \         P                  V ^RVRV4       Wn        R# )aJ  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"   FNrq   rs   s   &&&&r   r    ÚDerObjectId.__init__â  s!   € ô 	×Ñ˜4  s¨H°e¸XÔFØŽ
r"   c                óô  € V P                   P                  R4       Uu. uF  p\        V4      NK  	  pp\        V4      ^8  d   \	        R4      hV^ ,          ^8”  d   \	        R4      hV^ ,          ^8  d   V^,          ^'8”  d   \	        R4      h^(V^ ,          ,          V^,          ,           .VR,          ,           p. p\        V4       FV  pVP                  V^,          4       V^,          pV'       g   K.  VP                  V^,          ^€,          4       V^,          pK4  	  RP                  \        V4       Uu. uF  p\        V4      NK  	  up4      V n	        \        P                  V 4      # u upi u upi )z;Return the DER OBJECT ID, fully encoded as a
binary string.Ú.z$Not a valid Object Identifier stringz!First component must be 0, 1 or 2z#Second component must be 39 at most:r   NNr"   )rr   Úsplitrv   r-   r1   Úreversedrº   Újoinr   rH   r   rZ   )r   r   ÚcompsÚsubcompsrT   Úvs   &     r   rZ   ÚDerObjectId.encodeñ  s6  € ð "&§¡×!1Ñ!1°#Ô!6Ó7Ñ!6˜A”�Q–Ñ!6ˆÐ7äˆu‹:˜Œ>ÜÐCÓDÐDØ��8�aŒ<ÜÐ@ÓAÐAØ��8�aŒ<˜E !�H rœMÜÐBÓCÐCà˜˜q�•M E¨!¥HÕ,Ð-°°bµ	Õ9ˆàˆÜ˜(Ö#ˆAØ�O‰O˜A �HÔ%Ø�!�GˆAß‘!Ø—‘  T¥¨TÕ 1Ô2Ø�a•’ñ $ð —x‘x´(¸8Ô2DÓ EÑ2D¨Q¤ a¦Ñ2DÑ EÓFˆŒÜ×Ñ Ó%Ð%ùò) 8ùò& !Fs   žE0Ä;E5c                ó.   € \         P                  WV4      # )a  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.
r{   r|   s   &&&r   rf   ÚDerObjectId.decode  s   € ô ×Ñ °6Ó:Ð:r"   c                ót  € \         P                  WV4       \        V P                  4      p. p^ pVP	                  4       '       dN   VP                  4       pV^,          V^,          ,           pV^€,          '       d   KN  VP                  V4       ^ pKc  \        V4      ^ 8X  d   \        R4      hV^ ,          ^(8  d   ^ V^ ,          .VR&   M9V^ ,          ^P8  d   ^V^ ,          ^(,
          .VR&   M^V^ ,          ^P,
          .VR&   RP                  V Uu. uF  p\        V4      NK  	  up4      V n        R# u upi )z,Decode a complete DER OBJECT ID from a file.zEmpty payload:Nr8   Nrç   N)r   rc   r   rH   r.   r9   rº   r-   r1   rê   Ústrrr   )r   r]   re   rj   rì   rí   Úcr   s   &&&     r   rc   ÚDerObjectId._decodeFromStream  s	  € ô 	×#Ñ# D¨VÔ4ô ˜Ÿ™Ó%ˆàˆØˆØ×Ñ× Ò Ø—‘“ˆAØ�a•˜A �HÕ%ˆAØ˜—H–HØ—‘ Ô"Ø’äˆx‹=˜AÔÜ˜_Ó-Ð-à�A�;˜ÔØ˜x¨�{Ð+ˆH�RŠLØ�a�[˜2ÔØ˜x¨�{¨RÕ/Ð0ˆH�RŠLà˜x¨�{¨RÕ/Ð0ˆH�R‰Là—X‘X©xÓ8©x¨!œs 1žv©xÑ8Ó9ˆŽ
ùÒ8s   ÄD5r†   )Ú NNrm   r‡   rB   s   @r   r   r   Ä  s#   ø‡ € ñô:ò&ô4;÷ :ð :r"   c                   óD   a € ] tR tRt o RtR	R ltR tR
R ltR tRt	V t
R# )r   i:  aV  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                ó    € \         P                  V ^RVRV4       \        V\         4      '       d   VP                  4       V n        R# Wn        R# )ay  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    Ú
isinstancerZ   rr   rs   s   &&&&r   r    ÚDerBitString.__init__W  s=   € ô 	×Ñ˜4  s¨H°e¸XÔFô �eœY×'Ò'ØŸ™›ˆDŽJàŽJr"   c                ó\   € RV P                   ,           V n        \        P                  V 4      # )z:Return the DER BIT STRING, fully encoded as a
byte string.r�   rŽ   r%   s   &r   rZ   ÚDerBitString.encodel  s%   € ð
  §¡Õ+ˆŒÜ×Ñ Ó%Ð%r"   c                ó.   € \         P                  WV4      # )a  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.
r{   r|   s   &&&r   rf   ÚDerBitString.decodet  s   € ô ×Ñ °6Ó:Ð:r"   c                ó  € \         P                  WV4       V P                  '       d-   \        V P                  ^ ,          4      ^ 8w  d   \	        R4      hRV n        V P                  '       d   V P                  R,          V n        R# R# )z1Decode a complete DER BIT STRING DER from a file.zNot a valid BIT STRINGr"   :r8   NNN)r   rc   rH   r   r1   rr   r“   s   &&&r   rc   ÚDerBitString._decodeFromStreamƒ  sd   € ô 	×#Ñ# D¨VÔ4à�<�<ˆ<œD §¡¨a¥Ó1°QÔ6ÜÐ5Ó6Ð6ð ˆŒ
à�<�<ˆ<ØŸ™ bÕ)ˆDŽJñ r"   r†   )r"   NNrm   r‡   rB   s   @r   r   r   :  s#   ø‡ € ñô8ò*&ô;÷*ð *r"   c                   ó\   a € ] tR tRt o RtRR ltR tR tR tR t	RR	 lt
R
 tR tRtV tR# )r   i“  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                óœ   € \         P                  V ^RVR4       . V n        RV n        V'       d   V F  pV P	                  V4       K  	  R# R# )a  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   ÚstartSetrK   Úes   &&& r   r    ÚDerSetOf.__init__®  sG   € ô 	×Ñ˜4  s¨H°dÔ;ØˆŒ	ð ˆŒçÛ�Ø—‘˜–ó ñ r"   c                ó(   € V P                   V,          # r$   r›   rœ   s   &&r   r¡   ÚDerSetOf.__getitem__Ã  s   € Ø�y‰y˜�|Ðr"   c                ó,   € \        V P                  4      # r$   )Úiterr—   r%   s   &r   Ú__iter__ÚDerSetOf.__iter__Æ  s   € Ü�D—I‘I‹Ðr"   c                ó,   € \        V P                  4      # r$   rµ   r%   s   &r   r¶   ÚDerSetOf.__len__É  s   € Ü�4—9‘9‹~Ðr"   c                óR  € \        V4      '       d   ^pM5\        V\        4      '       d   V P                  pM\	        V^ ,          4      pV P
                  V8w  d    V P
                  e   \        R4      hW n        WP                  9  d   V P                  P                  V4       R# R# )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.
Nz&New element does not belong to the set)	r   rø   r   rF   r   r  r1   r—   rº   )r   ÚelemÚeos   && r   r  ÚDerSetOf.addÌ  s   € ô �d×ÒØ‰BÜ˜œi×(Ò(Ø—‘‰Bä�d˜1•g“ˆBà�?‰?˜bÔ Ø�‰Ò*Ü Ð!IÓJÐJØ ŒOà—y‘yÔ Ø�I‰I×Ñ˜TÖ"ñ !r"   c                ó.   € \         P                  WV4      # )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.
r{   r|   s   &&&r   rf   ÚDerSetOf.decodeä  s   € ô  ×Ñ °6Ó:Ð:r"   c                óR  € . V n         \        P                  WV4       \        V P                  4      pRpVP                  4       ^ 8”  dÞ   VP                  4        \        4       pVP                  W24       V^ 8  d   VP                  pMWEP                  8w  d   \        R4      hV^8w  d,   V P                   P                  VP                  4       4       K¡  \        4       pVP                  VP                  4       V4       V P                   P                  VP                  4       Kò  R# )z)Decode a complete DER SET OF from a file.z)Not all elements are of the same DER typeNéÿÿÿÿ)r—   r   rc   r   rH   r.   r&   rF   r1   rº   r*   r	   rf   rr   )r   r]   re   rj   Ú
setIdOctetrÕ   rÖ   s   &&&    r   rc   ÚDerSetOf._decodeFromStreamö  sè   € ð ˆŒ	ô 	×#Ñ# D¨VÔ4ô ˜Ÿ™Ó%ˆØˆ
Ø×ÑÓ  1Ô$Ø�N‰NÔä“+ˆCØ×!Ñ! !Ô,ð ˜AŒ~Ø Ÿ^™^‘
à§¡Ô/Ü$Ð%PÓQÐQð ˜TÔ!Ø—	‘	× Ñ  ×!6Ñ!6Ó!8Ö9ä#›�Ø—‘˜a×3Ñ3Ó5°vÔ>Ø—	‘	× Ñ  §¡Ö.ñ' %r"   c                ól  € . pV P                    Fh  p\        V4      '       d   \        V4      P                  4       pM)\	        V\
        4      '       d   VP                  4       pMTpVP                  V4       Kj  	  VP                  4        RP                  V4      V n	        \
        P                  V 4      # )zBReturn this SET OF DER element, fully encoded as a
binary string.
r"   )
r—   r   r	   rZ   rø   r   rº   Úsortrê   rH   )r   Úorderedr¼   Úbyss   &   r   rZ   ÚDerSetOf.encode  sŠ   € ð ˆØ—I”IˆDÜ˜$×ÒÜ  Ó&×-Ñ-Ó/‘Ü˜D¤)×,Ò,Ø—k‘k“m‘à�Ø�N‰N˜3Öñ ð 	�‰ŒØ—x‘x Ó(ˆŒÜ×Ñ Ó%Ð%r"   )r  r—   rH   )NNrm   )r;   r<   r=   r>   r?   r    r¡   r  r¶   r  rf   rc   rZ   r@   rA   rB   s   @r   r   r   “  s8   ø‡ € ñô4ò*òòò#ô0;ò$/÷B&ð &r"   )	r   r	   r
   r   r   r   r   r   r   rm   )r�   ÚCrypto.Util.py3compatr   r   r   ÚCrypto.Util.numberr   r   Ú__all__r   Úobjectr   r   r	   r
   r   r   r   r   r   r   rÞ   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"   