Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/site-packages/cryptography/x509/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/site-packages/cryptography/x509/__pycache__/name.cpython-38.pyc
U

O��g�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*ddd�dd�Z+ddd�dd �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__�	BitStringZOctetString�
UTF8StringZ
NumericString�PrintableStringZ	T61String�	IA5StringZUTCTimeZGeneralizedTimeZ
VisibleStringZUniversalStringZ	BMPString�rr�C/opt/cppython/lib/python3.8/site-packages/cryptography/x509/name.pyrsrcCsi|]}|j|�qSr)�value��.0�irrr�
<dictcomp>!sr!z!dict[ObjectIdentifier, _ASN1Type]�_NAMEOID_DEFAULT_TYPEZCN�LZST�OZOU�CZSTREETZDC�UID�_OidNameMap�_NAMEOID_TO_NAMEcCsi|]\}}||�qSrr)r�k�vrrrr!<s)�r+)��@�str | bytes�str)�val�returncCs�|sdSt|t�r&dt�|��d�S|�dd�}|�dd�}|�dd	�}|�d
d�}|�dd
�}|�dd�}|�dd�}|�dd�}|ddkr�d|}|ddkr�|dd�d}|S)z>Escape special characters in RFC4514 Distinguished Name value.��#�utf8�\z\\�"z\"�+z\+�,z\,�;z\;�<z\<�>z\>�z\00r)r3� ���r=Nz\ )�
isinstance�bytes�binascii�hexlify�decode�replace)r0rrr�_escape_dn_valueEs"
rEcCs|sdSdd�}tj�||�S)Nr2cSs(|�d�}t|�dkr|Stt|d��S)Nr,�)�group�len�chr�int)�mr0rrr�subjs
z_unescape_dn_value.<locals>.sub)�_RFC4514NameParser�_PAIR_RErL)r0rLrrr�_unescape_dn_valuebsrOc@s�eZdZd!dd�dddddd	�d
d�Zedd�d
d��Zedd�dd��Zedd�dd��Zd"ddd�dd�Zddd�dd�Z	dd�dd�Z
dd�dd �ZdS)#�
NameAttributeNT)�	_validaterr.z_ASN1Type | None�bool�None)�oidr�_typerQr1c
Cst|t�std��|tjkrB|tjkr.td��t|t�sTtd��nt|t�sTtd��t	�
|�}|dk	r�|\}}t|t�s|t�t|�
d��}||ks�||kr�d|�d|�d|��}	|d	kr�t|	��ntj|	d
d�|dkr�t�
|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 strr4zAttribute's length must be >= z and <= z
, but it was Tr+)�
stacklevelz%_type must be from the _ASN1Type enum)r?r�	TypeErrorrrrZX500_UNIQUE_IDENTIFIERr@r/�_NAMEOID_LENGTH_LIMIT�get�AssertionErrorrH�encode�
ValueError�warnings�warnr"r�_oid�_valuerU)
�selfrTrrUrQZ
length_limitsZ
min_length�
max_lengthZc_len�msgrrr�__init__vs>
�

�



�

zNameAttribute.__init__�r1cCs|jS�N)r_�rarrrrT�szNameAttribute.oidcCs|jSrf)r`rgrrrr�szNameAttribute.valuer/cCst�|j|jj�S)zt
        The short attribute name (for example "CN") if available,
        otherwise the OID dotted string.
        )r(rYrTZ
dotted_stringrgrrr�rfc4514_attribute_name�sz$NameAttribute.rfc4514_attribute_name�_OidNameMap | None��attr_name_overridesr1cCs6|r|�|j�nd}|dkr"|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�=)rYrTrhrEr)rark�	attr_namerrr�rfc4514_string�s

�zNameAttribute.rfc4514_string�object��otherr1cCs&t|t�stS|j|jko$|j|jkSrf)r?rP�NotImplementedrTr�rarqrrr�__eq__�s
zNameAttribute.__eq__rJcCst|j|jf�Srf)�hashrTrrgrrr�__hash__�szNameAttribute.__hash__cCsd|j�d|j�d�S)Nz<NameAttribute(oid=z, value=�)>)rTrrgrrr�__repr__�szNameAttribute.__repr__)N)N)rrrrd�propertyrTrrhrnrtrvrxrrrrrPus��6�rPc@s�eZdZdd�dd�Zddd�dd	�Zd ddd
�dd�Zddd�dd�Zdd�dd�Zdd�dd�Zdd�dd�Z	dd�dd�Z
d
S)!�RelativeDistinguishedName�typing.Iterable[NameAttribute])�
attributescCs\t|�}|std��tdd�|D��s.td��||_t|�|_t|j�t|�krXtd��dS)Nz-a relative distinguished name cannot be emptycss|]}t|t�VqdSrf�r?rP�r�xrrr�	<genexpr>�sz5RelativeDistinguishedName.__init__.<locals>.<genexpr>z/attributes must be an iterable of NameAttributez$duplicate attributes are not allowed)�listr\�allrW�_attributes�	frozenset�_attribute_setrH�rar|rrrrd�s
z"RelativeDistinguishedName.__init__r�list[NameAttribute]�rTr1cs�fdd�|D�S)Ncsg|]}|j�kr|�qSr�rTrr�rr�
<listcomp>�s
zDRelativeDistinguishedName.get_attributes_for_oid.<locals>.<listcomp>r�rarTrr�r�get_attributes_for_oid�sz0RelativeDistinguishedName.get_attributes_for_oidNrir/rjcsd��fdd�|jD��S)z�
        Format as RFC4514 Distinguished Name string.

        Within each RDN, attributes are joined by '+', although that is rarely
        used in certificates.
        r7c3s|]}|���VqdSrf�rn�r�attr�rkrrr��s�z;RelativeDistinguishedName.rfc4514_string.<locals>.<genexpr>��joinr��rarkrr�rrn�s	�z(RelativeDistinguishedName.rfc4514_stringrorRrpcCst|t�stS|j|jkSrf)r?rzrrr�rsrrrrt�s
z RelativeDistinguishedName.__eq__rJrecCs
t|j�Srf)rur�rgrrrrvsz"RelativeDistinguishedName.__hash__�typing.Iterator[NameAttribute]cCs
t|j�Srf)�iterr�rgrrr�__iter__sz"RelativeDistinguishedName.__iter__cCs
t|j�Srf)rHr�rgrrr�__len__sz!RelativeDistinguishedName.__len__cCsd|���d�S)Nz<RelativeDistinguishedName(rwr�rgrrrrxsz"RelativeDistinguishedName.__repr__)N)rrrrdr�rnrtrvr�r�rxrrrrrz�s�rzc@s�eZdZejddd�dd��Zejddd�dd��Zddd�d	d�Zed1dddd
�dd��Zd2ddd�dd�Zddd�dd�Z	e
dd�dd��Zd3ddd�d d!�Zd"d#d$�d%d&�Z
d'd�d(d)�Zd*d�d+d,�Zd'd�d-d.�Zdd�d/d0�Zd
S)4�Namer{rS)r|r1cCsdSrfrr�rrrrdsz
Name.__init__z*typing.Iterable[RelativeDistinguishedName]cCsdSrfrr�rrrrdsz:typing.Iterable[NameAttribute | RelativeDistinguishedName]cCs`t|�}tdd�|D��r,dd�|D�|_n0tdd�|D��rTt�tjt|�|_ntd��dS)Ncss|]}t|t�VqdSrfr}r~rrrr�sz Name.__init__.<locals>.<genexpr>cSsg|]}tt�t|�g��qSr)rz�typing�castrPr~rrrr�s�z!Name.__init__.<locals>.<listcomp>css|]}t|t�VqdSrf)r?rzr~rrrr�"szNattributes must be a list of NameAttribute or a list RelativeDistinguishedName)r�r�r�r�r��ListrzrWr�rrrrds�
��Nr/z_NameOidMap | None��datarkr1cCst||p
i���Srf)rM�parse)�clsr�rkrrr�from_rfc4514_string,szName.from_rfc4514_stringrirjcsd��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.
        r8c3s|]}|���VqdSrfr�r�r�rrr�As�z&Name.rfc4514_string.<locals>.<genexpr>)r��reversedr�r�rr�rrn4s
