o
    Þý°j`= ã                   @   sd  d dl Z d dlZd dlZd dlZd dlmZ d dlmZ d dlmZ d dl	m
Z
 d dl	mZ d dl	mZ d dl	mZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ g d¢Zejeejd�ZejZejZdZ dZ!dZ"dZ#G dd„ de$ƒZ%G dd„ de%ƒZ&G dd„ de&ƒZ'e'ƒ Z(G dd„ de&ƒZ)G dd„ de)ƒZ*G d d!„ d!e&ƒZ+G d"d#„ d#e&ƒZ,G d$d%„ d%e&ƒZ-G d&d'„ d'e&ƒZ.G d(d)„ d)e&ƒZ/G d*d+„ d+e&ƒZ0G d,d-„ d-e%ƒZ1G d.d/„ d/e1ƒZ2G d0d1„ d1e2ƒZ3G d2d3„ d3e3ƒZ4G d4d5„ d5e3ƒZ5G d6d7„ d7e2ƒZ6G d8d9„ d9e6ƒZ7G d:d;„ d;e6ƒZ8G d<d=„ d=e2ƒZ9G d>d?„ d?e&ƒZ:G d@dA„ dAe,ƒZ;G dBdC„ dCe,ƒZ<G dDdE„ dEe,ƒZ=G dFdG„ dGe,ƒZ>G dHdI„ dIe,ƒZ?G dJdK„ dKe,ƒZ@G dLdM„ dMe,ƒZAG dNdO„ dOe,ƒZBG dPdQ„ dQe,ƒZCG dRdS„ dSe,ƒZDG dTdU„ dUe,ƒZEG dVdW„ dWe,ƒZFG dXdY„ dYe,ƒZGG dZd[„ d[e,ƒZHi ejIjJe)ƒ “ejKjJe*ƒ “ejLjJe+ƒ “ejMjJe,ƒ “ejNjJe-ƒ “ejOjJe.ƒ “ejPjJe/ƒ “ejQjJe)ƒ “ejRjJe0ƒ “ejSjJe3ƒ “ejTjJe6ƒ “ejUjJe9ƒ “ejVjJe;ƒ “ejWjJe<ƒ “ejXjJe=ƒ “ejYjJe>ƒ “ejZjJe?ƒ “ej[jJe@ƒ ej\jJeAƒ ej]jJeBƒ ej^jJeCƒ ej_jJeDƒ ej`jJeEƒ ejajJeFƒ ejbjJeGƒ ejcjJeHƒ i	¥ZdejTjee7ƒ ejfjee8ƒ ejSjee4ƒ ejgjee5ƒ ejUjee9ƒ ejhjee:ƒ iZied j¡ D ]Zkekjldu�ruekjljmjeZeeedu�rueeeiv�ruekeiee< �qZd\d]„ end^ƒD ƒ\
ZoZpZqZrZsZtZuZvZwZxeyd_ƒZzG d`da„ dae$ƒZ{G dbdc„ dce$ƒZ|G ddde„ dee$ƒZ}e}ƒ Z~dfefdgdh„Z€dS )ié    N)Údebug)Úerror)Úeoo)ÚasSeekableStream)ÚisEndOfStream)ÚpeekIntoStream©ÚreadFromStream)Ú_MISSING)ÚPyAsn1Error)Úbase)Úchar)Útag)Útagmap)Úuniv)Úuseful)ÚStreamingDecoderÚDecoderÚdecode)Úflagsé   éd   é   c                   @   s8   e Zd ZdZ		ddd„Z		ddd„Zedd„ ƒZdS )	ÚAbstractPayloadDecoderNc           	      K   ó   t  d|f ¡‚)ztDecode value with fixed byte length.

        The decoder is allowed to consume as many bytes as necessary.
        z(SingleItemDecoder not implemented for %s©r   r   ©	ÚselfÚ	substrateÚasn1SpecÚtagSetÚlengthÚstateÚ	decodeFunÚsubstrateFunÚoptions© r&   ú‹/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/pyasn1/codec/ber/decoder.pyÚvalueDecoder4   ó   z#AbstractPayloadDecoder.valueDecoderc           	      K   r   )zsDecode value with undefined length.

        The decoder is allowed to consume as many bytes as necessary.
        z5Indefinite length mode decoder not implemented for %sr   r   r&   r&   r'   ÚindefLenValueDecoder>   r)   z+AbstractPayloadDecoder.indefLenValueDecoderc                 C   s   d|vr| |d< |S )NÚ
asn1Objectr&   )r+   r%   r&   r&   r'   Ú_passAsn1ObjectH   s   z&AbstractPayloadDecoder._passAsn1Object©NNNNN)Ú__name__Ú
__module__Ú__qualname__ÚprotoComponentr(   r*   Ústaticmethodr,   r&   r&   r&   r'   r   1   s    
þ
þ
r   c                   @   s    e Zd Zedd„ ƒZdd„ ZdS )ÚAbstractSimplePayloadDecoderc                 c   s   � t |||ƒD ]}|V  qd S ©Nr   )r+   r   r!   r%   Úchunkr&   r&   r'   ÚsubstrateCollectorQ   s   €ÿz/AbstractSimplePayloadDecoder.substrateCollectorc                 K   s<   |  d¡r|S |d u r| jj||d�S |tu r|S | |¡S )NÚnative©r    )Úgetr1   ÚcloneÚnoValue©r   r   r    Úvaluer%   r&   r&   r'   Ú_createComponentV   s   

z-AbstractSimplePayloadDecoder._createComponentN)r.   r/   r0   r2   r6   r>   r&   r&   r&   r'   r3   P   s    
r3   c                   @   s2   e Zd Ze d¡Z		ddd„Z		ddd„ZdS )ÚRawPayloadDecoderÚ Nc                 k   s`   � |r| j ||dfi |¤Ž}	||	|||ƒD ]}
|
V  qd S |||||fi |¤ŽD ]}|V  q(d S )Nr@   )r>   ©r   r   r   r    r!   r"   r#   r$   r%   r+   r5   r=   r&   r&   r'   r(   d   s   €ÿzRawPayloadDecoder.valueDecoderc                 k   st   � |r| j ||dfi |¤Ž}	||	|||ƒD ]}
|
V  qd S 	 |||||fddi|¤ŽD ]}|tju r5 d S |V  q+q)Nr@   TÚallowEoo)r>   r   ÚendOfOctetsrA   r&   r&   r'   r*   s   s$   €ÿþ
þ
øz&RawPayloadDecoder.indefLenValueDecoderr-   ©r.   r/   r0   r   ÚAnyr1   r(   r*   r&   r&   r&   r'   r?   a   s    

þþr?   c                   @   ó$   e Zd Ze d¡Z		ddd„ZdS )ÚIntegerPayloadDecoderr   Nc                 k   sx   � |d j tjkrt d¡‚t|||ƒD ]
}	t|	tƒr|	V  q|	r,tj	t
|	ƒddd�}
nd}
| j|||
fi |¤ŽV  d S )Nr   úSimple tag format expectedÚbigT)Úsigned)Ú	tagFormatr   ÚtagFormatSimpler   r   r	   Ú
isinstanceÚSubstrateUnderrunErrorÚintÚ
from_bytesÚbytesr>   )r   r   r   r    r!   r"   r#   r$   r%   r5   r=   r&   r&   r'   r(   �   s   €

