dfvfs.encryption package

Submodules

dfvfs.encryption.aes_decrypter module

The AES decrypter implementation.

class dfvfs.encryption.aes_decrypter.AESDecrypter(cipher_mode=None, initialization_vector=None, key=None, **kwargs)[source]

Bases: Decrypter

AES decrypter using pycaes.

Decrypt(encrypted_data, finalize=False)[source]

Decrypts the encrypted data.

Parameters:
  • encrypted_data (bytes) – encrypted data.

  • finalize (Optional[bool]) – True if the end of data has been reached and the cipher context should be finalized.

Returns:

decrypted data and remaining encrypted data.

Return type:

tuple[bytes, bytes]

ENCRYPTION_METHOD = 'aes'
__init__(cipher_mode=None, initialization_vector=None, key=None, **kwargs)[source]

Initializes a decrypter.

Parameters:
  • cipher_mode (Optional[str]) – cipher mode.

  • initialization_vector (Optional[bytes]) – initialization vector.

  • key (Optional[bytes]) – key.

  • kwargs (dict) – keyword arguments depending on the decrypter.

Raises:

ValueError – when key is not set or the cipher mode is not supported.

dfvfs.encryption.blowfish_decrypter module

The Blowfish decrypter implementation.

class dfvfs.encryption.blowfish_decrypter.BlowfishDecrypter(cipher_mode=None, initialization_vector=None, key=None, **kwargs)[source]

Bases: Decrypter

Blowfish decrypter using pyfcrypto.

Decrypt(encrypted_data, finalize=False)[source]

Decrypts the encrypted data.

Parameters:
  • encrypted_data (bytes) – encrypted data.

  • finalize (Optional[bool]) – True if the end of data has been reached and the cipher context should be finalized.

Returns:

decrypted data and remaining encrypted data.

Return type:

tuple[bytes, bytes]

ENCRYPTION_METHOD = 'blowfish'
__init__(cipher_mode=None, initialization_vector=None, key=None, **kwargs)[source]

Initializes a decrypter.

Parameters:
  • cipher_mode (Optional[str]) – cipher mode.

  • initialization_vector (Optional[bytes]) – initialization vector.

  • key (Optional[bytes]) – key.

  • kwargs (dict) – keyword arguments depending on the decrypter.

Raises:
  • ValueError – when key is not set, the cipher mode is not supported or initialization vector not set or not supported.

  • TypeError – when the initialization vector type is not supported.

dfvfs.encryption.decrypter module

The decrypter interface.

class dfvfs.encryption.decrypter.Decrypter(**kwargs)[source]

Bases: object

Decrypter interface.

abstract Decrypt(encrypted_data, finalize=False)[source]

Decrypts the encrypted data.

Parameters:
  • encrypted_data (bytes) – encrypted data.

  • finalize (Optional[bool]) – True if the end of data has been reached and the cipher context should be finalized.

Returns:

decrypted data and remaining encrypted data.

Return type:

tuple[bytes, bytes]

__init__(**kwargs)[source]

Initializes a decrypter.

Parameters:

kwargs (dict) – keyword arguments depending on the decrypter.

Raises:

ValueError – when there are unused keyword arguments.

dfvfs.encryption.des3_decrypter module

The triple DES decrypter implementation.

class dfvfs.encryption.des3_decrypter.DES3Decrypter(cipher_mode=None, initialization_vector=None, key=None, **kwargs)[source]

Bases: Decrypter

Triple DES decrypter using pyfcrypto.

Decrypt(encrypted_data, finalize=False)[source]

Decrypts the encrypted data.

Parameters:
  • encrypted_data (bytes) – encrypted data.

  • finalize (Optional[bool]) – True if the end of data has been reached and the cipher context should be finalized.

Returns:

decrypted data and remaining encrypted data.

Return type:

tuple[bytes, bytes]

ENCRYPTION_METHOD = 'des3'
__init__(cipher_mode=None, initialization_vector=None, key=None, **kwargs)[source]

Initializes a decrypter.

Parameters:
  • cipher_mode (Optional[str]) – cipher mode.

  • initialization_vector (Optional[bytes]) – initialization vector.

  • key (Optional[bytes]) – key.

  • kwargs (dict) – keyword arguments depending on the decrypter.

Raises:
  • ValueError – when key is not set, the cipher mode is not supported or initialization vector not set or not supported.

  • TypeError – when the initialization vector type is not supported.

dfvfs.encryption.manager module

The encryption manager.

class dfvfs.encryption.manager.EncryptionManager[source]

Bases: object

Encryption manager.

classmethod DeregisterDecrypter(decrypter)[source]

Deregisters a decrypter for a specific encryption method.

Parameters:

decrypter (type) – decrypter class.

Raises:

KeyError – if the corresponding decrypter is not set.

classmethod GetDecrypter(encryption_method, **kwargs)[source]

Retrieves the decrypter object for a specific encryption method.

Parameters:
  • encryption_method (str) – encryption method identifier.

  • kwargs (dict) – keyword arguments depending on the decrypter.

Returns:

decrypter or None if the encryption method does not exists.

Return type:

Decrypter

Raises:

CredentialError – if the necessary credentials are missing.

classmethod RegisterDecrypter(decrypter)[source]

Registers a decrypter for a specific encryption method.

Parameters:

decrypter (type) – decrypter class.

Raises:

KeyError – if the corresponding decrypter is already set.

classmethod RegisterDecrypters(decrypters)[source]

Registers decrypters.

The decrypters are identified based on their lower case encryption method.

Parameters:

decrypters (list[type]) – decrypter classes.

Raises:

KeyError – if decrypters is already set for the corresponding encryption method.

dfvfs.encryption.rc4_decrypter module

The RC4 decrypter implementation.

class dfvfs.encryption.rc4_decrypter.RC4Decrypter(key=None, **kwargs)[source]

Bases: Decrypter

RC4 decrypter using pyfcrypto.

Decrypt(encrypted_data, finalize=False)[source]

Decrypts the encrypted data.

Parameters:
  • encrypted_data (bytes) – encrypted data.

  • finalize (Optional[bool]) – True if the end of data has been reached and the cipher context should be finalized.

Returns:

decrypted data and remaining encrypted data.

Return type:

tuple[bytes,bytes]

ENCRYPTION_METHOD = 'rc4'
__init__(key=None, **kwargs)[source]

Initializes a decrypter.

Parameters:
  • key (Optional[bytes]) – key.

  • kwargs (dict) – keyword arguments depending on the decrypter.

Raises:

ValueError – when key is not set.

Module contents

Imports for the encryption manager.