
    2i;                       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 d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$      Z0 G d. d/e0      Z1 G d0 d1e1      Z2 G d2 d3e2      Z3 G d4 d5e2      Z4 G d6 d7e1      Z5 G d8 d9e5      Z6 G d: d;e5      Z7 G d< d=e1      Z8 G d> d?e%      Z9 G d@ dAe+      Z: 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+      ZA G dP dQe+      ZB G dR dSe+      ZC G dT dUe+      ZD G dV dWe+      ZE G dX dYe+      ZF G dZ d[e+      ZGi 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                   e8       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       ej                  j                   eF       ej                  j                   eG       i	Zcej                  j                   e6       ej                  j                   e7       ej                  j                   e3       ej                  j                   e4       ej                  j                   e8       ej                  j                   e9       iZhecj                         D ]<  Zjejj                  ejj                  j                  j                  Zded3edehvs8ejehed<   >  emd\      D  cg c]  } |  c} \
  ZnZoZpZqZrZsZtZuZvZw exd]      Zy G d^ d_e#      Zz G d` dae#      Z{ G db dce#      Z| e|       Z}dde~fdeZyc c} w )f    N)debug)error)eoo)asSeekableStream)isEndOfStream)peekIntoStreamreadFromStream)_MISSING)PyAsn1Error)base)char)tag)tagmap)univ)useful)StreamingDecoderDecoderdecode)flags   d      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	            `/var/www/html/marco-python-backend/venv/lib/python3.12/site-packages/pyasn1/codec/ber/decoder.pyvalueDecoderz#AbstractPayloadDecoder.valueDecoder0   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.indefLenValueDecoder:   s     [a cddr*   c                     d|vr| |d<   |S )N
asn1Object )r.   r'   s     r(   _passAsn1Objectz&AbstractPayloadDecoder._passAsn1ObjectD   s    w&$.GL!r*   NNNNN)__name__
__module____qualname__protoComponentr)   r,   staticmethodr0   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.substrateCollectorM   s#     #Ivw? 	EK	s   c                     |j                  d      r|S || j                  j                  ||      S |t        u r|S |j                  |      S )Nnativer"   )getr5   clonenoValuer   r!   r"   valuer'   s        r(   _createComponentz-AbstractSimplePayloadDecoder._createComponentR   sQ    ;;x L&&,,U6,BBgO>>%((r*   N)r2   r3   r4   r6   r<   rE   r/   r*   r(   r8   r8   L   s     )r*   r8   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)NrH   )rE   r   r    r!   r"   r#   r$   r%   r&   r'   r.   r;   rD   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)NrH   TallowEoo)rE   r   endOfOctetsrJ   s               r(   r,   z&RawPayloadDecoder.indefLenValueDecodero   s      ...xOwOJ%j)VWM  "x.!.%,.  COO+ s   AAr1   r2   r3   r4   r   Anyr5   r)   r,   r/   r*   r(   rG   rG   ]   s,    TXXb\N 6:26  >B:>r*   rG   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bytesrE   )r   r    r!   r"   r#   r$   r%   r&   r'   r;   rD   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r1   )r2   r3   r4   r   Integerr5   r)   r/   r*   r(   rQ   rQ      s    !T\\!_N 6:26Hr*   rQ   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   )rQ   rE   rC   s        r(   rE   z&BooleanPayloadDecoder._createComponent   s2    $55(FEKa$41A8?A 	Ar*   N)r2   r3   r4   r   Booleanr5   rE   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   ra      Trailing bits overflow %sT)internalFormatpadding*Constructed encoding form prohibited at %s$assembling constructed serializationr*   rh   r&   rh   prependri   )rE   rB   r   r   r   rX   rY   rV   r   rW   r
   ordr5   fromOctetStringsupportConstructedForm	__class__r2   LOGr<   tell)r   r    r!   r"   r#   r$   r%   r&   r'   r.   r;   trailingBitsrD   	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*   Trl   r&   rL   r   rf   rg   ra   rm   )rE   rB   r<   r5   rp   r   rM   rX   rY   r   r   )r   r    r!   r"   r#   r$   r%   r&   r'   r.   r;   rv   rx   ru   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r1   )	r2   r3   r4   r   	BitStringr5   rq   r)   r,   r/   r*   r(   rd   rd      s7    #T^^B'N! 6:26NLb >B:>,Lr*   rd   c                   L    e Zd Z ej                  d      ZdZ	 	 ddZ	 	 ddZy)OctetStringPayloadDecoderrH   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   rj   rk   r*   r&   )rE   rB   rV   r   rW   r
   rX   rY   rq   r   r   rr   r2   rs   r<   rt   r5   )r   r    r!   r"   r#   r$   r%   r&   r'   r.   r;   headeroriginal_positionrx   s                 r(   r)   z&OctetStringPayloadDecoder.valueDecoder0  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*   Trz   )r<   rE   rB   r5   rX   rY   r   rM   )r   r    r!   r"   r#   r$   r%   r&   r'   r.   r;   r   rx   s                r(   r,   z.OctetStringPayloadDecoder.indefLenValueDecoder]  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r1   )	r2   r3   r4   r   OctetStringr5   rq   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)NullPayloadDecoderrH   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   rS   rH   z&Unexpected %d-octet substrate for Null)	rV   r   rW   r   r   r
   rX   rY   rE   )r   r    r!   r"   r#   r$   r%   r&   r'   r;   rx   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r1   )r2   r3   r4   r   Nullr5   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   rS   Empty substrater/   ra      zEOID arc exceeds maximum continuation octets limit (%d) at position %drf      !Short substrate for sub-OID past z"Invalid octet 0x80 in OID encoding'   )r   (   O   P      zMalformed first OID octet: %srV   r   rW   r   r   r
   rX   rY   lenMAX_OID_ARC_CONTINUATION_OCTETSrE   )r   r    r!   r"   r#   r$   r%   r&   r'   r;   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r1   )r2   r3   r4   r   ObjectIdentifierr5   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   rS   r   r/   ra   r   zNRELATIVE-OID arc exceeds maximum continuation octets limit (%d) at position %drf   r   r   z+Invalid octet 0x80 in RELATIVE-OID encodingr   )r   r    r!   r"   r#   r$   r%   r&   r'   r;   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r1   )r2   r3   r4   r   RelativeOIDr5   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   rS   g        ra   r   zIncomplete floating-point valuezdecoding binary encoded REAL      zReal exponent screwedr   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))rV   r   rW   r   r   r
   rX   rY   rE   rs   rZ   float
ValueError)r   r    r!   r"   r#   r$   r%   r&   r'   r;   foneoebpsfrD   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>r1   )r2   r3   r4   r   Realr5   r)   r/   r*   r(   r   r     s    TYY[N 6:26hHr*   r   c                       e Zd ZdZy)!AbstractConstructedPayloadDecoderN)r2   r3   r4   r5   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         r:   NotImplementedError)r   r.   idxs      r(   _getComponentTagMapz1ConstructedPayloadDecoderBase._getComponentTagMap      !!r*   c                     t         r:   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   ra   r?   z@guessed %r container type (pass `asn1Spec` to guide the decoder)FverifyConstraints	matchTagsmatchConstraints)setrt   rX   rY   r   rM   appendaddr"   r   protoRecordComponentprotoSequenceComponentrA   r   TagSetbaseTag	superTagsrs   	enumeratesetComponentByPosition)r   r    r"   r%   r#   r'   r.   
componentscomponentTypesr   rx   r5   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-rH   deterministic SET type  chosen by type ID Excessive components decoded at Fr   ra   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`):rV   r   tagFormatConstructedr   r   rt   rA   r5   r   r   r   rX   rY   rs   r
   r   r   hexdumpclearr0   typeIdr   SequenceSetcomponentTypehasOptionalOrDefaultr   tagMapUniquer.   
isOptionalisDefaultedgetTagMapNearPosition
IndexErrorgetPositionByTypeeffectiveTagSetgetPositionNearTyper   r   requiredComponentsissubsetrr   r2   hasOpenTypesr@   itemsr   
namedTypesopenTypegetComponentByPositionisValuegetComponentByNamenameKeyErrorSetOf
SequenceOfr   asOctetsisInconsistent)r   r    r!   r"   r#   r$   r%   r&   r'   r   r.   r;   trailingr  	isSetTypeisDeterministicseenIndicesr   r   rx   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rL   r   r   rH   r   r   r   r   r   rL   Fr   ra   r   r   r   r   r   r   r   r   r   r   r   r   r   r!   r   r   r   )9rV   r   r   r   r   rA   r5   r   r   r   dictrX   rY   r   r0   r   r   r   r   r   r   rs   r   r   r   r.   r   r   r   r   r   rM   r   r   r   r   r   r   r   rr   r2   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;   r  r  r  r  r   rx   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^])(^)^^^
^^^^^)NNNr1   )
r2   r3   r4   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)r2   r3   r4   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)r2   r3   r4   r   r   r5   r/   r*   r(   r!  r!    s    "T]]_Nr*   r!  c                   .    e Zd Z ej                         Zy)SequenceOfPayloadDecoderN)r2   r3   r4   r   r  r5   r/   r*   r(   r#  r#        $T__&Nr*   r#  c                   P    e Zd Z ej                         Z ej                         Zy)SetOrSetOfPayloadDecoderN)r2   r3   r4   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)r2   r3   r4   r   r   r5   r/   r*   r(   r(  r(    s    TXXZNr*   r(  c                   .    e Zd Z ej                         Zy)SetOfPayloadDecoderN)r2   r3   r4   r   r
  r5   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)
r5   rA   r0   r"   rs   componentTagMaprX   rY   r   setComponentByType)r   r    r!   r"   r#   r$   r%   r&   r'   r.   r;   rx   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/  Fr0  )r5   rA   r0   r"   rs   r   r   r  rX   rY   r   rM   r   r3  )r   r    r!   r"   r#   r$   r%   r&   r'   r.   r;   isTaggediteratorrx   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+r1   )r2   r3   r4   r   Choicer5   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)rr   r   TagMaptagMapr"   markedPositionrt   seekosSEEK_SETrs   r   rX   rY   r   r   rE   rB   r
   )r   r    r!   r"   r#   r$   r%   r&   r'   
isUntaggedfullPositioncurrentPositionr;   s                r(   r)   zAnyPayloadDecoder.valueDecoder  sR     J6==0x6J  8??2J$33L'nn.ONN<5o44F+Iv> $E!%)?@#$   ==/0 1 %)D))(FGOwOvw0  
 #Ivw? 	E%!78	 $d##HfeGwGGs   B+E.A5E$Ec              +     K   |d}	n:|j                   t        j                  u r||j                  v }	n||j                  k(  }	|	r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 %srk   Trz   )rr   r   r<  r=  r"   rs   r>  rt   r?  r@  rA  r
   rX   rY   r   r   r5   r<   rE   rB   r   r   rM   )r   r    r!   r"   r#   r$   r%   r&   r'   r6  r;   rC  rD  r.   rx   s                  r(   r,   z&AnyPayloadDecoder.indefLenValueDecoderG  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r1   rN   r/   r*   r(   r:  r:    s.    TXXZN 6:26'HT >B:>ILr*   r:  c                   .    e Zd Z ej                         Zy)UTF8StringPayloadDecoderN)r2   r3   r4   r   
UTF8Stringr5   r/   r*   r(   rG  rG    r$  r*   rG  c                   .    e Zd Z ej                         Zy)NumericStringPayloadDecoderN)r2   r3   r4   r   NumericStringr5   r/   r*   r(   rJ  rJ        'T'')Nr*   rJ  c                   .    e Zd Z ej                         Zy)PrintableStringPayloadDecoderN)r2   r3   r4   r   PrintableStringr5   r/   r*   r(   rN  rN        )T))+Nr*   rN  c                   .    e Zd Z ej                         Zy)TeletexStringPayloadDecoderN)r2   r3   r4   r   TeletexStringr5   r/   r*   r(   rR  rR    rL  r*   rR  c                   .    e Zd Z ej                         Zy)VideotexStringPayloadDecoderN)r2   r3   r4   r   VideotexStringr5   r/   r*   r(   rU  rU    s    (T((*Nr*   rU  c                   .    e Zd Z ej                         Zy)IA5StringPayloadDecoderN)r2   r3   r4   r   	IA5Stringr5   r/   r*   r(   rX  rX        #T^^%Nr*   rX  c                   .    e Zd Z ej                         Zy)GraphicStringPayloadDecoderN)r2   r3   r4   r   GraphicStringr5   r/   r*   r(   r\  r\    rL  r*   r\  c                   .    e Zd Z ej                         Zy)VisibleStringPayloadDecoderN)r2   r3   r4   r   VisibleStringr5   r/   r*   r(   r_  r_    rL  r*   r_  c                   .    e Zd Z ej                         Zy)GeneralStringPayloadDecoderN)r2   r3   r4   r   GeneralStringr5   r/   r*   r(   rb  rb    rL  r*   rb  c                   .    e Zd Z ej                         Zy)UniversalStringPayloadDecoderN)r2   r3   r4   r   UniversalStringr5   r/   r*   r(   re  re    rP  r*   re  c                   .    e Zd Z ej                         Zy)BMPStringPayloadDecoderN)r2   r3   r4   r   	BMPStringr5   r/   r*   r(   rh  rh    rZ  r*   rh  c                   .    e Zd Z ej                         Zy)ObjectDescriptorPayloadDecoderN)r2   r3   r4   r   ObjectDescriptorr5   r/   r*   r(   rk  rk    s    ,V,,.Nr*   rk  c                   .    e Zd Z ej                         Zy)GeneralizedTimePayloadDecoderN)r2   r3   r4   r   GeneralizedTimer5   r/   r*   r(   rn  rn    s    +V++-Nr*   rn  c                   .    e Zd Z ej                         Zy)UTCTimePayloadDecoderN)r2   r3   r4   r   UTCTimer5   r/   r*   r(   rq  rq    s    #V^^%Nr*   rq  r   )r   r   c                   J    e Zd ZeZ e       ZdZeZe	Z	e
e
fdZdddeddfdZy)SingleItemDecoderTc                     |t         ur|n| j                  | _        |t         ur|n| j                  | _        i | _        i | _        y r:   )r   TAG_MAP_tagMapTYPE_MAP_typeMap	_tagCache_tagSetCache)r   r=  typeMapignoreds       r(   __init__zSingleItemDecoder.__init__  s;    !'x!7vT\\#*(#: r*   Nc              +     K   |j                  dd      }	|	t        kD  rt        j                  dt        z        |	dz   |d<   |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/                         |_        |t2        ur |t4        u r{d}t        |d|      D ]  }t        |t              s|  t7              }	 ||   }| |r	 ||   }nt;        j>                  d|      }n||z   }t@        }t
        rt        d|z         |t@        u r,t        |d|      D ]  }t        |t              s|  t7              }|dk  r|}n|dkD  r|dz  }|tB        kD  rt        j                  d|tB        fz        t        |||      D ]  }t        |t              s|  tE              }tG        |      |k7  r&t        j                  |dtG        |      d|      d}|D ]  }|dz  }||z  } |dz  }nd}|dk(  r!| j                  st        j                  d      tH        }t
        rt        d|z         |tH        u r|tJ        }ntL        }|tJ        u r	 ||   }|rtN        }n	 ||d d    }|rtN        }ntP        }t
        rt        d|xr |jR                  jT                  xs dd|tN        u xr d xs d!       t        j                  jW                  |d u xr d"xs  |jX                  jR                  jT                         |tL        u r|jR                  tZ        j\                  u r	 ||   }t
        r$t        d#       |j^                  ja                         D ]*  \  }} t        d$|d%| jR                  jT                         , |jb                  rRt        d&       |jb                  ja                         D ]*  \  }} t        d$|d%| jR                  jT                         , t        d'|d u xr dxs |je                         d(|       nJ||jf                  k(  s||jh                  v r+|}t
        r%t        d)|jR                  jT                  z         nd }|@	 ||jj                     }t
        rt        d*|jj                         |r	|}tN        }ntP        }nd }tP        }t
        r~t        d|tN        u xr |jR                  jT                  xs dd,|tN        u xr d xs d!       t        j                  jW                  |d u xr d"xs |jR                  jT                         |tN        u rY|j                  d-d      s|sd. }|j/                         }"|dk(  r8 jn                  ||||tH        | |fi |D ]  }t        |t              s|  n| jp                  ||||tH        | |fi |D ]  }t        |t              s|  |j/                         |"z
  }#|s|#|k7  rt        d/|#d0|d1      |r|#|kD  rt        d/|#d2|d1      t
        rkt        d|jR                  jT                  d3|jR                  jT                  d4t        |tr        jt                        xr |jw                         xs |d5       t2        }n|tP        u r|rM|d   jx                  t:        jz                  k(  r-|d   j|                  t:        j~                  k7  rt        }tN        }nd }| j                  }t
        r;t        d|xr |jR                  jT                  xs dd6|tN        u xr d xs d7       |t        u r:| j                  }t
        r"t        d8|jR                  jT                  z         tN        }|t        u rt        j                  |d9|      |t2        ur t
        r:t        j                  j	                          t        d:t        j                  z         | y # t8        $ r |}|dz  }|dz  }|dz  }|dk(  rid}d}d}	 t        |d|      D ]  }t        |t              s|  st        j                  d      t7        |      }|dz  }|dz  }||dz  z  }|dz  snbt;        j<                  |||      }|r|||<   Y w xY w# t8        $ r t;        j>                  d|      }|||<   Y w xY w# t8        $ r d }Y ow xY w# t8        $ r d }Y ow xY w# t8        $ r d }Y w xY w# t8        $ rn t;        j>                  |jf                  jl                  |jf                  jl                        }!	 ||!   }t
        rt        d+|!       n# t8        $ r d }Y nw xY wY w xY ww);N_nestingLevelr   z0ASN.1 structure nesting depth exceeds limit (%d)ra   rL   FzWdecoder called at scope %s with state %d, working with up to %s octets of substrate: %sr   zend-of-octets sentinel foundTr          z'Short octet stream on long tag decodingrf   r   r   )tagClassrV   tagIdr/   z$tag decoded into %s, decoding lengthz+BER length field size %d exceeds limit (%d)<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 rD   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>.substrateFun7  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)Er@   MAX_NESTING_DEPTHr   r   poprs   r   scopesupportIndefLengthr
   rX   rY   EOO_SENTINELr   rM   r?  r@  SEEK_CURrw  ry  rz  r{  rB   rt   r>  stStopstDecodeTagro   r	  r   Tagr   stDecodeLengthMAX_LENGTH_OCTETSlistr   stGetValueDecoderstGetValueDecoderByTagstGetValueDecoderByAsn1SpecstDecodeValuestTryAsExplicitTagrr   r2   pushr5   r   r<  presentTypesr  	skipTypesprettyPrintTyper"   r=  r   r   r,   r)   r   Asn1ItemprettyPrintrV   r   r  tagClassUniversalrawPayloadDecoderdefaultErrorStatestDumpRawValuedefaultRawDecoderstErrorCondition)$r   r    r!   r"   r#   r$   r%   r&   r'   r  rL   eoo_candidater=  r|  tagCachetagSetCacherD   
isShortTag	firstByte
firstOctetlastTag
integerTagr  rV   r  lengthOctetIdxintegerBytesizeencodedLengthlengthOctetconcreteDecoder
chosenSpecr  
baseTagSetr   	bytesReads$                                       r(   __call__zSingleItemDecoder.__call__  s.    
  OQ7,,##BEVV  $11#4 ;;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//#//I $&7M9 9  *8	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 ]	 6!d	 KKOO7%++EFO	   #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=p   +&*O+ $ /*./$ $ *%)
*> $ 3%(ZZ
0A0A0I0IJL]L]LeLe%f
3.4Z.@O" #$U V' 3.2O33s>  B&h>)Ch>;h>b5 h>e# A h>=A*h>(B?h>(f -	h>7f  ?B<h><f2 D-h>/-g Dh> 7h>Gh>0Ah>5Ae <A e h>e  h>#$fh>
fh>fh>fh> f/+h>.f//h>2g=h> gh>Ah;h&%h;&h41h;3h44h;7h>:h;;h>)r2   r3   r4   r  r  r:  r  r  rv  rx  r   r~  r  r  r/   r*   r(   rt  rt    sB    ()+GH&  ,0Tddr*   rt  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r:   )r  r  r  r  r   rX   rY   )r   r.   r;   s      r(   __iter__zStreamingDecoder.__iter__  s~     5d55OOT^^F7;}}F !
  ! 't7 e%;<	  s   A0A2r:   )r2   r3   r4   __doc__rt  r  r~  r  r/   r*   r(   r   r     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_nextrX   ioBytesIOr   _callSubstrateFunV4asV5)r.   r    r#   r'   substrate_gen_valuerD   origSubstrateFuns          r(   substrateFunWrapperz-Decoder.__call__.<locals>.substrateFunWrapperE  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*   r:   )r   STREAMING_DECODERrX   rY   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_bytesrD   nextSubstratenbytess           r(   r  zDecoder._callSubstrateFunV4asV5i  si     #..*R<)F-j/6R}/w,s   A5A7r:   )
r2   r3   r4   r  r   r  classmethodr  r6   r  r/   r*   r(   r   r     s8     )v$ v$p  r*   r   attrc                     dddj                  |       x}r/t        j                  |  d| dt        d       t	               |   S t        |       )Nrv  rx  )r=  r|  z is deprecated. Please use z	 instead.r   )
stacklevel)r@   warningswarnDeprecationWarningglobalsAttributeError)r  newAttrs     r(   __getattr__r    sU    &:>BB4HHwH9')LN`mno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__registerLoggeer2   DEBUG_DECODERrs   rB   rY   r   r  r  objectr   r8   rG   r  rQ   r_   rd   r}   r   r   r   r   r   r   r  r!  r#  r&  r(  r*  r,  r:  rG  rJ  rN  rR  rU  rX  r\  r_  rb  re  rh  rk  rn  rq  r]   r"   rb   r{   r   r   r   r   
Enumeratedr   r   r   r8  rH  rK  rO  rS  rV  rY  r]  r`  rc  rf  ri  rl  ro  rr  rv  r   r
  r  rO   rx  valuestypeDecoderr5   rr   ranger  r  r  r  r  r  r  r  r  r  r\   r  rt  r   r   r   strr  )xs   0r(   <module>r     sZ   
 	 
      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}v vr`v `FIf ID 
c M "s   	Y