receiverUnwrapKey method

Key receiverUnwrapKey({
  1. required KeyAlgorithm keyWrappingAlgorithm,
  2. required KeyAlgorithm encryptionAlgorithm,
  3. required Key ephemeralKey,
  4. required Key recipientKey,
  5. required Uint8List ciphertext,
  6. Uint8List? nonce,
  7. Uint8List? tag,
})

Unwraps a key for the receiver using the derived key.

Returns a Key containing the unwrapped key.

Implementation

Key receiverUnwrapKey({
  required KeyAlgorithm keyWrappingAlgorithm,
  required KeyAlgorithm encryptionAlgorithm,
  required Key ephemeralKey,
  required Key recipientKey,
  required Uint8List ciphertext,
  Uint8List? nonce,
  Uint8List? tag,
}) {
  final derived = deriveKey(
    encryptionAlgorithm: keyWrappingAlgorithm,
    ephemeralKey: ephemeralKey,
    recipientKey: recipientKey,
    receive: true,
  );
  final encryptedBuffer = derived.unwrapKey(
    tag: tag,
    nonce: nonce,
    ciphertext: ciphertext,
    algorithm: encryptionAlgorithm,
  );
  derived.handle.free();
  return encryptedBuffer;
}