]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Merge topic branch t/openssl-3 into master
authorAndre Noll <maan@tuebingen.mpg.de>
Thu, 1 Dec 2022 17:08:44 +0000 (18:08 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Thu, 1 Dec 2022 17:09:39 +0000 (18:09 +0100)
Two patches. The first suppresses warnings when compiling against
openssl-3, the second switches the two hash functions over to the
EVP API. More work is needed but it does not hurt to merge this first
step now.

* refs/heads/t/openssl-3:
  openssl: Switch to evp API for sha1 and sha256.
  openssl: Deactivate openssl-3 warnings for now.

Makefile.real
NEWS.md
openssl.c

index bf3cb6e0ff0616f3618c778c11731651d9a4151c..dc658fe1b65747e66407e2f3f67f3b929f256d13 100644 (file)
@@ -221,7 +221,9 @@ $(call OD, afs aft attribute blob mood playlist score server vss command \
        CPPFLAGS += $(osl_cppflags)
 
 $(call OD, compress_filter): CFLAGS += -O3
+$(call OD, openssl): CFLAGS += -Wno-deprecated-declarations
 
+$(object_dir)/%.o: %.c | $(object_dir) $(dep_dir) $(lsg_h) $(yy_h)
 define CC_CMD
        $(call SAY, CC $<)
        $(CC) -c -o $(object_dir)/$(*F).o -MMD -MF \
diff --git a/NEWS.md b/NEWS.md
index 009982a3b85a3ad2421aab8ef4684b3dc30a8587..fff7a242bba99d3a322b47c0d101d36b93e8d8d5 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -12,6 +12,8 @@ NEWS
   the startup mood and the time period before fade-out starts. A bunch
   of further improvements for this subcommand went in as well.
 - Minor cleanup of the net subsystem.
+- The openssl specific code now employs the EVP API to compute hashes.
+  It should compile without warnings against openssl-3.
 
 Downloads:
 [tarball](./releases/paraslash-git.tar.xz)
index 9d3ad577da4f5636f409fbacb0f1433ca0c720e1..718498763c8ccc287fafc78edc22157d5fff7193 100644 (file)
--- a/openssl.c
+++ b/openssl.c
@@ -11,6 +11,7 @@
 #include <openssl/sha.h>
 #include <openssl/bn.h>
 #include <openssl/aes.h>
+#include <openssl/evp.h>
 
 #include "para.h"
 #include "error.h"
@@ -409,16 +410,24 @@ void sc_crypt(struct stream_cipher *sc, struct iovec *src, struct iovec *dst)
 
 void hash_function(const char *data, unsigned long len, unsigned char *hash)
 {
-       SHA_CTX c;
-       SHA1_Init(&c);
-       SHA1_Update(&c, data, len);
-       SHA1_Final(hash, &c);
+       EVP_MD_CTX *c = EVP_MD_CTX_new();
+       int ret = EVP_DigestInit_ex(c, EVP_sha1(), NULL);
+       assert(ret != 0);
+       ret = EVP_DigestUpdate(c, data, len);
+       assert(ret != 0);
+       ret = EVP_DigestFinal_ex(c, hash, NULL);
+       assert(ret != 0);
+       EVP_MD_CTX_free(c);
 }
 
 void hash2_function(const char *data, unsigned long len, unsigned char *hash)
 {
-       SHA256_CTX c;
-       SHA256_Init(&c);
-       SHA256_Update(&c, data, len);
-       SHA256_Final(hash, &c);
+       EVP_MD_CTX *c = EVP_MD_CTX_new();
+       int ret = EVP_DigestInit_ex(c, EVP_sha256(), NULL);
+       assert(ret != 0);
+       ret = EVP_DigestUpdate(c, data, len);
+       assert(ret != 0);
+       ret = EVP_DigestFinal_ex(c, hash, NULL);
+       assert(ret != 0);
+       EVP_MD_CTX_free(c);
 }