
    <OOf5                       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mZmZ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jD                        Z#ejH                  Z$ejJ                  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(      Z0 G d' d(e(      Z1 G d) d*e(      Z2 G d+ d,e'      Z3 G d- d.e3      Z4 G d/ d0e4      Z5 G d1 d2e5      Z6 G d3 d4e5      Z7 G d5 d6e4      Z8 G d7 d8e8      Z9 G d9 d:e8      Z: G d; d<e4      Z; G d= d>e(      Z< G d? d@e.      Z= G dA dBe.      Z> G dC dDe.      Z? G dE dFe.      Z@ G dG dHe.      ZA G dI dJe.      ZB G dK dLe.      ZC G dM dNe.      ZD G dO dPe.      ZE G dQ dRe.      ZF G dS dTe.      ZG G dU dVe.      ZH G dW dXe.      ZI G dY dZe.      ZJi ej                  j                   e+       ej                  j                   e,       ej                  j                   e-       ej                  j                   e.       ej                  j                   e/       ej                  j                   e0       ej                  j                   e1       ej                  j                   e+       ej                  j                   e2       ej                  j                   e5       ej                  j                   e8       ej                  j                   e;       ej                  j                   e=       ej                  j                   e>       ej                  j                   e?       ej                  j                   e@       ej                  j                   eA       ej                  j                   eB       ej                  j                   eC       ej                  j                   eD       ej                  j                   eE       ej                  j                   eF       ej                  j                   eG       ej                  j                   eH       ej                  j                   eI       ej                  j                   eJ       i	Zfej                  j                   e9       ej                  j                   e:       ej                  j                   e6       ej                  j                   e7       ej                  j                   e;       ej                  j                   e<       iZkefZlekZmefj                         D ]<  Zoeoj                  eoj                  j                  j                  Zgeg3egekvs8eoekeg<   >  erd[      D  cg c]  } |  c} \
  ZsZtZuZvZwZxZyZzZ{Z| ed\      Z} G d] d^e&      Z~ G d_ d`e&      Z G da dbe&      Z e       Zyc c} w )c    N)debug)error)eoo)asSeekableStream)isEndOfStream)peekIntoStreamreadFromStream)_MISSING)
from_bytes)oct2int	octs2ints	ints2octsnull)PyAsn1Error)base)char)tag)tagmap)univ)useful)StreamingDecoderDecoderdecode)flagsc                   8    e Zd ZdZ	 	 ddZ	 	 ddZed        Zy)AbstractPayloadDecoderNc                 2    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	            Y/var/www/premiumrankchecker/venv/lib/python3.12/site-packages/pyasn1/codec/ber/decoder.pyvalueDecoderz#AbstractPayloadDecoder.valueDecoder*   s     f VWW    c                 2    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.indefLenValueDecoder4   s     [a cddr,   c                     d|vr| |d<   |S )N
asn1Object )r0   r)   s     r*   _passAsn1Objectz&AbstractPayloadDecoder._passAsn1Object>   s    w&$.GL!r,   NNNNN)__name__
__module____qualname__protoComponentr+   r.   staticmethodr2   r1   r,   r*   r   r   '   s8    N 6:26X >B:>e  r,   r   c                   "    e Zd Zed        Zd Zy)AbstractSimplePayloadDecoderc              #   8   K   t        |||      D ]  }|  y wNr	   )r0   r"   r%   r)   chunks        r*   substrateCollectorz/AbstractSimplePayloadDecoder.substrateCollectorG   s#     #Ivw? 	EK	s   c                     |j                  d      r|S || j                  j                  ||      S |t        u r|S |j                  |      S )Nnativer$   )getr7   clonenoValuer!   r#   r$   valuer)   s        r*   _createComponentz-AbstractSimplePayloadDecoder._createComponentL   sQ    ;;x L&&,,U6,BBgO>>%((r,   N)r4   r5   r6   r8   r>   rG   r1   r,   r*   r:   r:   F   s     )r,   r:   c                   H    e Zd Z ej                  d      Z	 	 ddZ	 	 ddZy)RawPayloadDecoder Nc              +      K   |r* | j                   ||dfi |}	 ||	|||      D ]  }
|
  y  |||||fi |D ]  }|  y w)NrJ   )rG   r!   r"   r#   r$   r%   r&   r'   r(   r)   r0   r=   rF   s               r*   r+   zRawPayloadDecoder.valueDecoderZ   sn      ...xOwOJ%j)VWM  y(FFNgN 	EK	s   AAc              +      K   |r* | j                   ||dfi |}	 ||	|||      D ]  }
|
  y 	  |||||fddi|D ]  }|t        j                  u r y |  ,w)NrJ   TallowEoo)rG   r   endOfOctetsrL   s               r*   r.   z&RawPayloadDecoder.indefLenValueDecoderi   s      ...xOwOJ%j)VWM  "x.!.%,.  COO+ s   AAr3   r4   r5   r6   r   Anyr7   r+   r.   r1   r,   r*   rI   rI   W   s,    TXXb\N 6:26  >B:>r,   rI   c                   <    e Zd Z ej                  d      Z	 	 ddZy)IntegerPayloadDecoderr   Nc              +     K   |d   j                   t        j                  k7  rt        j                  d      t        |||      D ]  }	t        |	t              s|	  	rt        |	d      }
nd}
 | j                  |||
fi | y w)Nr   Simple tag format expectedT)signed)
	tagFormatr   tagFormatSimpler   r   r
   
isinstanceSubstrateUnderrunErrorr   rG   )r!   r"   r#   r$   r%   r&   r'   r(   r)   r=   rF   s              r*   r+   z"IntegerPayloadDecoder.valueDecoder   s     
 !9#"5"55##$@AA#Ivw? 	E%!78	 uT2E E#d##HfeGwGGs   AB	0B	r3   )r4   r5   r6   r   Integerr7   r+   r1   r,   r*   rS   rS      s    !T\\!_N 6:26Hr,   rS   c                   6    e Zd Z ej                  d      Zd Zy)BooleanPayloadDecoderr   c                 D    t        j                  | |||xr dxs dfi |S )N   r   )rS   rG   rE   s        r*   rG   z&BooleanPayloadDecoder._createComponent   s2    $55(FEKa$41A8?A 	Ar,   N)r4   r5   r6   r   Booleanr7   rG   r1   r,   r*   r]   r]      s    !T\\!_NAr,   r]   c                   L    e Zd Z ej                  d      ZdZ	 	 ddZ	 	 ddZy)BitStringPayloadDecoderr1   TNc              +   >  K   |r. | j                   ||t        fi |}	 ||	|||      D ]  }
|
  y |st        j                  d      t	        |      D ]  }
t        |
t              s|
  
rt        j                  d      |d   j                  t        j                  k(  rt        |d|      D ]  }t        |t              s|  t              }|dkD  rt        j                  d|z        t        ||dz
  |      D ]  }
t        |
t              s|
  | j                  j                  |
d|      } | j                   |||fi | y | j                  s,t        j                  d| j                  j                   z        t"        rt#        d	       | j$                  }| j                  j                  t&        d
      }|j)                         }|j)                         |z
  |k  r ||| j                  fd|i|D ]  }t        |t              s|  t+        d         }|dkD  rt        j                  d|z        | j                  j                  |dd  d||      }|j)                         |z
  |k  r | j                   |||fi | y w)NzEmpty BIT STRING substrater   r_      Trailing bits overflow %sT)internalFormatpadding*Constructed encoding form prohibited at %s$assembling constructed serializationrf   r(   rf   prependrg   )rG   rD   r   r   r   rY   rZ   rW   r   rX   r
   ordr7   fromOctetStringsupportConstructedForm	__class__r4   LOGr>   r   tellr   )r!   r"   r#   r$   r%   r&   r'   r(   r)   r0   r=   trailingBitsrF   	bitStringcurrent_position	components                   r*   r+   z$BitStringPayloadDecoder.valueDecoder   s    
 ...xTGTJ%j)VWM  ##$@AA"9- 	E%!78	 ##$@AA!9#"5"55 .y!W E 'l,BC&&' |,La''/,>  (	6A:wG  e%;<K  ''77dL 8 BE ($''&%K7KK**## %,.2nn.E.E%F G G 67 ..''77T7R	$>>+nn!11F:&t22AM $	 i)?@#O	$ #9Q<0La''/,>  ++;;!"d!< < I nn!11F:$ $d##HfiK7KKs(   A&J)AJAJDJA)JJc              +   B  K   |r. | j                   ||t        fi |}	 ||	|||      D ]  }
|
  y | j                  }| j                  j	                  t
        d      }	  ||| j                  f|dd|D ]+  }|t        j                  u r nt        |t              s(| - t        j                  u rnNt        |d         }|dkD  rt        j                  d|z        | j                  j	                  |dd  d||      } | j                   |||fi | y w)	NTrj   r(   rN   r   rd   re   r_   rk   )rG   rD   r>   r7   rn   r   r   rO   rY   rZ   r   r   r   )r!   r"   r#   r$   r%   r&   r'   r(   r)   r0   r=   rt   rv   rs   s                 r*   r.   z,BitStringPayloadDecoder.indefLenValueDecoder   sZ    
 ...xTGTJ%j)VWM   ..''77T7R	&t22.AM!.%,. $	 /i)?@#O$ COO+"9Q<0La''/,>  ++;;!"d!< < I+ 4 $d##HfiK7KKs   BD A?Dr3   )	r4   r5   r6   r   	BitStringr7   ro   r+   r.   r1   r,   r*   rb   rb      s7    #T^^B'N! 6:26NLb >B:>,Lr,   rb   c                   L    e Zd Z ej                  d      ZdZ	 	 ddZ	 	 ddZy)OctetStringPayloadDecoderrJ   TNc              +     K   |r. | j                   ||t        fi |}	 ||	|||      D ]  }
|
  y |d   j                  t        j                  k(  r?t        |||      D ]  }
t        |
t              s|
   | j                   ||
fi | y | j                  s,t        j                  d| j                  j                  z        t        rt        d       | j                  }t        }|j!                         }|j!                         |z
  |k  rL ||| j"                  fd|i|D ]  }t        |t              s|  |z  }|j!                         |z
  |k  rL | j                   |||fi | y w)Nr   rh   ri   r(   )rG   rD   rW   r   rX   r
   rY   rZ   ro   r   r   rp   r4   rq   r>   r   rr   r7   )r!   r"   r#   r$   r%   r&   r'   r(   r)   r0   r=   headeroriginal_positionrv   s                 r*   r+   z&OctetStringPayloadDecoder.valueDecoder*  s     ...xTGTJ%j)VWM  !9#"5"55'	67C  e%;<K  ($''&%K7KK**##$PSWSaSaSjSj$jkk67 ..%NN,nn!22V;&t22AM $	 i)?@#O	$ iF nn!22V; $d##HffHHHs   A1E74CE7=!E7E7c              +     K   |r<|| j                   ur. | j                  ||t        fi |}	 ||	|||      D ]  }
|
  y | j                   }t        }	  ||| j                  f|dd|D ]*  }t        |t              r| |t        j                  u s* n t        j                  u rn||z  }] | j                  |||fi | y w)NTrx   )	r>   rG   rD   r   r7   rY   rZ   r   rO   )r!   r"   r#   r$   r%   r&   r'   r(   r)   r0   r=   r}   rv   s                r*   r.   z.OctetStringPayloadDecoder.indefLenValueDecoderW  s      L0G0GG...xTGTJ%j)VWM   ..&t22.AM!.%,. 	 i)?@#O/ COO+iF " $d##HffHHHs   BC	4C	r3   )	r4   r5   r6   r   OctetStringr7   ro   r+   r.   r1   r,   r*   r{   r{   &  s8    %T%%b)N! 6:26+I\ >B:>"Ir,   r{   c                   <    e Zd Z ej                  d      Z	 	 ddZy)NullPayloadDecoderrJ   Nc              +   *  K   |d   j                   t        j                  k7  rt        j                  d      t        |||      D ]  }	t        |	t              s|	   | j                  ||dfi |}
	rt        j                  d|z        |
 y w)Nr   rU   rJ   z&Unexpected %d-octet substrate for Null)	rW   r   rX   r   r   r
   rY   rZ   rG   )r!   r"   r#   r$   r%   r&   r'   r(   r)   r=   rv   s              r*   r+   zNullPayloadDecoder.valueDecoder  s     
 !9#"5"55##$@AA#Ivw? 	E%!78	 *D))(FBJ'J	##$Lv$UVVs   AB:Br3   )r4   r5   r6   r   Nullr7   r+   r1   r,   r*   r   r   |  s    TYYr]N 6:26r,   r   c                   <    e Zd Z ej                  d      Z	 	 ddZy)ObjectIdentifierPayloadDecoderr1   Nc              +   J  K   |d   j                   t        j                  k7  rt        j                  d      t        |||      D ]  }	t        |	t              s|	  	st        j                  d      t        |	      }	d}
d}t        |	      }||k  r|	|   }|dz  }|dk  r|
|fz  }
nm|dkD  rN|}d}|dk\  r8|dz  |dz  z   }||k\  rt        j                  d	|
      |	|   }|dz  }|dk\  r8|
|dz  |z   fz  }
n|dk(  rt        j                  d
      ||k  rd|
d   cxk  rdk  r	n nd|
z   }
nVd|
d   cxk  rdk  rn nd|
d   dz
  f|
dd  z   }
n4|
d   dk\  rd|
d   dz
  f|
dd  z   }
nt        j                  d|	d   z         | j                  |||
fi | y w)Nr   rU   Empty substrater1   r_      rd      !Short substrate for sub-OID past z"Invalid octet 0x80 in OID encoding'   )r   (   O   P      zMalformed first OID octet: %srW   r   rX   r   r   r
   rY   rZ   r   lenrG   )r!   r"   r#   r$   r%   r&   r'   r(   r)   r=   oidindexsubstrateLensubId	nextSubIds                  r*   r+   z+ObjectIdentifierPayloadDecoder.valueDecoder  s     !9#"5"55##$@AA#Ivw? 	E%!78	 ##$566% 5zl"%LEQJEs{x!	3&"aZI,<=E,#::EHJ  !&eIQJE  3& !y022#
 ''(LMM/ l"4 A"*C3q6Rc!frk"SW,CVr\c!frk"SW,C##$CeAh$NOO#d##HfcEWEEs   AF#BF#1,F#BF#r3   )r4   r5   r6   r   ObjectIdentifierr7   r+   r1   r,   r*   r   r     s"    *T**2.N 6:266Fr,   r   c                   <    e Zd Z ej                  d      Z	 	 ddZy)RelativeOIDPayloadDecoderr1   Nc              +   p  K   |d   j                   t        j                  k7  rt        j                  d      t        |||      D ]  }	t        |	t              s|	  	st        j                  d      t        |	      }	d}
d}t        |	      }||k  r|	|   }|dz  }|dk  r|
|fz  }
nm|dkD  rN|}d}|dk\  r8|dz  |dz  z   }||k\  rt        j                  d	|
      |	|   }|dz  }|dk\  r8|
|dz  |z   fz  }
n|dk(  rt        j                  d
      ||k  r | j                  |||
fi | y w)Nr   rU   r   r1   r_   r   rd   r   r   z+Invalid octet 0x80 in RELATIVE-OID encodingr   )r!   r"   r#   r$   r%   r&   r'   r(   r)   r=   reloidr   r   r   r   s                  r*   r+   z&RelativeOIDPayloadDecoder.valueDecoder  s     !9#"5"55##$@AA#Ivw? 	E%!78	 ##$566% 5zl"%LEQJEs{5("!	3&"aZI,<=E,#::EKM  !&eIQJE  3& EQJ)355#
 ''(UVV/ l"2 $d##HffHHHs   AD6BD61,D6D6r3   )r4   r5   r6   r   RelativeOIDr7   r+   r1   r,   r*   r   r     s"    %T%%b)N 6:26,Ir,   r   c                   :    e Zd Z ej                         Z	 	 ddZy)RealPayloadDecoderNc              +   \  K   |d   j                   t        j                  k7  rt        j                  d      t        |||      D ]  }	t        |	t              s|	  	s | j                  ||dfi | y t        |	d         }
|	dd  }	|
dz  r|	st        j                  d      t        rt        d       |
dz  dz   }|d	k(  rt        |	d         }|	dd  }	|	d | |	|d  }	}|r|	st        j                  d
      t        |d         dz  xr dxs d}|r|dz  }|t        |d         z  }|dd  }|r|
d	z	  dz  }|dkD  rt        j                  d      |dk(  r|dz  }n
|dk(  r|d	z  }d}|	r|dz  }|t        |	d         z  }|	dd  }	|	r|
dz  r| }|
dz	  dz  }|d|z  z  }|d|f}n|
dz  rt        rt        d       |
dz  xr dxs d}n|
dz  dk(  r|	st        j                  d      t        rt        d       	 |
dz  dk(  rt        |	      ddf}n@|
dz  dk(  rt        |	      }n,|
dz  dk(  rt        |	      }nt        j                  d|
z        nt        j                  d|
z         | j                  |||fi | y # t        $ r t        j                  d      w xY ww)Nr   rU   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))rW   r   rX   r   r   r
   rY   rZ   rG   r   rq   intfloat
ValueError)r!   r"   r#   r$   r%   r&   r'   r(   r)   r=   foneoebpsfrF   s                     r*   r+   zRealPayloadDecoder.valueDecoder  s,     !9#"5"55##$@AA#Ivw? 	E%!78	 '$''&#IIIU1Xab	9''(IJJ23daAAvE!H%ab	bq	59BU''(?@@1%,"1AaWRU^#V 
 a$A1u''(;<<AvQaQAaWU1X&&ab	 
 DyBq4BbLA1IE$Y,-I(&1EE$Y!^''(IJJ568s? ZQ/E#X_!%LE#X_!%LE  66-2  ..+b0  $d##HfeGwGG  22/ s4   AJ,CJ,6AJ,A2J,AJ
 1J,
J))J,r3   )r4   r5   r6   r   Realr7   r+   r1   r,   r*   r   r     s    TYY[N 6:26hHr,   r   c                       e Zd ZdZy)!AbstractConstructedPayloadDecoderN)r4   r5   r6   r7   r1   r,   r*   r   r   o  s    Nr,   r   c                   D    e Zd ZdZdZd Zd Z	 	 ddZ	 	 ddZ	 	 ddZ	y)	ConstructedPayloadDecoderBaseNc                     t               r<   NotImplementedError)r!   r0   idxs      r*   _getComponentTagMapz1ConstructedPayloadDecoderBase._getComponentTagMapw      !##r,   c                     t               r<   r   )r!   r0   r$   r   s       r*   _getComponentPositionByTypez9ConstructedPayloadDecoderBase._getComponentPositionByTypez  r   r,   c              +     K   d }g }t               }|j                         }	|dk(  s|j                         |	|z   k  r ||fi |D ]  }
t        |
t              s|
  |dk(  r
t        j
                  u rn|j                  
       |j                  |
j                         t        |      dkD  r| j                  }n| j                  }|j                  t        j                  |j                  j                  g|j                          }|dk(  r|j                         |	|z   k  rt"        rt#        d|z         t%        |      D ]  \  }}
|j'                  ||
ddd        | y w)Nr   r_   rA   z@guessed %r container type (pass `asn1Spec` to guide the decoder)FverifyConstraints	matchTagsmatchConstraints)setrr   rY   rZ   r   rO   appendaddr$   r   protoRecordComponentprotoSequenceComponentrC   r   TagSetbaseTag	superTagsrq   	enumeratesetComponentByPosition)r!   r"   r$   r'   r%   r)   r0   
componentscomponentTypesr~   rv   r7   r   s                r*   _decodeComponentsSchemalessz9ConstructedPayloadDecoderBase._decodeComponentsSchemaless}  s}     

%NN,linn.1BV1KK&y<G< $	i)?@#O$ |	S__ <i(y//0 >"Q&!%!:!: "&!<!<'-- zz."7"7"?"?S&BRBRS . J+ linn.1BV1KK6  '( ) (
3 	NC--Y"'% . 	 s   AE-B:E-E-+AE-c              +   <  K   |d   j                   t        j                  k7  rt        j                  d      |j                         }	|ri||j                         }
nA| j                  | j                  j                  |      }
n| j                  | j                  f}
 ||
|||      D ]  }|  y | | j                  |f|||d|D ]  }
t        |
t              s|
  |j                         |	|z   k  rYt        rSt        ||      D ]  }t        |t              s|  t        dt              t!        j"                  |      fz         
 y |j                         }
|
j%                          | j'                  |
|      }|j(                  t*        j,                  j(                  t*        j.                  j(                  fv r;|j0                  }|j(                  t*        j.                  j(                  k(  }| xr |j2                   }t        r&t        d| xr dxs d	d
|xr dxs d	d|d       t5               }d}|j                         |	z
  |k  r*|sd }na|r|j6                  }nR	 |r||   j8                  }n?||   j:                  s||   j<                  r|j?                  |      }n||   j8                  } |||fi |D ]  }t        |t              s|  |sZ|rX|r|jC                  jD                        }n:||   j:                  s||   j<                  r|jG                  jD                  |      }|
jI                  |ddd       |jK                  |       |dz  }|j                         |	z
  |k  r*t        rt        d|z         |rV|jL                  jO                  |      s,t        j                  d|
jP                  jR                  z        |jT                  r|jW                  di       }t        r3t        d       |jY                         D ]  \  }}t        |d|        |s|jW                  dd      r@t[        |j\                        D ]  \  }}|j^                  s|j:                  r|
ja                  |      jb                  s<|
je                  |j^                  jf                        }	 ||   }t        rt        d|d|       |
ja                  |      }|j(                  t*        jj                  j(                  t*        jl                  j(                  fv r[t[        |      D ]K  \  }}to        ||   jq                               } ||fd|i|D ]  }t        |t              s|  ||<   M *to        |
ja                  |      jq                               } ||fd|i|D ]  }t        |t              s|  |
jI                  |        n|
jr                  }|r||j0                  }t        rt        d |z         d}|j                         |	z
  |k  rV |||fi |D ]  }t        |t              s|  |
jI                  |ddd       |dz  }|j                         |	z
  |k  rV|
 y # t@        $ r t        j                  d|      w xY w# th        $ r t        rt        d|
jP                  jR                  d|jf                  d|
jP                  jR                  d|j^                  jf                  d	       |j^                  jY                         D ]  \  }}t        |d|        	 |j^                  |   }n%# th        $ r t        rt        d|       Y Y &w xY wY w xY ww)!Nr   Constructed tag format expectedrA   r$   r'   r%   )contextz)Unused trailing %d octets encountered: %s	decoding non-rJ   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#   +decoding type %r chosen by given `asn1Spec`):rW   r   tagFormatConstructedr   r   rr   rC   r7   r   r   r   rY   rZ   rq   r
   r   r   hexdumpclearr2   typeIdr   SequenceSetcomponentTypehasOptionalOrDefaultr   tagMapUniquer0   
isOptionalisDefaultedgetTagMapNearPosition
IndexErrorgetPositionByTypeeffectiveTagSetgetPositionNearTyper   r   requiredComponentsissubsetrp   r4   hasOpenTypesrB   itemsr   
namedTypesopenTypegetComponentByPositionisValuegetComponentByNamenameKeyErrorSetOf
SequenceOfr   asOctetsisInconsistent)r!   r"   r#   r$   r%   r&   r'   r(   r)   r~   r0   r=   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%NN,#%^^-
$$0!0066f6E
 "668S8SS
%j)VWM  >d>>.&,	!.%,. %
 j*@A$$	% ~~"3f"<<$29g$N +%h0FG"*N+ CHu}}X'>G@ @ A ^^%
&&z7;??t}}33TXX__EE!//J 488??:I"+mSJ4S4S0SO''2F8b8):M:SQS:S  %KC.."%66?!$(M$.$;$;M*,6sO,F,FM'_77:c?;V;V,6,L,LS,QM -7sO,F,FM "+9m!Ow!O (I!)-CD'( ': (::9;T;TU#C33z#7R7R(<<Y=V=VX[\11&+#e 2  $qS .."%66?V /+=>!44==kJ++%'1';';'D'DEF F ++ 'K <I<=$-OO$5 5DAqa 345 !GKK0A5$I.7
8M8M.N ?RNC#,#5#5 ((33J<]<]^a<b<j<j (-7-J-J ) 2 2 7 7.N-+4^+D0  # #2:N%L !M .8-N-Ns-SN-44$(JJ$5$5t7M7M9O  O >G(6>8 	!D$9C)9 .>nS>Q>Z>Z>\-]F5>v5dPX5d\c5d %<	+5iAW+X2;O%< ;DN3$7	!D *:*:[:[\_:`:i:i:k)l1:61`H1`X_1` !8I'1)=S'T.7!8 !+ A A#y Q?RD !+ 9 9 '' %22MAMQRC.."%66?!*9m!Ow!O (I!)-CD'( 11&+#e 2  q .."%66? S & #//DLN x $, -#&$'/9/C/C/L/L/8~~/9/C/C/L/L/8/A/A/F/F)H %I 1:0B0B0H0H0J %A1(+!Q,?(@%A!-/8/A/A./QH'/ !-'*(+:H-K )L$,	!- %--s   C^ A^#E^6AZ ^%B$^E^[ B3^A^B^7^^"Z==^ B^ ]0/^0^^^^^^^^c              +     K   |d   j                   t        j                  k7  rt        j                  d      |i||j                         }	nA| j                  | j                  j                  |      }	n| j                  | j                  f}	 ||	|||      D ]  }
|
  y |A | j                  |f|||dt        |d      D ]  }	t        |	t              s|	  	 y |j                         }	|	j                          | j                  |	|      }|j                  t         j"                  j                  t         j$                  j                  fv r|	j&                  }|	j                  t         j$                  j                  k(  }| xr |j(                   }t*        r&t+        d| xr dxs d	d
|xr dxs d	d|d       t-               }d}	 t/        |      |k  rd }na|r|j0                  }nR	 |r||   j2                  }n?||   j4                  s||   j6                  r|j9                  |      }n||   j2                  } |||fddi|D ]*  }t        |t              r| |t<        j>                  u s* n t<        j>                  u rn|sZ|rX|r|jA                  |jB                        }n:||   j4                  s||   j6                  r|jE                  |jB                  |      }|	jG                  ||ddd       |jI                  |       |dz  }Ht*        rt+        d|z         |r.|jJ                  jM                  |      s,t        j                  d|	jN                  jP                  z        |jR                  r?|jU                  di       }t*        r3t+        d       |jW                         D ]  \  }}t+        |d|        |s|jU                  dd      rztY        |jZ                        D ]  \  }}|j\                  s|j4                  r|	j_                  |      j`                  s<|	jc                  |j\                  jd                        }	 ||   }t*        rt+        d|d|       |	j_                  |      }|j                  t         jh                  j                  t         jj                  j                  fv rytY        |      D ]i  \  }}tm        ||   jo                               } ||fd |it        |d      D ]*  }t        |t              r| |t<        j>                  u s* n |||<   k Htm        |	j_                  |      jo                               } ||fd |it        |d      D ]=  }t        |t              r| |t<        j>                  u r |	jG                  ||       ?  n|	jp                  }|r||j&                  }t*        rt+        d!|z         d}	  |||fddi|D ]*  }t        |t              r| |t<        j>                  u s* n t<        j>                  u rn|	jG                  ||ddd       |dz  }h|	 y # t:        $ r t        j                  d|	      w xY w# tf        $ r t*        rt+        d|	jN                  jP                  d|jd                  d|	jN                  jP                  d|j\                  jd                  d	       |j\                  jW                         D ]  \  }}t+        |d|        	 |j\                  |   }n%# tf        $ r t*        rt+        d|       Y Y `w xY wY  w xY ww)"Nr   r   rA   r   TrN   r   r   rJ   r   r   r   r   r   rN   Fr   r_   r   r   r   r   r   r   r   r   r   r   r   r   r   r#   r   )9rW   r   r   r   r   rC   r7   r   r   r   dictrY   rZ   r   r2   r   r   r   r   r   r   rq   r   r   r   r0   r   r   r   r   r   rO   r   r   r   r   r   r   r   rp   r4   r   rB   r   r   r   r   r  r  r  r  r  r  r  r   r  r	  )r!   r"   r#   r$   r%   r&   r'   r(   r)   r0   r=   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##%^^-
$$0!0066f6E
 "668S8SS
%j)VWM  >d>>C&,	!C%)'D%AC %
 j*@A$$	% ^^%
&&z7;??t}}33TXX__EE#11J"))TXX__<I"+mSJ4S4S0SO''2F8b8):M:SQS:S  %KCz?c)#H)66H*'1#'A'AH'_77:c?;V;V'1'G'G'LH (2#'A'AH "+9h!Y!YQX!Y I!)-CD' COO3 /&: (::9;T;TU#C33z#7R7R(<<Y=V=VX[\11&+#e 2  $qa d /+=>!44==kJ++%'1';';'D'DEF F ** 'K <I<=$-OO$5 5DAqa 345 !GKK0A5$I.7
8M8M.N FVNC#,#5#5 ((33J<]<]^a<b<j<j (-7-J-J ) 2 2 7 7.N-+4^+D0  # #2:N%L !M .8-N-Ns-SN-44$(JJ$5$5t7M7M9O  O >G(6>8 !D$9C)9 .>nS>Q>Z>Z>\-]F5>v 6_PX 6_AEgX\A]6_ %2	+5iAW+X2;O+4+G,1%2 ;DN3$7!D  *:*:[:[\_:`:i:i:k)l1:6 2[H 2[=A'TX=Y2[ !VI'1)=S'T.7'0COO'C(-$.$E$Ec9$U!V}FVR %/$=$=M$++ %22MAMQRC!*!="L;?"LCJ"L I ")-CD' COO3 /11&+#e 2  q) , A & #//DNP F $, -#&$'/9/C/C/L/L/8~~/9/C/C/L/L/8/A/A/F/F)H %I 1:0B0B0H0H0J %A1(+!Q,?(@%A!-/8/A/A./QH'/ !-'*(+:H-K )L$,	!- %--s   C]*D]*8AY) 	5]*?G!]*!Z&C]*;C6]*27]*)"Z]*B]'.\>=]'>] ]']*]  ]'#]*&]'']*)NNNr3   )
r4   r5   r6   r   r   r   r   r   r+   r.   r1   r,   r*   r   r   s  sD    !$$ 591h 6:26Zz >B:>hr,   r   c                   P    e Zd Z ej                         Z ej                         Zy)"SequenceOrSequenceOfPayloadDecoderN)r4   r5   r6   r   r   r   r  r   r1   r,   r*   r  r  w  s    (4==?,T__.r,   r  c                   .    e Zd Z ej                         Zy)SequencePayloadDecoderN)r4   r5   r6   r   r   r7   r1   r,   r*   r  r  |  s    "T]]_Nr,   r  c                   .    e Zd Z ej                         Zy)SequenceOfPayloadDecoderN)r4   r5   r6   r   r  r7   r1   r,   r*   r  r        $T__&Nr,   r  c                   P    e Zd Z ej                         Z ej                         Zy)SetOrSetOfPayloadDecoderN)r4   r5   r6   r   r   r   r  r   r1   r,   r*   r"  r"    s    #488:'TZZ\r,   r"  c                   .    e Zd Z ej                         Zy)SetPayloadDecoderN)r4   r5   r6   r   r   r7   r1   r,   r*   r$  r$    s    TXXZNr,   r$  c                   .    e Zd Z ej                         Zy)SetOfPayloadDecoderN)r4   r5   r6   r   r  r7   r1   r,   r*   r&  r&    s    TZZ\Nr,   r&  c                   F    e Zd Z ej                         Z	 	 ddZ	 	 ddZy)ChoicePayloadDecoderNc              +   j  K   || j                   j                  |      }	n|j                         }	|r ||	|||      D ]  }
|
  y | j                  |	|      }|	j                  |k(  rDt        rt	        d|d        |||	j
                  fi |D ]  }t        |t              s|  nFt        rt	        d|d        |||	j
                  |||fi |D ]  }t        |t              s|  j                  }t        rt	        d|d|       |	j                  ||dddd       |	 y w)	NrA   r   z as explicitly tagged CHOICEz as untagged CHOICEdecoded component , effective tag set Fr   r   r   	innerFlag)
