%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/cryptography/x509/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/cryptography/x509/__pycache__/name.cpython-312.pyc

�

�3Tf:���UddlmZddlZddlZddlZddlZddlZddlmZddl	m
Zddlm
Z
mZGd�dej�ZeD�cic]}|j"|��c}Ze
j&ej(e
j*ej(e
j,ej(e
j.ej(e
j0ej2e
j4ej2iZded	<ej:eefZej:eefZ e
jBd
e
jDde
jFde
jHd
e
jJde
j&de
jLde
j4de
jNdi	Z(ded<e(jS�D��cic]\}}||��
c}}Z*dd�Z+d d�Z,Gd�d�Z-Gd�d�Z.Gd�d�Z/Gd�d�Z0ycc}wcc}}w)!�)�annotationsN)�utils)�x509)�NameOID�ObjectIdentifierc�<�eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZy
)�	_ASN1Type������������N)�__name__�
__module__�__qualname__�	BitString�OctetString�
UTF8String�
NumericString�PrintableString�	T61String�	IA5String�UTCTime�GeneralizedTime�
VisibleString�UniversalString�	BMPString���8/usr/lib/python3/dist-packages/cryptography/x509/name.pyr	r	s>���I��K��J��M��O��I��I��G��O��M��O��Ir&r	z(typing.Dict[ObjectIdentifier, _ASN1Type]�_NAMEOID_DEFAULT_TYPE�CN�L�ST�O�OU�C�STREET�DC�UID�_OidNameMap�_NAMEOID_TO_NAMEc���|syt|t�r'dtj|�j	d�zS|jdd�}|jdd�}|jdd	�}|jd
d�}|jdd
�}|jdd�}|jdd�}|jdd�}|ddvrd|z}|ddk(r|dddz}|S)z>Escape special characters in RFC4514 Distinguished Name value.��#�utf8�\z\\�"z\"�+z\+�,z\,�;z\;�<z\<�>z\>�z\00r)r6� ���r@Nz\ )�
isinstance�bytes�binascii�hexlify�decode�replace)�vals r'�_escape_dn_valuerI?s������#�u���X�%�%�c�*�1�1�&�9�9�9��+�+�d�F�
#�C�

�+�+�c�5�
!�C�

�+�+�c�5�
!�C�

�+�+�c�5�
!�C�

�+�+�c�5�
!�C�

�+�+�c�5�
!�C�

�+�+�c�5�
!�C�

�+�+�d�F�
#�C�
�1�v����S�j��
�2�w�#�~��#�2�h�����Jr&c�N�|syd�}tjj||�S)Nr5c�n�|jd�}t|�dk(r|Stt|d��S)N��)�group�len�chr�int)�mrHs  r'�subz_unescape_dn_value.<locals>.subds0���g�g�a�j���s�8�q�=��J��3�s�B�<� � r&)�_RFC4514NameParser�_PAIR_RErS)rHrSs  r'�_unescape_dn_valuerV\s(����!��&�&�*�*�3��4�4r&c��eZdZ	ddd�									d
d�Zedd��Zedd��Zedd��Z	d			dd�Zdd	�Z	dd
�Z
dd�Zy)�
NameAttributeNT)�	_validatec���t|t�std��|tjk(r9|t
jk7rtd��t|t�s&td��t|t�std��|t
jk(s|t
jk(rkt|t�sJ�t|jd��}|dk7r|durtd��|dk7r&tjd	j!|�d�
�|�$t"j%|tj&�}t|t�std��||_||_||_y)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 strr7�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)rBr�	TypeErrorr	rr�X500_UNIQUE_IDENTIFIERrC�str�COUNTRY_NAME�JURISDICTION_COUNTRY_NAMErO�encode�
ValueError�warnings�warn�formatr(�getr�_oid�_value�_type)�self�oid�valuerjrY�c_lens      r'�__init__zNameAttribute.__init__psJ���#�/�0��D��
��I�'�'�'��g�4�4�4��L����e�U�+�� C�D�D��e�S�)�� >�?�?�
�7�'�'�'��g�7�7�7��e�S�)�)�)�����V�,�-�E���z�i�4�/� �E����!���
�
�<�<B�F�5�M� ���=�)�-�-�c�9�3G�3G�H�E��%��+��C�D�D���	������
r&c��|jS�N)rh�rks r'rlzNameAttribute.oid�s���y�y�r&c��|jSrq)rirrs r'rmzNameAttribute.value�s���{�{�r&c�j�tj|j|jj�S)zt
        The short attribute name (for example "CN") if available,
        otherwise the OID dotted string.
        )r3rgrl�
