Botan  2.1.0
Crypto and TLS for C++11
pbkdf2.h
Go to the documentation of this file.
1 /*
2 * PBKDF2
3 * (C) 1999-2007,2012 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7 
8 #ifndef BOTAN_PBKDF2_H__
9 #define BOTAN_PBKDF2_H__
10 
11 #include <botan/pbkdf.h>
12 #include <botan/mac.h>
13 #include <botan/hash.h>
14 
15 namespace Botan {
16 
17 BOTAN_DLL size_t pbkdf2(MessageAuthenticationCode& prf,
18  uint8_t out[],
19  size_t out_len,
20  const std::string& passphrase,
21  const uint8_t salt[], size_t salt_len,
22  size_t iterations,
23  std::chrono::milliseconds msec);
24 
25 /**
26 * PKCS #5 PBKDF2
27 */
28 class BOTAN_DLL PKCS5_PBKDF2 final : public PBKDF
29  {
30  public:
31  std::string name() const override
32  {
33  return "PBKDF2(" + m_mac->name() + ")";
34  }
35 
36  PBKDF* clone() const override
37  {
38  return new PKCS5_PBKDF2(m_mac->clone());
39  }
40 
41  size_t pbkdf(uint8_t output_buf[], size_t output_len,
42  const std::string& passphrase,
43  const uint8_t salt[], size_t salt_len,
44  size_t iterations,
45  std::chrono::milliseconds msec) const override;
46 
47  /**
48  * Create a PKCS #5 instance using the specified message auth code
49  * @param mac_fn the MAC object to use as PRF
50  */
51  explicit PKCS5_PBKDF2(MessageAuthenticationCode* mac_fn) : m_mac(mac_fn) {}
52  private:
53  std::unique_ptr<MessageAuthenticationCode> m_mac;
54  };
55 
56 }
57 
58 #endif
std::unique_ptr< MessageAuthenticationCode > m_mac
Definition: fpe_fe1.cpp:88
std::string name() const override
Definition: pbkdf2.h:31
PKCS5_PBKDF2(MessageAuthenticationCode *mac_fn)
Definition: pbkdf2.h:51
Definition: alg_id.cpp:13
size_t pbkdf2(MessageAuthenticationCode &prf, uint8_t out[], size_t out_len, const std::string &passphrase, const uint8_t salt[], size_t salt_len, size_t iterations, std::chrono::milliseconds msec)
Definition: pbkdf2.cpp:15
PBKDF * clone() const override
Definition: pbkdf2.h:36