€z"IntegerPayloadDecoder.valueDecoderr-   )r.   r/   r0   r   ÚIntegerr1   r(   r&   r&   r&   r'   rG   �   ó
    
þrG   c                   @   s   e Zd Ze d¡Zdd„ ZdS )ÚBooleanPayloadDecoderr   c                 K   s    t j| |||r	dp
dfi |¤ŽS )Né   r   )rG   r>   r<   r&   r&   r'   r>   ¨   s
   ÿÿz&BooleanPayloadDecoder._createComponentN)r.   r/   r0   r   ÚBooleanr1   r>   r&   r&   r&   r'   rT   ¥   s    
rT   c                   @   ó6   e Zd Ze d¡ZdZ		ddd„Z		ddd„ZdS )	ÚBitStringPayloadDecoderr&   TNc                 k   sþ  � |r| j ||tfi |¤Ž}	||	|||ƒD ]}
|
V  qd S |s$t d¡‚t|ƒD ]
}
t|
tƒr2|
V  q(|
r:t d¡‚|d jtj	krŒt
|d|ƒD ]
}t|tƒrR|V  qHt|ƒ}|dkrbt d| ¡‚t
||d |ƒD ]
}
t|
tƒrt|
V  qj| jj|
d|d�}| j |||fi |¤ŽV  d S | js˜t d| jj ¡‚tržtd	ƒ | j}| jjd
dd�}| ¡ }| ¡ | |k rñ||| jfd|i|¤ŽD ]
}t|tƒrË|V  qÁ|d }|dkrÛt d| ¡‚| jj|dd … d||d�}| ¡ | |k sµ| j |||fi |¤ŽV  d S )NzEmpty BIT STRING substrater   rU   é   úTrailing bits overflow %sT)ÚinternalFormatÚpaddingú*Constructed encoding form prohibited at %sú$assembling constructed serializationó    ©r[   r$   ©r[   Úprependr\   )r>   r;   r   r   r   rM   rN   rK   r   rL   r	   Úordr1   ÚfromOctetStringÚsupportConstructedFormÚ	__class__r.   ÚLOGr6   Útell)r   r   r   r    r!   r"   r#   r$   r%   r+   r5   ÚtrailingBitsr=   Ú	bitStringÚcurrent_positionÚ	componentr&   r&   r'   r(   ±   s€   €

€