r7   rC   r2   r$   rq   componentTagMaprY   rZ   r   setComponentByType)r!   r"   r#   r$   r%   r&   r'   r(   r)   r0   r=   rv   r   s                r*   r+   z!ChoicePayloadDecoder.valueDecoder  s[     ,,22&2AJ ")J%j)VWM  &&z7;&IJ&z99F=DF $	i)?@#O$ @A&z9966&$& $	 i)?@#O	$ $33	?[\%%Y#e	 	& 	
 s   B$D3'AD3.AD3c           	   +     K   || j                   j                  |      }	n|j                         }	|r ||	|||      D ]  }
|
  y | j                  |	|      }|	j                  |k(  }t        rt	        d|d|xr dxs dd       	 |r* |||	j
                  j                  fi t        |d      }n, |||	j
                  j                  |||fi t        |d      }|D ]h  }t        |t              r| |t        j                  u r n@|j                  }t        rt	        d	|d
|       |	j                  ||dddd       |rh n |rt        j                  u rn|	 y w)NrA   r   z as zexplicitly unztagged CHOICETr  r*  r+  Fr,  )r7   rC   r2   r$   rq   r   r   r  rY   rZ   r   rO   r   r/  )r!   r"   r#   r$   r%   r&   r'   r(   r)   r0   r=   isTaggediteratorrv   r   s                  r*   r.   z)ChoicePayloadDecoder.indefLenValueDecoder  s     ,,22&2AJ ")J%j)VWM  &&z7;$$.2]:d:< = $z77DD47T24
 %z77DDFEK-1'D-IK & 	i)?@#O/"+";"; )?< = --#Y&+#e#	 .   -0 yCOO;K N s   E
E+E+r3   )r4   r5   r6   r   Choicer7   r+   r.   r1   r,   r*   r(  r(    s+     T[[]N 6:261h >B:>?r,   r(  c                   F    e Zd Z ej                         Z	 	 ddZ	 	 ddZy)AnyPayloadDecoderNc              +     K   |d}	n:|j                   t        j                  u r||j                  v}	n||j                  k7  }	|	r|j
                  }
|j                         }|j                  |
t        j                         |||
z
  z  }t        rGt        ||      D ]  }t        |t              s|  t        dt        j                        z         |r, | | j                   ||t"        fi ||||      D ]  }|  y t%        |||      D ]  }t        |t              s|   | j                   ||fi | y w)NTz&decoding as untagged ANY, substrate %s)rp   r   TagMaptagMapr$   markedPositionrr   seekosSEEK_SETrq   r   rY   rZ   r   r   rG   rD   r
   )r!   r"   r#   r$   r%   r&   r'   r(   r)   
isUntaggedfullPositioncurrentPositionr=   s                r*   r+   zAnyPayloadDecoder.valueDecoder  sR     J6==0x6J  8??2J$33L'nn.ONN<5o44F+Iv> $E!%)?@#$   ==/0 1 %)D))(FGOwOvw0  
 #Ivw? 	E%!78	 $d##HfeGwGGs   B+E.A5E$Ec              +     K   |d}	n:|j                   t        j                  u r||j                  v }	n||j                  k(  }	|	rt
        }
