§
    ¡”jÓ#  ã                   óŽ   — d Z ddlmZmZmZmZ ddlZddlmZm	Z	m
Z
 ddlmZmZ ej        dk    ZdZd	Zd
„ Zdd„Zd„ Zdd„Zd„ ZdS )zÈ
Functions for parsing and dumping using the ASN.1 DER encoding. Exports the
following items:

 - emit()
 - parse()
 - peek()

Other type classes are defined that help compose the types listed above.
é    )Úunicode_literalsÚdivisionÚabsolute_importÚprint_functionNé   )Úbyte_clsÚchr_clsÚ	type_name)Úint_from_bytesÚint_to_bytes)é   z<Insufficient data - %s bytes requested but only %s availableé
   c                 ót  — t          | t          ¦  «        st          dt          | ¦  «        z  ¦  «        ‚| dk     s| dk    rt	          d| z  ¦  «        ‚t          |t          ¦  «        st          dt          |¦  «        z  ¦  «        ‚|dk     s|dk    rt	          d|z  ¦  «        ‚t          |t          ¦  «        st          dt          |¦  «        z  ¦  «        ‚|dk     rt	          d	|z  ¦  «        ‚t          |t
          ¦  «        st          d
t          |¦  «        z  ¦  «        ‚t          | |||¦  «        |z   S )a™  
    Constructs a byte string of an ASN.1 DER-encoded value

    This is typically not useful. Instead, use one of the standard classes from
    asn1crypto.core, or construct a new class with specific fields, and call the
    .dump() method.

    :param class_:
        An integer ASN.1 class value: 0 (universal), 1 (application),
        2 (context), 3 (private)

    :param method:
        An integer ASN.1 method value: 0 (primitive), 1 (constructed)

    :param tag:
        An integer ASN.1 tag value

    :param contents:
        A byte string of the encoded byte contents

    :return:
        A byte string of the ASN.1 DER value (header and contents)
    z!class_ must be an integer, not %sr   r   z*class_ must be one of 0, 1, 2 or 3, not %sz!method must be an integer, not %sr   zmethod must be 0 or 1, not %sztag must be an integer, not %sz%tag must be greater than zero, not %sú&contents must be a byte string, not %s)Ú
isinstanceÚintÚ	TypeErrorr
   Ú
