Botan 2.19.5 Crypto and TLS for C&

bcrypt_pbkdf.h
Go to the documentation of this file.
1/*
2* (C) 2018,2019 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#ifndef BOTAN_PBKDF_BCRYPT_H_
8#define BOTAN_PBKDF_BCRYPT_H_
9
10#include <botan/pwdhash.h>
11
12 BOTAN_FUTURE_INTERNAL_HEADER(bcrypt_pbkdf.h)
13
14namespace Botan {
15
16/**
17* Bcrypt-PBKDF key derivation function
18*/
19 class BOTAN_PUBLIC_API(2,11) Bcrypt_PBKDF final : public PasswordHash
20 {
21 public:
22 Bcrypt_PBKDF(size_t iterations) : m_iterations(iterations) {}
23
24 Bcrypt_PBKDF(const Bcrypt_PBKDF& other) = default;
25 Bcrypt_PBKDF& operator=(const Bcrypt_PBKDF&) = default;
26
27 /**
28 * Derive a new key under the current Bcrypt-PBKDF parameter set
29 */
30 void derive_key(uint8_t out[], size_t out_len,
31 const char* password, size_t password_len,
32 const uint8_t salt[], size_t salt_len) const override;
33
34 std::string to_string() const override;
35
36 size_t iterations() const override { return m_iterations; }
37
38 size_t parallelism() const override { return 0; }
39
40 size_t memory_param() const override { return 0; }
41
42 size_t total_memory_usage() const override { return 4096; }
43
44 private:
45 size_t m_iterations;
46 };
47
48 class BOTAN_PUBLIC_API(2,11) Bcrypt_PBKDF_Family final : public PasswordHashFamily
49 {
50 public:
51 Bcrypt_PBKDF_Family() {}
52
53 std::string name() const override;
54
55 std::unique_ptr<PasswordHash> tune(size_t output_length,
56 std::chrono::milliseconds msec,
57 size_t max_memory) const override;
58
59 std::unique_ptr<PasswordHash> default_params() const override;
60
61 std::unique_ptr<PasswordHash> from_iterations(size_t iter) const override;
62
63 std::unique_ptr<PasswordHash> from_params(
64 size_t i, size_t, size_t) const override;
65 };
66
67/**
68* Bcrypt PBKDF compatible with OpenBSD bcrypt_pbkdf
69*/
70 void BOTAN_UNSTABLE_API bcrypt_pbkdf(uint8_t output[], size_t output_len,
71 const char* pass, size_t pass_len,
72 const uint8_t salt[], size_t salt_len,
73 size_t rounds);
74
75}
76
77#endif
Botan::Bcrypt_PBKDF_Family
Definition: bcrypt_pbkdf.h:49
Botan::Bcrypt_PBKDF_Family::Bcrypt_PBKDF_Family
Bcrypt_PBKDF_Family()
Definition: bcrypt_pbkdf.h:51
Botan::Bcrypt_PBKDF
Definition: bcrypt_pbkdf.h:20
Botan::Bcrypt_PBKDF::Bcrypt_PBKDF
Bcrypt_PBKDF(const Bcrypt_PBKDF &other)=default
Botan::Bcrypt_PBKDF::iterations
size_t iterations() const override
Definition: bcrypt_pbkdf.h:36
Botan::Bcrypt_PBKDF::total_memory_usage
size_t total_memory_usage() const override
Definition: bcrypt_pbkdf.h:42
Botan::Bcrypt_PBKDF::parallelism
size_t parallelism() const override
Definition: bcrypt_pbkdf.h:38
Botan::Bcrypt_PBKDF::memory_param
size_t memory_param() const override
Definition: bcrypt_pbkdf.h:40
Botan::Bcrypt_PBKDF::operator=
Bcrypt_PBKDF & operator=(const Bcrypt_PBKDF &)=default
Botan::Bcrypt_PBKDF::Bcrypt_PBKDF
Bcrypt_PBKDF(size_t iterations)
Definition: bcrypt_pbkdf.h:22
Botan::PasswordHashFamily
Definition: pwdhash.h:80
Botan::PasswordHash
Definition: pwdhash.h:25
Botan::PasswordHash::derive_key
virtual void derive_key(uint8_t out[], size_t out_len, const char *password, size_t password_len, const uint8_t salt[], size_t salt_len) const =0
Botan::PasswordHash::to_string
virtual std::string to_string() const =0
name
std::string name
Definition: commoncrypto_hash.cpp:24
final
int(* final)(unsigned char *, CTX *)
Definition: commoncrypto_hash.cpp:29
BOTAN_PUBLIC_API
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
BOTAN_FUTURE_INTERNAL_HEADER
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition: compiler.h:136
BOTAN_UNSTABLE_API
#define BOTAN_UNSTABLE_API
Definition: compiler.h:44
Botan
Definition: alg_id.cpp:13
Botan::bcrypt_pbkdf
void bcrypt_pbkdf(uint8_t output[], size_t output_len, const char *pass, size_t pass_len, const uint8_t salt[], size_t salt_len, size_t rounds)
Definition: bcrypt_pbkdf.cpp:130
salt_len
size_t salt_len
Definition: x509_obj.cpp:25