diff options
author | lloyd <[email protected]> | 2010-02-24 02:18:55 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-02-24 02:18:55 +0000 |
commit | 6e50979c8d2a0635599228a2ae1a20d59b24a0c6 (patch) | |
tree | 587aaf6c20d45a6fa81ee180ca0aa533f51403d1 /src/pubkey | |
parent | 888fc3d0f2f6f1dc5e9764e83e9b7fd64da916d8 (diff) | |
parent | 8c951ef2f1e54e1134e8db683662ec881df89c88 (diff) |
propagate from branch 'net.randombit.botan' (head 84baf58b29f3aaaee34e2b873d0040be5a6c4368)
to branch 'net.randombit.botan.gost_3410' (head 63cbe3e357c071d7960bfedc31101eff35895285)
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/ec_dompar/ec_dompar.cpp | 8 | ||||
-rw-r--r-- | src/pubkey/ecc_key/ecc_key.cpp | 4 | ||||
-rw-r--r-- | src/pubkey/ecc_key/ecc_key.h | 1 | ||||
-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 |
11 files changed, 24 insertions, 30 deletions
diff --git a/src/pubkey/dl_group/dl_group.cpp b/src/pubkey/dl_group/dl_group.cpp index a2e239783..7940e69b2 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/ec_dompar/ec_dompar.cpp b/src/pubkey/ec_dompar/ec_dompar.cpp index 6c688f34e..3719153f0 100644 --- a/src/pubkey/ec_dompar/ec_dompar.cpp +++ b/src/pubkey/ec_dompar/ec_dompar.cpp @@ -564,18 +564,16 @@ EC_Domain_Params decode_ber_ec_dompar(SecureVector<byte> const& encoded) { BER_Decoder dec(encoded); BER_Object obj = dec.get_next_object(); - ASN1_Tag tag = obj.type_tag; - std::auto_ptr<EC_Domain_Params> p_result; - if(tag == OBJECT_ID) + if(obj.type_tag == OBJECT_ID) { OID dom_par_oid; BER_Decoder(encoded).decode(dom_par_oid); return EC_Domain_Params(get_ec_dompar(dom_par_oid.as_string())); } - else if(tag == SEQUENCE) + else if(obj.type_tag == SEQUENCE) return EC_Domain_Params(decode_ber_ec_dompar_explicit(encoded)); - else if(tag == NULL_TAG) + else if(obj.type_tag == NULL_TAG) throw Decoding_Error("cannot decode ECDSA parameters that are ImplicitCA"); throw Decoding_Error("encountered unexpected when trying to decode domain parameters"); diff --git a/src/pubkey/ecc_key/ecc_key.cpp b/src/pubkey/ecc_key/ecc_key.cpp index 677a5088e..b7f58eecc 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/ecc_key/ecc_key.h b/src/pubkey/ecc_key/ecc_key.h index 0ca9a0e75..c1a227bf2 100644 --- a/src/pubkey/ecc_key/ecc_key.h +++ b/src/pubkey/ecc_key/ecc_key.h @@ -16,6 +16,7 @@ #include <botan/ec_dompar.h> #include <botan/x509_key.h> #include <botan/pkcs8.h> +#include <memory> namespace Botan { diff --git a/src/pubkey/ecdsa/ecdsa.cpp b/src/pubkey/ecdsa/ecdsa.cpp index 9d352c70f..6116f7b13 100644 --- a/src/pubkey/ecdsa/ecdsa.cpp +++ b/src/pubkey/ecdsa/ecdsa.cpp @@ -156,9 +156,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 dc6eb925b..3e0f717e0 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 f287e1e63..d0954df39 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 44e31159c..dc0a505f5 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) to_string(sig_format)); } catch(Invalid_Argument) { return false; } - catch(Decoding_Error) { return false; } } /* |