00001 /* 00002 * lib/crypto/sha1hash.h 00003 * 00004 * Header file containing class SHA1Hash, a class for 00005 * computing the SHA1 message digest / hash algorithm as specified 00006 * by NIST/NSA (not the original weaker SHA0 algorithm). 00007 * 00008 * Copyright (c) 2000--2004 by Wolfgang Wieser ] wwieser (a) gmx <*> de [ 00009 * 00010 * This file may be distributed and/or modified under the terms of the 00011 * GNU General Public License version 2 as published by the Free Software 00012 * Foundation. (See COPYING.GPL for details.) 00013 * 00014 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00015 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00016 * 00017 */ 00018 00019 #ifndef _LIB_CRYPTO_SHA1Hash_H_ 00020 #define _LIB_CRYPTO_SHA1Hash_H_ 1 00021 00031 #include <lib/crypto/shashbase.h> 00032 00041 class SHA1Hash : public SecureHashBase 00042 { 00043 public: 00045 static const Parameters par; 00046 00047 private: 00048 uint32 state[5]; 00049 //uint64 length; <- in base class // length of hashed data in BYTES. 00050 00051 unsigned char tmpbuf[64]; 00052 int tmp_size; 00053 00055 void AtomicHash(const unsigned char *msg,uint32 *w); 00056 00058 SHA1Hash(const SHA1Hash &); 00059 void operator=(const SHA1Hash &); 00060 public: 00062 SHA1Hash() : SecureHashBase() 00063 { reset(); } 00065 ~SHA1Hash() 00066 { reset(); } 00067 00069 const Parameters *GetPar() const 00070 { return(&SHA1Hash::par); } 00071 00073 uint64 FedBytes() const 00074 { return(length); } 00075 00077 void reset(); 00078 00080 void feed(const char *buf,size_t len); 00081 00083 void final(); 00084 00086 void GetHash(char *buf) const; 00087 }; 00088 00089 #endif /* _LIB_CRYPTO_SHA1Hash_H_ */