HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib/python3.10/site-packages/cryptography/x509/__pycache__/name.cpython-310.pyc
o

�h�9�@s�UddlmZddlZddlZddlZddlZddlZddlmZddl	m
Zddlm
Z
mZGdd�dej�Zdd	�eD�Ze
jeje
jeje
jeje
jeje
jeje
jejiZd
ed<ejeefZejeefZe
j de
j!d
e
j"de
j#de
j$de
jde
j%de
jde
j&di	Z'ded<dd	�e'�(�D�Z)e
jde
jde
j diZ*d*dd�Z+d+d d!�Z,Gd"d#�d#�Z-Gd$d%�d%�Z.Gd&d'�d'�Z/Gd(d)�d)�Z0dS),�)�annotationsN)�utils)�x509)�NameOID�ObjectIdentifierc@s<eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
S)�	_ASN1Type������������N)�__name__�
__module__�__qualname__�	BitString�OctetString�
UTF8String�
NumericString�PrintableString�	T61String�	IA5String�UTCTime�GeneralizedTime�
VisibleString�UniversalString�	BMPString�r#r#�I/usr/local/CyberCP/lib/python3.10/site-packages/cryptography/x509/name.pyrsrcCsi|]}|j|�qSr#)�value��.0�ir#r#r$�
<dictcomp>!sr)z!dict[ObjectIdentifier, _ASN1Type]�_NAMEOID_DEFAULT_TYPE�CN�L�ST�O�OU�C�STREET�DC�UID�_OidNameMap�_NAMEOID_TO_NAMEcCsi|]\}}||�qSr#r#)r'�k�vr#r#r$r)<s)�r8)��@�val�str | bytes�return�strcCs�|sdSt|t�rdt�|��d�S|�dd�}|�dd�}|�dd	�}|�d
d�}|�dd
�}|�dd�}|�dd�}|�dd�}|ddvrMd|}|ddkr[|dd�d}|S)z>Escape special characters in RFC4514 Distinguished Name value.��#�utf8�\z\\�"z\"�+z\+�,z\,�;z\;�<z\<�>z\>�z\00r)r@� ���rJNz\ )�
isinstance�bytes�binascii�hexlify�decode�replace)r;r#r#r$�_escape_dn_valueEs"
rRcCs|sdSdd�}tj�||�S)Nr?cSs(|�d�}t|�dkr
|Stt|d��S)Nr9�)�group�len�chr�int)�mr;r#r#r$�subjs
z_unescape_dn_value.<locals>.sub)�_RFC4514NameParser�_PAIR_RErY)r;rYr#r#r$�_unescape_dn_valuebsr\c@sveZdZ	d$dd�d%dd�Zed&dd��Zed'dd��Zed(dd��Z	d$d)dd�Zd*dd�Z	d+d d!�Z
d(d"d#�ZdS),�
NameAttributeNT)�	_validate�oidrr%r<�_type�_ASN1Type | Noner^�boolr=�Nonec
Cst|t�s	td��|tjkr!|tjkrtd��t|t�s td��n	t|t�s*td��t	�
|�}|durg|\}}t|t�s>J�t|�d��}||ksM||krgd|�d|�d|��}	|d	ur`t
|	��tj|	d
d�|durrt�
|tj�}t|t�s{td��||_||_||_dS)
Nz2oid argument must be an ObjectIdentifier instance.z6oid must be X500_UNIQUE_IDENTIFIER for BitString type.z!value must be bytes for BitStringzvalue argument must be a strrAzAttribute's length must be >= z and <= z
, but it was Tr8)�
stacklevelz%_type must be from the _ASN1Type enum)rLr�	TypeErrorrrr�X500_UNIQUE_IDENTIFIERrMr>�_NAMEOID_LENGTH_LIMIT�getrU�encode�
ValueError�warnings�warnr*r�_oid�_valuer`)
�selfr_r%r`r^�
length_limits�
min_length�
max_length�c_len�msgr#r#r$�__init__vsH
�

�
�

���

zNameAttribute.__init__cC�|jS�N)rm�ror#r#r$r_��zNameAttribute.oidcCrvrw)rnrxr#r#r$r%�ryzNameAttribute.valuer>cCst�|j|jj�S)zt
        The short attribute name (for example "CN") if available,
        otherwise the OID dotted string.
        )r5rhr_�
dotted_stringrxr#r#r$�rfc4514_attribute_name��z$NameAttribute.rfc4514_attribute_name�attr_name_overrides�_OidNameMap | NonecCs6|r|�|j�nd}|dur|j}|�dt|j���S)z�
        Format as RFC4514 Distinguished Name string.

        Use short attribute name if available, otherwise fall back to OID
        dotted string.
        N�=)rhr_r{rRr%)ror}�	attr_namer#r#r$�rfc4514_string�s

�zNameAttribute.rfc4514_string�other�objectcCs&t|t�stS|j|jko|j|jkSrw)rLr]�NotImplementedr_r%�ror�r#r#r$�__eq__�s
zNameAttribute.__eq__rWcCst|j|jf�Srw)�hashr_r%rxr#r#r$�__hash__��zNameAttribute.__hash__cCsd|j�d|j�d�S)Nz<NameAttribute(oid=z, value=�)>)r_r%rxr#r#r$�__repr__�szNameAttribute.__repr__rw)
r_rr%r<r`rar^rbr=rc)r=r)r=r<�r=r>�r}r~r=r>�r�r�r=rb�r=rW)rrrru�propertyr_r%r{r�r�r�r�r#r#r#r$r]us ��6�

r]c@s`eZdZd dd�Zd!d	d
�Z	d"d#dd�Zd$dd�Zd%dd�Zd&dd�Zd%dd�Z	d'dd�Z
dS)(�RelativeDistinguishedName�
attributes�typing.Iterable[NameAttribute]cCs\t|�}|s
td��tdd�|D��std��||_t|�|_t|j�t|�kr,td��dS)Nz-a relative distinguished name cannot be emptycs��|]}t|t�VqdSrw�rLr]�r'�xr#r#r$�	<genexpr>���z5RelativeDistinguishedName.__init__.<locals>.<genexpr>z/attributes must be an iterable of NameAttributez$duplicate attributes are not allowed)�listrj�allre�_attributes�	frozenset�_attribute_setrU�ror�r#r#r$ru�s
�z"RelativeDistinguishedName.__init__r_rr=�list[NameAttribute]c��fdd�|D�S)Nc�g|]	}|j�kr|�qSr#�r_r&r�r#r$�
<listcomp>��zDRelativeDistinguishedName.get_attributes_for_oid.<locals>.<listcomp>r#�ror_r#r�r$�get_attributes_for_oid��z0RelativeDistinguishedName.get_attributes_for_oidNr}r~r>csd��fdd�|jD��S)z�
        Format as RFC4514 Distinguished Name string.

        Within each RDN, attributes are joined by '+', although that is rarely
        used in certificates.
        rDc3��|]}|���VqdSrw�r��r'�attr�r}r#r$r���
��
�z;RelativeDistinguishedName.rfc4514_string.<locals>.<genexpr>��joinr��ror}r#r�r$r��s	�z(RelativeDistinguishedName.rfc4514_stringr�r�rbcC�t|t�stS|j|jkSrw)rLr�r�r�r�r#r#r$r���
z RelativeDistinguishedName.__eq__rWcC�
t|j�Srw)r�r�rxr#r#r$r��
z"RelativeDistinguishedName.__hash__�typing.Iterator[NameAttribute]cCr�rw)�iterr�rxr#r#r$�__iter__r�z"RelativeDistinguishedName.__iter__cCr�rw)rUr�rxr#r#r$�__len__r�z!RelativeDistinguishedName.__len__cCsd|���d�S)Nz<RelativeDistinguishedName(r�r�rxr#r#r$r�r�z"RelativeDistinguishedName.__repr__)r�r��r_rr=r�rwr�r�r��r=r�r�)rrrrur�r�r�r�r�r�r�r#r#r#r$r��s

�



r�c@s�eZdZejd1dd��Zejd2dd��Zd3d
d�Ze	d4d5dd��Z	d4d6dd�Zd7dd�Z	e
d8dd��Zd4d9d d!�Zd:d%d&�Z
d;d(d)�Zd<d+d,�Zd;d-d.�Zd=d/d0�ZdS)>�Namer�r�r=rccC�dSrwr#r�r#r#r$rusz
Name.__init__�*typing.Iterable[RelativeDistinguishedName]cCr�rwr#r�r#r#r$rus�:typing.Iterable[NameAttribute | RelativeDistinguishedName]cCs`t|�}tdd�|D��rdd�|D�|_dStdd�|D��r,t�tjt|�|_dStd��)Ncsr�rwr�r�r#r#r$r�r�z Name.__init__.<locals>.<genexpr>cSsg|]}tt�t|�g��qSr#)r��typing�castr]r�r#r#r$r�s��z!Name.__init__.<locals>.<listcomp>csr�rw)rLr�r�r#r#r$r�"r�zNattributes must be a list of NameAttribute or a list RelativeDistinguishedName)r�r�r�r�r��Listr�rer�r#r#r$rus�

