Conceal algorithms' impl details in service namespaces

This commit is contained in:
hashlag
2025-08-10 21:21:22 +03:00
parent 72a8902954
commit da4232894a
2 changed files with 18 additions and 8 deletions

View File

@@ -8,7 +8,7 @@
#include "Hash.hpp" #include "Hash.hpp"
#include "Hasher.hpp" #include "Hasher.hpp"
namespace Chaos::Hashing::Md4 namespace Chaos::Hashing::Md4::Inner_
{ {
struct Buffer struct Buffer
@@ -129,6 +129,11 @@ private:
} }
}; };
} // namespace Chaos::Hashing::Md4::Inner_
namespace Chaos::Hashing::Md4
{
struct Md4Hash : public Hash<Md4Hash> struct Md4Hash : public Hash<Md4Hash>
{ {
std::array<uint8_t, 16> GetRawDigest() const std::array<uint8_t, 16> GetRawDigest() const
@@ -241,9 +246,9 @@ private:
static_assert(std::size(PAD_) == 64); static_assert(std::size(PAD_) == 64);
Buffer Buffer_; Inner_::Buffer Buffer_;
Block Block_; Inner_::Block Block_;
int_fast8_t BlockSize_; int_fast8_t BlockSize_;
uint32_t Word_; uint32_t Word_;
@@ -269,7 +274,7 @@ private:
if (BlockSize_ == 16) if (BlockSize_ == 16)
{ {
Algorithm::UpdateBuffer(Buffer_, Block_); Inner_::Algorithm::UpdateBuffer(Buffer_, Block_);
BlockSize_ = 0; BlockSize_ = 0;
} }
} }

View File

@@ -8,7 +8,7 @@
#include "Hash.hpp" #include "Hash.hpp"
#include "Hasher.hpp" #include "Hasher.hpp"
namespace Chaos::Hashing::Md5 namespace Chaos::Hashing::Md5::Inner_
{ {
struct Buffer struct Buffer
@@ -153,6 +153,11 @@ private:
} }
}; };
} // namespace Chaos::Hashing::Md5::Inner_
namespace Chaos::Hashing::Md5
{
struct Md5Hash : public Hash<Md5Hash> struct Md5Hash : public Hash<Md5Hash>
{ {
std::array<uint8_t, 16> GetRawDigest() const std::array<uint8_t, 16> GetRawDigest() const
@@ -265,9 +270,9 @@ private:
static_assert(std::size(PAD_) == 64); static_assert(std::size(PAD_) == 64);
Buffer Buffer_; Inner_::Buffer Buffer_;
Block Block_; Inner_::Block Block_;
int_fast8_t BlockSize_; int_fast8_t BlockSize_;
uint32_t Word_; uint32_t Word_;
@@ -293,7 +298,7 @@ private:
if (BlockSize_ == 16) if (BlockSize_ == 16)
{ {
Algorithm::UpdateBuffer(Buffer_, Block_); Inner_::Algorithm::UpdateBuffer(Buffer_, Block_);
BlockSize_ = 0; BlockSize_ = 0;
} }
} }