initCipher method

BlockCipher initCipher(
  1. int cipherId,
  2. Uint8List IV,
  3. Uint8List key,
  4. bool dir,
)

Initializes the block cipher used for encrypted transport.

Implementation

BlockCipher initCipher(int cipherId, Uint8List IV, Uint8List key, bool dir) {
  BlockCipher cipher = Cipher.cipher(cipherId);
  if (tracePrint != null) {
    tracePrint('$hostport: ' +
        (dir ? 'C->S' : 'S->C') +
        ' IV  = "${hex.encode(IV)}"');
    tracePrint('$hostport: ' +
        (dir ? 'C->S' : 'S->C') +
        ' key = "${hex.encode(key)}"');
  }
  cipher.init(
      dir,
      ParametersWithIV(
          KeyParameter(key), viewUint8List(IV, 0, cipher.blockSize)));
  return cipher;
}