EVP_CHACHA20(3ossl)

πŸ“¦
version 15.1 Β· 3 versions
, in freebsd 15.1

πŸ’œ 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 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