EVP_CHACHA20(3ossl)
π EVP_CHACHA20 β like, the ChaCha20 stream cipher era π
okay so bestie, welcome to the 3ossl girlies' corner of the OpenSSL manual π
this one's all about EVP_chacha20 and EVP_chacha20_poly1305, which are literally the EVP ChaCha20 stream cipher functions. no cap, it's a short page but it ate β¨
π¦ SYNOPSIS π¦
#include <openssl/evp.h>
const EVP_CIPHER *EVP_chacha20(void);
const EVP_CIPHER *EVP_chacha20_poly1305(void);
π DESCRIPTION π
so, it's the ChaCha20 stream cipher, but for EVP. main character energy fr fr π₯
πΈ EVP_chacha20()
the ChaCha20 stream cipher, bestie. the key length is 256 bits and the IV is 128 bits long π
here's the cute part: the first 64 bits is a counter in little-endian order, followed by a 64 bit nonce. so like, for example, a nonce of:
0000000000000002
with an initial counter of 42 (2a in hex) would be expressed as:
2a000000000000000000000000000002
the way that math works outβ¦ iconic π§
π EVP_chacha20_poly1305()
authenticated encryption with ChaCha20-Poly1305 π just like EVP_chacha20(), the key is 256 bits and the IV is 96 bits. this one supports additional authenticated data (AAD) and produces a 128-bit authentication tag. if you want the deets, go check the "AEAD INTERFACE" in EVP_EncryptInit(3) section π«Ά
β NOTES β
okay, real talk time π developers should be aware of the negative performance implications of calling these functions multiple times β like, don't just spam them, babe β and should consider using EVP_CIPHER_fetch(3) with EVP_CIPHER-CHACHA(7) instead. there's more about that in "Performance" in crypto(7) if you wanna go deeper π
also heads up: RFC 7539 <https://www.rfc-editor.org/rfc/rfc7539.html#section-2.4> uses a 32 bit counter and a 96 bit nonce for the IV. just so you know π
π RETURN VALUES π
these functions return an EVP_CIPHER structure that contains the implementation of the symmetric cipher π
and if you wanna know what's inside that structure, see EVP_CIPHER_meth_new(3) for details π
π SEE ALSO π
π COPYRIGHT π
copyright 2017-2025 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 vibe check bestie β¨ this page is from version 3.5.6, dated 2026-04-07 β mwah, slay, periodt ππ
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms