dissect.fve.crypto
¶
Submodules¶
Package Contents¶
Classes¶
Functions¶
Create a cipher object according to a given cipher specification and key. |
|
Parse a cipher specification into a tuple of (cipher, mode, key size, iv mode, iv options). |
Attributes¶
- class dissect.fve.crypto.Cipher(key: bytes, key_size: int, block_size: int, iv_mode: type[IV], iv_options: str, sector_size: int = 512, iv_sector_size: int = 512)¶
- key¶
- key_size¶
- key_size_bytes¶
- block_size¶
- sector_size = 512¶
- iv_sector_size = 512¶
- iv_mode¶
- class dissect.fve.crypto.Plain(cipher: Cipher, key: bytes, iv_options: str | None = None)¶
Bases:
IV
- generate(mode: int, iv: bytearray, data: bytearray, sector: int = 0) None ¶
- class dissect.fve.crypto.Plain64(cipher: Cipher, key: bytes, iv_options: str | None = None)¶
Bases:
IV
- generate(mode: int, iv: bytearray, data: bytearray, sector: int = 0) None ¶
- class dissect.fve.crypto.Plain64BE(cipher: Cipher, key: bytes, iv_options: str | None = None)¶
Bases:
IV
- generate(mode: int, iv: bytearray, data: bytearray, sector: int = 0) None ¶
- dissect.fve.crypto.CIPHER_MODE_MAP¶
- dissect.fve.crypto.IV_MODE_MAP¶
- dissect.fve.crypto.create_cipher(spec: str, key: bytes, key_size: int | None = None, sector_size: int = 512, iv_sector_size: int = 512) base.Cipher ¶
Create a cipher object according to a given cipher specification and key.
For more information on the cipher specification, read the documentation on
parse_cipher_spec()
.- Parameters:
spec – The cipher specification to parse.
key – The key to initialize the cipher with.
key_size – Optional key size that overrides the specification key size.
sector_size – Optional sector size.
- dissect.fve.crypto.parse_cipher_spec(spec: str, key_size: int | None = None, key_size_hint: int | None = None) tuple[str, str, int, str, str | None] ¶
Parse a cipher specification into a tuple of (cipher, mode, key size, iv mode, iv options).
Inspired by and accepts LUKS/dm-crypt-like cipher specifications in the form of:
cipher-mode-keysize-iv:ivopts
The
mode
,keysize
,iv
andivopts
are optional and will default tocbc
, thekey_size
argument andplain
respectively.- Parameters:
spec – The cipher specification to parse.
key_size – Optional key size that overrides the specification key size.
key_size_hint – Optional key size hint for the amount of bits that the key actually has.