Botan  2.10.0
Crypto and TLS for C++11
Functions | Variables
Botan::PKCS8 Namespace Reference

Functions

secure_vector< uint8_t > BER_encode (const Private_Key &key)
 
std::vector< uint8_t > BER_encode (const Private_Key &key, RandomNumberGenerator &rng, const std::string &pass, std::chrono::milliseconds msec, const std::string &pbe_algo)
 
std::vector< uint8_t > BER_encode_encrypted_pbkdf_iter (const Private_Key &key, RandomNumberGenerator &rng, const std::string &pass, size_t pbkdf_iterations, const std::string &cipher, const std::string &pbkdf_hash)
 
std::vector< uint8_t > BER_encode_encrypted_pbkdf_msec (const Private_Key &key, RandomNumberGenerator &rng, const std::string &pass, std::chrono::milliseconds pbkdf_msec, size_t *pbkdf_iterations, const std::string &cipher, const std::string &pbkdf_hash)
 
 BOTAN_PUBLIC_API (2, 0) secure_vector< uint8_t > BER_encode(const Private_Key &key)
 
std::unique_ptr< Private_Key > copy_key (const Private_Key &key)
 
Private_Key * copy_key (const Private_Key &key, RandomNumberGenerator &rng)
 
std::unique_ptr< Private_Key > load_key (DataSource &source, std::function< std::string()> get_pass)
 
std::unique_ptr< Private_Key > load_key (DataSource &source, const std::string &pass)
 
std::unique_ptr< Private_Key > load_key (DataSource &source)
 
Private_Key * load_key (DataSource &source, RandomNumberGenerator &rng, std::function< std::string()> get_pass)
 
Private_Key * load_key (DataSource &source, RandomNumberGenerator &rng, const std::string &pass)
 
Private_Key * load_key (DataSource &source, RandomNumberGenerator &rng)
 
std::string PEM_encode (const Private_Key &key)
 
std::string PEM_encode (const Private_Key &key, RandomNumberGenerator &rng, const std::string &pass, std::chrono::milliseconds msec, const std::string &pbe_algo)
 
std::string PEM_encode_encrypted_pbkdf_iter (const Private_Key &key, RandomNumberGenerator &rng, const std::string &pass, size_t pbkdf_iterations, const std::string &cipher, const std::string &pbkdf_hash)
 
std::string PEM_encode_encrypted_pbkdf_msec (const Private_Key &key, RandomNumberGenerator &rng, const std::string &pass, std::chrono::milliseconds pbkdf_msec, size_t *pbkdf_iterations, const std::string &cipher, const std::string &pbkdf_hash)
 

Variables

BOTAN_PUBLIC_API(2, 0) std BOTAN_PUBLIC_API(2, 0) std BOTAN_PUBLIC_API(2, 0) std BOTAN_PUBLIC_API(2, 1) std BOTAN_PUBLIC_API(2, 1) std BOTAN_PUBLIC_API(2, 1) std BOTAN_PUBLIC_API(2, 1) std RandomNumberGenerator std::function< std::string()> get_passphrase
 
RandomNumberGenerator const std::string & pass
 
BOTAN_PUBLIC_API(2, 0) std BOTAN_PUBLIC_API(2, 0) std BOTAN_PUBLIC_API(2, 0) std BOTAN_PUBLIC_API(2, 1) std BOTAN_PUBLIC_API(2, 1) std BOTAN_PUBLIC_API(2, 1) std BOTAN_PUBLIC_API(2, 1) std RandomNumberGenerator & rng
 

Detailed Description

PKCS #8 General ExceptionThis namespace contains functions for handling PKCS #8 private keys

Function Documentation

◆ BER_encode() [1/2]

secure_vector<uint8_t> Botan::PKCS8::BER_encode ( const Private_Key &  key)

Definition at line 139 of file pkcs8.cpp.