€ÿ
€ÿÿÿÿ
þ
€ÿþóz$BitStringPayloadDecoder.valueDecoderc                 k   sô   � |r| j ||tfi |¤Ž}	||	|||ƒD ]}
|
V  qd S | j}| jjddd�}	 ||| jf|ddœ|¤ŽD ]}|tju r? n	t|tƒrG|V  q6|tju rNn|d }|dkr]t	 
d| ¡‚| jj|dd … d||d	�}q)| j |||fi |¤ŽV  d S )
Nr_   Tr`   ©r$   rB   r   rY   rZ   rU   ra   )r>   r;   r6   r1   rd   r   rC   rM   rN   r   r   )r   r   r   r    r!   r"   r#   r$   r%   r+   r5   rj   rl   ri   r&   r&   r'   r*     sF   €ÿþ
þ

€
ÿþëz,BitStringPayloadDecoder.indefLenValueDecoderr-   )	r.   r/   r0   r   Ú	BitStringr1   re   r(   r*   r&   r&   r&   r'   rX   ­   s    

þQþrX   c                   @   rW   )	ÚOctetStringPayloadDecoderr@   TNc                 k   s0  � |r| j ||tfi |¤Ž}	||	|||ƒD ]}
|
V  qd S |d jtjkrDt|||ƒD ]
}
t|
tƒr5|
V  q+| j |||
fi |¤ŽV  d S | jsPt	 
d| jj ¡‚trVtdƒ | j}d}| ¡ }| ¡ | |k rŠ||| jfd|i|¤ŽD ]
}t|tƒr}|V  qs||7 }| ¡ | |k sg| j |||fi |¤ŽV  d S )Nr   r]   r^   r_   r$   )r>   r;   rK   r   rL   r	   rM   rN   re   r   r   rf   r.   rg   r6   rh   r1   )r   r   r   r    r!   r"   r#   r$   r%   r+   r5   ÚheaderÚoriginal_positionrl   r&   r&   r'   r(   4  sD   €
€ÿÿ
þ
€ù	z&OctetStringPayloadDecoder.valueDecoderc                 k   sÀ   � |r"|| j ur"| j||tfi |¤Ž}	||	|||ƒD ]}
|
V  qd S | j }d}	 ||| jf|ddœ|¤ŽD ]}t|tƒr?|V  |tju rF nq5|tju rMn||7 }q(| j|||fi |¤ŽV  d S )Nr_   Trm   )r6   r>   r;   r1   rM   rN   r   rC   )r   r   r   r    r!   r"   r#   r$   r%   r+   r5   rp   rl   r&   r&   r'   r*   a  s6   €ÿþ
þ

ÿ
ñz.OctetStringPayloadDecoder.indefLenValueDecoderr-   )	r.   r/   r0   r   ÚOctetStringr1   re   r(   r*   r&   r&   r&   r'   ro   0  s    

þ.þro   c                   @   rF   )ÚNullPayloadDecoderr@   Nc                 k   sp   � |d j tjkrt d¡‚t|||ƒD ]
}	t|	tƒr|	V  q| j||dfi |¤Ž}
|	r3t d| ¡‚|
V  d S )Nr   rH   r@   z&Unexpected %d-octet substrate for Null)	rK   r   rL   r   r   r	   rM   rN   r>   )r   r   r   r    r!   r"   r#   r$   r%   r5   rl   r&   r&   r'   r(   ‰  s   €

€
zNullPayloadDecoder.valueDecoderr-   )r.   r/   r0   r   ÚNullr1   r(   r&   r&   r&   r'   rs   †  rS   rs   c                   @   rF   )ÚObjectIdentifierPayloadDecoderr&   Nc                 k   sø  � |d j tjkrt d¡‚t|||ƒD ]
}	t|	tƒr|	V  q|	s&t d¡‚g }
d}t|	ƒ}||k rœ|	| }|d7 }|dk rD|
 	|¡ nT|dkr�|}d}d}|dkr…|d7 }|t
krct dt
|f ¡‚|d> |d@  }||kryt d	t|
ƒf ¡‚|	| }|d7 }|dksR|
 	|d> | ¡ n	|dkr˜t d
¡‚||k s2d|
d   kr¨dkr±n n|
 dd¡ n;d|
d   kr½dkrÎn n|
d  d8  < |
 dd¡ n|
d dkrã|
d  d8  < |
 dd¡ n	t d|	d  ¡‚| j||t|
ƒfi |¤ŽV  d S )Nr   rH   úEmpty substraterU   é€   zEOID arc exceeds maximum continuation octets limit (%d) at position %drY   é   ú#Short substrate for sub-OID past %sz"Invalid octet 0x80 in OID encodingé'   é(   éO   éP   é   zMalformed first OID octet: %s)rK   r   rL   r   r   r	   rM   rN   ÚlenÚappendÚMAX_OID_ARC_CONTINUATION_OCTETSÚtupleÚinsertr>   )r   r   r   r    r!   r"   r#   r$   r%   r5   ÚoidÚindexÚsubstrateLenÚsubIdÚ	nextSubIdÚcontinuationOctetCountr&   r&   r'   r(      sf   €

€
ÿÿÿó
â! z+ObjectIdentifierPayloadDecoder.valueDecoderr-   )r.   r/   r0   r   ÚObjectIdentifierr1   r(   r&   r&   r&   r'   ru   �  rS   ru   c                   @   rF   )ÚRelativeOIDPayloadDecoderr&   Nc                 k   sX  � |d j tjkrt d¡‚t|||ƒD ]
}	t|	tƒr|	V  q|	s&t d¡‚g }
d}t|	ƒ}||k rœ|	| }|d7 }|dk rD|
 	|¡ nT|dkr�|}d}d}|dkr…|d7 }|t
krct dt
|f ¡‚|d> |d@  }||kryt d	t|
ƒf ¡‚|	| }|d7 }|dksR|
 	|d> | ¡ n	|dkr˜t d
¡‚||k s2| j||t|
ƒfi |¤ŽV  d S )Nr   rH   rv   rU   rw   zNRELATIVE-OID arc exceeds maximum continuation octets limit (%d) at position %drY   rx   ry   z+Invalid octet 0x80 in RELATIVE-OID encoding)rK   r   rL   r   r   r	   rM   rN   r   r€   r�   r‚   r>   )r   r   r   r    r!   r"   r#   r$   r%   r5   Úreloidr…   r†   r‡   rˆ   r‰   r&   r&   r'   r(   ã  sT   €

€
ÿÿÿó
â  z&RelativeOIDPayloadDecoder.valueDecoderr-   )r.   r/   r0   r   ÚRelativeOIDr1   r(   r&   r&   r&   r'   r‹   à  rS   r‹   c                   @   s"   e Zd Ze ¡ Z		ddd„ZdS )ÚRealPayloadDecoderNc                 k   sº  � |d j tjkrt d¡‚t|||ƒD ]
}	t|	tƒr|	V  q|	s/| j||dfi |¤ŽV  d S |	d }
|	dd … }	|
d@ rá|	sDt d¡‚t	rJt	dƒ |
d@ d }|d	kr^|	d }|	dd … }	|	d |… |	|d … }}	|ro|	stt d
¡‚|d d@ r|dp}d}|r’|dK }||d O }|dd … }|s€|
d	? d@ }|dkr¡t d¡‚|dkrª|d9 }n|dkr²|d	9 }d}|	rÈ|dK }||	d O }|	dd … }	|	s¶|
d@ rÏ| }|
d? d@ }|d| 9 }|d|f}nn|
d@ rôt	rët	dƒ |
d@ rñdpòd}n[|
d@ dk�rH|	�st d¡‚t	�r
t	dƒ z0|
d@ dk�rt
|	ƒddf}n|
d@ dk�r&t|	ƒ}n|
d@ dk�r2t|	ƒ}nt d|
 ¡‚W n t�yG   t d¡‚w t d|
 ¡‚| j|||fi |¤ŽV  d S )Nr   rH   g        rU   rw   zIncomplete floating-point valuezdecoding binary encoded REALé   é   zReal exponent screwedéÿÿÿÿr   r~   zIllegal Real baseé@   zdecoding infinite REALz-infÚinféÀ   zdecoding character encoded REALé
   zUnknown NR (tag %s)zBad character Real syntaxzUnknown encoding (tag %s))rK   r   rL   r   r   r	   rM   rN   r>   rg   rO   ÚfloatÚ
ValueError)r   r   r   r    r!   r"   r#   r$   r%   r5   ÚfoÚnÚeoÚeÚbÚpÚsfr=   r&   r&   r'   r(     sš   €

€

ý

ý


ÿ€ÿÿÿzRealPayloadDecoder.valueDecoderr-   )r.   r/   r0   r   ÚRealr1   r(   r&   r&   r&   r'   rŽ     s
    þrŽ   c                   @   s   e Zd ZdZdS )Ú!AbstractConstructedPayloadDecoderN)r.   r/   r0   r1   r&   r&   r&   r'   r    …  s    r    c                   @   sN   e Zd ZdZdZdd„ Zdd„ Z		ddd„Z		ddd	„Z		dd
d„Z	dS )ÚConstructedPayloadDecoderBaseNc                 C   ó   t ‚r4   ©ÚNotImplementedError)r   r+   Úidxr&   r&   r'   Ú_getComponentTagMap�  ó   z1ConstructedPayloadDecoderBase._getComponentTagMapc                 C   r¢   r4   r£   )r   r+   r    r¥   r&   r&   r'   Ú_getComponentPositionByType�  r§   z9ConstructedPayloadDecoderBase._getComponentPositionByTypec                 k   s  � d }g }t ƒ }| ¡ }	|dks| ¡ |	| k ri||fi |¤ŽD ]
}
t|
tƒr*|
V  q |dkr5|
tju r5n4| |
¡ | |
j¡ t	|ƒdkrJ| j
}n| j}|jtj|jjg|j¢R Ž d�}|dks| ¡ |	| k strqtd| ƒ t|ƒD ]\}}
|j||
dddd� qu|V  d S )Nr‘   rU   r8   z@guessed %r container type (pass `asn1Spec` to guide the decoder)F©ÚverifyConstraintsÚ	matchTagsÚmatchConstraints)Úsetrh   rM   rN   r   rC   r€   Úaddr    r   ÚprotoRecordComponentÚprotoSequenceComponentr:   r   ÚTagSetÚbaseTagÚ	superTagsrg   Ú	enumerateÚsetComponentByPosition)r   r   r    r#   r!   r%   r+   Ú
componentsÚcomponentTypesrq   rl   r1   r¥   r&   r&   r'   Ú_decodeComponentsSchemaless“  s@   €
€
ýëÿý
z9ConstructedPayloadDecoderBase._decodeComponentsSchemalessc                 k   sê  � |d j tjkrt d¡‚| ¡ }	|r?|d ur| ¡ }
n| jd ur*| jj|d�}
n| j| j	f}
||
|||ƒD ]}|V  q7d S |d u rˆ| j
|f|||dœ|¤ŽD ]
}
t|
tƒrZ|
V  qP| ¡ |	| k rƒtrƒt||d�D ]
}t|tƒru|V  qktdt|ƒt |¡f ƒ |
V  d S | ¡ }
|
 ¡  |  |
|¡}|jtjjtjjfv �r¬|j}|jtjjk}| o²|j }trÇtd| r¼dp½d	|rÁd
pÂd	|f ƒ tƒ }d}| ¡ |	 |k �rd|sÚd }n6|rà|j}n0z|ré|| j}n|| jsó|| jrù| |¡}n|| j}W n t �y   t d|f ¡‚w |||fi |¤ŽD ]}t|tƒ�r$|V  �q|�sI|�rI|�r6| !|j"¡}n|| j�sB|| j�rI| #|j"|¡}|
j$||dddd� | %|¡ |d7 }| ¡ |	 |k sÕt�rmtd| ƒ |�rš|j& '|¡�s€t d|
j(j) ¡‚|j*�r™| +di ¡}t�r£tdƒ | ,¡ D ]\}}td||f ƒ �q•|�s­| +dd¡�r™t-|j.ƒD ]æ\}}|j/�s¼�q²|j�rÉ|
 0|¡j1�sÉ�q²|
 2|j/j3¡}z|| }W nO t4�y%   t�rtd|
j(j)|j3|
j(j)|j/j3f ƒ |j/ ,¡ D ]\}}td||f ƒ �q÷z|j/| }W n t4�y"   t�rtd|f ƒ Y Y �q²w Y nw t�r1td||f ƒ |
 0|¡}|jtj5jtj6jfv �rqt-|ƒD ](\}}t7||  8¡ ƒ}||fd|i|¤ŽD ]}t|tƒ�rg|V  �q\|||< �qF�q²t7|
 0|¡ 8¡ ƒ}||fd|i|¤ŽD ]}t|tƒ�r�|V  �q„|
 $||¡ �q²nV|
j9}|�r«t d|
j(j)› d�¡‚nD|j}t�r¸td| ƒ d}| ¡ |	 |k �rð|||fi |¤ŽD ]}t|tƒ�r×|V  �qÌ|
j$||dddd� |d7 }| ¡ |	 |k �sÃ|
V  d S )Nr   úConstructed tag format expectedr8   ©r    r#   r!   )Úcontextz)Unused trailing %d octets encountered: %sú5decoding %sdeterministic %s type %r chosen by type IDúnon-r@   ÚSETú"Excessive components decoded at %rFr©   rU   úseen component indices %sú,ASN.1 object %s has uninitialized componentsÚ	openTypesúuser-specified open types map:ú%s -> %rÚdecodeOpenTypesúJdefault open types map of component "%s.%s" governed by component "%s.%s":ú1failed to resolve open type by governing value %rú+resolved open type %r by governing value %rr   úASN.1 object ú is inconsistentú+decoding type %r chosen by given `asn1Spec`):rK   r   ÚtagFormatConstructedr   r   rh   r:   r1   r¯   r°   r¸   rM   rN   rg   r	   r   r   ÚhexdumpÚclearr,   ÚtypeIdr   ÚSequenceÚSetÚcomponentTypeÚhasOptionalOrDefaultr­   ÚtagMapUniquer+   Ú
isOptionalÚisDefaultedÚgetTagMapNearPositionÚ
IndexErrorÚgetPositionByTypeÚeffectiveTagSetÚgetPositionNearTyperµ   r®   ÚrequiredComponentsÚissubsetrf   r.   ÚhasOpenTypesr9   Úitemsr´   Ú
namedTypesÚopenTypeÚgetComponentByPositionÚisValueÚgetComponentByNameÚnameÚKeyErrorÚSetOfÚ
SequenceOfr   ÚasOctetsÚisInconsistent)r   r   r   r    r!   r"   r#   r$   r%   rq   r+   r5   Útrailingrà   Ú	isSetTypeÚisDeterministicÚseenIndicesr¥   rÒ   rl   rÂ   ÚkÚvÚ	namedTypeÚgoverningValuerá   ÚcontainerValueÚposÚcontainerElementÚstreamÚinconsistencyr&   r&   r'   r(   Æ  sh  €


ÿþ
þ
€
€ÿþ
€ÿÿ€ý
×+ÿÿÿýþÿüþòÿ
ÿÿ€÷€€ÿÿ€ýõ
z*ConstructedPayloadDecoderBase.valueDecoderc                 k   sØ  � |d j tjkrt d¡‚|d ur=|d ur| ¡ }	n| jd ur(| jj|d�}	n| j| jf}	||	|||ƒD ]}
|
V  q5d S |d u rb| j	|f|||dœt
|dd�¤ŽD ]
}	t|	tƒr\|	V  qR|	V  d S | ¡ }	|	 ¡  |  |	|¡}|jtjjtjjfv �r¡|	j}|	jtjjk}| oŒ|j }tr¡td| r–dp—d	|r›d
pœd	|f ƒ tƒ }d}	 t|ƒ|kr°d }n5|r¶|j}n/z|r¿|| j}n|| jsÉ|| jrÏ| |¡}n|| j}W n tyä   t d|	f ¡‚w |||fddi|¤ŽD ]}t|tƒrú|V  |tju �r nqð|tju �r
n7|�s-|�r-|�r|  |j!¡}n|| j�s&|| j�r-| "|j!|¡}|	j#||dddd� | $|¡ |d7 }q§t�rJtd| ƒ |�r |j% &|¡�s]t d|	j'j( ¡‚|j)�r�| *di ¡}t�r€tdƒ | +¡ D ]\}}td||f ƒ �qr|�sŠ| *dd¡�rŽt,|j-ƒD ]þ\}}|j.�s™�q�|j�r¦|	 /|¡j0�s¦�q�|	 1|j.j2¡}z|| }W nO t3�y   t�râtd|	j'j(|j2|	j'j(|j.j2f ƒ |j. +¡ D ]\}}td||f ƒ �qÔz|j.| }W n t3�yÿ   t�rûtd|f ƒ Y Y �q�w Y nw t�rtd||f ƒ |	 /|¡}|jtj4jtj5jfv �rZt,|ƒD ]4\}}t6||  7¡ ƒ}||fd|it
|dd�¤ŽD ]}t|tƒ�rH|V  |tju �rP n�q=|||< �q#�q�t6|	 /|¡ 7¡ ƒ}||fd|it
|dd�¤ŽD ]}t|tƒ�r||V  |tju �r„ n|	 #||¡ �qq�q�nX|	j8}|�r t d|	j'j(› d�¡‚nF|j}t�r­td| ƒ d}	 |||fddi|¤ŽD ]}t|tƒ�rÆ|V  |tju �rÎ n�q»|tju �r×n|	j#||dddd� |d7 }�q°|	V  d S )Nr   r¹   r8   rº   T©rB   r¼   r½   r@   r¾   r¿   rB   Fr©   rU   rÀ   rÁ   rÂ   rÃ   rÄ   rÅ   rÆ   rÇ   rÈ   r   rÉ   rÊ   rË   )9rK   r   rÌ   r   r   r:   r1   r¯   r°   r¸   ÚdictrM   rN   rÎ   r,   rÏ   r   rÐ   rÑ   rÒ   rÓ   rg   r­   r   rÔ   r+   rÕ   rÖ   r×   rØ   r   rC   rÙ   rÚ   rÛ   rµ   r®   rÜ   rÝ   rf   r.   rÞ   r9   rß   r´   rà   rá   râ   rã   rä   rå   ræ   rç   rè   r   ré   rê   )r   r   r   r    r!   r"   r#   r$   r%   r+   r5   rà   rì   rí   rî   r¥   rl   rÂ   rï   rð   rñ   rò   rá   ró   rô   rõ   rö   r÷   rÒ   r&   r&   r'   r*   £  s~  €


ÿþ

þ
€þ
€ÿÿ
ÿý
Ð2ÿÿÿýþÿüþòÿ
ÿÿ

ÿÿó

ÿ€ÿ€ÿÿ
ÿÿýì
z2ConstructedPayloadDecoderBase.indefLenValueDecoder)NNNr-   )
r.   r/   r0   r¯   r°   r¦   r¨   r¸   r(   r*   r&   r&   r&   r'   r¡   ‰  s    
þ4
þ _þr¡   c                   @   ó   e Zd Ze ¡ Ze ¡ ZdS )Ú"SequenceOrSequenceOfPayloadDecoderN)r.   r/   r0   r   rÐ   r¯   rè   r°   r&   r&   r&   r'   rû   �  ó    rû   c                   @   ó   e Zd Ze ¡ ZdS )ÚSequencePayloadDecoderN)r.   r/   r0   r   rÐ   r1   r&   r&   r&   r'   rþ   ”  ó    rþ   c                   @   rý   )ÚSequenceOfPayloadDecoderN)r.   r/   r0   r   rè   r1   r&   r&   r&   r'   r   ˜  rÿ   r   c                   @   rú   )ÚSetOrSetOfPayloadDecoderN)r.   r/   r0   r   rÑ   r¯   rç   r°   r&   r&   r&   r'   r  œ  rü   r  c                   @   rý   )ÚSetPayloadDecoderN)r.   r/   r0   r   rÑ   r1   r&   r&   r&   r'   r  ¡  rÿ   r  c                   @   rý   )ÚSetOfPayloadDecoderN)r.   r/   r0   r   rç   r1   r&   r&   r&   r'   r  ¥  rÿ   r  c                   @   ó0   e Zd Ze ¡ Z		ddd„Z		ddd„ZdS )ÚChoicePayloadDecoderNc                 k   s  � |d u r| j j|d�}	n| ¡ }	|r"||	|||ƒD ]}
|
V  qd S |  |	|¡}|	j|krLtr6td|f ƒ |||	jfi |¤ŽD ]
}t|tƒrJ|V  q@n!trUtd|f ƒ |||	j|||fi |¤ŽD ]
}t|tƒrl|V  qb|j}trztd||f ƒ |	j	||ddddd� |	V  d S )Nr8   z'decoding %s as explicitly tagged CHOICEzdecoding %s as untagged CHOICEú*decoded component %s, effective tag set %sF©rª   r«   r¬   Ú	innerFlag)
r1   r:   r,   r    rg   ÚcomponentTagMaprM   rN   rÚ   ÚsetComponentByType)r   r   r   r    r!   r"   r#   r$   r%   r+   r5   rl   rÚ   r&   r&   r'   r(   ¬  sT   €
ÿ
ÿ
€ý
þ
þ
€ü
z!ChoicePayloadDecoder.valueDecoderc              	   k   s<  � |d u r| j j|d�}	n| ¡ }	|r"||	|||ƒD ]}
|
V  qd S |  |	|¡}|	j|k}tr;td||r6dp7df ƒ 	 |rN|||	jjfi t|dd�¤Ž}n|||	jj|||fi t|dd�¤Ž}|D ]-}t|t	ƒrl|V  |t
ju rs n|j}tr€td||f ƒ |	j||ddddd	� |s� nqb|r—|t
ju r˜nq<|	V  d S )
Nr8   zdecoding %s as %stagged CHOICEzexplicitly ÚunTrø   r  Fr  )r1   r:   r,   r    rg   rÒ   rÔ   rù   rM   rN   r   rC   rÚ   r
  )r   r   r   r    r!   r"   r#   r$   r%   r+   r5   ÚisTaggedÚiteratorrl   rÚ   r&   r&   r'   r*   ß  sd   €
ÿÿ
þþ
þ

ÿüÿÛ
'z)ChoicePayloadDecoder.indefLenValueDecoderr-   )r.   r/   r0   r   ÚChoicer1   r(   r*   r&   r&   r&   r'   r  ©  s    
þ4þr  c                   @   r  )ÚAnyPayloadDecoderNc                 k   s  � |d u rd}	n|j tju r||jv}	n||jk}	|	rJ|j}
| ¡ }| |
tj	¡ |||
 7 }t
rJt||ƒD ]
}t|tƒr@|V  q6t
dt |¡ ƒ |rd|| j||tfi |¤Ž|||ƒD ]}|V  q\d S t|||ƒD ]
}t|tƒrt|V  qj| j|||fi |¤ŽV  d S )NTz&decoding as untagged ANY, substrate %s)rf   r   ÚTagMapÚtagMapr    ÚmarkedPositionrh   ÚseekÚosÚSEEK_SETrg   r   rM   rN   r   rÍ   r>   r;   r	   )r   r   r   r    r!   r"   r#   r$   r%   Ú
isUntaggedÚfullPositionÚcurrentPositionr5   r&   r&   r'   r(   $  s>   €

€ÿþ
€zAnyPayloadDecoder.valueDecoderc                 k   s„  � |d u rd}	n|j tju r||jv }	n||jk}	|	r$d}
tr#tdƒ n,|j}| ¡ }| |t	j
¡ t||| |ƒD ]
}
t|
tƒrD|
V  q:trPtdt |
¡ ƒ | j}|rz|| jurz| j||tfi |¤Ž}|||
| |t|
ƒ |ƒD ]}
|
V  qrd S tr€tdƒ | j}	 |||f|ddœ|¤ŽD ]}t|tƒrš|V  |tju r¡ nq�|tju r¨n|
|7 }
q„|r´|
V  d S | j|||
fi |¤ŽV  d S )NFr_   zdecoding as tagged ANYz-decoding as untagged ANY, header substrate %sr^   Trm   )rf   r   r  r  r    rg   r  rh   r  r  r  r	   rM   rN   r   rÍ   r1   r6   r>   r;   r   r   rC   )r   r   r   r    r!   r"   r#   r$   r%   r  r5   r  r  r+   rl   r&   r&   r'   r*   M  sp   €
€
€ÿÿÿÿþ
þ

ÿ
ñ
z&AnyPayloadDecoder.indefLenValueDecoderr-   rD   r&   r&   r&   r'   r  !  s    
þ*þr  c                   @   rý   )ÚUTF8StringPayloadDecoderN)r.   r/   r0   r   Ú
UTF8Stringr1   r&   r&   r&   r'   r  š  rÿ   r  c                   @   rý   )ÚNumericStringPayloadDecoderN)r.   r/   r0   r   ÚNumericStringr1   r&   r&   r&   r'   r  ž  rÿ   r  c                   @   rý   )ÚPrintableStringPayloadDecoderN)r.   r/   r0   r   ÚPrintableStringr1   r&   r&   r&   r'   r  ¢  rÿ   r  c                   @   rý   )ÚTeletexStringPayloadDecoderN)r.   r/   r0   r   ÚTeletexStringr1   r&   r&   r&   r'   r  ¦  rÿ   r  c                   @   rý   )ÚVideotexStringPayloadDecoderN)r.   r/   r0   r   ÚVideotexStringr1   r&   r&   r&   r'   r!  ª  rÿ   r!  c                   @   rý   )ÚIA5StringPayloadDecoderN)r.   r/   r0   r   Ú	IA5Stringr1   r&   r&   r&   r'   r#  ®  rÿ   r#  c                   @   rý   )ÚGraphicStringPayloadDecoderN)r.   r/   r0   r   ÚGraphicStringr1   r&   r&   r&   r'   r%  ²  rÿ   r%  c                   @   rý   )ÚVisibleStringPayloadDecoderN)r.   r/   r0   r   ÚVisibleStringr1   r&   r&   r&   r'   r'  ¶  rÿ   r'  c                   @   rý   )ÚGeneralStringPayloadDecoderN)r.   r/   r0   r   ÚGeneralStringr1   r&   r&   r&   r'   r)  º  rÿ   r)  c                   @   rý   )ÚUniversalStringPayloadDecoderN)r.   r/   r0   r   ÚUniversalStringr1   r&   r&   r&   r'   r+  ¾  rÿ   r+  c                   @   rý   )ÚBMPStringPayloadDecoderN)r.   r/   r0   r   Ú	BMPStringr1   r&   r&   r&   r'   r-  Â  rÿ   r-  c                   @   rý   )ÚObjectDescriptorPayloadDecoderN)r.   r/   r0   r   ÚObjectDescriptorr1   r&   r&   r&   r'   r/  Ç  rÿ   r/  c                   @   rý   )ÚGeneralizedTimePayloadDecoderN)r.   r/   r0   r   ÚGeneralizedTimer1   r&   r&   r&   r'   r1  Ë  rÿ   r1  c                   @   rý   )ÚUTCTimePayloadDecoderN)r.   r/   r0   r   ÚUTCTimer1   r&   r&   r&   r'   r3  Ï  rÿ   r3  c                 C   s   g | ]}|‘qS r&   r&   )Ú.0Úxr&   r&   r'   Ú
<listcomp>  s    r7  r•   )r   r   c                   @   sF   e Zd ZeZeƒ ZdZeZe	Z	e
e
fdd„Zdddeddfdd„ZdS )ÚSingleItemDecoderTc                 K   s8   |t ur|n| j| _|t ur|n| j| _i | _i | _d S r4   )r
   ÚTAG_MAPÚ_tagMapÚTYPE_MAPÚ_typeMapÚ	_tagCacheÚ_tagSetCache)r   r  ÚtypeMapÚignoredr&   r&   r'   Ú__init__  s   
zSingleItemDecoder.__init__Nc           $      k   sÊ  � |  dd¡}	|	tkrt dt ¡‚|	d |d< | dd¡}
tr+tdtj|||f ƒ |
rX| jrXt	|d|ƒD ]
}t
|tƒr@|V  q6|tkrQtrKtd	ƒ tjV  d S | d
tj¡ | j}| j}| j}| j}t}| ¡ |_|tu�rQ|tu �r8d}t	|d|ƒD ]
}t
|tƒr‡|V  q}t|ƒ}z|| }W nl tyþ   |}|d@ }|d@ }|d@ }|dkrîd}d}d}	 t	|d|ƒD ]
}t
|tƒrÂ|V  q¸|sÊt d¡‚t|ƒ}|d7 }|tkrÞt dtf ¡‚|dK }||d@ O }|d@ sínq²tj|||d�}|rü|||< Y nw |d u �r)|�r"z|| }W n t�y!   t  d|¡}|||< Y nw t  d|¡}n|| }t!}t�r8td| ƒ |t!u �rÍt	|d|ƒD ]}t
|tƒ�rN|V  �qCt|ƒ}|dk �r\|}nX|dk�r²|d@ }|t"k�rst d|t"f ¡‚t	|||ƒD ]}t
|tƒ�r„|V  �qyt#|ƒ}t$|ƒ|k�r�t d|t$|ƒ|f ¡‚d}|D ]}|dK }||O }�q¡|d7 }nd}|dk�rÂ| j�sÂt d¡‚t%}t�rÍtd| ƒ |t%u �rÜ|d u �rÚt&}nt'}|t&u �rEz|| }W n t�yó   d }Y nw |�rút(}nz
||d d…  }W n t�y   d }Y nw |�rt(}nt)}t�rEtd|�r&|j*j+�p'd|t(u �r/d�p0d f ƒ tj ,|d u �r?d!�pC|j-j*j+¡ |t'u �rQ|j*t.j/u �r°z|| }W n t�yc   d }Y nw t�r¯td"ƒ |j0 1¡ D ]\}} td#|| j*j+f ƒ �qp|j2�r�td$ƒ |j2 1¡ D ]\}} td#|| j*j+f ƒ �q�td%|d u �r§d�pª| 3¡ |f ƒ n||j4k�s¼||j5v �rÊ|}t�rÉtd&|j*j+ ƒ nd }|d u�r z||j6 }t�râtd'|j6f ƒ W n1 t�y   t  |j4j7|j4j7¡}!z||! }t�rtd(|!f ƒ W n t�y   d }Y nw Y nw |�r|}t(}nt)}nd }t)}t�rQtd)|t(u �r3|j*j+�p4d|t(u �r<d�p=d f ƒ tj ,|d u �rLd!�pO|j*j+¡ |t(u �rë|  d*d¡�sd|�sdd+d,„ }| ¡ }"|dk�rŠ|j8||||t%| |fi |¤ŽD ]}t
|tƒ�r‡|V  �q|nB|j9||||t%| |fi |¤ŽD ]}t
|tƒ�r¤|V  �q™| ¡ |" }#|�s¼|#|k�r¼td-|#|f ƒ‚|�rÌ|#|k�rÌtd.|#|f ƒ‚t�rètd/|j*j+|j*j+t
|t:j;ƒ�rã| <¡ �pä|f ƒ t}nf|t)u �r*|�r
|d j=tj>k�r
|d j?tj@k�r
tA}t(}nd }| jB}t�r*td0|�r|j*j+�pd|t(u �r%d�p&d1f ƒ |tCu �r?| jD}t�r=td2|j*j+ ƒ t(}|tEu �rMt d3||f ¡‚|tuspt�r`tj ¡  td4tj ƒ |V  d S )5NÚ_nestingLevelr   z0ASN.1 structure nesting depth exceeds limit (%d)rU   rB   FzWdecoder called at scope %s with state %d, working with up to %s octets of substrate: %sr~   zend-of-octets sentinel foundéþÿÿÿTr”   é    é   z'Short octet stream on long tag decodingz%Tag ID octet count exceeds limit (%d)rY   rx   rw   )ÚtagClassrK   ÚtagIdr&   z$tag decoded into %s, decoding lengthz+BER length field size %d exceeds limit (%d)z%s<%s at %sr   r‘   z6Indefinite length encoding not supported by this codeczvalue length decoded into %dz/codec %s chosen by a built-in type, decoding %sz<none>r=   zas explicit tagú?z!candidate ASN.1 spec is a map of:z
  %s -> %szbut neither of: z,new candidate ASN.1 spec is %s, chosen by %szcandidate ASN.1 spec is %sz8value decoder chosen for an ambiguous type by type ID %szvalue decoder chosen by base %sz*codec %s chosen by ASN.1 spec, decoding %sÚrecursiveFlagc                 s   s   � | V  dS )ae  Legacy hack to keep the recursiveFlag=False option supported.

                        The decode(..., substrateFun=userCallback) option was introduced in 0.1.4 as a generalization
                        of the old recursiveFlag=False option. Users should pass their callback instead of using
                        recursiveFlag.
                        Nr&   )r+   Ú
