Botan  2.10.0
Crypto and TLS for C++11
exceptn.cpp
Go to the documentation of this file.
1 /*
2 * (C) 2017 Jack Lloyd
3 *
4 * Botan is released under the Simplified BSD License (see license.txt)
5 */
6 
7 #include <botan/exceptn.h>
8 
9 namespace Botan {
10 
11 Exception::Exception(const std::string& msg) : m_msg(msg)
12  {}
13 
14 Exception::Exception(const std::string& msg, const std::exception& e) :
15  m_msg(msg + " failed with " + std::string(e.what()))
16  {}
17 
18 Exception::Exception(const char* prefix, const std::string& msg) :
19  m_msg(std::string(prefix) + " " + msg)
20  {}
21 
22 Invalid_Argument::Invalid_Argument(const std::string& msg) :
23  Exception(msg)
24  {}
25 
26 Invalid_Argument::Invalid_Argument(const std::string& msg, const std::string& where) :
27  Exception(msg + " in " + where)
28  {}
29 
30 Invalid_Argument::Invalid_Argument(const std::string& msg, const std::exception& e) :
31  Exception(msg, e) {}
32 
33 Lookup_Error::Lookup_Error(const std::string& type,
34  const std::string& algo,
35  const std::string& provider) :
36  Exception("Unavailable " + type + " " + algo +
37  (provider.empty() ? std::string("") : (" for provider " + provider)))
38  {}
39 
40 Internal_Error::Internal_Error(const std::string& err) :
41  Exception("Internal error: " + err)
42  {}
43 
44 Invalid_Key_Length::Invalid_Key_Length(const std::string& name, size_t length) :
45  Invalid_Argument(name + " cannot accept a key of length " +
46  std::to_string(length))
47  {}
48 
49 Invalid_IV_Length::Invalid_IV_Length(const std::string& mode, size_t bad_len) :
50  Invalid_Argument("IV length " + std::to_string(bad_len) +
51  " is invalid for " + mode)
52  {}
53 
54 Key_Not_Set::Key_Not_Set(const std::string& algo) :
55  Invalid_State("Key not set in " + algo)
56  {}
57 
58 Policy_Violation::Policy_Violation(const std::string& err) :
59  Invalid_State("Policy violation: " + err) {}
60 
61 PRNG_Unseeded::PRNG_Unseeded(const std::string& algo) :
62  Invalid_State("PRNG not seeded: " + algo)
63  {}
64 
66  Lookup_Error("Could not find any algorithm named \"" + name + "\"")
67  {}
68 
70  Exception("Could not find any provider for algorithm named \"" + name + "\"")
71  {}
72 
73 Provider_Not_Found::Provider_Not_Found(const std::string& algo, const std::string& provider) :
74  Lookup_Error("Could not find provider '" + provider + "' for " + algo)
75  {}
76 
78  Invalid_Argument("Invalid algorithm name: " + name)
79  {}
80 
81 Encoding_Error::Encoding_Error(const std::string& name) :
82  Invalid_Argument("Encoding error: " + name)
83  {}
84 
85 Decoding_Error::Decoding_Error(const std::string& name) :
86  Invalid_Argument(name)
87  {}
88 
89 Decoding_Error::Decoding_Error(const std::string& msg, const std::exception& e) :
90  Invalid_Argument(msg, e)
91  {}
92 
93 Decoding_Error::Decoding_Error(const std::string& name, const char* exception_message) :
94  Invalid_Argument(name + " failed with exception " + exception_message) {}
95 
97  Exception("Invalid authentication tag: " + msg)
98  {}
99 
100 Invalid_OID::Invalid_OID(const std::string& oid) :
101  Decoding_Error("Invalid ASN.1 OID: " + oid)
102  {}
103 
104 Stream_IO_Error::Stream_IO_Error(const std::string& err) :
105  Exception("I/O error: " + err)
106  {}
107 
108 System_Error::System_Error(const std::string& msg, int err_code) :
109  Exception(msg + " error code " + std::to_string(err_code)),
110  m_error_code(err_code)
111  {}
112 
113 Self_Test_Failure::Self_Test_Failure(const std::string& err) :
114  Internal_Error("Self test failed: " + err)
115  {}
116 
117 Not_Implemented::Not_Implemented(const std::string& err) :
118  Exception("Not implemented", err)
119  {}
120 
121 }
Encoding_Error(const std::string &name)
Definition: exceptn.cpp:81
Invalid_Algorithm_Name(const std::string &name)
Definition: exceptn.cpp:77
Exception(const std::string &msg)
Definition: exceptn.cpp:11
Invalid_Argument(const std::string &msg)
Definition: exceptn.cpp:22
Definition: bigint.h:1136
Policy_Violation(const std::string &err)
Definition: exceptn.cpp:58
MechanismType type
Decoding_Error(const std::string &name)
Definition: exceptn.cpp:85
Key_Not_Set(const std::string &algo)
Definition: exceptn.cpp:54
const char * what() const noexcept override
Definition: exceptn.h:89
Not_Implemented(const std::string &err)
Definition: exceptn.cpp:117
Provider_Not_Found(const std::string &algo, const std::string &provider)
Definition: exceptn.cpp:73
std::string name
Stream_IO_Error(const std::string &err)
Definition: exceptn.cpp:104
Algorithm_Not_Found(const std::string &name)
Definition: exceptn.cpp:65
No_Provider_Found(const std::string &name)
Definition: exceptn.cpp:69
Definition: alg_id.cpp:13
PRNG_Unseeded(const std::string &algo)
Definition: exceptn.cpp:61
Invalid_OID(const std::string &oid)
Definition: exceptn.cpp:100
System_Error(const std::string &msg)
Definition: exceptn.h:309
Invalid_Authentication_Tag(const std::string &msg)
Definition: exceptn.cpp:96
Internal_Error(const std::string &err)
Definition: exceptn.cpp:40
Invalid_Key_Length(const std::string &name, size_t length)
Definition: exceptn.cpp:44
std::string to_string(const secure_vector< uint8_t > &bytes)
Definition: stl_util.h:25
Invalid_IV_Length(const std::string &mode, size_t bad_len)
Definition: exceptn.cpp:49
Self_Test_Failure(const std::string &err)
Definition: exceptn.cpp:113
Lookup_Error(const std::string &err)
Definition: exceptn.h:233