
    xi[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j4                  eej8                        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j                  j                   e&       ej                  j                   e'       ej                  j                   e(       ej                  j                   e)       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                   e3       ej                  j                   e6       ej                  j                   e8       ej                  j                   e9       ej                  j                   e:       ej                  j                   e;       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       i	Zaej                  j                   e4       ej                  j                   e5       ej                  j                   e1       ej                  j                   e2       ej                  j                   e6       ej                  j                   e7       iZfeaj                         D ]<  Zhehj                  ehj                  j                  j                  Zbeb3ebefvs8ehefeb<   >  ekdZ      D  cg c]  } |  c} \
  ZlZmZnZoZpZqZrZsZtZu evd[      Zw G d\ d]e!      Zx G d^ d_e!      Zy G d` dae!      Zz ez       Z{dbe|fdcZ}yc c} w )d    N)debug)error)eoo)asSeekableStream)isEndOfStream)peekIntoStreamreadFromStream)_MISSING)PyAsn1Error)base)char)tag)tagmap)univ)useful)StreamingDecoderDecoderdecode)flags   c                   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	            d/var/www/html/chatbot/card-advisor-bot/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.indefLenValueDecoder6   s     [a c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   )   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	   )r,   r   r!   r%   chunks        r&   substrateCollectorz/AbstractSimplePayloadDecoder.substrateCollectorI   s#     #Ivw? 	EK	s   c                     |j                  d      r|S || j                  j                  ||      S |t        u r|S |j                  |      S )Nnativer    )getr3   clonenoValuer   r   r    valuer%   s        r&   _createComponentz-AbstractSimplePayloadDecoder._createComponentN   sQ    ;;x L&&,,U6,BBgO>>%((r(   N)r0   r1   r2   r4   r:   rC   r-   r(   r&   r6   r6   H   s     )r(   r6   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)NrF   )rC   r   r   r   r    r!   r"   r#   r$   r%   r,   r9   rB   s               r&   r'   zRawPayloadDecoder.valueDecoder\   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)NrF   TallowEoo)rC   r   endOfOctetsrH   s               r&   r*   z&RawPayloadDecoder.indefLenValueDecoderk   s      ...xOwOJ%j)VWM  "x.!.%,.  COO+ s   AAr/   r0   r1   r2   r   Anyr3   r'   r*   r-   r(   r&   rE   rE   Y   s,    TXXb\N 6:26  >B:>r(   rE   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        j                  t        |	      dd      }
nd}
 | j                  |||
fi | y w)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#Ivw? 	E%!78	 NN5<tNDE E#d##HfeGwGGs   ABABr/   )r0   r1   r2   r   Integerr3   r'   r-   r(   r&   rO   rO      s    !T\\!_N 6:26Hr(   rO   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   )rO   rC   rA   s        r&   rC   z&BooleanPayloadDecoder._createComponent   s2    $55(FEKa$41A8?A 	Ar(   N)r0   r1   r2   r   Booleanr3   rC   r-   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)BitStringPayloadDecoderr-   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                  d
d      }|j'                         }|j'                         |z
  |k  r ||| j                  fd|i|D ]  }t        |t              s|  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 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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D7Q	$>>+nn!11F:&t22AM $	 i)?@#O	$ %Q<La''/,>  ++;;!"d!< < I nn!11F:$ $d##HfiK7KKs(   A&J)AJAJC=JA J8Jc              +   (  K   |r. | j                   ||t        fi |}	 ||	|||      D ]  }
|
  y | j                  }| j                  j	                  dd      }	  ||| j                  f|dd|D ]+  }|t
        j                  u r nt        |t              s(| - t
        j                  u rnE|d   }|dkD  rt        j                  d|z        | j                  j	                  |dd  d||	      } | j                   |||fi | y w)
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   sU    
 ...xTGTJ%j)VWM   ..''77D7Q	&t22.AM!.%,. $	 /i)?@#O$ COO+$Q<La''/,>  ++;;!"d!< < I+ 4 $d##HfiK7KKs   BDA6Dr/   )	r0   r1   r2   r   	BitStringr3   ro   r'   r*   r-   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)OctetStringPayloadDecoderrF   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                  }d}|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(   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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   A1E34CE39!E3E3c              +     K   |r<|| j                   ur. | j                  ||t        fi |}	 ||	|||      D ]  }
