init method
Initializes this for addition of AAD and en/decryption of data.
Implementation
@override
void init(bool forEncryption, CipherParameters params) {
_forEncryption = forEncryption;
_initParams = params;
Uint8List initNonce;
Uint8List? initAAD;
if (params is AEADParameters) {
_macSize = params.macSize ~/ 8;
_keyParam = params.parameters as KeyParameter;
initNonce = params.nonce;
initAAD = params.associatedData;
} else if (params is ParametersWithIV) {
_keyParam = params.parameters as KeyParameter;
initNonce = params.iv;
} else {
throw ArgumentError(
'${params.runtimeType} is not ParametersWithIV or AEADParameters',
'params');
}
_nonceMac = Uint8List(_blockSize);
_cMac
..init(_keyParam)
..update(
Uint8List(_blockSize)..[_blockSize - 1] = _nonceTAG, 0, _blockSize)
..update(initNonce, 0, initNonce.length)
..doFinal(_nonceMac, 0);
_aadFinished = false;
_aadMac = Uint8List(_blockSize);
_cMac
..init(_keyParam)
..update(
Uint8List(_blockSize)..[_blockSize - 1] = _aadTAG, 0, _blockSize);
if (initAAD != null) processAADBytes(initAAD, 0, initAAD.length);
_cipherMac = Uint8List(_blockSize);
_ctr.init(_forEncryption, ParametersWithIV(_keyParam, _nonceMac));
_bufBlock = Uint8List(_macSize);
_bufOff = 0;
_bufFull = false;
}