Blame SOURCES/mod_http2-1.15.14-openssl30.patch

e3ec87
commit 124c2ca0886b05d0871ee09466de555d757b72fc
e3ec87
Author: Joe Orton <jorton@redhat.com>
e3ec87
Date:   Fri May 7 10:58:18 2021 +0100
e3ec87
e3ec87
    Switch to using OpenSSL EVP_* API to avoid deprecation warnings
e3ec87
    with OpenSSL 3.0.
e3ec87
e3ec87
diff --git a/mod_http2/h2_push.c b/mod_http2/h2_push.c
e3ec87
index 8ae0b49..0a90a5d 100644
e3ec87
--- a/mod_http2/h2_push.c
e3ec87
+++ b/mod_http2/h2_push.c
e3ec87
@@ -23,7 +23,7 @@
e3ec87
 #include <apr_time.h>
e3ec87
 
e3ec87
 #ifdef H2_OPENSSL
e3ec87
-#include <openssl/sha.h>
e3ec87
+#include <openssl/evp.h>
e3ec87
 #endif
e3ec87
 
e3ec87
 #include <httpd.h>
e3ec87
@@ -472,27 +472,32 @@ typedef struct h2_push_diary_entry {
e3ec87
 
e3ec87
 
e3ec87
 #ifdef H2_OPENSSL
e3ec87
-static void sha256_update(SHA256_CTX *ctx, const char *s)
e3ec87
+static void sha256_update(EVP_MD_CTX *ctx, const char *s)
e3ec87
 {
e3ec87
-    SHA256_Update(ctx, s, strlen(s));
e3ec87
+    EVP_DigestUpdate(ctx, s, strlen(s));
e3ec87
 }
e3ec87
 
e3ec87
 static void calc_sha256_hash(h2_push_diary *diary, apr_uint64_t *phash, h2_push *push) 
e3ec87
 {
e3ec87
-    SHA256_CTX sha256;
e3ec87
+    EVP_MD_CTX *md;
e3ec87
     apr_uint64_t val;
e3ec87
-    unsigned char hash[SHA256_DIGEST_LENGTH];
e3ec87
+    unsigned char hash[EVP_MAX_MD_SIZE];
e3ec87
+    unsigned len;
e3ec87
     int i;
e3ec87
-    
e3ec87
-    SHA256_Init(&sha256);
e3ec87
-    sha256_update(&sha256, push->req->scheme);
e3ec87
-    sha256_update(&sha256, "://");
e3ec87
-    sha256_update(&sha256, push->req->authority);
e3ec87
-    sha256_update(&sha256, push->req->path);
e3ec87
-    SHA256_Final(hash, &sha256);
e3ec87
+
e3ec87
+    md = EVP_MD_CTX_create();
e3ec87
+    ap_assert(md != NULL);
e3ec87
+
e3ec87
+    i = EVP_DigestInit_ex(md, EVP_sha256(), NULL);
e3ec87
+    ap_assert(i == 1);
e3ec87
+    sha256_update(md, push->req->scheme);
e3ec87
+    sha256_update(md, "://");
e3ec87
+    sha256_update(md, push->req->authority);
e3ec87
+    sha256_update(md, push->req->path);
e3ec87
+    EVP_DigestFinal(md, hash, &len;;
e3ec87
 
e3ec87
     val = 0;
e3ec87
-    for (i = 0; i != sizeof(val); ++i)
e3ec87
+    for (i = 0; i != len; ++i)
e3ec87
         val = val * 256 + hash[i];
e3ec87
     *phash = val >> (64 - diary->mask_bits);
e3ec87
 }