initialize method
Future<void>
initialize({
- required bool isEncrypting,
- required SecretKey secretKey,
- required List<
int> nonce, - List<
int> aad = const [], - int keyStreamIndex = 0,
override
Initializes the state with the given secretKey
, nonce
, and aad
.
Implementation
@override
Future<void> initialize({
required bool isEncrypting,
required SecretKey secretKey,
required List<int> nonce,
List<int> aad = const [],
int keyStreamIndex = 0,
}) async {
_isInitialized = false;
_isEncrypting = isEncrypting;
this.keyStreamIndex = keyStreamIndex;
final secretKeyData = await secretKey.extract();
final derivedSecretKey = deriveKeySync(
secretKey: secretKeyData,
nonce: nonce,
);
final derivedNonce = deriveNonce(
secretKey: secretKeyData,
nonce: nonce,
);
final macSink = await cipher.macAlgorithm.newMacSink(
secretKey: secretKey,
nonce: nonce,
aad: aad,
);
_macSink = macSink;
assert(!_isInitialized);
_isInitialized = true;
beforeData(
secretKey: derivedSecretKey,
nonce: derivedNonce,
aad: aad,
);
}