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;
//-----------------------------------------------------------------------------
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)

View File

@ -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 <http://www.gnu.org/licenses/>.
*
@ -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 ];