Your IP : 18.223.172.243


Current Path : /usr/lib64/python3.6/site-packages/cryptography/hazmat/__pycache__/
Upload File :
Current File : //usr/lib64/python3.6/site-packages/cryptography/hazmat/__pycache__/_der.cpython-36.pyc

3

l�_U�@s�ddlmZmZmZddlZddlmZmZdZdZ	dZ
dZdZd	Z
d
ZdeBZdeBZd
ZdZdZGdd�de�Zdd�Zdd�ZdS)�)�absolute_import�division�print_functionN)�int_from_bytes�int_to_bytes� �����������c@sleZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�	DERReadercCst|�|_dS)N)�
memoryview�data)�selfr�r�/usr/lib64/python3.6/_der.py�__init__$szDERReader.__init__cCs|S)Nr)rrrr�	__enter__'szDERReader.__enter__cCs|dkr|j�dS)N)�check_empty)r�exc_type�	exc_value�tbrrr�__exit__*szDERReader.__exit__cCst|j�dkS)Nr)�lenr)rrrr�is_empty.szDERReader.is_emptycCs|j�std��dS)Nz Invalid DER input: trailing data)r!�
ValueError)rrrrr1szDERReader.check_emptycCs8t|j�dkrtd��tj|jd�}|jdd�|_|S)N�z$Invalid DER input: insufficient datar)r rr"�six�
indexbytes)r�retrrr�	read_byte5s
zDERReader.read_bytecCs8t|j�|krtd��|jd|�}|j|d�|_|S)Nz$Invalid DER input: insufficient data)r rr")r�nr&rrr�
read_bytes<s
zDERReader.read_bytescCs�|j�}|d@dkrtd��|j�}|d@dkr6|}nb|dM}|dkrNtd��d}x4t|�D](}|dK}||j�O}|dkr\td��q\W|dkr�td��|j|�}|t|�fS)	N�z-Invalid DER input: unexpected high tag numberrr�z?Invalid DER input: indefinite length form is not allowed in DER�z3Invalid DER input: length was not minimally-encoded)r'r"�ranger)r)r�tagZlength_byte�length�i�bodyrrr�read_any_elementCs,

zDERReader.read_any_elementcCs |j�\}}||krtd��|S)Nz!Invalid DER input: unexpected tag)r2r")r�expected_tagr.r1rrr�read_elementgszDERReader.read_elementc	Cs|�|j|�SQRXdS)N)r4)rr3rrr�read_single_elementmszDERReader.read_single_elementcCs.t|j�dkr*tj|jd�|kr*|j|�SdS)Nr)r rr$r%r4)rr3rrr�read_optional_elementqs 
zDERReader.read_optional_elementcCs|t|j�dkrtd��tj|jd�}|d@dkr8td��t|j�dkrptj|jd�}|dkrp|d@dkrptd��t|jd�S)Nrz)Invalid DER input: empty integer contentsrz'Negative DER integers are not supportedr#z0Invalid DER input: integer not minimally-encodedZbig)r rr"r$r%r)r�first�secondrrr�
as_integervszDERReader.as_integerN)�__name__�
__module__�__qualname__rrrr!rr'r)r2r4r5r6r9rrrrr#s$rcCs>t|tj�std��|dkr$td��|j�dd}t||�S)NzValue must be an integerrz#Negative integers are not supportedr,r#)�
isinstancer$Z
integer_typesr"�
bit_lengthr)�xr(rrr�encode_der_integer�sr@cGs�d}x|D]}|t|�7}q
Wtj|�g}|dkrD|jtj|��n*t|�}|jtjdt|�B��|j|�|j|�dj|�S)Nrr�)r r$Zint2byte�appendr�extend�join)r.Zchildrenr/ZchildZchunksZlength_bytesrrr�
encode_der�s


rE)Z
__future__rrrr$Zcryptography.utilsrrZCONSTRUCTEDZCONTEXT_SPECIFICZINTEGERZ
BIT_STRINGZOCTET_STRINGZNULLZOBJECT_IDENTIFIERZSEQUENCEZSETZPRINTABLE_STRINGZUTC_TIMEZGENERALIZED_TIME�objectrr@rErrrr�<module>s"d	

?>