140  {
141  // keeping around for compat
142  return key.private_key_info();
143  }
const uint8_t * key
Definition: ffi.h:359

References key.

Referenced by BER_encode(), botan_privkey_export(), Botan::OCSP::BOTAN_PUBLIC_API(), Botan::BOTAN_PUBLIC_API(), and PEM_encode().

◆ BER_encode() [2/2]

std::vector<uint8_t> Botan::PKCS8::BER_encode ( const Private_Key &  key,
RandomNumberGenerator &  rng,
const std::string &  pass,
std::chrono::milliseconds  msec,
const std::string &  pbe_algo 
)

Definition at line 200 of file pkcs8.cpp.

205  {
206 #if defined(BOTAN_HAS_PKCS5_PBES2)
207  const auto pbe_params = choose_pbe_params(pbe_algo, key.algo_name());
208 
209  const std::pair<AlgorithmIdentifier, std::vector<uint8_t>> pbe_info =
211  pbe_params.first, pbe_params.second, rng);
212 
213  std::vector<uint8_t> output;
214  DER_Encoder der(output);
215  der.start_cons(SEQUENCE)
216  .encode(pbe_info.first)
217  .encode(pbe_info.second, OCTET_STRING)
218  .end_cons();
219 
220  return output;
221 #else
222  BOTAN_UNUSED(key, rng, pass, msec, pbe_algo);
223  throw Encoding_Error("PKCS8::BER_encode cannot encrypt because PBES2 was disabled in build");
224 #endif
225  }
uint32_t uint8_t output[]
Definition: ffi.h:509
botan_rng_t rng
Definition: ffi.h:856
std::vector< uint8_t > BER_encode(const Private_Key &key, RandomNumberGenerator &rng, const std::string &pass, std::chrono::milliseconds msec, const std::string &pbe_algo)
Definition: pkcs8.cpp:200
int uint32_t msec
Definition: ffi.h:610
#define BOTAN_UNUSED(...)
Definition: assert.h:142
const uint8_t * key
Definition: ffi.h:359
RandomNumberGenerator const std::string & pass
Definition: pkcs8.h:198
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:276

References BER_encode(), BOTAN_UNUSED, key, Botan::msec, Botan::OCTET_STRING, Botan::output, pass, Botan::pbes2_encrypt_msec(), rng, and Botan::SEQUENCE.

◆ BER_encode_encrypted_pbkdf_iter()

std::vector<uint8_t> Botan::PKCS8::BER_encode_encrypted_pbkdf_iter ( const Private_Key &  key,
RandomNumberGenerator &  rng,
const std::string &  pass,
size_t  pbkdf_iterations,
const std::string &  cipher,
const std::string &  pbkdf_hash 
)

Definition at line 246 of file pkcs8.cpp.

252  {
253 #if defined(BOTAN_HAS_PKCS5_PBES2)
254  const std::pair<AlgorithmIdentifier, std::vector<uint8_t>> pbe_info =
255  pbes2_encrypt_iter(key.private_key_info(),
257  cipher.empty() ? "AES-256/CBC" : cipher,
258  pbkdf_hash.empty() ? "SHA-256" : pbkdf_hash,
259  rng);
260 
261  std::vector<uint8_t> output;
262  DER_Encoder der(output);
263  der.start_cons(SEQUENCE)
264  .encode(pbe_info.first)
265  .encode(pbe_info.second, OCTET_STRING)
266  .end_cons();
267 
268  return output;
269 
270 #else
271  BOTAN_UNUSED(key, rng, pass, pbkdf_iterations, cipher, pbkdf_hash);
272  throw Encoding_Error("PKCS8::BER_encode_encrypted_pbkdf_iter cannot encrypt because PBES2 disabled in build");
273 #endif
274  }
uint32_t uint8_t output[]
Definition: ffi.h:509
botan_rng_t rng
Definition: ffi.h:856
uint8_t size_t botan_rng_t const char size_t pbkdf_iterations
Definition: ffi.h:1053
void BlockCipher * cipher
Definition: package.h:29
#define BOTAN_UNUSED(...)
Definition: assert.h:142
const uint8_t * key
Definition: ffi.h:359
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:295
RandomNumberGenerator const std::string & pass
Definition: pkcs8.h:198

References BOTAN_UNUSED, Botan::cipher, key, Botan::OCTET_STRING, Botan::output, pass, Botan::pbes2_encrypt_iter(), pbkdf_iterations, rng, and Botan::SEQUENCE.

Referenced by botan_privkey_export_encrypted_pbkdf_iter(), and PEM_encode_encrypted_pbkdf_iter().

◆ BER_encode_encrypted_pbkdf_msec()

std::vector<uint8_t> Botan::PKCS8::BER_encode_encrypted_pbkdf_msec ( const Private_Key &  key,
RandomNumberGenerator &  rng,
const std::string &  pass,
std::chrono::milliseconds  pbkdf_msec,
size_t *  pbkdf_iterations,
const std::string &  cipher,
const std::string &  pbkdf_hash 
)

Definition at line 294 of file pkcs8.cpp.

301  {
302 #if defined(BOTAN_HAS_PKCS5_PBES2)
303  const std::pair<AlgorithmIdentifier, std::vector<uint8_t>> pbe_info =
304  pbes2_encrypt_msec(key.private_key_info(), pass,
305  pbkdf_msec, pbkdf_iterations,
306  cipher.empty() ? "AES-256/CBC" : cipher,
307  pbkdf_hash.empty() ? "SHA-256" : pbkdf_hash,
308  rng);
309 
310  std::vector<uint8_t> output;
311  DER_Encoder(output)
312  .start_cons(SEQUENCE)
313  .encode(pbe_info.first)
314  .encode(pbe_info.second, OCTET_STRING)
315  .end_cons();
316 
317  return output;
318 #else
319  BOTAN_UNUSED(key, rng, pass, pbkdf_msec, pbkdf_iterations, cipher, pbkdf_hash);
320  throw Encoding_Error("BER_encode_encrypted_pbkdf_msec cannot encrypt because PBES2 disabled in build");
321 #endif
322  }
uint32_t uint8_t output[]
Definition: ffi.h:509
botan_rng_t rng
Definition: ffi.h:856
uint8_t size_t botan_rng_t const char size_t pbkdf_iterations
Definition: ffi.h:1053
void BlockCipher * cipher
Definition: package.h:29
#define BOTAN_UNUSED(...)
Definition: assert.h:142
const uint8_t * key
Definition: ffi.h:359
RandomNumberGenerator const std::string & pass
Definition: pkcs8.h:198
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:276

References BOTAN_UNUSED, Botan::cipher, key, Botan::OCTET_STRING, Botan::output, pass, Botan::pbes2_encrypt_msec(), pbkdf_iterations, rng, and Botan::SEQUENCE.

Referenced by botan_privkey_export_encrypted_pbkdf_msec(), and PEM_encode_encrypted_pbkdf_msec().

◆ BOTAN_PUBLIC_API()

Botan::PKCS8::BOTAN_PUBLIC_API ( ,
 
) const &

BER encode a private key

Parameters
keythe private key to encode
Returns
BER encoded key

Get a string containing a PEM encoded private key.

Parameters
keythe key to encode
Returns
encoded keyEncrypt a key using PKCS #8 encryption
Parameters
keythe key to encode
rngthe rng to use
passthe password to use for encryption
msecnumber of milliseconds to run the password derivation
pbe_algothe name of the desired password-based encryption algorithm; if empty ("") a reasonable (portable/secure) default will be chosen.
Returns
encrypted key in binary BER formGet a string containing a PEM encoded private key, encrypting it with a password.
Parameters
keythe key to encode
rngthe rng to use
passthe password to use for encryption
msecnumber of milliseconds to run the password derivation
pbe_algothe name of the desired password-based encryption algorithm; if empty ("") a reasonable (portable/secure) default will be chosen.
Returns
encrypted key in PEM formEncrypt a key using PKCS #8 encryption and a fixed iteration count
Parameters
keythe key to encode
rngthe rng to use
passthe password to use for encryption
pbkdf_iternumber of interations to run PBKDF2
cipherif non-empty specifies the cipher to use. CBC and GCM modes are supported, for example "AES-128/CBC", "AES-256/GCM", "Serpent/CBC". If empty a suitable default is chosen.
pbkdf_hashif non-empty specifies the PBKDF hash function to use. For example "SHA-256" or "SHA-384". If empty a suitable default is chosen.
Returns
encrypted key in binary BER formGet a string containing a PEM encoded private key, encrypting it with a password.
Parameters
keythe key to encode
rngthe rng to use
passthe password to use for encryption
pbkdf_iternumber of iterations to run PBKDF
cipherif non-empty specifies the cipher to use. CBC and GCM modes are supported, for example "AES-128/CBC", "AES-256/GCM", "Serpent/CBC". If empty a suitable default is chosen.
pbkdf_hashif non-empty specifies the PBKDF hash function to use. For example "SHA-256" or "SHA-384". If empty a suitable default is chosen.
Returns
encrypted key in PEM formEncrypt a key using PKCS #8 encryption and a variable iteration count
Parameters
keythe key to encode
rngthe rng to use
passthe password to use for encryption
pbkdf_msechow long to run PBKDF2
pbkdf_iterationsif non-null, set to the number of iterations used
cipherif non-empty specifies the cipher to use. CBC and GCM modes are supported, for example "AES-128/CBC", "AES-256/GCM", "Serpent/CBC". If empty a suitable default is chosen.
pbkdf_hashif non-empty specifies the PBKDF hash function to use. For example "SHA-256" or "SHA-384". If empty a suitable default is chosen.
Returns
encrypted key in binary BER formGet a string containing a PEM encoded private key, encrypting it with a password.
Parameters
keythe key to encode
rngthe rng to use
passthe password to use for encryption
pbkdf_msechow long in milliseconds to run PBKDF2
pbkdf_iterations(output argument) number of iterations of PBKDF that ended up being used
cipherif non-empty specifies the cipher to use. CBC and GCM modes are supported, for example "AES-128/CBC", "AES-256/GCM", "Serpent/CBC". If empty a suitable default is chosen.
pbkdf_hashif non-empty specifies the PBKDF hash function to use. For example "SHA-256" or "SHA-384". If empty a suitable default is chosen.
Returns
encrypted key in PEM formLoad an encrypted key from a data source.
Parameters
sourcethe data source providing the encoded key
rngignored for compatibility
get_passphrasea function that returns passphrases
Returns
loaded private key object

Load an encrypted key from a data source.

Parameters
sourcethe data source providing the encoded key
rngignored for compatibility
passthe passphrase to decrypt the key
Returns
loaded private key object

Load an unencrypted key from a data source.

Parameters
sourcethe data source providing the encoded key
rngignored for compatibility
Returns
loaded private key object

Copy an existing encoded key object.

Parameters
keythe key to copy
rngignored for compatibility
Returns
new copy of the key

◆ copy_key() [1/2]

std::unique_ptr< Private_Key > Botan::PKCS8::copy_key ( const Private_Key &  key)

Copy an existing encoded key object.

Parameters
keythe key to copy
Returns
new copy of the key

Definition at line 396 of file pkcs8.cpp.

