about summary refs log tree commit homepage
path: root/lib/PublicInbox/SHA.pm
DateCommit message (Collapse)
2023-10-25lei_mirror+fetch: don't slurp `git show-ref' output
While uncommon, some git repos have hundreds of thousands of refs and slurping that output into memory can bloat the heap. Introduce a sha_all sub in PublicInbox::SHA to loop until EOF and rely on autodie for checking sysread errors.
2023-03-07sha: fix compatibility with old OpenSSL + Net::SSLeay
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
2023-01-30use Net::SSLeay (OpenSSL) for SHA-(1|256) if installed
On my x86-64 machine, OpenSSL SHA-256 is nearly twice as fast as the Digest::SHA implementation from Perl, most likely due to an optimized assembly implementation. SHA-1 is a few percent faster, too.