��N�datar>r}�_NameOidMap | NonecCst||pi���Srw)rZ�parse)�clsr�r}r#r#r$�from_rfc4514_string,r|zName.from_rfc4514_stringr~csd��fdd�t|j�D��S)a�
        Format as RFC4514 Distinguished Name string.
        For example 'CN=foobar.com,O=Foo Corp,C=US'

        An X.509 name is a two-level structure: a list of sets of attributes.
        Each list element is separated by ',' and within each list element, set
        elements are separated by '+'. The latter is almost never used in
        real world certificates. According to RFC4514 section 2.1 the
        RDNSequence must be reversed when converting to string representation.
        rEc3r�rwr�r�r�r#r$r�Ar�z&Name.rfc4514_string.<locals>.<genexpr>)r��reversedr�r�r#r�r$r�4s
�zName.rfc4514_stringr_rr�cr�)Ncr�r#r�r&r�r#r$r�Ir�z/Name.get_attributes_for_oid.<locals>.<listcomp>r#r�r#r�r$r�Fr�zName.get_attributes_for_oid�list[RelativeDistinguishedName]cCrvrw�r�rxr#r#r$�rdnsKryz	Name.rdns�backend�
typing.AnyrMcCs
t�|�Srw)�	rust_x509�encode_name_bytes)ror�r#r#r$�public_bytesOr�zName.public_bytesr�r�rbcCr�rw)rLr�r�r�r�r#r#r$r�Rr�zName.__eq__rWcCstt|j��Srw)r��tupler�rxr#r#r$r�Xsz
Name.__hash__r�ccs�|jD]}|EdHqdSrwr�)ro�rdnr#r#r$r�]s�
�z
Name.__iter__cCstdd�|jD��S)Ncss�|]}t|�VqdSrw)rU)r'r�r#r#r$r�b��zName.__len__.<locals>.<genexpr>)�sumr�rxr#r#r$r�aszName.__len__cCs"d�dd�|jD��}d|�d�S)NrEcss�|]}|��VqdSrwr�r�r#r#r$r�er�z Name.__repr__.<locals>.<genexpr>z<Name(r�r��ror�r#r#r$r�dsz
Name.__repr__)r�r�r=rc)r�r�r=rc)r�r�r=rcrw)r�r>r}r�r=r�r�r�)r=r�)r�r�r=rMr�r�r�r�)rrrr��overloadru�classmethodr�r�r�r�r�r�r�r�r�r�r�r#r#r#r$r�s(
��




