
    ?gX5                       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 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.      Z/ G d/ d0e/      Z0 G d1 d2e/      Z1 G d3 d4e.      Z2 G d5 d6e2      Z3 G d7 d8e2      Z4 G d9 d:e.      Z5 G d; d<e"      Z6 G d= d>e(      Z7 G d? d@e(      Z8 G dA dBe(      Z9 G dC dDe(      Z: G dE dFe(      Z; G dG dHe(      Z< G dI dJe(      Z= G dK dLe(      Z> G dM dNe(      Z? G dO dPe(      Z@ G dQ dRe(      ZA G dS dTe(      ZB G dU dVe(      ZC G dW dXe(      ZDi 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                   e/       ej                  j                   e2       ej                  j                   e5       ej                  j                   e7       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       i	Z`ej                  j                   e3       ej                  j                   e4       ej                  j                   e0       ej                  j                   e1       ej                  j                   e5       ej                  j                   e6       iZee`j                         D ]<  Zgegj                  egj                  j                  j                  Zaea3eaeevs8egeeea<   >  ejdY      D  cg c]  } |  c} \
  ZkZlZmZnZoZpZqZrZsZt eudZ      Zv G d[ d\e       Zw G d] d^e       Zx G d_ d`e       Zy ey       Zzdae{fdbZ|yc c} w )c    N)debug)error)eoo)asSeekableStream)isEndOfStream)peekIntoStreamreadFromStream)_MISSING)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	            M/var/www/openai/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.indefLenValueDecoder2   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.substrateCollectorE   s     #Ivw?EK @s   c                     |j                  d      r|S || j                  j                  ||      S |t        u r|S |j                  |      S )Nnativer   )getr2   clonenoValuer   r   r   valuer$   s        r%   _createComponentz-AbstractSimplePayloadDecoder._createComponentJ   sQ    ;;x L&&,,U6,BBgO>>%((r'   N)r/   r0   r1   r3   r9   rB   r,   r'   r%   r5   r5   D   s     )r'   r5   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)NrE   )rB   r   r   r   r   r    r!   r"   r#   r$   r+   r8   rA   s               r%   r&   zRawPayloadDecoder.valueDecoderX   sf      ...xOwOJ%j)VWM N y(FFNgNEK Os   AAc              +      K   |r* | j                   ||dfi |}	 ||	|||      D ]  }
