
    i[9                       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                  Zej        Zej        ZdZ  G d de!          Z" G d de"          Z# G d de#          Z$ e$            Z% G d de#          Z& G d de&          Z' G d de#          Z( G d  d!e#          Z) G d" d#e#          Z* G d$ d%e#          Z+ G d& d'e#          Z, G d( d)e#          Z- G d* d+e"          Z. G d, d-e.          Z/ G d. d/e/          Z0 G d0 d1e0          Z1 G d2 d3e0          Z2 G d4 d5e/          Z3 G d6 d7e3          Z4 G d8 d9e3          Z5 G d: d;e/          Z6 G d< d=e#          Z7 G d> d?e)          Z8 G d@ dAe)          Z9 G dB dCe)          Z: G dD dEe)          Z; G dF dGe)          Z< G dH dIe)          Z= G dJ dKe)          Z> G dL dMe)          Z? G dN dOe)          Z@ G dP dQe)          ZA G dR dSe)          ZB G dT dUe)          ZC G dV dWe)          ZD G dX dYe)          ZEi ejF        jG         e&            ejH        jG         e'            ejI        jG         e(            ejJ        jG         e)            ejK        jG         e*            ejL        jG         e+            ejM        jG         e,            ejN        jG         e&            ejO        jG         e-            ejP        jG         e0            ejQ        jG         e3            ejR        jG         e6            ejS        jG         e8            ejT        jG         e9            ejU        jG         e:            ejV        jG         e;            ejW        jG         e<            ejX        jG         e=            ejY        jG         e>            ejZ        jG         e?            ej[        jG         e@            ej\        jG         eA            ej]        jG         eB            ej^        jG         eC            ej_        jG         eD            ej`        jG         eE            i	ZaejQ        jb         e4            ejc        jb         e5            ejP        jb         e1            ejd        jb         e2            ejR        jb         e6            eje        jb         e7            iZfeag                                D ]%Zhehji        ehji        jj        jb        Zbeb	ebefvrehefeb<   &dZ  ekd[          D             \
  ZlZmZnZoZpZqZrZsZtZu evd\          Zw G d] d^e!          Zx G d_ d`e!          Zy G da dbe!          Zz ez            Z{dce|fddZ}dS )e    N)debug)error)eoo)asSeekableStream)isEndOfStream)peekIntoStreamreadFromStream)_MISSING)PyAsn1Error)base)char)tag)tagmap)univ)useful)StreamingDecoderDecoderdecode)flags   c                   @    e Zd ZdZ	 	 ddZ	 	 ddZed             ZdS )AbstractPayloadDecoderNc                 0    t          j        d|          )ztDecode value with fixed byte length.

        The decoder is allowed to consume as many bytes as necessary.
        z&SingleItemDecoder not implemented for r   r   	self	substrateasn1SpectagSetlengthstate	decodeFunsubstrateFunoptionss	            S/root/projects/butler/venv/lib/python3.11/site-packages/pyasn1/codec/ber/decoder.pyvalueDecoderz#AbstractPayloadDecoder.valueDecoder,   s     ff VWWW    c                 0    t          j        d|          )zsDecode value with undefined length.

        The decoder is allowed to consume as many bytes as necessary.
        z3Indefinite length mode decoder not implemented for r   r   s	            r&   indefLenValueDecoderz+AbstractPayloadDecoder.indefLenValueDecoder6   s     [a[a cdddr(   c                     d|vr| |d<   |S )N
asn1Object )r,   r%   s     r&   _passAsn1Objectz&AbstractPayloadDecoder._passAsn1Object@   s    w&&$.GL!r(   NNNNN)__name__
__module____qualname__protoComponentr'   r*   staticmethodr.   r-   r(   r&   r   r   )   su        N 6:26X X X X >B:>e e e e   \  r(   r   c                   *    e Zd Zed             Zd ZdS )AbstractSimplePayloadDecoderc              #   :   K   t          |||          D ]}|V  d S Nr	   )r,   r   r!   r%   chunks        r&   substrateCollectorz/AbstractSimplePayloadDecoder.substrateCollectorI   s6      #Ivw?? 	 	EKKKK	 	r(   c                     |                     d          r|S || j                            ||          S |t          u r|S |                    |          S )Nnativer    )getr3   clonenoValuer   r   r    valuer%   s        r&   _createComponentz-AbstractSimplePayloadDecoder._createComponentN   s_    ;;x   	)L&,,U6,BBBgO>>%(((r(   N)r0   r1   r2   r4   r:   rC   r-   r(   r&   r6   r6   H   s<          \) ) ) ) )r(   r6   c                   F    e Zd Z ej        d          Z	 	 ddZ	 	 ddZdS )RawPayloadDecoder Nc              +      K   |r' | j         ||dfi |}	 ||	|||          D ]}
|
V  d S  |||||fi |D ]}|V  d S )NrF   )rC   r   r   r   r    r!   r"   r#   r$   r%   r,   r9   rB   s               r&   r'   zRawPayloadDecoder.valueDecoder\   s        	..xOOwOOJ%j)VWMM  FYy(FFNNgNN 	 	EKKKK	 	r(   c              +      K   |r' | j         ||dfi |}	 ||	|||          D ]}
|
V  d S 	  |||||fddi|D ]}|t          j        u r d S |V  ')NrF   TallowEoo)rC   r   endOfOctetsrH   s               r&   r*   z&RawPayloadDecoder.indefLenValueDecoderk   s        	..xOOwOOJ%j)VWMM  F	"x. .!.%,. .   CO++FF	r(   r/   r0   r1   r2   r   Anyr3   r'   r*   r-   r(   r&   rE   rE   Y   s\        TXb\\N 6:26     >B:>     r(   rE   c                   :    e Zd Z ej        d          Z	 	 ddZdS )IntegerPayloadDecoderr   Nc              +   D  K   |d         j         t          j        k    rt          j        d          t          |||          D ]}	t          |	t                    r|	V  |	r+t          	                    t          |	          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bytesrC   )r   r   r   r    r!   r"   r#   r$   r%   r9   rB   s              r&   r'   z"IntegerPayloadDecoder.valueDecoder   s      
 !9#"555#$@AAA#Ivw?? 	 	E%!788  	NN5<<tNDDEE E#d#HfeGGwGGGGGGGr(   r/   )r0   r1   r2   r   Integerr3   r'   r-   r(   r&   rO   rO      sE        !T\!__N 6:26H H H H H Hr(   rO   c                   4    e Zd Z ej        d          Zd ZdS )BooleanPayloadDecoderr   c                 4    t          j        | |||rdpdfi |S )N   r   )rO   rC   rA   s        r&   rC   z&BooleanPayloadDecoder._createComponent   s;    $5(FEKa$41A A8?A A 	Ar(   N)r0   r1   r2   r   Booleanr3   rC   r-   r(   r&   r]   r]      s7        !T\!__NA A A A Ar(   r]   c                   J    e Zd Z ej        d          ZdZ	 	 ddZ	 	 ddZdS )BitStringPayloadDecoderr-   TNc              +   (  K   |r, | j         ||t          fi |}	 ||	|||          D ]}
|
V  d S |st          j        d          t	          |          D ]}
t          |
t                    r|
V  |
rt          j        d          |d         j        t          j	        k    rt          |d|          D ]}t          |t                    r|V  t          |          }|dk    rt          j        d|z            t          ||dz
  |          D ]}
t          |
t                    r|
V  | j                            |
d|          } | j         |||fi |V  d S | j        s!t          j        d| j        j        z            t"          rt#          d	           | j        }| j                            d
d          }|                                }|                                |z
  |k     r ||| j        fd|i|D ]}t          |t                    r|V  |d         }|dk    rt          j        d|z            | j                            |dd          d||          }|                                |z
  |k      | j         |||fi |V  d S )NzEmpty BIT STRING substrater   r_      Trailing bits overflow %sT)internalFormatpadding*Constructed encoding form prohibited at %s$assembling constructed serializationr(   rf   r$   rf   prependrg   )rC   r@   r   r   r   rV   rW   rT   r   rU   r
   ordr3   fromOctetStringsupportConstructedForm	__class__r0   LOGr:   tell)r   r   r   r    r!   r"   r#   r$   r%   r,   r9   trailingBitsrB   	bitStringcurrent_position	components                   r&   r'   z$BitStringPayloadDecoder.valueDecoder   s     
  	..xTTGTTJ%j)VWMM  F 	B#$@AAA"9-- 	 	E%!788  	B#$@AAA!9#"555 .y!W E E ' 'l,BCC '&&&&|,,La'/,>   (	6A:wGG    e%;<<  KKK'77dL 8 B BE ($'&%KK7KKKKKF* 	G# %,.2n.E%F G G G  	86777 .'77D7QQ	$>>++nn!11F::&Yt2 AM  $ $	 i)?@@ $#OOO$Q<La'/,>   +;;!""d!< <  I nn!11F::$ $d#HfiKK7KKKKKKKr(   c              +     K   |r, | j         ||t          fi |}	 ||	|||          D ]}
|
V  d S | j        }| j                            dd          }	  ||| j        f|dd|D ]+}|t
          j        u r nt          |t                    r|V  ,|t
          j        u rnL|d         }|dk    rt          j
        d|z            | j                            |dd          d||	          } | j         |||fi |V  d S )
Nr(   Trj   r$   rJ   r   rd   re   r_   rk   )rC   r@   r:   r3   rn   r   rK   rV   rW   r   r   )r   r   r   r    r!   r"   r#   r$   r%   r,   r9   rt   rv   rs   s                 r&   r*   z,BitStringPayloadDecoder.indefLenValueDecoder   s     
  	..xTTGTTJ%j)VWMM  F .'77D7QQ		&Yt2.AM!. .%,. . $ $	 //Ei)?@@ $#OOOCO++$Q<La'/,>   +;;!""d!< <  I+	4 $d#HfiKK7KKKKKKKr(   r/   )	r0   r1   r2   r   	BitStringr3   ro   r'   r*   r-   r(   r&   rb   rb      ss        #T^B''N! 6:26NL NL NL NLb >B:>,L ,L ,L ,L ,L ,Lr(   rb   c                   J    e Zd Z ej        d          ZdZ	 	 ddZ	 	 ddZdS )OctetStringPayloadDecoderrF   TNc              +     K   |r, | j         ||t          fi |}	 ||	|||          D ]}
|
V  d S |d         j        t          j        k    rAt          |||          D ]}
t          |
t                    r|
V   | j         |||
fi |V  d S | j        s!t          j
        d| j        j        z            t          rt          d           | j        }d}|                                }|                                |z
  |k     rM ||| j        fd|i|D ]}t          |t                    r|V  ||z  }|                                |z
  |k     M | j         |||fi |V  d S )Nr   rh   ri   r(   r$   )rC   r@   rT   r   rU   r
   rV   rW   ro   r   r   rp   r0   rq   r:   rr   r3   )r   r   r   r    r!   r"   r#   r$   r%   r,   r9   headeroriginal_positionrv   s                 r&   r'   z&OctetStringPayloadDecoder.valueDecoder,  s       	..xTTGTTJ%j)VWMM  F!9#"555'	67CC    e%;<<  KKK'$'&%KK7KKKKKF* 	l#$PSWSaSj$jkkk 	86777 .%NN,,nn!22V;;&Yt2 AM  $ $	 i)?@@ $#OOOiF nn!22V;; $d#HffHHHHHHHHHr(   c              +   V  K   |r5|| j         ur, | j        ||t          fi |}	 ||	|||          D ]}
|
V  d S | j         }d}	  ||| j        f|dd|D ]+}t	          |t
                    r|V  |t          j        u r n,|t          j        u rn||z  }S | j        |||fi |V  d S )Nr(   Trx   )r:   rC   r@   r3   rV   rW   r   rK   )r   r   r   r    r!   r"   r#   r$   r%   r,   r9   r}   rv   s                r&   r*   z.OctetStringPayloadDecoder.indefLenValueDecoderY  s<       	L0GGG..xTTGTTJ%j)VWMM  F .	 &Yt2.AM!. .%,. .  	 i)?@@ $#OOO//E 0 CO++iF	 " $d#HffHHHHHHHHHr(   r/   )	r0   r1   r2   r   OctetStringr3   ro   r'   r*   r-   r(   r&   r{   r{   (  sp        %T%b))N! 6:26+I +I +I +I\ >B:>"I "I "I "I "I "Ir(   r{   c                   :    e Zd Z ej        d          Z	 	 ddZdS )NullPayloadDecoderrF   Nc              +     K   |d         j         t          j        k    rt          j        d          t          |||          D ]}	t          |	t                    r|	V   | j        ||dfi |}
|	rt          j        d|z            |
V  d S )Nr   rQ   rF   z&Unexpected %d-octet substrate for Null)	rT   r   rU   r   r   r
   rV   rW   rC   )r   r   r   r    r!   r"   r#   r$   r%   r9   rv   s              r&   r'   zNullPayloadDecoder.valueDecoder  s      
 !9#"555#$@AAA#Ivw?? 	 	E%!788 )D)(FBJJ'JJ	 	W#$Lv$UVVVr(   r/   )r0   r1   r2   r   Nullr3   r'   r-   r(   r&   r   r   ~  s?        TYr]]N 6:26     r(   r   c                   :    e Zd Z ej        d          Z	 	 ddZdS )ObjectIdentifierPayloadDecoderr-   Nc              +     K   |d         j         t          j        k    rt          j        d          t          |||          D ]}	t          |	t                    r|	V  |	st          j        d          d}
d}t          |	          }||k     r|	|         }|dz  }|dk     r|
|fz  }
n|dk    r|}d}d}|dk    ri|dz  }|t          k    rt          j        dt          |fz            |dz  |d	z  z   }||k    rt          j        d
|
          |	|         }|dz  }|dk    i|
|dz  |z   fz  }
n|dk    rt          j        d          ||k     d|
d         cxk    rdk    r	n nd|
z   }
nqd|
d         cxk    rdk    rn nd|
d         dz
  f|
dd          z   }
nB|
d         dk    rd|
d         dz
  f|
dd          z   }
nt          j        d|	d         z             | j
        |||
fi |V  d S )Nr   rQ   Empty substrater-   r_      zEOID arc exceeds maximum continuation octets limit (%d) at position %drd      !Short substrate for sub-OID past z"Invalid octet 0x80 in OID encoding'   )r   (   O   P      zMalformed first OID octet: %srT   r   rU   r   r   r
   rV   rW   lenMAX_OID_ARC_CONTINUATION_OCTETSrC   )r   r   r   r    r!   r"   r#   r$   r%   r9   oidindexsubstrateLensubId	nextSubIdcontinuationOctetCounts                   r&   r'   z+ObjectIdentifierPayloadDecoder.valueDecoder  s      !9#"555#$@AAA#Ivw?? 	 	E%!788  	7#$56665zzl""%LEQJEs{{x!	)*&3&&*a/*-0OOO#/-0OQV/WX   #aZI,<=E,,#::EHSJ   !&eIQJE  3&& !y022#
 '(LMMM= l""B A"*CC3q6Rc!frk"SW,CCVr\\c!frk"SW,CC#$CeAh$NOOO#d#HfcEEWEEEEEEEr(   r/   )r0   r1   r2   r   ObjectIdentifierr3   r'   r-   r(   r&   r   r     sH        *T*2..N 6:26;F ;F ;F ;F ;F ;Fr(   r   c                   :    e Zd Z ej        d          Z	 	 ddZdS )RelativeOIDPayloadDecoderr-   Nc              +     K   |d         j         t          j        k    rt          j        d          t          |||          D ]}	t          |	t                    r|	V  |	st          j        d          d}
d}t          |	          }||k     r|	|         }|dz  }|dk     r|
|fz  }
n|dk    r|}d}d}|dk    ri|dz  }|t          k    rt          j        dt          |fz            |dz  |d	z  z   }||k    rt          j        d
|
          |	|         }|dz  }|dk    i|
|dz  |z   fz  }
n|dk    rt          j        d          ||k      | j
        |||
fi |V  d S )Nr   rQ   r   r-   r_   r   zNRELATIVE-OID arc exceeds maximum continuation octets limit (%d) at position %drd   r   r   z+Invalid octet 0x80 in RELATIVE-OID encodingr   )r   r   r   r    r!   r"   r#   r$   r%   r9   reloidr   r   r   r   r   s                   r&   r'   z&RelativeOIDPayloadDecoder.valueDecoder  s      !9#"555#$@AAA#Ivw?? 	 	E%!788  	7#$56665zzl""%LEQJEs{{5("!	)*&3&&*a/*-0OOO#/-0OQV/WX   #aZI,<=E,,#::EKVM   !&eIQJE  3&& EQJ)355#
 '(UVVV= l""@ $d#HffHHHHHHHHHr(   r/   )r0   r1   r2   r   RelativeOIDr3   r'   r-   r(   r&   r   r     sH        %T%b))N 6:261I 1I 1I 1I 1I 1Ir(   r   c                   8    e Zd Z ej                    Z	 	 ddZdS )RealPayloadDecoderNc              +   n  K   |d         j         t          j        k    rt          j        d          t          |||          D ]}	t          |	t                    r|	V  |	s | j        ||dfi |V  d S |	d         }
|	dd          }	|
dz  r|	st          j        d          t          rt          d           |
dz  dz   }|d	k    r|	d         }|	dd          }	|	d |         |	|d          }	}|r|	st          j        d
          |d         dz  rdpd}|r|dz  }||d         z  }|dd          }||
d	z	  dz  }|dk    rt          j        d          |dk    r|dz  }n|dk    r|d	z  }d}|	r|dz  }||	d         z  }|	dd          }	|	|
dz  r| }|
dz	  dz  }|d|z  z  }|d|f}n|
dz  r t          rt          d           |
dz  rdpd}n|
dz  dk    r|	st          j        d          t          rt          d           	 |
dz  dk    rt          |	          ddf}nI|
dz  dk    rt          |	          }n0|
dz  dk    rt          |	          }nt          j        d|
z            n9# t          $ r t          j        d          w xY wt          j        d|
z             | j        |||fi |V  d S )Nr   rQ   g        r_   r   zIncomplete floating-point valuezdecoding binary encoded REAL      zReal exponent screwed   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))rT   r   rU   r   r   r
   rV   rW   rC   rq   rX   float
ValueError)r   r   r   r    r!   r"   r#   r$   r%   r9   foneoebpsfrB   s                     r&   r'   zRealPayloadDecoder.valueDecoder  s      !9#"555#$@AAA#Ivw?? 	 	E%!788  	'$'&#IIIIIIIF1Xabb	9 U	 K'(IJJJ 42333daAAvv!Habb	bqb	59B AU A'(?@@@1#(qA aRU
V  
 a$A1uu'(;<<<AvvQaQA "aU1Xabb	  "
 Dy Bq4BbLA1IEE$Y $	 .,---I(&1EEE$Y!^^ K'(IJJJ 756668s?? ZZQ/EE#X__!%LLEE#X__!%LLEE  6-2      2/   .+b0   $d#HfeGGwGGGGGGGs   A%I* *J	r/   )r0   r1   r2   r   Realr3   r'   r-   r(   r&   r   r     sI        TY[[N 6:26hH hH hH hH hH hHr(   r   c                       e Zd ZdZdS )!AbstractConstructedPayloadDecoderN)r0   r1   r2   r3   r-   r(   r&   r   r   {  s        NNNr(   r   c                   F    e Zd ZdZdZd Zd Z	 	 ddZ	 	 ddZ	 	 ddZ	dS )	ConstructedPayloadDecoderBaseNc                     t           r8   NotImplementedError)r   r,   idxs      r&   _getComponentTagMapz1ConstructedPayloadDecoderBase._getComponentTagMap      !!r(   c                     t           r8   r   )r   r,   r    r   s       r&   _getComponentPositionByTypez9ConstructedPayloadDecoderBase._getComponentPositionByType  r   r(   c              +     K   d }g }t                      }|                                }	|dk    s|                                |	|z   k     r ||fi |D ]}
t          |
t                    r|
V  |dk    r|
t          j        u rn|                    |
           |                    |
j                   t          |          dk    r| j
        }n| j        }|                    t          j        |j        j        g|j        R            }|dk    |                                |	|z   k     t"          rt#          d|z             t%          |          D ]\  }}
|                    ||
ddd            |V  d S )Nr   r_   r=   z@guessed %r container type (pass `asn1Spec` to guide the decoder)FverifyConstraints	matchTagsmatchConstraints)setrr   rV   rW   r   rK   appendaddr    r   protoRecordComponentprotoSequenceComponentr?   r   TagSetbaseTag	superTagsrq   	enumeratesetComponentByPosition)r   r   r    r#   r!   r%   r,   
componentscomponentTypesr~   rv   r3   r   s                r&   _decodeComponentsSchemalessz9ConstructedPayloadDecoderBase._decodeComponentsSchemaless  s      

%NN,,llinn..1BV1KKK&Yy<<G<< $ $	i)?@@ $#OOO||	S_ < <i(((y/000 >""Q&&!%!: "&!<'-- z."7"?S&BRSSS .  J+ llinn..1BV1KKK6  	) '( ) ) ) (
33 	 	NC--Y"'% .     r(   c              +   @  K   |d         j         t          j        k    rt          j        d          |                                }	|r_||                                }
n1| j        | j                            |          }
n| j        | j	        f}
 ||
|||          D ]}|V  d S | | j
        |f|||d|D ]}
t          |
t                    r|
V  |                                |	|z   k     rgt          r`t          ||          D ]}t          |t                    r|V  t          dt          |          t!          j        |          fz             |
V  d S |                                }
|
                                 |                     |
|          }|j        t*          j        j        t*          j        j        fv r6|j        }|j        t*          j        j        k    }| o|j         }t          r"t          d| rdpd	d
|rdpd	d|d           t5                      }d}|                                |	z
  |k     rO|sd }n~|r|j        }nt	 |r||         j        }n=||         j        s||         j        r|                    |          }n||         j        }n%# t@          $ r t          j        d|          w xY w |||fi |D ]}t          |t                    r|V  |sT|rR|r|!                    |j"                  }n5||         j        s||         j        r|#                    |j"        |          }|
$                    ||ddd           |%                    |           |dz  }|                                |	z
  |k     Ot          rt          d|z             |r|j&        '                    |          s!t          j        d|
j(        j)        z            |j*        r|+                    di           }t          r=t          d           |,                                D ]\  }}t          |d|           |s|+                    dd          rgt[          |j.                  D ]Q\  }}|j/        s|j        r|
0                    |          j1        s0|
2                    |j/        j3                  }	 ||         }n# th          $ r t          rrt          d|
j(        j)        d|j3        d|
j(        j)        d|j/        j3        d	           |j/        ,                                D ]\  }}t          |d|           	 |j/        |         }n+# th          $ r t          rt          d|           Y Y w xY wY nw xY wt          rt          d|d|           |
0                    |          }|j        t*          j5        j        t*          j6        j        fv rjt[          |          D ]X\  }}to          ||         8                                          } ||fd|i|D ]}t          |t                    r|V  |||<   Yto          |
0                    |          8                                          } ||fd|i|D ]}t          |t                    r|V  |
$                    ||           Sn|
j9        }|r"t          j        d |
j(        j)         d!          n|j        }t          rt          d"|z             d}|                                |	z
  |k     r` |||fi |D ]}t          |t                    r|V  |
$                    ||ddd           |dz  }|                                |	z
  |k     `|
