synology_apm_repo.sdk.api.key_manager module

KeyManager: one opened Repository’s encryption-key state (keys/key_verification/encrypted) and the KeyStatus it resolves to.

class synology_apm_repo.sdk.api.key_manager.KeyStatus(*values)

Bases: Enum

A repository’s key state. NO_KEY_PROVIDED means encrypted (or, rarely, undeterminable) with no key tried yet; INVALID means the last key tried was rejected.

NO_KEY_PROVIDED = 'no_key_provided'
NOT_ENCRYPTED = 'not_encrypted'
VERIFIED = 'verified'
INVALID = 'invalid'
property label: str

This status as a user reads it ("key needed", "not encrypted", "key verified" or "invalid key").

class synology_apm_repo.sdk.api.key_manager.KeyManager(keys, key_verification, *, encrypted=None)

Bases: object

One Repository’s encryption-key state. Repository.set_key() sequences verify()/adopt()/record().

property keys: KeyMaterial | None

The adopted key material; None until a key is supplied at construction or adopt()-ed. A rejected key is never adopted.

property status: KeyStatus

The current KeyStatus; no I/O.

property verification: KeyVerification | None

The GCM-unwrap verification result, or None when no key was ever provided — the detail behind status’s INVALID/ VERIFIED.

property is_encrypted: bool | None

Whether this repository is encrypted, True even when the key was rejected; None when the probe couldn’t tell.

require_verified()

Check, before workload/version I/O, that a confirmed-encrypted repository has a verified key.

Raises:
async verify(store, layout, key_string)

KeyMaterial from key_string, verified against layout’s key-probe location. Leaves this manager’s state unchanged.

Raises:
adopt(keys)

Make keys the key material catalogs open with from now on. status/verification change only on record().

record(keys, verification)

Record verification and recompute status. keys is the key just tried, adopted or not, so a rejected key still yields INVALID rather than NO_KEY_PROVIDED.

synology_apm_repo.sdk.api.key_manager.validate_key_string(key_string)

Check key_string is a well-formed "<userKeyID>@<base64 userKey>" without opening anything, e.g. while a command line is read.

Raises:

KeyMaterialError – It is malformed. The message never repeats the secret userKey.