|
  y 	  |||||fddi|D ]  }|t        j                  u r y |  ,w)NrE   TallowEoo)rB   r   endOfOctetsrG   s               r%   r)   z&RawPayloadDecoder.indefLenValueDecoderg   s      ...xOwOJ%j)VWM N "x.!.%,. COO+. s   AAr.   r/   r0   r1   r   Anyr2   r&   r)   r,   r'   r%   rD   rD   U   s,    TXXb\N 6:26  >B:>r'   rD   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bytesrB   )r   r   r   r   r    r!   r"   r#   r$   r8   rA   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.   )r/   r0   r1   r   Integerr2   r&   r,   r'   r%   rN   rN      s    !T\\!_N 6:26Hr'   rN   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   )rN   rB   r@   s        r%   rB   z&BooleanPayloadDecoder._createComponent   s2    $55(FEKa$41A8?A 	Ar'   N)r/   r0   r1   r   Booleanr2   rB   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'   re   r#   re   prependrf   )rB   r?   r   r   r   rU   rV   rS   r   rT   r
   ordr2   fromOctetStringsupportConstructedForm	__class__r/   LOGr9   tell)r   r   r   r   r    r!   r"   r#   r$   r+   r8   trailingBitsrA   	bitStringcurrent_position	components                   r%   r&   z$BitStringPayloadDecoder.valueDecoder   s    
 ...xTGTJ%j)VWM N ##$@AA"9-E%!78 . ##$@AA!9#"5"55 .y!W El,BC&& !F |,La''/,>  (	6A:wGe%;<K H ''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'   Tri   r#   rI   r   rc   rd   r^   rj   )rB   r?   r9   r2   rm   r   rJ   rU   rV   r   r   )r   r   r   r   r    r!   r"   r#   r$   r+   r8   rs   ru   rr   s                 r%   r)   z,BitStringPayloadDecoder.indefLenValueDecoder   sL    
 ...xTGTJ%j)VWM N  ..''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.   )	r/   r0   r1   r   	BitStringr2   rn   r&   r)   r,   r'   r%   ra   ra      s7    #T^^B'N! 6:26NLb >B:>,Lr'   ra   c                   L    e Zd Z ej                  d      ZdZ	 	 ddZ	 	 ddZy)OctetStringPayloadDecoderrE   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   rg   rh   r'   r#   )rB   r?   rS   r   rT   r
   rU   rV   rn   r   r   ro   r/   rp   r9   rq   r2   )r   r   r   r   r    r!   r"   r#   r$   r+   r8   headeroriginal_positionru   s                 r%   r&   z&OctetStringPayloadDecoder.valueDecoder(  s     ...xTGTJ%j)VWM N !9#"5"55'	67Ce%;<K D ($''&%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'   Trw   )r9   rB   r?   r2   rU   rV   r   rJ   )r   r   r   r   r    r!   r"   r#   r$   r+   r8   r|   ru   s                r%   r)   z.OctetStringPayloadDecoder.indefLenValueDecoderU  s      L0G0GG...xTGTJ%j)VWM N  ..&t22.AM!.%,.	 i)?@#O/. COO+iF " $d##HffHHHs   BC4Cr.   )	r/   r0   r1   r   OctetStringr2   rn   r&   r)   r,   r'   r%   rz   rz   $  s8    %T%%b)N! 6:26+I\ >B:>"Ir'   rz   c                   <    e Zd Z ej                  d      Z	 	 ddZy)NullPayloadDecoderrE   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   rP   rE   z&Unexpected %d-octet substrate for Null)	rS   r   rT   r   r   r
   rU   rV   rB   )r   r   r   r   r    r!   r"   r#   r$   r8   ru   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.   )r/   r0   r1   r   Nullr2   r&   r,   r'   r%   r   r   z  s    TYYr]N 6:26r'   r   c                   <    e Zd Z ej                  d      Z	 	 ddZy)ObjectIdentifierPayloadDecoderr,   Nc              +   4  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  }
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   rP   Empty substrater,   r^      rc      !Short substrate for sub-OID past z"Invalid octet 0x80 in OID encoding'   )r   (   O   P      zMalformed first OID octet: %s
rS   r   rT   r   r   r
   rU   rV   lenrB   )r   r   r   r   r    r!   r"   r#   r$   r8   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&,FBFr.   )r/   r0   r1   r   ObjectIdentifierr2   r&   r,   r'   r%   r   r     s"    *T**2.N 6:264Fr'   r   c                   <    e Zd Z ej                  d      Z	 	 ddZy)RelativeOIDPayloadDecoderr,   Nc              +   Z  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  }
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   rP   r   r,   r^   r   rc   r   r   z+Invalid octet 0x80 in RELATIVE-OID encodingr   )r   r   r   r   r    r!   r"   r#   r$   r8   reloidr   r   r   r   s                  r%   r&   z&RelativeOIDPayloadDecoder.valueDecoder  ss     !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D+BD+&,D+D+r.   )r/   r0   r1   r   RelativeOIDr2   r&   r,   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 |	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   rP   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))rS   r   rT   r   r   r
   rU   rV   rB   rp   rW   float
ValueError)r   r   r   r   r    r!   r"   r#   r$   r8   foneoebpsfrA   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.   )r/   r0   r1   r   Realr2   r&   r,   r'   r%   r   r     s    TYY[N 6:26hHr'   r   c                       e Zd ZdZy)!AbstractConstructedPayloadDecoderN)r/   r0   r1   r2   r,   r'   r%   r   r   i  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         r7   NotImplementedError)r   r+   idxs      r%   _getComponentTagMapz1ConstructedPayloadDecoderBase._getComponentTagMapq      !!r'   c                     t         r7   r   )r   r+   r   r   s       r%   _getComponentPositionByTypez9ConstructedPayloadDecoderBase._getComponentPositionByTypet  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)setrq   rU   rV   r   rJ   appendaddr   r   protoRecordComponentprotoSequenceComponentr>   r   TagSetbaseTag	superTagsrp   	enumeratesetComponentByPosition)r   r   r   r"   r    r$   r+   
componentscomponentTypesr}   ru   r2   r   s                r%   _decodeComponentsSchemalessz9ConstructedPayloadDecoderBase._decodeComponentsSchemalessw  ss     