397  {
398  DataSource_Memory source(PEM_encode(key));
399  return PKCS8::load_key(source);
400  }
Private_Key * load_key(DataSource &source, RandomNumberGenerator &rng)
Definition: pkcs8.cpp:427
const uint8_t * key
Definition: ffi.h:359
std::string PEM_encode(const Private_Key &key, RandomNumberGenerator &rng, const std::string &pass, std::chrono::milliseconds msec, const std::string &pbe_algo)
Definition: pkcs8.cpp:230
const botan_hash_t source
Definition: ffi.h:269

References key, load_key(), PEM_encode(), and source.

Referenced by copy_key().

◆ copy_key() [2/2]

Private_Key* Botan::PKCS8::copy_key ( const Private_Key &  key,
RandomNumberGenerator &  rng 
)

Definition at line 475 of file pkcs8.cpp.

477  {
478  BOTAN_UNUSED(rng);
479  return PKCS8::copy_key(key).release();
480  }
botan_rng_t rng
Definition: ffi.h:856
#define BOTAN_UNUSED(...)
Definition: assert.h:142
const uint8_t * key
Definition: ffi.h:359
Private_Key * copy_key(const Private_Key &key, RandomNumberGenerator &rng)
Definition: pkcs8.cpp:475

References BOTAN_UNUSED, copy_key(), key, and rng.

◆ load_key() [1/6]

std::unique_ptr< Private_Key > Botan::PKCS8::load_key ( DataSource &  source,
std::function< std::string()>  get_passphrase 
)

Load an encrypted key from a data source.

Parameters
sourcethe data source providing the encoded key
get_passphrasea function that returns passphrases
Returns
loaded private key object

Definition at line 366 of file pkcs8.cpp.

368  {
369  return load_key(source, get_pass, true);
370  }
Private_Key * load_key(DataSource &source, RandomNumberGenerator &rng)
Definition: pkcs8.cpp:427
const botan_hash_t source
Definition: ffi.h:269

References source.

Referenced by botan_privkey_load(), copy_key(), and load_key().

◆ load_key() [2/6]

std::unique_ptr< Private_Key > Botan::PKCS8::load_key ( DataSource &  source,
const std::string &  pass 
)

Load an encrypted key from a data source.

Parameters
sourcethe data source providing the encoded key
passthe passphrase to decrypt the key
Returns
loaded private key object

Definition at line 375 of file pkcs8.cpp.

377  {
378  return load_key(source, [pass]() { return pass; }, true);
379  }
Private_Key * load_key(DataSource &source, RandomNumberGenerator &rng)
Definition: pkcs8.cpp:427
const botan_hash_t source
Definition: ffi.h:269
RandomNumberGenerator const std::string & pass
Definition: pkcs8.h:198

References load_key(), pass, and source.

◆ load_key() [3/6]

std::unique_ptr< Private_Key > Botan::PKCS8::load_key ( DataSource &  source)

Load an unencrypted key from a data source.

Parameters
sourcethe data source providing the encoded key
Returns
loaded private key object

Definition at line 384 of file pkcs8.cpp.

385  {
386  auto fail_fn = []() -> std::string {
387  throw PKCS8_Exception("Internal error: Attempt to read password for unencrypted key");
388  };
389 
390  return load_key(source, fail_fn, false);
391  }
Private_Key * load_key(DataSource &source, RandomNumberGenerator &rng)
Definition: pkcs8.cpp:427
const botan_hash_t source
Definition: ffi.h:269

References load_key(), and source.

◆ load_key() [4/6]

Private_Key* Botan::PKCS8::load_key ( DataSource &  source,
RandomNumberGenerator &  rng,
std::function< std::string()>  get_pass 
)

Definition at line 405 of file pkcs8.cpp.

408  {
409  BOTAN_UNUSED(rng);
410  return PKCS8::load_key(source, get_pass).release();
411  }
botan_rng_t rng
Definition: ffi.h:856
Private_Key * load_key(DataSource &source, RandomNumberGenerator &rng)
Definition: pkcs8.cpp:427
#define BOTAN_UNUSED(...)
Definition: assert.h:142
const botan_hash_t source
Definition: ffi.h:269

