summaryrefslogtreecommitdiff
path: root/cipher.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2002-06-21 00:43:42 +0000
committerBen Lindstrom <mouring@eviladmin.org>2002-06-21 00:43:42 +0000
commit402c6cc68170ee63d07c5ff4a081e113b1628445 (patch)
tree081f2f0e57c333e53c308abbfdce31b6ae3d2006 /cipher.c
parentcb72e4f6d2cf63cda22484ec90142689fed288f6 (diff)
- markus@cvs.openbsd.org 2002/06/19 18:01:00
[cipher.c monitor.c monitor_wrap.c packet.c packet.h] make the monitor sync the transfer ssh1 session key; transfer keycontext only for RC4 (this is still depends on EVP implementation details and is broken).
Diffstat (limited to 'cipher.c')
-rw-r--r--cipher.c37
1 files changed, 7 insertions, 30 deletions
diff --git a/cipher.c b/cipher.c
index 39807d5c2..b18c701fb 100644
--- a/cipher.c
+++ b/cipher.c
@@ -35,7 +35,7 @@
35 */ 35 */
36 36
37#include "includes.h" 37#include "includes.h"
38RCSID("$OpenBSD: cipher.c,v 1.58 2002/06/04 23:05:49 markus Exp $"); 38RCSID("$OpenBSD: cipher.c,v 1.59 2002/06/19 18:01:00 markus Exp $");
39 39
40#include "xmalloc.h" 40#include "xmalloc.h"
41#include "log.h" 41#include "log.h"
@@ -689,28 +689,14 @@ int
689cipher_get_keycontext(CipherContext *cc, u_char *dat) 689cipher_get_keycontext(CipherContext *cc, u_char *dat)
690{ 690{
691 Cipher *c = cc->cipher; 691 Cipher *c = cc->cipher;
692 int plen; 692 int plen = 0;
693 693
694 if (c->number == SSH_CIPHER_3DES) { 694 if (c->evptype == EVP_rc4) {
695 struct ssh1_3des_ctx *desc; 695 plen = EVP_X_STATE_LEN(cc->evp);
696 desc = EVP_CIPHER_CTX_get_app_data(&cc->evp);
697 if (desc == NULL)
698 fatal("%s: no 3des context", __func__);
699 plen = EVP_X_STATE_LEN(desc->k1);
700 if (dat == NULL) 696 if (dat == NULL)
701 return (3*plen); 697 return (plen);
702 memcpy(dat, EVP_X_STATE(desc->k1), plen); 698 memcpy(dat, EVP_X_STATE(cc->evp), plen);
703 memcpy(dat + plen, EVP_X_STATE(desc->k2), plen);
704 memcpy(dat + 2*plen, EVP_X_STATE(desc->k3), plen);
705 return (3*plen);
706 } 699 }
707
708 /* Generic EVP */
709 plen = EVP_X_STATE_LEN(cc->evp);
710 if (dat == NULL)
711 return (plen);
712
713 memcpy(dat, EVP_X_STATE(cc->evp), plen);
714 return (plen); 700 return (plen);
715} 701}
716 702
@@ -720,16 +706,7 @@ cipher_set_keycontext(CipherContext *cc, u_char *dat)
720 Cipher *c = cc->cipher; 706 Cipher *c = cc->cipher;
721 int plen; 707 int plen;
722 708
723 if (c->number == SSH_CIPHER_3DES) { 709 if (c->evptype == EVP_rc4) {
724 struct ssh1_3des_ctx *desc;
725 desc = EVP_CIPHER_CTX_get_app_data(&cc->evp);
726 if (desc == NULL)
727 fatal("%s: no 3des context", __func__);
728 plen = EVP_X_STATE_LEN(desc->k1);
729 memcpy(EVP_X_STATE(desc->k1), dat, plen);
730 memcpy(EVP_X_STATE(desc->k2), dat + plen, plen);
731 memcpy(EVP_X_STATE(desc->k3), dat + 2*plen, plen);
732 } else {
733 plen = EVP_X_STATE_LEN(cc->evp); 710 plen = EVP_X_STATE_LEN(cc->evp);
734 memcpy(EVP_X_STATE(cc->evp), dat, plen); 711 memcpy(EVP_X_STATE(cc->evp), dat, plen);
735 } 712 }