t        rt        d       n|j                  }|j                         }|j                  |t        j                         t        |||z
  |      D ]  }
t        |
t              s|
  t        r!t        dt        j                   
      z         | j"                  }|rK|| j$                  ur= | j&                  ||t(        fi |} ||
|z   |t+        |
      z   |      D ]  }
|
  y t        rt        d       | j$                  }	  |||f|dd|D ]*  }t        |t              r| |t,        j.                  u s* n t,        j.                  u rn
|z  }
S|r
 y  | j&                  ||
fi | y w)NFzdecoding as tagged ANYz-decoding as untagged ANY, header substrate %sri   Trx   )rp   r   r8  r9  r$   r   rq   r:  rr   r;  r<  r=  r
   rY   rZ   r   r   r7   r>   rG   rD   r   r   rO   )r!   r"   r#   r$   r%   r&   r'   r(   r)   r2  r=   r?  r@  r0   rv   s                  r*   r.   z&AnyPayloadDecoder.indefLenValueDecoder5  s     H6==00H 0HE,- %33L'nn.ONN<5'	?\3QSZ[  e%;<K  CemmTYFZZ[ &&L0G0GG...&'6-46J &	 16CJ3FQ  67 ..&x.6B!.%,. 	 i)?@#O/ COO+YE " K ($''&%K7KKs   B9G<CG;Gr3   rP   r1   r,   r*   r6  r6  	  s.    TXXZN 6:26'HT >B:>ILr,   r6  c                   .    e Zd Z ej                         Zy)UTF8StringPayloadDecoderN)r4   r5   r6   r   
UTF8Stringr7   r1   r,   r*   rC  rC    r   r,   rC  c                   .    e Zd Z ej                         Zy)NumericStringPayloadDecoderN)r4   r5   r6   r   NumericStringr7   r1   r,   r*   rF  rF        'T'')Nr,   rF  c                   .    e Zd Z ej                         Zy)PrintableStringPayloadDecoderN)r4   r5   r6   r   PrintableStringr7   r1   r,   r*   rJ  rJ        )T))+Nr,   rJ  c                   .    e Zd Z ej                         Zy)TeletexStringPayloadDecoderN)r4   r5   r6   r   TeletexStringr7   r1   r,   r*   rN  rN    rH  r,   rN  c                   .    e Zd Z ej                         Zy)VideotexStringPayloadDecoderN)r4   r5   r6   r   VideotexStringr7   r1   r,   r*   rQ  rQ    s    (T((*Nr,   rQ  c                   .    e Zd Z ej                         Zy)IA5StringPayloadDecoderN)r4   r5   r6   r   	IA5Stringr7   r1   r,   r*   rT  rT        #T^^%Nr,   rT  c                   .    e Zd Z ej                         Zy)GraphicStringPayloadDecoderN)r4   r5   r6   r   GraphicStringr7   r1   r,   r*   rX  rX    rH  r,   rX  c                   .    e Zd Z ej                         Zy)VisibleStringPayloadDecoderN)r4   r5   r6   r   VisibleStringr7   r1   r,   r*   r[  r[    rH  r,   r[  c                   .    e Zd Z ej                         Zy)GeneralStringPayloadDecoderN)r4   r5   r6   r   GeneralStringr7   r1   r,   r*   r^  r^    rH  r,   r^  c                   .    e Zd Z ej                         Zy)UniversalStringPayloadDecoderN)r4   r5   r6   r   UniversalStringr7   r1   r,   r*   ra  ra    rL  r,   ra  c                   .    e Zd Z ej                         Zy)BMPStringPayloadDecoderN)r4   r5   r6   r   	BMPStringr7   r1   r,   r*   rd  rd    rV  r,   rd  c                   .    e Zd Z ej                         Zy)ObjectDescriptorPayloadDecoderN)r4   r5   r6   r   ObjectDescriptorr7   r1   r,   r*   rg  rg    s    ,V,,.Nr,   rg  c                   .    e Zd Z ej                         Zy)GeneralizedTimePayloadDecoderN)r4   r5   r6   r   GeneralizedTimer7   r1   r,   r*   rj  rj    s    +V++-Nr,   rj  c                   .    e Zd Z ej                         Zy)UTCTimePayloadDecoderN)r4   r5   r6   r   UTCTimer7   r1   r,   r*   rm  rm    s    #V^^%Nr,   rm  r   )r   r   c                   J    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y)SingleItemDecoderTc                     |t         ur|n| j                  | _        |t         ur|n| j                  | _        i | _        i | _        y r<   )r   TAG_MAP_tagMapTYPE_MAP_typeMap	_tagCache_tagSetCache)r!   r9  typeMapignoreds       r*   __init__zSingleItemDecoder.__init__	  s;    !'x!7vT\\#*(#: r,   Nc              +     K   |j                  dd      }	t        r t        dt        j                  |||fz         |	r| j                  rtt        |d|      D ]  }
t        |
t              s|
  
t        k(  r$t        rt        d       t        j                   y |j                  dt        j                         | j                  }| j                  }| j                   }| j"                  }t$        }|j'                         |_        |t*        ur|t,        u r{d}t        |d|      D ]  }t        |t              s|  t/              }	 ||   }| |r	 ||   }nt5        j8                  d|      }n||z   }t:        }t        rt        d|z         |t:        u rt        |d|      D ]  }t        |t              s|  t/              }|dk  r|}n|dkD  r|dz  }t        |||      D ]  }t        |t              s|  t=              }t?        |      |k7  r&t3        j                  |dt?        |      d|      d}|D ]  }|dz  }|tA        |      z  } |dz  }nd}|dk(  r!| j                  st3        jB                  d      tD        }t        rt        d|z         |tD        u r|tF        }ntH        }|tF        u r	 ||   }|rtJ        }n	 ||d d    }|rtJ        }ntL        }t        rt        d|xr |jN                  jP                  xs dd|tJ        u xr dxs d       t        j                  jS                  |d u xr dxs  |jT                  jN                  jP                         |tH        u r|jN                  tV        jX                  u r	 ||   }t        r$t        d        |jZ                  j]                         D ]*  \  }}t        d!|d"|jN                  jP                         , |j^                  rRt        d#       |j^                  j]                         D ]*  \  }}t        d!|d"|jN                  jP                         , t        d$|d u xr dxs |ja                         d%|       nJ||jb                  k(  s||jd                  v r+|}t        r%t        d&|jN                  jP                  z         nd }|@	 ||jf                     }t        rt        d'|jf                         |r	|}tJ        }ntL        }nd }tL        }t        r~t        d|tJ        u xr |jN                  jP                  xs dd)|tJ        u xr dxs d       t        j                  jS                  |d u xr dxs |jN                  jP                         |tJ        u rY|jk                  d*d      s|sd+ }|j'                         }!|dk(  r8 jl                  ||||tD        | |fi |D ]  }t        |t              s|  n| jn                  ||||tD        | |fi |D ]  }t        |t              s|  |j'                         |!z
  }"|s|"|k7  rtC        d,|"d-|d.      |r|"|kD  rtC        d,|"d/|d.      t        rkt        d|jN                  jP                  d0|jN                  jP                  d1t        |tp        jr                        xr |ju                         xs |d2       t*        }n|tL        u r|rM|d   jv                  t4        jx                  k(  r-|d   jz                  t4        j|                  k7  rt~        }tJ        }nd }| j                  }t        r;t        d|xr |jN                  jP                  xs dd3|tJ        u xr dxs d4       |t        u r:| j                  }t        r"t        d5|jN                  jP                  z         tJ        }|t        u rt3        jB                  |d6|      |t*        urt        r:t        j                  j                          t        d7t        j                  z         | y # t0        $ r |}|d	z  }|d
