diff options
Diffstat (limited to 'src/pubkey')
-rw-r--r-- | src/pubkey/dl_group/dl_group.cpp | 4 | ||||
-rw-r--r-- | src/pubkey/dlies/dlies.cpp | 2 | ||||
-rw-r--r-- | src/pubkey/dsa/dsa.cpp | 2 | ||||
-rw-r--r-- | src/pubkey/ecc_key/ecc_key.cpp | 4 | ||||
-rw-r--r-- | src/pubkey/ecdsa/ecdsa.cpp | 4 | ||||
-rw-r--r-- | src/pubkey/eckaeg/eckaeg.cpp | 8 | ||||
-rw-r--r-- | src/pubkey/pk_codecs/pkcs8.cpp | 2 | ||||
-rw-r--r-- | src/pubkey/pk_codecs/pkcs8.h | 10 | ||||
-rw-r--r-- | src/pubkey/pubkey.cpp | 9 |
9 files changed, 20 insertions, 25 deletions
diff --git a/src/pubkey/dl_group/dl_group.cpp b/src/pubkey/dl_group/dl_group.cpp index 6bb49fa5a..55a83794c 100644 --- a/src/pubkey/dl_group/dl_group.cpp +++ b/src/pubkey/dl_group/dl_group.cpp @@ -193,7 +193,7 @@ const BigInt& DL_Group::get_q() const { init_check(); if(q == 0) - throw Format_Error("DLP group has no q prime specified"); + throw Invalid_State("DLP group has no q prime specified"); return q; } @@ -325,7 +325,7 @@ BigInt DL_Group::make_dsa_generator(const BigInt& p, const BigInt& q) } if(g == 1) - throw Exception("DL_Group: Couldn't create a suitable generator"); + throw Internal_Error("DL_Group: Couldn't create a suitable generator"); return g; } diff --git a/src/pubkey/dlies/dlies.cpp b/src/pubkey/dlies/dlies.cpp index 3a3ab52ee..6ef3292e1 100644 --- a/src/pubkey/dlies/dlies.cpp +++ b/src/pubkey/dlies/dlies.cpp @@ -127,7 +127,7 @@ SecureVector<byte> DLIES_Decryptor::dec(const byte msg[], u32bit length) const mac->update(0); SecureVector<byte> T2 = mac->final(); if(T != T2) - throw Integrity_Failure("DLIES: message authentication failed"); + throw Decoding_Error("DLIES: message authentication failed"); xor_buf(C, K.begin() + mac_keylen, C.size()); diff --git a/src/pubkey/dsa/dsa.cpp b/src/pubkey/dsa/dsa.cpp index b0688ae0d..5be3e1d48 100644 --- a/src/pubkey/dsa/dsa.cpp +++ b/src/pubkey/dsa/dsa.cpp @@ -97,6 +97,8 @@ SecureVector<byte> DSA_PrivateKey::sign(const byte in[], u32bit length, { const BigInt& q = group_q(); + rng.add_entropy(in, length); + BigInt k; do k.randomize(rng, q.bits()); diff --git a/src/pubkey/ecc_key/ecc_key.cpp b/src/pubkey/ecc_key/ecc_key.cpp index 8d9e89f1e..7d3c79868 100644 --- a/src/pubkey/ecc_key/ecc_key.cpp +++ b/src/pubkey/ecc_key/ecc_key.cpp @@ -134,9 +134,9 @@ void EC_PublicKey::set_parameter_encoding(EC_dompar_enc type) m_param_enc = type; } -/******************************** +/* * EC_PrivateKey -********************************/ +*/ void EC_PrivateKey::affirm_init() const // virtual { if(m_private_value == 0) diff --git a/src/pubkey/ecdsa/ecdsa.cpp b/src/pubkey/ecdsa/ecdsa.cpp index ea90010b1..dffd37e6f 100644 --- a/src/pubkey/ecdsa/ecdsa.cpp +++ b/src/pubkey/ecdsa/ecdsa.cpp @@ -155,9 +155,9 @@ u32bit ECDSA_PublicKey::max_input_bits() const return mp_dom_pars->get_order().bits(); } -/************************* +/* * ECDSA_PrivateKey -*************************/ +*/ void ECDSA_PrivateKey::affirm_init() const // virtual { EC_PrivateKey::affirm_init(); diff --git a/src/pubkey/eckaeg/eckaeg.cpp b/src/pubkey/eckaeg/eckaeg.cpp index a2dec5279..15c817fa7 100644 --- a/src/pubkey/eckaeg/eckaeg.cpp +++ b/src/pubkey/eckaeg/eckaeg.cpp @@ -16,9 +16,9 @@ namespace Botan { -/********************************* +/* * ECKAEG_PublicKey -*********************************/ +*/ void ECKAEG_PublicKey::affirm_init() const // virtual { @@ -72,9 +72,9 @@ ECKAEG_PublicKey::ECKAEG_PublicKey(EC_Domain_Params const& dom_par, PointGFp con m_eckaeg_core = ECKAEG_Core(*mp_dom_pars, BigInt(0), *mp_public_point); } -/********************************* +/* * ECKAEG_PrivateKey -*********************************/ +*/ void ECKAEG_PrivateKey::affirm_init() const // virtual { EC_PrivateKey::affirm_init(); diff --git a/src/pubkey/pk_codecs/pkcs8.cpp b/src/pubkey/pk_codecs/pkcs8.cpp index 6cbdabac0..830f3a10d 100644 --- a/src/pubkey/pk_codecs/pkcs8.cpp +++ b/src/pubkey/pk_codecs/pkcs8.cpp @@ -168,7 +168,7 @@ void encrypt_key(const Private_Key& key, const std::string& pass, const std::string& pbe_algo, X509_Encoding encoding) { - const std::string DEFAULT_PBE = "PBE-PKCS5v20(SHA-1,TripleDES/CBC)"; + const std::string DEFAULT_PBE = "PBE-PKCS5v20(SHA-1,AES-128/CBC)"; Pipe raw_key; raw_key.start_msg(); diff --git a/src/pubkey/pk_codecs/pkcs8.h b/src/pubkey/pk_codecs/pkcs8.h index 28008bdba..adfad0e63 100644 --- a/src/pubkey/pk_codecs/pkcs8.h +++ b/src/pubkey/pk_codecs/pkcs8.h @@ -82,9 +82,8 @@ BOTAN_DLL void encode(const Private_Key& key, Pipe& pipe, * @param pipe the pipe to feed the encoded key into * @param pass the password to use for encryption * @param rng the rng to use -* @param pbe_algo the name of the desired password-based encryption algorithm. -* Provide an empty string to use the default PBE defined in the configuration -* under base/default_pbe. +* @param pbe_algo the name of the desired password-based encryption algorithm; + if empty ("") a reasonable (portable/secure) default will be chosen. * @param enc the encoding type to use */ BOTAN_DLL void encrypt_key(const Private_Key& key, @@ -108,9 +107,8 @@ BOTAN_DLL std::string PEM_encode(const Private_Key& key); * @param key the key to encode * @param rng the rng to use * @param pass the password to use for encryption -* @param pbe_algo the name of the desired password-based encryption algorithm. -* Provide an empty string to use the default PBE defined in the configuration -* under base/default_pbe. +* @param pbe_algo the name of the desired password-based encryption algorithm; + if empty ("") a reasonable (portable/secure) default will be chosen. */ BOTAN_DLL std::string PEM_encode(const Private_Key& key, RandomNumberGenerator& rng, diff --git a/src/pubkey/pubkey.cpp b/src/pubkey/pubkey.cpp index a6e424e05..69002207f 100644 --- a/src/pubkey/pubkey.cpp +++ b/src/pubkey/pubkey.cpp @@ -73,7 +73,7 @@ PK_Encryptor_MR_with_EME::enc(const byte msg[], message.set(msg, length); if(8*(message.size() - 1) + high_bit(message[0]) > key.max_input_bits()) - throw Exception("PK_Encryptor_MR_with_EME: Input is too large"); + throw Invalid_Argument("PK_Encryptor_MR_with_EME: Input is too large"); return key.encrypt(message, message.size(), rng); } @@ -113,11 +113,7 @@ SecureVector<byte> PK_Decryptor_MR_with_EME::dec(const byte msg[], } catch(Invalid_Argument) { - throw Exception("PK_Decryptor_MR_with_EME: Input is invalid"); - } - catch(Decoding_Error) - { - throw Exception("PK_Decryptor_MR_with_EME: Input is invalid"); + throw Decoding_Error("PK_Decryptor_MR_with_EME: Input is invalid"); } } @@ -331,7 +327,6 @@ bool PK_Verifier::check_signature(const byte sig[], u32bit length) std::to_string(sig_format)); } catch(Invalid_Argument) { return false; } - catch(Decoding_Error) { return false; } } /* |