diff options
Diffstat (limited to 'src/lib/pubkey')
-rw-r--r-- | src/lib/pubkey/blinding.cpp | 4 | ||||
-rw-r--r-- | src/lib/pubkey/ec_group/point_gfp.h | 17 | ||||
-rw-r--r-- | src/lib/pubkey/mce/gf2m_small_m.cpp | 4 | ||||
-rw-r--r-- | src/lib/pubkey/mceies/mceies.cpp | 4 | ||||
-rw-r--r-- | src/lib/pubkey/pk_ops_impl.h | 4 | ||||
-rw-r--r-- | src/lib/pubkey/pkcs8.cpp | 13 | ||||
-rw-r--r-- | src/lib/pubkey/xmss/xmss_parameters.cpp | 3 | ||||
-rw-r--r-- | src/lib/pubkey/xmss/xmss_wots_parameters.cpp | 3 |
8 files changed, 28 insertions, 24 deletions
diff --git a/src/lib/pubkey/blinding.cpp b/src/lib/pubkey/blinding.cpp index ecd420780..d1f299229 100644 --- a/src/lib/pubkey/blinding.cpp +++ b/src/lib/pubkey/blinding.cpp @@ -35,7 +35,7 @@ BigInt Blinder::blinding_nonce() const BigInt Blinder::blind(const BigInt& i) const { if(!m_reducer.initialized()) - throw Exception("Blinder not initialized, cannot blind"); + throw Invalid_State("Blinder not initialized, cannot blind"); ++m_counter; @@ -58,7 +58,7 @@ BigInt Blinder::blind(const BigInt& i) const BigInt Blinder::unblind(const BigInt& i) const { if(!m_reducer.initialized()) - throw Exception("Blinder not initialized, cannot unblind"); + throw Invalid_State("Blinder not initialized, cannot unblind"); return m_reducer.multiply(i, m_d); } diff --git a/src/lib/pubkey/ec_group/point_gfp.h b/src/lib/pubkey/ec_group/point_gfp.h index fa447bf87..222b5f474 100644 --- a/src/lib/pubkey/ec_group/point_gfp.h +++ b/src/lib/pubkey/ec_group/point_gfp.h @@ -19,23 +19,26 @@ namespace Botan { /** * Exception thrown if you try to convert a zero point to an affine * coordinate +* +* In a future major release this exception type will be removed and its +* usage replaced by Invalid_State */ -class BOTAN_PUBLIC_API(2,0) Illegal_Transformation final : public Exception +class BOTAN_PUBLIC_API(2,0) Illegal_Transformation final : public Invalid_State { public: - explicit Illegal_Transformation(const std::string& err = - "Requested transformation is not possible") : - Exception(err) {} + explicit Illegal_Transformation(const std::string& err) : Invalid_State(err) {} }; /** * Exception thrown if some form of illegal point is decoded +* +* In a future major release this exception type will be removed and its +* usage replaced by Decoding_Error */ -class BOTAN_PUBLIC_API(2,0) Illegal_Point final : public Exception +class BOTAN_PUBLIC_API(2,0) Illegal_Point final : public Decoding_Error { public: - explicit Illegal_Point(const std::string& err = "Malformed ECP point detected") : - Exception(err) {} + explicit Illegal_Point(const std::string& err) : Decoding_Error(err) {} }; /** diff --git a/src/lib/pubkey/mce/gf2m_small_m.cpp b/src/lib/pubkey/mce/gf2m_small_m.cpp index 95187c7af..8a2632b10 100644 --- a/src/lib/pubkey/mce/gf2m_small_m.cpp +++ b/src/lib/pubkey/mce/gf2m_small_m.cpp @@ -59,7 +59,7 @@ const std::vector<gf2m>& exp_table(size_t deg) static std::vector<gf2m> tabs[MAX_EXT_DEG + 1]; if(deg < 2 || deg > MAX_EXT_DEG) - throw Exception("GF2m_Field does not support degree " + std::to_string(deg)); + throw Invalid_Argument("GF2m_Field does not support degree " + std::to_string(deg)); if(tabs[deg].empty()) tabs[deg] = gf_exp_table(deg, prim_poly[deg]); @@ -84,7 +84,7 @@ const std::vector<gf2m>& log_table(size_t deg) static std::vector<gf2m> tabs[MAX_EXT_DEG + 1]; if(deg < 2 || deg > MAX_EXT_DEG) - throw Exception("GF2m_Field does not support degree " + std::to_string(deg)); + throw Invalid_Argument("GF2m_Field does not support degree " + std::to_string(deg)); if(tabs[deg].empty()) tabs[deg] = gf_log_table(deg, exp_table(deg)); diff --git a/src/lib/pubkey/mceies/mceies.cpp b/src/lib/pubkey/mceies/mceies.cpp index 15706d430..875c9dd10 100644 --- a/src/lib/pubkey/mceies/mceies.cpp +++ b/src/lib/pubkey/mceies/mceies.cpp @@ -83,7 +83,7 @@ mceies_decrypt(const McEliece_PrivateKey& privkey, const size_t nonce_len = aead->default_nonce_length(); if(ct_len < mce_code_bytes + nonce_len + aead->tag_size()) - throw Exception("Input message too small to be valid"); + throw Decoding_Error("Input message too small to be valid"); const secure_vector<uint8_t> mce_key = kem_op.decrypt(ct, mce_code_bytes, 64); @@ -102,7 +102,7 @@ mceies_decrypt(const McEliece_PrivateKey& privkey, } catch(std::exception& e) { - throw Exception("mce_decrypt failed: " + std::string(e.what())); + throw Decoding_Error("mce_decrypt failed: " + std::string(e.what())); } } diff --git a/src/lib/pubkey/pk_ops_impl.h b/src/lib/pubkey/pk_ops_impl.h index 1878a7417..6bab2143e 100644 --- a/src/lib/pubkey/pk_ops_impl.h +++ b/src/lib/pubkey/pk_ops_impl.h @@ -82,7 +82,7 @@ class Verification_with_EMSA : public Verification * @return the message prefix if this signature scheme uses * a message prefix, signaled via has_prefix() */ - virtual secure_vector<uint8_t> message_prefix() const { throw Exception( "No prefix" ); } + virtual secure_vector<uint8_t> message_prefix() const { throw Invalid_State("No prefix"); } /** * @return boolean specifying if this key type supports message @@ -146,7 +146,7 @@ class Signature_with_EMSA : public Signature * @return the message prefix if this signature scheme uses * a message prefix, signaled via has_prefix() */ - virtual secure_vector<uint8_t> message_prefix() const { throw Exception( "No prefix" ); } + virtual secure_vector<uint8_t> message_prefix() const { throw Invalid_State("No prefix"); } std::unique_ptr<EMSA> clone_emsa() const { return std::unique_ptr<EMSA>(m_emsa->clone()); } diff --git a/src/lib/pubkey/pkcs8.cpp b/src/lib/pubkey/pkcs8.cpp index f6d50256d..d299a98a4 100644 --- a/src/lib/pubkey/pkcs8.cpp +++ b/src/lib/pubkey/pkcs8.cpp @@ -105,7 +105,7 @@ secure_vector<uint8_t> PKCS8_decode( if(is_encrypted) { if(OIDS::lookup(pbe_alg_id.get_oid()) != "PBE-PKCS5v20") - throw Exception("Unknown PBE type " + pbe_alg_id.get_oid().as_string()); + throw PKCS8_Exception("Unknown PBE type " + pbe_alg_id.get_oid().as_string()); #if defined(BOTAN_HAS_PKCS5_PBES2) key = pbes2_decrypt(key_data, get_passphrase(), pbe_alg_id.get_parameters()); #else @@ -167,10 +167,13 @@ choose_pbe_params(const std::string& pbe_algo, const std::string& key_algo) } SCAN_Name request(pbe_algo); - if(request.arg_count() != 2) - throw Exception("Unsupported PBE " + pbe_algo); - if(request.algo_name() != "PBE-PKCS5v20" && request.algo_name() != "PBES2") - throw Exception("Unsupported PBE " + pbe_algo); + + if(request.arg_count() != 2 || + (request.algo_name() != "PBE-PKCS5v20" && request.algo_name() != "PBES2")) + { + throw Invalid_Argument("Unsupported PBE " + pbe_algo); + } + return std::make_pair(request.arg(0), request.arg(1)); } diff --git a/src/lib/pubkey/xmss/xmss_parameters.cpp b/src/lib/pubkey/xmss/xmss_parameters.cpp index 288b50fdc..b67e5694e 100644 --- a/src/lib/pubkey/xmss/xmss_parameters.cpp +++ b/src/lib/pubkey/xmss/xmss_parameters.cpp @@ -177,8 +177,7 @@ XMSS_Parameters::XMSS_Parameters(xmss_algorithm_t oid) m_wots_oid = XMSS_WOTS_Parameters::ots_algorithm_t::WOTSP_SHAKE256_W16; break; default: - throw Unsupported_Argument( - "Algorithm id does not match any XMSS algorithm id."); + throw Not_Implemented("Algorithm id does not match any known XMSS algorithm id."); break; } } diff --git a/src/lib/pubkey/xmss/xmss_wots_parameters.cpp b/src/lib/pubkey/xmss/xmss_wots_parameters.cpp index 7ba3dad58..c2a324475 100644 --- a/src/lib/pubkey/xmss/xmss_wots_parameters.cpp +++ b/src/lib/pubkey/xmss/xmss_wots_parameters.cpp @@ -75,8 +75,7 @@ XMSS_WOTS_Parameters::XMSS_WOTS_Parameters(ots_algorithm_t oid) m_strength = 512; break; default: - throw Unsupported_Argument( - "Algorithm id does not match any XMSS WOTS algorithm id."); + throw Not_Implemented("Algorithm id does not match any known XMSS WOTS algorithm id."); break; } |