On Thu, 7 May 2020 at 07:51, Niels Möller nisse@lysator.liu.se wrote:
Emil Velikov emil.l.velikov@gmail.com writes:
The direct $HASH_{Init,Update,Final} has been discouraged for a while. With the upcoming OpenSSL 3.0 it will be officially deprecated.
Add a handy macro, to avoid repetition and mistakes like in the current code. Namely - we're using SHA cblock/digest_len for md5 :-\
Thanks. Reducing code duplication with the macro is nice, but I think the handling of the context is a bit confusing. In the definiton of the nettle_hash structs, you use sizeof (NAME##_CTX), but in the functions you cast like (EVP_MD_CTX **)ctx. I think it will de clearer with something like
struct openssl_hash_ctx { EVP_MD_CTX *evp; };
analogous to struct openssl_cipher_ctx, and use that for all the hash functions. And it looks like the update function can be the same for all hashes, no need to have the macro define it.
Thanks for the suggestions Niels. Will try to update the series in a couple of days.
-Emil