GCM mode (Galois/Counter Mode) is a mode of operation for symmetric key cryptographic block ciphers. It is an authenticated encryption algorithm designed to provide both authentication and secrecy. GCM mode is defined for block ciphers with a block size of 128 bits. GMAC is an authentication-only variant of the GCM.

## Encryption and authentication

As the name suggests, GCM mode combines the well-known counter mode of encryption with the new Galois mode of authentication. The key feature is that the Galois field multiplication used for authentication can be easily computed in parallel thus permitting higher throughput than the authentication algorithms that use chaining modes, like CBC. The GF(2128) field used is defined by the polynomial

${\displaystyle x^{128}+x^{7}+x^{2}+x+1.\,}$

The GHASH function is defined by

${\displaystyle {\text{GHASH}}(H,A,C)=X_{m+n+1},\,}$

where H is a string of 128 zeros encrypted using the block cipher, A is data which is only authenticated (not encrypted), C is the ciphertext, m is the number of 128 bit blocks in A, n is the number of 128 bit blocks in C (the final blocks of A and C need not be exactly 128 bits), and the variable Xi for i = 0, ..., m + n + 1 is defined as[1]

${\displaystyle X_{i}={\begin{cases}0&{\text{for }}i=0\\(X_{i-1}\oplus A_{i})\cdot H&{\text{for }}i=1,\ldots ,m-1\\(X_{m-1}\oplus (A_{m}^{*}\lVert 0^{128-v}))\cdot H&{\mbox{for}}~i=m\\(X_{i-1}\oplus C_{i-m})\cdot H&{\text{for }}i=m+1,\ldots ,m+n-1\\(X_{m+n-1}\oplus (C_{m}^{*}\lVert 0^{128-u}))\cdot H&{\text{for }}i=m+n\\(X_{m+n}\oplus (\operatorname {len} (A)\lVert \operatorname {len} (C)))\cdot H&{\mbox{for}}~i=m+n+1\\\end{cases}}}$

GCM mode was designed by John Viega and David A. McGrew as an improvement to Carter-Wegman Counter CWC mode.

On November 26, 2007 NIST announced the release of NIST Special Publication 800-38D Recommendation for Block Cipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC making GCM and GMAC official standards.

## Use

GCM mode is used in the IEEE 802.1AE (MACsec) Ethernet security, ANSI (INCITS) Fibre Channel Security Protocols (FC-SP), IEEE P1619.1 tape storage, IETF IPsec standards[2][3], SSH [4] and TLS/SSL [5]. AES-GCM is included into the NSA Suite B Cryptography.

## Performance

GCM requires one block cipher operation and one 128-bit multiplication in the Galois field per each block (128 bit) of encrypted and authenticated data. Intel has added the PCLMULQDQ instruction, highlighting its use for GCM [1]

## Tag size

The bit-length of the tag, denoted t, is a security parameter. In general, t may be any one of the following five values: 128, 120, 112, 104, or 96. For certain applications, t may be 64 or 32, but the use of these two tag lengths constrains the length of the input data and the lifetime of the key. Appendix C in NIST SP 800-38D provides guidance for these constraints (for example, if t = 32 and the maximal packet size is 210 bytes, then the authentication decryption function should be invoked no more than 211 times; if t = 64 and the maximal packet size is 215 bytes, then the authentication decryption function should be invoked no more than 232 times).

As with any tag-based authentication mechanism, if the adversary chooses a t-bit tag at random, it is expected to be correct for given data with probability 2t. With GCM, however, an adversary can choose tags that increase this probability, proportional to the total length of the ciphertext and additional authenticated data (AAD). Consequently, GCM is not well-suited for use with short tag lengths or very long messages.

In particular, if n denotes the total number of blocks in the encoding (the input to the GHASH function), then there is a method of constructing a targeted ciphertext forgery that is expected to succeed with a probability of approximately n2t. Moreover, each successful forgery in this attack increases the probability that subsequent targeted forgeries will succeed, and leaks information about the hash subkey, H. Eventually, H may be compromised entirely and the authentication assurance is completely lost.[6]

Independent of this attack, an adversary may attempt to systematically guess many different tags for a given input to authenticated decryption, and thereby increase the probability that one (or more) of them, eventually, will be accepted as valid. For this reason, the system or protocol that implements GCM should monitor and, if necessary, limit the number of unsuccessful verification attempts for each key.

## Patents

According to the authors' statement, GCM is unencumbered by patents.