HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //proc/1233/cwd/usr/lib/python3/dist-packages/cryptography/x509/__pycache__/name.cpython-38.pyc
U

�>bA!�@sddlZddlmZddlmZddlmZmZGdd�dej�Z	dd�e	D�Z
e�Zej
e	jeje	jeje	jeje	jeje	jeje	jiZejd	ejd
ejdejdejd
ej
dejdejdejdi	Zdd�ZGdd�de�ZGdd�de�Z Gdd�de�Z!dS)�N)�utils)�_get_backend)�NameOID�ObjectIdentifierc@s4eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdS)�	_ASN1Type����������N)
�__name__�
__module__�__qualname__�
UTF8StringZ
NumericString�PrintableStringZ	T61String�	IA5StringZUTCTimeZGeneralizedTimeZ
VisibleStringZUniversalStringZ	BMPString�rr�8/usr/lib/python3/dist-packages/cryptography/x509/name.pyrsrcCsi|]}|j|�qSr)�value��.0�irrr�
<dictcomp>srZCN�LZST�OZOU�CZSTREETZDCZUIDcCs�|sdS|�dd�}|�dd�}|�dd�}|�dd	�}|�d
d�}|�dd
�}|�dd�}|�dd�}|ddkr|d|}|ddkr�|dd�d}|S)z>Escape special characters in RFC4514 Distinguished Name value.��\z\\�"z\"�+z\+�,z\,�;z\;�<z\<�>z\>�z\00r)�#� ���r+Nz\ )�replace)�valrrr�_escape_dn_value3sr/c@s~eZdZefeed�dd�Ze�d�Z	e�d�Z
ed�dd�Zee
d	�d
d�Zee
d	�dd
�Zed�dd�Zed�dd�ZdS)�
NameAttribute)�oidrcCs�t|t�std��t|t�s$td��|tjks8|tjkrRt|�d��dkrRt	d��|t
krht�|t
j�}t|t
�sztd��||_||_||_dS)Nz2oid argument must be an ObjectIdentifier instance.z#value argument must be a text type.�utf8�z/Country name must be a 2 character country codez%_type must be from the _ASN1Type enum)�
isinstancer�	TypeError�strr�COUNTRY_NAME�JURISDICTION_COUNTRY_NAME�len�encode�
ValueError�	_SENTINEL�_NAMEOID_DEFAULT_TYPE�getrr�_oid�_value�_type)�selfr1rrArrr�__init__Ls*
�
���

zNameAttribute.__init__r?r@��returncCs$t�|j|jj�}d|t|j�fS)z�
        Format as RFC4514 Distinguished Name string.

        Use short attribute name if available, otherwise fall back to OID
        dotted string.
        z%s=%s)�_NAMEOID_TO_NAMEr>r1�
dotted_stringr/r)rB�keyrrr�rfc4514_stringqszNameAttribute.rfc4514_string��otherrEcCs&t|t�stS|j|jko$|j|jkS�N)r4r0�NotImplementedr1r�rBrKrrr�__eq__{s
zNameAttribute.__eq__cCs
||kSrLrrNrrr�__ne__�szNameAttribute.__ne__cCst|j|jf�SrL)�hashr1r�rBrrr�__hash__�szNameAttribute.__hash__cCs
d�|�S)Nz/<NameAttribute(oid={0.oid}, value={0.value!r})>)�formatrRrrr�__repr__�szNameAttribute.__repr__N)rrrr<rr6rCr�read_only_propertyr1rrI�object�boolrOrP�intrSrUrrrrr0Ks"


r0c@s�eZdZejed�dd�Zejed�dd�Ze	d�dd�Z
eed	�d
d�Z
eed	�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�VqdSrL�r4r0�r�xrrr�	<genexpr>�sz5RelativeDistinguishedName.__init__.<locals>.<genexpr>z/attributes must be an iterable of NameAttributez$duplicate attributes are not allowed)�listr;�allr5�_attributes�	frozenset�_attribute_setr9�rBr[rrrrC�s
z"RelativeDistinguishedName.__init__rDcs�fdd�|D�S)Ncsg|]}|j�kr|�qSr�r1rrfrr�
<listcomp>�s
zDRelativeDistinguishedName.get_attributes_for_oid.<locals>.<listcomp>r�rBr1rrfr�get_attributes_for_oid�sz0RelativeDistinguishedName.get_attributes_for_oidcCsd�dd�|jD��S)z�
        Format as RFC4514 Distinguished Name string.

        Within each RDN, attributes are joined by '+', although that is rarely
        used in certificates.
        r$css|]}|��VqdSrL�rI�r�attrrrrr_�sz;RelativeDistinguishedName.rfc4514_string.<locals>.<genexpr>)�joinrbrRrrrrI�sz(RelativeDistinguishedName.rfc4514_stringrJcCst|t�stS|j|jkSrL)r4rZrMrdrNrrrrO�s
