decryptBlock method
This method takes a source block of ciphertext, decrypts it using the decryption key schedule,
and returns the resulting plaintext. Optionally, you can provide a destination block (dst
)
to write the decrypted data into. If not provided, a new List
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.StateError
if the instance was created with thenoDecryption
option, indicating that decryption is not supported by this instance.
Returns:
- The decrypted plaintext block as a List
Implementation
@override
List<int> decryptBlock(List<int> src, [List<int>? dst]) {
final out = dst ?? List<int>.filled(blockSize, 0);
if (src.length != blockSize) {
throw const ArgumentException("AES: invaiid source block size");
}
if (out.length != blockSize) {
throw const ArgumentException("AES: invalid destination block size");
}
if (_decKey == null) {
throw const MessageException(
"AES: decrypting with an instance created with noDecryption option");
} else {
_lib.decryptBlock(_decKey!, src, out);
}
return out;
}