FS#76515 - Deprecations with the use of openssl version 3

Attached to Project: Pacman
Opened by Victor Bistak (vicbis) - Friday, 11 November 2022, 01:34 GMT
Last edited by Allan McRae (Allan) - Friday, 11 November 2022, 02:18 GMT
Task Type Bug Report
Category General
Status Closed
Assigned To No-one
Architecture All
Severity Low
Priority Normal
Reported Version 6.0.2
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Summary and Info: Build with openssl version 3

I don't know if this has been addressed:

Building with openssl (OpenSSL 3.0.7 1 Nov 2022 (Library: OpenSSL 3.0.7 1 Nov 2022), this should have probably been changed when openssl v1.x was released.

Deprecated declarations:

vicb@emily [ ~/Downloads/pacman-6.0.2 ]$ ninja -C build
ninja: Entering directory `build'
[263/283] Compiling C object libalpm_objlib.a.p/lib_libalpm_util.c.o
../lib/libalpm/util.c: In function ‘md5_file’:
../lib/libalpm/util.c:936:9: warning: ‘MD5_Init’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
936 | MD5_Init(&ctx);
| ^~~~~~~~
In file included from ../lib/libalpm/util.c:43:
/usr/include/openssl/md5.h:49:27: note: declared here
49 | OSSL_DEPRECATEDIN_3_0 int MD5_Init(MD5_CTX *c);
| ^~~~~~~~
../lib/libalpm/util.c:946:17: warning: ‘MD5_Update’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
946 | MD5_Update(&ctx, buf, n);
| ^~~~~~~~~~
/usr/include/openssl/md5.h:50:27: note: declared here
50 | OSSL_DEPRECATEDIN_3_0 int MD5_Update(MD5_CTX *c, const void *data, size_t len);
| ^~~~~~~~~~
../lib/libalpm/util.c:960:9: warning: ‘MD5_Final’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
960 | MD5_Final(output, &ctx);
| ^~~~~~~~~
/usr/include/openssl/md5.h:51:27: note: declared here
51 | OSSL_DEPRECATEDIN_3_0 int MD5_Final(unsigned char *md, MD5_CTX *c);
| ^~~~~~~~~
../lib/libalpm/util.c: In function ‘sha256_file’:
../lib/libalpm/util.c:992:9: warning: ‘SHA256_Init’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
992 | SHA256_Init(&ctx);
| ^~~~~~~~~~~
In file included from ../lib/libalpm/util.c:44:
/usr/include/openssl/sha.h:73:27: note: declared here
73 | OSSL_DEPRECATEDIN_3_0 int SHA256_Init(SHA256_CTX *c);
| ^~~~~~~~~~~
../lib/libalpm/util.c:1002:17: warning: ‘SHA256_Update’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
1002 | SHA256_Update(&ctx, buf, n);
| ^~~~~~~~~~~~~
/usr/include/openssl/sha.h:74:27: note: declared here
74 | OSSL_DEPRECATEDIN_3_0 int SHA256_Update(SHA256_CTX *c,
| ^~~~~~~~~~~~~
../lib/libalpm/util.c:1016:9: warning: ‘SHA256_Final’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
1016 | SHA256_Final(output, &ctx);
| ^~~~~~~~~~~~
/usr/include/openssl/sha.h:76:27: note: declared here
76 | OSSL_DEPRECATEDIN_3_0 int SHA256_Final(unsigned char *md, SHA256_CTX *c);
| ^~~~~~~~~~~~
[283/283] Linking target pacman

Diff output for my fix:

diff -Naur lib-orig/libalpm/util.c lib/libalpm/util.c
--- lib-orig/libalpm/util.c 2022-10-03 13:52:04.000000000 +1100
+++ lib/libalpm/util.c 2022-11-11 12:09:29.978543048 +1100
@@ -40,8 +40,7 @@
#include <archive_entry.h>

#ifdef HAVE_LIBSSL
-#include <openssl/md5.h>
-#include <openssl/sha.h>
+#include <openssl/evp.h>
#endif

#ifdef HAVE_LIBNETTLE
@@ -916,7 +915,7 @@
static int md5_file(const char *path, unsigned char output[16])
{
#if HAVE_LIBSSL
- MD5_CTX ctx;
+ EVP_MD_CTX *ctx;
#else /* HAVE_LIBNETTLE */
struct md5_ctx ctx;
#endif
@@ -933,7 +932,8 @@
}

#if HAVE_LIBSSL
- MD5_Init(&ctx);
+ ctx=EVP_MD_CTX_new();
+ EVP_DigestInit_ex2(ctx, EVP_md5(), NULL);
#else /* HAVE_LIBNETTLE */
md5_init(&ctx);
#endif
@@ -943,7 +943,7 @@
continue;
}
#if HAVE_LIBSSL
- MD5_Update(&ctx, buf, n);
+ EVP_DigestUpdate(ctx, buf,n);
#else /* HAVE_LIBNETTLE */
md5_update(&ctx, n, buf);
#endif
@@ -957,7 +957,8 @@
}

#if HAVE_LIBSSL
- MD5_Final(output, &ctx);
+ EVP_DigestFinal_ex(ctx, output, NULL);
+ EVP_MD_CTX_free(ctx);
#else /* HAVE_LIBNETTLE */
md5_digest(&ctx, MD5_DIGEST_SIZE, output);
#endif
@@ -972,7 +973,7 @@
static int sha256_file(const char *path, unsigned char output[32])
{
#if HAVE_LIBSSL
- SHA256_CTX ctx;
+ EVP_MD_CTX *ctx;
#else /* HAVE_LIBNETTLE */
struct sha256_ctx ctx;
#endif
@@ -989,7 +990,8 @@
}

#if HAVE_LIBSSL
- SHA256_Init(&ctx);
+ ctx=EVP_MD_CTX_new();
+ EVP_DigestInit_ex2(ctx, EVP_sha256(), NULL);
#else /* HAVE_LIBNETTLE */
sha256_init(&ctx);
#endif
@@ -999,7 +1001,7 @@
continue;
}
#if HAVE_LIBSSL
- SHA256_Update(&ctx, buf, n);
+ EVP_DigestUpdate(ctx, buf, n);
#else /* HAVE_LIBNETTLE */
sha256_update(&ctx, n, buf);
#endif
@@ -1013,7 +1015,8 @@
}

#if HAVE_LIBSSL
- SHA256_Final(output, &ctx);
+ EVP_DigestFinal_ex(ctx, output, NULL);
+ EVP_MD_CTX_free(ctx);
#else /* HAVE_LIBNETTLE */
sha256_digest(&ctx, SHA256_DIGEST_SIZE, output);
#endif




This task depends upon

Closed by  Allan McRae (Allan)
Friday, 11 November 2022, 02:18 GMT
Reason for closing:  Fixed
Additional comments about closing:  git commit b2c9543ea94bbfd00480ab6e89e31813f4320e13

Loading...