dotted_stringrrs r'�rfc4514_attribute_namez$NameAttribute.rfc4514_attribute_name�s%�� �#�#�D�H�H�d�h�h�.D�.D�E�Er&c��|r|j|j�nd}|�|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�=)rgrlrvrIrm)rk�attr_name_overrides�	attr_names   r'�rfc4514_stringzNameAttribute.rfc4514_string�sP��2E��#�#�D�H�H�-�$�	����3�3�I���A�.�t�z�z�:�;�<�<r&c��t|t�stS|j|jk(xr|j|jk(Srq)rBrX�NotImplementedrlrm�rk�others  r'�__eq__zNameAttribute.__eq__�s7���%��/�!�!��x�x�5�9�9�$�B����u�{�{�)B�Br&c�D�t|j|jf�Srq)�hashrlrmrrs r'�__hash__zNameAttribute.__hash__�s���T�X�X�t�z�z�*�+�+r&c�$�dj|�S)Nz/<NameAttribute(oid={0.oid}, value={0.value!r})>)rfrrs r'�__repr__zNameAttribute.__repr__�s��@�G�G��M�Mr&rq)
rlrrm�typing.Union[str, bytes]rjztyping.Optional[_ASN1Type]rY�bool�return�None)r�r)r�r��r�r_�ryztyping.Optional[_OidNameMap]r�r_�r�objectr�r��r�rQ)rrrro�propertyrlrmrvr{r�r�r�r%r&r'rXrXos���
-1�	6��
6�
�6�(�6�*�	6��
6�
�6�p���������F��F�CG�=�#?�=�	�=�"C�,�Nr&rXc�^�eZdZd
d�Z				dd�Z	d			d
d�Zdd�Zdd�Zdd�Zdd�Z	dd	�Z
y)�RelativeDistinguishedNamec���t|�}|std��td�|D��std��||_t|�|_t|j�t|�k7rtd��y)Nz-a relative distinguished name cannot be emptyc3�<K�|]}t|t����y�wrq�rBrX��.0�xs  r'�	<genexpr>z5RelativeDistinguishedName.__init__.<locals>.<genexpr>�s����D�A�:�a��/�D���z/attributes must be an iterable of NameAttributez$duplicate attributes are not allowed)�listrc�allr]�_attributes�	frozenset�_attribute_setrO�rk�
attributess  r'roz"RelativeDistinguishedName.__init__�st���*�%�
���L�M�M��D��D�D��M�N�N�&���'�
�3����t�"�"�#�s�:��6��C�D�D�7r&c�L�|D�cgc]}|j|k(s�|��c}Scc}wrq�rl�rkrl�is   r'�get_attributes_for_oidz0RelativeDistinguishedName.get_attributes_for_oid��"�� �0�a�1�5�5�C�<��0�0��0��!�!Nc�L��dj�fd�|jD��S)z�
        Format as RFC4514 Distinguished Name string.

        Within each RDN, attributes are joined by '+', although that is rarely
        used in certificates.
        r:c3�@�K�|]}|j�����y�wrq�r{�r��attrrys  �r'r�z;RelativeDistinguishedName.rfc4514_string.<locals>.<genexpr>��%�����
��
��� 3�4�
�����joinr��rkrys `r'r{z(RelativeDistinguishedName.rfc4514_string�s)����x�x�
��(�(�
�
�	
r&c�`�t|t�stS|j|jk(Srq)rBr�r}r�r~s  r'r�z RelativeDistinguishedName.__eq__�s*���%�!:�;�!�!��"�"�e�&:�&:�:�:r&c�,�t|j�Srq)r�r�rrs r'r�z"RelativeDistinguishedName.__hash__�s���D�'�'�(�(r&c�,�t|j�Srq)�iterr�rrs r'�__iter__z"RelativeDistinguishedName.__iter__s���D�$�$�%�%r&c�,�t|j�Srq)rOr�rrs r'�__len__z!RelativeDistinguishedName.__len__s���4�#�#�$�$r&c�*�d|j��d�S)Nz<RelativeDistinguishedName(�)>r�rrs r'r�z"RelativeDistinguishedName.__repr__s��,�T�-@�-@�-B�,C�2�F�Fr&)r��typing.Iterable[NameAttribute]�rlrr�ztyping.List[NameAttribute]rqr�r�r��r�ztyping.Iterator[NameAttribute]r�)rrrror�r{r�r�r�r�r�r%r&r'r�r��sS��E�1�#�1�	#�1�CG�
�#?�
�	�
�;�)�&�%�Gr&r�c��eZdZejdd��Zej				dd��Z				dd�Ze	d					dd��Z	d			dd�Z				dd�Z	e
dd��Zddd	�Zdd
�Z
dd�Zdd�Zdd
�Zdd�Zy)�Namec��yrqr%r�s  r'roz
Name.__init__s��r&c��yrqr%r�s  r'roz
Name.__init__s��	r&c	�R�t|�}td�|D��r8|D�cgc]&}ttjt
|�g���(c}|_ytd�|D��r1tjtjt|�|_ytd��cc}w)Nc3�<K�|]}t|t����y�wrqr�r�s  r'r�z Name.__init__.<locals>.<genexpr>s����@��z�!�]�+�@�r�c3�<K�|]}t|t����y�wrq)rBr�r�s  r'r�z Name.__init__.<locals>.<genexpr>"s����N�a��A�8�9�N�r�zNattributes must be a list of NameAttribute or a list RelativeDistinguishedName)	r�r�r��typing�castrXr��Listr])rkr�r�s   r'roz
Name.__init__s����*�%�
��@�Z�@�@�$� ��*�6�;�;�}�a�+H�*I�J� �D���N�:�N�
N�%�{�{����5�6�
� �D���7��
�� s�+B$Nc�>�t||xsi�j�Srq)rT�parse)�cls�datarys   r'�from_rfc4514_stringzName.from_rfc4514_string,s ��"�$�(;�(A�r�B�H�H�J�Jr&c�^��dj�fd�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;c3�@�K�|]}|j�����y�wrqr�r�s  �r'r�z&Name.rfc4514_string.<locals>.<genexpr>Ar�r�)r��reversedr�r�s `r'r{zName.rfc4514_string4s.����x�x�
� ��!1�!1�2�
�
�	
r&c�L�|D�cgc]}|j|k(s�|��c}Scc}wrqr�r�s   r'r�zName.get_attributes_for_oidFr�r�c��|jSrq�r�rrs r'�rdnsz	Name.rdnsKs�����r&c�,�tj|�Srq)�	rust_x509�encode_name_bytes)rk�backends  r'�public_byteszName.public_bytesOs���*�*�4�0�0r&c�`�t|t�stS|j|jk(Srq)rBr�r}r�r~s  r'r�zName.__eq__Rs)���%��&�!�!����5�#4�#4�4�4r&c�>�tt|j��Srq)r��tupler�rrs r'r�z
Name.__hash__Xs���E�$�*�*�+�,�,r&c#�DK�|jD]
}|D]}|����y�wrqr�)rk�rdn�avas   r'r�z
Name.__iter__]s/�����#�#�	�C��
���	�
�	�s� c�:�td�|jD��S)Nc3�2K�|]}t|����y�wrq)rO)r�r�s  r'r�zName.__len__.<locals>.<genexpr>cs����8��3�s�8�8�s�)�sumr�rrs r'r�zName.__len__bs���8�t�'7�'7�8�8�8r&c�R�djd�|jD��}d|�d�S)Nr;c3�<K�|]}|j����y�wrqr�)r�r�s  r'r�z Name.__repr__.<locals>.<genexpr>fs����K�$��+�+�-�K�r�z<Name(r�r��rkr�s  r'r�z
Name.__repr__es+���x�x�K�$�:J�:J�K�K����v�R� � r&)r�r�r�r�)r�z*typing.Iterable[RelativeDistinguishedName]r�r�)r�zGtyping.Iterable[typing.Union[NameAttribute, RelativeDistinguishedName]]r�r�rq)r�r_ryztyping.Optional[_NameOidMap]r�r�r�r�)r�z&typing.List[RelativeDistinguishedName])r�z
typing.Anyr�rCr�r�r�r�)rrrr��overloadro�classmethodr�r{r�r�r�r�r�r�r�r�r�r%r&r'r�r�s����_�_�����_�_��D��	
����
�
��

��,�=A�K��K�:�K�
�	K��K�CG�
�#?�
�	�
�$1�#�1�	#�1�
� �� �1�5�-�
�
9�!r&r�c��eZdZejd�Zejd�ZdZeje�ZdZ	dZ
dZdee
j��d�Ze	�d	e��Ze
�d	e��Ze�d	e��Zejd
e�d	e�de�d	e�de�d	e�d
�
ej&�Zejd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zy) rTz!(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})+c�.�||_d|_||_y)Nr)�_data�_idx�_attr_name_overrides)rkr�rys   r'roz_RFC4514NameParser.__init__�s����
���	�$7��!r&c�F�|jt|j�kSrq)r�rOr�rrs r'�	_has_dataz_RFC4514NameParser._has_data�s���y�y�3�t�z�z�?�*�*r&c�V�|j�r|j|jSyrq)r�r�r�rrs r'�_peekz_RFC4514NameParser._peek�s"���>�>���:�:�d�i�i�(�(�r&c�`�|j�|k7rt�|xjdz
c_y)NrL)r�rcr�)rk�chs  r'�
_read_charz_RFC4514NameParser._read_char�s#���:�:�<�2�����	�	�Q��	r&c��|j|j|j��}|�t�|j	�}|xjt|�z
c_|S)N)�pos)�matchr�r�rcrNrO)rk�patr�rHs    r'�_read_rez_RFC4514NameParser._read_re�sI���	�	�$�*�*�$�)�)�	�4���=����k�k�m���	�	�S��X��	��
r&c���|j�g}|j�rA|jd�|j|j��|j�r�At	t|��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.
        r;)�
_parse_rdnr�r��appendr�r�r�s  r'r�z_RFC4514NameParser.parse�sY�����!�"���n�n���O�O�C� ��K�K����)�*��n�n���H�T�N�#�#r&c���|j�g}|j�dk(rD|jd�|j|j��|j�dk(r�Dt	|�S)Nr:)�	_parse_nar�r�r�r�)rk�nass  r'r�z_RFC4514NameParser._parse_rdn�s[���~�~�� ���j�j�l�c�!��O�O�C� ��J�J�t�~�~�'�(��j�j�l�c�!�)��-�-r&c�B�	|j|j�}t|�}|jd�|j�dk(rB|j|j�}tj|dd�j�}n&|j|j�}t|�}t!||�S#t$rU|j|j�}|j
j
|tj
|��}|�t�Y��wxYw)Nrxr6rL)r��_OID_RErrc�	_DESCR_REr�rg�_NAME_TO_NAMEOIDr�r��
_HEXSTRING_RErD�	unhexlifyrF�
_STRING_RErVrX)rk�	oid_valuerl�namerm�	raw_values      r'r�z_RFC4514NameParser._parse_na�s���
	.��
�
�d�l�l�3�I�#�9�-�C�������:�:�<�3���M�M�$�"4�"4�5�E��&�&�u�Q�R�y�1�8�8�:�E��
�
�d�o�o�6�I�&�y�1�E��S�%�(�(��%�	!��=�=����0�D��+�+�/�/��&�*�*�4�0��C��{� � ��	!�s�C�AD�DN)r�r_ry�_NameOidMapr�r�)r�r�)r�ztyping.Optional[str])r�r_r�r�r�)r�r�)r�r�)r�rX)rrr�re�compilerr�_PAIRrU�_LUTF1�_SUTF1�_TUTF1rP�sys�
maxunicode�_UTFMB�	_LEADCHAR�_STRINGCHAR�
_TRAILCHAR�VERBOSErrror�r�r�r�r�r�r�r%r&r'rTrTjs���b�j�j�=�>�G���
�
�2�3�I�0�E��r�z�z�%� �H�
G�F�
C�F�
G�F��s�3�>�>�*�+�1�
-�F��8�1�V�H�%�I��X�Q�v�h�'�K��H�A�f�X�&�J�������[��%��!���a��w�'���Q�u�g�&	�	�	�
�
��J��B�J�J�3�4�M�8�+��
�
�$�".�)r&rT)rHr�r�r_)rHr_r�r_)1�
__future__rrDrrr�rd�cryptographyr�"cryptography.hazmat.bindings._rustrr��cryptography.x509.oidrr�Enumr	rm�_ASN1_TYPE_TO_ENUMr`rra�
SERIAL_NUMBER�DN_QUALIFIER�
EMAIL_ADDRESSr�DOMAIN_COMPONENTr(�__annotations__�Mappingr_r2r
�COMMON_NAME�
LOCALITY_NAME�STATE_OR_PROVINCE_NAME�ORGANIZATION_NAME�ORGANIZATIONAL_UNIT_NAME�STREET_ADDRESS�USER_IDr3�itemsrrIrVrXr�r�rT)r��k�vs000r'�<module>r.s���
#��	�
�
���@�;���
�
��+4�4�Q�a�g�g�q�j�4�����)�3�3��%�%�y�'@�'@����9�4�4����)�3�3����9�.�.����i�1�1�
C��?���n�n�-�s�2�3���n�n�S�"2�2�3��
�������3��"�"�D����s��$�$�d����#����H����d��O�O�U�
!��+�
�&6�%;�%;�%=�>�T�Q��A�q�D�>���:5�&dN�dN�N2G�2G�j\!�\!�~d)�d)��S
5��6?s�	G�
G

Zerion Mini Shell 1.0