MySQL 5.6.14 Source Code Document
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
yassl_error.cpp
1
/*
2
Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
3
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation; version 2 of the License.
7
8
This program is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
GNU General Public License for more details.
12
13
You should have received a copy of the GNU General Public License
14
along with this program; see the file COPYING. If not, write to the
15
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
16
MA 02110-1301 USA.
17
*/
18
19
20
/* yaSSL error implements and an exception class
21
*/
22
23
#include "runtime.hpp"
24
#include "yassl_error.hpp"
25
#include "error.hpp"
// TaoCrypt error numbers
26
#include "openssl/ssl.h"
// SSL_ERROR_WANT_READ
27
#include <string.h>
// strncpy
28
29
#ifdef _MSC_VER
30
// 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy
31
#pragma warning(disable: 4996)
32
#endif
33
34
namespace
yaSSL {
35
36
37
/* may bring back in future
38
Error::Error(const char* s, YasslError e, Library l)
39
: mySTL::runtime_error(s), error_(e), lib_(l)
40
{
41
}
42
43
44
YasslError Error::get_number() const
45
{
46
return error_;
47
}
48
49
50
Library Error::get_lib() const
51
{
52
53
return lib_;
54
}
55
*/
56
57
58
void
SetErrorString(YasslError error,
char
* buffer)
59
{
60
using namespace
TaoCrypt;
61
const
int
max = MAX_ERROR_SZ;
// shorthand
62
int
localError = error;
// errors from a few enums
63
64
switch
(localError) {
65
66
// yaSSL proper errors
67
case
range_error :
68
strncpy(buffer,
"buffer index error, out of range"
, max);
69
break
;
70
71
case
realloc_error :
72
strncpy(buffer,
"trying to realloc a fixed buffer"
, max);
73
break
;
74
75
case
factory_error :
76
strncpy(buffer,
"unknown factory create request"
, max);
77
break
;
78
79
case
unknown_cipher :
80
strncpy(buffer,
"trying to use an unknown cipher"
, max);
81
break
;
82
83
case
prefix_error :
84
strncpy(buffer,
"bad master secret derivation, prefix too big"
, max);
85
break
;
86
87
case
record_layer :
88
strncpy(buffer,
"record layer not ready yet"
, max);
89
break
;
90
91
case
handshake_layer :
92
strncpy(buffer,
"handshake layer not ready yet"
, max);
93
break
;
94
95
case
out_of_order :
96
strncpy(buffer,
"handshake message received in wrong order"
, max);
97
break
;
98
99
case
bad_input :
100
strncpy(buffer,
"bad cipher suite input"
, max);
101
break
;
102
103
case
match_error :
104
strncpy(buffer,
"unable to match a supported cipher suite"
, max);
105
break
;
106
107
case
no_key_file :
108
strncpy(buffer,
"the server needs a private key file"
, max);
109
break
;
110
111
case
verify_error :
112
strncpy(buffer,
"unable to verify peer checksum"
, max);
113
break
;
114
115
case
send_error :
116
strncpy(buffer,
"socket layer send error"
, max);
117
break
;
118
119
case
receive_error :
120
strncpy(buffer,
"socket layer receive error"
, max);
121
break
;
122
123
case
certificate_error :
124
strncpy(buffer,
"unable to proccess cerificate"
, max);
125
break
;
126
127
case
privateKey_error :
128
strncpy(buffer,
"unable to proccess private key, bad format"
, max);
129
break
;
130
131
case
badVersion_error :
132
strncpy(buffer,
"protocol version mismatch"
, max);
133
break
;
134
135
case
compress_error :
136
strncpy(buffer,
"compression error"
, max);
137
break
;
138
139
case
decompress_error :
140
strncpy(buffer,
"decompression error"
, max);
141
break
;
142
143
case
pms_version_error :
144
strncpy(buffer,
"bad PreMasterSecret version error"
, max);
145
break
;
146
147
case
sanityCipher_error :
148
strncpy(buffer,
"sanity check on cipher text size error"
, max);
149
break
;
150
151
// openssl errors
152
case
SSL_ERROR_WANT_READ :
153
strncpy(buffer,
"the read operation would block"
, max);
154
break
;
155
156
case
SSL_ERROR_WANT_WRITE :
157
strncpy(buffer,
"the write operation would block"
, max);
158
break
;
159
160
case
CERTFICATE_ERROR :
161
strncpy(buffer,
"Unable to verify certificate"
, max);
162
break
;
163
164
// TaoCrypt errors
165
case
NO_ERROR_E :
166
strncpy(buffer,
"not in error state"
, max);
167
break
;
168
169
case
WINCRYPT_E :
170
strncpy(buffer,
"bad wincrypt acquire"
, max);
171
break
;
172
173
case
CRYPTGEN_E :
174
strncpy(buffer,
"CryptGenRandom error"
, max);
175
break
;
176
177
case
OPEN_RAN_E :
178
strncpy(buffer,
"unable to use random device"
, max);
179
break
;
180
181
case
READ_RAN_E :
182
strncpy(buffer,
"unable to use random device"
, max);
183
break
;
184
185
case
INTEGER_E :
186
strncpy(buffer,
"ASN: bad DER Integer Header"
, max);
187
break
;
188
189
case
SEQUENCE_E :
190
strncpy(buffer,
"ASN: bad Sequence Header"
, max);
191
break
;
192
193
case
SET_E :
194
strncpy(buffer,
"ASN: bad Set Header"
, max);
195
break
;
196
197
case
VERSION_E :
198
strncpy(buffer,
"ASN: version length not 1"
, max);
199
break
;
200
201
case
SIG_OID_E :
202
strncpy(buffer,
"ASN: signature OID mismatch"
, max);
203
break
;
204
205
case
BIT_STR_E :
206
strncpy(buffer,
"ASN: bad BitString Header"
, max);
207
break
;
208
209
case
UNKNOWN_OID_E :
210
strncpy(buffer,
"ASN: unknown key OID type"
, max);
211
break
;
212
213
case
OBJECT_ID_E :
214
strncpy(buffer,
"ASN: bad Ojbect ID Header"
, max);
215
break
;
216
217
case
TAG_NULL_E :
218
strncpy(buffer,
"ASN: expected TAG NULL"
, max);
219
break
;
220
221
case
EXPECT_0_E :
222
strncpy(buffer,
"ASN: expected 0"
, max);
223
break
;
224
225
case
OCTET_STR_E :
226
strncpy(buffer,
"ASN: bad Octet String Header"
, max);
227
break
;
228
229
case
TIME_E :
230
strncpy(buffer,
"ASN: bad TIME"
, max);
231
break
;
232
233
case
DATE_SZ_E :
234
strncpy(buffer,
"ASN: bad Date Size"
, max);
235
break
;
236
237
case
SIG_LEN_E :
238
strncpy(buffer,
"ASN: bad Signature Length"
, max);
239
break
;
240
241
case
UNKOWN_SIG_E :
242
strncpy(buffer,
"ASN: unknown signature OID"
, max);
243
break
;
244
245
case
UNKOWN_HASH_E :
246
strncpy(buffer,
"ASN: unknown hash OID"
, max);
247
break
;
248
249
case
DSA_SZ_E :
250
strncpy(buffer,
"ASN: bad DSA r or s size"
, max);
251
break
;
252
253
case
BEFORE_DATE_E :
254
strncpy(buffer,
"ASN: before date in the future"
, max);
255
break
;
256
257
case
AFTER_DATE_E :
258
strncpy(buffer,
"ASN: after date in the past"
, max);
259
break
;
260
261
case
SIG_CONFIRM_E :
262
strncpy(buffer,
"ASN: bad self signature confirmation"
, max);
263
break
;
264
265
case
SIG_OTHER_E :
266
strncpy(buffer,
"ASN: bad other signature confirmation"
, max);
267
break
;
268
269
case
CONTENT_E :
270
strncpy(buffer,
"bad content processing"
, max);
271
break
;
272
273
case
PEM_E :
274
strncpy(buffer,
"bad PEM format processing"
, max);
275
break
;
276
277
default
:
278
strncpy(buffer,
"unknown error number"
, max);
279
}
280
}
281
282
283
284
}
// namespace yaSSL
extra
yassl
src
yassl_error.cpp
Generated on Sat Nov 9 2013 01:24:42 for MySQL 5.6.14 Source Code Document by
1.8.1.2