Ņō
BwLc           @   sh   d  d k  l Z l Z d d d g Z d d	 d     YZ d e f d     YZ d e f d     YZ d S(
   iĸĸĸĸ(   t   long_to_bytest   bytes_to_longt	   DerObjectt
   DerIntegert   DerSequencec           B   sV   e  Z h d  d 6d d 6d d 6Z d d  Z d   Z d   Z d	   Z d
 d  Z RS(   t   0t   SEQUENCEs   s
   BIT STRINGs   t   INTEGERc         C   s%   |  i  i | |  |  _ d |  _ d  S(   Nt    (   t   typeTagst   gett   typeTagt   payload(   t   selft   ASN1Type(    (    sO   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Util\asn1.pyt   __init__   s    c         C   s<   | d j o% t  |  } t t |  d  | St |  S(   s   
		Return an octet string that is suitable for the BER/DER
		length element if the relevant payload is of the given
		size (in bytes).
		i   i   (   R    t   chrt   len(   R   t
   payloadLent   encoding(    (    sO   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Util\asn1.pyt   _lengthOctets"   s    c         C   s$   |  i  |  i t |  i   |  i S(   N(   R   R   R   R   (   R   (    (    sO   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Util\asn1.pyt   encode-   s    c         C   s   t  | |  } | d j o | | d f St | | d | d | d @! } | d j o t d   n | | d | d @f Sd S(   s   
		Given a string and an index to a DER LV,
		this function returns a tuple with the length of V
		and an index to the first byte of it.
		i   i   s   Not a DER length tag.N(   t   ordR   t
   ValueError(   R   t   idxt   strt   lengtht   payloadLength(    (    sO   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Util\asn1.pyt
   _decodeLen0   s    #i    c         C   sŋ   y | d |  _  t |  i   d @d j o t d   n |  i d |  \ } } | o' t |  | | j o t d   n | | | | !|  _ Wn t j
 o t d   n X| | S(   Ni    i   s   Unsupported DER tagi   s   Not a DER structures   Not a valid DER SEQUENCE.(   R   R   R   R   R   R   t
   IndexError(   R   t   inputt   noLeftOversR   R   (    (    sO   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Util\asn1.pyt   decode?   s    N(	   t   __name__t
   __module__R	   t   NoneR   R   R   R   R    (    (    (    sO   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Util\asn1.pyR      s   			c           B   s)   e  Z d  d  Z d   Z d  d  Z RS(   i    c         C   s   t  i |  d  | |  _ d  S(   NR   (   R   R   t   value(   R   R$   (    (    sO   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Util\asn1.pyR   M   s    c         C   sM   t  |  i  |  _ t |  i d  d j o d |  i |  _ n t i |   S(   Ni    i   t    (   R    R$   R   R   R   R   (   R   (    (    sO   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Util\asn1.pyR   Q   s    c         C   sU   t  i |  | |  } t |  i d  d j o t d   n t |  i  |  _ | S(   Ni    i   s   Negative INTEGER.(   R   R    R   R   R   R   R$   (   R   R   R   t	   tlvLength(    (    sO   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Util\asn1.pyR    W   s
    (   R!   R"   R   R   R    (    (    (    sO   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Util\asn1.pyR   L   s   	c           B   sw   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d d  Z RS(   c         C   s   t  i |  d  g  |  _ d  S(   NR   (   R   R   t   _seq(   R   (    (    sO   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Util\asn1.pyR   _   s    c         C   s   |  i  | =d  S(   N(   R'   (   R   t   n(    (    sO   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Util\asn1.pyt   __delitem__b   s    c         C   s   |  i  | S(   N(   R'   (   R   R(   (    (    sO   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Util\asn1.pyt   __getitem__d   s    c         C   s   | |  i  | <d  S(   N(   R'   (   R   t   keyR$   (    (    sO   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Util\asn1.pyt   __setitem__f   s    c         C   s   | |  i  | | +d  S(   N(   R'   (   R   t   it   jt   sequence(    (    sO   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Util\asn1.pyt   __setslice__h   s    c         C   s   |  i  | | 5d  S(   N(   R'   (   R   R-   R.   (    (    sO   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Util\asn1.pyt   __delslice__j   s    c         C   s    |  i  t d |  t d |  !S(   Ni    (   R'   t   max(   R   R-   R.   (    (    sO   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Util\asn1.pyt   __getslice__l   s    c         C   s   t  |  i  S(   N(   R   R'   (   R   (    (    sO   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Util\asn1.pyt   __len__n   s    c         C   s   |  i  i |  S(   N(   R'   t   append(   R   t   item(    (    sO   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Util\asn1.pyR5   p   s    c         C   sR   |  i  p d Sd } x6 |  i  D]+ } y | | 7} Wq t j
 o d SXq Wd S(   Ni    i   (   R'   t	   TypeError(   R   t   testR6   (    (    sO   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Util\asn1.pyt   hasOnlyIntss   s    
 
 
c         C   s|   d |  _  xc |  i D]X } y |  i  | 7_  Wq y |  i  t |  i   7_  Wqk t d   qk Xq Xq Wt i |   S(   s{   
		Return the DER encoding for the ASN.1 SEQUENCE containing
		the non-negative integers and longs added to this object.
		R   s&   Trying to DER encode an unknown object(   R   R'   R   R   R   R   (   R   R6   (    (    sO   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Util\asn1.pyR   }   s    	
 i    c   	      C   s5  g  |  _  yt i |  | |  } |  i |  i d j o t d   n d } x― | t |  i  j  oĶ |  i | } | |  i d j o: t   } | | i |  i |  7} |  i  i	 | i
  qQ |  i | d |  i  \ } } |  i  i	 |  i | | | ! | | } qQ WWn t j
 o t d   n X| S(   sė   
		This function decodes the given string into a sequence of
		ASN.1 objects. Yet, we only know about unsigned INTEGERs.
		Any other type is stored as its rough TLV. In the latter
		case, the correctectness of the TLV is not checked.
		R   s   Not a DER SEQUENCE.i    R   i   s   Not a valid DER SEQUENCE.(   R'   R   R    R   R	   R   R   R   R   R5   R$   R   R   (	   R   R   R   R&   R   R   t
   newIntegert   itemLent   itemIdx(    (    sO   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Util\asn1.pyR       s&    	 	(   R!   R"   R   R)   R*   R,   R0   R1   R3   R4   R5   R9   R   R    (    (    (    sO   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Util\asn1.pyR   ^   s   										
	N(    (   t   Crypto.Util.numberR    R   t   __all__R   R   R   (    (    (    sO   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Util\asn1.pyt   <module>   s   1