diff options
Diffstat (limited to 'src/pbe')
-rw-r--r-- | src/pbe/get_pbe.h | 9 | ||||
-rw-r--r-- | src/pbe/pbes1/pbes1.cpp | 2 | ||||
-rw-r--r-- | src/pbe/pbes1/pbes1.h | 11 | ||||
-rw-r--r-- | src/pbe/pbes2/pbes2.cpp | 30 | ||||
-rw-r--r-- | src/pbe/pbes2/pbes2.h | 23 |
5 files changed, 47 insertions, 28 deletions
diff --git a/src/pbe/get_pbe.h b/src/pbe/get_pbe.h index 04eda6696..73c53497c 100644 --- a/src/pbe/get_pbe.h +++ b/src/pbe/get_pbe.h @@ -16,17 +16,18 @@ namespace Botan { /** * Factory function for PBEs. * @param algo_spec the name of the PBE algorithm to retrieve -* @return a pointer to a PBE with randomly created parameters +* @return pointer to a PBE with randomly created parameters */ -BOTAN_DLL PBE* get_pbe(const std::string&); +BOTAN_DLL PBE* get_pbe(const std::string& algo_spec); /** * Factory function for PBEs. * @param pbe_oid the oid of the desired PBE * @param params a DataSource providing the DER encoded parameters to use -* @return a pointer to the PBE with the specified parameters +* @return pointer to the PBE with the specified parameters */ -BOTAN_DLL PBE* get_pbe(const OID&, DataSource&); +BOTAN_DLL PBE* get_pbe(const OID& pbe_oid, + DataSource& params); } diff --git a/src/pbe/pbes1/pbes1.cpp b/src/pbe/pbes1/pbes1.cpp index 36cfaa6b4..a3e08d679 100644 --- a/src/pbe/pbes1/pbes1.cpp +++ b/src/pbe/pbes1/pbes1.cpp @@ -93,7 +93,7 @@ void PBE_PKCS5v15::set_key(const std::string& passphrase) */ void PBE_PKCS5v15::new_params(RandomNumberGenerator& rng) { - iterations = 2048; + iterations = 10000; salt.resize(8); rng.randomize(salt, salt.size()); } diff --git a/src/pbe/pbes1/pbes1.h b/src/pbe/pbes1/pbes1.h index 2e1855dc2..d50c01f53 100644 --- a/src/pbe/pbes1/pbes1.h +++ b/src/pbe/pbes1/pbes1.h @@ -15,8 +15,8 @@ namespace Botan { -/* -* PKCS#5 v1.5 PBE +/** +* PKCS #5 v1.5 PBE */ class BOTAN_DLL PBE_PKCS5v15 : public PBE { @@ -25,9 +25,14 @@ class BOTAN_DLL PBE_PKCS5v15 : public PBE void start_msg(); void end_msg(); + /** + * @param cipher the block cipher to use (DES or RC2) + * @param hash the hash function to use + * @param direction are we encrypting or decrypting + */ PBE_PKCS5v15(BlockCipher* cipher, HashFunction* hash, - Cipher_Dir); + Cipher_Dir direction); ~PBE_PKCS5v15(); private: diff --git a/src/pbe/pbes2/pbes2.cpp b/src/pbe/pbes2/pbes2.cpp index 63772263f..1ac16af8d 100644 --- a/src/pbe/pbes2/pbes2.cpp +++ b/src/pbe/pbes2/pbes2.cpp @@ -1,4 +1,4 @@ -/** +/* * PKCS #5 PBES2 * (C) 1999-2008 Jack Lloyd * @@ -21,7 +21,7 @@ namespace Botan { -/** +/* * Encrypt some bytes using PBES2 */ void PBE_PKCS5v20::write(const byte input[], u32bit length) @@ -35,7 +35,7 @@ void PBE_PKCS5v20::write(const byte input[], u32bit length) } } -/** +/* * Start encrypting with PBES2 */ void PBE_PKCS5v20::start_msg() @@ -54,7 +54,7 @@ void PBE_PKCS5v20::start_msg() pipe.set_default_msg(pipe.default_msg() + 1); } -/** +/* * Finish encrypting with PBES2 */ void PBE_PKCS5v20::end_msg() @@ -64,7 +64,7 @@ void PBE_PKCS5v20::end_msg() pipe.reset(); } -/** +/* * Flush the pipe */ void PBE_PKCS5v20::flush_pipe(bool safe_to_skip) @@ -80,7 +80,7 @@ void PBE_PKCS5v20::flush_pipe(bool safe_to_skip) } } -/** +/* * Set the passphrase to use */ void PBE_PKCS5v20::set_key(const std::string& passphrase) @@ -92,22 +92,22 @@ void PBE_PKCS5v20::set_key(const std::string& passphrase) iterations).bits_of(); } -/** +/* * Create a new set of PBES2 parameters */ void PBE_PKCS5v20::new_params(RandomNumberGenerator& rng) { - iterations = 2048; + iterations = 10000; key_length = block_cipher->MAXIMUM_KEYLENGTH; - salt.resize(8); + salt.resize(12); rng.randomize(salt, salt.size()); iv.resize(block_cipher->BLOCK_SIZE); rng.randomize(iv, iv.size()); } -/** +/* * Encode PKCS#5 PBES2 parameters */ MemoryVector<byte> PBE_PKCS5v20::encode_params() const @@ -136,7 +136,7 @@ MemoryVector<byte> PBE_PKCS5v20::encode_params() const .get_contents(); } -/** +/* * Decode PKCS#5 PBES2 parameters */ void PBE_PKCS5v20::decode_params(DataSource& source) @@ -187,7 +187,7 @@ void PBE_PKCS5v20::decode_params(DataSource& source) throw Decoding_Error("PBE-PKCS5 v2.0: Encoded salt is too small"); } -/** +/* * Return an OID for PBES2 */ OID PBE_PKCS5v20::get_oid() const @@ -195,7 +195,7 @@ OID PBE_PKCS5v20::get_oid() const return OIDS::lookup("PBE-PKCS5v20"); } -/** +/* * Check if this is a known PBES2 cipher */ bool PBE_PKCS5v20::known_cipher(const std::string& algo) @@ -207,7 +207,7 @@ bool PBE_PKCS5v20::known_cipher(const std::string& algo) return false; } -/** +/* * PKCS#5 v2.0 PBE Constructor */ PBE_PKCS5v20::PBE_PKCS5v20(BlockCipher* cipher, @@ -220,7 +220,7 @@ PBE_PKCS5v20::PBE_PKCS5v20(BlockCipher* cipher, throw Invalid_Argument("PBE-PKCS5 v2.0: Invalid digest " + digest->name()); } -/** +/* * PKCS#5 v2.0 PBE Constructor */ PBE_PKCS5v20::PBE_PKCS5v20(DataSource& params) : direction(DECRYPTION) diff --git a/src/pbe/pbes2/pbes2.h b/src/pbe/pbes2/pbes2.h index fc460a228..f24d572d0 100644 --- a/src/pbe/pbes2/pbes2.h +++ b/src/pbe/pbes2/pbes2.h @@ -15,20 +15,33 @@ namespace Botan { -/* -* PKCS#5 v2.0 PBE +/** +* PKCS #5 v2.0 PBE */ class BOTAN_DLL PBE_PKCS5v20 : public PBE { public: - static bool known_cipher(const std::string&); + /** + * @param cipher names a block cipher + * @return true iff PKCS #5 knows how to use this cipher + */ + static bool known_cipher(const std::string& cipher); void write(const byte[], u32bit); void start_msg(); void end_msg(); - PBE_PKCS5v20(DataSource&); - PBE_PKCS5v20(BlockCipher*, HashFunction*); + /** + * Load a PKCS #5 v2.0 encrypted stream + * @param input is the input source + */ + PBE_PKCS5v20(DataSource& input); + + /** + * @param cipher the block cipher to use + * @param hash the hash function to use + */ + PBE_PKCS5v20(BlockCipher* cipher, HashFunction* hash); ~PBE_PKCS5v20(); private: |