z  }|dz  }|dk(  rid}d}d}	 t        |d|      D ]  }t        |t              s|  st3        j                  d      t/        |      }|dz  }|dz  }||dz  z  }|dz  snbt5        j6                  |||      }|r|||<   Y w xY w# t0        $ r t5        j8                  d|      }|||<   Y w xY w# t0        $ r d }Y ow xY w# t0        $ r d }Y ow xY w# t0        $ r d }Y w xY w# t0        $ rn t5        j8                  |jb                  jh                  |jb                  jh                        } 	 ||    }t        rt        d(|        n# t0        $ r d }Y nw xY wY w xY ww)8NrN   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   )tagClassrW   tagIdr1   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 rF   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   |  yw)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.
                        Nr1   )r0   
_substrate_length_optionss       r*   r(   z0SingleItemDecoder.__call__.<locals>.substrateFun  s      )(s   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)Dpoprq   r   scopesupportIndefLengthr
   rY   rZ   EOO_SENTINELr   rO   r;  r<  SEEK_CURrs  ru  rv  rw  rD   rr   r:  stStopstDecodeTagrm   r  r   r   Tagr   stDecodeLengthlistr   r   r   stGetValueDecoderstGetValueDecoderByTagstGetValueDecoderByAsn1SpecstDecodeValuestTryAsExplicitTagrp   r4   pushr7   r   r8  presentTypesr   	skipTypesprettyPrintTyper$   r9  r   r   rB   r.   r+   r   Asn1ItemprettyPrintrW   r   r  tagClassUniversalrawPayloadDecoderdefaultErrorStatestDumpRawValuedefaultRawDecoderstErrorCondition)#r!   r"   r#   r$   r%   r&   r'   r(   r)   rN   eoo_candidater9  rx  tagCachetagSetCacherF   
isShortTag	firstByte
firstOctetlastTag
integerTagr  rW   r  lengthOctetIdxintegerBytesizeencodedLengthlengthOctetconcreteDecoder
chosenSpecr  
baseTagSetr~   	bytesReads#                                      r*   __call__zSingleItemDecoder.__call__  s
    
 ;;z51 UFI>? @
 //!/	1g!F (m-CD''( ,67oo% r2;;/-->>''#,>>#3	 6!#!
!/	1g!F (I!)-CD'( !^
&7&z2GN >!=%0%<F "%B!8 %v-F&>GH&"0Aw"G )J!*.DE(() !_
#'F#%%,D)7	4)Q 0%m5KL"//0 %)$7M =)T1#::-13}3EvN  F'4 71'+"667 AID  FR<(?(?++,dee)6?@))#2E 8E" ..+&,VnO
 #)E/*0*<
 ' - 2_  NDapazaz  bD  bD  NP  HP  NP  RW  [h  Rh  Rt  mt  RI  xI  RI  J  KKK$$_%<%D%yHfHfHpHpHyHyz33%%6*%-f%5

 ?@-5-B-B-H-H-J SMJ
