EVP_AES_128_GCM(3)
π EVP_AES_128_GCM(3) π
okay bestie, this is the Library Functions Manual page for EVP_AES_128_GCM(3) β the AES-GCM cipher girlies β and itβs lowkey a whole control-command saga. π
β¨
π¦ NAME π¦
EVP_aes_128_gcm, EVP_aes_192_gcm, EVP_aes_256_gcm β EVP AES cipher in Galois Counter Mode. the trio ate, no cap. π«Ά
β¨ SYNOPSIS β¨
Link against library libcrypto and include <openssl/evp.h>:
#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);
π DESCRIPTION π
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 Galois Counter Mode in the evp(3) framework. iconic framework moment.
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 EVP_CTRL_GCM_* control commands are older aliases for the corresponding EVP_CTRL_AEAD_* constants as indicated below. iykyk.
To avoid using the cumbersome and error-prone API documented in this present manual page, consider using the functions documented in EVP_AEAD_CTX_init(3) instead. bestie, this is the βplease use the nicer APIβ memo.
π§ Configuration controls
EVP_CTRL_AEAD_SET_IVLEN(== EVP_CTRL_GCM_SET_IVLEN) β Set the length of the initialization vector toargbytes; theptrargument is ignored, and passingNULLis recommended. This call can only be made before specifying an initialization vector. If not called, the default IV length of12bytes is used. Discouraged: Using this control command is discouraged because section5.2.1.1of the specification explicitly recommends that implementations of GCM restrict support to the default IV length of12bytes for interoperability, efficiency, and simplicity of design. fr fr, donβt fight the spec.EVP_CTRL_AEAD_SET_IV_FIXED(== EVP_CTRL_GCM_SET_IV_FIXED) β Usually,-1is passed forarg. In that case, the complete initialization vector is copied fromptr. Otherwise, set the fixed field at the beginning of the initialization vector to theargbytes pointed to byptr. When encrypting, also generate the remaining bytes of the initialization vector at random. It is an error to specify anargthat is less than4or so large that less than8bytes remain. math girlies, pay attention.
π₯ Encryption controls
EVP_CTRL_GCM_IV_GENβ Generate the precounter block from the initialization vector, copy the lastargbytes of the initialization vector to the location pointed to byptr, or all of it ifargis less than1or greater than the length of the initialization vector, and increment the initialization vector by1. Incrementing ignores the IV length and the fixed field length that may have been configured earlier and always operates on the last eight bytes of the initialization vector. It is an error to issue this command when no key or no initialization vector is set. that last-eight-bytes rule is the main character.EVP_CTRL_AEAD_GET_TAG(== EVP_CTRL_GCM_GET_TAG) β Writeargbytes of the tag value to the location pointed to byptr. This control command only makes sense after all data has been processed, e.g. after callingEVP_EncryptFinal(3). It is an error to issue this command while decrypting, before any data has been processed, or to specify anargthat is less than1or greater than16. tag check, but make it aftercare.
To specify any additional authenticated data (AAD), call EVP_EncryptUpdate(3) with the out argument set to NULL. AAD era.
πΈ Decryption controls
EVP_CTRL_GCM_SET_IV_INVβ Copyargbytes fromptrto the last bytes of the initialization vector and generate the precounter block from the initialization vector. The library does not check whether the arguments are consistent with the configured initialization vector and fixed field lengths. When default lengths are in use, pass8forarg. In that case, this control command sets the invocation field. It is an error to issue this command when no key or no initialization vector is set, or when encrypting. no consistency check bestie, so donβt get cute with mismatched lengths.EVP_CTRL_AEAD_SET_TAG(== EVP_CTRL_GCM_SET_TAG) β Set the expected tag to theargbytes located atptr. This control command is mandatory before any data is processed, e.g. before callingEVP_DecryptUpdate(3). It is an error to issue this command while encrypting or to specify anargthat is less than1or greater than16. mandatory means mandatory, bestie.
To specify any additional authenticated data (AAD), call EVP_DecryptUpdate(3) with the out argument set to NULL. AAD again, but decryption flavour.
If the return value ofEVP_DecryptFinal(3),EVP_DecryptFinal_ex(3),EVP_CipherFinal(3), orEVP_CipherFinal_ex(3)does not indicate success when decrypting, the authentication operation failed. In that case, regard any output data as corrupted. like, do not trust that output. periodt.
π¦ SEE ALSO π¦
AES_encrypt(3)evp(3)EVP_AEAD_CTX_init(3)EVP_aes_128_cbc(3)EVP_CIPHER_CTX_ctrl(3)EVP_EncryptInit(3)
π STANDARDS π
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. citation slay.
π HISTORY π
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. legacy icons, honestly.
Source/version:Debian; date:June 8, 2025β thatβs the cute footer sign-off forEVP_AES_128_GCM(3), bestie. byeee π
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2024 Ingo Schwarze <schwarze@openbsd.org>
- Copyright (c) 2012 The OpenSSL Project. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms