unwrapKey method

Key unwrapKey({
  1. required KeyAlgorithm algorithm,
  2. Uint8List? tag,
  3. required Uint8List ciphertext,
  4. Uint8List? nonce,
})

Unwraps a key.

Throws an AskarKeyException if unwrapping fails.

Implementation

Key unwrapKey({
  required KeyAlgorithm algorithm,
  Uint8List? tag,
  required Uint8List ciphertext,
  Uint8List? nonce,
}) {
  try {
    return Key(
      askarKeyUnwrapKey(
        localKeyHandle,
        algorithm,
        ciphertext,
        nonce: nonce,
        tag: tag,
      ).getValueOrException(),
    );
  } catch (e) {
    throw AskarKeyException('Failed to unwrap key: $e');
  }
}