AKK<P<P QRS $-- 23191C1C1I1I1K W
A #J@T@T$U VWj\`N`Nmem  ONq{  rL  rL  rN  ON  PV  W  Xx.&HOO2K!)J88;M;M;V;VVW "&J)3*1*2C2C*D^h^o^o qr '#- - !3 '+O.EQ^H^  IFcrc|c|  dF  dF  IR  JR  IR  TY  ]j  Tj  Tv  ov  TK  zK  TK  L  MKK$$Z4%7%?C%`:CWCWC`C`a%{{?D9,) %.NN$4!R<!E!E!E%x"F,= ,"; 3:"; ( &e-CD"'K( ">!=!=%x"F,= ,"; 3:"; ( &e-CD"'K( !* 03D DI'I,?)GPRXY[ [%)f*<)JSU[\^ ^ &00995??;S;S!%7OE<M<M<OXSXXZ [ **q	++s/G/GGq	**c.C.CC&7O)E '+O 22E/:poNgNgNpNp:|t|:|  D  HU  U  a  Za  q  eq  q  r  s&"&"8"89O<U<U<^<^^_%((''06A S	 6!Z	 KKOO7%++EFE	   #7!+J)D0H *T 1I&-E}%*
)* !"/=iG/T 6#-k;Q#R*5$56 $/&+&B&B$M'" !" *-[)9J*a/N!aKE!j4&78E#-#4 %! #$ "gg!)YeG "/6,G#7T  ( =%(ZZG%<F6<K
3=f   +&*O+ $ /*./$ $ *%)
*> $ 3%(ZZ
0A0A0I0IJL]L]LeLe%f
3.4Z.@O" #$U V' 3.2O33s>  A'g!*Cg!<g!a g!d A g!>Ag!Cg!d1 	g!e "B<g!e $D-g!-e' ?Dg!7g!;Gg!Ag!AdA d?g!dg!$d.*g!-d..g!1e <g!?e  g!eg!eg!e$ g!#e$$g!'Ag/g	g	ggggg!gg!)r4   r5   r6   r  r  r6  r  r  rr  rt  r   rz  r  r  r1   r,   r*   rp  rp    sB    ()+GH&  ,0TdVr,   rp  c                   "    e Zd ZdZeZddZd Zy)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        |      | _        || _        || _        y )Nr1   )SINGLE_ITEM_DECODER_singleItemDecoderr   r  	_asn1Specr  )r!   r"   r#   r)   s       r*   rz  zStreamingDecoder.__init__  s4    ":$":":"EW"E*95!r,   c              #      K   	  | j                   | j                  | j                  fi | j                  D ]  }|  t	        | j                        D ]  }t        |t              rd   n ry nwr<   )r  r  r  r  r   rY   rZ   )r!   r0   r=   s      r*   __iter__zStreamingDecoder.__iter__  s~     5d55OOT^^F7;}}F !
  ! 't7 e%;<	  s   A0A2r<   )r4   r5   r6   __doc__rp  r  rz  r  r1   r,   r*   r   r   j  s    HT , r,   r   c                   6    e Zd ZdZeZedd       Zed        Z	y)r   znCreate a BER decoder object.

    Parse BER/CER/DER octet-stream into one, possibly nested, ASN.1 object.
    Nc                 6   t        |      }d|v r|d   dfd	}||d<    | j                  ||fi |}|D ]A  }t        |t              rt	        j                  d      	 t        t        |            }||fc S  y# t        j                  $ r	 t        }Y #w xY w)a  Turns BER/CER/DER octet stream into an ASN.1 object.

        Takes BER/CER/DER octet-stream in form of :py:class:`bytes` (Python 3)
        or :py:class:`str` (Python 2) 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` (Python 3) or :py:class:`str` (Python 2)
            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   	  	| |||      }|D ]  }|  y# t         $ r\ t        j                         \  }}}|j                  r t	        |t
        j                        sJ t        j                  	| ||      }Y pw xY ww)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sysexc_infotb_nextrY   ioBytesIOr   _callSubstrateFunV4asV5)
r0   r"   r%   r)   substrate_gen_type_value	tracebackrF   origSubstrateFuns
            r*   substrateFunWrapperz-Decoder.__call__.<locals>.substrateFunWrapper)  s     	u$4ZFT[$\M +  EK  ! u/2||~,E69 ((%i<<<$+$C$CDTV`bkms$tMus&   B BA"B>B BBzShort substrate on inputr<   )	r   STREAMING_DECODERrY   rZ   r   nextr
   EndOfStreamErrorr   )	clsr"   r#   r)   r  streamingDecoderr0   tailr  s	           @r*   r  zDecoder.__call__  s    ` %Y/	W$&~6 ( ':GN#0300x,#*, + 
	$J*&<=223MNNN956
 t##
	$ )) s    A<<BBc              #      K   |j                         }|dk(  rt        |      } | |||      \  }}|j                  |      }|j                          |j	                  | t
        j                         | y w)Nr   )readr   writetruncater;  r<  r  )substrateFunV4r0   r"   r%   substrate_bytesrF   nextSubstratenbytess           r*   r  zDecoder._callSubstrateFunV4asV5N  si     #..*R<)F-j/6R}/w,s   A5A7r<   )
r4   r5   r6   r  r   r  classmethodr  r8   r  r1   r,   r*   r   r     s8     )w$ w$r  r,   r   )r  r<  r  pyasn1r   r   pyasn1.codec.berr   pyasn1.codec.streamingr   r   r   r
   pyasn1.compatr   pyasn1.compat.integerr   pyasn1.compat.octetsr   r   r   r   pyasn1.errorr   pyasn1.typer   r   r   r   r   r   __all__registerLoggeer4   DEBUG_DECODERrq   rD   rZ   objectr   r:   rI   r  rS   r]   rb   r{   r   r   r   r   r   r   r  r  r  r"  r$  r&  r(  r6  rC  rF  rJ  rN  rQ  rT  rX  r[  r^  ra  rd  rg  rj  rm  r[   r$   r`   ry   r   r   r   r   
Enumeratedr   r   r   r4  rD  rG  rK  rO  rR  rU  rY  r\  r_  rb  re  rh  rk  rn  rr  r   r  r  rQ   rt  r9  rx  valuestypeDecoderr7   rp   ranger  r  r  r  r  r  r  r  r  r  r  rp  r   r   r   )xs   0r*   <module>r     sM   
 	 
     3 0 1 1 " , D D $      
3e85+>+>?
,,55 V >)#9 )"&4 &R &' H8 H0A1 A@L: @LFSI < SIl5 .9F%A 9Fx/I < /IdkH5 kH\(> A$E AH/)F /
%? %'A '*< *
 0  "2 "u8 upuL4 uLr'8 '*"; *,$= ,*"; *+#< +&7 &*"; **"; **"; *,$= ,&7 &
/%> /.$= .&5 &LL.0LL.0 	NN24 	68	
 	II(* 	  "@"B 	68 	OO13 	II(* 	MM<> 	HHOO-/ 	KK,. 	OO46 	:<  	!>!@!" 	:<#$ 	 < >%& 	NN24:<:<:<!>!@NN24
""$B$D
!!#@#B
NN029B 	HHOO&(JJ*,MM02OO46KK,.HHOO&( 

 >># +K!!-++55<<&"8*HV	+  Ry!!A!		  h hV`v `FJf JF 
o "s   	Y