sha1: give state enum a print operator

This commit is contained in:
Danny Robson 2014-07-02 15:40:20 +10:00
parent ca9db30ab4
commit a9bffcff08
2 changed files with 22 additions and 7 deletions

View File

@ -37,6 +37,19 @@ using std::begin;
using std::end; 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 // Logical function for sequence of rounds
static inline uint32_t static inline uint32_t
f_00 (uint32_t B, uint32_t C, uint32_t D) f_00 (uint32_t B, uint32_t C, uint32_t D)

View File

@ -40,13 +40,15 @@ namespace util {
digest_t digest (void) const; digest_t digest (void) const;
void reset (void); void reset (void);
enum state_t {
READY,
FINISHED
};
protected: protected:
void process (void); void process (void);
enum { state_t state;
READY,
FINISHED
} state;
uint64_t total; uint64_t total;
uint32_t H[5]; uint32_t H[5];