Commit 11e1a4841a for openssl.org

commit 11e1a4841acecb3c30b835f0d16dfd3adf870637
Author: Neil Horman <nhorman@openssl.org>
Date:   Tue Jan 20 12:28:22 2026 -0500

    convert SHA512_Update to do thunking

    Reviewed-by: Tomas Mraz <tomas@openssl.org>
    Reviewed-by: Paul Dale <paul.dale@oracle.com>
    (Merged from https://github.com/openssl/openssl/pull/29650)

diff --git a/crypto/sha/sha512.c b/crypto/sha/sha512.c
index 4c3a3b6c09..473ec09b5f 100644
--- a/crypto/sha/sha512.c
+++ b/crypto/sha/sha512.c
@@ -71,6 +71,8 @@
 #define U64(C) C##ULL
 #endif

+int SHA512_Update_thunk(void *cp, const unsigned char *data, size_t len);
+
 int sha512_224_init(SHA512_CTX *c)
 {
     c->h[0] = U64(0x8c3d37c819544da2);
@@ -276,11 +278,11 @@ int SHA384_Final(unsigned char *md, SHA512_CTX *c)
     return SHA512_Final(md, c);
 }

-int SHA512_Update(SHA512_CTX *c, const void *_data, size_t len)
+int SHA512_Update_thunk(void *cp, const unsigned char *data, size_t len)
 {
+    SHA512_CTX *c = (SHA512_CTX *)cp;
     SHA_LONG64 l;
     unsigned char *p = c->u.p;
-    const unsigned char *data = (const unsigned char *)_data;

     if (len == 0)
         return 1;
@@ -324,6 +326,11 @@ int SHA512_Update(SHA512_CTX *c, const void *_data, size_t len)
     return 1;
 }

+int SHA512_Update(SHA512_CTX *c, const void *_data, size_t len)
+{
+    return SHA512_Update_thunk((void *)c, (const unsigned char *)_data, len);
+}
+
 int SHA384_Update(SHA512_CTX *c, const void *data, size_t len)
 {
     return SHA512_Update(c, data, len);
diff --git a/providers/implementations/digests/sha2_prov.c b/providers/implementations/digests/sha2_prov.c
index 3e7f719f0d..607228a355 100644
--- a/providers/implementations/digests/sha2_prov.c
+++ b/providers/implementations/digests/sha2_prov.c
@@ -30,8 +30,9 @@

 #define SHA2_FLAGS PROV_DIGEST_FLAG_ALGID_ABSENT

-extern int SHA256_Update_thunk(void *ctx, const unsigned char *data, size_t sz);
 extern int SHA1_Update_thunk(void *ctx, const unsigned char *data, size_t sz);
+extern int SHA256_Update_thunk(void *ctx, const unsigned char *data, size_t sz);
+extern int SHA512_Update_thunk(void *ctx, const unsigned char *data, size_t sz);

 /* Special set_params method for SSL3 */
 static int sha1_set_ctx_params(void *vctx, const OSSL_PARAM params[])
@@ -315,19 +316,19 @@ IMPLEMENT_digest_functions_with_serialize(sha384, SHA512_CTX,
 IMPLEMENT_digest_functions_with_serialize(sha512, SHA512_CTX,
     SHA512_CBLOCK, SHA512_DIGEST_LENGTH,
     SHA2_FLAGS, SHA512_Init,
-    SHA512_Update, SHA512_Final,
+    SHA512_Update_thunk, SHA512_Final,
     SHA512_Serialize, SHA512_Deserialize)

 /* ossl_sha512_224_functions */
 IMPLEMENT_digest_functions_with_serialize(sha512_224, SHA512_CTX,
     SHA512_CBLOCK, SHA224_DIGEST_LENGTH,
     SHA2_FLAGS, sha512_224_init,
-    SHA512_Update, SHA512_Final,
+    SHA512_Update_thunk, SHA512_Final,
     SHA512_Serialize, SHA512_Deserialize)

 /* ossl_sha512_256_functions */
 IMPLEMENT_digest_functions_with_serialize(sha512_256, SHA512_CTX,
     SHA512_CBLOCK, SHA256_DIGEST_LENGTH,
     SHA2_FLAGS, sha512_256_init,
-    SHA512_Update, SHA512_Final,
+    SHA512_Update_thunk, SHA512_Final,
     SHA512_Serialize, SHA512_Deserialize)