r�c@seZdZe�d�Ze�d�ZdZe�e�ZdZ	dZ
dZdee
j��d�Ze	�d	e��Ze
�d	e��Ze�d	e��Ze�d
e�d	e�de�d	e�de�d	e�d
�
ej�Ze�d�Zd,dd�Zd-dd�Zd.dd�Zd/dd�Zd0d d!�Zd1d#d$�Zd2d&d'�Zd3d)d*�Zd+S)4rZz!(0|([1-9]\d*))(\.(0|([1-9]\d*)))+z[a-zA-Z][a-zA-Z\d-]*z!\\([\\ #=\"\+,;<>]|[\da-zA-Z]{2})z7[\x01-\x1f\x21\x24-\x2A\x2D-\x3A\x3D\x3F-\x5B\x5D-\x7F]z3[\x01-\x21\x23-\x2A\x2D-\x3A\x3D\x3F-\x5B\x5D-\x7F]z7[\x01-\x1F\x21\x23-\x2A\x2D-\x3A\x3D\x3F-\x5B\x5D-\x7F]z[\x80-�]�|z
        (
            (z!)
            (
                (z)*
                (z$)
            )?
        )?
        z#([\da-zA-Z]{2})+r�r>r}�_NameOidMapr=rccCs||_d|_||_dS)Nr)�_data�_idx�_attr_name_overrides)ror�r}r#r#r$ru�s
z_RFC4514NameParser.__init__rbcCs|jt|j�kSrw)r�rUr�rxr#r#r$�	_has_data�r�z_RFC4514NameParser._has_data�
str | NonecCs|��r
|j|jSdSrw)r�r�r�rxr#r#r$�_peek�sz_RFC4514NameParser._peek�chcCs"|��|krt�|jd7_dS)Nr9)r�rjr�)ror�r#r#r$�
_read_char�sz_RFC4514NameParser._read_charcCs<|j|j|jd�}|durt�|��}|jt|�7_|S)N)�pos)�matchr�r�rjrTrU)ro�patr�r;r#r#r$�_read_re�sz_RFC4514NameParser._read_rer�cCsN|��stg�S|��g}|��r!|�d�|�|���|��stt|��S)a'
        Parses the `data` string and converts it to a Name.

        According to RFC4514 section 2.1 the RDNSequence must be
        reversed when converting to string representation. So, when
        we parse it, we need to reverse again to get the RDNs on the
        correct order.
        rE)r�r��
_parse_rdnr��appendr�r�r#r#r$r��s


�z_RFC4514NameParser.parser�cCsB|��g}|��dkr|�d�|�|���|��dkst|�S)NrD)�	_parse_nar�r�r�r�)ro�nasr#r#r$r��s

�z_RFC4514NameParser._parse_rdnr]c	Cs�z|�|j�}Wnty'|�|j�}|j�|t�|��}|dur%t�Ynwt|�}|�d�|�	�dkrI|�|j
�}t�|dd���
�}n
|�|j�}t|�}t||�S)Nrr@r9)r��_OID_RErj�	_DESCR_REr�rh�_NAME_TO_NAMEOIDrr�r��
_HEXSTRING_RErN�	unhexlifyrP�
_STRING_REr\r])ro�	oid_value�namer_r%�	raw_valuer#r#r$r��s&
���

z_RFC4514NameParser._parse_naN)r�r>r}r�r=rc)r=rb)r=r�)r�r>r=rcr�)r=r�)r=r�)r=r])rrr�re�compiler�r��_PAIRr[�_LUTF1�_SUTF1�_TUTF1rV�sys�
maxunicode�_UTFMB�	_LEADCHAR�_STRINGCHAR�
_TRAILCHAR�VERBOSEr�r�rur�r�r�r�r�r�r�r#r#r#r$rZisJ


������	�







rZ)r;r<r=r>)r;r>r=r>)1�
__future__rrNr�r�r�rk�cryptographyr�"cryptography.hazmat.bindings._rustrr��cryptography.x509.oidrr�Enumr�_ASN1_TYPE_TO_ENUM�COUNTRY_NAMEr�JURISDICTION_COUNTRY_NAME�
SERIAL_NUMBER�DN_QUALIFIER�
EMAIL_ADDRESSr�DOMAIN_COMPONENTr*�__annotations__�Mappingr>r4r��COMMON_NAME�
LOCALITY_NAME�STATE_OR_PROVINCE_NAME�ORGANIZATION_NAME�ORGANIZATIONAL_UNIT_NAME�STREET_ADDRESS�USER_IDr5�itemsr�rgrRr\r]r�r�rZr#r#r#r$�<module>sR�
��

e5Z