Imported Upstream version 9.20
[platform/upstream/7zip.git] / CPP / 7zip / Crypto / HmacSha1.h
1 // HmacSha1.h\r
2 // Implements HMAC-SHA-1 (RFC2104, FIPS-198)\r
3 \r
4 #ifndef __CRYPTO_HMAC_SHA1_H\r
5 #define __CRYPTO_HMAC_SHA1_H\r
6 \r
7 #include "Sha1.h"\r
8 \r
9 namespace NCrypto {\r
10 namespace NSha1 {\r
11 \r
12 // Use:  SetKey(key, keySize); for () Update(data, size); Final(mac, macSize);\r
13 \r
14 class CHmac\r
15 {\r
16   CContext _sha;\r
17   CContext _sha2;\r
18 public:\r
19   void SetKey(const Byte *key, size_t keySize);\r
20   void Update(const Byte *data, size_t dataSize) { _sha.Update(data, dataSize); }\r
21   void Final(Byte *mac, size_t macSize = kDigestSize);\r
22 };\r
23 \r
24 class CHmac32\r
25 {\r
26   CContext32 _sha;\r
27   CContext32 _sha2;\r
28 public:\r
29   void SetKey(const Byte *key, size_t keySize);\r
30   void Update(const UInt32 *data, size_t dataSize) { _sha.Update(data, dataSize); }\r
31   void Final(UInt32 *mac, size_t macSize = kDigestSizeInWords);\r
32   \r
33   // It'sa for hmac function. in,out: mac[kDigestSizeInWords].\r
34   void GetLoopXorDigest(UInt32 *mac, UInt32 numIteration);\r
35 };\r
36 \r
37 }}\r
38 \r
39 #endif\r