2
Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
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.
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.
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,
20
/* yaSSL error implements and an exception class
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
30
// 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy
31
#pragma warning(disable: 4996)
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)
44
YasslError Error::get_number() const
50
Library Error::get_lib() const
58
void SetErrorString(unsigned long error, char* buffer)
60
using namespace TaoCrypt;
61
const int max = MAX_ERROR_SZ; // shorthand
65
// yaSSL proper errors
67
strncpy(buffer, "buffer index error, out of range", max);
71
strncpy(buffer, "trying to realloc a fixed buffer", max);
75
strncpy(buffer, "unknown factory create request", max);
79
strncpy(buffer, "trying to use an unknown cipher", max);
83
strncpy(buffer, "bad master secret derivation, prefix too big", max);
87
strncpy(buffer, "record layer not ready yet", max);
90
case handshake_layer :
91
strncpy(buffer, "handshake layer not ready yet", max);
95
strncpy(buffer, "handshake message received in wrong order", max);
99
strncpy(buffer, "bad cipher suite input", max);
103
strncpy(buffer, "unable to match a supported cipher suite", max);
107
strncpy(buffer, "the server needs a private key file", max);
111
strncpy(buffer, "unable to verify peer checksum", max);
115
strncpy(buffer, "socket layer send error", max);
119
strncpy(buffer, "socket layer receive error", max);
122
case certificate_error :
123
strncpy(buffer, "unable to proccess cerificate", max);
126
case privateKey_error :
127
strncpy(buffer, "unable to proccess private key, bad format", max);
130
case badVersion_error :
131
strncpy(buffer, "protocl version mismatch", max);
134
case compress_error :
135
strncpy(buffer, "compression error", max);
138
case decompress_error :
139
strncpy(buffer, "decompression error", max);
142
case pms_version_error :
143
strncpy(buffer, "bad PreMasterSecret version error", max);
147
case SSL_ERROR_WANT_READ :
148
strncpy(buffer, "the read operation would block", max);
151
case CERTFICATE_ERROR :
152
strncpy(buffer, "Unable to verify certificate", max);
157
strncpy(buffer, "not in error state", max);
161
strncpy(buffer, "bad wincrypt acquire", max);
165
strncpy(buffer, "CryptGenRandom error", max);
169
strncpy(buffer, "unable to use random device", max);
173
strncpy(buffer, "unable to use random device", max);
177
strncpy(buffer, "ASN: bad DER Integer Header", max);
181
strncpy(buffer, "ASN: bad Sequence Header", max);
185
strncpy(buffer, "ASN: bad Set Header", max);
189
strncpy(buffer, "ASN: version length not 1", max);
193
strncpy(buffer, "ASN: signature OID mismatch", max);
197
strncpy(buffer, "ASN: bad BitString Header", max);
201
strncpy(buffer, "ASN: unknown key OID type", max);
205
strncpy(buffer, "ASN: bad Ojbect ID Header", max);
209
strncpy(buffer, "ASN: expected TAG NULL", max);
213
strncpy(buffer, "ASN: expected 0", max);
217
strncpy(buffer, "ASN: bad Octet String Header", max);
221
strncpy(buffer, "ASN: bad TIME", max);
225
strncpy(buffer, "ASN: bad Date Size", max);
229
strncpy(buffer, "ASN: bad Signature Length", max);
233
strncpy(buffer, "ASN: unknown signature OID", max);
237
strncpy(buffer, "ASN: unknown hash OID", max);
241
strncpy(buffer, "ASN: bad DSA r or s size", max);
245
strncpy(buffer, "ASN: before date in the future", max);
249
strncpy(buffer, "ASN: after date in the past", max);
253
strncpy(buffer, "ASN: bad self signature confirmation", max);
257
strncpy(buffer, "ASN: bad other signature confirmation", max);
261
strncpy(buffer, "bad content processing", max);
265
strncpy(buffer, "bad PEM format processing", max);
269
strncpy(buffer, "unknown error number", max);