From 814ffcfaf34ad1d35e397eeaaafefbf03faed9cf Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 7 Jan 2020 19:21:40 +0100 Subject: hashes: Use Libgcrypt for hashing purposes Switch the code of the Hashes class to use libgcrypt, which allows us to use hardware-accelerated implementations of SHA1 and friends. --- apt-pkg/contrib/hashes.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'apt-pkg/contrib/hashes.h') diff --git a/apt-pkg/contrib/hashes.h b/apt-pkg/contrib/hashes.h index e9b8a0519..14100e13b 100644 --- a/apt-pkg/contrib/hashes.h +++ b/apt-pkg/contrib/hashes.h @@ -173,10 +173,10 @@ class Hashes PrivateHashes * const d; /* TODO: those will disappear in the future as it is hard to add new ones this way. * Use Add* to build the results and get them via GetHashStringList() instead */ - MD5Summation MD5; - SHA1Summation SHA1; - SHA256Summation SHA256; - SHA512Summation SHA512; + MD5Summation MD5 APT_PKG_590("Remove"); + SHA1Summation SHA1 APT_PKG_590("Remove"); + SHA256Summation SHA256 APT_PKG_590("Remove"); + SHA512Summation SHA512 APT_PKG_590("Remove"); public: static const int UntilEOF = 0; -- cgit v1.2.3 From 79de3008ebfc6b4a5dd32e9de1d19788da0b885d Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 7 Jan 2020 20:36:53 +0100 Subject: Convert users of {MD5,SHA1,SHA256,SHA512}Summation to use Hashes This makes use of the a function GetHashString() that returns the specific hash string. We also need to implement another overload of Add() for signed chars with sizes, so the existing users do not require reinterpret_cast everywhere. --- apt-pkg/contrib/hashes.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'apt-pkg/contrib/hashes.h') diff --git a/apt-pkg/contrib/hashes.h b/apt-pkg/contrib/hashes.h index 14100e13b..07ccc6900 100644 --- a/apt-pkg/contrib/hashes.h +++ b/apt-pkg/contrib/hashes.h @@ -184,6 +184,10 @@ class Hashes bool Add(const unsigned char * const Data, unsigned long long const Size) APT_NONNULL(2); inline bool Add(const char * const Data) APT_NONNULL(2) {return Add(reinterpret_cast(Data),strlen(Data));}; + inline bool Add(const char *const Data, unsigned long long const Size) APT_NONNULL(2) + { + return Add(reinterpret_cast(Data), Size); + }; inline bool Add(const unsigned char * const Beg,const unsigned char * const End) APT_NONNULL(2,3) {return Add(Beg,End-Beg);}; @@ -194,6 +198,9 @@ class Hashes HashStringList GetHashStringList(); + /** Get a specific hash. It is an error to use a hash that was not hashes */ + HashString GetHashString(SupportedHashes hash); + /** create a Hashes object to calculate all supported hashes * * If ALL is too much, you can limit which Hashes are calculated -- cgit v1.2.3 From 5872a2e7dd308e49a063a20da1beb40a32d1e9b2 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 7 Jan 2020 21:05:27 +0100 Subject: Deprecate the Summation classes and mark them for removal --- apt-pkg/contrib/hashes.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'apt-pkg/contrib/hashes.h') diff --git a/apt-pkg/contrib/hashes.h b/apt-pkg/contrib/hashes.h index 07ccc6900..dad50c564 100644 --- a/apt-pkg/contrib/hashes.h +++ b/apt-pkg/contrib/hashes.h @@ -171,12 +171,14 @@ class PrivateHashes; class Hashes { PrivateHashes * const d; +APT_IGNORE_DEPRECATED_PUSH /* TODO: those will disappear in the future as it is hard to add new ones this way. * Use Add* to build the results and get them via GetHashStringList() instead */ MD5Summation MD5 APT_PKG_590("Remove"); SHA1Summation SHA1 APT_PKG_590("Remove"); SHA256Summation SHA256 APT_PKG_590("Remove"); SHA512Summation SHA512 APT_PKG_590("Remove"); +APT_IGNORE_DEPRECATED_POP public: static const int UntilEOF = 0; -- cgit v1.2.3