decryptBlock method
Decrypts one 16-byte block, writing into dst if given. Throws if
this instance was created with noDecryption.
Implementation
@override
BuBytes decryptBlock(List<int> src, [List<int>? dst]) {
final out = BuBytes.unsafeMutable(dst ?? List<int>.filled(blockSize, 0));
if (src.length != blockSize) {
throw CoreErrors.invalidOperationArguments(
"decryptBlock",
name: "src",
reason: "Invalid source bytes length.",
);
}
if (out.length != blockSize) {
throw CoreErrors.invalidOperationArguments(
"decryptBlock",
name: "dst",
reason: "Invalid destination bytes length.",
);
}
final decKey = _decKey;
if (decKey == null) {
throw CoreErrors.cryptoFailed(
"decryptBlock",
reason: "Decryption key is not available.",
);
} else {
_lib.decryptBlock(decKey, src.asBytes, out);
}
return out;
}