References BOTAN_UNUSED, load_key(), rng, and source.

◆ load_key() [5/6]

Private_Key* Botan::PKCS8::load_key ( DataSource &  source,
RandomNumberGenerator &  rng,
const std::string &  pass 
)

Definition at line 416 of file pkcs8.cpp.

419  {
420  BOTAN_UNUSED(rng);
421  return PKCS8::load_key(source, pass).release();
422  }
botan_rng_t rng
Definition: ffi.h:856
Private_Key * load_key(DataSource &source, RandomNumberGenerator &rng)
Definition: pkcs8.cpp:427
#define BOTAN_UNUSED(...)
Definition: assert.h:142
const botan_hash_t source
Definition: ffi.h:269
RandomNumberGenerator const std::string & pass
Definition: pkcs8.h:198

References BOTAN_UNUSED, load_key(), pass, rng, and source.

◆ load_key() [6/6]

Private_Key* Botan::PKCS8::load_key ( DataSource &  source,
RandomNumberGenerator &  rng 
)

Definition at line 427 of file pkcs8.cpp.

429  {
430  BOTAN_UNUSED(rng);
431  return PKCS8::load_key(source).release();
432  }
botan_rng_t rng
Definition: ffi.h:856
Private_Key * load_key(DataSource &source, RandomNumberGenerator &rng)
Definition: pkcs8.cpp:427
#define BOTAN_UNUSED(...)
Definition: assert.h:142
const botan_hash_t source
Definition: ffi.h:269

References BOTAN_UNUSED, load_key(), rng, and source.

◆ PEM_encode() [1/2]

std::string Botan::PKCS8::PEM_encode ( const Private_Key &  key)

Definition at line 148 of file pkcs8.cpp.

149  {
150  return PEM_Code::encode(PKCS8::BER_encode(key), "PRIVATE KEY");
151  }
std::vector< uint8_t > BER_encode(const Private_Key &key, RandomNumberGenerator &rng, const std::string &pass, std::chrono::milliseconds msec, const std::string &pbe_algo)
Definition: pkcs8.cpp:200
std::string encode(const uint8_t der[], size_t length, const std::string &label, size_t width)
Definition: pem.cpp:43
const uint8_t * key
Definition: ffi.h:359

References BER_encode(), Botan::PEM_Code::encode(), and key.

Referenced by botan_privkey_export(), copy_key(), and PEM_encode().

◆ PEM_encode() [2/2]

std::string Botan::PKCS8::PEM_encode ( const Private_Key &  key,
RandomNumberGenerator &  rng,
const std::string &  pass,
std::chrono::milliseconds  msec,
const std::string &  pbe_algo 
)

Definition at line 230 of file pkcs8.cpp.

235  {
236  if(pass.empty())
237  return PEM_encode(key);
238 
239  return PEM_Code::encode(PKCS8::BER_encode(key, rng, pass, msec, pbe_algo),
240  "ENCRYPTED PRIVATE KEY");
241  }
botan_rng_t rng
Definition: ffi.h:856
std::vector< uint8_t > BER_encode(const Private_Key &key, RandomNumberGenerator &rng, const std::string &pass, std::chrono::milliseconds msec, const std::string &pbe_algo)
Definition: pkcs8.cpp:200
int uint32_t msec
Definition: ffi.h:610
std::string encode(const uint8_t der[], size_t length, const std::string &label, size_t width)
Definition: pem.cpp:43
const uint8_t * key
Definition: ffi.h:359
std::string PEM_encode(const Private_Key &key, RandomNumberGenerator &rng, const std::string &pass, std::chrono::milliseconds msec, const std::string &pbe_algo)
Definition: pkcs8.cpp:230
RandomNumberGenerator const std::string & pass
Definition: pkcs8.h:198

References BER_encode(), Botan::PEM_Code::encode(), key, Botan::msec, pass, PEM_encode(), and rng.