|
  y | j                   }d}	  ||| j                  f|dd|D ]*  }t	        |t
              r| |t        j                  u s* n t        j                  u rn||z  }] | j                  |||fi | y w)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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r/   )	r0   r1   r2   r   OctetStringr3   ro   r'   r*   r-   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)NullPayloadDecoderrF   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   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#Ivw? 	E%!78	 *D))(FBJ'J	##$Lv$UVVs   AB:Br/   )r0   r1   r2   r   Nullr3   r'   r-   r(   r&   r   r   ~  s    TYYr]N 6:26r(   r   c                   <    e Zd Z ej                  d      Z	 	 ddZy)ObjectIdentifierPayloadDecoderr-   Nc              +     K   |d   j                   t        j                  k7  rt        j                  d      t        |||      D ]  }	t        |	t              s|	  	st        j                  d      d}
d}t        |	      }||k  r|	|   }|dz  }|dk  r|
|fz  }
n|dkD  r||}d}d}|dk\  rd|dz  }|t        kD  rt        j                  dt        |fz        |dz  |d	z  z   }||k\  rt        j                  d
|
      |	|   }|dz  }|dk\  rd|
|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   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  sE     !9#"5"55##$@AA#Ivw? 	E%!78	 ##$5665zl"%LEQJEs{x!	)*&3&*a/*-0OO#//-0OQV/WX  #aZI,<=E,#::EHJ  !&eIQJE  3& !y022#
 ''(LMM= l"B 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GB:G,GBGr/   )r0   r1   r2   r   ObjectIdentifierr3   r'   r-   r(   r&   r   r     s"    *T**2.N 6:26;Fr(   r   c                   <    e Zd Z ej                  d      Z	 	 ddZy)RelativeOIDPayloadDecoderr-   Nc              +     K   |d   j                   t        j                  k7  rt        j                  d      t        |||      D ]  }	t        |	t              s|	  	st        j                  d      d}
d}t        |	      }||k  r|	|   }|dz  }|dk  r|
|fz  }
n|dkD  r||}d}d}|dk\  rd|dz  }|t        kD  rt        j                  dt        |fz        |dz  |d	z  z   }||k\  rt        j                  d
|
      |	|   }|dz  }|dk\  rd|
|dz  |z   fz  }
n|dk(  rt        j                  d      ||k  r | j                  |||
fi | y w)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#Ivw? 	E%!78	 ##$5665zl"%LEQJEs{5("!	)*&3&*a/*-0OO#//-0OQV/WX  #aZI,<=E,#::EKM  !&eIQJE  3& EQJ)355#
 ''(UVV= l"@ $d##HffHHHs   AEB:E,EEr/   )r0   r1   r2   r   RelativeOIDr3   r'   r-   r(   r&   r   r     s"    %T%%b)N 6:261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 |	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  xr dxs d}|r|dz  }||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  }||	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   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#Ivw? 	E%!78	 '$''&#III1Xab	9''(IJJ23daAAv!Hab	bq	59BU''(?@@1#(qAaRU
V 
 a$A1u''(;<<AvQaQAaU1X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I>B7I>AI>!A2I>AI +1I>I;;I>r/   )r0   r1   r2   r   Realr3   r'   r-   r(   r&   r   r     s    TYY[N 6:26hHr(   r   c                       e Zd ZdZy)!AbstractConstructedPayloadDecoderN)r0   r1   r2   r3   r-   r(   r&   r   r   {  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         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               }|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_   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,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 rf|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      rkt[        |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                  }|rt        j                  d |
