keyringUnlockWithHardware method

Future<SecretBytes> keyringUnlockWithHardware(
  1. Pointer<Void> kr,
  2. HardwareKey key, {
  3. String reason = 'Unlock your keys',
})

Unlocks the slot wrapped by key; returns the master key.

Implementation

Future<SecretBytes> keyringUnlockWithHardware(
  Pointer<Void> kr,
  HardwareKey key, {
  String reason = 'Unlock your keys',
}) async {
  final index = keyringHardwareSlotIndex(kr, key);
  if (index < 0) {
    throw HardwareKeyException('not_found', 'no slot for ${key.label}');
  }
  final (_, blob) = keyringHardwareSlot(kr, index);
  final factor = await key.unwrap(blob, reason: reason);
  try {
    return SecretBytes.take(
      keyringUnlockWithHardwareFactor(kr, index, factor.bytes),
    );
  } finally {
    factor.wipe();
  }
}