ValueErrorr   Ú_dump_header)Úclass_ÚmethodÚtagÚcontentss       ú`/var/www/finuniver-perm.ru/html/portfolio/venv/lib/python3.11/site-packages/asn1crypto/parser.pyÚemitr      s>  € õ2 �f�cÑ"Ô"ð QÝÐ;½iÈÑ>OÔ>OÑOÑPÔPÐPà�‚z€z�V˜a’Z�ZÝÐEÈÑNÑOÔOÐOå�f�cÑ"Ô"ð QÝÐ;½iÈÑ>OÔ>OÑOÑPÔPÐPà�‚z€z�V˜a’Z�ZÝÐ8¸6ÑAÑBÔBÐBå�c�3ÑÔð KÝÐ8½9ÀS¹>¼>ÑIÑJÔJÐJà
ˆQ‚w€wÝÐ@À3ÑFÑGÔGÐGå�h¥Ñ)Ô)ð XÝÐ@Å9ÈXÑCVÔCVÑVÑWÔWÐWå˜ ¨¨XÑ6Ô6¸ÑAÐAó    Fc                 óì   — t          | t          ¦  «        st          dt          | ¦  «        z  ¦  «        ‚t	          | ¦  «        }t          | |¦  «        \  }}|r||k    rt          d||z
  z  ¦  «        ‚|S )al  
    Parses a byte string of ASN.1 BER/DER-encoded data.

    This is typically not useful. Instead, use one of the standard classes from
    asn1crypto.core, or construct a new class with specific fields, and call the
    .load() class method.

    :param contents:
        A byte string of BER/DER-encoded data

    :param strict:
        A boolean indicating if trailing data should be forbidden - if so, a
        ValueError will be raised when trailing data exists

    :raises:
        ValueError - when the contents do not contain an ASN.1 header or are truncated in some way
        TypeError - when contents is not a byte string

    :return:
        A 6-element tuple:
         - 0: integer class (0 to 3)
         - 1: integer method
         - 2: integer tag
         - 3: byte string header
         - 4: byte string content
         - 5: byte string trailer
    r   z4Extra data - %d bytes of trailing data were provided)r   r   r   r
   ÚlenÚ_parser   )r   ÚstrictÚcontents_lenÚinfoÚconsumeds        r   Úparser$   K   s„   € õ: �h¥Ñ)Ô)ð XÝÐ@Å9ÈXÑCVÔCVÑVÑWÔWÐWå�x‘=”=€LÝ˜H lÑ3Ô3�N€Dˆ(Øð m�(˜lÒ*Ð*ÝÐOÐS_ÐbjÑSjÑkÑlÔlÐlØ€Kr   c                 ó®   — t          | t          ¦  «        st          dt          | ¦  «        z  ¦  «        ‚t	          | t          | ¦  «        ¦  «        \  }}|S )aW  
    Parses a byte string of ASN.1 BER/DER-encoded data to find the length

    This is typically used to look into an encoded value to see how long the
    next chunk of ASN.1-encoded data is. Primarily it is useful when a
    value is a concatenation of multiple values.

    :param contents:
        A byte string of BER/DER-encoded data

    :raises:
        ValueError - when the contents do not contain an ASN.1 header or are truncated in some way
        TypeError - when contents is not a byte string

    :return:
        An integer with the number of bytes occupied by the ASN.1 value
    r   )r   r   r   r
   r   r   )r   r"   r#   s      r   Úpeekr&   r   sQ   € õ& �h¥Ñ)Ô)ð XÝÐ@Å9ÈXÑCVÔCVÑVÑWÔWÐWå˜H¥c¨(¡m¤mÑ4Ô4�N€Dˆ(Ø€Or   c           
      ó  — |t           k    rt          d¦  «        ‚|}||dz   k     rt          t          d||z
  fz  ¦  «        ‚t          rt	          | |         ¦  «        n| |         }|dz  }|dz  }|dz	  dz  }|dk    r™d}	 ||dz   k     rt          t          d||z
  fz  ¦  «        ‚t          rt	          | |         ¦  «        n| |         }	|dz  }|	dk    r|dk    rt          d¦  «        ‚|dz  }||	d	z  z  }|	d
z	  dk    rnŒ�|dk     rt          d¦  «        ‚||dz   k     rt          t          d||z
  fz  ¦  «        ‚t          rt	          | |         ¦  «        n| |         }
|dz  }d}|
d
z	  dk    r	||
d	z  z   }n¹|
d	z  }|rJ|||z   k     rt          t          |||z
  fz  ¦  «        ‚||z  }|t          | ||z
  |…         d¬¦  «        z   }nh|st          d¦  «        ‚|}||dz   k     s| ||dz   …         dk    r4t          | ||d|dz   ¬¦  «        \  }}||dz   k     °#| ||dz   …         dk    °4|dz  }d}||k    rt          t          ||z
  ||z
  fz  ¦  «        ‚|r||fS |dz	  ||| ||…         | ||t          |¦  «        z
  …         |f|fS )aø  
    Parses a byte string into component parts

    :param encoded_data:
        A byte string that contains BER-encoded data

    :param data_len:
        The integer length of the encoded data

    :param pointer:
        The index in the byte string to parse from

    :param lengths_only:
        A boolean to cause the call to return a 2-element tuple of the integer
        number of bytes in the header and the integer number of bytes in the
        contents. Internal use only.

    :param depth:
        The recursion depth when evaluating indefinite-length encoding.

    :return:
        A 2-element tuple:
         - 0: A tuple of (class_, method, tag, header, content, trailer)
         - 1: An integer indicating how many bytes were consumed
    z*Indefinite-length recursion limit exceededr   é   é   r   Té€   zNon-minimal tag encodingé   é   r   F)Úsignedz-Indefinite-length element must be constructedé   s     )Úlengths_onlyÚdepthé   )Ú
_MAX_DEPTHr   Ú_INSUFFICIENT_DATA_MESSAGEÚ_PY2Úordr   r   r   )Úencoded_dataÚdata_lenÚpointerr/   r0   ÚstartÚfirst_octetr   ÚconstructedÚnumÚlength_octetÚtrailerÚcontents_endÚlength_octetsÚ_s                  r   r   r   Œ   sŒ  € ð6 �zÒÐÝÐEÑFÔFÐFà€Eà�'˜A‘+ÒÐÝÕ3°q¸(ÀWÑ:LÐ6MÑMÑNÔNÐNÝ04ÐO•#�l 7Ô+Ñ,Ô,Ð,¸,ÀwÔ:O€Kàˆq�L€Gà
˜Ñ
€CØ !Ñ# qÑ(€Kà
ˆb‚y€yØˆð
	Ø˜' A™+Ò%Ð%Ý Õ!;¸qÀ(ÈWÑBTÐ>UÑ!UÑVÔVÐVÝ04ÐO•#�l 7Ô+Ñ,Ô,Ð,¸,ÀwÔ:OˆCØ�q‰LˆGØ�dŠ{ˆ{˜s ašx˜xÝ Ð!;Ñ<Ô<Ð<Ø�3‰JˆCØ�3˜‘9ÑˆCØ�a‰x˜1Š}ˆ}Øð
	ð �Š8ˆ8ÝÐ7Ñ8Ô8Ð8à�'˜A‘+ÒÐÝÕ3°q¸(ÀWÑ:LÐ6MÑMÑNÔNÐNÝ15ÐP•3�| GÔ,Ñ-Ô-Ð-¸<ÈÔ;P€LØˆq�L€GØ€Gà�qÑ˜AÒÐØ ,°Ñ"4Ñ5ˆˆð % sÑ*ˆØð 	"Ø˜' MÑ1Ò1Ð1Ý Õ!;¸}ÈhÐY`ÑN`Ð>aÑ!aÑbÔbÐbØ�}Ñ$ˆGØ"¥^°LÀÈ=ÑAXÐY`ÐA`Ô4aÐjoÐ%pÑ%pÔ%pÑpˆLˆLð ð RÝ Ð!PÑQÔQÐQØ"ˆLØ˜\¨AÑ-Ò-Ð-°¸lÈ<ÐXYÉ>Ð>YÔ1ZÐ^iÒ1iÐ1iÝ"(¨°xÀÐ\`ÐhmÐnoÑhoÐ"pÑ"pÔ"p‘��<ð ˜\¨AÑ-Ò-Ð-°¸lÈ<ÐXYÉ>Ð>YÔ1ZÐ^iÒ1iÐ1ià˜AÑˆLØ!ˆGà�hÒÐÝÕ3°|ÀgÑ7MÈxÐZaÑOaÐ6bÑbÑcÔcÐcàð 'Ø˜Ð&Ð&ð ˜1ÑØØØ˜˜w˜Ô'Ø˜ ­c°'©l¬lÑ!:Ð:Ô;Øð	
ð 	ð
ð 
r   c                 óª  — d}d}|| dz  z  }||dz  z  }|dk    rEd}|dk    r't          ||dz  z  ¦  «        |z   }|sd}|dz	  }|dk    °'t          |dz  ¦  «        |z   }n|t          ||z  ¦  «        z  }t          |¦  «        }|dk    r|t          |¦  «        z  }n6t          |¦  «        }|t          dt          |¦  «        z  ¦  «        z  }||z  }|S )	aÇ  
    Constructs the header bytes for an ASN.1 object

    :param class_:
        An integer ASN.1 class value: 0 (universal), 1 (application),
        2 (context), 3 (private)

    :param method:
        An integer ASN.1 method value: 0 (primitive), 1 (constructed)

    :param tag:
        An integer ASN.1 tag value

    :param contents:
        A byte string of the encoded byte contents

    :return:
        A byte string of the ASN.1 DER header
    r   r   r1   r)   r(   r+   r*   r,   )r	   r   r   )	r   r   r   r   ÚheaderÚid_numÚcont_bitÚlengthÚlength_bytess	            r   r   r   ö   s  € ð* €Fà€FØ
ˆf˜‰kÑ€FØ
ˆf˜‰kÑ€Fà
ˆb‚y€yØˆØ�AŠgˆgÝ˜X¨¨t©Ñ4Ñ5Ô5¸Ñ>ˆFØð  Ø�Ø˜‘(ˆCð	 �AŠgˆgõ
 ˜ "™Ñ%Ô%¨Ñ.ˆˆà•'˜& 3™,Ñ'Ô'Ñ'ˆå�‰]Œ]€FØ�‚}€}Ø•'˜&‘/”/Ñ!ˆˆå# FÑ+Ô+ˆØ•'˜$¥ \Ñ!2Ô!2Ñ2Ñ3Ô3Ñ3ˆØ�,Ñˆà€Mr   )F)r   Fr   )Ú__doc__Ú
__future__r   r   r   r   ÚsysÚ_typesr   r	   r
   Úutilr   r   Úversion_infor4   r3   r2   r   r$   r&   r   r   © r   r   ú<module>rO      sö   ðð	ð 	ð SÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ Rà 
€
€
€
à 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø .Ð .Ð .Ð .Ð .Ð .Ð .Ð .à
Ô˜4Ò€Ø[Ð Ø€
ð.Bð .Bð .Bðb$ð $ð $ð $ðNð ð ð4gð gð gð gðT.ð .ð .ð .ð .r   