AES_ENCRYPT(3)
β¨ AES_ENCRYPT(3) β¨
okay so bestie, this is the Library Functions Manual page for the low-level AES squad, and it is literally the βI can handle raw cipher keysβ corner of the library. the whole crew is here: AES_set_encrypt_key, AES_set_decrypt_key, AES_encrypt, AES_decrypt, and AES_cbc_encrypt. π
π NAME π
these functions are the low-level interface to the AES symmetric cipher, and the lineup is AES_set_encrypt_key, AES_set_decrypt_key, AES_encrypt, AES_decrypt, and AES_cbc_encrypt. periodt. π
β¨ SYNOPSIS β¨
bestie, hereβs the exact spellbook:
library βlibcryptoβ #include <openssl/aes.h>
int
AES_set_encrypt_key(const unsigned char *userKey, const int bits,
AES_KEY *key);
int
AES_set_decrypt_key(const unsigned char *userKey, const int bits,
AES_KEY *key);
void
AES_encrypt(const unsigned char *in, unsigned char *out,
const AES_KEY *key);
void
AES_decrypt(const unsigned char *in, unsigned char *out,
const AES_KEY *key);
void
AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
size_t length, const AES_KEY *key, unsigned char *ivec,
const int enc);
πΈ DESCRIPTION πΈ
these functions give you a low-level interface to the AES symmetric cipher algorithm, also called Rijndael. for reasons of flexibility, the recommendation is that application programs use the high-level interface described in EVP_EncryptInit(3) and EVP_aes_128_cbc(3) instead whenever possible. iykyk. π¦
AES_KEY is a structure that can hold up to 60 int values and a number of rounds. sheβs compact but sheβs carrying a lot. π«Ά
AES_set_encrypt_key() expands the userKey, which is bits long, into the key structure to prepare for encryption. the number of bits and bytes read from userKey, the number of int values stored into key, and the number of rounds are as follows:
bits=128,bytes=16,ints=44,rounds=10bits=192,bytes=24,ints=52,rounds=12bits=256,bytes=32,ints=60,rounds=14
AES_set_decrypt_key() does the same, but in preparation for decryption. same energy, opposite direction. π₯
AES_encrypt() reads a single 16 byte block from *in, encrypts it with the key, and writes the 16 resulting bytes to *out. the 16 byte buffers starting at in and out can overlap, and in and out can even point to the same memory location. no cap, that overlap is allowed. β¨
AES_decrypt() decrypts a single block and is otherwise identical to AES_encrypt(). twin behavior, different job. π
if enc is non-zero, AES_cbc_encrypt() encrypts len bytes at in to out using the 128 bit key and the 128 bit initialization vector ivec in CBC mode. if enc is 0, AES_cbc_encrypt() performs the corresponding decryption. π
π«Ά RETURN VALUES π«Ά
AES_set_encrypt_key() and AES_set_decrypt_key() return 0 for success, -1 if userKey or key is NULL, or -2 if the number of bits is unsupported. thatβs the whole mood ring: 0, -1, -2. π
π SEE ALSO π
π STANDARDS π
ISO/IEC 18033-3:2010 Information technology β Security techniques β Encryption algorithms β Part 3: Block ciphers
π°οΈ HISTORY π°οΈ
these functions first appeared in OpenSSL 0.9.7 and have been available since OpenBSD 3.2. vintage but still on the timeline, bestie. π
π AUTHORS π
- Vincent Rijmen
- Antoon Bosselaers
- Paulo Barreto
π cute sign-off: this page is from Debian, dated December 20, 2025, and its manual tag is AES_ENCRYPT(3). periodt, bestie. π
π¦ 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) 2019 Ingo Schwarze <schwarze@openbsd.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms