Image encryption/decryption using AES and the Galois Counter Mode (GCM) Block Cipher. Accepts AES secret key lengths of 128,192,256 (hexidecimal). 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), imageFile - string of file name (i.e., 'AES_image.jpg'), aad - additional authenticated data (plaintext string).
Outputs: outputCipher - uint8 encrypted matrix of same size as input image, authTag - authentication tag (hexidecimal).
Inputs: secretKey (same as above), iv (same as above), outputCipher - encrypted uint8 matrix of image (same size as original), aad - additional authenticated data (plaintext string) must match encrypted aad string, authTag (same as above output).
Outputs: ImageOut - decrypted uint8 matrix (same as original image that can be uiwriten to whatever output format), authTagResult - either true or false (true is decrypted correctly, i.e. authentication tag match)
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). Depending on the size of the image, encryption/decryption times can be several minutes long.