|
Botan 3.13.0
Crypto and TLS for C&
|
#include <pkcs12_kdf.h>
Public Member Functions | |
| 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 uint8_t ad[], size_t ad_len, const uint8_t key[], size_t key_len) const |
| 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 override |
| void | hash (std::span< uint8_t > out, std::string_view password, std::span< const uint8_t > salt) const |
| void | hash (std::span< uint8_t > out, std::string_view password, std::span< const uint8_t > salt, std::span< const uint8_t > associated_data, std::span< const uint8_t > key) const |
| size_t | iterations () const override |
| virtual size_t | memory_param () const |
| virtual size_t | parallelism () const |
| PKCS12_KDF (std::unique_ptr< HashFunction > hash, uint8_t id, size_t iterations) | |
| virtual bool | supports_associated_data () const |
| virtual bool | supports_keyed_operation () const |
| std::string | to_string () const override |
| virtual size_t | total_memory_usage () const |
PKCS#12 KDF (RFC 7292 Appendix B)
The id parameter (purpose byte) is fixed at family construction time: 1 = encryption key, 2 = IV, 3 = MAC key
The family spec used with PasswordHashFamily::create() is "PKCS12-KDF(hash,id)", e.g. "PKCS12-KDF(SHA-1,1)" with two arguments. PKCS12_KDF::to_string() additionally embeds the iteration count for round-tripping a fully-parameterized instance, producing "PKCS12-KDF(hash,id,iterations)"; that 3-argument form is not accepted by PasswordHashFamily::create() and should not be used as an algo spec.
Definition at line 35 of file pkcs12_kdf.h.
| Botan::PKCS12_KDF::PKCS12_KDF | ( | std::unique_ptr< HashFunction > | hash, |
| uint8_t | id, | ||
| size_t | iterations ) |
Definition at line 166 of file pkcs12_kdf.cpp.
References BOTAN_ARG_CHECK, Botan::PasswordHash::hash(), and iterations().
|
virtualinherited |
Derive a key from a password plus additional data and/or a secret key
Currently this is only supported for Argon2. Using a non-empty AD or key with other algorithms will cause a Not_Implemented exception.
| out | buffer to store the derived key, must be of out_len bytes |
| out_len | the desired length of the key to produce |
| password | the password to derive the key from |
| password_len | the length of password in bytes |
| salt | a randomly chosen salt |
| salt_len | length of salt in bytes |
| ad | some additional data |
| ad_len | length of ad in bytes |
| key | a secret key |
| key_len | length of key in bytes |
This function is const, but is not thread safe. Different threads should either use unique objects, or serialize all access.
Reimplemented in Botan::Argon2.
Definition at line 39 of file pwdhash.cpp.
References BOTAN_UNUSED, derive_key(), and to_string().
|
overridevirtual |
Derive a key from a password
| out | buffer to store the derived key, must be of out_len bytes |
| out_len | the desired length of the key to produce |
| password | the password to derive the key from |
| password_len | the length of password in bytes |
| salt | a randomly chosen salt |
| salt_len | length of salt in bytes |
This function is const, but is not thread safe. Different threads should either use unique objects, or serialize all access.
Implements Botan::PasswordHash.
Definition at line 177 of file pkcs12_kdf.cpp.
Referenced by Botan::PKCS12::export_to().
|
inlineinherited |
Hash a password into a bitstring
Derive a key from the specified password and salt, placing it into out.
| out | a span where the derived key will be placed |
| password | the password to derive the key from |
| salt | a randomly chosen salt |
This function is const, but is not thread safe. Different threads should either use unique objects, or serialize all access.
Definition at line 95 of file pwdhash.h.
References derive_key().
Referenced by Botan::PKCS12_KDF::PKCS12_KDF(), and Botan::RFC4880_S2K::RFC4880_S2K().
|
inlineinherited |
Hash a password into a bitstring
Derive a key from the specified password, salt, associated_data, and secret key, placing it into out. The associated_data and key are both allowed to be empty. Currently non-empty AD/key is only supported with Argon2.
| out | a span where the derived key will be placed |
| password | the password to derive the key from |
| salt | a randomly chosen salt |
| associated_data | some additional data |
| key | a secret key |
This function is const, but is not thread safe. Different threads should either use unique objects, or serialize all access.
Definition at line 116 of file pwdhash.h.
References derive_key().
|
inlineoverridevirtual |
Most password hashes have some notion of iterations.
Implements Botan::PasswordHash.
Definition at line 41 of file pkcs12_kdf.h.
Referenced by PKCS12_KDF().
|
inlinevirtualinherited |
Some password hashing algorithms have a parameter which controls how much memory is used. If not supported by some algorithm, returns 0.
Reimplemented in Botan::Argon2, Botan::Bcrypt_PBKDF, and Botan::Scrypt.
Definition at line 47 of file pwdhash.h.
|
inlinevirtualinherited |
Some password hashing algorithms have a parallelism parameter. If the algorithm does not support this notion, then the function returns zero. This allows distinguishing between a password hash which just does not support parallel operation, vs one that does support parallel operation but which has been configured to use a single lane.
Reimplemented in Botan::Argon2, Botan::Bcrypt_PBKDF, and Botan::Scrypt.
Definition at line 57 of file pwdhash.h.
|
inlinevirtualinherited |
Query if this password hash supports associated data
Reimplemented in Botan::Argon2.
Definition at line 80 of file pwdhash.h.
|
inlinevirtualinherited |
Query if this password hash supports a symmetric key
Reimplemented in Botan::Argon2.
Definition at line 73 of file pwdhash.h.
|
overridevirtual |
Return a free-form string identifying the algorithm and parameters
Implements Botan::PasswordHash.
Definition at line 173 of file pkcs12_kdf.cpp.
References Botan::fmt().
|
inlinevirtualinherited |
Returns an estimate of the total number of bytes required to perform this key derivation.
If this algorithm uses a small and constant amount of memory, with no effort made towards being memory hard, this function returns 0.
Reimplemented in Botan::Argon2, Botan::Bcrypt_PBKDF, and Botan::Scrypt.
Definition at line 66 of file pwdhash.h.