2004-02-14 04:16:58 +01:00
|
|
|
$NetBSD: patch-as,v 1.2 2004/02/14 03:16:59 jlam Exp $
|
2003-08-16 11:06:41 +02:00
|
|
|
|
2004-02-14 04:16:58 +01:00
|
|
|
--- plugins/digestmd5.c.orig Tue Nov 11 08:26:07 2003
|
|
|
|
+++ plugins/digestmd5.c
|
|
|
|
@@ -60,6 +60,7 @@
|
2003-08-16 11:06:41 +02:00
|
|
|
/* DES support */
|
|
|
|
#ifdef WITH_DES
|
|
|
|
# ifdef WITH_SSL_DES
|
|
|
|
+# include <openssl/opensslv.h>
|
|
|
|
# include <openssl/des.h>
|
2004-02-14 04:16:58 +01:00
|
|
|
# include <openssl/opensslv.h>
|
|
|
|
# if (OPENSSL_VERSION_NUMBER >= 0x0090700f) && \
|
|
|
|
@@ -733,9 +734,15 @@ static void get_pair(char **in, char **n
|
2003-08-16 11:06:41 +02:00
|
|
|
|
|
|
|
#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;
|
2004-02-14 04:16:58 +01:00
|
|
|
@@ -770,6 +777,15 @@ static int dec_3des(context_t *text,
|
2003-08-16 11:06:41 +02:00
|
|
|
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,
|
2004-02-14 04:16:58 +01:00
|
|
|
@@ -777,7 +793,7 @@ static int dec_3des(context_t *text,
|
2003-08-16 11:06:41 +02:00
|
|
|
c->keysched2,
|
|
|
|
&c->ivec,
|
|
|
|
DES_DECRYPT);
|
|
|
|
-
|
|
|
|
+#endif
|
|
|
|
/* now chop off the padding */
|
|
|
|
padding = output[inputlen - 11];
|
|
|
|
if (padding < 1 || padding > 8) {
|
2004-02-14 04:16:58 +01:00
|
|
|
@@ -818,6 +834,15 @@ static int enc_3des(context_t *text,
|
2003-08-16 11:06:41 +02:00
|
|
|
|
|
|
|
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,
|
2004-02-14 04:16:58 +01:00
|
|
|
@@ -825,7 +850,7 @@ static int enc_3des(context_t *text,
|
2003-08-16 11:06:41 +02:00
|
|
|
c->keysched2,
|
|
|
|
&c->ivec,
|
|
|
|
DES_ENCRYPT);
|
|
|
|
-
|
|
|
|
+#endif
|
|
|
|
*outputlen=len;
|
|
|
|
|
|
|
|
return SASL_OK;
|
2004-02-14 04:16:58 +01:00
|
|
|
@@ -844,12 +869,23 @@ static int init_3des(context_t *text,
|
2003-08-16 11:06:41 +02:00
|
|
|
|
|
|
|
/* 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;
|
2004-02-14 04:16:58 +01:00
|
|
|
@@ -857,13 +893,23 @@ static int init_3des(context_t *text,
|
2003-08-16 11:06:41 +02:00
|
|
|
/* 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;
|
2004-02-14 04:16:58 +01:00
|
|
|
@@ -888,12 +934,21 @@ static int dec_des(context_t *text,
|
2003-08-16 11:06:41 +02:00
|
|
|
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) */
|
2004-02-14 04:16:58 +01:00
|
|
|
@@ -939,12 +994,21 @@ static int enc_des(context_t *text,
|
2003-08-16 11:06:41 +02:00
|
|
|
|
|
|
|
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) */
|
2004-02-14 04:16:58 +01:00
|
|
|
@@ -968,7 +1032,12 @@ static int init_des(context_t *text,
|
2003-08-16 11:06:41 +02:00
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
2004-02-14 04:16:58 +01:00
|
|
|
@@ -977,8 +1046,11 @@ static int init_des(context_t *text,
|
2003-08-16 11:06:41 +02:00
|
|
|
/* 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;
|