Botan  2.4.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 char* prefix, const std::string& msg) :
15  m_msg(std::string(prefix) + " " + msg)
16  {}
17 
18 Invalid_Argument::Invalid_Argument(const std::string& msg) :
19  Exception("Invalid argument", msg)
20  {}
21 
22 Invalid_Argument::Invalid_Argument(const std::string& msg, const std::string& where) :
23  Exception("Invalid argument", msg + " in " + where)
24  {}
25 
26 Lookup_Error::Lookup_Error(const std::string& type,
27  const std::string& algo,
28  const std::string& provider) :
29  Exception("Unavailable " + type + " " + algo +
30  (provider.empty() ? std::string("") : (" for provider " + provider)))
31  {}
32 
33 Internal_Error::Internal_Error(const std::string& err) :
34  Exception("Internal error: " + err)
35  {}
36 
37 Invalid_Key_Length::Invalid_Key_Length(const std::string& name, size_t length) :
38  Invalid_Argument(name + " cannot accept a key of length " +
39  std::to_string(length))
40  {}
41 
42 Invalid_IV_Length::Invalid_IV_Length(const std::string& mode, size_t bad_len) :
43  Invalid_Argument("IV length " + std::to_string(bad_len) +
44  " is invalid for " + mode)
45  {}
46 
47 Key_Not_Set::Key_Not_Set(const std::string& algo) :
48  Invalid_State("Key not set in " + algo)
49  {}
50 
51 Policy_Violation::Policy_Violation(const std::string& err) :
52  Invalid_State("Policy violation: " + err) {}
53 
54 PRNG_Unseeded::PRNG_Unseeded(const std::string& algo) :
55  Invalid_State("PRNG not seeded: " + algo)
56  {}
57 
58 Algorithm_Not_Found::Algorithm_Not_Found(const std::string& name) :
59  Lookup_Error("Could not find any algorithm named \"" + name + "\"")
60  {}
61 
62 No_Provider_Found::No_Provider_Found(const std::string& name) :
63  Exception("Could not find any provider for algorithm named \"" + name + "\"")
64  {}
65 
66 Provider_Not_Found::Provider_Not_Found(const std::string& algo, const std::string& provider) :
67  Lookup_Error("Could not find provider '" + provider + "' for " + algo)
68  {}
69 
71  Invalid_Argument("Invalid algorithm name: " + name)
72  {}
73 
74 Encoding_Error::Encoding_Error(const std::string& name) :
75  Invalid_Argument("Encoding error: " + name)
76  {}
77 
78 Decoding_Error::Decoding_Error(const std::string& name) :
79  Invalid_Argument("Decoding error: " + name)
80  {}
81 
82 Decoding_Error::Decoding_Error(const std::string& name, const char* exception_message) :
83  Invalid_Argument("Decoding error: " + name + " failed with exception " + exception_message) {}
84 
85 Integrity_Failure::Integrity_Failure(const std::string& msg) :
86  Exception("Integrity failure: " + msg)
87  {}
88 
89 Invalid_OID::Invalid_OID(const std::string& oid) :
90  Decoding_Error("Invalid ASN.1 OID: " + oid)
91  {}
92 
93 Stream_IO_Error::Stream_IO_Error(const std::string& err) :
94  Exception("I/O error: " + err)
95  {}
96 
97 Self_Test_Failure::Self_Test_Failure(const std::string& err) :
98  Internal_Error("Self test failed: " + err)
99  {}
100 
101 Not_Implemented::Not_Implemented(const std::string& err) :
102  Exception("Not implemented", err)
103  {}
104 
105 }
Encoding_Error(const std::string &name)
Definition: exceptn.cpp:74
Invalid_Algorithm_Name(const std::string &name)
Definition: exceptn.cpp:70
Invalid_Argument(const std::string &msg)
Definition: exceptn.cpp:18
Integrity_Failure(const std::string &msg)
Definition: exceptn.cpp:85
Definition: bigint.h:635
Exception(const char *prefix, const std::string &msg)
Definition: exceptn.cpp:14
Policy_Violation(const std::string &err)
Definition: exceptn.cpp:51
MechanismType type
Decoding_Error(const std::string &name)
Definition: exceptn.cpp:78
Key_Not_Set(const std::string &algo)
Definition: exceptn.cpp:47
Not_Implemented(const std::string &err)
Definition: exceptn.cpp:101
Provider_Not_Found(const std::string &algo, const std::string &provider)
Definition: exceptn.cpp:66
Stream_IO_Error(const std::string &err)
Definition: exceptn.cpp:93
Algorithm_Not_Found(const std::string &name)
Definition: exceptn.cpp:58
No_Provider_Found(const std::string &name)
Definition: exceptn.cpp:62
Definition: alg_id.cpp:13
PRNG_Unseeded(const std::string &algo)
Definition: exceptn.cpp:54
Invalid_OID(const std::string &oid)
Definition: exceptn.cpp:89
Internal_Error(const std::string &err)
Definition: exceptn.cpp:33
Invalid_Key_Length(const std::string &name, size_t length)
Definition: exceptn.cpp:37
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:42
Self_Test_Failure(const std::string &err)
Definition: exceptn.cpp:97
Lookup_Error(const std::string &err)
Definition: exceptn.h:77