EVP(7ossl)
π EVP(7ossl) β high-level cryptographic functions π
okay so this is the EVP(7ossl) page from the OpenSSL manual set (yes, section 7, we're fancy like that), and it's basically the group chat where all the high-level crypto functions hang out. bestie, if you've ever been like "why is crypto so much work," it's because you were doing it the hard way. this page is the glow-up. β¨
β¨ SYNOPSIS β¨
#include <openssl/evp.h>
that's it. one include and you're in. π«Ά
π¦ DESCRIPTION π¦
The EVP library provides a high-level interface to cryptographic functions. that's the whole vibe β high-level, meaning you don't have to touch the scary low-level bits. iconic.
The EVP_SealXXX and EVP_OpenXXX functions provide public key encryption and decryption to implement digital "envelopes". yes, like an envelope, but cryptographic. slay. π
The EVP_DigestSignXXX and EVP_DigestVerifyXXX functions implement digital signatures and Message Authentication Codes (MACs). Also see the older EVP_SignXXX and EVP_VerifyXXX functions β they're the vintage versions, still valid, just older. npc energy but in a respected way.
Symmetric encryption is available with the EVP_EncryptXXX functions. The EVP_DigestXXX functions provide message digests. both absolute main characters in their own lanes. π₯
The EVP_PKEYXXX functions provide a high-level interface to asymmetric algorithms.
π making and managing keys π
- To create a new
EVP_PKEYseeEVP_PKEY_new(3). EVP_PKEYs can be associated with a private key of a particular algorithm by using the functions described on theEVP_PKEY_fromdata(3)page.- Or new keys can be generated using
EVP_PKEY_keygen(3). EVP_PKEYs can be compared usingEVP_PKEY_eq(3).- Or printed using
EVP_PKEY_print_private(3). EVP_PKEY_todata(3)can be used to convert a key back into anOSSL_PARAM(3)array. yes bestie, round-trip it back. π§
π what the EVP_PKEY functions actually do π
The EVP_PKEY functions support the full range of asymmetric algorithm operations:
- For key agreement see
EVP_PKEY_derive(3). - For signing and verifying see
EVP_PKEY_sign(3),EVP_PKEY_verify(3)andEVP_PKEY_verify_recover(3). However, note that these functions do not perform a digest of the data to be signed. Therefore, normally you would use theEVP_DigestSignInit(3)functions for this purpose. π that's the one you actually want, like 99% of the time. - For encryption and decryption see
EVP_PKEY_encrypt(3)andEVP_PKEY_decrypt(3)respectively. However, note that these functions perform encryption and decryption only. As public key encryption is an expensive operation, normally you would wrap an encrypted message in a "digital envelope" using theEVP_SealInit(3)andEVP_OpenInit(3)functions. lowkey expensive, so wrap it up, periodt.
π passwords and base64 π
The EVP_BytesToKey(3) function provides some limited support for password based encryption. Careful selection of the parameters will provide a PKCS#5 PBKDF1 compatible implementation. However, new applications should not typically use this (preferring, for example, PBKDF2 from PCKS#5). so like... it exists, it's there, but it's giving legacy. π
The EVP_EncodeXXX and EVP_DecodeXXX functions implement base64 encoding and decoding. ily base64, never change. π
π ENGINEs (yes, the swap-in magic) π
All the symmetric algorithms (ciphers), digests and asymmetric algorithms (public key algorithms) can be replaced by ENGINE modules providing alternative implementations.
If ENGINE implementations of ciphers or digests are registered as defaults, then the various EVP functions will automatically use those implementations automatically in preference to built in software implementations. like, they just pick it up, no extra work from you. For more information, consult the engine(3) man page.
π and now the warning section, sorry π
Although low-level algorithm specific functions exist for many algorithms their use is discouraged. fr fr. here's why:
- They cannot be used with an ENGINE.
- ENGINE versions of new algorithms cannot be accessed using the low-level functions.
- Also makes code harder to adapt to new algorithms.
- And some options are not cleanly supported at the low-level.
- And some operations are more efficient using the high-level interface.
so bestie, use the high-level interface. it's not a phase, it's a lifestyle. π§ββοΈ
πΈ SEE ALSO πΈ
EVP_DigestInit(3), EVP_EncryptInit(3), EVP_OpenInit(3), EVP_SealInit(3), EVP_DigestSignInit(3), EVP_SignInit(3), EVP_VerifyInit(3), EVP_EncodeInit(3), EVP_PKEY_new(3), EVP_PKEY_fromdata(3), EVP_PKEY_todata(3), EVP_PKEY_keygen(3), EVP_PKEY_print_private(3), EVP_PKEY_decrypt(3), EVP_PKEY_encrypt(3), EVP_PKEY_sign(3), EVP_PKEY_verify(3), EVP_PKEY_verify_recover(3), EVP_PKEY_derive(3), EVP_BytesToKey(3), ENGINE_by_id(3)
the whole friend group, linked. go read them, they're all bangers. π
π COPYRIGHT π
Copyright 2000-2024 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 page!! π this was version 3.5.6, dated 2026-04-07 β so go forth, use the high-level interface, and remember: low-level functions are not the move. mwah. ππ
π¦ 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