Botan  2.4.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 
14 namespace Botan {
15 
16 BOTAN_PUBLIC_API(2,0) size_t pbkdf2(MessageAuthenticationCode& prf,
17  uint8_t out[],
18  size_t out_len,
19  const std::string& passphrase,
20  const uint8_t salt[], size_t salt_len,
21  size_t iterations,
22  std::chrono::milliseconds msec);
23 
24 /**
25 * PKCS #5 PBKDF2
26 */
27 class BOTAN_PUBLIC_API(2,0) PKCS5_PBKDF2 final : public PBKDF
28  {
29  public:
30  std::string name() const override
31  {
32  return "PBKDF2(" + m_mac->name() + ")";
33  }
34 
35  PBKDF* clone() const override
36  {
37  return new PKCS5_PBKDF2(m_mac->clone());
38  }
39 
40  size_t pbkdf(uint8_t output_buf[], size_t output_len,
41  const std::string& passphrase,
42  const uint8_t salt[], size_t salt_len,
43  size_t iterations,
44  std::chrono::milliseconds msec) const override;
45 
46  /**
47  * Create a PKCS #5 instance using the specified message auth code
48  * @param mac_fn the MAC object to use as PRF
49  */
50  explicit PKCS5_PBKDF2(MessageAuthenticationCode* mac_fn) : m_mac(mac_fn) {}
51  private:
52  std::unique_ptr<MessageAuthenticationCode> m_mac;
53  };
54 
55 }
56 
57 #endif
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:27
Definition: bigint.h:635
std::string name() const override
Definition: pbkdf2.h:30
PKCS5_PBKDF2(MessageAuthenticationCode *mac_fn)
Definition: pbkdf2.h:50
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:14
size_t salt_len
Definition: x509_obj.cpp:25
Definition: alg_id.cpp:13
PBKDF * clone() const override
Definition: pbkdf2.h:35