V  d S )#Nr   Constructed tag format expectedr=   r    r#   r!   )contextz)Unused trailing %d octets encountered: %s	decoding non-rF   deterministic SET type  chosen by type ID Excessive components decoded at Fr   r_   seen component indices %s,ASN.1 object %s has uninitialized components	openTypesuser-specified open types map: -> decodeOpenTypes%default open types map of component "." governed by component "":/failed to resolve open type by governing value resolved open type  by governing value r   ASN.1 object  is inconsistent+decoding type %r chosen by given `asn1Spec`):rT   r   tagFormatConstructedr   r   rr   r?   r3   r   r   r   rV   rW   rq   r
   r   r   hexdumpclearr.   typeIdr   SequenceSetcomponentTypehasOptionalOrDefaultr   tagMapUniquer,   
isOptionalisDefaultedgetTagMapNearPosition
IndexErrorgetPositionByTypeeffectiveTagSetgetPositionNearTyper   r   requiredComponentsissubsetrp   r0   hasOpenTypesr>   itemsr   
namedTypesopenTypegetComponentByPositionisValuegetComponentByNamenameKeyErrorSetOf
SequenceOfr   asOctetsisInconsistent)r   r   r   r    r!   r"   r#   r$   r%   r~   r,   r9   trailingr  	isSetTypeisDeterministicseenIndicesr   r   rv   r   kv	namedTypegoverningValuer  containerValueposcontainerElementstreaminconsistencys                                  r&   r'   z*ConstructedPayloadDecoderBase.valueDecoder  s
      !9#":::#$EFFF%NN,, 	#%^^--

$0!066f6EE

 "68SS
%j)VWMM  F>d>.&,	!. .%,. . % %
 j*@AA %$$$$~~"3f"<<< A$29g$N$N$N + +%h0FGG +"*NNNCHu}X'>'>G@ @ A A A F^^%%
&&z7;;?t}3TX_EEE!/J 48?:I"+mSJ4S0SO ''2F8b88):M:SQS:S:SHH    %%KC..""%66??! $(MM $.$;MM* G,6sO,FMM'_7 G:c?;V G,6,L,LS,Q,QMM -7sO,FM%   #//DLHN  
 "+9m!O!Ow!O!O ( (I!)-CDD ('& ]: ]  ](::9;TUU#C3 ]z#7R ](<<Y=VX[\\11&+#e 2    $$$qS ..""%66??V  ?/+=>>> WY!4==kJJ F+%'1';'DEF F F + KR 'K < <I 5<===$-OO$5$5 5 5DAqaaa 34444  ARGKK0A5$I$I AR.7
8M.N.N ?R ?RNC#,#5 ) ((3 )J<]<]^a<b<b<j ) (-7-J-J ) 2 7. .N-+4^+D#+ - - -#& 	!A$'C/9/C/L/L/L/8~~~/9/C/L/L/L/8/A/F/F/F)H %I %I %I 1:0B0H0H0J0J %A %A1(+!!!QQ,?(@(@(@(@!-/8/A./QHH'/ !- !- !-'* %L(+:H.-K )L )L )L$,HH	!- %-H-,  # M #2:((NN%L !M !M !M .8-N-Ns-S-SN-4$(J$5t7M9O  O  O >G(6>8 >8 	!D 	!D$9C)9 .>nS>Q>Z>Z>\>\-]-]F5>Yv5d5dPX5d\c5d5d %< %<	+5iAW+X+X )<2;OOO:CN3$7$7	!D *:*:[:[\_:`:`:i:i:k:k)l)l1:61`1`H1`X_1`1` !8 !8I'1)=S'T'T %8.7 * A A#y Q Q Q Q !+ 9  Y+W
(<(EWWWY Y YY
 %2M SAMQRRRC..""%66??!*9m!O!Ow!O!O ( (I!)-CDD ('11&+#e 2    q ..""%66?? sD   AJ& &"KSBVU('V(#VVVVVc              +     K   |d         j         t          j        k    rt          j        d          |_||                                }	n1| j        | j                            |          }	n| j        | j        f}	 ||	|||          D ]}
|
V  d S |C | j	        |f|||dt          |d          D ]}	t          |	t                    r|	V  |	V  d S |                                }	|	                                 |                     |	|          }|j        t           j        j        t           j        j        fv rq|	j        }|	j        t           j        j        k    }| o|j         }t*          r"t+          d| rdpd	d
|rdpd	d|d           t-                      }d}	 t/          |          |k    rd }n~|r|j        }nt	 |r||         j        }n=||         j        s||         j        r|                    |          }n||         j        }n%# t:          $ r t          j        d|	          w xY w |||fddi|D ]+}t          |t                    r|V  |t<          j        u r n,|t<          j        u rn|sT|rR|r|                     |j!                  }n5||         j        s||         j        r|"                    |j!        |          }|	#                    ||ddd           |$                    |           |dz  }gt*          rt+          d|z             |r|j%        &                    |          s!t          j        d|	j'        j(        z            |j)        r|*                    di           }t*          r=t+          d           |+                                D ]\  }}t+          |d|           |s|*                    dd          rtY          |j-                  D ]\  }}|j.        s|j        r|	/                    |          j0        s0|	1                    |j.        j2                  }	 ||         }n# tf          $ r t*          rrt+          d|	j'        j(        d|j2        d|	j'        j(        d|j.        j2        d	           |j.        +                                D ]\  }}t+          |d|           	 |j.        |         }n+# tf          $ r t*          rt+          d|           Y Y w xY wY nw xY wt*          rt+          d|d|           |	/                    |          }|j        t           j4        j        t           j5        j        fv rtY          |          D ]w\  }}tm          ||         7                                          } ||fd |it          |d          D ]+}t          |t                    r|V  |t<          j        u r n,|||<   xtm          |	/                    |          7                                          } ||fd |it          |d          D ]A}t          |t                    r|V  |t<          j        u r n|	#                    ||           Bn|	j8        }|r"t          j        d!|	j'        j(         d"          n|j        }t*          rt+          d#|z             d}	  |||fddi|D ]+}t          |t                    r|V  |t<          j        u r n,|t<          j        u rn |	#                    ||ddd           |dz  }g|	V  d S )$Nr   r   r=   r   TrJ   r   r   rF   r   r   r   r   r   rJ   Fr   r_   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )9rT   r   r   r   r   r?   r3   r   r   r   dictrV   rW   r   r.   r   r   r   r   r   r   rq   r   r   r   r,   r   r   r   r   r   rK   r   r   r   r   r   r   r   rp   r0   r   r>   r  r   r  r  r  r  r  r  r  r	  r
  r   r  r  )r   r   r   r    r!   r"   r#   r$   r%   r,   r9   r  r  r  r  r   rv   r   r  r  r  r  r  r  r  r  r  r  r   s                                r&   r*   z2ConstructedPayloadDecoderBase.indefLenValueDecoder  s	      !9#":::#$EFFF##%^^--

$0!066f6EE

 "68SS
%j)VWMM  F>d>C&,	!C C%)'D%A%A%AC C % %
 j*@AA %$$$$F^^%%
&&z7;;?t}3TX_EEE#1J")TX_<I"+mSJ4S0SO ''2F8b88):M:SQS:S:SHH    %%KC0z??c))#HH )6HH* B'1#'AHH'_7 B:c?;V B'1'G'G'L'LHH (2#'AH%   #//DNJP  
 "+9h!Y!Y!YQX!Y!Y  I!)-CDD (' CO33 4 //& ]: ]  ](::9;TUU#C3 ]z#7R ](<<Y=VX[\\11&+#e 2    $$$qa0d  ?/+=>>> ^]!4==kJJ F+%'1';'DEF F F * X] 'K < <I 5<===$-OO$5$5 5 5DAqaaa 34444  HVGKK0A5$I$I HV.7
8M.N.N FV FVNC#,#5 ) ((3 )J<]<]^a<b<b<j ) (-7-J-J ) 2 7. .N-+4^+D#+ - - -#& 	!A$'C/9/C/L/L/L/8~~~/9/C/L/L/L/8/A/F/F/F)H %I %I %I 1:0B0H0H0J0J %A %A1(+!!!QQ,?(@(@(@(@!-/8/A./QHH'/ !- !- !-'* %L(+:H.-K )L )L )L$,HH	!- %-H-,  # M #2:((NN%L !M !M !M .8-N-Ns-S-SN-4$(J$5t7M9O  O  O >G(6>8 >8 !D !D$9C)9 .>nS>Q>Z>Z>\>\-]-]F5>Yv 6_ 6_PX 6_AEgX\A]A]A]6_ 6_ %2 %2	+5iAW+X+X )<2;OOO+4+G+G,1E ,H ;DN3$7$7!D  *:*:[:[\_:`:`:i:i:k:k)l)l1:6 2[ 2[H 2[=A'TX=Y=Y=Y2[ 2[ !V !VI'1)=S'T'T %8.7'0CO'C'C(-$.$E$Ec9$U$U$U$U %/$=M$ ]#/[J,@,I[[[] ] ] %2M SAMQRRRC!*!="L "L;?"LCJ"L "L  I ")-CDD (' CO33 4 //11&+#e 2    q), sD   AH "H7QBTST#TTTTT)NNNr/   )
r0   r1   r2   r   r   r   r   r   r'   r*   r-   r(   r&   r   r     s        !" " "" " " 591 1 1 1h 6:26[ [ [ [| >B:>i i i i i ir(   r   c                   J    e Zd Z ej                    Z ej                    ZdS )"SequenceOrSequenceOfPayloadDecoderN)r0   r1   r2   r   r   r   r
  r   r-   r(   r&   r  r    s.        (4=??,T_..r(   r  c                   ,    e Zd Z ej                    ZdS )SequencePayloadDecoderN)r0   r1   r2   r   r   r3   r-   r(   r&   r   r     s        "T]__NNNr(   r   c                   ,    e Zd Z ej                    ZdS )SequenceOfPayloadDecoderN)r0   r1   r2   r   r
  r3   r-   r(   r&   r"  r"            $T_&&NNNr(   r"  c                   J    e Zd Z ej                    Z ej                    ZdS )SetOrSetOfPayloadDecoderN)r0   r1   r2   r   r   r   r	  r   r-   r(   r&   r%  r%    s,        #48::'TZ\\r(   r%  c                   ,    e Zd Z ej                    ZdS )SetPayloadDecoderN)r0   r1   r2   r   r   r3   r-   r(   r&   r'  r'    s        TXZZNNNr(   r'  c                   ,    e Zd Z ej                    ZdS )SetOfPayloadDecoderN)r0   r1   r2   r   r	  r3   r-   r(   r&   r)  r)    s        TZ\\NNNr(   r)  c                   D    e Zd Z ej                    Z	 	 ddZ	 	 ddZdS )ChoicePayloadDecoderNc              +     K   || j                             |          }	n|                                }	|r ||	|||          D ]}
|
V  d S |                     |	|          }|	j        |k    rFt          rt	          d|d            |||	j        fi |D ]}t          |t                    r|V  nHt          rt	          d|d            |||	j        |||fi |D ]}t          |t                    r|V  |j        }t          rt	          d|d|           |		                    ||dddd           |	V  d S )	Nr=   r   z as explicitly tagged CHOICEz as untagged CHOICEdecoded component , effective tag set Fr   r   r   	innerFlag)
r3   r?   r.   r    rq   componentTagMaprV   rW   r   setComponentByType)r   r   r   r    r!   r"   r#   r$   r%   r,   r9   rv   r   s                r&   r'   z!ChoicePayloadDecoder.valueDecoder  s      ,22&2AAJJ "))J 	%j)VWMM  F&&z7;;&& KIJJJ&Yz9F F=DF F $ $	i)?@@ $#OOO$  B@AAA&Yz966& &$& & $ $	 i)?@@ $#OOO#3 	]C			??[\\\%%Y#e	 	& 	
 	
 	
 r(   c           	   +     K   || j                             |          }	n|                                }	|r ||	|||          D ]}
