EVP_AES_128_GCM(3ossl)

πŸ“¦ version 3.5.0, in opensuse-leap 16.0

πŸ’… EVP_AES_128_GCM(3ossl) β€” open up, it's the OpenSSL manual ✨

okay so bestie, you've found the AES page. yes, that AES β€” the one everybody's always whispering about. this is an OpenSSL manpage and it's honestly a lot, so grab a snack πŸ“, because we are going through every single one of these cipher functions together. no skipping, no cap.


πŸŽ€ NAME

so this whole squad of functions is the EVP AES cipher family. here they all are, exactly, because i refuse to leave a single one out:

EVP_aes_128_cbc, EVP_aes_192_cbc, EVP_aes_256_cbc, EVP_aes_128_cfb,
EVP_aes_192_cfb, EVP_aes_256_cfb, EVP_aes_128_cfb1, EVP_aes_192_cfb1,
EVP_aes_256_cfb1, EVP_aes_128_cfb8, EVP_aes_192_cfb8, EVP_aes_256_cfb8,
EVP_aes_128_cfb128, EVP_aes_192_cfb128, EVP_aes_256_cfb128,
EVP_aes_128_ctr, EVP_aes_192_ctr, EVP_aes_256_ctr, EVP_aes_128_ecb,
EVP_aes_192_ecb, EVP_aes_256_ecb, EVP_aes_128_ofb, EVP_aes_192_ofb,
EVP_aes_256_ofb, EVP_aes_128_cbc_hmac_sha1, EVP_aes_256_cbc_hmac_sha1,
EVP_aes_128_cbc_hmac_sha256, EVP_aes_256_cbc_hmac_sha256,
EVP_aes_128_ccm, EVP_aes_192_ccm, EVP_aes_256_ccm, EVP_aes_128_gcm,
EVP_aes_192_gcm, EVP_aes_256_gcm, EVP_aes_128_ocb, EVP_aes_192_ocb,
EVP_aes_256_ocb, EVP_aes_128_wrap, EVP_aes_192_wrap, EVP_aes_256_wrap,
EVP_aes_128_wrap_pad, EVP_aes_192_wrap_pad, EVP_aes_256_wrap_pad,
EVP_aes_128_xts, EVP_aes_256_xts - EVP AES cipher

like, that's forty-something functions. it's giving overachiever. we love her for it πŸ’–


✨ SYNOPSIS

#include <openssl/evp.h>

const EVP_CIPHER *EVP_ciphername(void)

quick translation bestie: EVP_ciphername is literally just a placeholder for any of the cipher functions described here β€” like, imagine it standing in for EVP_aes_128_cbc or whichever one your heart desires. it's not a real function, it's the vibe of a function 🫢


🌸 DESCRIPTION

the AES encryption algorithm, but for EVP. that's the whole premise. now let's break it down by group πŸ‘‘

the "classic modes" girlies

EVP_aes_128_cbc(), EVP_aes_192_cbc(), EVP_aes_256_cbc(), EVP_aes_128_cfb(), EVP_aes_192_cfb(), EVP_aes_256_cfb(), EVP_aes_128_cfb1(), EVP_aes_192_cfb1(), EVP_aes_256_cfb1(), EVP_aes_128_cfb8(), EVP_aes_192_cfb8(), EVP_aes_256_cfb8(), EVP_aes_128_cfb128(), EVP_aes_192_cfb128(), EVP_aes_256_cfb128(), EVP_aes_128_ctr(), EVP_aes_192_ctr(), EVP_aes_256_ctr(), EVP_aes_128_ecb(), EVP_aes_192_ecb(), EVP_aes_256_ecb(), EVP_aes_128_ofb(), EVP_aes_192_ofb(), EVP_aes_256_ofb()

AES for 128, 192 and 256 bit keys in the following modes: CBC, CFB with 128-bit shift, CFB with 1-bit shift, CFB with 8-bit shift, CTR, ECB, and OFB.

so yes β€” three key sizes, seven modes, and you get to pick your fighter. the CFB ones come in three flavors of shift (128-bit, 1-bit, 8-bit) which is why the list is so long. she's thorough πŸ’…

the authenticated CBC + HMAC ones (handle with care 😭)

EVP_aes_128_cbc_hmac_sha1(), EVP_aes_256_cbc_hmac_sha1()

Authenticated encryption with AES in CBC mode using SHA-1 as HMAC, with keys of 128 and 256 bits length respectively. The authentication tag is 160 bits long.

EVP_aes_128_cbc_hmac_sha256(), EVP_aes_256_cbc_hmac_sha256()

Authenticated encryption with AES in CBC mode using SHA256 (SHA-2, 256-bits) as HMAC, with keys of 128 and 256 bits length respectively. The authentication tag is 256 bits long.

okay and now the part where you need to actually pay attention because both of these groups have the same big warning:

WARNING: this is not intended for usage outside of TLS and requires calling of some undocumented ctrl functions. These ciphers do not conform to the EVP AEAD interface.

like, fr fr β€” these are TLS-only girls, not for your random side project. the ctrl functions they need are undocumented, and they do not conform to the EVP AEAD interface. repeating that because it matters: not AEAD interface conformant. don't get caught out πŸ™ˆ

the AEAD trio (CCM, GCM, OCB) πŸ”₯

EVP_aes_128_ccm(), EVP_aes_192_ccm(), EVP_aes_256_ccm(), EVP_aes_128_gcm(), EVP_aes_192_gcm(), EVP_aes_256_gcm(), EVP_aes_128_ocb(), EVP_aes_192_ocb(), EVP_aes_256_ocb()

AES for 128, 192 and 256 bit keys in CBC-MAC Mode (CCM), Galois Counter Mode (GCM) and OCB Mode respectively. These ciphers require additional control operations to function correctly, see the "AEAD Interface" in EVP_EncryptInit(3) section for details.

yep β€” CCM = CBC-MAC Mode, GCM = Galois Counter Mode, OCB = OCB Mode. and listen: these require extra control operations to actually work right. if you don't do them, it's not gonna go well. go read the "AEAD Interface" section in EVP_EncryptInit(3). i'm serious, bestie, go read it πŸ“–

the key wrap crew 🎁

EVP_aes_128_wrap(), EVP_aes_192_wrap(), EVP_aes_256_wrap(), EVP_aes_128_wrap_pad(), EVP_aes_192_wrap_pad(), EVP_aes_256_wrap_pad()

AES key wrap with 128, 192 and 256 bit keys, as according to RFC 3394 section 2.2.1 ("wrap") and RFC 5649 section 4.1 ("wrap with padding") respectively.

so the plain _wrap ones follow RFC 3394 section 2.2.1 (that's "wrap"), and the _wrap_pad ones follow RFC 5649 section 4.1 (that's "wrap with padding"). respectively. she said what she said ✨

XTS mode β€” the storage-device one πŸ‘‘

EVP_aes_128_xts(), EVP_aes_256_xts()

AES XTS mode (XTS-AES) is standardized in IEEE Std. 1619-2007 and described in NIST SP 800-38E. The XTS (XEX-based tweaked-codebook mode with ciphertext stealing) mode was designed by Prof. Phillip Rogaway of University of California, Davis, intended for encrypting data on a storage device.

yes, an actual professor designed it β€” Prof. Phillip Rogaway of University of California, Davis β€” and it's for encrypting data on a storage device. she has a whole resume.

XTS-AES provides confidentiality but not authentication of data. It also requires a key of double-length for protection of a certain key size. In particular, XTS-AES-128 (EVP_aes_128_xts) takes input of a 256-bit key to achieve AES 128-bit security, and XTS-AES-256 (EVP_aes_256_xts) takes input of a 512-bit key to achieve AES 256-bit security.

read that again bestie: confidentiality but NOT authentication. and the keys are double-length β€” EVP_aes_128_xts takes a 256-bit key to get AES 128-bit security, EVP_aes_256_xts takes a 512-bit key to get AES 256-bit security. don't show up with a short key, it's not the move 😭

The XTS implementation in OpenSSL does not support streaming. That is there must only be one EVP_EncryptUpdate(3) call per EVP_EncryptInit_ex(3) call (and similarly with the "Decrypt" functions).

no streaming, periodt. one EVP_EncryptUpdate(3) call per EVP_EncryptInit_ex(3) call β€” and same deal on the "Decrypt" side. that's the rule.

The iv parameter to EVP_EncryptInit_ex(3) or EVP_DecryptInit_ex(3) is the XTS "tweak" value.

oh and the iv parameter you pass to EVP_EncryptInit_ex(3) or EVP_DecryptInit_ex(3)? that's the XTS "tweak" value. not an iv, a tweak. terminology slay πŸ’…


⭐ NOTES

okay so real talk β€” calling these functions over and over has negative performance implications, and developers should be aware of that. instead, consider using EVP_CIPHER_fetch(3) with EVP_CIPHER-AES(7). and if you want the full tea, see "Performance" in crypto(7). iykyk πŸ”₯


πŸ¦‹ RETURN VALUES

these functions return an EVP_CIPHER structure that contains the implementation of the symmetric cipher. if you want the details of what's actually inside that EVP_CIPHER structure, see EVP_CIPHER_meth_new(3). she's got the lore 🌈


πŸ‘‘ SEE ALSO

go read these too, they're the supporting cast and honestly they ate πŸ’œ


Copyright 2017-2023 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


and that's the whole page, bestie 🫢 go encrypt something responsibly. mwah πŸ’–

✨ sign-off time: this is from OpenSSL 3.5.0, dated 2026-09-25 β€” and the title was EVP_AES_128_GCM(3ossl), in case you forgot where you were. bye diva πŸŽ€
πŸ“¦ where this page comes from