Explaining the AES-GCM Authentication Tag
In GCM (Galois/Counter Mode) encryption, the authentication tag is a short value (usually 16 bytes) that ensures the integrity and authenticity of both the ciphertext and any additional authenticated data (AAD).
During Encryption:
- GCM computes the authentication tag using a GHASH function over the ciphertext and AAD.
- The tag is sent alongside the ciphertext.
During Decryption:
- The recipient recomputes the tag using the same algorithm and inputs.
- If the recomputed tag matches the received tag, the data is accepted.
- If not, decryption fails — signaling tampering or corruption.
In summary, the tag ensures that the encrypted message has not been altered and that it came from a trusted source.