|
V  d S |                     |	|          }|	j        |k    }t          rt	          d|d|rdpdd           	 |r$ |||	j        j        fi t          |d          }n& |||	j        j        |||fi t          |d          }|D ]m}t          |t                    r|V  |t          j        u r nC|j        }t          rt	          d	|d
|           |	                    ||dddd           |s nn|r|t          j        u rn|	V  d S )Nr=   r   z as zexplicitly unztagged CHOICETr  r-  r.  Fr/  )r3   r?   r.   r    rq   r   r   r  rV   rW   r   rK   r   r2  )r   r   r   r    r!   r"   r#   r$   r%   r,   r9   isTaggediteratorrv   r   s                  r&   r*   z)ChoicePayloadDecoder.indefLenValueDecoder  s@      ,22&2AAJJ "))J 	%j)VWMM  F&&z7;;$. 	=C2]:d::< = = =%	 K$9z7D4 47T2224 4
 %9z7DFEK K-1'D-I-I-IK K &  	i)?@@ $#OOO//E"+"; =C )		??< = = = --#Y&+#e#	 .      E  yCO;;K%	N r(   r/   )r0   r1   r2   r   Choicer3   r'   r*   r-   r(   r&   r+  r+    s[         T[]]N 6:261 1 1 1h >B:>? ? ? ? ? ?r(   r+  c                   D    e Zd Z ej                    Z	 	 ddZ	 	 ddZdS )AnyPayloadDecoderNc              +   r  K   |d}	n(|j         t          j        u r
||j        v}	n||j        k    }	|	r|j        }
|                                }|                    |
t          j	                   |||
z
  z  }t          rPt          ||          D ]}t          |t                    r|V  t          dt          j        |          z             |r* | | j        ||t"          fi ||||          D ]}|V  d S t%          |||          D ]}t          |t                    r|V   | j        |||fi |V  d S )NTz&decoding as untagged ANY, substrate %s)rp   r   TagMaptagMapr    markedPositionrr   seekosSEEK_SETrq   r   rV   rW   r   r   rC   r@   r
   )r   r   r   r    r!   r"   r#   r$   r%   
isUntaggedfullPositioncurrentPositionr9   s                r&   r'   zAnyPayloadDecoder.valueDecoder  s      JJ6=00x6JJ  8?2J 	1$3L'nn..ONN<555o44F 1+Iv>> $ $E!%)?@@ $#  =//0 1 1 1  	%)D)(FGOOwOOvw0 0   F#Ivw?? 	 	E%!788 #d#HfeGGwGGGGGGGr(   c              +   t  K   |d}	n(|j         t          j        u r
||j        v }	n||j        k    }	|	rd}
t
          rt          d           n|j        }|                                }|                    |t          j
                   t          |||z
  |          D ]}
t          |
t                    r|
V  t
          r$t          dt          j        |
          z             | j        }|rH|| j        ur? | j        ||t&          fi |} |||
|z   |t)          |
          z   |          D ]}
|
V  d S t
          rt          d           | j        }	  |||f|dd|D ]+}t          |t                    r|V  |t*          j        u r n,|t*          j        u rn|
|z  }
N|r|
V  d S  | j        |||
fi |V  d S )NFr(   zdecoding as tagged ANYz-decoding as untagged ANY, header substrate %sri   Trx   )rp   r   r;  r<  r    rq   r=  rr   r>  r?  r@  r
   rV   rW   r   r   r3   r:   rC   r@   r   r   rK   )r   r   r   r    r!   r"   r#   r$   r%   r5  r9   rB  rC  r,   rv   s                  r&   r*   z&AnyPayloadDecoder.indefLenValueDecoderC  s      HH6=000HH 0H 	\E .,--- %3L'nn..ONN<555'	?\3QSZ[[    e%;<<  KKK \CemTYFZFZZ[[[ & 	L0GGG..&'6 6-46 6J &	 16CJJ3FQ Q  F 	86777 .	&Yx.6B!. .%,. .  	 i)?@@ $#OOO//E 0 CO++YE	"  	LKKKKK ($'&%KK7KKKKKKKr(   r/   rL   r-   r(   r&   r9  r9    sk        TXZZN 6:26'H 'H 'H 'HT >B:>IL IL IL IL IL ILr(   r9  c                   ,    e Zd Z ej                    ZdS )UTF8StringPayloadDecoderN)r0   r1   r2   r   
UTF8Stringr3   r-   r(   r&   rF  rF    r#  r(   rF  c                   ,    e Zd Z ej                    ZdS )NumericStringPayloadDecoderN)r0   r1   r2   r   NumericStringr3   r-   r(   r&   rI  rI            'T'))NNNr(   rI  c                   ,    e Zd Z ej                    ZdS )PrintableStringPayloadDecoderN)r0   r1   r2   r   PrintableStringr3   r-   r(   r&   rM  rM            )T)++NNNr(   rM  c                   ,    e Zd Z ej                    ZdS )TeletexStringPayloadDecoderN)r0   r1   r2   r   TeletexStringr3   r-   r(   r&   rQ  rQ    rK  r(   rQ  c                   ,    e Zd Z ej                    ZdS )VideotexStringPayloadDecoderN)r0   r1   r2   r   VideotexStringr3   r-   r(   r&   rT  rT    s        (T(**NNNr(   rT  c                   ,    e Zd Z ej                    ZdS )IA5StringPayloadDecoderN)r0   r1   r2   r   	IA5Stringr3   r-   r(   r&   rW  rW            #T^%%NNNr(   rW  c                   ,    e Zd Z ej                    ZdS )GraphicStringPayloadDecoderN)r0   r1   r2   r   GraphicStringr3   r-   r(   r&   r[  r[    rK  r(   r[  c                   ,    e Zd Z ej                    ZdS )VisibleStringPayloadDecoderN)r0   r1   r2   r   VisibleStringr3   r-   r(   r&   r^  r^    rK  r(   r^  c                   ,    e Zd Z ej                    ZdS )GeneralStringPayloadDecoderN)r0   r1   r2   r   GeneralStringr3   r-   r(   r&   ra  ra    rK  r(   ra  c                   ,    e Zd Z ej                    ZdS )UniversalStringPayloadDecoderN)r0   r1   r2   r   UniversalStringr3   r-   r(   r&   rd  rd    rO  r(   rd  c                   ,    e Zd Z ej                    ZdS )BMPStringPayloadDecoderN)r0   r1   r2   r   	BMPStringr3   r-   r(   r&   rg  rg    rY  r(   rg  c                   ,    e Zd Z ej                    ZdS )ObjectDescriptorPayloadDecoderN)r0   r1   r2   r   ObjectDescriptorr3   r-   r(   r&   rj  rj    s        ,V,..NNNr(   rj  c                   ,    e Zd Z ej                    ZdS )GeneralizedTimePayloadDecoderN)r0   r1   r2   r   GeneralizedTimer3   r-   r(   r&   rm  rm    s        +V+--NNNr(   rm  c                   ,    e Zd Z ej                    ZdS )UTCTimePayloadDecoderN)r0   r1   r2   r   UTCTimer3   r-   r(   r&   rp  rp    s        #V^%%NNNr(   rp  c                     g | ]}|S r-   r-   ).0xs     r&   
<listcomp>ru    s    !!!!A!!!r(   r   )r   r   c                   R    e Zd ZeZ e            ZdZeZe	Z	e
e
fdZdddeddfdZdS )SingleItemDecoderTc                 ~    |t           ur|n| j        | _        |t           ur|n| j        | _        i | _        i | _        d S r8   )r   TAG_MAP_tagMapTYPE_MAP_typeMap	_tagCache_tagSetCache)r   r<  typeMapignoreds       r&   __init__zSingleItemDecoder.__init__  sG    !'x!7!7vvT\#*(#:#: r(   Nc              +   \  K   |                     dd          }	t          r t          dt          j        |||fz             |	r| j        r~t          |d|          D ]}
t          |
t                    r|
V  |
t          k    r&t          rt          d           t          j
        V  d S |                    dt          j                   | j        }| j        }| j        }| j        }t$          }|                                |_        |t*          urZ|t,          u rrd}t          |d|          D ]}t          |t                    r|V  t/          |          }	 ||         }n# t0          $ r |}|d	z  }|d