%NN,linn.1BV1KK&y<G<	i)?@#O = |	S__ <i(y//0 >"Q&!%!:!: "&!<!<'-- zz."7"7"?"?S&BRBRS . J+ linn.1BV1KK6  '( ) (
3NC--Y"'% .  4 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-rE   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`):rS   r   tagFormatConstructedr   r   rq   r>   r2   r   r   r   rU   rV   rp   r
   r   r   hexdumpclearr-   typeIdr   SequenceSetcomponentTypehasOptionalOrDefaultr   tagMapUniquer+   
isOptionalisDefaultedgetTagMapNearPosition
IndexErrorgetPositionByTypeeffectiveTagSetgetPositionNearTyper   r   requiredComponentsissubsetro   r/   hasOpenTypesr=   itemsr   
namedTypesopenTypegetComponentByPositionisValuegetComponentByNamenameKeyErrorSetOf
SequenceOfr   asOctetsisInconsistent)r   r   r   r   r    r!   r"   r#   r$   r}   r+   r8   trailingr   	isSetTypeisDeterministicseenIndicesr   r   ru   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 N >d>>.&,	!.%,.
 j*@A$$	. ~~"3f"<<$29g$N%h0FG"*N %O 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!OI!)-CD' "P ': (::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$5DAqa 34 %6 !GKK0A5$I.7
8M8M.NNC#,#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$9C)9 .>nS>Q>Z>Z>\-]F5>v5dPX5d\c5d	+5iAW+X2;O 6e ;DN3$7>8 *:*:[:[\_:`:i:i:k)l1:61`H1`X_1`I'1)=S'T.7 2a !+ A A#y Q /OD !+ 9 9 ++'
(<(<(E(E'FFVWY Y %22MAMQRC.."%66?!*9m!Ow!OI!)-CD' "P 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1(+!Q,?(@ 1K!-/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rI   r   r   rE   r   r   r   r   r   rI   Fr   r^   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )9rS   r   r   r   r   r>   r2   r   r   r   dictrU   rV   r   r-   r   r   r   r   r   r   rp   r   r   r   r+   r   r   r   r   r   rJ   r   r   r   r   r   r   r   ro   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$   r+   r8   r   r  r  r  r   ru   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 N >d>>C&,	!C%)'D%AC
 j*@A$$	C ^^%
&&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!YI!)-CD' COO3 "Z /&: (::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$5DAqa 34 %6 !GKK0A5$I.7
8M8M.NNC#,#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$9C)9 .>nS>Q>Z>Z>\-]F5>v 6_PX 6_AEgX\A]6_	+5iAW+X2;O+4+G,16_ ;DN3$7>8  *:*:[:[\_:`:i:i:k)l1:6 2[H 2[=A'TX=Y2[I'1)=S'T.7'0COO'C(-$.$E$Ec9$U2[} /OR %/$=$=M$#//+J,@,@,I,I+JJZ[] ] %22MAMQRC!*!="L;?"LCJ"LI ")-CD' COO3"L /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1(+!Q,?(@ 1K!-/8/A/A./QH'/ !-'*(+:H-K )L$,	!- %--s   C^D^8AZ 	5^?G!^!Z9&C^;D!^7^"Z66^9B^])(^)^^^
^^^^^)NNNr.   )
r/   r0   r1   r   r   r   r   r   r&   r)   r,   r'   r%   r   r   m  sD    !"" 591h 6:26[| >B:>ir'   r   c                   P    e Zd Z ej                         Z ej                         Zy)"SequenceOrSequenceOfPayloadDecoderN)r/   r0   r1   r   r   r   r  r   r,   r'   r%   r  r  s  s    (4==?,T__.r'   r  c                   .    e Zd Z ej                         Zy)SequencePayloadDecoderN)r/   r0   r1   r   r   r2   r,   r'   r%   r  r  x  s    "T]]_Nr'   r  c                   .    e Zd Z ej                         Zy)SequenceOfPayloadDecoderN)r/   r0   r1   r   r  r2   r,   r'   r%   r  r  |      $T__&Nr'   r  c                   P    e Zd Z ej                         Z ej                         Zy)SetOrSetOfPayloadDecoderN)r/   r0   r1   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)r/   r0   r1   r   r   r2   r,   r'   r%   r$  r$    s    TXXZNr'   r$  c                   .    e Zd Z ej                         Zy)SetOfPayloadDecoderN)r/   r0   r1   r   r  r2   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)
r2   r>   r-   r   rp   componentTagMaprU   rV   r   setComponentByType)r   r   r   r   r    r!   r"   r#   r$   r+   r8   ru   r   s                r%   r&   z!ChoicePayloadDecoder.valueDecoder  sN     ,,22&2AJ ")J%j)VWM N &&z7;&IJ&z99F=DF	i)?@#OF @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,  )r2   r>   r-   r   rp   r   r   r  rU   rV   r   rJ   r   r/  )r   r   r   r   r    r!   r"   r#   r$   r+   r8   isTaggediteratorru   r   s                  r%   r)   z)ChoicePayloadDecoder.indefLenValueDecoder  s     ,,22&2AJ ")J%j)VWM N &&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.   )r/   r0   r1   r   Choicer2   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)ro   r   TagMaptagMapr   markedPositionrq   seekosSEEK_SETrp   r   rU   rV   r   r   rB   r?   r
   )r   r   r   r   r    r!   r"   r#   r$   
