Package twisted :: Package conch :: Package ssh :: Module keys

[show private | hide private]
[frames | no frames]

## Module twisted.conch.ssh.keys

Handling of RSA and DSA keys.

This module is unstable.

Maintainer: Paul Swartz<mailto:z3p@twistedmatrix.com>

Exceptions
`BadKeyError` | raised when a key isn't what we expected from it.

Function Summary
| `des_cbc3_decrypt(src, key, iv)`
| `des_cbc3_encrypt(src, key, iv)`
| ``getPrivateKeyObject`(filename, data, passphrase)` Return a `Crypto.PublicKey.pubkey.pubkey`object corresponding to the private key file/data.
| `getPrivateKeyObject_lsh(data, passphrase)`
| `getPrivateKeyObject_openssh(data, passphrase)`
`Crypto.PublicKey.pubkey.pubkey` | ``getPublicKeyObject`(data)` Return a `Crypto.PublicKey.pubkey.pubkey`corresponding to the SSHv2 public key data.
`str` | ``getPublicKeyString`(filename, line, data)` Return a public key string given a filename or data of a public key.
| `getPublicKeyString_lsh(data)`
| `getPublicKeyString_openssh(data)`
| `lenSig(obj)`
`str` | ``makePrivateKeyString`(obj, passphrase, kind)` Return an OpenSSH-style private key for a `Crypto.PublicKey.pubkey.pubkey`object.
| `makePrivateKeyString_lsh(obj, passphrase)`
| `makePrivateKeyString_openssh(obj, passphrase)`
`str` | ``makePublicKeyString`(obj, comment, kind)` Return an public key given a `Crypto.PublicKey.pubkey.pubkey`object.
| `makePublicKeyString_lsh(obj)`
| `makePublicKeyString_openssh(obj, comment)`
`str` | ``objectType`(obj)` Return the SSH key type corresponding to a `Crypto.PublicKey.pubkey.pubkey`object.
| `pkcs1Digest(data, lMod)`
| `pkcs1Pad(data, lMod)`
| ``printKey`(obj)` Pretty print a `Crypto.PublicKey.pubkey.pubkey`object.
`str` | ``signData`(obj, data)` Sign the data with the given `Crypto.PublicKey.pubkey.pubkey`object.
| `signData_dsa(obj, data)`
| `signData_rsa(obj, data)`
`bool` | ``verifySignature`(obj, sig, data)` Verify that the signature for the data is valid.
| `verifySignature_dsa(obj, sig, data)`
| `verifySignature_rsa(obj, sig, data)`
| `_strxor(s1, s2)`

Variable Summary
`str` | `data`
`str` | `data2`
`str` | `enc`
`str` | `ID_SHA1`
`str` | `iv`
`str` | `key`

Function Details

### getPrivateKeyObject(filename=None, data='', passphrase='')

Return a `Crypto.PublicKey.pubkey.pubkey` object corresponding to the private key file/data. If the private key is encrypted, passphrase must be specified, other wise a `BadKeyError` will be raised.

  Parameters:
    `filename`
    (type=`str`)
    `data`
    (type=`str`)
    `passphrase`
    (type=`str`)
  Raises:
    `BadKeyError` - if the key is invalid or a passphrase is not specified

### getPublicKeyObject(data)

Return a `Crypto.PublicKey.pubkey.pubkey` corresponding to the SSHv2 public key data. data is in the over-the-wire public key format.

  Parameters:
    `data`
    (type=`str`)
  Returns:
    `Crypto.PublicKey.pubkey.pubkey`

### getPublicKeyString(filename=None, line=0, data='')

Return a public key string given a filename or data of a public key. Currently handles OpenSSH and LSH keys.

  Parameters:
    `filename`
    (type=`str`)
    `line`
    (type=`int`)
    `data`
    (type=`str`)
  Returns:
    `str`

### makePrivateKeyString(obj, passphrase=None, kind='openssh')

Return an OpenSSH-style private key for a `Crypto.PublicKey.pubkey.pubkey` object. If passphrase is given, encrypt the private key with it. kind is one of ('openssh', 'lsh')

  Parameters:
    `obj`
    (type=`Crypto.PublicKey.pubkey.pubkey`)
    `passphrase`
    (type=`str`/`None`)
    `kind`
    (type=`str`)
  Returns:
    `str`

### makePublicKeyString(obj, comment='', kind='openssh')

Return an public key given a `Crypto.PublicKey.pubkey.pubkey` object. kind is one of ('openssh', 'lsh')

  Parameters:
    `obj`
    (type=`Crypto.PublicKey.pubkey.pubkey`)
    `comment`
    (type=`str`)
    `kind`
    (type=`str`)
  Returns:
    `str`

### objectType(obj)

Return the SSH key type corresponding to a `Crypto.PublicKey.pubkey.pubkey` object.

  Parameters:
    `obj`
    (type=`Crypto.PublicKey.pubkey.pubkey`)
  Returns:
    `str`

### printKey(obj)

Pretty print a `Crypto.PublicKey.pubkey.pubkey` object.

  Parameters:
    `obj`
    (type=`Crypto.PublicKey.pubkey.pubkey`)

### signData(obj, data)

Sign the data with the given `Crypto.PublicKey.pubkey.pubkey` object.

  Parameters:
    `obj`
    (type=`Crypto.PublicKey.pubkey.pubkey`)
    `data`
    (type=`str`)
  Returns:
    `str`

### verifySignature(obj, sig, data)

Verify that the signature for the data is valid.

  Parameters:
    `obj`
    (type=`Crypto.PublicKey.pubkey.pubkey`)
    `sig`
    (type=`str`)
    `data`
    (type=`str`)
  Returns:
    `bool`

Variable Details

### data

  Type:
    `str`
  Value:

        'datadatadatadata'

### data2

  Type:
    `str`
  Value:

        'datadatadatadata'

### enc

  Type:
    `str`
  Value:

        '\x00:5J\x18^$M\xae\x1f\x98\x05h\xf3G\xcb'

### ID_SHA1

  Type:
    `str`
  Value:

        '0!0\t\x06\x05+\x0e\x03\x02\x1a\x05\x00\x04\x14'

### iv

  Type:
    `str`
  Value:

        'iviviviv'

### key

  Type:
    `str`
  Value:

        'keykeykeykeykeykeykeykey'

Generated by Epydoc 1.1 on Thu May 8 13:18:19 2003 | http://epydoc.sf.net