z  }|dz  }|dk    rrd}d}d}	 t          |d|          D ]}t          |t                    r|V  |st3          j        d          t/          |          }|dz  }|dz  }||dz  z  }|dz  snkt5          j        |||          }|r|||<   Y nw xY w|L|r4	 ||         }nE# t0          $ r t5          j        d|          }|||<   Y nw xY wt5          j        d|          }n||z   }t:          }t          rt          d|z             |t:          u r"t          |d|          D ]}t          |t                    r|V  t/          |          }|dk     r|}n|dk    r|dz  }t          |||          D ]}t          |t                    r|V  t=          |          }t?          |          |k    r)t3          j        |dt?          |          d|          d}|D ]}|dz  }||z  }|dz  }nd}|dk    r| j        st3          j         d          tB          }t          rt          d|z             |tB          u r|tD          }ntF          }|tD          u r	 ||         }n# t0          $ r d }Y nw xY w|rtH          }n5	 ||d d                  }n# t0          $ r d }Y nw xY w|rtH          }ntJ          }t          rbt          d|r|j&        j'        pdd|tH          u rdpd           t          j        (                    |d u rdp|j)        j&        j'                   |tF          u rf|j&        tT          j+        u r	 ||         }n# t0          $ r d }Y nw xY wt          rt          d            |j,        -                                D ]$\  }}t          d!|d"|j&        j'                   %|j.        rMt          d#           |j.        -                                D ]$\  }}t          d!|d"|j&        j'                   %t          d$|d u rdp|/                                d%|           n<||j0        k    s	||j1        v r&|}t          rt          d&|j&        j'        z             nd }|	 ||j2                 }t          rt          d'|j2                   nn# t0          $ ra t5          j        |j0        j3        |j0        j3                  } 	 ||          }t          rt          d(|            n# t0          $ r d }Y nw xY wY nw xY w|r
|}tH          }ntJ          }n	d }tJ          }t          rdt          d|tH          u r|j&        j'        pdd)|tH          u rdpd           t          j        (                    |d u rdp|j&        j'                   |tH          u r]|4                    d*d          s|sd+ }|                                }!|dk    r6 |j5        ||||tB          | |fi |D ]}t          |t                    r|V  n |j6        ||||tB          | |fi |D ]}t          |t                    r|V  |                                |!z
  }"|s|"|k    rtA          d,|"d-|d.          |r|"|k    rtA          d,|"d/|d.          t          r[t          d|j&        j'        d0|j&        j'        d1t          |tn          j8                  r|9                                p|d2           t*          }n|tJ          u r|rE|d         j:        t4          j;        k    r*|d         j<        t4          j=        k    rt|          }tH          }n	d }| j?        }t          r.t          d|r|j&        j'        pdd3|tH          u rdpd4           |t          u r1| jA        }t          rt          d5|j&        j'        z             tH          }|t          u rt3          j         |d6|          |t*          uZt          r:t          j                                          t          d7t          j        z             |V  d S )8NrJ   FzWdecoder called at scope %s with state %d, working with up to %s octets of substrate: %sr   zend-of-octets sentinel foundTr_   r          r   z'Short octet stream on long tag decodingrd   r   r   )tagClassrT   tagIdr-   z$tag decoded into %s, decoding length<z at r   r   z6Indefinite length encoding not supported by this codeczvalue length decoded into %dzcodec z<none>z% chosen by a built-in type, decoding rB   zas explicit tag?z!candidate ASN.1 spec is a map of:z  r   zbut neither of: znew candidate ASN.1 spec is z, chosen by zcandidate ASN.1 spec is %sz6value decoder chosen for an ambiguous type by type ID zvalue decoder chosen by base z  chosen by ASN.1 spec, decoding recursiveFlagc              3      K   | 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_optionss       r&   r$   z0SingleItemDecoder.__call__.<locals>.substrateFun%  s       )(((((r(   zRead z bytes instead of expected r   z bytes are more than expected z yields type z	, value:
z
...z chosen, decoding z
as failurezcodec %s chosen, decoding valuez not in asn1Spec: z%decoder left scope %s, call completed)Cpoprq   r   scopesupportIndefLengthr
   rV   rW   EOO_SENTINELr   rK   r>  r?  SEEK_CURrz  r|  r}  r~  r@   rr   r=  stStopstDecodeTagrm   r  r   r   Tagr   stDecodeLengthlistr   r   stGetValueDecoderstGetValueDecoderByTagstGetValueDecoderByAsn1SpecstDecodeValuestTryAsExplicitTagrp   r0   pushr3   r   r;  presentTypesr  	skipTypesprettyPrintTyper    r<  r   r   r>   r*   r'   r   Asn1ItemprettyPrintrT   r   r  tagClassUniversalrawPayloadDecoderdefaultErrorStatestDumpRawValuedefaultRawDecoderstErrorCondition)#r   r   r   r    r!   r"   r#   r$   r%   rJ   eoo_candidater<  r  tagCachetagSetCacherB   