isUntaggedfullPositioncurrentPositionr8   s                r%   r&   zAnyPayloadDecoder.valueDecoder  sD     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 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 %srh   Trw   )ro   r   r8  r9  r   rp   r:  rq   r;  r<  r=  r
   rU   rV   r   r   r2   r9   rB   r?   r   r   rJ   )r   r   r   r   r    r!   r"   r#   r$   r2  r8   r?  r@  r+   ru   s                  r%   r)   z&AnyPayloadDecoder.indefLenValueDecoder1  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Q 67 ..&x.6B!.%,.	 i)?@#O/. COO+YE " K ($''&%K7KKs   B5G8CG;Gr.   rK   r,   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)r/   r0   r1   r   
UTF8Stringr2   r,   r'   r%   rC  rC  ~  r   r'   rC  c                   .    e Zd Z ej                         Zy)NumericStringPayloadDecoderN)r/   r0   r1   r   NumericStringr2   r,   r'   r%   rF  rF        'T'')Nr'   rF  c                   .    e Zd Z ej                         Zy)PrintableStringPayloadDecoderN)r/   r0   r1   r   PrintableStringr2   r,   r'   r%   rJ  rJ        )T))+Nr'   rJ  c                   .    e Zd Z ej                         Zy)TeletexStringPayloadDecoderN)r/   r0   r1   r   TeletexStringr2   r,   r'   r%   rN  rN    rH  r'   rN  c                   .    e Zd Z ej                         Zy)VideotexStringPayloadDecoderN)r/   r0   r1   r   VideotexStringr2   r,   r'   r%   rQ  rQ    s    (T((*Nr'   rQ  c                   .    e Zd Z ej                         Zy)IA5StringPayloadDecoderN)r/   r0   r1   r   	IA5Stringr2   r,   r'   r%   rT  rT        #T^^%Nr'   rT  c                   .    e Zd Z ej                         Zy)GraphicStringPayloadDecoderN)r/   r0   r1   r   GraphicStringr2   r,   r'   r%   rX  rX    rH  r'   rX  c                   .    e Zd Z ej                         Zy)VisibleStringPayloadDecoderN)r/   r0   r1   r   VisibleStringr2   r,   r'   r%   r[  r[    rH  r'   r[  c                   .    e Zd Z ej                         Zy)GeneralStringPayloadDecoderN)r/   r0   r1   r   GeneralStringr2   r,   r'   r%   r^  r^    rH  r'   r^  c                   .    e Zd Z ej                         Zy)UniversalStringPayloadDecoderN)r/   r0   r1   r   UniversalStringr2   r,   r'   r%   ra  ra    rL  r'   ra  c                   .    e Zd Z ej                         Zy)BMPStringPayloadDecoderN)r/   r0   r1   r   	BMPStringr2   r,   r'   r%   rd  rd    rV  r'   rd  c                   .    e Zd Z ej                         Zy)ObjectDescriptorPayloadDecoderN)r/   r0   r1   r   ObjectDescriptorr2   r,   r'   r%   rg  rg    s    ,V,,.Nr'   rg  c                   .    e Zd Z ej                         Zy)GeneralizedTimePayloadDecoderN)r/   r0   r1   r   GeneralizedTimer2   r,   r'   r%   rj  rj    s    +V++-Nr'   rj  c                   .    e Zd Z ej                         Zy)UTCTimePayloadDecoderN)r/   r0   r1   r   UTCTimer2   r,   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 r7   )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  }||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)8NrI   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 decodingrc   r   r   )tagClassrS   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 rA   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poprp   r   scopesupportIndefLengthr
   rU   rV   EOO_SENTINELr   rJ   r;  r<  SEEK_CURrs  ru  rv  rw  r?   rq   r:  stStopstDecodeTagrl   r  r   r   Tagr   stDecodeLengthlistr   r   stGetValueDecoderstGetValueDecoderByTagstGetValueDecoderByAsn1SpecstDecodeValuestTryAsExplicitTagro   r/   pushr2   r   r8  presentTypesr   	skipTypesprettyPrintTyper   r9  r   r   r=   r)   r&   r   Asn1ItemprettyPrintrS   r   r  tagClassUniversalrawPayloadDecoderdefaultErrorStatestDumpRawValuedefaultRawDecoderstErrorCondition)#r   r   r   r   r    r!   r"   r#   r$   rI   eoo_candidater9  rx  tagCachetagSetCacherA   
isShortTag	firstByte
firstOctetlastTag
integerTagr  rS   r  lengthOctetIdxintegerBytesizeencodedLengthlengthOctetconcreteDecoder
chosenSpecr  
baseTagSetr}   	bytesReads#                                      r%   __call__zSingleItemDecoder.__call__	  s
    
 ;;z51 UFI>? @
 //!/	1g!Fm-CD'' "G ,67oo% r2;;/-->>''#,>>#3	 6!#!