_substrateÚ_lengthÚ_optionsr&   r&   r'   r$   B  s   €
z0SingleItemDecoder.__call__.<locals>.substrateFunz%Read %s bytes instead of expected %s.z(Read %s bytes are more than expected %s.z&codec %s yields type %s, value:
%s
...zcodec %s chosen, decoding %sz
as failurezcodec %s chosen, decoding valuez%s not in asn1Spec: %rz%decoder left scope %s, call completed)Fr9   ÚMAX_NESTING_DEPTHr   r   Úpoprg   r   ÚscopeÚsupportIndefLengthr	   rM   rN   ÚEOO_SENTINELr   rC   r  r  ÚSEEK_CURr:  r<  r=  r>  r;   rh   r  ÚstStopÚstDecodeTagrc   ræ   ÚMAX_TAG_OCTETSr   ÚTagr±   ÚstDecodeLengthÚMAX_LENGTH_OCTETSÚlistr   ÚstGetValueDecoderÚstGetValueDecoderByTagÚstGetValueDecoderByAsn1SpecÚstDecodeValueÚstTryAsExplicitTagrf   r.   Úpushr1   r   r  ÚpresentTypesrß   Ú	skipTypesÚprettyPrintTyper    r  rÏ   r²   r*   r(   r   ÚAsn1ItemÚprettyPrintrK   rÌ   rF  ÚtagClassUniversalÚrawPayloadDecoderÚdefaultErrorStateÚstDumpRawValueÚdefaultRawDecoderÚstErrorCondition)$r   r   r   r    r!   r"   r#   r$   r%   rB  rB   Úeoo_candidater  r?  ÚtagCacheÚtagSetCacher=   Ú
isShortTagÚ	firstByteÚ
firstOctetÚlastTagÚ
integerTagrF  rK   rG  ÚtagOctetCountÚintegerByteÚsizeÚencodedLengthÚlengthOctetÚconcreteDecoderÚ
chosenSpecrð   Ú
baseTagSetrq   Ú	bytesReadr&   r&   r'   Ú__call__%  s  €ÿþ

