1 // HmacSha1.h 2 // Implements HMAC-SHA-1 (RFC2104, FIPS-198) 3 4 #ifndef ZIP7_INC_CRYPTO_HMAC_SHA1_H 5 #define ZIP7_INC_CRYPTO_HMAC_SHA1_H 6 7 #include "Sha1Cls.h" 8 9 namespace NCrypto { 10 namespace NSha1 { 11 12 // Use: SetKey(key, keySize); for () Update(data, size); FinalFull(mac); 13 14 class CHmac 15 { 16 CContext _sha; 17 CContext _sha2; 18 public: 19 void SetKey(const Byte *key, size_t keySize); Update(const Byte * data,size_t dataSize)20 void Update(const Byte *data, size_t dataSize) { _sha.Update(data, dataSize); } 21 22 // Final() : mac is recommended to be aligned for 4 bytes 23 // GetLoopXorDigest1() : mac is required to be aligned for 4 bytes 24 // The caller can use: UInt32 mac[NSha1::kNumDigestWords] and typecast to (Byte *) and (void *); 25 void Final(Byte *mac); 26 void GetLoopXorDigest1(void *mac, UInt32 numIteration); 27 }; 28 29 }} 30 31 #endif 32