From ae7c17868992ac2c64c46ba418d46cf75374054f Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Thu, 1 Jul 2021 11:27:04 -0400 Subject: [PATCH] Add some OpenSSL compatibility aliases. EVP_MD_nid, in OpenSSL, is the same as EVP_MD_type. EVP_MD_type seems to be the preferred spelling, so put EVP_MD_nid in the deprecated bucket. Also add an EVP_MD_do_all alias to EVP_MD_do_all_sorted. Change-Id: I4e7b800902459ac5cb9ef0df65d73da94afdf927 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/48365 Reviewed-by: Adam Langley --- crypto/fipsmodule/digest/digest.c | 2 ++ decrepit/evp/evp_do_all.c | 6 ++++++ include/openssl/digest.h | 3 +++ include/openssl/evp.h | 6 ++++++ 4 files changed, 17 insertions(+) diff --git a/crypto/fipsmodule/digest/digest.c b/crypto/fipsmodule/digest/digest.c index d893cbc7f..059d72c33 100644 --- a/crypto/fipsmodule/digest/digest.c +++ b/crypto/fipsmodule/digest/digest.c @@ -68,6 +68,8 @@ int EVP_MD_type(const EVP_MD *md) { return md->type; } +int EVP_MD_nid(const EVP_MD *md) { return EVP_MD_type(md); } + uint32_t EVP_MD_flags(const EVP_MD *md) { return md->flags; } size_t EVP_MD_size(const EVP_MD *md) { return md->md_size; } diff --git a/decrepit/evp/evp_do_all.c b/decrepit/evp/evp_do_all.c index d540144b2..d8023e08f 100644 --- a/decrepit/evp/evp_do_all.c +++ b/decrepit/evp/evp_do_all.c @@ -87,3 +87,9 @@ void EVP_MD_do_all_sorted(void (*callback)(const EVP_MD *cipher, callback(EVP_sha384(), "sha384", NULL, arg); callback(EVP_sha512(), "sha512", NULL, arg); } + +void EVP_MD_do_all(void (*callback)(const EVP_MD *cipher, const char *name, + const char *unused, void *arg), + void *arg) { + EVP_MD_do_all_sorted(callback, arg); +} diff --git a/include/openssl/digest.h b/include/openssl/digest.h index 12542c18b..fa7616896 100644 --- a/include/openssl/digest.h +++ b/include/openssl/digest.h @@ -297,6 +297,9 @@ OPENSSL_EXPORT void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags); // their needs). Thus this exists only to allow code to compile. #define EVP_MD_CTX_FLAG_NON_FIPS_ALLOW 0 +// EVP_MD_nid calls |EVP_MD_type|. +OPENSSL_EXPORT int EVP_MD_nid(const EVP_MD *md); + struct evp_md_pctx_ops; diff --git a/include/openssl/evp.h b/include/openssl/evp.h index 405b402a6..c5678754c 100644 --- a/include/openssl/evp.h +++ b/include/openssl/evp.h @@ -867,6 +867,12 @@ OPENSSL_EXPORT void EVP_MD_do_all_sorted(void (*callback)(const EVP_MD *cipher, void *arg), void *arg); +OPENSSL_EXPORT void EVP_MD_do_all(void (*callback)(const EVP_MD *cipher, + const char *name, + const char *unused, + void *arg), + void *arg); + // i2d_PrivateKey marshals a private key from |key| to an ASN.1, DER // structure. If |outp| is not NULL then the result is written to |*outp| and // |*outp| is advanced just past the output. It returns the number of bytes in