aboutsummaryrefslogtreecommitdiff
path: root/libraries/libvmime/libvmime_gnutls3.patch
blob: 66ad19cba4a310c6e8c1d9f9e48513821bd1a7d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
--- libvmime-0.9.1/src/net/tls/TLSSession.cpp	2010-08-19 04:44:52.000000000 -0300
+++ libvmime-0.9.1_patched/src/net/tls/TLSSession.cpp	2013-03-31 09:35:30.294331115 -0300
@@ -22,7 +22,9 @@
 //
 
 #include <gnutls/gnutls.h>
+#if GNUTLS_VERSION_NUMBER < 0x030000
 #include <gnutls/extra.h>
+#endif
 
 #include "vmime/config.hpp"
 
@@ -41,6 +41,9 @@
 //#define GNUTLS_DEBUG 1
 
 
+#include <sstream>
+#include <iomanip>
+
 #if VMIME_DEBUG && GNUTLS_DEBUG
 	#include <iostream>
 #endif // VMIME_DEBUG && GNUTLS_DEBUG
@@ -240,119 +243,14 @@
 
 void TLSSession::throwTLSException(const string& fname, const int code)
 {
-	string msg = fname + "() returned ";
-
-#define ERROR(x) \
-	case x: msg += #x; break;
-
-	switch (code)
-	{
-	ERROR(GNUTLS_E_SUCCESS)
-	ERROR(GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM)
-	ERROR(GNUTLS_E_UNKNOWN_CIPHER_TYPE)
-	ERROR(GNUTLS_E_LARGE_PACKET)
-	ERROR(GNUTLS_E_UNSUPPORTED_VERSION_PACKET)
-	ERROR(GNUTLS_E_UNEXPECTED_PACKET_LENGTH)
-	ERROR(GNUTLS_E_INVALID_SESSION)
-	ERROR(GNUTLS_E_FATAL_ALERT_RECEIVED)
-	ERROR(GNUTLS_E_UNEXPECTED_PACKET)
-	ERROR(GNUTLS_E_WARNING_ALERT_RECEIVED)
-	ERROR(GNUTLS_E_ERROR_IN_FINISHED_PACKET)
-	ERROR(GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET)
-	ERROR(GNUTLS_E_UNKNOWN_CIPHER_SUITE)
-	ERROR(GNUTLS_E_UNWANTED_ALGORITHM)
-	ERROR(GNUTLS_E_MPI_SCAN_FAILED)
-	ERROR(GNUTLS_E_DECRYPTION_FAILED)
-	ERROR(GNUTLS_E_MEMORY_ERROR)
-	ERROR(GNUTLS_E_DECOMPRESSION_FAILED)
-	ERROR(GNUTLS_E_COMPRESSION_FAILED)
-	ERROR(GNUTLS_E_AGAIN)
-	ERROR(GNUTLS_E_EXPIRED)
-	ERROR(GNUTLS_E_DB_ERROR)
-	ERROR(GNUTLS_E_SRP_PWD_ERROR)
-	ERROR(GNUTLS_E_INSUFFICIENT_CREDENTIALS)
-	ERROR(GNUTLS_E_HASH_FAILED)
-	ERROR(GNUTLS_E_BASE64_DECODING_ERROR)
-	ERROR(GNUTLS_E_MPI_PRINT_FAILED)
-	ERROR(GNUTLS_E_REHANDSHAKE)
-	ERROR(GNUTLS_E_GOT_APPLICATION_DATA)
-	ERROR(GNUTLS_E_RECORD_LIMIT_REACHED)
-	ERROR(GNUTLS_E_ENCRYPTION_FAILED)
-	ERROR(GNUTLS_E_PK_ENCRYPTION_FAILED)
-	ERROR(GNUTLS_E_PK_DECRYPTION_FAILED)
-	ERROR(GNUTLS_E_PK_SIGN_FAILED)
-	ERROR(GNUTLS_E_X509_UNSUPPORTED_CRITICAL_EXTENSION)
-	ERROR(GNUTLS_E_KEY_USAGE_VIOLATION)
-	ERROR(GNUTLS_E_NO_CERTIFICATE_FOUND)
-	ERROR(GNUTLS_E_INVALID_REQUEST)
-	ERROR(GNUTLS_E_SHORT_MEMORY_BUFFER)
-	ERROR(GNUTLS_E_INTERRUPTED)
-	ERROR(GNUTLS_E_PUSH_ERROR)
-	ERROR(GNUTLS_E_PULL_ERROR)
-	ERROR(GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER)
-	ERROR(GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
-	ERROR(GNUTLS_E_PKCS1_WRONG_PAD)
-	ERROR(GNUTLS_E_RECEIVED_ILLEGAL_EXTENSION)
-	ERROR(GNUTLS_E_INTERNAL_ERROR)
-	ERROR(GNUTLS_E_DH_PRIME_UNACCEPTABLE)
-	ERROR(GNUTLS_E_FILE_ERROR)
-	ERROR(GNUTLS_E_TOO_MANY_EMPTY_PACKETS)
-	ERROR(GNUTLS_E_UNKNOWN_PK_ALGORITHM)
-	ERROR(GNUTLS_E_INIT_LIBEXTRA)
-	ERROR(GNUTLS_E_LIBRARY_VERSION_MISMATCH)
-	ERROR(GNUTLS_E_NO_TEMPORARY_RSA_PARAMS)
-	ERROR(GNUTLS_E_LZO_INIT_FAILED)
-	ERROR(GNUTLS_E_NO_COMPRESSION_ALGORITHMS)
-	ERROR(GNUTLS_E_NO_CIPHER_SUITES)
-	ERROR(GNUTLS_E_OPENPGP_GETKEY_FAILED)
-	ERROR(GNUTLS_E_PK_SIG_VERIFY_FAILED)
-	ERROR(GNUTLS_E_ILLEGAL_SRP_USERNAME)
-	ERROR(GNUTLS_E_SRP_PWD_PARSING_ERROR)
-	ERROR(GNUTLS_E_NO_TEMPORARY_DH_PARAMS)
-	ERROR(GNUTLS_E_ASN1_ELEMENT_NOT_FOUND)
-	ERROR(GNUTLS_E_ASN1_IDENTIFIER_NOT_FOUND)
-	ERROR(GNUTLS_E_ASN1_DER_ERROR)
-	ERROR(GNUTLS_E_ASN1_VALUE_NOT_FOUND)
-	ERROR(GNUTLS_E_ASN1_GENERIC_ERROR)
-	ERROR(GNUTLS_E_ASN1_VALUE_NOT_VALID)
-	ERROR(GNUTLS_E_ASN1_TAG_ERROR)
-	ERROR(GNUTLS_E_ASN1_TAG_IMPLICIT)
-	ERROR(GNUTLS_E_ASN1_TYPE_ANY_ERROR)
-	ERROR(GNUTLS_E_ASN1_SYNTAX_ERROR)
-	ERROR(GNUTLS_E_ASN1_DER_OVERFLOW)
-	//ERROR(GNUTLS_E_OPENPGP_TRUSTDB_VERSION_UNSUPPORTED)
-	ERROR(GNUTLS_E_OPENPGP_UID_REVOKED)
-	ERROR(GNUTLS_E_CERTIFICATE_ERROR)
-	//ERROR(GNUTLS_E_X509_CERTIFICATE_ERROR)
-	ERROR(GNUTLS_E_CERTIFICATE_KEY_MISMATCH)
-	ERROR(GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE)
-	ERROR(GNUTLS_E_X509_UNKNOWN_SAN)
-	ERROR(GNUTLS_E_OPENPGP_FINGERPRINT_UNSUPPORTED)
-	ERROR(GNUTLS_E_X509_UNSUPPORTED_ATTRIBUTE)
-	ERROR(GNUTLS_E_UNKNOWN_HASH_ALGORITHM)
-	ERROR(GNUTLS_E_UNKNOWN_PKCS_CONTENT_TYPE)
-	ERROR(GNUTLS_E_UNKNOWN_PKCS_BAG_TYPE)
-	ERROR(GNUTLS_E_INVALID_PASSWORD)
-	ERROR(GNUTLS_E_MAC_VERIFY_FAILED)
-	ERROR(GNUTLS_E_CONSTRAINT_ERROR)
-	ERROR(GNUTLS_E_BASE64_ENCODING_ERROR)
-	ERROR(GNUTLS_E_INCOMPATIBLE_GCRYPT_LIBRARY)
-	//ERROR(GNUTLS_E_INCOMPATIBLE_CRYPTO_LIBRARY)
-	ERROR(GNUTLS_E_INCOMPATIBLE_LIBTASN1_LIBRARY)
-	ERROR(GNUTLS_E_OPENPGP_KEYRING_ERROR)
-	ERROR(GNUTLS_E_X509_UNSUPPORTED_OID)
-	//ERROR(GNUTLS_E_RANDOM_FAILED)
-	ERROR(GNUTLS_E_UNIMPLEMENTED_FEATURE)
-
-	default:
-
-		msg += "unknown error";
-		break;
-	}
+	std::ostringstream msg;
 
-#undef ERROR
+	msg << fname + "() returned code ";
+	msg << std::hex << code;
+	msg << ": ";
+	msg << gnutls_strerror(code);
 
-	throw exceptions::tls_exception(msg);
+	throw exceptions::tls_exception(msg.str());
 }