Package paramiko :: Module ecdsakey :: Class ECDSAKey
[frames] | no frames]

Class ECDSAKey

source code

object --+    
         |    
 pkey.PKey --+
             |
            ECDSAKey

Representation of an ECDSA key which can be used to sign and verify SSH2 data.

Instance Methods
 
__init__(self, msg=None, data=None, filename=None, password=None, vals=None, file_obj=None)
Create a new instance of this public key type.
source code
 
asbytes(self)
Return a string of an SSH `.Message` made up of the public part(s) of this key.
source code
 
__str__(self)
str(x)
source code
 
__hash__(self)
hash(x)
source code
 
get_name(self)
Return the name of this private key implementation.
source code
 
get_bits(self)
Return the number of significant bits in this key.
source code
 
can_sign(self)
Return ``True`` if this key has the private part necessary for signing data.
source code
 
sign_ssh_data(self, data)
Sign a blob of data with this private key, and return a `.Message` representing an SSH signature message.
source code
 
verify_ssh_sig(self, data, msg)
Given a blob of data, and an SSH message representing a signature of that data, verify that it was signed with this key.
source code
 
write_private_key_file(self, filename, password=None)
Write private key contents into a file.
source code
 
write_private_key(self, file_obj, password=None)
Write private key contents into a file (or file-like) object.
source code

Inherited from pkey.PKey: __cmp__, __eq__, get_base64, get_fingerprint

Inherited from object: __delattr__, __format__, __getattribute__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Class Methods

Inherited from pkey.PKey: from_private_key, from_private_key_file

Static Methods
RSAKey
generate(bits, progress_func=None)
Generate a new private RSA key.
source code
Class Variables
  ALLOWED_PADDINGS = ['\x01', '\x02\x02', '\x03\x03\x03', '\x04\...
Properties

Inherited from object: __class__

Method Details

__init__(self, msg=None, data=None, filename=None, password=None, vals=None, file_obj=None)
(Constructor)

source code 

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.

Overrides: object.__init__
(inherited documentation)

asbytes(self)

source code 

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.

Overrides: pkey.PKey.asbytes
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

__hash__(self)
(Hashing function)

source code 

hash(x)

Overrides: object.__hash__
(inherited documentation)

get_name(self)

source code 

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"``).

Overrides: pkey.PKey.get_name
(inherited documentation)

get_bits(self)

source code 

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`)

Overrides: pkey.PKey.get_bits
(inherited documentation)

can_sign(self)

source code 

Return ``True`` if this key has the private part necessary for signing data.

Overrides: pkey.PKey.can_sign
(inherited documentation)

sign_ssh_data(self, data)

source code 

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>`.

Overrides: pkey.PKey.sign_ssh_data
(inherited documentation)

verify_ssh_sig(self, data, msg)

source code 

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.

Overrides: pkey.PKey.verify_ssh_sig
(inherited documentation)

write_private_key_file(self, filename, password=None)

source code 

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

Overrides: pkey.PKey.write_private_key_file
(inherited documentation)

write_private_key(self, file_obj, password=None)

source code 

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 file_obj: the file 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

Overrides: pkey.PKey.write_private_key
(inherited documentation)

generate(bits, progress_func=None)
Static Method

source code 

Generate a new private RSA key. This factory function can be used to generate a new host key or authentication key.

Parameters:
  • bits (int) - number of bits the generated key should be.
  • progress_func (function) - an optional function to call at key points in key generation (used by pyCrypto.PublicKey).
Returns: RSAKey
new private key

Class Variable Details

ALLOWED_PADDINGS

Value:
['\x01',
 '\x02\x02',
 '\x03\x03\x03',
 '\x04\x04\x04\x04',
 '\x05\x05\x05\x05\x05',
 '\x06\x06\x06\x06\x06\x06',
 '\x07\x07\x07\x07\x07\x07\x07']