From ef17f9c7d11ef73926e6c36656193aee23205437 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Fri, 17 Jun 2016 15:57:09 +1000 Subject: [PATCH] hash: class decleration style --- hash/md2.hpp | 40 ++++++++++++++++++------------------- hash/md4.hpp | 46 +++++++++++++++++++++---------------------- hash/md5.hpp | 48 ++++++++++++++++++++++----------------------- hash/ripemd.hpp | 52 ++++++++++++++++++++++++------------------------- hash/sha2.hpp | 42 +++++++++++++++++++-------------------- 5 files changed, 109 insertions(+), 119 deletions(-) diff --git a/hash/md2.hpp b/hash/md2.hpp index 0e20e4b9..e210a65c 100644 --- a/hash/md2.hpp +++ b/hash/md2.hpp @@ -21,32 +21,30 @@ #include -namespace util { - namespace hash { - class MD2 { - public: - typedef std::array digest_t; +namespace util { namespace hash { + class MD2 { + public: + typedef std::array digest_t; - public: - MD2 (); + public: + MD2 (); - void update (const uint8_t *data, size_t len); - void update (const void *data, size_t len); - void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept; + void update (const uint8_t *data, size_t len); + void update (const void *data, size_t len); + void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept; - void finish (void); - digest_t digest (void) const; - void reset (void); + void finish (void); + digest_t digest (void) const; + void reset (void); - private: - void transform (void); + private: + void transform (void); - uint64_t m_total; + uint64_t m_total; - uint8_t C[16]; - uint8_t X[48]; - }; - } -} + uint8_t C[16]; + uint8_t X[48]; + }; +} } #endif diff --git a/hash/md4.hpp b/hash/md4.hpp index 4428404c..79969eea 100644 --- a/hash/md4.hpp +++ b/hash/md4.hpp @@ -20,35 +20,33 @@ #include #include -namespace util { - namespace hash { - class MD4 { - public: - typedef std::array digest_t; +namespace util { namespace hash { + class MD4 { + public: + typedef std::array digest_t; - public: - MD4(); + public: + MD4(); - void update (const void *data, size_t len); - void update (const uint8_t *data, size_t len); - void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept; + void update (const void *data, size_t len); + void update (const uint8_t *data, size_t len); + void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept; - void finish (void); - digest_t digest (void) const; - void reset (void); - - private: - void transform (void); + void finish (void); + digest_t digest (void) const; + void reset (void); - uint64_t m_total; + private: + void transform (void); - std::array ABCD; - union { - uint32_t X [16]; - uint8_t Xb[64]; - }; + uint64_t m_total; + + std::array ABCD; + union { + uint32_t X [16]; + uint8_t Xb[64]; }; - } -} + }; +} } #endif diff --git a/hash/md5.hpp b/hash/md5.hpp index 6d105bde..49725e2f 100644 --- a/hash/md5.hpp +++ b/hash/md5.hpp @@ -21,40 +21,38 @@ #include #include -namespace util { - namespace hash { - class MD5 { - public: - typedef std::array digest_t; - static const size_t BLOCK_SIZE = 64; - static const size_t DIGEST_SIZE = 16; +namespace util { namespace hash { + class MD5 { + public: + typedef std::array digest_t; + static const size_t BLOCK_SIZE = 64; + static const size_t DIGEST_SIZE = 16; - public: - MD5(); + public: + MD5(); - void update (const void *data, size_t len); - void update (const uint8_t *data, size_t len); - void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept; + void update (const void *data, size_t len); + void update (const uint8_t *data, size_t len); + void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept; - void finish (void); - digest_t digest (void) const; - void reset (void); + void finish (void); + digest_t digest (void) const; + void reset (void); - private: - void transform (void); + private: + void transform (void); - uint64_t m_total; - std::array ABCD; + uint64_t m_total; + std::array ABCD; - union { - uint32_t X [16]; - uint8_t Xb[64]; - }; + union { + uint32_t X [16]; + uint8_t Xb[64]; }; - } + }; typedef uint8_t md5_t; md5_t md5 (const void *restrict data, size_t len); -} +} } #endif diff --git a/hash/ripemd.hpp b/hash/ripemd.hpp index 17a56a30..2b140ca5 100644 --- a/hash/ripemd.hpp +++ b/hash/ripemd.hpp @@ -20,39 +20,37 @@ #include -namespace util { - namespace hash { - class RIPEMD { - public: - typedef std::array digest_t; +namespace util { namespace hash { + class RIPEMD { + public: + typedef std::array digest_t; - public: - RIPEMD(); + public: + RIPEMD(); - void update (const uint8_t*, size_t); - void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept; + void update (const uint8_t*, size_t); + void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept; - digest_t digest (void) const; - void finish (void); - void reset (void); + digest_t digest (void) const; + void finish (void); + void reset (void); - protected: - void transform (); + protected: + void transform (); - bool m_finished; + bool m_finished; - uint32_t m_state[5]; - uint64_t m_length; + uint32_t m_state[5]; + uint64_t m_length; - struct { - union { - uint32_t d32[16]; - uint8_t d08[64]; - }; - size_t size; - } m_buffer; - }; - } -} + struct { + union { + uint32_t d32[16]; + uint8_t d08[64]; + }; + size_t size; + } m_buffer; + }; +} } #endif diff --git a/hash/sha2.hpp b/hash/sha2.hpp index 91631922..a45c9b10 100644 --- a/hash/sha2.hpp +++ b/hash/sha2.hpp @@ -21,35 +21,33 @@ #include #include -namespace util { - namespace hash { - class SHA256 { - public: - typedef std::array digest_t; +namespace util { namespace hash { + class SHA256 { + public: + typedef std::array digest_t; - public: - SHA256(); + public: + SHA256(); - void update (const uint8_t *, size_t); - void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept; + void update (const uint8_t *, size_t); + void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept; - void finish (void); - digest_t digest (void) const; + void finish (void); + digest_t digest (void) const; - void reset (void); + void reset (void); - private: - void process (void); + private: + void process (void); - uint64_t m_total; - std::array H; + uint64_t m_total; + std::array H; - union { - std::array M; - std::array C; - }; + union { + std::array M; + std::array C; }; - } -} + }; +} } #endif