jP                  jR                   d!      |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 Qw xY wY w xY ww)#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%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 ++'
(<(<(E(E'FFVWY Y %22MAMQRC.."%66?!*9m!Ow!O (I!)-CD'( 11&+#e 2  q .."%66? U & #//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[ _%B$_E_[+B3_A_B,_	7__"[((_+B_^_^=8_9_<^==_ ___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         |rY|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      rtY        |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                  }|rt        j                  d!|	jN                  jP                   d"      |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   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##%^^-
$$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$#//+J,@,@,I,I+JJZ[] ] %22MAMQRC!*!="L;?"LCJ"L I ")-CD' COO3 /11&+#e 2  q) , C & #//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Z 	5^?G!^!Z9&C^;D!^7^"Z66^9B^])(^)^^^
^^^^^)NNNr/   )
r0   r1   r2   r   r   r   r   r   r'   r*   r-   r(   r&   r   r     sD    !"" 591h 6:26[| >B:>ir(   r   c                   P    e Zd Z ej                         Z ej                         Zy)"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y)SequencePayloadDecoderN)r0   r1   r2   r   r   r3   r-   r(   r&   r   r     s    "T]]_Nr(   r   c                   .    e Zd Z ej                         Zy)SequenceOfPayloadDecoderN)r0   r1   r2   r   r
  r3   r-   r(   r&   r"  r"        $T__&Nr(   r"  c                   P    e Zd Z ej                         Z ej                         Zy)SetOrSetOfPayloadDecoderN)r0   r1   r2   r   r   r   r	  r   r-   r(   r&   r%  r%    s    #488:'TZZ\r(   r%  c                   .    e Zd Z ej                         Zy)SetPayloadDecoderN)r0   r1   r2   r   r   r3   r-   r(   r&   r'  r'    s    TXXZNr(   r'  c                   .    e Zd Z ej                         Zy)SetOfPayloadDecoderN)r0   r1   r2   r   r	  r3   r-   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)	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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)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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+r/   )r0   r1   r2   r   Choicer3   r'   r*   r-   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   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  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d}
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)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     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   B5G8CG;Gr/   rL   r-   r(   r&   r9  r9    s.    TXXZN 6:26'HT >B:>ILr(   r9  c                   .    e Zd Z ej                         Zy)UTF8StringPayloadDecoderN)r0   r1   r2   r   
UTF8Stringr3   r-   r(   r&   rF  rF    r#  r(   rF  c                   .    e Zd Z ej                         Zy)NumericStringPayloadDecoderN)r0   r1   r2   r   NumericStringr3   r-   r(   r&   rI  rI        'T'')Nr(   rI  c                   .    e Zd Z ej                         Zy)PrintableStringPayloadDecoderN)r0   r1   r2   r   PrintableStringr3   r-   r(   r&   rM  rM        )T))+Nr(   rM  c                   .    e Zd Z ej                         Zy)TeletexStringPayloadDecoderN)r0   r1   r2   r   TeletexStringr3   r-   r(   r&   rQ  rQ    rK  r(   rQ  c                   .    e Zd Z ej                         Zy)VideotexStringPayloadDecoderN)r0   r1   r2   r   VideotexStringr3   r-   r(   r&   rT  rT    s    (T((*Nr(   rT  c                   .    e Zd Z ej                         Zy)IA5StringPayloadDecoderN)r0   r1   r2   r   	IA5Stringr3   r-   r(   r&   rW  rW        #T^^%Nr(   rW  c                   .    e Zd Z ej                         Zy)GraphicStringPayloadDecoderN)r0   r1   r2   r   GraphicStringr3   r-   r(   r&   r[  r[    rK  r(   r[  c                   .    e Zd Z ej                         Zy)VisibleStringPayloadDecoderN)r0   r1   r2   r   VisibleStringr3   r-   r(   r&   r^  r^    rK  r(   r^  c                   .    e Zd Z ej                         Zy)GeneralStringPayloadDecoderN)r0   r1   r2   r   GeneralStringr3   r-   r(   r&   ra  ra    rK  r(   ra  c                   .    e Zd Z ej                         Zy)UniversalStringPayloadDecoderN)r0   r1   r2   r   UniversalStringr3   r-   r(   r&   rd  rd    rO  r(   rd  c                   .    e Zd Z ej                         Zy)BMPStringPayloadDecoderN)r0   r1   r2   r   	BMPStringr3   r-   r(   r&   rg  rg    rY  r(   rg  c                   .    e Zd Z ej                         Zy)ObjectDescriptorPayloadDecoderN)r0   r1   r2   r   ObjectDescriptorr3   r-   r(   r&   rj  rj    s    ,V,,.Nr(   rj  c                   .    e Zd Z ej                         Zy)GeneralizedTimePayloadDecoderN)r0   r1   r2   r   GeneralizedTimer3   r-   r(   r&   rm  rm    s    +V++-Nr(   rm  c                   .    e Zd Z ej                         Zy)UTCTimePayloadDecoderN)r0   r1   r2   r   UTCTimer3   r-   r(   r&   rp  rp    s    #V^^%Nr(   rp  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 r8   )r   TAG_MAP_tagMapTYPE_MAP_typeMap	_tagCache_tagSetCache)r   r<  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  }||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	 ||   }|rtH        }n	 ||d d    }|rtH        }ntJ        }t        rt        d|xr |jL                  jN                  xs dd|tH        u xr dxs d       t        j                  jQ                  |d u xr dxs  |jR                  jL                  jN                         |tF        u r|jL                  tT        jV                  u r	 ||   }t        r$t        d        |jX                  j[                         D ]*  \  }}t        d!|d"|jL                  jN                         , |j\                  rRt        d#       |j\                  j[                         D ]*  \  }}t        d!|d"|jL                  jN                         , t        d$|d u xr dxs |j_                         d%|       nJ||j`                  k(  s||jb                  v r+|}t        r%t        d&|jL                  jN                  z         nd }|@	 ||jd                     }t        rt        d'|jd                         |r	|}tH        }ntJ        }nd }tJ        }t        r~t        d|tH        u xr |jL                  jN                  xs dd)|tH        u xr dxs d       t        j                  jQ                  |d u xr dxs |jL                  jN                         |tH        u rY|ji                  d*d      s|sd+ }|j'                         }!|dk(  r8 jj                  ||||tB        | |fi |D ]  }t        |t              s|  n| jl                  ||||tB        | |fi |D ]  }t        |t              s|  |j'                         |!z
  }"|s|"|k7  rtA        d,|"d-|d.      |r|"|kD  rtA        d,|"d/|d.      t        rkt        d|jL                  jN                  d0|jL                  jN                  d1t        |tn        jp                        xr |js                         xs |d2       t*        }n|tJ        u r|rM|d   jt                  t4        jv                  k(  r-|d   jx                  t4        jz                  k7  rt|        }tH        }nd }| j~                  }t        r;t        d|xr |jL                  jN                  xs dd3|tH        u xr dxs d4       |t        u r:| j                  }t        r"t        d5|jL                  jN                  z         tH        }|t        u rt3        j@                  |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                  |j`                  jf                  |j`                  jf                        } 	 ||    }t        rt        d(|        n# t0        $ r d }Y nw xY wY w xY ww)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   |  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.
                        Nr-   )r,   
_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)Cpoprq   r   scopesupportIndefLengthr
   rV   rW   EOO_SENTINELr   rK   r>  r?  SEEK_CURrv  rx  ry  rz  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 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 .1+-. 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c= A g>AgB?gd( 	gd: B<ge D-g	-e 6Dg:7g2Gg
AgAc:A c:6g9c::g=$d%!g$d%%g(d73g6d77g:e	ge		gegegAg&g ?g ggggggg)r0   r1   r2   r  r  r9  r  r  ru  rw  r   r}  r  r  r-   r(   r&   rs  rs  	  sB    ()+GH&  ,0TdVr(   rs  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 )Nr-   )SINGLE_ITEM_DECODER_singleItemDecoderr   r  	_asn1Specr  )r   r   r   r%   s       r&   r}  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r8   )r  r  r  r  r   rV   rW   )r   r,   r9   s      r&   __iter__zStreamingDecoder.__iter__  s~     5d55OOT^^F7;}}F !
  ! 't7 e%;<	  s   A0A2r8   )r0   r1   r2   __doc__rs  r  r}  r  r-   r(   r&   r   r   t  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                 .   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 d}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`
        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   	  | |||      }|D ]  }|  y# t         $ rU}|j                  j                  r t        |t        j
                        sJ t        j                  | ||      }Y d}~ed}~ww 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__traceback__tb_nextrV   ioBytesIOr   _callSubstrateFunV4asV5)r,   r   r!   r%   substrate_gen_valuerB   origSubstrateFuns          r&   substrateFunWrapperz-Decoder.__call__.<locals>.substrateFunWrapper3  s     u$4ZFT[$\M +  EK  ! u++33%i<<<$+$C$CDTV`bkms$tMus+   A= A=	A:AA50A=5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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  )substrateFunV4r,   r   r!   substrate_bytesrB   nextSubstratenbytess           r&   r  zDecoder._callSubstrateFunV4asV5W  si     #..*R<)F-j/6R}/w,s   A5A7r8   )
r0   r1   r2   r  r   r  classmethodr  r4   r  r-   r(   r&   r   r     s8     )v$ v$p  r(   r   attrc                     dddj                  |       x}r-t        j                  |  d| dt               t	               |   S t        |       )Nru  rw  )r<  r{  z is deprecated. Please use z	 instead.)r>   warningswarnDeprecationWarningglobalsAttributeError)r  newAttrs     r&   __getattr__r    sR    &:>BB4HHwH9')LN`ay!!

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  ru  r   r	  r
  rM   rw  valuestypeDecoderr3   rp   ranger  r  r  r  r  r  r  r  r  r  rZ   r  rs  r   r   r   strr  )xs   0r&   <module>r     sL   
 	 
      3 0 1 1 " $      
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 .>F%A >FB4I < 4InkH5 kH\(> C$E CL/)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!		 V}h hV`v `FIf ID 
c q "s   ?	Y