Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00022
00023 #ifndef ICL_CORE_CRYPT_SHA2_IMPL_H_INCLUDED
00024 #define ICL_CORE_CRYPT_SHA2_IMPL_H_INCLUDED
00025
00026 #include <icl_core/BaseTypes.h>
00027
00028 namespace icl_core {
00029 namespace crypt {
00030
00051 template <typename T, T t_h0, T t_h1, T t_h2, T t_h3, T t_h4, T t_h5, T t_h6, T t_h7, size_t t_len>
00052 class Sha2Impl
00053 {
00054 public:
00056 static const size_t cMESSAGE_BLOCK_SIZE = 64;
00060 static const size_t cMESSAGE_PAD_POSITION = 56;
00061
00063 Sha2Impl();
00064
00066 void clear();
00067
00069 ::icl_core::String getHexDigest() const;
00070
00071 protected:
00075 void processBuffer();
00076
00078 T m_digest[8];
00080 uint64_t m_message_size;
00084 uint8_t m_buffer[cMESSAGE_BLOCK_SIZE];
00086 size_t m_buffer_fill;
00087 };
00088
00104 template <uint64_t t_h0, uint64_t t_h1, uint64_t t_h2, uint64_t t_h3, uint64_t t_h4, uint64_t t_h5, uint64_t t_h6, uint64_t t_h7, size_t t_len>
00105 class Sha2Impl<uint64_t, t_h0, t_h1, t_h2, t_h3, t_h4, t_h5, t_h6, t_h7, t_len>
00106 {
00107 public:
00109 static const size_t cMESSAGE_BLOCK_SIZE = 128;
00113 static const size_t cMESSAGE_PAD_POSITION = 112;
00114
00116 Sha2Impl();
00117
00119 void clear();
00120
00122 ::icl_core::String getHexDigest() const;
00123
00124 protected:
00128 void processBuffer();
00129
00133 void finalizeBuffer(size_t size);
00134
00136 uint64_t m_digest[8];
00138 uint64_t m_message_size;
00142 uint8_t m_buffer[cMESSAGE_BLOCK_SIZE];
00144 size_t m_buffer_fill;
00145 };
00146
00147 }
00148 }
00149
00150 #include "icl_core_crypt/Sha2Impl.hpp"
00151
00152 #endif