Botan 2.19.3
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
13
14namespace Botan {
15
16/**
17* Bcrypt-PBKDF key derivation function
18*/
20 {
21 public:
22 Bcrypt_PBKDF(size_t iterations) : m_iterations(iterations) {}
23
24 Bcrypt_PBKDF(const Bcrypt_PBKDF& other) = 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
49 {
50 public:
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*/
70void 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
Bcrypt_PBKDF(const Bcrypt_PBKDF &other)=default
size_t iterations() const override
size_t total_memory_usage() const override
size_t parallelism() const override
size_t memory_param() const override
Bcrypt_PBKDF & operator=(const Bcrypt_PBKDF &)=default
Bcrypt_PBKDF(size_t iterations)
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
virtual std::string to_string() const =0
std::string name
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition compiler.h:31
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition compiler.h:136
#define BOTAN_UNSTABLE_API
Definition compiler.h:44
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)
size_t salt_len
Definition x509_obj.cpp:25