Galois Counter Mode (GCM) Block Cipher using AES

Version 1.0.0 (6.04 KB) by David Hill
Encrypt/Decrypt a plaintext message using AES GCM.
Updated 2 Dec 2021

View License

Galois Counter Mode (GCM) Block Cipher using AES-128,192,256 based on the key length. Implimentation is based on NIST Special Publication 800-38D.
Inputs: secretKey - AES secret key, hexidecimal (128,192, or 256 bits), iv - initialization vector (random 96-bit hexidecimal), plainTextInput - plaintext message of input that needs to be encrypted, aad - additional authenticated data (plaintext string).
Outputs: outputCipher - hexidecimal encrypted Cipher, authTag - authentication tag (hexidecimal).
The initialization vection is not generated by the code and must be provided. It is extremely important that the initialization vection be different for each encryption using the same secret key (see NIST publication for explanation).
plainTextInput='I like to swim!';
aad= 'additional unencrypted instructions';
C =
T =
P =
'I like to swim!'
A =

Cite As

David Hill (2024). Galois Counter Mode (GCM) Block Cipher using AES (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2021a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes