Botan  1.10.9
hmac.h
Go to the documentation of this file.
1 /*
2 * HMAC
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7 
8 #ifndef BOTAN_HMAC_H__
9 #define BOTAN_HMAC_H__
10 
11 #include <botan/mac.h>
12 #include <botan/hash.h>
13 
14 namespace Botan {
15 
16 /**
17 * HMAC
18 */
19 class BOTAN_DLL HMAC : public MessageAuthenticationCode
20  {
21  public:
22  void clear();
23  std::string name() const;
24  MessageAuthenticationCode* clone() const;
25 
26  size_t output_length() const { return hash->output_length(); }
27 
29  {
30  // Absurd max length here is to support PBKDF2
31  return Key_Length_Specification(0, 512);
32  }
33 
34  /**
35  * @param hash the hash to use for HMACing
36  */
37  HMAC(HashFunction* hash);
38  ~HMAC() { delete hash; }
39  private:
40  void add_data(const byte[], size_t);
41  void final_result(byte[]);
42  void key_schedule(const byte[], size_t);
43 
44  HashFunction* hash;
45  SecureVector<byte> i_key, o_key;
46  };
47 
48 }
49 
50 #endif
Key_Length_Specification key_spec() const
Definition: hmac.h:28
unsigned char byte
Definition: types.h:22
~HMAC()
Definition: hmac.h:38
size_t output_length() const
Definition: hmac.h:26