# man > crypto(7ssl)

---
type: CommandReference
command: crypto
mode: man
section: 7ssl
source: man-pages
---

## Quick Reference
- `EVP_MD_fetch(NULL, "SHA2-256", NULL)` — Fetch a SHA-256 digest algorithm implementation.
- `EVP_CIPHER_fetch(NULL, "AES-128-CBC", NULL)` — Fetch an AES-128-CBC cipher.
- `OSSL_PROVIDER_load(NULL, "legacy")` — Load the legacy provider.
- `EVP_PKEY_CTX_new_from_name(NULL, "RSA", NULL)` — Create a public key context for RSA.
- Digest data: `EVP_MD_CTX_new()` → `EVP_DigestInit_ex(ctx, md, NULL)` → `EVP_DigestUpdate(ctx, msg, len)` → `EVP_DigestFinal_ex(ctx, out, &outlen)`.
- Encrypt data: `EVP_CIPHER_CTX_new()` → `EVP_EncryptInit_ex(ctx, cipher, NULL, key, iv)` → `EVP_EncryptUpdate(ctx, out, &outlen, in, inlen)` → `EVP_EncryptFinal_ex(ctx, out, &outlen)`.
- `OSSL_LIB_CTX *ctx = OSSL_LIB_CTX_new()` — Create a custom library context.
- `OSSL_LIB_CTX_load_config(ctx, "config.cnf")` — Load configuration into a library context.

## Name
crypto - OpenSSL cryptographic library

## Synopsis
See the individual manual pages for API details.

## Options
Not applicable (library interface).

## Examples

### Algorithm fetching

c
/* Fetch SHA256 */
EVP_MD *md = EVP_MD_fetch(NULL, "SHA2-256", NULL);
EVP_MD_free(md);

/* Fetch AES-128-CBC */
EVP_CIPHER *cipher = EVP_CIPHER_fetch(NULL, "AES-128-CBC", NULL);
EVP_CIPHER_free(cipher);

/* Fetch with property query (default provider) */
md = EVP_MD_fetch(NULL, "SHA2-256", "provider=default");
EVP_MD_free(md);

/* Load the legacy provider and fetch WHIRLPOOL */
OSSL_PROVIDER *legacy = OSSL_PROVIDER_load(NULL, "legacy");
md = EVP_MD_fetch(NULL, "WHIRLPOOL", "provider=legacy");
EVP_MD_free(md);
### Complete SHA-256 digest

c
#include <openssl/evp.h>
#include <openssl/bio.h>
#include <openssl/err.h>

int main(void)
{
    EVP_MD_CTX *ctx = NULL;
    EVP_MD *sha256 = NULL;
    const unsigned char msg[] = { 0x00, 0x01, 0x02, 0x03 };
    unsigned int len = 0;
    unsigned char *outdigest = NULL;
    int ret = 1;

    ctx = EVP_MD_CTX_new();
    if (ctx == NULL) goto err;

    sha256 = EVP_MD_fetch(NULL, "SHA256", NULL);
    if (sha256 == NULL) goto err;

    if (!EVP_DigestInit_ex(ctx, sha256, NULL)) goto err;
    if (!EVP_DigestUpdate(ctx, msg, sizeof(msg))) goto err;

    outdigest = OPENSSL_malloc(EVP_MD_get_size(sha256));
    if (outdigest == NULL) goto err;

    if (!EVP_DigestFinal_ex(ctx, outdigest, &len)) goto err;

    BIO_dump_fp(stdout, outdigest, len);
    ret = 0;

 err:
    OPENSSL_free(outdigest);
    EVP_MD_free(sha256);
    EVP_MD_CTX_free(ctx);
    if (ret != 0) ERR_print_errors_fp(stderr);
    return ret;
}
## See Also
[openssl(1)](https://www.chedong.com/phpMan.php/man/openssl/1/markdown), [ssl(7)](https://www.chedong.com/phpMan.php/man/ssl/7/markdown), [evp(7)](https://www.chedong.com/phpMan.php/man/evp/7/markdown), [OSSL_LIB_CTX(3)](https://www.chedong.com/phpMan.php/man/CTX/3/markdown), [openssl-threads(7)](https://www.chedong.com/phpMan.php/man/openssl-threads/7/markdown), [property(7)](https://www.chedong.com/phpMan.php/man/property/7/markdown), [OSSL_PROVIDER-default(7)](https://www.chedong.com/phpMan.php/man/PROVIDER-default/7/markdown), [OSSL_PROVIDER-base(7)](https://www.chedong.com/phpMan.php/man/PROVIDER-base/7/markdown), [OSSL_PROVIDER-FIPS(7)](https://www.chedong.com/phpMan.php/man/PROVIDER-FIPS/7/markdown), [OSSL_PROVIDER-legacy(7)](https://www.chedong.com/phpMan.php/man/PROVIDER-legacy/7/markdown), [OSSL_PROVIDER-null(7)](https://www.chedong.com/phpMan.php/man/PROVIDER-null/7/markdown), [openssl-glossary(7)](https://www.chedong.com/phpMan.php/man/openssl-glossary/7/markdown), [provider(7)](https://www.chedong.com/phpMan.php/man/provider/7/markdown)