�zName.rfc4514_stringrr�r�cs�fdd�|D�S)Ncsg|]}|j�kr|�qSrr�rr�rrr�Is
z/Name.get_attributes_for_oid.<locals>.<listcomp>rr�rr�rr�FszName.get_attributes_for_oidzlist[RelativeDistinguishedName]recCs|jSrf�r�rgrrr�rdnsKsz	Name.rdnsz
typing.Anyr@)�backendr1cCs
t�|�Srf)�	rust_x509Zencode_name_bytes)rar�rrr�public_bytesOszName.public_bytesrorRrpcCst|t�stS|j|jkSrf)r?r�rrr�rsrrrrtRs
zName.__eq__rJcCstt|j��Srf)ru�tupler�rgrrrrvXsz
Name.__hash__r�ccs|jD]}|EdHqdSrfr�)ra�rdnrrrr�]s
z
Name.__iter__cCstdd�|jD��S)Ncss|]}t|�VqdSrf)rH)rr�rrrr�bszName.__len__.<locals>.<genexpr>)�sumr�rgrrrr�aszName.__len__cCs"d�dd�|jD��}d|�d�S)Nr8css|]}|��VqdSrfr�r�rrrr�esz Name.__repr__.<locals>.<genexpr>z<Name(rwr��rar�rrrrxdsz
Name.__repr__)N)N)N)rrrr��overloadrd�classmethodr�rnr�ryr�r�rtrvr�r�rxrrrrr�s&��r�c@s*eZdZe�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�Zdddd�dd�Zdd�dd�Zdd�dd�Zddd�dd�Zdd�dd �Zd!d�d"d#�Zd$d�d%d&�Zd'd�d(d)�Zd*S)+rMz!(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/�_NameOidMaprSr�cCs||_d|_||_dS)Nr)�_data�_idx�_attr_name_overrides)rar�rkrrrrd�sz_RFC4514NameParser.__init__rRrecCs|jt|j�kSrf)r�rHr�rgrrr�	_has_data�sz_RFC4514NameParser._has_dataz
str | NonecCs|��r|j|jSdSrf)r�r�r�rgrrr�_peek�sz_RFC4514NameParser._peek)�chr1cCs"|��|krt�|jd7_dS)Nr,)r�r\r�)rar�rrr�
_read_char�sz_RFC4514NameParser._read_charcCs<|j|j|jd�}|dkrt�|��}|jt|�7_|S)N)�pos)�matchr�r�r\rGrH)ra�patr�r0rrr�_read_re�sz_RFC4514NameParser._read_rer�cCsH|��stg�S|��g}|��r<|�d�|�|���qtt|��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.
        r8)r�r��
_parse_rdnr��appendr�r�rrrr��s


z_RFC4514NameParser.parserzcCs8|��g}|��dkr0|�d�|�|���q
t|�S)Nr7)�	_parse_nar�r�r�rz)raZnasrrrr��s


z_RFC4514NameParser._parse_rdnrPc	Cs�z|�|j�}Wn@tk
rP|�|j�}|j�|t�|��}|dkrLt�Yn
Xt|�}|�d�|�	�dkr�|�|j
�}t�|dd���
�}n|�|j�}t|�}t||�S)Nrlr3r,)r��_OID_REr\�	_DESCR_REr�rY�_NAME_TO_NAMEOIDrr�r��
_HEXSTRING_RErA�	unhexlifyrC�
_STRING_RErOrP)raZ	oid_value�namerTrZ	raw_valuerrrr��s$�

z_RFC4514NameParser._parse_naN)rrr�re�compiler�r�Z_PAIRrNZ_LUTF1Z_SUTF1Z_TUTF1rI�sys�
maxunicodeZ_UTFMBZ	_LEADCHARZ_STRINGCHARZ
_TRAILCHAR�VERBOSEr�r�rdr�r�r�r�r�r�r�rrrrrMisH


������	�
rM)1�
__future__rrAr�r�r�r]ZcryptographyrZ"cryptography.hazmat.bindings._rustrr�Zcryptography.x509.oidrr�EnumrZ_ASN1_TYPE_TO_ENUMZCOUNTRY_NAMErZJURISDICTION_COUNTRY_NAMEZ
SERIAL_NUMBERZDN_QUALIFIERZ
EMAIL_ADDRESSrZDOMAIN_COMPONENTr"�__annotations__�Mappingr/r'r�ZCOMMON_NAMEZ
LOCALITY_NAMEZSTATE_OR_PROVINCE_NAMEZORGANIZATION_NAMEZORGANIZATIONAL_UNIT_NAMEZSTREET_ADDRESSZUSER_IDr(�itemsr�rXrErOrPrzr�rMrrrr�<module>sv�
��e5Z

F1le Man4ger