summaryrefslogtreecommitdiff
path: root/cipher.c
diff options
context:
space:
mode:
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 }