summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--cipher.c33
2 files changed, 5 insertions, 34 deletions
diff --git a/ChangeLog b/ChangeLog
index c89ccdf2d..a2208a7c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
120020308
2 - (djm) Revert bits of Markus' OpenSSL compat patch which was accidentally
3 committed.
4
120020307 520020307
2 - (djm) OpenBSD CVS Sync 6 - (djm) OpenBSD CVS Sync
3 - markus@cvs.openbsd.org 2002/03/06 00:20:54 7 - markus@cvs.openbsd.org 2002/03/06 00:20:54
@@ -7820,4 +7824,4 @@
7820 - Wrote replacements for strlcpy and mkdtemp 7824 - Wrote replacements for strlcpy and mkdtemp
7821 - Released 1.0pre1 7825 - Released 1.0pre1
7822 7826
7823$Id: ChangeLog,v 1.1916 2002/03/08 03:50:57 mouring Exp $ 7827$Id: ChangeLog,v 1.1917 2002/03/10 23:48:53 djm Exp $
diff --git a/cipher.c b/cipher.c
index fa0532ca0..ce3f6f3ce 100644
--- a/cipher.c
+++ b/cipher.c
@@ -41,10 +41,6 @@ RCSID("$OpenBSD: cipher.c,v 1.52 2002/02/18 13:05:32 markus Exp $");
41#include "log.h" 41#include "log.h"
42#include "cipher.h" 42#include "cipher.h"
43 43
44#if OPENSSL_VERSION_NUMBER <= 0x0090600fL
45#define EVP_CIPHER_CTX_get_app_data(e) ((e)->app_data)
46#endif
47
48#include <openssl/md5.h> 44#include <openssl/md5.h>
49#include "rijndael.h" 45#include "rijndael.h"
50 46
@@ -200,7 +196,6 @@ cipher_init(CipherContext *cc, Cipher *cipher,
200 type = (*cipher->evptype)(); 196 type = (*cipher->evptype)();
201 197
202 EVP_CIPHER_CTX_init(&cc->evp); 198 EVP_CIPHER_CTX_init(&cc->evp);
203#if OPENSSL_VERSION_NUMBER > 0x0090600fL
204 if (EVP_CipherInit(&cc->evp, type, NULL, (u_char *)iv, 199 if (EVP_CipherInit(&cc->evp, type, NULL, (u_char *)iv,
205 (encrypt == CIPHER_ENCRYPT)) == 0) 200 (encrypt == CIPHER_ENCRYPT)) == 0)
206 fatal("cipher_init: EVP_CipherInit failed for %s", 201 fatal("cipher_init: EVP_CipherInit failed for %s",
@@ -215,10 +210,6 @@ cipher_init(CipherContext *cc, Cipher *cipher,
215 if (EVP_CipherInit(&cc->evp, NULL, (u_char *)key, NULL, -1) == 0) 210 if (EVP_CipherInit(&cc->evp, NULL, (u_char *)key, NULL, -1) == 0)
216 fatal("cipher_init: EVP_CipherInit: set key failed for %s", 211 fatal("cipher_init: EVP_CipherInit: set key failed for %s",
217 cipher->name); 212 cipher->name);
218#else
219 EVP_CipherInit(&cc->evp, type, (u_char *)key, (u_char *)iv,
220 (encrypt == CIPHER_ENCRYPT));
221#endif
222} 213}
223 214
224void 215void
@@ -226,23 +217,15 @@ cipher_crypt(CipherContext *cc, u_char *dest, const u_char *src, u_int len)
226{ 217{
227 if (len % cc->cipher->block_size) 218 if (len % cc->cipher->block_size)
228 fatal("cipher_encrypt: bad plaintext length %d", len); 219 fatal("cipher_encrypt: bad plaintext length %d", len);
229#if OPENSSL_VERSION_NUMBER > 0x0090600fL
230 if (EVP_Cipher(&cc->evp, dest, (u_char *)src, len) == 0) 220 if (EVP_Cipher(&cc->evp, dest, (u_char *)src, len) == 0)
231 fatal("evp_crypt: EVP_Cipher failed"); 221 fatal("evp_crypt: EVP_Cipher failed");
232#else
233 EVP_Cipher(&cc->evp, dest, (u_char *)src, len);
234#endif
235} 222}
236 223
237void 224void
238cipher_cleanup(CipherContext *cc) 225cipher_cleanup(CipherContext *cc)
239{ 226{
240#if OPENSSL_VERSION_NUMBER > 0x0090600fL
241 if (EVP_CIPHER_CTX_cleanup(&cc->evp) == 0) 227 if (EVP_CIPHER_CTX_cleanup(&cc->evp) == 0)
242 error("cipher_cleanup: EVP_CIPHER_CTX_cleanup failed"); 228 error("cipher_cleanup: EVP_CIPHER_CTX_cleanup failed");
243#else
244 EVP_CIPHER_CTX_cleanup(&cc->evp);
245#endif
246} 229}
247 230
248/* 231/*
@@ -313,7 +296,6 @@ ssh1_3des_init(EVP_CIPHER_CTX *ctx, const u_char *key, const u_char *iv,
313 EVP_CIPHER_CTX_init(&c->k1); 296 EVP_CIPHER_CTX_init(&c->k1);
314 EVP_CIPHER_CTX_init(&c->k2); 297 EVP_CIPHER_CTX_init(&c->k2);
315 EVP_CIPHER_CTX_init(&c->k3); 298 EVP_CIPHER_CTX_init(&c->k3);
316#if OPENSSL_VERSION_NUMBER > 0x0090600fL
317 if (EVP_CipherInit(&c->k1, EVP_des_cbc(), k1, NULL, enc) == 0 || 299 if (EVP_CipherInit(&c->k1, EVP_des_cbc(), k1, NULL, enc) == 0 ||
318 EVP_CipherInit(&c->k2, EVP_des_cbc(), k2, NULL, !enc) == 0 || 300 EVP_CipherInit(&c->k2, EVP_des_cbc(), k2, NULL, !enc) == 0 ||
319 EVP_CipherInit(&c->k3, EVP_des_cbc(), k3, NULL, enc) == 0) { 301 EVP_CipherInit(&c->k3, EVP_des_cbc(), k3, NULL, enc) == 0) {
@@ -322,11 +304,6 @@ ssh1_3des_init(EVP_CIPHER_CTX *ctx, const u_char *key, const u_char *iv,
322 EVP_CIPHER_CTX_set_app_data(ctx, NULL); 304 EVP_CIPHER_CTX_set_app_data(ctx, NULL);
323 return (0); 305 return (0);
324 } 306 }
325#else
326 EVP_CipherInit(&c->k1, EVP_des_cbc(), k1, NULL, enc);
327 EVP_CipherInit(&c->k2, EVP_des_cbc(), k2, NULL, !enc);
328 EVP_CipherInit(&c->k3, EVP_des_cbc(), k3, NULL, enc);
329#endif
330 return (1); 307 return (1);
331} 308}
332static int 309static int
@@ -338,16 +315,10 @@ ssh1_3des_cbc(EVP_CIPHER_CTX *ctx, u_char *dest, const u_char *src, u_int len)
338 error("ssh1_3des_cbc: no context"); 315 error("ssh1_3des_cbc: no context");
339 return (0); 316 return (0);
340 } 317 }
341#if OPENSSL_VERSION_NUMBER > 0x0090600fL
342 if (EVP_Cipher(&c->k1, dest, (u_char *)src, len) == 0 || 318 if (EVP_Cipher(&c->k1, dest, (u_char *)src, len) == 0 ||
343 EVP_Cipher(&c->k2, dest, dest, len) == 0 || 319 EVP_Cipher(&c->k2, dest, dest, len) == 0 ||
344 EVP_Cipher(&c->k3, dest, dest, len) == 0) 320 EVP_Cipher(&c->k3, dest, dest, len) == 0)
345 return (0); 321 return (0);
346#else
347 EVP_Cipher(&c->k1, dest, (u_char *)src, len);
348 EVP_Cipher(&c->k2, dest, dest, len);
349 EVP_Cipher(&c->k3, dest, dest, len);
350#endif
351 return (1); 322 return (1);
352} 323}
353static int 324static int
@@ -375,9 +346,7 @@ evp_ssh1_3des(void)
375 ssh1_3des.init = ssh1_3des_init; 346 ssh1_3des.init = ssh1_3des_init;
376 ssh1_3des.cleanup = ssh1_3des_cleanup; 347 ssh1_3des.cleanup = ssh1_3des_cleanup;
377 ssh1_3des.do_cipher = ssh1_3des_cbc; 348 ssh1_3des.do_cipher = ssh1_3des_cbc;
378#if OPENSSL_VERSION_NUMBER > 0x0090600fL
379 ssh1_3des.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH; 349 ssh1_3des.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH;
380#endif
381 return (&ssh1_3des); 350 return (&ssh1_3des);
382} 351}
383 352
@@ -525,9 +494,7 @@ evp_rijndael(void)
525 rijndal_cbc.init = ssh_rijndael_init; 494 rijndal_cbc.init = ssh_rijndael_init;
526 rijndal_cbc.cleanup = ssh_rijndael_cleanup; 495 rijndal_cbc.cleanup = ssh_rijndael_cleanup;
527 rijndal_cbc.do_cipher = ssh_rijndael_cbc; 496 rijndal_cbc.do_cipher = ssh_rijndael_cbc;
528#if OPENSSL_VERSION_NUMBER > 0x0090600fL
529 rijndal_cbc.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | 497 rijndal_cbc.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH |
530 EVP_CIPH_ALWAYS_CALL_INIT; 498 EVP_CIPH_ALWAYS_CALL_INIT;
531#endif
532 return (&rijndal_cbc); 499 return (&rijndal_cbc);
533} 500}