Botan  2.7.0
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/alg_id.h>
12 #include <chrono>
13 
14 namespace Botan {
15 
16 class RandomNumberGenerator;
17 
18 /**
19 * Encrypt with PBES2 from PKCS #5 v2.0
20 * @param key_bits the input
21 * @param passphrase the passphrase to use for encryption
22 * @param msec how many milliseconds to run PBKDF2
23 * @param cipher specifies the block cipher to use to encrypt
24 * @param digest specifies the PRF to use with PBKDF2 (eg "HMAC(SHA-1)")
25 * @param rng a random number generator
26 */
27 std::pair<AlgorithmIdentifier, std::vector<uint8_t>>
28 BOTAN_PUBLIC_API(2,0) pbes2_encrypt(const secure_vector<uint8_t>& key_bits,
29  const std::string& passphrase,
30  std::chrono::milliseconds msec,
31  const std::string& cipher,
32  const std::string& digest,
33  RandomNumberGenerator& rng);
34 
35 /**
36 * Encrypt with PBES2 from PKCS #5 v2.0
37 * @param key_bits the input
38 * @param passphrase the passphrase to use for encryption
39 * @param msec how many milliseconds to run PBKDF2
40 * @param out_iterations_if_nonnull if not null, set to the number
41 * of PBKDF iterations used
42 * @param cipher specifies the block cipher to use to encrypt
43 * @param digest specifies the PRF to use with PBKDF2 (eg "HMAC(SHA-1)")
44 * @param rng a random number generator
45 */
46 std::pair<AlgorithmIdentifier, std::vector<uint8_t>>
47 BOTAN_PUBLIC_API(2,1) pbes2_encrypt_msec(const secure_vector<uint8_t>& key_bits,
48  const std::string& passphrase,
49  std::chrono::milliseconds msec,
50  size_t* out_iterations_if_nonnull,
51  const std::string& cipher,
52  const std::string& digest,
53  RandomNumberGenerator& rng);
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 */
64 std::pair<AlgorithmIdentifier, std::vector<uint8_t>>
65 BOTAN_PUBLIC_API(2,1) pbes2_encrypt_iter(const secure_vector<uint8_t>& key_bits,
66  const std::string& passphrase,
67  size_t iterations,
68  const std::string& cipher,
69  const std::string& digest,
70  RandomNumberGenerator& rng);
71 
72 /**
73 * Decrypt a PKCS #5 v2.0 encrypted stream
74 * @param key_bits the input
75 * @param passphrase the passphrase to use for decryption
76 * @param params the PBES2 parameters
77 */
78 secure_vector<uint8_t>
79 BOTAN_PUBLIC_API(2,0) pbes2_decrypt(const secure_vector<uint8_t>& key_bits,
80  const std::string& passphrase,
81  const std::vector<uint8_t>& params);
82 
83 }
84 
85 #endif
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:27
Definition: bigint.h:796
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:246
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:265
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:233
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:276
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:88