isShortTag	firstByte
firstOctetlastTag
integerTagr  rT   r  lengthOctetIdxintegerBytesizeencodedLengthlengthOctetconcreteDecoder
chosenSpecr  
baseTagSetr~   	bytesReads#                                      r&   __call__zSingleItemDecoder.__call__  s     
 ;;z511 	@ UFI>? @ @ @
  	0/ 	0!/	1g!F!F ( (m-CDD ('''',, 86777o%%% r2;///->'#,>>#3#3	 6!!##!
!/	1g!F!F ( (I!)-CDD (' ^^
&7&z2GG #7 #7 #7!+J)D0H *T 1I&-E}}%*
)* !&/=iG/T/T 6 6#-k;Q#R#R !6*5$5$5$5#. "&+&B$M'" '" !" *-[)9)9J*a/N!aKE!j4&78E#-#4 & %!&$ "g!)Ye  G " 7/6,G#7J >! 	9=%0%<FF' = = =%(ZG%<%<F6<K
333=
 "%B!8!8 %v-F& I>GHHH&&"0Aw"G"G ) )J!*.DEE )(((( __
##'FF#%%%,D)7	4)Q)Q 0 0%m5KLL 0"////$($7$7M =))T11#:-1TT3}3E3E3E3EvvN   F'4 . .1+-AIDD  FR<<(?<+,deee) A6?@@@)))#2EE 8E" ...+&,VnOO + + +&*OOO+ # 3)EE/*0*<# / / /*./ ' 3 - 2 {C_  NDapaz  bD  NP  HP  NP  NP  RW  [h  Rh  Rt  mt  RI  xI  RI  J  K  K  KK$$_%<%D%yHfHpHyzzz333%66*%-f%5

# * * *%)


*  
X?@@@-5-B-H-H-J-J S SMJC


AK<P<P QRRRR#- W 2333191C1I1I1K1K W W
A #JJJ@T@T$U V V V Vj\`N`Nmem  ONq{  rL  rL  rN  rN  ON  ON  PV  PV  W  X  X  Xx..&HO2K2K!)J X88;M;VVWWW "&J)3*1*2C*D sC^h^o^o qrrr# 3 3 3%(Z
0A0IJL]Le%f%f
3.4Z.@O" W #$U V V V' 3 3 3.2OOO33 ' 3#- - !3 '+O.E bCQ^H^  IFcrc|  dF  IR  JR  IR  IR  TY  ]j  Tj  Tv  ov  TK  zK  TK  L  M  M  MK$$Z4%7%?C%`:CWC`aaa%%{{?D99 ), )) ) ) %.NN$4$4!R<<!E!E%x"F,= ,"; "; 3:"; "; ( ( &e-CDD ("'KKK( ">!=%x"F,= ,"; "; 3:"; "; ( ( &e-CDD ("'KKK ) 0 03D DI' ^I,?,?)kGPyyRXRXRXY[ [ [% ^)f*<*<)kJS))U[U[U[\^ ^ ^  [3&09995?;S;S;S!%77OE<M<M<O<OXSXXXZ [ [ [ *** 	3q	+s/GGGq	*c.CCC&7O)EE '+O 2E sC/:poNgNp:|t|:|:|  D  HU  U  a  Za  q  eq  q  r  s  s  s&&"&"8 `9O<U<^^___%((('06A  S	 6!!Z	  	GKOO7%+EFFFs   E B1HHH$ $$I
IO" "O10O1?P PP:S SS*+X 3Z
!Y,+Z,Y;8Z:Y;;Z Z)r0   r1   r2   r  r  r9  r  r  ry  r{  r   r  r  r  r-   r(   r&   rw  rw  	  s}        ())++GH&     ,0TdV V V V V Vr(   rw  c                   $    e Zd ZdZeZddZ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                 n     | j         di || _        t          |          | _        || _        || _        d S )Nr-   )SINGLE_ITEM_DECODER_singleItemDecoderr   r  	_asn1Specr  )r   r   r   r%   s       r&   r  zStreamingDecoder.__init__  s>    ":$":"E"EW"E"E*955!r(   c              #      K   	  | j         | j        | j        fi | j        D ]}|V  t	          | j                  D ]}t          |t                    rd V   |rd S Zr8   )r  r  r  r  r   rV   rW   )r   r,   r9   s      r&   __iter__zStreamingDecoder.__iter__  s      	5d5OT^F F7;}F F ! !
     &t77  e%;<< EEE 	r(   r8   )r0   r1   r2   __doc__rw  r  r  r  r-   r(   r&   r   r   t  sL        H HT ,           r(   r   c                   D    e Zd ZdZeZedd            Zed             Z	dS )r   znCreate a BER decoder object.

    Parse BER/CER/DER octet-stream into one, possibly nested, ASN.1 object.
    Nc                 B   t          |          }d|v r|d         dfd	}||d<    | j        ||fi |}|D ]e}t          |t                    rt	          j        d          	 t          t          |                    }n# t          j        $ r d}Y nw xY w||fc 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      K   	  | |||          }n]# t           $ rP}|j        j        r t          |t          j                  sJ t                              | ||          }Y d}~nd}~ww xY w|D ]}|V  d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_nextrV   ioBytesIOr   _callSubstrateFunV4asV5)r,   r   r!   r%   substrate_gen_valuerB   origSubstrateFuns          r&   substrateFunWrapperz-Decoder.__call__.<locals>.substrateFunWrapper3  s      u$4$4ZFT[$\$\MM  u u u+3 %i<<<<<$+$C$CDTV`bkms$t$tMMMMMMu +    EKKKK   s    
A.AA))A.zShort substrate on inputr(   r8   )r   STREAMING_DECODERrV   rW   r   nextr
   EndOfStreamError)	clsr   r   r%   r  streamingDecoderr,   tailr  s	           @r&   r  zDecoder.__call__  s   ` %Y//	W$$&~6           & ':GN#030x, ,#*, , + 
	$ 
	$J*&<== O23MNNNN95566)    t####
	$ 
	$s   %BBBc              #     K   |                                 }|dk    rt          |          } | |||          \  }}|                    |          }|                                 |                    | t
          j                   |V  d S )Nr   )readr   writetruncater>  r?  r  )substrateFunV4r,   r   r!   substrate_bytesrB   nextSubstratenbytess           r&   r  zDecoder._callSubstrateFunV4asV5W  s      #..**R<<))F-~j/6RR}//w,,,r(   r8   )
r0   r1   r2   r  r   r  classmethodr  r4   r  r-   r(   r&   r   r     sd          )v$ v$ v$ [v$p   \  r(   r   attrc                     ddd                     |           x}r4t          j        |  d| dt                     t	                      |         S t          |           )Nry  r{  )r<  r  z is deprecated. Please use z	 instead.)r>   warningswarnDeprecationWarningglobalsAttributeError)r  newAttrs     r&   __getattr__r    sf    &:>>BB4HHHw "LL'LLLN`aaayy!!


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__registerLoggeer0   DEBUG_DECODERrq   r@   rW   r   objectr   r6   rE   r  rO   r]   rb   r{   r   r   r   r   r   r   r  r   r"  r%  r'  r)  r+  r9  rF  rI  rM  rQ  rT  rW  r[  r^  ra  rd  rg  rj  rm  rp  r[   r    r`   ry   r   r   r   r   
Enumeratedr   r   r   r7  rG  rJ  rN  rR  rU  rX  r\  r_  rb  re  rh  rk  rn  rq  ry  r   r	  r
  rM   r{  valuestypeDecoderr3   rp   ranger  r  r  r  r  r  r  r  r  r  rZ   r  rw  r   r   r   strr  r-   r(   r&   <module>r     s^   
			 				 



                          3 3 3 3 3 3 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 " " " " " " $ $ $ $ $ $                                    
3
3
3e85+>???
,5  #%     V   >) ) ) ) )#9 ) ) )"& & & & &4 & & &R &%'' H H H H H8 H H H0A A A A A1 A A A@L @L @L @L @L: @L @L @LFSI SI SI SI SI < SI SI SIl    5   .>F >F >F >F >F%A >F >F >FB4I 4I 4I 4I 4I < 4I 4I 4InkH kH kH kH kH5 kH kH kH\    (>   C C C C C$E C C CL/ / / / /)F / / /
% % % % %? % % %' ' ' ' 'A ' ' '* * * * *< * * *
         0      " " " " "2 " " "u u u u u8 u u upuL uL uL uL uL4 uL uL uLr' ' ' ' '8 ' ' '* * * * *"; * * *, , , , ,$= , , ,* * * * *"; * * *+ + + + +#< + + +& & & & &7 & & &* * * * *"; * * ** * * * *"; * * ** * * * *"; * * *, , , , ,$= , , ,& & & & &7 & & &
/ / / / /%> / / /. . . . .$= . . .& & & & &5 & & &L..00L..00 	N2244 	6688	
 	I((** 	 "@"@"B"B 	6688 	O1133 	I((** 	M<<>> 	HO--// 	K,,.. 	O4466 	::<<  	!>!>!@!@!" 	::<<#$ 	 < < > >%& 	N2244::<<::<<::<<!>!>!@!@N2244
"$B$B$D$D
!#@#@#B#B
N00229 B 	HO&&((J**,,M0022O4466K,,..HO&&(( >>## + +K!-+5<&"8"8*HV "!uuRyy!!!		 uV}}h h h h h h h hV` ` ` ` `v ` ` `FI I I I If I I ID 
c      r(   