GCM constructor

GCM(
  1. BlockCipher cipher
)

Creates a GCM instance with the specified block cipher.

Parameters:

  • cipher: The block cipher with a 16-byte block size to be used for GCM encryption and decryption.

Throws:

Implementation

GCM(BlockCipher cipher) {
  if (cipher.blockSize != 16) {
    throw ArgumentException.invalidOperationArguments(
      "GCM",
      name: "cipher",
      reason: "GCM supports only 16-byte block cipher.",
      expecteLen: 16,
    );
  }
  _cipher = cipher;

  _subkey = List<int>.filled(_cipher.blockSize, 0);
  _cipher.encryptBlock(List<int>.filled(_cipher.blockSize, 0), _subkey);
}