!/	1g!FI!)-CD' "G !^
&7&z2GN >!=%0%<F "%B!8 %v-F&>GH&"0Aw"GJ!*.DE(( #H !_
#'F#%%,D)7	4)Q%m5KL"// *R %)$7M =)T1#::-13}3EvN  F'41+- (5 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-JMJ
AKK<P<P QR .K $-- 23191C1C1I1I1K
A #J@T@T$U V 2L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#-k;Q#R*5$5 0U $/&+&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)r/   r0   r1   r  r  r6  r  r  rr  rt  r   rz  r  r  r,   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 )Nr,   )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r7   )r  r  r  r  r   rU   rV   )r   r+   r8   s      r%   __iter__zStreamingDecoder.__iter__  su     5d55OOT^^F7;}}F
  F 't7e%;<	 8  s   A0A2r7   )r/   r0   r1   __doc__rp  r  rz  r  r,   r'   r%   r   r   b  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_nextrU   ioBytesIOr   _callSubstrateFunV4asV5)r+   r   r    r$   substrate_gen_valuerA   origSubstrateFuns          r%   substrateFunWrapperz-Decoder.__call__.<locals>.substrateFunWrapper!  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'   r7   )r   STREAMING_DECODERrU   rV   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_bytesrA   nextSubstratenbytess           r%   r  zDecoder._callSubstrateFunV4asV5E  si     #..*R<)F-j/6R}/w,s   A5A7r7   )
r/   r0   r1   r  r   r  classmethodr  r3   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        |       )Nrr  rt  )r9  rx  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__registerLoggeer/   DEBUG_DECODERrp   r?   rV   objectr   r5   rD   r  rN   r\   ra   rz   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  rZ   r   r_   rx   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  rL   rt  valuestypeDecoderr2   ro   ranger  r  r  r  r  r  r  r  r  r  rY   r  rp  r   r   r   strr  )xs   0r%   <module>r     sC   
 	 
      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 .7F%A 7Ft-I < -I`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!y!Ay!		 V}h hV`v `FIf ID 
c q "s   =	Y