mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-08 08:44:22 +00:00
This required multiple changes: - Make hashes non-copiable because they contain a heap allocated pointer - Reference classes via `NonnullOwnPtr` only (they are non-copiable) - Drop all existing hashes implementations - Use the `OpenSSLHashFunction` base class to implement the same hashes I was not able to come up with a way to divide this commit into multiple without increasing the amount of changes. Nothing breaks with this commit!
60 lines
1.1 KiB
C++
60 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) 2020, Ali Mohammad Pur <mpfard@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/ByteString.h>
|
|
#include <LibCrypto/Hash/OpenSSLHashFunction.h>
|
|
|
|
namespace Crypto::Hash {
|
|
|
|
class SHA256 final : public OpenSSLHashFunction<SHA256, 512, 256> {
|
|
AK_MAKE_NONCOPYABLE(SHA256);
|
|
|
|
public:
|
|
explicit SHA256(EVP_MD_CTX* context)
|
|
: OpenSSLHashFunction(EVP_sha256(), context)
|
|
{
|
|
}
|
|
|
|
virtual ByteString class_name() const override
|
|
{
|
|
return "SHA256";
|
|
}
|
|
};
|
|
|
|
class SHA384 final : public OpenSSLHashFunction<SHA384, 1024, 384> {
|
|
AK_MAKE_NONCOPYABLE(SHA384);
|
|
|
|
public:
|
|
explicit SHA384(EVP_MD_CTX* context)
|
|
: OpenSSLHashFunction(EVP_sha384(), context)
|
|
{
|
|
}
|
|
|
|
virtual ByteString class_name() const override
|
|
{
|
|
return "SHA384";
|
|
}
|
|
};
|
|
|
|
class SHA512 final : public OpenSSLHashFunction<SHA512, 1024, 512> {
|
|
AK_MAKE_NONCOPYABLE(SHA512);
|
|
|
|
public:
|
|
explicit SHA512(EVP_MD_CTX* context)
|
|
: OpenSSLHashFunction(EVP_sha512(), context)
|
|
{
|
|
}
|
|
|
|
virtual ByteString class_name() const override
|
|
{
|
|
return "SHA512";
|
|
}
|
|
};
|
|
|
|
}
|