HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.60.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Nov 5 05:00:59 EST 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //var/opt/nydus/ops/cryptography/x509/__pycache__/name.cpython-39.pyc
a

�,�hx7�@s�UddlZddlZddlZddlZddlZddlmZddlmZ	ddl
mZmZGdd�dej
�Zdd�eD�ZejejejejejejejejejejejejiZejeefed	<ejeefZejd
ejdej dej!d
ej"dejdej#dejdej$di	Z%eed<dd�e%�&�D�Z'ej(ee)fed�dd�Z*eed�dd�Z+Gdd�d�Z,Gdd�d�Z-Gdd�d�Z.Gd d!�d!�Z/dS)"�N)�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�I/opt/nydus/tmp/pip-target-wkfpz8uv/lib64/python/cryptography/x509/name.pyrsrcCsi|]}|j|�qSr)�value��.0�irrr�
<dictcomp>!�r �_NAMEOID_DEFAULT_TYPEZCN�LZST�OZOU�CZSTREETZDC�UID�_NAMEOID_TO_NAMEcCsi|]\}}||�qSrr)r�k�vrrrr ;r!)�val�returncCs�|sdSt|t�r&dt�|��d�S|�dd�}|�dd�}|�dd	�}|�d
d�}|�dd
�}|�dd�}|�dd�}|�dd�}|ddvr�d|}|ddkr�|dd�d}|S)z>Escape special characters in RFC4514 Distinguished Name value.��#�utf8�\z\\�"z\"�+z\+�,z\,�;z\;�<z\<�>z\>�z\00r)r-� ���r7Nz\ )�
isinstance�bytes�binascii�hexlify�decode�replace)r*rrr�_escape_dn_value>s"
r?cCs|sdSdd�}tj�||�S)Nr,cSs(|�d�}t|�dkr|Stt|d��S)N��)�group�len�chr�int)�mr*rrr�subcs
z_unescape_dn_value.<locals>.sub)�_RFC4514NameParser�_PAIR_RErG)r*rGrrr�_unescape_dn_value[srJc@s�eZdZddd�eejeefeje	e
dd�dd�Zeed�dd	��Z
eejeefd�d
d��Zeed�dd
��Zdejeed�dd�Zee
d�dd�Zed�dd�Zed�dd�ZdS)�
NameAttributeNT)�	_validate)�oidr�_typerLr+cCs�t|t�std��|tjkrB|tjkr.td��t|t�sTtd��nt|t�sTtd��|tj	ksh|tj
kr�t|t�svJ�t|�d��}|dkr�|dur�t
d��n|dkr�tjd	�|�dd
�|dur�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 strr.�Tz/Country name must be a 2 character country codezUCountry names should be two characters, but the attribute is {} characters in length.)�
stacklevelz%_type must be from the _ASN1Type enum)r9r�	TypeErrorrrrZX500_UNIQUE_IDENTIFIERr:�str�COUNTRY_NAME�JURISDICTION_COUNTRY_NAMErC�encode�
ValueError�warnings�warn�formatr"�getr�_oid�_valuerN)�selfrMrrNrLZc_lenrrr�__init__osJ
�

�


