diff --git a/hash/sha1.cpp b/hash/sha1.cpp index 926ac5cc..7042bd07 100644 --- a/hash/sha1.cpp +++ b/hash/sha1.cpp @@ -37,6 +37,19 @@ using std::begin; using std::end; +//----------------------------------------------------------------------------- +std::ostream& +operator<< (std::ostream &os, SHA1::state_t t) { + switch (t) { + case SHA1::READY: os << "READY"; return os; + case SHA1::FINISHED: os << "FINISHED"; return os; + default: + unreachable (); + } +} + + +//----------------------------------------------------------------------------- // Logical function for sequence of rounds static inline uint32_t f_00 (uint32_t B, uint32_t C, uint32_t D) diff --git a/hash/sha1.hpp b/hash/sha1.hpp index e2379c66..c388dbea 100644 --- a/hash/sha1.hpp +++ b/hash/sha1.hpp @@ -5,12 +5,12 @@ * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. - * + * * libgim is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. - * + * * You should have received a copy of the GNU General Public License * along with libgim. If not, see . * @@ -40,17 +40,19 @@ namespace util { digest_t digest (void) const; void reset (void); + enum state_t { + READY, + FINISHED + }; + protected: void process (void); - enum { - READY, - FINISHED - } state; + state_t state; uint64_t total; uint32_t H[5]; - + union { uint8_t c[16*4+64*4]; uint32_t W[16 +64 ];