summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--cipher.c76
2 files changed, 40 insertions, 39 deletions
diff --git a/ChangeLog b/ChangeLog
index 397defde5..dd42df5dc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,7 @@
10 - (stevesk) [defines.h] #define MAP_ANON MAP_ANONYMOUS for HP-UX; other 10 - (stevesk) [defines.h] #define MAP_ANON MAP_ANONYMOUS for HP-UX; other
11 platforms may need this--I'm not sure. mmap() issues will need to be 11 platforms may need this--I'm not sure. mmap() issues will need to be
12 addressed further. 12 addressed further.
13 - (tim) [cipher.c] fix problem with OpenBSD sync
13 14
1420020321 1520020321
15 - (bal) OpenBSD CVS Sync 16 - (bal) OpenBSD CVS Sync
@@ -8004,4 +8005,4 @@
8004 - Wrote replacements for strlcpy and mkdtemp 8005 - Wrote replacements for strlcpy and mkdtemp
8005 - Released 1.0pre1 8006 - Released 1.0pre1
8006 8007
8007$Id: ChangeLog,v 1.1973 2002/03/22 21:08:03 stevesk Exp $ 8008$Id: ChangeLog,v 1.1974 2002/03/22 21:27:40 tim Exp $
diff --git a/cipher.c b/cipher.c
index b899fcd22..a9ca99cd7 100644
--- a/cipher.c
+++ b/cipher.c
@@ -507,6 +507,44 @@ ssh_rijndael_cbc(EVP_CIPHER_CTX *ctx, u_char *dest, const u_char *src,
507 for (i = blocks; i > 0; i--, cnow-=RIJNDAEL_BLOCKSIZE, 507 for (i = blocks; i > 0; i--, cnow-=RIJNDAEL_BLOCKSIZE,
508 plain-=RIJNDAEL_BLOCKSIZE) { 508 plain-=RIJNDAEL_BLOCKSIZE) {
509 rijndael_decrypt(&c->r_ctx, cnow, plain); 509 rijndael_decrypt(&c->r_ctx, cnow, plain);
510 ivp = (i == 1) ? c->r_iv : cnow-RIJNDAEL_BLOCKSIZE;
511 for (j = 0; j < RIJNDAEL_BLOCKSIZE; j++)
512 plain[j] ^= ivp[j];
513 }
514 memcpy(c->r_iv, buf, RIJNDAEL_BLOCKSIZE);
515 }
516 return (1);
517}
518static int
519ssh_rijndael_cleanup(EVP_CIPHER_CTX *ctx)
520{
521 struct ssh_rijndael_ctx *c;
522
523 if ((c = EVP_CIPHER_CTX_get_app_data(ctx)) != NULL) {
524 memset(c, 0, sizeof(*c));
525 xfree(c);
526 EVP_CIPHER_CTX_set_app_data(ctx, NULL);
527 }
528 return (1);
529}
530static EVP_CIPHER *
531evp_rijndael(void)
532{
533 static EVP_CIPHER rijndal_cbc;
534
535 memset(&rijndal_cbc, 0, sizeof(EVP_CIPHER));
536 rijndal_cbc.nid = NID_undef;
537 rijndal_cbc.block_size = RIJNDAEL_BLOCKSIZE;
538 rijndal_cbc.iv_len = RIJNDAEL_BLOCKSIZE;
539 rijndal_cbc.key_len = 16;
540 rijndal_cbc.init = ssh_rijndael_init;
541 rijndal_cbc.cleanup = ssh_rijndael_cleanup;
542 rijndal_cbc.do_cipher = ssh_rijndael_cbc;
543#ifndef SSH_OLD_EVP
544 rijndal_cbc.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH |
545 EVP_CIPH_ALWAYS_CALL_INIT;
546#endif
547 return (&rijndal_cbc);
510} 548}
511 549
512/* 550/*
@@ -675,42 +713,4 @@ cipher_set_keycontext(CipherContext *cc, u_char *dat)
675 plen = EVP_X_STATE_LEN(cc->evp); 713 plen = EVP_X_STATE_LEN(cc->evp);
676 memcpy(EVP_X_STATE(cc->evp), dat, plen); 714 memcpy(EVP_X_STATE(cc->evp), dat, plen);
677 } 715 }
678 ivp = (i == 1) ? c->r_iv : cnow-RIJNDAEL_BLOCKSIZE;
679 for (j = 0; j < RIJNDAEL_BLOCKSIZE; j++)
680 plain[j] ^= ivp[j];
681 }
682 memcpy(c->r_iv, buf, RIJNDAEL_BLOCKSIZE);
683 }
684 return (1);
685}
686static int
687ssh_rijndael_cleanup(EVP_CIPHER_CTX *ctx)
688{
689 struct ssh_rijndael_ctx *c;
690
691 if ((c = EVP_CIPHER_CTX_get_app_data(ctx)) != NULL) {
692 memset(c, 0, sizeof(*c));
693 xfree(c);
694 EVP_CIPHER_CTX_set_app_data(ctx, NULL);
695 }
696 return (1);
697}
698static EVP_CIPHER *
699evp_rijndael(void)
700{
701 static EVP_CIPHER rijndal_cbc;
702
703 memset(&rijndal_cbc, 0, sizeof(EVP_CIPHER));
704 rijndal_cbc.nid = NID_undef;
705 rijndal_cbc.block_size = RIJNDAEL_BLOCKSIZE;
706 rijndal_cbc.iv_len = RIJNDAEL_BLOCKSIZE;
707 rijndal_cbc.key_len = 16;
708 rijndal_cbc.init = ssh_rijndael_init;
709 rijndal_cbc.cleanup = ssh_rijndael_cleanup;
710 rijndal_cbc.do_cipher = ssh_rijndael_cbc;
711#ifndef SSH_OLD_EVP
712 rijndal_cbc.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH |
713 EVP_CIPH_ALWAYS_CALL_INIT;
714#endif
715 return (&rijndal_cbc);
716} 716}