| EVP_AES_128_GCM(3) | Library Functions Manual | EVP_AES_128_GCM(3) |
EVP_aes_128_gcm,
EVP_aes_192_gcm,
EVP_aes_256_gcm — EVP AES
cipher in Galois Counter Mode
#include
<openssl/evp.h>
const EVP_CIPHER *
EVP_aes_128_gcm(void);
const EVP_CIPHER *
EVP_aes_192_gcm(void);
const EVP_CIPHER *
EVP_aes_256_gcm(void);
EVP_aes_128_gcm(),
EVP_aes_192_gcm(),
and
EVP_aes_256_gcm()
provide the Advanced Encryption Standard algorithm for 128, 192 and 256-bit
keys in and Galois Counter Mode in the
evp(3) framework.
For GCM mode ciphers, the behaviour of the EVP interface is subtly
altered and several additional
EVP_CIPHER_CTX_ctrl(3)
operations are required to function correctly. Some of the
EVP_CTRL_GCM_* control commands are older aliases
for corresponding EVP_CTRL_AEAD_* constants as
indicated below.
To avoid using the cumbersome and error-prone API documented in the present manual page, consider using the functions documented in EVP_AEAD_CTX_init(3) instead.
EVP_CTRL_AEAD_SET_IVLEN
(== EVP_CTRL_GCM_SET_IVLEN)NULL is recommended. This call can only be made
before specifying an initialization vector. If not called, the default IV
length of 12 bytes is used.
Using this control command is discouraged because section 5.2.1.1 of the specification explicitly recommends that implementations of GCM restrict support to the default IV length of 12 bytes for interoperability, efficiency, and simplicity of design.
EVP_CTRL_AEAD_SET_IV_FIXED
(== EVP_CTRL_GCM_SET_IV_FIXED)Otherwise, set the fixed field at the beginning of the initialization vector to the arg bytes pointed to by ptr. When encrypting, also generate the remaining bytes of the initialization vector at random. It is an error to specify an arg that is less than 4 or so large that less than 8 bytes remain.
EVP_CTRL_GCM_IV_GENEVP_CTRL_AEAD_GET_TAG
(== EVP_CTRL_GCM_GET_TAG)To specify any additional authenticated data (AAD), call
EVP_EncryptUpdate(3)
with the out argument set to
NULL.
EVP_CTRL_GCM_SET_IV_INVEVP_CTRL_AEAD_SET_TAG
(== EVP_CTRL_GCM_SET_TAG)To specify any additional authenticated data (AAD), call
EVP_DecryptUpdate(3)
with the out argument set to
NULL.
If the return value of EVP_DecryptFinal(3), EVP_DecryptFinal_ex(3), EVP_CipherFinal(3), or EVP_CipherFinal_ex(3) does not indicate success when decrypting, the authentication operation failed. In that case, regard any output data as corrupted.
AES_encrypt(3), evp(3), EVP_AEAD_CTX_init(3), EVP_aes_128_cbc(3), EVP_CIPHER_CTX_ctrl(3), EVP_EncryptInit(3)
Morris Dworkin, National Institute of Standards and Technology, Recommendation for Block Cipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC, NIST Special Publication 800-38D, Gaithersburg, Maryland, November 2007.
EVP_aes_128_gcm(),
EVP_aes_192_gcm(), and
EVP_aes_256_gcm() first appeared in OpenSSL 1.0.1
and have been available since OpenBSD 5.3.
| December 29, 2024 | openbsd |