◆ PEM_encode_encrypted_pbkdf_iter()

std::string Botan::PKCS8::PEM_encode_encrypted_pbkdf_iter ( const Private_Key &  key,
RandomNumberGenerator &  rng,
const std::string &  pass,
size_t  pbkdf_iterations,
const std::string &  cipher,
const std::string &  pbkdf_hash 
)

Definition at line 279 of file pkcs8.cpp.

285  {
286  return PEM_Code::encode(
288  "ENCRYPTED PRIVATE KEY");
289  }
std::vector< uint8_t > BER_encode_encrypted_pbkdf_iter(const Private_Key &key, RandomNumberGenerator &rng, const std::string &pass, size_t pbkdf_iterations, const std::string &cipher, const std::string &pbkdf_hash)
Definition: pkcs8.cpp:246
botan_rng_t rng
Definition: ffi.h:856
uint8_t size_t botan_rng_t const char size_t pbkdf_iterations
Definition: ffi.h:1053
std::string encode(const uint8_t der[], size_t length, const std::string &label, size_t width)
Definition: pem.cpp:43
void BlockCipher * cipher
Definition: package.h:29
const uint8_t * key
Definition: ffi.h:359
RandomNumberGenerator const std::string & pass
Definition: pkcs8.h:198

References BER_encode_encrypted_pbkdf_iter(), Botan::cipher, Botan::PEM_Code::encode(), key, pass, pbkdf_iterations, and rng.

Referenced by botan_privkey_export_encrypted_pbkdf_iter().

◆ PEM_encode_encrypted_pbkdf_msec()

std::string Botan::PKCS8::PEM_encode_encrypted_pbkdf_msec ( const Private_Key &  key,
RandomNumberGenerator &  rng,
const std::string &  pass,
std::chrono::milliseconds  pbkdf_msec,
size_t *  pbkdf_iterations,
const std::string &  cipher,
const std::string &  pbkdf_hash 
)

Definition at line 327 of file pkcs8.cpp.

334  {
335  return PEM_Code::encode(
337  "ENCRYPTED PRIVATE KEY");
338  }
botan_rng_t rng
Definition: ffi.h:856
std::vector< uint8_t > BER_encode_encrypted_pbkdf_msec(const Private_Key &key, RandomNumberGenerator &rng, const std::string &pass, std::chrono::milliseconds pbkdf_msec, size_t *pbkdf_iterations, const std::string &cipher, const std::string &pbkdf_hash)
Definition: pkcs8.cpp:294
uint8_t size_t botan_rng_t const char size_t pbkdf_iterations
Definition: ffi.h:1053
std::string encode(const uint8_t der[], size_t length, const std::string &label, size_t width)
Definition: pem.cpp:43
void BlockCipher * cipher
Definition: package.h:29
const uint8_t * key
Definition: ffi.h:359
RandomNumberGenerator const std::string & pass
Definition: pkcs8.h:198

References BER_encode_encrypted_pbkdf_msec(), Botan::cipher, Botan::PEM_Code::encode(), key, pass, pbkdf_iterations, and rng.

Referenced by botan_privkey_export_encrypted_pbkdf_msec().

Variable Documentation

◆ get_passphrase

BOTAN_PUBLIC_API (2,0) std BOTAN_PUBLIC_API (2,0) std BOTAN_PUBLIC_API (2,0) std BOTAN_PUBLIC_API (2,1) std BOTAN_PUBLIC_API (2,1) std BOTAN_PUBLIC_API (2,1) std BOTAN_PUBLIC_API (2,1) std RandomNumberGenerator std::function<std::string ()> Botan::PKCS8::get_passphrase

Definition at line 188 of file pkcs8.h.

◆ pass

RandomNumberGenerator const std::string& Botan::PKCS8::pass

◆ rng

RandomNumberGenerator & Botan::PKCS8::rng