pkgsrc/security/cyrus-sasl2/patches/patch-as

199 lines
5.6 KiB
Text
Raw Normal View History

$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;