9#ifndef BOTAN_OPENPGP_S2K_H_
10#define BOTAN_OPENPGP_S2K_H_
12#include <botan/hash.h>
13#include <botan/pbkdf.h>
14#include <botan/pwdhash.h>
15#include <botan/rfc4880.h>
44 explicit OpenPGP_S2K(std::unique_ptr<HashFunction> hash) : m_hash(std::move(hash)) {}
46 std::string
name()
const override {
return "OpenPGP-S2K(" + m_hash->name() +
")"; }
48 std::unique_ptr<PBKDF>
new_object()
const override {
return std::make_unique<OpenPGP_S2K>(m_hash->new_object()); }
50 size_t pbkdf(uint8_t output_buf[],
52 std::string_view passphrase,
56 std::chrono::milliseconds msec)
const override;
66 std::unique_ptr<HashFunction> m_hash;
86 RFC4880_S2K(std::unique_ptr<HashFunction> hash,
size_t iterations);
90 size_t iterations()
const override {
return m_iterations; }
97 size_t salt_len)
const override;
100 std::unique_ptr<HashFunction> m_hash;
108 std::string
name()
const override;
110 std::unique_ptr<PasswordHash> tune(
size_t output_len,
111 std::chrono::milliseconds msec,
113 std::chrono::milliseconds tune_msec)
const override;
120 std::unique_ptr<PasswordHash> default_params()
const override;
122 std::unique_ptr<PasswordHash> from_iterations(
size_t iter)
const override;
124 std::unique_ptr<PasswordHash> from_params(
size_t iter,
size_t,
size_t)
const override;
127 std::unique_ptr<HashFunction> m_hash;
std::unique_ptr< PBKDF > new_object() const override
static size_t decode_count(uint8_t encoded_iter)
std::string name() const override
static uint8_t encode_count(size_t iterations)
OpenPGP_S2K(std::unique_ptr< HashFunction > hash)
OctetString derive_key(size_t out_len, std::string_view passphrase, const uint8_t salt[], size_t salt_len, size_t iterations) const
virtual size_t pbkdf(uint8_t out[], size_t out_len, std::string_view passphrase, const uint8_t salt[], size_t salt_len, size_t iterations, std::chrono::milliseconds msec) const =0
virtual std::string name() const =0
RFC4880_S2K_Family(std::unique_ptr< HashFunction > hash)
size_t iterations() const override
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
uint8_t RFC4880_encode_count(size_t desired_iterations)
size_t RFC4880_decode_count(uint8_t iter)
std::string to_string(ErrorType type)
Convert an ErrorType to string.