€



€
€ÿÿÿëÿ€Ø
*ý
€


ÿÿ€ÿ




ÿÿ0"
ÿ$€€

€€ÿ€ö4 
	
ý
ý€ûý
ý€
ÿ
ÿþ
0


ÿ � �Ë  9

zSingleItemDecoder.__call__)r.   r/   r0   rj  rg  r  ri  rP  r9  r;  r
   rA  rT  r|  r&   r&   r&   r'   r8    s    þr8  c                   @   s&   e Zd ZdZeZddd„Zdd„ ZdS )r   a±	  Create an iterator that turns BER/CER/DER byte stream into ASN.1 objects.

    On each iteration, consume whatever BER/CER/DER serialization is
    available in the `substrate` stream-like object and turns it into
    one or more, possibly nested, ASN.1 objects.

    Parameters
    ----------
    substrate: :py:class:`file`, :py:class:`io.BytesIO`
        BER/CER/DER serialization in form of a byte stream

    Keyword Args
    ------------
    asn1Spec: :py:class:`~pyasn1.type.base.PyAsn1Item`
        A pyasn1 type object to act as a template guiding the decoder.
        Depending on the ASN.1 structure being decoded, `asn1Spec` may
        or may not be required. One of the reasons why `asn1Spec` may
        me required is that ASN.1 structure is encoded in the *IMPLICIT*
        tagging mode.

    Yields
    ------
    : :py:class:`~pyasn1.type.base.PyAsn1Item`, :py:class:`~pyasn1.error.SubstrateUnderrunError`
        Decoded ASN.1 object (possibly, nested) or
        :py:class:`~pyasn1.error.SubstrateUnderrunError` object indicating
        insufficient BER/CER/DER serialization on input to fully recover ASN.1
        objects from it.

        In the latter case the caller is advised to ensure some more data in
        the input stream, then call the iterator again. The decoder will resume
        the decoding process using the newly arrived data.

        The `context` property of :py:class:`~pyasn1.error.SubstrateUnderrunError`
        object might hold a reference to the partially populated ASN.1 object
        being reconstructed.

    Raises
    ------
    ~pyasn1.error.PyAsn1Error, ~pyasn1.error.EndOfStreamError
        `PyAsn1Error` on deserialization error, `EndOfStreamError` on
         premature stream closure.

    Examples
    --------
    Decode BER serialisation without ASN.1 schema

    .. code-block:: pycon

        >>> stream = io.BytesIO(
        ...    b'0	')
        >>>
        >>> for asn1Object in StreamingDecoder(stream):
        ...     print(asn1Object)
        >>>
        SequenceOf:
         1 2 3

    Decode BER serialisation with ASN.1 schema

    .. code-block:: pycon

        >>> stream = io.BytesIO(
        ...    b'0	')
        >>>
        >>> schema = SequenceOf(componentType=Integer())
        >>>
        >>> decoder = StreamingDecoder(stream, asn1Spec=schema)
        >>> for asn1Object in decoder:
        ...     print(asn1Object)
        >>>
        SequenceOf:
         1 2 3
    Nc                 K   s,   | j di |¤Ž| _t|ƒ| _|| _|| _d S )Nr&   )ÚSINGLE_ITEM_DECODERÚ_singleItemDecoderr   rJ  Ú	_asn1SpecrL  )r   r   r   r%   r&   r&   r'   rA  Þ  s   

