decryptBlock method

  1. @override
List<int> decryptBlock(
  1. List<int> src, [
  2. List<int>? dst
])
override

Decrypt block

Parameters:

  • src: The source block of ciphertext to be decrypted, which must have a length of 16 bytes.
  • dst: An optional destination block to store the decrypted plaintext. If not provided, a new block is created.

Throws:

  • ArgumentException if the source or destination block size is not 16 bytes.
  • CryptoException if the instance was created with the noDecryption option, indicating that decryption is not supported by this instance.

Implementation

@override
List<int> decryptBlock(List<int> src, [List<int>? dst]) {
  final out = dst ?? List<int>.filled(blockSize, 0);
  if (src.length != blockSize) {
    throw ArgumentException.invalidOperationArguments(
      "decryptBlock",
      name: "src",
      reason: "Invalid source bytes length.",
    );
  }
  if (out.length != blockSize) {
    throw ArgumentException.invalidOperationArguments(
      "decryptBlock",
      name: "dst",
      reason: "Invalid destination bytes length.",
    );
  }

  if (_decKey == null) {
    throw CryptoException.failed(
      "decryptBlock",
      reason: "Decryption key is not available.",
    );
  } else {
    _lib.decryptBlock(_decKey!, src.asBytes, out);
  }

  return out;
}