Skip to content

Decoder

XOR decoding and AES-256-CBC decryption functions.

XOR and AES decryption for DJI log records.

xor_decode

xor_decode(data: bytes, record_type: int) -> bytes

XOR-decode data using a CRC64-derived 8-byte key.

The first byte is consumed for key derivation and excluded from the output. This matches the Rust XorDecoder::new behaviour.

aes_decode

aes_decode(data: bytes, iv: bytes, key: bytes) -> tuple[bytes, bytes]

AES-256-CBC decrypt data, returning (plaintext, next_iv).

The next_iv is the last 16 bytes of the ciphertext (before decryption), used for IV chaining between records of the same feature point.

record_decode

record_decode(data: bytes, record_type: int, version: int, keychain: Keychain | None) -> bytes

Decode record data: XOR for v7-12, XOR+AES for v13+.

Returns decoded bytes ready for struct parsing.