Botan 2.13.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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 std::string to_string(ErrorType type)
12 {
13 switch(type)
14 {
15 case ErrorType::Unknown:
16 return "Unknown";
17 case ErrorType::SystemError:
18 return "SystemError";
19 case ErrorType::NotImplemented:
20 return "NotImplemented";
21 case ErrorType::OutOfMemory:
22 return "OutOfMemory";
23 case ErrorType::InternalError:
24 return "InternalError";
25 case ErrorType::IoError:
26 return "IoError";
27 case ErrorType::InvalidObjectState :
28 return "InvalidObjectState";
29 case ErrorType::KeyNotSet:
30 return "KeyNotSet";
31 case ErrorType::InvalidArgument:
32 return "InvalidArgument";
33 case ErrorType::InvalidKeyLength:
34 return "InvalidKeyLength";
35 case ErrorType::InvalidNonceLength:
36 return "InvalidNonceLength";
37 case ErrorType::LookupError:
38 return "LookupError";
39 case ErrorType::EncodingFailure:
40 return "EncodingFailure";
41 case ErrorType::DecodingFailure:
42 return "DecodingFailure";
43 case ErrorType::TLSError:
44 return "TLSError";
45 case ErrorType::HttpError:
46 return "HttpError";
47 case ErrorType::InvalidTag:
48 return "InvalidTag";
49 case ErrorType::RoughtimeError:
50 return "RoughtimeError";
51 case ErrorType::OpenSSLError :
52 return "OpenSSLError";
53 case ErrorType::CommonCryptoError:
54 return "CommonCryptoError";
55 case ErrorType::Pkcs11Error:
56 return "Pkcs11Error";
57 case ErrorType::TPMError:
58 return "TPMError";
59 case ErrorType::DatabaseError:
60 return "DatabaseError";
61 case ErrorType::ZlibError :
62 return "ZlibError";
63 case ErrorType::Bzip2Error:
64 return "Bzip2Error" ;
65 case ErrorType::LzmaError:
66 return "LzmaError";
67 }
68
69 // No default case in above switch so compiler warns
70 return "Unrecognized Botan error";
71 }
72
73 Exception::Exception(const std::string& msg) : m_msg(msg)
74 {}
75
76 Exception::Exception(const std::string& msg, const std::exception& e) :
77 m_msg(msg + " failed with " + std::string(e.what()))
78 {}
79
80 Exception::Exception(const char* prefix, const std::string& msg) :
81 m_msg(std::string(prefix) + " " + msg)
82 {}
83
84 Invalid_Argument::Invalid_Argument(const std::string& msg) :
85 Exception(msg)
86 {}
87
88 Invalid_Argument::Invalid_Argument(const std::string& msg, const std::string& where) :
89 Exception(msg + " in " + where)
90 {}
91
92 Invalid_Argument::Invalid_Argument(const std::string& msg, const std::exception& e) :
93 Exception(msg, e) {}
94
95 Lookup_Error::Lookup_Error(const std::string& type,
96 const std::string& algo,
97 const std::string& provider) :
98 Exception("Unavailable " + type + " " + algo +
99 (provider.empty() ? std::string("") : (" for provider " + provider)))
100 {}
101
102 Internal_Error::Internal_Error(const std::string& err) :
103 Exception("Internal error: " + err)
104 {}
105
106 Invalid_Key_Length::Invalid_Key_Length(const std::string& name, size_t length) :
107 Invalid_Argument(name + " cannot accept a key of length " +
108 std::to_string(length))
109 {}
110
111 Invalid_IV_Length::Invalid_IV_Length(const std::string& mode, size_t bad_len) :
112 Invalid_Argument("IV length " + std::to_string(bad_len) +
113 " is invalid for " + mode)
114 {}
115
116 Key_Not_Set::Key_Not_Set(const std::string& algo) :
117 Invalid_State("Key not set in " + algo)
118 {}
119
120 Policy_Violation::Policy_Violation(const std::string& err) :
121 Invalid_State("Policy violation: " + err) {}
122
123 PRNG_Unseeded::PRNG_Unseeded(const std::string& algo) :
124 Invalid_State("PRNG not seeded: " + algo)
125 {}
126
127 Algorithm_Not_Found::Algorithm_Not_Found(const std::string& name) :
128 Lookup_Error("Could not find any algorithm named \"" + name + "\"")
129 {}
130
131 No_Provider_Found::No_Provider_Found(const std::string& name) :
132 Exception("Could not find any provider for algorithm named \"" + name + "\"")
133 {}
134
135 Provider_Not_Found::Provider_Not_Found(const std::string& algo, const std::string& provider) :
136 Lookup_Error("Could not find provider '" + provider + "' for " + algo)
137 {}
138
139 Invalid_Algorithm_Name::Invalid_Algorithm_Name(const std::string& name):
140 Invalid_Argument("Invalid algorithm name: " + name)
141 {}
142
143 Encoding_Error::Encoding_Error(const std::string& name) :
144 Invalid_Argument("Encoding error: " + name)
145 {}
146
147 Decoding_Error::Decoding_Error(const std::string& name) :
148 Invalid_Argument(name)
149 {}
150
151 Decoding_Error::Decoding_Error(const std::string& msg, const std::exception& e) :
152 Invalid_Argument(msg, e)
153 {}
154
155 Decoding_Error::Decoding_Error(const std::string& name, const char* exception_message) :
156 Invalid_Argument(name + " failed with exception " + exception_message) {}
157
158 Invalid_Authentication_Tag::Invalid_Authentication_Tag(const std::string& msg) :
159 Exception("Invalid authentication tag: " + msg)
160 {}
161
162 Invalid_OID::Invalid_OID(const std::string& oid) :
163 Decoding_Error("Invalid ASN.1 OID: " + oid)
164 {}
165
166 Stream_IO_Error::Stream_IO_Error(const std::string& err) :
167 Exception("I/O error: " + err)
168 {}
169
170 System_Error::System_Error(const std::string& msg, int err_code) :
171 Exception(msg + " error code " + std::to_string(err_code)),
172 m_error_code(err_code)
173 {}
174
175 Self_Test_Failure::Self_Test_Failure(const std::string& err) :
176 Internal_Error("Self test failed: " + err)
177 {}
178
179 Not_Implemented::Not_Implemented(const std::string& err) :
180 Exception("Not implemented", err)
181 {}
182
183 }
Botan::ErrorType::LzmaError
Botan::ErrorType::SystemError
Botan::Invalid_Argument
Definition: exceptn.h:136
Botan::ErrorType::NotImplemented
Botan::ErrorType::HttpError
Botan::Encoding_Error::Encoding_Error
Encoding_Error(const std::string &name)
Definition: exceptn.cpp:143
Botan::Invalid_Algorithm_Name::Invalid_Algorithm_Name
Invalid_Algorithm_Name(const std::string &name)
Definition: exceptn.cpp:139
Botan::Exception
Definition: exceptn.h:85
Botan::Lookup_Error
Definition: exceptn.h:247
Botan::Exception::Exception
Exception(const std::string &msg)
Definition: exceptn.cpp:73
Botan::Invalid_Argument::Invalid_Argument
Invalid_Argument(const std::string &msg)
Definition: exceptn.cpp:84
Botan::ErrorType::InvalidObjectState
std
Definition: bigint.h:1135
m_msg
std::vector< uint8_t > m_msg
Definition: ed25519_key.cpp:131
Botan::Internal_Error
Definition: exceptn.h:341
Botan::Policy_Violation::Policy_Violation
Policy_Violation(const std::string &err)
Definition: exceptn.cpp:120
type
MechanismType type
Definition: p11_mechanism.cpp:44
Botan::Decoding_Error::Decoding_Error
Decoding_Error(const std::string &name)
Definition: exceptn.cpp:147
Botan::ErrorType::TLSError
Botan::Key_Not_Set::Key_Not_Set
Key_Not_Set(const std::string &algo)
Definition: exceptn.cpp:116
Botan::ErrorType::Pkcs11Error
Botan::ErrorType::TPMError
Botan::ErrorType::Bzip2Error
Botan::Not_Implemented::Not_Implemented
Not_Implemented(const std::string &err)
Definition: exceptn.cpp:179
Botan::to_string
std::string to_string(ErrorType type)
Convert an ErrorType to string.
Definition: exceptn.cpp:11
Botan::Decoding_Error
Definition: exceptn.h:199
Botan::ErrorType::IoError
Botan::Provider_Not_Found::Provider_Not_Found
Provider_Not_Found(const std::string &algo, const std::string &provider)
Definition: exceptn.cpp:135
Botan::ErrorType::InvalidNonceLength
name
std::string name
Definition: commoncrypto_hash.cpp:23
Botan::ErrorType::KeyNotSet
Botan::ErrorType::InternalError
Botan::Stream_IO_Error::Stream_IO_Error
Stream_IO_Error(const std::string &err)
Definition: exceptn.cpp:166
Botan::ErrorType::InvalidArgument
Botan::ErrorType::LookupError
Botan::ErrorType
ErrorType
Definition: exceptn.h:20
Botan::Algorithm_Not_Found::Algorithm_Not_Found
Algorithm_Not_Found(const std::string &name)
Definition: exceptn.cpp:127
Botan::No_Provider_Found::No_Provider_Found
No_Provider_Found(const std::string &name)
Definition: exceptn.cpp:131
Botan::ErrorType::Unknown
Botan
Definition: alg_id.cpp:13
Botan::PRNG_Unseeded::PRNG_Unseeded
PRNG_Unseeded(const std::string &algo)
Definition: exceptn.cpp:123
Botan::ErrorType::InvalidKeyLength
Botan::Invalid_OID::Invalid_OID
Invalid_OID(const std::string &oid)
Definition: exceptn.cpp:162
Botan::System_Error::System_Error
System_Error(const std::string &msg)
Definition: exceptn.h:326
Botan::Invalid_Authentication_Tag::Invalid_Authentication_Tag
Invalid_Authentication_Tag(const std::string &msg)
Definition: exceptn.cpp:158
Botan::Internal_Error::Internal_Error
Internal_Error(const std::string &err)
Definition: exceptn.cpp:102
Botan::Invalid_Key_Length::Invalid_Key_Length
Invalid_Key_Length(const std::string &name, size_t length)
Definition: exceptn.cpp:106
Botan::ErrorType::ZlibError
Botan::ErrorType::RoughtimeError
Botan::Invalid_State
Definition: exceptn.h:215
Botan::ErrorType::DatabaseError
Botan::ErrorType::OpenSSLError
Botan::Invalid_IV_Length::Invalid_IV_Length
Invalid_IV_Length(const std::string &mode, size_t bad_len)
Definition: exceptn.cpp:111
Botan::ErrorType::CommonCryptoError
Botan::Self_Test_Failure::Self_Test_Failure
Self_Test_Failure(const std::string &err)
Definition: exceptn.cpp:175
Botan::ErrorType::OutOfMemory
Botan::ErrorType::EncodingFailure
Botan::ErrorType::DecodingFailure
Botan::Lookup_Error::Lookup_Error
Lookup_Error(const std::string &err)
Definition: exceptn.h:250
Botan::ErrorType::InvalidTag