unlockWithBundle method

Future<void> unlockWithBundle(
  1. String vault,
  2. TomSecretsUnlockBundle bundle
)

Unlocks vault (a store's name as status lists it: the primary unlocks the service, another store a locked store of an unlocked service) with bundle, the key material the OS unlock read (protocol.md 6.4): sealed under this connection's bundle key. A bundle that no longer opens the vault (re-keyed) answers denied reason bad_password; one the service cannot open, bad_bundle.

Implementation

Future<void> unlockWithBundle(
  String vault,
  TomSecretsUnlockBundle bundle,
) async {
  final key = _bundleKey;
  if (key == null) {
    throw TomSecretsAdminException(
      'unsupported',
      'a connection that claimed the service cannot send a key bundle',
    );
  }
  final plaintext = bundle.encode();
  final Map<String, String> sealed;
  try {
    sealed = await tomSecretsSealBundle(
      bundleKey: key,
      vault: vault,
      serviceStart: serviceStart,
      plaintext: plaintext,
    );
  } finally {
    plaintext.fillRange(0, plaintext.length, 0);
  }
  await request('unlock', {'vault': vault, 'bundle': sealed});
}