From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 3F01E1F62E for ; Tue, 7 Mar 2023 08:47:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1678178835; bh=Ro4c7yDA/17N14FgnEwEWJinEbRILg8VYuSloa3ENrs=; h=From:To:Subject:Date:From; b=42/djFKA3MIn65OEVXP6X9nxH9+iC8bqyOTU/b1Gvmov1bUmA5Q7w481jLxan/5cC +2p83sxEvJA9AhH558Qzsxcd5lMb5tByIHzk4oHvFlSxtGVqKEpl3ZpH1KzRrGfmqt O6P83Y2o7p02d8fMD/BnchMuPR+9ug+dCU3qqm1o= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] sha: fix compatibility with old OpenSSL + Net::SSLeay Date: Tue, 7 Mar 2023 08:47:15 +0000 Message-Id: <20230307084715.398251-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: In older OpenSSL, EVP_get_digestbyname() didn't work properly without calling OpenSSL_add_all_digests(), first. However, OpenSSL_add_all_digests() is deprecated by OpenSSL 1.1.0 in favor of OPENSSL_init_crypto(). Of course, OpenSSL_init_crypto() isn't available in OpenSSL 1.0.1k nor Net::SSLeay as of 1.93_02 (2023-02-22). Thus, instead of relying on string lookups and conditional subroutine calls, just call EVP_sha1() and EVP_sha256() which work on both old and new systems. Tested with Net::SSLeay 1.55 and OpenSSL 1.0.1k on on CentOS 7.x --- lib/PublicInbox/SHA.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/SHA.pm b/lib/PublicInbox/SHA.pm index da70beef..81f62618 100644 --- a/lib/PublicInbox/SHA.pm +++ b/lib/PublicInbox/SHA.pm @@ -20,8 +20,8 @@ BEGIN { unless (eval(<<'EOM')) { use Net::SSLeay 1.43; my %SHA = ( - 1 => Net::SSLeay::EVP_get_digestbyname('sha1'), - 256 => Net::SSLeay::EVP_get_digestbyname('sha256'), + 1 => Net::SSLeay::EVP_sha1(), + 256 => Net::SSLeay::EVP_sha256(), ); sub new {