Skip to content
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.

security (module)

Aaron Graubert edited this page Sep 18, 2018 · 4 revisions

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

API
  • 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 the EncryptionCipher and may be any valid keyword argument to configure_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 by agutil versions 1.2.0 and newer. compatability must be True 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 by agutil.security.EncryptionCipher if there is an error during encryption

  • DecryptionError: (Exception)

    ValueError -> CipherError -> DecryptionError Raised by agutil.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 by agutil.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