Botan  2.19.1
Crypto and TLS for C++11
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 <chrono>
13 
15 
16 namespace Botan {
17 
18 class RandomNumberGenerator;
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 */
29 std::pair<AlgorithmIdentifier, std::vector<uint8_t>>
30 BOTAN_PUBLIC_API(2,0) pbes2_encrypt(const secure_vector<uint8_t>& key_bits,
31  const std::string& passphrase,
32  std::chrono::milliseconds msec,
33  const std::string& cipher,
34  const std::string& digest,
35  RandomNumberGenerator& rng);
36 
37 /**
38 * Encrypt with PBES2 from PKCS #5 v2.0
39 * @param key_bits the input
40 * @param passphrase the passphrase to use for encryption
41 * @param msec how many milliseconds to run PBKDF2
42 * @param out_iterations_if_nonnull if not null, set to the number
43 * of PBKDF iterations used
44 * @param cipher specifies the block cipher to use to encrypt
45 * @param digest specifies the PRF to use with PBKDF2 (eg "HMAC(SHA-1)")
46 * @param rng a random number generator
47 */
48 std::pair<AlgorithmIdentifier, std::vector<uint8_t>>
49 BOTAN_PUBLIC_API(2,1) pbes2_encrypt_msec(const secure_vector<uint8_t>& key_bits,
50  const std::string& passphrase,
51  std::chrono::milliseconds msec,
52  size_t* out_iterations_if_nonnull,
53  const std::string& cipher,
54  const std::string& digest,
55  RandomNumberGenerator& rng);
56 
57 /**
58 * Encrypt with PBES2 from PKCS #5 v2.0
59 * @param key_bits the input
60 * @param passphrase the passphrase to use for encryption
61 * @param iterations how many iterations to run PBKDF2
62 * @param cipher specifies the block cipher to use to encrypt
63 * @param digest specifies the PRF to use with PBKDF2 (eg "HMAC(SHA-1)")
64 * @param rng a random number generator
65 */
66 std::pair<AlgorithmIdentifier, std::vector<uint8_t>>
67 BOTAN_PUBLIC_API(2,1) pbes2_encrypt_iter(const secure_vector<uint8_t>& key_bits,
68  const std::string& passphrase,
69  size_t iterations,
70  const std::string& cipher,
71  const std::string& digest,
72  RandomNumberGenerator& rng);
73 
74 /**
75 * Decrypt a PKCS #5 v2.0 encrypted stream
76 * @param key_bits the input
77 * @param passphrase the passphrase to use for decryption
78 * @param params the PBES2 parameters
79 */
80 secure_vector<uint8_t>
81 BOTAN_PUBLIC_API(2,0) pbes2_decrypt(const secure_vector<uint8_t>& key_bits,
82  const std::string& passphrase,
83  const std::vector<uint8_t>& params);
84 
85 }
86 
87 #endif
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
Definition: bigint.h:1143
std::pair< AlgorithmIdentifier, std::vector< uint8_t > > pbes2_encrypt_msec(const secure_vector< uint8_t > &key_bits, const std::string &passphrase, std::chrono::milliseconds msec, size_t *out_iterations_if_nonnull, const std::string &cipher, const std::string &digest, RandomNumberGenerator &rng)
Definition: pbes2.cpp:273
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:65
std::pair< AlgorithmIdentifier, std::vector< uint8_t > > pbes2_encrypt_iter(const secure_vector< uint8_t > &key_bits, const std::string &passphrase, size_t pbkdf_iter, const std::string &cipher, const std::string &digest, RandomNumberGenerator &rng)
Definition: pbes2.cpp:292
std::pair< AlgorithmIdentifier, std::vector< uint8_t > > pbes2_encrypt(const secure_vector< uint8_t > &key_bits, const std::string &passphrase, std::chrono::milliseconds msec, const std::string &cipher, const std::string &digest, RandomNumberGenerator &rng)
Definition: pbes2.cpp:260
Definition: alg_id.cpp:13
secure_vector< uint8_t > pbes2_decrypt(const secure_vector< uint8_t > &key_bits, const std::string &passphrase, const std::vector< uint8_t > &params)
Definition: pbes2.cpp:303
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition: compiler.h:136