Botan 3.6.1
Crypto and TLS for C&
passhash9.h
Go to the documentation of this file.
1/*
2* Passhash9 Password Hashing
3* (C) 2010 Jack Lloyd
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_PASSHASH9_H_
9#define BOTAN_PASSHASH9_H_
10
11#include <botan/types.h>
12#include <string>
13
14namespace Botan {
15
16class RandomNumberGenerator;
17
18/**
19* Create a password hash using PBKDF2
20*
21* Functions much like generate_bcrypt(). The last parameter,
22* @p alg_id, specifies which PRF to use. Currently defined values are:
23*
24* - 0: HMAC(SHA-1)
25* - 1: HMAC(SHA-256)
26* - 2: CMAC(Blowfish)
27* - 3: HMAC(SHA-384)
28* - 4: HMAC(SHA-512)
29*
30* The @p work_factor must be greater than zero and less than 512. This performs
31* 10000 * @p work_factor PBKDF2 iterations, using 96 bits of salt taken from
32* @p rng. Using work factor of 10 or more is recommended.
33*
34* @param password the password
35* @param rng a random number generator
36* @param work_factor how much work to do to slow down guessing attacks
37* @param alg_id specifies which PRF to use with PBKDF2 0 is HMAC(SHA-1) 1 is
38* HMAC(SHA-256) 2 is CMAC(Blowfish) 3 is HMAC(SHA-384) 4 is HMAC(SHA-512)
39* all other values are currently undefined
40*/
41std::string BOTAN_PUBLIC_API(2, 0) generate_passhash9(std::string_view password,
42 RandomNumberGenerator& rng,
43 uint16_t work_factor = 15,
44 uint8_t alg_id = 4);
45
46/**
47* Check a previously created password hash
48* @param password the password to check against
49* @param hash the stored hash to check against
50*/
51bool BOTAN_PUBLIC_API(2, 0) check_passhash9(std::string_view password, std::string_view hash);
52
53/**
54* Check if the PRF used with PBKDF2 is supported
55* @param alg_id alg_id used in generate_passhash9()
56*/
57bool BOTAN_PUBLIC_API(2, 3) is_passhash9_alg_supported(uint8_t alg_id);
58
59} // namespace Botan
60
61#endif
#define BOTAN_PUBLIC_API(maj, min)
Definition compiler.h:31
std::string generate_passhash9(std::string_view pass, RandomNumberGenerator &rng, uint16_t work_factor, uint8_t alg_id)
Definition passhash9.cpp:46
bool check_passhash9(std::string_view pass, std::string_view hash)
Definition passhash9.cpp:75
bool is_passhash9_alg_supported(uint8_t alg_id)