zStreamingDecoder.__init__c                 c   sT   � 	 | j | j| jfi | j¤ŽD ]}|V  qt| jƒD ]
}t|tƒr$d V   |r)d S qr4   )r~  rJ  r  rL  r   rM   rN   )r   r+   r5   r&   r&   r'   Ú__iter__ä  s   €ÿ
ÿ
ôzStreamingDecoder.__iter__r4   )r.   r/   r0   Ú__doc__r8  r}  rA  r€  r&   r&   r&   r'   r   ‘  s
    J
r   c                   @   s.   e Zd ZdZeZeddd„ƒZedd„ ƒZ	dS )r   znCreate a BER decoder object.

    Parse BER/CER/DER octet-stream into one, possibly nested, ASN.1 object.
    Nc              	      s˜   t |ƒ}d|v r|d ‰ d‡ fdd„	}||d< | j||fi |¤Ž}|D ]&}t|tƒr/t d¡‚ztt|ƒƒ}W n tjyC   d}Y nw ||f  S dS )a.  Turns BER/CER/DER octet stream into an ASN.1 object.

        Takes BER/CER/DER octet-stream in form of :py:class:`bytes`
        and decode it into an ASN.1 object
        (e.g. :py:class:`~pyasn1.type.base.PyAsn1Item` derivative) which
        may be a scalar or an arbitrary nested structure.

        Parameters
        ----------
        substrate: :py:class:`bytes`
            BER/CER/DER octet-stream to parse

        Keyword Args
        ------------
        asn1Spec: :py:class:`~pyasn1.type.base.PyAsn1Item`
            A pyasn1 type object (:py:class:`~pyasn1.type.base.PyAsn1Item`
            derivative) to act as a template guiding the decoder.
            Depending on the ASN.1 structure being decoded, `asn1Spec` may or
            may not be required. Most common reason for it to require is that
            ASN.1 structure is encoded in *IMPLICIT* tagging mode.

        substrateFun: :py:class:`Union[
                Callable[[pyasn1.type.base.PyAsn1Item, bytes, int],
                         Tuple[pyasn1.type.base.PyAsn1Item, bytes]],
                Callable[[pyasn1.type.base.PyAsn1Item, io.BytesIO, int, dict],
                         Generator[Union[pyasn1.type.base.PyAsn1Item,
                                         pyasn1.error.SubstrateUnderrunError],
                                   None, None]]
            ]`
            User callback meant to generalize special use cases like non-recursive or
            partial decoding. A 3-arg non-streaming variant is supported for backwards
            compatiblilty in addition to the newer 4-arg streaming variant.
            The callback will receive the uninitialized object recovered from substrate
            as 1st argument, the uninterpreted payload as 2nd argument, and the length
            of the uninterpreted payload as 3rd argument. The streaming variant will
            additionally receive the decode(..., **options) kwargs as 4th argument.
            The non-streaming variant shall return an object that will be propagated
            as decode() return value as 1st item, and the remainig payload for further
            decode passes as 2nd item.
            The streaming variant shall yield an object that will be propagated as
            decode() return value, and leave the remaining payload in the stream.

        Returns
        -------
        : :py:class:`tuple`
            A tuple of :py:class:`~pyasn1.type.base.PyAsn1Item` object
            recovered from BER/CER/DER substrate and the unprocessed trailing
            portion of the `substrate` (may be empty)

        Raises
        ------
        : :py:class:`~pyasn1.error.PyAsn1Error`
            :py:class:`~pyasn1.error.SubstrateUnderrunError` on insufficient
            input or :py:class:`~pyasn1.error.PyAsn1Error` on decoding error.

        Examples
        --------
        Decode BER/CER/DER serialisation without ASN.1 schema

        .. code-block:: pycon

           >>> s, unprocessed = decode(b'0	')
           >>> str(s)
           SequenceOf:
            1 2 3

        Decode BER/CER/DER serialisation with ASN.1 schema

        .. code-block:: pycon

           >>> seq = SequenceOf(componentType=Integer())
           >>> s, unprocessed = decode(
                b'0	', asn1Spec=seq)
           >>> str(s)
           SequenceOf:
            1 2 3

        r$   Nc              
   3   sx   � z	ˆ | |||ƒ}W n' t y1 } z|jjr‚ t|tjƒsJ ‚t ˆ | ||¡}W Y d}~nd}~ww |D ]}|V  q4dS )ar  Support both 0.4 and 0.5 style APIs.

                substrateFun API has changed in 0.5 for use with streaming decoders. To stay backwards compatible,
                we first try if we received a streaming user callback. If that fails,we assume we've received a
                non-streaming v0.4 user callback and convert it for streaming on the fly
                N)Ú	TypeErrorÚ__traceback__Útb_nextrM   ÚioÚBytesIOr   Ú_callSubstrateFunV4asV5)r+   r   r!   r%   Úsubstrate_genÚ_valuer=   ©ÚorigSubstrateFunr&   r'   ÚsubstrateFunWrapperP  s   €€úÿz-Decoder.__call__.<locals>.substrateFunWrapperzShort substrate on inputr_   r4   )r   ÚSTREAMING_DECODERrM   rN   r   Únextr	   ÚEndOfStreamError)Úclsr   r   r%   rŒ  ÚstreamingDecoderr+   Útailr&   rŠ  r'   r|  û  s(   Pÿÿ

ÿözDecoder.__call__c                 c   sV   � |  ¡ }|dkrt|ƒ}| |||ƒ\}}| |¡}| ¡  | | tj¡ |V  d S )Nr‘   )Úreadr   ÚwriteÚtruncater  r  rR  )ÚsubstrateFunV4r+   r   r!   Úsubstrate_bytesr=   ÚnextSubstrateÚnbytesr&   r&   r'   r‡  t  s   €

