summaryrefslogtreecommitdiff
path: root/security/cyrus-sasl2/patches/patch-as
blob: c2e6cbe3c79f5dcbc5b8a14421cb42d02c805270 (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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
$NetBSD: patch-as,v 1.2 2004/02/14 03:16:59 jlam Exp $

--- plugins/digestmd5.c.orig	Tue Nov 11 08:26:07 2003
+++ plugins/digestmd5.c
@@ -60,6 +60,7 @@
 /* DES support */
 #ifdef WITH_DES
 # ifdef WITH_SSL_DES
+#  include <openssl/opensslv.h>
 #  include <openssl/des.h>
 #  include <openssl/opensslv.h>
 #  if (OPENSSL_VERSION_NUMBER >= 0x0090700f) && \
@@ -733,9 +734,15 @@ static void get_pair(char **in, char **n
 
 #ifdef WITH_DES
 struct des_context_s {
+#if OPENSSL_VERSION_NUMBER >= 0x0090700f    
+    DES_key_schedule keysched;  /* key schedule for des initialization */
+    DES_cblock ivec;            /* initial vector for encoding */
+    DES_key_schedule keysched2; /* key schedule for 3des initialization */
+#else
     des_key_schedule keysched;  /* key schedule for des initialization */
     des_cblock ivec;            /* initial vector for encoding */
     des_key_schedule keysched2; /* key schedule for 3des initialization */
+#endif
 };
 
 typedef struct des_context_s des_context_t;
@@ -770,6 +777,15 @@ static int dec_3des(context_t *text,
     des_context_t *c = (des_context_t *) text->cipher_dec_context;
     int padding, p;
     
+#if OPENSSL_VERSION_NUMBER >= 0x0090700f    
+    DES_ede2_cbc_encrypt((void *) input,
+			 (void *) output,
+			 inputlen,
+			 &c->keysched,
+			 &c->keysched2,
+			 &c->ivec,
+			 DES_DECRYPT);
+#else
     des_ede2_cbc_encrypt((void *) input,
 			 (void *) output,
 			 inputlen,
@@ -777,7 +793,7 @@ static int dec_3des(context_t *text,
 			 c->keysched2,
 			 &c->ivec,
 			 DES_DECRYPT);
-    
+#endif    
     /* now chop off the padding */
     padding = output[inputlen - 11];
     if (padding < 1 || padding > 8) {
@@ -818,6 +834,15 @@ static int enc_3des(context_t *text,
     
     len=inputlen+paddinglen+10;
     
+#if OPENSSL_VERSION_NUMBER >= 0x0090700f    
+    DES_ede2_cbc_encrypt((void *) output,
+			 (void *) output,
+			 len,
+			 &c->keysched,
+			 &c->keysched2,
+			 &c->ivec,
+			 DES_ENCRYPT);
+#else
     des_ede2_cbc_encrypt((void *) output,
 			 (void *) output,
 			 len,
@@ -825,7 +850,7 @@ static int enc_3des(context_t *text,
 			 c->keysched2,
 			 &c->ivec,
 			 DES_ENCRYPT);
-    
+#endif 
     *outputlen=len;
     
     return SASL_OK;
@@ -844,12 +869,23 @@ static int init_3des(context_t *text, 
 
     /* setup enc context */
     slidebits(keybuf, enckey);
+#if OPENSSL_VERSION_NUMBER >= 0x0090700f    
+    if (DES_key_sched((DES_cblock *) keybuf, &c->keysched) < 0)
+	return SASL_FAIL;
+#else
     if (des_key_sched((des_cblock *) keybuf, c->keysched) < 0)
 	return SASL_FAIL;
+#endif
 
     slidebits(keybuf, enckey + 7);
+#if OPENSSL_VERSION_NUMBER >= 0x0090700f    
+    if (DES_key_sched((DES_cblock *) keybuf, &c->keysched2) < 0)
+	return SASL_FAIL;
+#else
     if (des_key_sched((des_cblock *) keybuf, c->keysched2) < 0)
 	return SASL_FAIL;
+#endif
+    
     memcpy(c->ivec, ((char *) enckey) + 8, 8);
 
     text->cipher_enc_context = (cipher_context_t *) c;
@@ -857,13 +893,23 @@ static int init_3des(context_t *text, 
     /* setup dec context */
     c++;
     slidebits(keybuf, deckey);
+
+#if OPENSSL_VERSION_NUMBER >= 0x0090700f    
+    if (DES_key_sched((DES_cblock *) keybuf, &c->keysched) < 0)
+	return SASL_FAIL;
+#else
     if (des_key_sched((des_cblock *) keybuf, c->keysched) < 0)
 	return SASL_FAIL;
-    
+#endif    
     slidebits(keybuf, deckey + 7);
+
+#if OPENSSL_VERSION_NUMBER >= 0x0090700f    
+    if (DES_key_sched((DES_cblock *) keybuf, &c->keysched2) < 0)
+	return SASL_FAIL;
+#else
     if (des_key_sched((des_cblock *) keybuf, c->keysched2) < 0)
 	return SASL_FAIL;
-    
+#endif 
     memcpy(c->ivec, ((char *) deckey) + 8, 8);
 
     text->cipher_dec_context = (cipher_context_t *) c;
@@ -888,12 +934,21 @@ static int dec_des(context_t *text, 
     des_context_t *c = (des_context_t *) text->cipher_dec_context;
     int p, padding = 0;
     
+#if OPENSSL_VERSION_NUMBER >= 0x0090700f    
+    DES_cbc_encrypt((void *) input,
+		    (void *) output,
+		    inputlen,
+		    &c->keysched,
+		    &c->ivec,
+		    DES_DECRYPT);
+#else
     des_cbc_encrypt((void *) input,
 		    (void *) output,
 		    inputlen,
 		    c->keysched,
 		    &c->ivec,
 		    DES_DECRYPT);
+#endif
 
     /* Update the ivec (des_cbc_encrypt implementations tend to be broken in
        this way) */
@@ -939,12 +994,21 @@ static int enc_des(context_t *text,
     
     len = inputlen + paddinglen + 10;
     
+#if OPENSSL_VERSION_NUMBER >= 0x0090700f    
+    DES_cbc_encrypt((void *) output,
+                    (void *) output,
+                    len,
+                    &c->keysched,
+                    &c->ivec,
+                    DES_ENCRYPT);
+#else
     des_cbc_encrypt((void *) output,
                     (void *) output,
                     len,
                     c->keysched,
                     &c->ivec,
                     DES_ENCRYPT);
+#endif
     
     /* Update the ivec (des_cbc_encrypt implementations tend to be broken in
        this way) */
@@ -968,7 +1032,12 @@ static int init_des(context_t *text,
     
     /* setup enc context */
     slidebits(keybuf, enckey);
+
+#if OPENSSL_VERSION_NUMBER >= 0x0090700f    
+    DES_key_sched((DES_cblock *) keybuf, &c->keysched);
+#else
     des_key_sched((des_cblock *) keybuf, c->keysched);
+#endif
 
     memcpy(c->ivec, ((char *) enckey) + 8, 8);
     
@@ -977,8 +1046,11 @@ static int init_des(context_t *text,
     /* setup dec context */
     c++;
     slidebits(keybuf, deckey);
+#if OPENSSL_VERSION_NUMBER >= 0x0090700f    
+    DES_key_sched((DES_cblock *) keybuf, &c->keysched);
+#else
     des_key_sched((des_cblock *) keybuf, c->keysched);
-
+#endif
     memcpy(c->ivec, ((char *) deckey) + 8, 8);
     
     text->cipher_dec_context = (cipher_context_t *) c;