Pádraig Brady <[email protected]> writes:

> Would it be better to call EVP_MD_CTX_init() rather than memset() ?
> Or even simpler, remove the explicit init and use EVP_DigestInit()
> rather than EVP_DigestInit_ex(), which the docs imply does an implicit
> init of the ctx.

The OpenSSL API naming convention isn't my favorite, to put it nicely.

My understanding based on the manual is that memset + EVP_DigestInit_ex
is more efficient than the other options [1]:

> The functions EVP_DigestInit(), EVP_DigestFinal() and
> EVP_MD_CTX_copy() are obsolete but are retained to maintain
> compatibility with existing code. New applications should use
> EVP_DigestInit_ex(), EVP_DigestFinal_ex() and EVP_MD_CTX_copy_ex()
> because they can efficiently reuse a digest context instead of
> initializing and cleaning it up on each call and allow non default
> implementations of digests to be specified.

Collin

[1] https://docs.openssl.org/master/man3/EVP_DigestInit/#notes

Reply via email to