mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:37:45 +00:00
LibCrypto: Mutualize Digest
s
This commit is contained in:
parent
4e851145ba
commit
3f0e425f1e
5 changed files with 21 additions and 33 deletions
|
@ -72,16 +72,8 @@ constexpr static u64 InitializationHashes[8] = {
|
|||
};
|
||||
}
|
||||
|
||||
template<size_t Bytes>
|
||||
struct SHA2Digest {
|
||||
u8 data[Bytes];
|
||||
constexpr static size_t Size = Bytes;
|
||||
const u8* immutable_data() const { return data; }
|
||||
size_t data_length() const { return Bytes; }
|
||||
};
|
||||
|
||||
// FIXME: I want template<size_t BlockSize> but the compiler gets confused
|
||||
class SHA256 final : public HashFunction<512, SHA2Digest<256 / 8>> {
|
||||
class SHA256 final : public HashFunction<512, 256> {
|
||||
public:
|
||||
using HashFunction::update;
|
||||
|
||||
|
@ -131,7 +123,7 @@ private:
|
|||
constexpr static auto Rounds = 64;
|
||||
};
|
||||
|
||||
class SHA384 final : public HashFunction<1024, SHA2Digest<384 / 8>> {
|
||||
class SHA384 final : public HashFunction<1024, 384> {
|
||||
public:
|
||||
using HashFunction::update;
|
||||
|
||||
|
@ -181,7 +173,7 @@ private:
|
|||
constexpr static auto Rounds = 80;
|
||||
};
|
||||
|
||||
class SHA512 final : public HashFunction<1024, SHA2Digest<512 / 8>> {
|
||||
class SHA512 final : public HashFunction<1024, 512> {
|
||||
public:
|
||||
using HashFunction::update;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue