summaryrefslogtreecommitdiff
path: root/extra/kdelibs3/openssl.patch
blob: a948b884a8180527840962c5d73b272eb02ed842 (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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
diff -up kdelibs-3.5.10/kio/kssl/kopenssl.cc.ossl-1.x kdelibs-3.5.10/kio/kssl/kopenssl.cc
--- kdelibs-3.5.10/kio/kssl/kopenssl.cc.ossl-1.x	2009-09-04 23:10:53.000000000 +0200
+++ kdelibs-3.5.10/kio/kssl/kopenssl.cc	2009-09-04 23:10:53.000000000 +0200
@@ -96,9 +96,14 @@ static int  (*K_BIO_write) (BIO *b, cons
 static int (*K_PEM_ASN1_write_bio) (int (*)(),const char *,BIO *,char *,
                                    const EVP_CIPHER *,unsigned char *,int ,
                                             pem_password_cb *, void *) = 0L;
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+static int (*K_ASN1_item_i2d_fp)(ASN1_ITEM *,FILE *,unsigned char *) = 0L;
+static ASN1_ITEM *K_NETSCAPE_X509_it = 0L;
+#else
 static ASN1_METHOD* (*K_X509_asn1_meth) (void) = 0L;
 static int (*K_ASN1_i2d_fp)(int (*)(),FILE *,unsigned char *) = 0L;
 static int (*K_i2d_ASN1_HEADER)(ASN1_HEADER *, unsigned char **) = 0L;
+#endif
 static int (*K_X509_print_fp)  (FILE *, X509*) = 0L;
 static int (*K_i2d_PKCS12)  (PKCS12*, unsigned char**) = 0L;
 static int (*K_i2d_PKCS12_fp)  (FILE *, PKCS12*) = 0L;
@@ -430,9 +435,14 @@ KConfig *cfg;
       K_BIO_ctrl = (long (*) (BIO *,int,long,void *)) _cryptoLib->symbol("BIO_ctrl");
       K_BIO_write = (int (*) (BIO *b, const void *data, int len)) _cryptoLib->symbol("BIO_write");
       K_PEM_ASN1_write_bio = (int (*)(int (*)(), const char *,BIO*, char*, const EVP_CIPHER *, unsigned char *, int, pem_password_cb *, void *)) _cryptoLib->symbol("PEM_ASN1_write_bio");
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+      K_ASN1_item_i2d_fp = (int (*)(ASN1_ITEM *, FILE*, unsigned char *)) _cryptoLib->symbol("ASN1_item_i2d_fp");
+      K_NETSCAPE_X509_it = (ASN1_ITEM *) _cryptoLib->symbol("NETSCAPE_X509_it");
+#else
       K_X509_asn1_meth = (ASN1_METHOD* (*)(void)) _cryptoLib->symbol("X509_asn1_meth");
       K_ASN1_i2d_fp = (int (*)(int (*)(), FILE*, unsigned char *)) _cryptoLib->symbol("ASN1_i2d_fp");
       K_i2d_ASN1_HEADER = (int (*)(ASN1_HEADER *, unsigned char **)) _cryptoLib->symbol("i2d_ASN1_HEADER");
+#endif
       K_X509_print_fp = (int (*)(FILE*, X509*)) _cryptoLib->symbol("X509_print_fp");
       K_i2d_PKCS12 = (int (*)(PKCS12*, unsigned char**)) _cryptoLib->symbol("i2d_PKCS12");
       K_i2d_PKCS12_fp = (int (*)(FILE *, PKCS12*)) _cryptoLib->symbol("i2d_PKCS12_fp");
@@ -594,7 +604,7 @@ KConfig *cfg;
       K_SSL_set_session = (int (*)(SSL*,SSL_SESSION*)) _sslLib->symbol("SSL_set_session");
       K_d2i_SSL_SESSION = (SSL_SESSION* (*)(SSL_SESSION**,unsigned char**, long)) _sslLib->symbol("d2i_SSL_SESSION");
       K_i2d_SSL_SESSION = (int (*)(SSL_SESSION*,unsigned char**)) _sslLib->symbol("i2d_SSL_SESSION");
-      K_SSL_get_ciphers = (STACK *(*)(const SSL*)) _sslLib->symbol("SSL_get_ciphers");
+      K_SSL_get_ciphers = (STACK_OF(SSL_CIPHER) *(*)(const SSL*)) _sslLib->symbol("SSL_get_ciphers");
 #endif
 
 
@@ -982,7 +992,13 @@ int KOpenSSLProxy::PEM_write_bio_X509(BI
    else return -1;
 }
 
-
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+int KOpenSSLProxy::ASN1_i2d_fp(FILE *out,unsigned char *x) {
+   if (K_ASN1_item_i2d_fp && K_NETSCAPE_X509_it)
+        return (K_ASN1_item_i2d_fp)(K_NETSCAPE_X509_it, out, x);
+   else return -1;
+}
+#else
 ASN1_METHOD *KOpenSSLProxy::X509_asn1_meth(void) {
    if (K_X509_asn1_meth) return (K_X509_asn1_meth)();
    else return 0L;
@@ -994,7 +1010,7 @@ int KOpenSSLProxy::ASN1_i2d_fp(FILE *out
         return (K_ASN1_i2d_fp)((int (*)())K_i2d_ASN1_HEADER, out, x);
    else return -1;
 }
-
+#endif
 
 int KOpenSSLProxy::X509_print(FILE *fp, X509 *x) {
    if (K_X509_print_fp) return (K_X509_print_fp)(fp, x);
diff -up kdelibs-3.5.10/kio/kssl/kopenssl.h.ossl-1.x kdelibs-3.5.10/kio/kssl/kopenssl.h
--- kdelibs-3.5.10/kio/kssl/kopenssl.h.ossl-1.x	2006-07-22 10:16:39.000000000 +0200
+++ kdelibs-3.5.10/kio/kssl/kopenssl.h	2009-09-04 23:10:53.000000000 +0200
@@ -48,6 +48,9 @@ class KOpenSSLProxyPrivate;
 #include <openssl/stack.h>
 #include <openssl/bn.h>
 #undef crypt
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+#define STACK _STACK
+#endif
 #endif
 
 #include <kstaticdeleter.h>
@@ -446,12 +449,12 @@ public:
     */
    int PEM_write_bio_X509(BIO *bp, X509 *x);
 
-
+#if OPENSSL_VERSION_NUMBER < 0x10000000L
    /*
     *   X509_asn1_meth - used for netscape output
     */
    ASN1_METHOD *X509_asn1_meth();
-
+#endif
 
    /*
     *   ASN1_i2d_fp - used for netscape output
@@ -531,6 +534,9 @@ public:
     */
    void sk_free(STACK *s);
 
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+   void sk_free(void *s) { return sk_free(reinterpret_cast<STACK*>(s)); }
+#endif
 
    /* 
     *  Number of elements in the stack
@@ -543,6 +549,9 @@ public:
     */
    char *sk_value(STACK *s, int n);
 
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+   char *sk_value(void *s, int n) { return sk_value(reinterpret_cast<STACK*>(s), n); }
+#endif
 
    /* 
     *  Create a new stack
@@ -555,6 +564,9 @@ public:
     */
    int sk_push(STACK *s, char *d);
 
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+   int sk_push(void *s, void *d) { return sk_push(reinterpret_cast<STACK*>(s), reinterpret_cast<char*>(d)); }
+#endif
 
    /* 
     *  Duplicate the stack
diff -up kdelibs-3.5.10/kio/kssl/ksmimecrypto.cc.ossl-1.x kdelibs-3.5.10/kio/kssl/ksmimecrypto.cc
--- kdelibs-3.5.10/kio/kssl/ksmimecrypto.cc.ossl-1.x	2005-10-10 17:05:44.000000000 +0200
+++ kdelibs-3.5.10/kio/kssl/ksmimecrypto.cc	2009-09-04 23:10:53.000000000 +0200
@@ -87,7 +87,7 @@ KSMIMECryptoPrivate::KSMIMECryptoPrivate
 
 
 STACK_OF(X509) *KSMIMECryptoPrivate::certsToX509(QPtrList<KSSLCertificate> &certs) {
-    STACK_OF(X509) *x509 = sk_new(NULL);
+    STACK_OF(X509) *x509 = reinterpret_cast<STACK_OF(X509)*>(sk_new(NULL));
     KSSLCertificate *cert = certs.first();
     while(cert) {
 	sk_X509_push(x509, cert->getCert());
diff -up kdelibs-3.5.10/kio/kssl/ksslcertificate.cc.ossl-1.x kdelibs-3.5.10/kio/kssl/ksslcertificate.cc
--- kdelibs-3.5.10/kio/kssl/ksslcertificate.cc.ossl-1.x	2006-01-19 18:06:12.000000000 +0100
+++ kdelibs-3.5.10/kio/kssl/ksslcertificate.cc	2009-09-04 23:10:53.000000000 +0200
@@ -1003,17 +1003,31 @@ return qba;
 QByteArray KSSLCertificate::toNetscape() {
 QByteArray qba;
 #ifdef KSSL_HAVE_SSL
-ASN1_HEADER ah;
-ASN1_OCTET_STRING os;
-KTempFile ktf;
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+	NETSCAPE_X509 nx;
+	ASN1_OCTET_STRING hdr;
+#else
+   ASN1_HEADER ah;
+   ASN1_OCTET_STRING os;
+#endif
+	KTempFile ktf;
 
-	os.data = (unsigned char *)NETSCAPE_CERT_HDR;
-	os.length = strlen(NETSCAPE_CERT_HDR);
-	ah.header = &os;
-	ah.data = (char *)getCert();
-	ah.meth = d->kossl->X509_asn1_meth();
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+	hdr.data = (unsigned char *)NETSCAPE_CERT_HDR;
+	hdr.length = strlen(NETSCAPE_CERT_HDR);
+	nx.header = &hdr;
+	nx.cert = getCert();
+
+	d->kossl->ASN1_i2d_fp(ktf.fstream(),(unsigned char *)&nx);
+#else
+   os.data = (unsigned char *)NETSCAPE_CERT_HDR;
+   os.length = strlen(NETSCAPE_CERT_HDR);
+   ah.header = &os;
+   ah.data = (char *)getCert();
+   ah.meth = d->kossl->X509_asn1_meth();
 
-	d->kossl->ASN1_i2d_fp(ktf.fstream(),(unsigned char *)&ah);
+   d->kossl->ASN1_i2d_fp(ktf.fstream(),(unsigned char *)&ah);
+#endif
 
 	ktf.close();