zDecoder._callSubstrateFunV4asV5r4   )
r.   r/   r0   r�  r   r�  Úclassmethodr|  r2   r‡  r&   r&   r&   r'   r   ô  s    xr   Úattrc                 C   sB   dddœ  | ¡ }rtj| › d|› d�tdd� tƒ | S t| ƒ‚)Nr9  r;  )r  r?  z is deprecated. Please use z	 instead.r~   )Ú
stacklevel)r9   ÚwarningsÚwarnÚDeprecationWarningÚglobalsÚAttributeError)r›  ÚnewAttrr&   r&   r'   Ú__getattr__¸  s   
r£  )�r…  r  Úsysr�  Úpyasn1r   r   Úpyasn1.codec.berr   Úpyasn1.codec.streamingr   r   r   r	   Úpyasn1.compatr
   Úpyasn1.errorr   Úpyasn1.typer   r   r   r   r   r   Ú__all__ÚregisterLoggeer.   ÚDEBUG_DECODERrg   r;   rN   r�   rU  rM  rX  Úobjectr   r3   r?   rf  rG   rT   rX   ro   rs   ru   r‹   rŽ   r    r¡   rû   rþ   r   r  r  r  r  r  r  r  r  r  r!  r#  r%  r'  r)  r+  r-  r/  r1  r3  rR   r    rV   rn   rr   rt   rŠ   r�   Ú
EnumeratedrŸ   rÐ   rÑ   r  r  r  r  r   r"  r$  r&  r(  r*  r,  r.  r0  r2  r4  r9  rÏ   rç   rè   rE   r;  ÚvaluesÚtypeDecoderr1   rf   ÚrangerT  rW  rZ  r\  r[  r^  r]  rh  rj  rS  rQ   rQ  r8  r   r   r   Ústrr£  r&   r&   r&   r'   Ú<module>   s&  ) VC7n    
xy
ÿ
þ
ý
ü
û
ú
ù
ø
	÷

ö
õ
ô
ò
ñ
ð
ï
î








ä
!




ú

€÷   c C