�����
zNameAttribute.__init__�r+cCs|jS�N)r[�r]rrrrM�szNameAttribute.oidcCs|jSr`)r\rarrrr�szNameAttribute.valuecCst�|j|jj�S)zt
        The short attribute name (for example "CN") if available,
        otherwise the OID dotted string.
        )r'rZrMZ
dotted_stringrarrr�rfc4514_attribute_name�sz$NameAttribute.rfc4514_attribute_name��attr_name_overridesr+cCs6|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�=)rZrMrbr?r)r]rd�	attr_namerrr�rfc4514_string�s

�zNameAttribute.rfc4514_string��otherr+cCs&t|t�stS|j|jko$|j|jkSr`)r9rK�NotImplementedrMr�r]rirrr�__eq__�s
zNameAttribute.__eq__cCst|j|jf�Sr`)�hashrMrrarrr�__hash__�szNameAttribute.__hash__cCs
d�|�S)Nz/<NameAttribute(oid={0.oid}, value={0.value!r})>)rYrarrr�__repr__�szNameAttribute.__repr__)N)N)rrrr�typing�UnionrRr:�Optionalr�boolr^�propertyrMrrb�_OidNameMaprg�objectrlrErnrorrrrrKns0���8��rKc@s�eZdZejed�dd�Zeejed�dd�Z	dej
eed�d	d
�Z
eed�dd
�Zed�dd�Zejed�dd�Zed�dd�Zed�dd�ZdS)�RelativeDistinguishedName)�
attributescCs\t|�}|std��tdd�|D��s.td��||_t|�|_t|j�t|�krXtd��dS)Nz-a relative distinguished name cannot be emptycss|]}t|t�VqdSr`�r9rK�r�xrrr�	<genexpr>�r!z5RelativeDistinguishedName.__init__.<locals>.<genexpr>z/attributes must be an iterable of NameAttributez$duplicate attributes are not allowed)�listrV�allrQ�_attributes�	frozenset�_attribute_setrC�r]rxrrrr^�s
z"RelativeDistinguishedName.__init__�rMr+cs�fdd�|D�S)Ncsg|]}|j�kr|�qSr�rMrr�rr�
<listcomp>�r!zDRelativeDistinguishedName.get_attributes_for_oid.<locals>.<listcomp>r�r]rMrr�r�get_attributes_for_oid�sz0RelativeDistinguishedName.get_attributes_for_oidNrccsd��fdd�|jD��S)z�
        Format as RFC4514 Distinguished Name string.

        Within each RDN, attributes are joined by '+', although that is rarely
        used in certificates.
        r1c3s|]}|���VqdSr`�rg�r�attr�rdrrr|�s�z;RelativeDistinguishedName.rfc4514_string.<locals>.<genexpr>)�joinr�r]rdrr�rrg�s	�z(RelativeDistinguishedName.rfc4514_stringrhcCst|t�stS|j|jkSr`)r9rwrjr�rkrrrrl�s
z RelativeDistinguishedName.__eq__r_cCs
t|j�Sr`)rmr�rarrrrn�sz"RelativeDistinguishedName.__hash__cCs
t|j�Sr`)�iterrrarrr�__iter__sz"RelativeDistinguishedName.__iter__cCs
t|j�Sr`)rCrrarrr�__len__sz!RelativeDistinguishedName.__len__cCsd�|���S)Nz<RelativeDistinguishedName({})>)rYrgrarrrrosz"RelativeDistinguishedName.__repr__)N)rrrrp�IterablerKr^r�Listr�rrrurRrgrvrsrlrErn�Iteratorr�r�rorrrrrw�s���rwc@s eZdZejejedd�dd��Zejejedd�dd��Zejej	eefdd�dd�Ze
edd�dd	��Zd!ej
eed
�dd�Zeejed
�dd�Zeejed�dd��Zd"ejed�dd�Zeed�dd�Zed�dd�Zejed�dd�Zed�dd�Zed�dd �Z dS)#�NameN)rxr+cCsdSr`rr�rrrr^sz
Name.__init__cCsdSr`rr�rrrr^scCs`t|�}tdd�|D��r,dd�|D�|_n0tdd�|D��rTt�tjt|�|_ntd��dS)Ncss|]}t|t�VqdSr`ryrzrrrr|r!z Name.__init__.<locals>.<genexpr>cSsg|]}tt�t|�g��qSr)rwrp�castrKrzrrrr�s�z!Name.__init__.<locals>.<listcomp>css|]}t|t�VqdSr`)r9rwrzrrrr|!r!zNattributes must be a list of NameAttribute or a list RelativeDistinguishedName)r}r~rrpr�r�rwrQr�rrrr^s�

����datar+cCst|���Sr`)rH�parse)�clsr�rrr�from_rfc4514_string+szName.from_rfc4514_stringrccsd��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.
        r2c3s|]}|���VqdSr`r�r�r�rrr|<s�z&Name.rfc4514_string.<locals>.<genexpr>)r��reversedrr�rr�rrg/s
