diff options
author | Oliver Reiche <oliver.reiche@huawei.com> | 2022-06-15 18:51:47 +0200 |
---|---|---|
committer | Oliver Reiche <oliver.reiche@huawei.com> | 2022-06-20 15:23:02 +0200 |
commit | 855affd9b681d98f248009ddb2c1abe987029f72 (patch) | |
tree | 6d4dbfc2c99020772313f381d2f793950d2b03f4 /src/buildtool/crypto/hash_impl.hpp | |
parent | 391d982f2fbd98a2973f14e0b5969f66c2abd756 (diff) | |
download | justbuild-855affd9b681d98f248009ddb2c1abe987029f72.tar.gz |
Crypto: Refactor hash computation
... by renaming HashGenerator to (incremental) Hasher and
dropping support for Git/MD5 hashes. The Hasher does not
expose the actual hash implementation.
Diffstat (limited to 'src/buildtool/crypto/hash_impl.hpp')
-rw-r--r-- | src/buildtool/crypto/hash_impl.hpp | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/src/buildtool/crypto/hash_impl.hpp b/src/buildtool/crypto/hash_impl.hpp deleted file mode 100644 index d37322bd..00000000 --- a/src/buildtool/crypto/hash_impl.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef INCLUDED_SRC_BUILDTOOL_CRYPTO_HASH_IMPL_HPP -#define INCLUDED_SRC_BUILDTOOL_CRYPTO_HASH_IMPL_HPP - -#include <optional> -#include <string> - -#include "src/buildtool/logging/logger.hpp" - -/// \brief Interface for hash implementations -class IHashImpl { - public: - IHashImpl() noexcept = default; - IHashImpl(IHashImpl const&) = default; - IHashImpl(IHashImpl&&) = default; - auto operator=(IHashImpl const&) -> IHashImpl& = default; - auto operator=(IHashImpl&&) -> IHashImpl& = default; - virtual ~IHashImpl() = default; - - /// \brief Feed data to the incremental hashing. - [[nodiscard]] virtual auto Update(std::string const& data) noexcept - -> bool = 0; - - /// \brief Finalize the hashing and return hash as string of raw bytes. - [[nodiscard]] virtual auto Finalize() && noexcept - -> std::optional<std::string> = 0; - - /// \brief Compute the hash of data and return it as string of raw bytes. - [[nodiscard]] virtual auto Compute(std::string const& data) && noexcept - -> std::string = 0; - - /// \brief Get length of the hash in raw bytes. - [[nodiscard]] virtual auto DigestLength() const noexcept -> std::size_t = 0; - - static auto FatalError() noexcept -> void { - Logger::Log(LogLevel::Error, "Failed to compute hash."); - std::terminate(); - } -}; - -#endif // INCLUDED_SRC_BUILDTOOL_CRYPTO_HASH_IMPL_HPP |