PROVIDER-DIGEST(7ossl)
πΈ PROVIDER-DIGEST(7ossl) π
okay bestie, buckle up β this is provider-digest, and it's literally the manual page for the digest library β provider functions. that <-> is doing a lot of heavy lifting, iykyk. this is 7ossl, so it's a provider-level page, not your cute little everyday command. π
β¨ NAME β¨
provider-digest β the digest library <-> provider functions. that's the whole vibe, no cap. π¦
π SYNOPSIS π
ok so this is the part where libcrypto and your provider hold hands. look at all these signatures, they are not actual functions, they're function signatures for OSSL_DISPATCH arrays. don't come for me, that's just how it is π
#include <openssl/core_dispatch.h>
#include <openssl/core_names.h>
/*
* Digests support the following function signatures in OSSL_DISPATCH arrays.
* (The function signatures are not actual functions).
*/
/* Context management */
void *OSSL_FUNC_digest_newctx(void *provctx);
void OSSL_FUNC_digest_freectx(void *dctx);
void *OSSL_FUNC_digest_dupctx(void *dctx);
void OSSL_FUNC_digest_copyctx(void *voutctx, void *vinctx);
/* Digest generation */
int OSSL_FUNC_digest_init(void *dctx, const OSSL_PARAM params[]);
int OSSL_FUNC_digest_update(void *dctx, const unsigned char *in, size_t inl);
int OSSL_FUNC_digest_final(void *dctx, unsigned char *out, size_t *outl,
size_t outsz);
int OSSL_FUNC_digest_digest(void *provctx, const unsigned char *in, size_t inl,
unsigned char *out, size_t *outl, size_t outsz);
/* Digest parameter descriptors */
const OSSL_PARAM *OSSL_FUNC_digest_gettable_params(void *provctx);
/* Digest operation parameter descriptors */
const OSSL_PARAM *OSSL_FUNC_digest_gettable_ctx_params(void *dctx,
void *provctx);
const OSSL_PARAM *OSSL_FUNC_digest_settable_ctx_params(void *dctx,
void *provctx);
/* Digest parameters */
int OSSL_FUNC_digest_get_params(OSSL_PARAM params[]);
/* Digest operation parameters */
int OSSL_FUNC_digest_set_ctx_params(void *dctx, const OSSL_PARAM params[]);
int OSSL_FUNC_digest_get_ctx_params(void *dctx, OSSL_PARAM params[]);
like, yes, they're all here. every single one. we don't skip. π«Ά
π DESCRIPTION π
so real talk: this documentation is primarily aimed at provider authors. if that's not you, go peek at provider(7) for the bigger picture, bestie.
the DIGEST operation is what lets providers implement digest algorithms and then make them available to applications through the API functions EVP_DigestInit_ex(3), EVP_DigestUpdate(3) and EVP_DigestFinal(3) β plus all the other related functions that come along for the ride. β¨
all the "functions" we're talking about here get passed as function pointers between libcrypto and the provider, inside OSSL_DISPATCH(3) arrays, via OSSL_ALGORITHM(3) arrays that the provider's provider_query_operation() function returns (peep "Provider Functions" in provider-base(7) for that one).
every single one of these "functions" has a matching function type definition named OSSL_FUNC_{name}_fn, plus a lil helper function that grabs the function pointer out of an OSSL_DISPATCH(3) element, named OSSL_FUNC_{name}. so for example, the "function" OSSL_FUNC_digest_newctx() comes with these two besties:
typedef void *(OSSL_FUNC_digest_newctx_fn)(void *provctx);
static ossl_inline OSSL_FUNC_digest_newctx_fn
OSSL_FUNC_digest_newctx(const OSSL_DISPATCH *opf);
and the OSSL_DISPATCH(3) arrays are indexed by numbers that show up as macros in openssl-core_dispatch.h(7), like this:
OSSL_FUNC_digest_newctx OSSL_FUNC_DIGEST_NEWCTX
OSSL_FUNC_digest_freectx OSSL_FUNC_DIGEST_FREECTX
OSSL_FUNC_digest_dupctx OSSL_FUNC_DIGEST_DUPCTX
OSSL_FUNC_digest_copyctx OSSL_FUNC_DIGEST_COPYCTX
OSSL_FUNC_digest_init OSSL_FUNC_DIGEST_INIT
OSSL_FUNC_digest_update OSSL_FUNC_DIGEST_UPDATE
OSSL_FUNC_digest_final OSSL_FUNC_DIGEST_FINAL
OSSL_FUNC_digest_digest OSSL_FUNC_DIGEST_DIGEST
OSSL_FUNC_digest_get_params OSSL_FUNC_DIGEST_GET_PARAMS
OSSL_FUNC_digest_get_ctx_params OSSL_FUNC_DIGEST_GET_CTX_PARAMS
OSSL_FUNC_digest_set_ctx_params OSSL_FUNC_DIGEST_SET_CTX_PARAMS
OSSL_FUNC_digest_gettable_params OSSL_FUNC_DIGEST_GETTABLE_PARAMS
OSSL_FUNC_digest_gettable_ctx_params OSSL_FUNC_DIGEST_GETTABLE_CTX_PARAMS
OSSL_FUNC_digest_settable_ctx_params OSSL_FUNC_DIGEST_SETTABLE_CTX_PARAMS
now, important: a digest algorithm implementation may not implement all of these functions. to actually be usable, you want all or none of OSSL_FUNC_digest_newctx, OSSL_FUNC_digest_freectx, OSSL_FUNC_digest_init, OSSL_FUNC_digest_update, OSSL_FUNC_digest_final and OSSL_FUNC_digest_get_params implemented. yes, all or none, that's not a drill. everything else? optional, do it if you feel like it π
π§ Context Management Functions π§
OSSL_FUNC_digest_newctx()β should create and return a pointer to a provider-side structure that holds context info during a digest operation. a pointer to this context gets passed back in a bunch of the other digest operation function calls. theprovctxparameter is the provider context generated during provider initialisation (seeprovider(7)). main character energy, honestly πOSSL_FUNC_digest_freectx()β gets handed a pointer to the provider-side digest context in thedctxparameter. this function should free any resources associated with that context. clean up your room, bestie π§ΉOSSL_FUNC_digest_dupctx()β should duplicate the provider-side digest context in thedctxparameter and return the duplicate copy. two of them. twins. π«ΆOSSL_FUNC_digest_copyctx()β should copy the provider-side digest context in thevinctxparameter over to thevoutctxparameter, which is another provider-side context. this one gets used inEVP_MD_CTX_copy_exto speed up HMAC operations in PBKDF2 β glow-up via performance β¨. it's optional, anddupctxwill be used instead if there's noEVP_MD_CTX_copy_exfunction.
π₯ Digest Generation Functions π₯
OSSL_FUNC_digest_init()β initialises a digest operation, given a newly created provider-side digest context in thedctxparameter. ifparamsisn'tNULL, it should be set on the context kinda like how you'd useOSSL_FUNC_digest_set_ctx_params().OSSL_FUNC_digest_update()β gets called to feed in data that's gonna be digested, as part of a digest operation you already initialised. thedctxparameter holds a pointer to a previously initialised provider-side context.OSSL_FUNC_digest_update()should digestinlbytes of data at the location thatinpoints to. and it may be called multiple times for a single digest operation β feed it, feed it again, it's chill πOSSL_FUNC_digest_final()β generates the digest that got started through earlierOSSL_FUNC_digest_init()andOSSL_FUNC_digest_update()calls. thedctxparameter holds a pointer to the provider-side context. the digest should be written to*outand the digest's length to*outl. and the digest should not exceedoutszbytes β respect the boundary, fr fr.OSSL_FUNC_digest_digest()β the "oneshot" digest function π―. no provider-side digest context gets used here. instead, the provider context that was created during provider initialisation gets passed in theprovctxparameter (seeprovider(7)).inlbytes atinshould be digested and the result stored atout. the length of the digest should be stored in*outl, which should not exceedoutszbytes. one and done.
π Digest Parameters π
go check OSSL_PARAM(3) for more deets on the parameters structure all these functions use.
OSSL_FUNC_digest_get_params()β gets the details of the algorithm implementation and stores them inparams.OSSL_FUNC_digest_set_ctx_params()β sets digest operation parameters for the provider-side digest contextdctxtoparams. any parameter settings are additional to whatever was set before. and passingNULLforparamsshould return true.OSSL_FUNC_digest_get_ctx_params()β gets digest operation details out of the given provider-side digest contextdctxand stores them inparams. passingNULLforparamsshould return true. (yes the original says "details details", she's quirky like that π)OSSL_FUNC_digest_gettable_params()β returns a constantOSSL_PARAM(3)array holding descriptors of the parameters thatOSSL_FUNC_digest_get_params()can handle.OSSL_FUNC_digest_gettable_ctx_params()andOSSL_FUNC_digest_settable_ctx_params()β both return constantOSSL_PARAM(3)arrays as descriptors of the parameters thatOSSL_FUNC_digest_get_ctx_params()andOSSL_FUNC_digest_set_ctx_params()can handle, respectively. the array is based on the current state of the provider-side context ifdctxis notNULL, and on the provider-side algorithmprovctxotherwise. iykyk π
the parameters that built-in digests currently recognise with this function are below. ngl, not all parameters are relevant to, or even understood by, all digests β so don't assume β
"blocksize"(OSSL_DIGEST_PARAM_BLOCK_SIZE)<unsigned integer>β the digest block size. the length of the"blocksize"parameter should not exceed that of asize_t."size"(OSSL_DIGEST_PARAM_SIZE)<unsigned integer>β the digest output size. the length of the"size"parameter should not exceed that of asize_t."flags"(OSSL_DIGEST_PARAM_FLAGS)<unsigned integer>β diverse flags describing exceptional behaviour for the digest. here's the whole flag family πEVP_MD_FLAG_ONESHOTβ this digest method can only handle one block of input.EVP_MD_FLAG_XOFβ this digest method is an extensible-output function (XOF). slay, flexible output β¨EVP_MD_FLAG_DIGALGID_NULLβ when setting up a DigestAlgorithmIdentifier, this flag will have the parameter set toNULLby default. use this for PKCS#1. note: if combined withEVP_MD_FLAG_DIGALGID_ABSENT, the latter will override.EVP_MD_FLAG_DIGALGID_ABSENTβ when setting up a DigestAlgorithmIdentifier, this flag will have the parameter left absent by default. note: if combined withEVP_MD_FLAG_DIGALGID_NULL, the latter will be overridden.EVP_MD_FLAG_DIGALGID_CUSTOMβ custom DigestAlgorithmIdentifier handling via ctrl, withEVP_MD_FLAG_DIGALGID_ABSENTas default. note: if combined withEVP_MD_FLAG_DIGALGID_NULL, the latter will be overridden. currently unused π
the length of the "flags" parameter should equal that of an unsigned long int.
π¦ Digest Context Parameters π¦
OSSL_FUNC_digest_set_ctx_params()β sets digest parameters associated with the given provider-side digest contextdctxtoparams. any parameter settings are additional to whatever was previously set. seeOSSL_PARAM(3)for more deets on the parameters structure.OSSL_FUNC_digest_get_ctx_params()β gets details of the currently set parameter values associated with the give provider-side digest contextdctxand stores them inparams. seeOSSL_PARAM(3)for more deets on the parameters structure. (yes, "the give provider side", we love a typo moment π)
π RETURN VALUES π
OSSL_FUNC_digest_newctx()andOSSL_FUNC_digest_dupctx()β should return the newly created provider-side digest context, orNULLon failure.OSSL_FUNC_digest_init(),OSSL_FUNC_digest_update(),OSSL_FUNC_digest_final(),OSSL_FUNC_digest_digest(),OSSL_FUNC_digest_set_params()andOSSL_FUNC_digest_get_params()β should return1for success or0on error. that's the whole scoring system, pass/fail πOSSL_FUNC_digest_size()β should return the digest size.OSSL_FUNC_digest_block_size()β should return the block size of the underlying digest algorithm.
and that's where part one leaves us bestie β more incoming, do not touch that dial πβ¨
π BUGS π
ok so there's one little thing, and it's giving "known limitation, not a bug per se, but ur girl's gotta tell you" π
The EVP_Q_digest(), EVP_Digest() and EVP_DigestFinal_ex() API calls do not expect the digest size to be larger than EVP_MAX_MD_SIZE. Like, that's just not a vibe they're built for.
Which means: any algorithm that produces bigger digests than that is literally unusable with those API calls. Not "kinda awkward", not "works with a warning" β unusable. Periodt. So if you're out here inventing a chonky 300-byte digest and wondering why EVP_Digest() is acting brand newβ¦ that's why bestie π«
π SEE ALSO π
okay the reading list is long and honestly kind of iconic, so buckle up and go meet the whole fam π
provider(7)OSSL_PROVIDER-FIPS(7)OSSL_PROVIDER-default(7)OSSL_PROVIDER-legacy(7)EVP_MD-common(7)EVP_MD-BLAKE2(7)EVP_MD-MD2(7)EVP_MD-MD4(7)EVP_MD-MD5(7)EVP_MD-MD5-SHA1(7)EVP_MD-MDC2(7)EVP_MD-RIPEMD160(7)EVP_MD-SHA1(7)EVP_MD-SHA2(7)EVP_MD-SHA3(7)EVP_MD-KECCAK(7)EVP_MD-SHAKE(7)EVP_MD-SM3(7)EVP_MD-WHIRLPOOL(7)EVP_MD-NULL(7)life_cycle-digest(7)EVP_DigestInit(3)
(yes, EVP_MD-KECCAK(7) and EVP_MD-SHAKE(7) are chilling there with no comma between them in the original β I'm not gonna gaslight you and pretend otherwise, that's just how it's printed π
)
π°οΈ HISTORY π°οΈ
a lil lore drop for the timeline girlies β¨
- The provider DIGEST interface was introduced in OpenSSL 3.0.
OSSL_FUNC_digest_copyctx()was added in 3.5 version.
so yeah, if you're on something ancient and OSSL_FUNC_digest_copyctx() isn't showing up, that's not you being bad at this β the feature literally wasn't born yet π
π COPYRIGHT π
Copyright 2019-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>.
like pls respect the license, it's the bare minimum and it's free π
okay that's the whole page bestie, you made it to the end π go forth and digest responsibly π¦
source 3.5.6 β¨ dated 2026-04-07 β¨ PROVIDER-DIGEST(7ossl) β slay, bye π
π
π¦ 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