�zName.rfc4514_stringr�cs�fdd�|D�S)Ncsg|]}|j�kr|�qSrr�rr�rrr�Dr!z/Name.get_attributes_for_oid.<locals>.<listcomp>rr�rr�rr�AszName.get_attributes_for_oidr_cCs|jSr`�rrarrr�rdnsFsz	Name.rdns)�backendr+cCs
t�|�Sr`)�	rust_x509Zencode_name_bytes)r]r�rrr�public_bytesJszName.public_bytesrhcCst|t�stS|j|jkSr`)r9r�rjrrkrrrrlMs
zName.__eq__cCstt|j��Sr`)rm�tuplerrarrrrnSsz
Name.__hash__ccs |jD]}|D]
}|VqqdSr`r�)r]�rdnZavarrrr�Xs
z
Name.__iter__cCstdd�|jD��S)Ncss|]}t|�VqdSr`)rC)rr�rrrr|^r!zName.__len__.<locals>.<genexpr>)�sumrrarrrr�]szName.__len__cCs d�dd�|jD��}d�|�S)Nr2css|]}|��VqdSr`r�r�rrrr|ar!z Name.__repr__.<locals>.<genexpr>z
<Name({})>)r�rrY�r]r�rrrro`sz
Name.__repr__)N)N)!rrrrp�overloadr�rKr^rwrq�classmethodrRr�rrrurgrr�r�rtr��Anyr:r�rvrsrlrErnr�r�r�rorrrrr�
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�Zedd�dd�Zed�dd�Zejed�dd�Zedd�dd�Zed�dd�Zed�dd�Z e!d�dd �Z"e#d�d!d"�Z$dS)#rHz!(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})+Nr�cCs||_d|_dS)Nr)�_data�_idx)r]r�rrrr^�sz_RFC4514NameParser.__init__r_cCs|jt|j�kSr`)r�rCr�rarrr�	_has_data�sz_RFC4514NameParser._has_datacCs|��r|j|jSdSr`)r�r�r�rarrr�_peek�sz_RFC4514NameParser._peek)�chr+cCs"|��|krt�|jd7_dS)Nr@)r�rVr�)r]r�rrr�
_read_char�sz_RFC4514NameParser._read_charcCs<|j|j|jd�}|durt�|��}|jt|�7_|S)N)�pos)�matchr�r�rVrBrC)r]�patr�r*rrr�_read_re�sz_RFC4514NameParser._read_recCs4|��g}|��r,|�d�|�|���q
t|�S)Nr2)�
_parse_rdnr�r��appendr�r�rrrr��s


z_RFC4514NameParser.parsecCs8|��g}|��dkr0|�d�|�|���q
t|�S)Nr1)�	_parse_nar�r�r�rw)r]Znasrrrr��s


z_RFC4514NameParser._parse_rdncCs�z|�|j�}Wn4tyD|�|j�}t�|�}|dur@t�Yn
0t|�}|�d�|��dkr�|�|j	�}t
�|dd����}n|�|j
�}t|�}t||�S)Nrer-r@)r��_OID_RErV�	_DESCR_RE�_NAME_TO_NAMEOIDrZrr�r��
_HEXSTRING_REr;�	unhexlifyr=�
_STRING_RErJrK)r]Z	oid_value�namerMr�	raw_valuerrrr��s


z_RFC4514NameParser._parse_na)%rrr�re�compiler�r�Z_PAIRrIZ_LUTF1Z_SUTF1Z_TUTF1rD�sys�
maxunicodeZ_UTFMBZ	_LEADCHARZ_STRINGCHARZ
_TRAILCHAR�VERBOSEr�r�rRr^rsr�rprrr�r�r�r�r�rwr�rKr�rrrrrHesH


������	�
	rH)0r;r�r�rprWZcryptographyrZ"cryptography.hazmat.bindings._rustrr�Zcryptography.x509.oidrr�EnumrZ_ASN1_TYPE_TO_ENUMrSrrTZ
SERIAL_NUMBERZDN_QUALIFIERZ
EMAIL_ADDRESSrZDOMAIN_COMPONENTr"�Dict�__annotations__�MappingrRruZCOMMON_NAMEZ
LOCALITY_NAMEZSTATE_OR_PROVINCE_NAMEZORGANIZATION_NAMEZORGANIZATIONAL_UNIT_NAMEZSTREET_ADDRESSZUSER_IDr'�itemsr�rqr:r?rJrKrwr�rHrrrr�<module>sD
�
�g5[