-
Notifications
You must be signed in to change notification settings - Fork 0
security (module)
The agutil.security
module includes two methods at the module level for file encryption and decryption: encryptFile()
and decryptFile()
. Additionally, several exceptions are defined for use by the ciphers
-
encryptFile(input_filename, output_filename, key, nonce=
None
, **kwargs):Opens input_filename and output_filename and passes their file handles, along with the other arguments, to
encryptFileObj()
. For a description of that function, see below. -
encryptFileObj(reader, writer, key, nonce=
None
, **kwargs):Encrypts the data read from reader using the cipher and writes it to writer. Initializes an
agutil.security.EncryptionCipher
to handle the encryption. kwargs are passed to the constructor of theEncryptionCipher
and may be any valid keyword argument toconfigure_cipher()
(see ciphers). Padding is handled internally (chunks are padded to 16-byte intervals). -
decryptFile(input_filename, output_filename, key, nonce=
None
, compatability=False
):Opens input_filename and output_filename and passes their file handles, along with the other arguments, to
decryptFileObj()
. For a description of that function, see below. -
decryptFileObj(reader, writer, key, nonce=
None
, compatability=False
):Decrypts the data read from reader using cipher and writes it to writer. Initializes an
agutil.security.DecryptionCipher
to handle decryption. The cipher can handle data encrypted byagutil
versions 1.2.0 and newer. compatability must beTrue
to decrypt data from earlier versions. -
CipherError: (Exception)
ValueError
->CipherError
This is the parent exception type for other cipher errors -
EncryptionError: (Exception)
ValueError
->CipherError
->EncryptionError
Raised byagutil.security.EncryptionCipher
if there is an error during encryption -
DecryptionError: (Exception)
ValueError
->CipherError
->DecryptionError
Raised byagutil.security.DecryptionCipher
if there is an error during decryption -
HeaderError: (Exception)
ValueError
->CipherError
->HeaderError
Raised by ciphers if the header is in an invalid state -
HeaderLengthError: (Exception)
ValueError
->CipherError
->HeaderError
->HeaderLengthError
Raised byagutil.security.DecryptionCipher
if there was not enough initial data to initialize the cipher -
InvalidHeaderError: (Exception)
ValueError
->CipherError
->HeaderError
->InvalidHeaderError
Raised by ciphers if the header is corrupt or does not specify a valid configuration