Botan 3.3.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 <chrono>
13#include <span>
14
15namespace Botan {
16
17class RandomNumberGenerator;
18
19/**
20* Encrypt with PBES2 from PKCS #5 v2.0
21* @param key_bits the input
22* @param passphrase the passphrase to use for encryption
23* @param msec how many milliseconds to run PBKDF2
24* @param cipher specifies the block cipher to use to encrypt
25* @param digest specifies the PRF to use with PBKDF2 (eg "HMAC(SHA-1)")
26* @param rng a random number generator
27*/
28std::pair<AlgorithmIdentifier, std::vector<uint8_t>> pbes2_encrypt(std::span<const uint8_t> key_bits,
29 std::string_view passphrase,
30 std::chrono::milliseconds msec,
31 std::string_view cipher,
32 std::string_view 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*/
46std::pair<AlgorithmIdentifier, std::vector<uint8_t>> pbes2_encrypt_msec(std::span<const uint8_t> key_bits,
47 std::string_view passphrase,
48 std::chrono::milliseconds msec,
49 size_t* out_iterations_if_nonnull,
50 std::string_view cipher,
51 std::string_view digest,
52 RandomNumberGenerator& rng);
53
54/**
55* Encrypt with PBES2 from PKCS #5 v2.0
56* @param key_bits the input
57* @param passphrase the passphrase to use for encryption
58* @param iterations how many iterations to run PBKDF2
59* @param cipher specifies the block cipher to use to encrypt
60* @param digest specifies the PRF to use with PBKDF2 (eg "HMAC(SHA-1)")
61* @param rng a random number generator
62*/
63std::pair<AlgorithmIdentifier, std::vector<uint8_t>> pbes2_encrypt_iter(std::span<const uint8_t> key_bits,
64 std::string_view passphrase,
65 size_t iterations,
66 std::string_view cipher,
67 std::string_view digest,
68 RandomNumberGenerator& rng);
69
70/**
71* Decrypt a PKCS #5 v2.0 encrypted stream
72* @param key_bits the input
73* @param passphrase the passphrase to use for decryption
74* @param params the PBES2 parameters
75*/
76secure_vector<uint8_t> pbes2_decrypt(std::span<const uint8_t> key_bits,
77 std::string_view passphrase,
78 const std::vector<uint8_t>& params);
79
80} // namespace Botan
81
82#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:261
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:270
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:243
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:232