ok

Mini Shell

Direktori : /usr/lib64/python3.6/site-packages/cryptography/x509/__pycache__/
Upload File :
Current File : //usr/lib64/python3.6/site-packages/cryptography/x509/__pycache__/name.cpython-36.pyc

3

l�_c �@sddlmZmZmZddlmZddlZddlmZddl	m
Z
ddlmZm
Z
Gdd�de�Zd	d
�eD�Ze�ZejejejejejejejejejejejejiZejdejdejd
ejdejdejdej dejdej!di	Z"dd�Z#Gdd�de�Z$Gdd�de�Z%Gdd�de�Z&dS)�)�absolute_import�division�print_function)�EnumN)�utils)�_get_backend)�NameOID�ObjectIdentifierc@s4eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdS)�	_ASN1Type����������N)
�__name__�
__module__�__qualname__�
UTF8StringZ
NumericString�PrintableStringZ	T61String�	IA5StringZUTCTimeZGeneralizedTimeZ
VisibleStringZUniversalStringZ	BMPString�rr�/usr/lib64/python3.6/name.pyr
sr
cCsi|]}||j�qSr)�value)�.0�irrr�
<dictcomp>sr ZCN�LZST�OZOU�CZSTREETZDCZUIDcCs�|sdS|jdd�}|jdd�}|jdd�}|jdd	�}|jd
d�}|jdd
�}|jdd�}|jdd�}|ddkr|d|}|ddkr�|dd�d}|S)z>Escape special characters in RFC4514 Distinguished Name value.��\z\\�"z\"�+z\+�,z\,�;z\;�<z\<�>z\>�z\00r�#� �Nz\ )r-r.���r0)�replace)�valrrr�_escape_dn_value7sr3c@sTeZdZefdd�Zejd�Zejd�Zdd�Z	dd�Z
d	d
�Zdd�Zd
d�Z
dS)�
NameAttributecCs�t|t�std��t|tj�s&td��|tjks:|tjkrTt|j	d��dkrTt
d��|tkrjtj
|tj�}t|t�s|td��||_||_||_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�sixZ	text_typer�COUNTRY_NAME�JURISDICTION_COUNTRY_NAME�len�encode�
ValueError�	_SENTINEL�_NAMEOID_DEFAULT_TYPE�getr
r�_oid�_value�_type)�self�oidrrDrrr�__init__Ps"


	
zNameAttribute.__init__rBrCcCs$tj|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_NAMErArFZ
dotted_stringr3r)rE�keyrrr�rfc4514_stringuszNameAttribute.rfc4514_stringcCs&t|t�stS|j|jko$|j|jkS)N)r7r4�NotImplementedrFr)rE�otherrrr�__eq__s
zNameAttribute.__eq__cCs
||kS)Nr)rErLrrr�__ne__�szNameAttribute.__ne__cCst|j|jf�S)N)�hashrFr)rErrr�__hash__�szNameAttribute.__hash__cCs
dj|�S)Nz/<NameAttribute(oid={0.oid}, value={0.value!r})>)�format)rErrr�__repr__�szNameAttribute.__repr__N)rrrr?rGrZread_only_propertyrFrrJrMrNrPrRrrrrr4Os"


r4c@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�RelativeDistinguishedNamecCs\t|�}|std��tdd�|D��s.td��||_t|�|_t|j�t|�krXtd��dS)Nz-a relative distinguished name cannot be emptycss|]}t|t�VqdS)N)r7r4)r�xrrr�	<genexpr>�sz5RelativeDistinguishedName.__init__.<locals>.<genexpr>z/attributes must be an iterable of NameAttributez$duplicate attributes are not allowed)�listr>�allr8�_attributes�	frozenset�_attribute_setr<)rE�
attributesrrrrG�s
z"RelativeDistinguishedName.__init__cs�fdd�|D�S)Ncsg|]}|j�kr|�qSr)rF)rr)rFrr�
<listcomp>�szDRelativeDistinguishedName.get_attributes_for_oid.<locals>.<listcomp>r)rErFr)rFr�get_attributes_for_oid�sz0RelativeDistinguishedName.get_attributes_for_oidcCsdjdd�|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|]}|j�VqdS)N)rJ)r�attrrrrrU�sz;RelativeDistinguishedName.rfc4514_string.<locals>.<genexpr>)�joinrX)rErrrrJ�sz(RelativeDistinguishedName.rfc4514_stringcCst|t�stS|j|jkS)N)r7rSrKrZ)rErLrrrrM�s
z RelativeDistinguishedName.__eq__cCs
||kS)Nr)rErLrrrrN�sz RelativeDistinguishedName.__ne__cCs
t|j�S)N)rOrZ)rErrrrP�sz"RelativeDistinguishedName.__hash__cCs
t|j�S)N)�iterrX)rErrr�__iter__�sz"RelativeDistinguishedName.__iter__cCs
t|j�S)N)r<rX)rErrr�__len__�sz!RelativeDistinguishedName.__len__cCsdj|j��S)Nz<RelativeDistinguishedName({})>)rQrJ)rErrrrR�sz"RelativeDistinguishedName.__repr__N)rrrrGr]rJrMrNrPrarbrRrrrrrS�s	rSc@sjeZdZdd�Zdd�Zdd�Zedd��Zdd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zd	S)�NamecCsRt|�}tdd�|D��r,dd�|D�|_n"tdd�|D��rF||_ntd��dS)Ncss|]}t|t�VqdS)N)r7r4)rrTrrrrU�sz Name.__init__.<locals>.<genexpr>cSsg|]}t|g��qSr)rS)rrTrrrr\�sz!Name.__init__.<locals>.<listcomp>css|]}t|t�VqdS)N)r7rS)rrTrrrrU�szNattributes must be a list of NameAttribute or a list RelativeDistinguishedName)rVrWrXr8)rEr[rrrrG�sz
Name.__init__cCsdjdd�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|]}|j�VqdS)N)rJ)rr^rrrrU�sz&Name.rfc4514_string.<locals>.<genexpr>)r_�reversedrX)rErrrrJ�szName.rfc4514_stringcs�fdd�|D�S)Ncsg|]}|j�kr|�qSr)rF)rr)rFrrr\�sz/Name.get_attributes_for_oid.<locals>.<listcomp>r)rErFr)rFrr]�szName.get_attributes_for_oidcCs|jS)N)rX)rErrr�rdns�sz	Name.rdnsNcCst|�}|j|�S)N)rZx509_name_bytes)rEZbackendrrr�public_bytes�szName.public_bytescCst|t�stS|j|jkS)N)r7rcrKrX)rErLrrrrM�s
zName.__eq__cCs
||kS)Nr)rErLrrrrN�szName.__ne__cCstt|j��S)N)rO�tuplerX)rErrrrP�sz
Name.__hash__ccs(x"|jD]}x|D]
}|VqWqWdS)N)rX)rE�rdnZavarrrra�s
z
Name.__iter__cCstdd�|jD��S)Ncss|]}t|�VqdS)N)r<)rrhrrrrU�szName.__len__.<locals>.<genexpr>)�sumrX)rErrrrb�szName.__len__cCs:djdd�|jD��}tjr,dj|jd��Sdj|�SdS)Nr(css|]}|j�VqdS)N)rJ)rr^rrrrUsz Name.__repr__.<locals>.<genexpr>z
<Name({})>r5)r_rXr9ZPY2rQr=)rErerrrrR�sz
Name.__repr__)N)rrrrGrJr]�propertyrerfrMrNrPrarbrRrrrrrc�s
rc)'Z
__future__rrr�enumrr9ZcryptographyrZcryptography.hazmat.backendsrZcryptography.x509.oidrr	r
Z_ASN1_TYPE_TO_ENUM�objectr?r:rr;Z
SERIAL_NUMBERZDN_QUALIFIERZ
EMAIL_ADDRESSrZDOMAIN_COMPONENTr@ZCOMMON_NAMEZ
LOCALITY_NAMEZSTATE_OR_PROVINCE_NAMEZORGANIZATION_NAMEZORGANIZATIONAL_UNIT_NAMEZSTREET_ADDRESSZUSER_IDrHr3r4rSrcrrrr�<module>s6

@1

Zerion Mini Shell 1.0