diff options
Diffstat (limited to 'packet.c')
-rw-r--r-- | packet.c | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -37,7 +37,7 @@ | |||
37 | */ | 37 | */ |
38 | 38 | ||
39 | #include "includes.h" | 39 | #include "includes.h" |
40 | RCSID("$OpenBSD: packet.c,v 1.94 2002/06/04 23:02:06 markus Exp $"); | 40 | RCSID("$OpenBSD: packet.c,v 1.95 2002/06/19 18:01:00 markus Exp $"); |
41 | 41 | ||
42 | #include "xmalloc.h" | 42 | #include "xmalloc.h" |
43 | #include "buffer.h" | 43 | #include "buffer.h" |
@@ -60,6 +60,7 @@ RCSID("$OpenBSD: packet.c,v 1.94 2002/06/04 23:02:06 markus Exp $"); | |||
60 | #include "log.h" | 60 | #include "log.h" |
61 | #include "canohost.h" | 61 | #include "canohost.h" |
62 | #include "misc.h" | 62 | #include "misc.h" |
63 | #include "ssh.h" | ||
63 | 64 | ||
64 | #ifdef PACKET_DEBUG | 65 | #ifdef PACKET_DEBUG |
65 | #define DBG(x) x | 66 | #define DBG(x) x |
@@ -118,6 +119,10 @@ Newkeys *newkeys[MODE_MAX]; | |||
118 | static u_int32_t read_seqnr = 0; | 119 | static u_int32_t read_seqnr = 0; |
119 | static u_int32_t send_seqnr = 0; | 120 | static u_int32_t send_seqnr = 0; |
120 | 121 | ||
122 | /* Session key for protocol v1 */ | ||
123 | static u_char ssh1_key[SSH_SESSION_KEY_LENGTH]; | ||
124 | static u_int ssh1_keylen; | ||
125 | |||
121 | /* roundup current message to extra_pad bytes */ | 126 | /* roundup current message to extra_pad bytes */ |
122 | static u_char extra_pad = 0; | 127 | static u_char extra_pad = 0; |
123 | 128 | ||
@@ -391,6 +396,7 @@ packet_start_compression(int level) | |||
391 | * key is used for both sending and reception. However, both directions are | 396 | * key is used for both sending and reception. However, both directions are |
392 | * encrypted independently of each other. | 397 | * encrypted independently of each other. |
393 | */ | 398 | */ |
399 | |||
394 | void | 400 | void |
395 | packet_set_encryption_key(const u_char *key, u_int keylen, | 401 | packet_set_encryption_key(const u_char *key, u_int keylen, |
396 | int number) | 402 | int number) |
@@ -400,10 +406,23 @@ packet_set_encryption_key(const u_char *key, u_int keylen, | |||
400 | fatal("packet_set_encryption_key: unknown cipher number %d", number); | 406 | fatal("packet_set_encryption_key: unknown cipher number %d", number); |
401 | if (keylen < 20) | 407 | if (keylen < 20) |
402 | fatal("packet_set_encryption_key: keylen too small: %d", keylen); | 408 | fatal("packet_set_encryption_key: keylen too small: %d", keylen); |
409 | if (keylen > SSH_SESSION_KEY_LENGTH) | ||
410 | fatal("packet_set_encryption_key: keylen too big: %d", keylen); | ||
411 | memcpy(ssh1_key, key, keylen); | ||
412 | ssh1_keylen = keylen; | ||
403 | cipher_init(&send_context, cipher, key, keylen, NULL, 0, CIPHER_ENCRYPT); | 413 | cipher_init(&send_context, cipher, key, keylen, NULL, 0, CIPHER_ENCRYPT); |
404 | cipher_init(&receive_context, cipher, key, keylen, NULL, 0, CIPHER_DECRYPT); | 414 | cipher_init(&receive_context, cipher, key, keylen, NULL, 0, CIPHER_DECRYPT); |
405 | } | 415 | } |
406 | 416 | ||
417 | u_int | ||
418 | packet_get_encryption_key(u_char *key) | ||
419 | { | ||
420 | if (key == NULL) | ||
421 | return (ssh1_keylen); | ||
422 | memcpy(key, ssh1_key, ssh1_keylen); | ||
423 | return (ssh1_keylen); | ||
424 | } | ||
425 | |||
407 | /* Start constructing a packet to send. */ | 426 | /* Start constructing a packet to send. */ |
408 | void | 427 | void |
409 | packet_start(u_char type) | 428 | packet_start(u_char type) |