Botan 3.11.0
Crypto and TLS for C&
pbes2.h
Go to the documentation of this file.
1/*
2* PKCS #5 v2.0 PBE
3* (C) 1999-2007,2014 Jack Lloyd
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_PBE_PKCS_V20_H_
9#define BOTAN_PBE_PKCS_V20_H_
10
11#include <botan/asn1_obj.h>
12#include <botan/secmem.h>
13#include <chrono>
14#include <span>
15
16namespace Botan {
17
19
20/**
21* Encrypt with PBES2 from PKCS #5 v2.0
22* @param key_bits the input
23* @param passphrase the passphrase to use for encryption
24* @param msec how many milliseconds to run PBKDF2
25* @param cipher specifies the block cipher to use to encrypt
26* @param digest specifies the PRF to use with PBKDF2 (eg "HMAC(SHA-1)")
27* @param rng a random number generator
28*/
29std::pair<AlgorithmIdentifier, std::vector<uint8_t>> pbes2_encrypt(std::span<const uint8_t> key_bits,
30 std::string_view passphrase,
31 std::chrono::milliseconds msec,
32 std::string_view cipher,
33 std::string_view digest,
35
36/**
37* Encrypt with PBES2 from PKCS #5 v2.0
38* @param key_bits the input
39* @param passphrase the passphrase to use for encryption
40* @param msec how many milliseconds to run PBKDF2
41* @param out_iterations_if_nonnull if not null, set to the number
42* of PBKDF iterations used
43* @param cipher specifies the block cipher to use to encrypt
44* @param digest specifies the PRF to use with PBKDF2 (eg "HMAC(SHA-1)")
45* @param rng a random number generator
46*/
47std::pair<AlgorithmIdentifier, std::vector<uint8_t>> pbes2_encrypt_msec(std::span<const uint8_t> key_bits,
48 std::string_view passphrase,
49 std::chrono::milliseconds msec,
50 size_t* out_iterations_if_nonnull,
51 std::string_view cipher,
52 std::string_view digest,
54
55/**
56* Encrypt with PBES2 from PKCS #5 v2.0
57* @param key_bits the input
58* @param passphrase the passphrase to use for encryption
59* @param iterations how many iterations to run PBKDF2
60* @param cipher specifies the block cipher to use to encrypt
61* @param digest specifies the PRF to use with PBKDF2 (eg "HMAC(SHA-1)")
62* @param rng a random number generator
63*/
64std::pair<AlgorithmIdentifier, std::vector<uint8_t>> pbes2_encrypt_iter(std::span<const uint8_t> key_bits,
65 std::string_view passphrase,
66 size_t iterations,
67 std::string_view cipher,
68 std::string_view digest,
70
71/**
72* Decrypt a PKCS #5 v2.0 encrypted stream
73* @param key_bits the input
74* @param passphrase the passphrase to use for decryption
75* @param params the PBES2 parameters
76*/
77secure_vector<uint8_t> pbes2_decrypt(std::span<const uint8_t> key_bits,
78 std::string_view passphrase,
79 const std::vector<uint8_t>& params);
80
81} // namespace Botan
82
83#endif
std::pair< AlgorithmIdentifier, std::vector< uint8_t > > pbes2_encrypt_iter(std::span< const uint8_t > key_bits, std::string_view passphrase, size_t pbkdf_iter, std::string_view cipher, std::string_view digest, RandomNumberGenerator &rng)
Definition pbes2.cpp:272
secure_vector< uint8_t > pbes2_decrypt(std::span< const uint8_t > key_bits, std::string_view passphrase, const std::vector< uint8_t > &params)
Definition pbes2.cpp:281
std::pair< AlgorithmIdentifier, std::vector< uint8_t > > pbes2_encrypt_msec(std::span< const uint8_t > key_bits, std::string_view passphrase, std::chrono::milliseconds msec, size_t *out_iterations_if_nonnull, std::string_view cipher, std::string_view digest, RandomNumberGenerator &rng)
Definition pbes2.cpp:254
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:68
std::pair< AlgorithmIdentifier, std::vector< uint8_t > > pbes2_encrypt(std::span< const uint8_t > key_bits, std::string_view passphrase, std::chrono::milliseconds msec, std::string_view cipher, std::string_view digest, RandomNumberGenerator &rng)
Definition pbes2.cpp:243