Acquire.Crypto._keys module¶
-
class
PrivateKey(private_key=None, auto_generate=True)[source]¶ Bases:
objectThis is a holder for an in-memory private key
-
bytes(passphrase, mangleFunction=None)[source]¶ Return the raw bytes for this key, encoded by the passed passphrase that has been optionally mangled by mangleFunction
-
fingerprint()[source]¶ Return the fingerprint of this key - this is useful to help work out which key to use to decrypt data
-
static
from_data(data, passphrase, mangleFunction=None)[source]¶ Return a private key constructed from the passed json-deserialised dictionary
-
public_key(filename=None)[source]¶ Get the public key for this private key. If filename is specified then this is written to the passed file
-
static
random_passphrase()[source]¶ Randomly generate and return a passphrase that obeys the password rules and could be used to serialise a PrivateKey
-
static
read(filename, passphrase, mangleFunction=None)[source]¶ Read a private key from ‘filename’ that is encrypted using ‘passphrase’ and return a PrivateKey object holding that key
-
-
class
PublicKey(public_key=None)[source]¶ Bases:
objectThis is a holder for an in-memory public key
-
encrypt(message)[source]¶ Encrypt and return the passed message. For short messages this will use the private key directly. For longer messages, this will generate a random symmetric key, will encrypt the message using that, and will then encrypt the symmetric key. This returns some bytes
-
-
get_private_key(key='default')[source]¶ Internal function used to return the key associated with ‘key’. This allows a single session to re-use a key, rather than continually generating new keys (which is slow). Make sure you know that you can safely re-use a key. Re-using keys for different function calls is completely ok