Repository URL to install this package:
|
Version:
3.3.30 ▾
|
ó
°EYc @ sì d Z d d l Z d d l m 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 m
Z
m Z d d l m Z d d l m Z d d
l m Z m Z m Z m Z d d l m Z m Z d e f d
YZ d S( s!
Common API for all public keys.
iÿÿÿÿN( t unhexlify( t md5( t default_backend( t
serialization( t
algorithmst modest Cipher( t util( t o600( t ut encodebytest decodebytest b( t SSHExceptiont PasswordRequiredExceptiont PKeyc B sm e Z d Z i i e j d 6d d 6d d 6e j d 6d 6i e j d 6d d 6d d 6e j d 6d 6i e j d 6d d 6d
d 6e j d 6d 6Z d d d Z
d
Z d Z d Z
d Z d Z d Z d Z d Z d Z d Z d Z e d d Z e d d Z d d Z d d Z d d Z d d Z d d Z d d Z RS(! s%
Base class for public keys.
t cipheri t keysizet blocksizet modes AES-128-CBCi s AES-256-CBCi i s DES-EDE3-CBCc C s d S( s[
Create a new instance of this public key type. If ``msg`` is given,
the key's public part(s) will be filled in from the message. If
``data`` is given, the key's public part(s) will be filled in from
the string.
:param .Message msg:
an optional SSH `.Message` containing a public key of this type.
:param str data: an optional string containing a public key
of this type
:raises: `.SSHException` --
if a key cannot be created from the ``data`` or ``msg`` given, or
no key was passed in.
N( ( t selft msgt data( ( sB /home/tvault/.virtenv/lib/python2.7/site-packages/paramiko/pkey.pyt __init__A s c C s t S( sÇ
Return a string of an SSH `.Message` made up of the public part(s) of
this key. This string is suitable for passing to `__init__` to
re-create the key object later.
( t bytes( R ( ( sB /home/tvault/.virtenv/lib/python2.7/site-packages/paramiko/pkey.pyt asbytesS s c C s
| j S( N( R ( R ( ( sB /home/tvault/.virtenv/lib/python2.7/site-packages/paramiko/pkey.pyt __str__[ s c C sJ t | } t | } | | k r1 t | | St | j | j S( sB
Compare this key to another. Returns 0 if this key is equivalent to
the given key, or non-0 if they are different. Only the public parts
of the key are compared, so a public key will compare equal to its
corresponding private key.
:param .PKey other: key to compare to.
( t hasht cmpR ( R t othert hst ho( ( sB /home/tvault/.virtenv/lib/python2.7/site-packages/paramiko/pkey.pyt __cmp__a s
c C s t | t | k S( N( R ( R R ( ( sB /home/tvault/.virtenv/lib/python2.7/site-packages/paramiko/pkey.pyt __eq__p s c C s d S( sË
Return the name of this private key implementation.
:return:
name of this private key type, in SSH terminology, as a `str` (for
example, ``"ssh-rsa"``).
t ( ( R ( ( sB /home/tvault/.virtenv/lib/python2.7/site-packages/paramiko/pkey.pyt get_names s c C s d S( s¸
Return the number of significant bits in this key. This is useful
for judging the relative security of a key.
:return: bits in the key (as an `int`)
i ( ( R ( ( sB /home/tvault/.virtenv/lib/python2.7/site-packages/paramiko/pkey.pyt get_bits} s c C s t S( sf
Return ``True`` if this key has the private part necessary for signing
data.
( t False( R ( ( sB /home/tvault/.virtenv/lib/python2.7/site-packages/paramiko/pkey.pyt can_sign s c C s t | j j S( sã
Return an MD5 fingerprint of the public part of this key. Nothing
secret is revealed.
:return:
a 16-byte `string <str>` (binary) of the MD5 fingerprint, in SSH
format.
( R R t digest( R ( ( sB /home/tvault/.virtenv/lib/python2.7/site-packages/paramiko/pkey.pyt get_fingerprint s c C s" t t | j j d d S( s+
Return a base64 string containing the public part of this key. Nothing
secret is revealed. This format is compatible with that used to store
public key files or recognized host keys.
:return: a base64 `string <str>` containing the public part of the key.
s
R" ( R R
R t replace( R ( ( sB /home/tvault/.virtenv/lib/python2.7/site-packages/paramiko/pkey.pyt
get_base64 s c C s t S( sç
Sign a blob of data with this private key, and return a `.Message`
representing an SSH signature message.
:param str data: the data to sign.
:return: an SSH signature `message <.Message>`.
( R ( R R ( ( sB /home/tvault/.virtenv/lib/python2.7/site-packages/paramiko/pkey.pyt
sign_ssh_data¢ s c C s t S( s\
Given a blob of data, and an SSH message representing a signature of
that data, verify that it was signed with this key.
:param str data: the data that was signed.
:param .Message msg: an SSH signature message
:return:
``True`` if the signature verifies correctly; ``False`` otherwise.
( R% ( R R R ( ( sB /home/tvault/.virtenv/lib/python2.7/site-packages/paramiko/pkey.pyt verify_ssh_sig¬ s
c C s | d | d | } | S( s²
Create a key object by reading a private key file. If the private
key is encrypted and ``password`` is not ``None``, the given password
will be used to decrypt the key (otherwise `.PasswordRequiredException`
is thrown). Through the magic of Python, this factory method will
exist in all subclasses of PKey (such as `.RSAKey` or `.DSSKey`), but
is useless on the abstract PKey class.
:param str filename: name of the file to read
:param str password:
an optional password to use to decrypt the key file, if it's
encrypted
:return: a new `.PKey` based on the given private key
:raises: ``IOError`` -- if there was an error reading the file
:raises: `.PasswordRequiredException` -- if the private key file is
encrypted, and ``password`` is ``None``
:raises: `.SSHException` -- if the key file is invalid
t filenamet password( ( t clsR- R. t key( ( sB /home/tvault/.virtenv/lib/python2.7/site-packages/paramiko/pkey.pyt from_private_key_file¸ s c C s | d | d | } | S( s
Create a key object by reading a private key from a file (or file-like)
object. If the private key is encrypted and ``password`` is not
``None``, the given password will be used to decrypt the key (otherwise
`.PasswordRequiredException` is thrown).
:param file_obj: the file-like object to read from
:param str password:
an optional password to use to decrypt the key, if it's encrypted
:return: a new `.PKey` based on the given private key
:raises: ``IOError`` -- if there was an error reading the key
:raises: `.PasswordRequiredException` --
if the private key file is encrypted, and ``password`` is ``None``
:raises: `.SSHException` -- if the key file is invalid
t file_objR. ( ( R/ R2 R. R0 ( ( sB /home/tvault/.virtenv/lib/python2.7/site-packages/paramiko/pkey.pyt from_private_keyÐ s c C s t d d S( s
Write private key contents into a file. If the password is not
``None``, the key is encrypted before writing.
:param str filename: name of the file to write
:param str password:
an optional password to use to encrypt the key file
:raises: ``IOError`` -- if there was an error writing the file
:raises: `.SSHException` -- if the key is invalid
s Not implemented in PKeyN( t Exception( R R- R. ( ( sB /home/tvault/.virtenv/lib/python2.7/site-packages/paramiko/pkey.pyt write_private_key_fileå s c C s t d d S( s¬
Write private key contents into a file (or file-like) object. If the
password is not ``None``, the key is encrypted before writing.
:param file_obj: the file-like object to write into
:param str password: an optional password to use to encrypt the key
:raises: ``IOError`` -- if there was an error writing to the file
:raises: `.SSHException` -- if the key is invalid
s Not implemented in PKeyN( R4 ( R R2 R. ( ( sB /home/tvault/.virtenv/lib/python2.7/site-packages/paramiko/pkey.pyt write_private_keyó s c C s1 t | d } | j | | | } Wd QX| S( sí
Read an SSH2-format private key file, looking for a string of the type
``"BEGIN xxx PRIVATE KEY"`` for some ``xxx``, base64-decode the text we
find, and return it as a string. If the private key is encrypted and
``password`` is not ``None``, the given password will be used to
decrypt the key (otherwise `.PasswordRequiredException` is thrown).
:param str tag: ``"RSA"`` or ``"DSA"``, the tag used to mark the
data block.
:param str filename: name of the file to read.
:param str password:
an optional password to use to decrypt the key file, if it's
encrypted.
:return: data blob (`str`) that makes up the private key.
:raises: ``IOError`` -- if there was an error reading the file.
:raises: `.PasswordRequiredException` -- if the private key file is
encrypted, and ``password`` is ``None``.
:raises: `.SSHException` -- if the key file is invalid.
t rN( t opent _read_private_key( R t tagR- R. t fR ( ( sB /home/tvault/.virtenv/lib/python2.7/site-packages/paramiko/pkey.pyt _read_private_key_file s c C sæ | j } d } d | d } x6 | t | k rX | | j | k rX | d 7} q# W| t | k r t d | d n i } | d 7} xg | t | k rû | | j d } t | d k rÐ Pn | d j | | d j <| d 7} q W| } d | d }
x6 | t | k rH| | j |
k rH| d 7} qWy&