Skip to content

Keychain

Encryption key management for AES decryption (v13+ logs).

Keychain

Keychain

Keychain()

Maps FeaturePoint → (iv, key) for AES decryption.

The IV is updated after each record decryption (IV chaining).

empty classmethod

empty() -> Keychain

Return an empty keychain (no feature-point keys).

from_feature_points classmethod

from_feature_points(entries: Sequence[KeychainFeaturePoint]) -> Keychain

Build a keychain from decoded feature-point entries.

get

get(fp: int) -> tuple[bytes, bytes] | None

Get (iv, key) for a feature point, or None.

update_iv

update_iv(fp: int, iv: bytes) -> None

Update IV for a feature point (IV chaining after decryption).

FeaturePoint

FeaturePoint

Bases: IntEnum

Feature point types for AES keychain selection.

api_name property

api_name: str

Name used in DJI API serialization.

feature_point_for_record

feature_point_for_record

feature_point_for_record(record_type: int, version: int) -> FeaturePoint

Map a record type (magic byte) to its FeaturePoint for key selection.

KeychainsRequest

KeychainsRequest dataclass

KeychainsRequest(version: int = 0, department: int = 3, keychains: list[list[EncodedKeychainFeaturePoint]] = list())

Request body for the DJI keychains API.

to_dict

to_dict() -> dict[str, Any]

Serialise to a dict for the DJI API request body.

fetch

fetch(api_key: str, *, cache: bool = True, verify: bool = True) -> list[list[KeychainFeaturePoint]]

Fetch decoded keychains from DJI API.

When cache is True (default), responses are cached locally under $XDG_CACHE_HOME/pydjirecord/keychains/ so that repeated parses of the same log file skip the network round-trip.

Raises :class:ApiKeyError if api_key is None or empty.

KeychainFeaturePoint

KeychainFeaturePoint dataclass

KeychainFeaturePoint(feature_point: int, aes_key: str, aes_iv: str)

Decoded feature point with AES key and IV.

EncodedKeychainFeaturePoint

EncodedKeychainFeaturePoint dataclass

EncodedKeychainFeaturePoint(feature_point: int, aes_ciphertext: str)

Encoded (encrypted) feature point data from KeyStorage records.

to_dict

to_dict() -> dict[str, Any]

Serialise to a dict for the DJI API request body.