z RelativeDistinguishedName.__eq__cCs
||kSrLrrNrrrrP�sz RelativeDistinguishedName.__ne__cCs
t|j�SrL)rQrdrRrrrrS�sz"RelativeDistinguishedName.__hash__cCs
t|j�SrL)�iterrbrRrrr�__iter__�sz"RelativeDistinguishedName.__iter__cCs
t|j�SrL)r9rbrRrrr�__len__�sz!RelativeDistinguishedName.__len__cCsd�|���S)Nz<RelativeDistinguishedName({})>)rTrIrRrrrrU�sz"RelativeDistinguishedName.__repr__N)rrr�typing�Iterabler0rC�Listrir6rIrWrXrOrPrYrS�IteratorrorprUrrrrrZ�s	rZc@s�eZdZdd�Zed�dd�Zejed�dd�Z	e
ejed�dd	��Z
ded�dd�Zeed
�dd�Zeed
�dd�Zed�dd�Zejed�dd�Zed�dd�Zed�dd�Zd
S)�NamecCsRt|�}tdd�|D��r,dd�|D�|_n"tdd�|D��rF||_ntd��dS)Ncss|]}t|t�VqdSrLr\r]rrrr_�sz Name.__init__.<locals>.<genexpr>cSsg|]}t|g��qSr)rZr]rrrrg�sz!Name.__init__.<locals>.<listcomp>css|]}t|t�VqdSrL)r4rZr]rrrr_�szNattributes must be a list of NameAttribute or a list RelativeDistinguishedName)r`rarbr5rerrrrC�s�
�z
Name.__init__rDcCsd�dd�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.
        r%css|]}|��VqdSrLrjrkrrrr_�sz&Name.rfc4514_string.<locals>.<genexpr>)rm�reversedrbrRrrrrI�s
�zName.rfc4514_stringcs�fdd�|D�S)Ncsg|]}|j�kr|�qSrrfrrfrrrg�s
z/Name.get_attributes_for_oid.<locals>.<listcomp>rrhrrfrri�szName.get_attributes_for_oidcCs|jSrL�rbrRrrr�rdns�sz	Name.rdnsNcCst|�}|�|�SrL)r�x509_name_bytes)rB�backendrrr�public_bytes�szName.public_bytesrJcCst|t�stS|j|jkSrL)r4rurMrbrNrrrrO�s
zName.__eq__cCs
||kSrLrrNrrrrP�szName.__ne__cCstt|j��SrL)rQ�tuplerbrRrrrrS�sz
Name.__hash__ccs |jD]}|D]
}|VqqdSrLrw)rB�rdnZavarrrro�s
z
Name.__iter__cCstdd�|jD��S)Ncss|]}t|�VqdSrL)r9)rr}rrrr_�szName.__len__.<locals>.<genexpr>)�sumrbrRrrrrp�szName.__len__cCs d�dd�|jD��}d�|�S)Nr%css|]}|��VqdSrLrjrkrrrr_�sz Name.__repr__.<locals>.<genexpr>z
<Name({})>)rmrbrT)rBrxrrrrU�sz
Name.__repr__)N)rrrrCr6rIrqrsr0ri�propertyrrrZrx�bytesr{rWrXrOrPrYrSrtrorprUrrrrru�sru)"rq�cryptographyr�cryptography.hazmat.backendsr�cryptography.x509.oidrr�EnumrZ_ASN1_TYPE_TO_ENUMrWr<r7rr8�
SERIAL_NUMBER�DN_QUALIFIER�
EMAIL_ADDRESSr�DOMAIN_COMPONENTr=�COMMON_NAME�
LOCALITY_NAME�STATE_OR_PROVINCE_NAME�ORGANIZATION_NAME�ORGANIZATIONAL_UNIT_NAMEZSTREET_ADDRESSZUSER_IDrFr/r0rZrurrrr�<module>sT
��
@1