Ñò
ðgcJc           @   s    d  Z  d d k l Z d d k l Z d d k Td d k l Z d d k l	 Z	 d d k
 l Z d d k l Z l Z d d	 k l Z d
 e f d „  ƒ  YZ d S(   s   
L{DSSKey}
iÿÿÿÿ(   t   DSA(   t   SHA(   t   *(   t   util(   t   SSHException(   t   Message(   t   BERt   BERException(   t   PKeyt   DSSKeyc           B   s¿   e  Z d  Z d d d d d d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z d d
 „ Z d d „ Z d d d „ Z e e ƒ Z d „  Z d „  Z d „  Z RS(   sX   
    Representation of a DSS key which can be used to sign an verify SSH2
    data.
    c         C   s_  d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ | d  j	 o |  i | | ƒ d  S| d  j	 o |  i | | ƒ d  S| d  j o | d  j	 o t | ƒ } n | d  j	 o" | \ |  _ |  _ |  _ |  _ n} | d  j o t	 d ƒ ‚ n | i
 ƒ  d j o t	 d ƒ ‚ n | i ƒ  |  _ | i ƒ  |  _ | i ƒ  |  _ | i ƒ  |  _ t i |  i ƒ |  _ d  S(   Ns   Key object may not be emptys   ssh-dsss   Invalid key(   t   Nonet   pt   qt   gt   yt   xt   _from_private_keyt   _from_private_key_fileR   R   t
   get_stringt	   get_mpintR   t
   bit_lengtht   size(   t   selft   msgt   datat   filenamet   passwordt   valst   file_obj(    (    sN   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\dsskey.pyt   __init__(   s0    					"c         C   s`   t  ƒ  } | i d ƒ | i |  i ƒ | i |  i ƒ | i |  i ƒ | i |  i ƒ t | ƒ S(   Ns   ssh-dss(   R   t
   add_stringt	   add_mpintR   R   R   R   t   str(   R   t   m(    (    sN   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\dsskey.pyt   __str__C   s    	c         C   sx   t  |  i ƒ  ƒ } | d t  |  i ƒ } | d t  |  i ƒ } | d t  |  i ƒ } | d t  |  i ƒ } t  | ƒ S(   Ni%   (   t   hasht   get_nameR   R   R   R   (   R   t   h(    (    sN   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\dsskey.pyt   __hash__L   s    c         C   s   d S(   Ns   ssh-dss(    (   R   (    (    sN   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\dsskey.pyR$   U   s    c         C   s   |  i  S(   N(   R   (   R   (    (    sN   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\dsskey.pyt   get_bitsX   s    c         C   s   |  i  d  j	 S(   N(   R   R
   (   R   (    (    sN   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\dsskey.pyt   can_sign[   s    c         C   s˜  t  i | ƒ i ƒ  } t i t |  i ƒ t |  i ƒ t |  i ƒ t |  i	 ƒ t |  i
 ƒ f ƒ } t t i |  i	 d ƒ ƒ } xI t oA t i | i | ƒ d ƒ } | d j o | |  i	 j  o Pq~ q~ W| i t i | d ƒ | ƒ \ } } t ƒ  }	 |	 i d ƒ t i | d ƒ }
 t i | d ƒ } t |
 ƒ d j  o d d t |
 ƒ |
 }
 n t | ƒ d j  o d d t | ƒ | } n |	 i |
 | ƒ |	 S(   Ni    i   i   s   ssh-dssi   t    (   R   t   newt   digestR    t	   constructt   longR   R   R   R   R   t   lenR   t   deflate_longt   Truet   inflate_longt	   get_bytest   signR   R   (   R   t   rpoolR   R+   t   dsst   qsizet   kt   rt   sR!   t   rstrt   sstr(    (    sN   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\dsskey.pyt   sign_ssh_data^   s&    K 
$	c   	      C   sõ   t  t | ƒ ƒ d j o t | ƒ } n+ | i ƒ  } | d j o d S| i ƒ  } t i | d  d ƒ } t i | d d ƒ } t i t i | ƒ i ƒ  d ƒ } t i	 t
 |  i ƒ t
 |  i ƒ t
 |  i ƒ t
 |  i ƒ f ƒ } | i | | | f ƒ S(   Ni(   s   ssh-dssi    i   i   (   R.   R    R   R   R1   R   R*   R+   R    R,   R-   R   R   R   R   t   verify(	   R   R   R   t   sigt   kindt   sigRt   sigSt   sigMR5   (    (    sN   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\dsskey.pyt   verify_ssh_sigt   s    !?c         C   s   |  i  d  j o t d ƒ ‚ n d |  i |  i |  i |  i |  i  g } y t ƒ  } | i | ƒ Wn t	 j
 o t d ƒ ‚ n Xt
 | ƒ S(   Ns   Not enough key informationi    s$   Unable to create ber encoding of key(   R   R
   R   R   R   R   R   R   t   encodeR   R    (   R   t   keylistt   b(    (    sN   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\dsskey.pyt   _encode_key†   s    '	c         C   s    |  i  d | |  i ƒ  | ƒ d  S(   NR    (   t   _write_private_key_fileRG   (   R   R   R   (    (    sN   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\dsskey.pyt   write_private_key_file‘   s    c         C   s    |  i  d | |  i ƒ  | ƒ d  S(   NR    (   t   _write_private_keyRG   (   R   R   R   (    (    sN   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\dsskey.pyt   write_private_key”   s    i   c         C   sY   t  i ƒ  t i |  t  i | ƒ } t d | i | i | i | i	 f ƒ } | i
 | _
 | S(   sÑ  
        Generate a new private DSS key.  This factory function can be used to
        generate a new host key or authentication key.

        @param bits: number of bits the generated key should be.
        @type bits: int
        @param progress_func: an optional function to call at key points in
            key generation (used by C{pyCrypto.PublicKey}).
        @type progress_func: function
        @return: new private key
        @rtype: L{DSSKey}
        R   (   t   randpoolt   stirR    t   generateR2   R	   R   R   R   R   R   (   t   bitst   progress_funct   dsat   key(    (    sN   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\dsskey.pyRN   —   s
    
'c         C   s&   |  i  d | | ƒ } |  i | ƒ d  S(   NR    (   t   _read_private_key_filet   _decode_key(   R   R   R   R   (    (    sN   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\dsskey.pyR   ¯   s    c         C   s&   |  i  d | | ƒ } |  i | ƒ d  S(   NR    (   t   _read_private_keyRT   (   R   R   R   R   (    (    sN   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\dsskey.pyR   ³   s    c         C   så   y t  | ƒ i ƒ  } Wn+ t j
 o } t d t | ƒ ƒ ‚ n Xt | ƒ t j	 p$ t | ƒ d j  p | d d j o t d ƒ ‚ n | d |  _ | d |  _	 | d |  _
 | d |  _ | d	 |  _ t i |  i ƒ |  _ d  S(
   Ns   Unable to parse key file: i   i    s3   not a valid DSA private key file (bad ber encoding)i   i   i   i   i   (   R   t   decodeR   R   R    t   typet   listR.   R   R   R   R   R   R   R   R   (   R   R   RE   R   (    (    sN   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\dsskey.pyRT   ·   s    7N(   t   __name__t
   __module__t   __doc__R
   R   R"   R&   R$   R'   R(   R<   RC   RG   RI   RK   RN   t   staticmethodR   R   RT   (    (    (    sN   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\dsskey.pyR	   "   s"   												N(   R[   t   Crypto.PublicKeyR    t   Crypto.HashR   t   paramiko.commont   paramikoR   t   paramiko.ssh_exceptionR   t   paramiko.messageR   t   paramiko.berR   R   t   paramiko.pkeyR   R	   (    (    (    sN   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\dsskey.pyt   <module>   s   
