keyringAddHardwareSlot method
Adds a slot the hardware key wraps; returns the slot index. The keyring must be unlocked.
Implementation
Future<int> keyringAddHardwareSlot(Pointer<Void> kr, HardwareKey key) async {
final factor = SecretBytes.take(keyringBeginHardwareSlot(kr, key.keyId));
final index = keyringSlotCount(kr) - 1;
try {
final blob = await key.wrap(factor);
if (!keyringSetHardwareBlob(kr, index, blob)) {
throw const HardwareKeyException(
'failed',
'could not store the wrapped factor',
);
}
return index;
} finally {
factor.wipe();
}
}