The openssl/evp.h header provides a high-level interface to cryptographic functions.
| Facility Category | Key Symbols | Description |
|---|---|---|
| Message Digests | EVP_MD_CTX_new, EVP_DigestInit | Calculating hashes (SHA256, MD5, etc.). |
| Encryption | EVP_CIPHER_CTX_new, EVP_EncryptInit | Symmetric encryption (AES, etc.). |
| Public Key | EVP_PKEY_new, EVP_SignInit | Asymmetric cryptography and signatures. |
Context object for message digest (hash) operations.
Context object for symmetric cipher operations.
Structure representing a public or private key.
int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)Initializes the digest context ctx to use type.
Example:
#include <openssl/evp.h>
#include <stdio.h>
int main(void) {
EVP_MD_CTX *ctx = EVP_MD_CTX_new();
const EVP_MD *md = EVP_sha256();
unsigned char hash[EVP_MAX_MD_SIZE];
unsigned int len;
EVP_DigestInit_ex(ctx, md, NULL);
EVP_DigestUpdate(ctx, "Hello", 5);
EVP_DigestFinal_ex(ctx, hash, &len);
for(int i = 0; i < len; i++) printf("%02x", hash[i]);
printf("\n");
EVP_MD_CTX_free(ctx);
return 0;
}int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, size_t cnt)int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s)int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, ...)