diff options
Diffstat (limited to 'cipher.c')
-rw-r--r-- | cipher.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -35,7 +35,7 @@ | |||
35 | */ | 35 | */ |
36 | 36 | ||
37 | #include "includes.h" | 37 | #include "includes.h" |
38 | RCSID("$OpenBSD: cipher.c,v 1.59 2002/06/19 18:01:00 markus Exp $"); | 38 | RCSID("$OpenBSD: cipher.c,v 1.60 2002/06/23 03:26:52 deraadt Exp $"); |
39 | 39 | ||
40 | #include "xmalloc.h" | 40 | #include "xmalloc.h" |
41 | #include "log.h" | 41 | #include "log.h" |
@@ -95,11 +95,13 @@ cipher_blocksize(Cipher *c) | |||
95 | { | 95 | { |
96 | return (c->block_size); | 96 | return (c->block_size); |
97 | } | 97 | } |
98 | |||
98 | u_int | 99 | u_int |
99 | cipher_keylen(Cipher *c) | 100 | cipher_keylen(Cipher *c) |
100 | { | 101 | { |
101 | return (c->key_len); | 102 | return (c->key_len); |
102 | } | 103 | } |
104 | |||
103 | u_int | 105 | u_int |
104 | cipher_get_number(Cipher *c) | 106 | cipher_get_number(Cipher *c) |
105 | { | 107 | { |
@@ -314,6 +316,7 @@ struct ssh1_3des_ctx | |||
314 | { | 316 | { |
315 | EVP_CIPHER_CTX k1, k2, k3; | 317 | EVP_CIPHER_CTX k1, k2, k3; |
316 | }; | 318 | }; |
319 | |||
317 | static int | 320 | static int |
318 | ssh1_3des_init(EVP_CIPHER_CTX *ctx, const u_char *key, const u_char *iv, | 321 | ssh1_3des_init(EVP_CIPHER_CTX *ctx, const u_char *key, const u_char *iv, |
319 | int enc) | 322 | int enc) |
@@ -356,6 +359,7 @@ ssh1_3des_init(EVP_CIPHER_CTX *ctx, const u_char *key, const u_char *iv, | |||
356 | #endif | 359 | #endif |
357 | return (1); | 360 | return (1); |
358 | } | 361 | } |
362 | |||
359 | static int | 363 | static int |
360 | ssh1_3des_cbc(EVP_CIPHER_CTX *ctx, u_char *dest, const u_char *src, u_int len) | 364 | ssh1_3des_cbc(EVP_CIPHER_CTX *ctx, u_char *dest, const u_char *src, u_int len) |
361 | { | 365 | { |
@@ -377,6 +381,7 @@ ssh1_3des_cbc(EVP_CIPHER_CTX *ctx, u_char *dest, const u_char *src, u_int len) | |||
377 | #endif | 381 | #endif |
378 | return (1); | 382 | return (1); |
379 | } | 383 | } |
384 | |||
380 | static int | 385 | static int |
381 | ssh1_3des_cleanup(EVP_CIPHER_CTX *ctx) | 386 | ssh1_3des_cleanup(EVP_CIPHER_CTX *ctx) |
382 | { | 387 | { |
@@ -389,6 +394,7 @@ ssh1_3des_cleanup(EVP_CIPHER_CTX *ctx) | |||
389 | } | 394 | } |
390 | return (1); | 395 | return (1); |
391 | } | 396 | } |
397 | |||
392 | static const EVP_CIPHER * | 398 | static const EVP_CIPHER * |
393 | evp_ssh1_3des(void) | 399 | evp_ssh1_3des(void) |
394 | { | 400 | { |
@@ -430,7 +436,9 @@ swap_bytes(const u_char *src, u_char *dst, int n) | |||
430 | *dst++ = c[3]; | 436 | *dst++ = c[3]; |
431 | } | 437 | } |
432 | } | 438 | } |
439 | |||
433 | static int (*orig_bf)(EVP_CIPHER_CTX *, u_char *, const u_char *, u_int) = NULL; | 440 | static int (*orig_bf)(EVP_CIPHER_CTX *, u_char *, const u_char *, u_int) = NULL; |
441 | |||
434 | static int | 442 | static int |
435 | bf_ssh1_cipher(EVP_CIPHER_CTX *ctx, u_char *out, const u_char *in, u_int len) | 443 | bf_ssh1_cipher(EVP_CIPHER_CTX *ctx, u_char *out, const u_char *in, u_int len) |
436 | { | 444 | { |
@@ -441,6 +449,7 @@ bf_ssh1_cipher(EVP_CIPHER_CTX *ctx, u_char *out, const u_char *in, u_int len) | |||
441 | swap_bytes(out, out, len); | 449 | swap_bytes(out, out, len); |
442 | return (ret); | 450 | return (ret); |
443 | } | 451 | } |
452 | |||
444 | static const EVP_CIPHER * | 453 | static const EVP_CIPHER * |
445 | evp_ssh1_bf(void) | 454 | evp_ssh1_bf(void) |
446 | { | 455 | { |
@@ -483,6 +492,7 @@ ssh_rijndael_init(EVP_CIPHER_CTX *ctx, const u_char *key, const u_char *iv, | |||
483 | memcpy(c->r_iv, iv, RIJNDAEL_BLOCKSIZE); | 492 | memcpy(c->r_iv, iv, RIJNDAEL_BLOCKSIZE); |
484 | return (1); | 493 | return (1); |
485 | } | 494 | } |
495 | |||
486 | static int | 496 | static int |
487 | ssh_rijndael_cbc(EVP_CIPHER_CTX *ctx, u_char *dest, const u_char *src, | 497 | ssh_rijndael_cbc(EVP_CIPHER_CTX *ctx, u_char *dest, const u_char *src, |
488 | u_int len) | 498 | u_int len) |
@@ -528,6 +538,7 @@ ssh_rijndael_cbc(EVP_CIPHER_CTX *ctx, u_char *dest, const u_char *src, | |||
528 | } | 538 | } |
529 | return (1); | 539 | return (1); |
530 | } | 540 | } |
541 | |||
531 | static int | 542 | static int |
532 | ssh_rijndael_cleanup(EVP_CIPHER_CTX *ctx) | 543 | ssh_rijndael_cleanup(EVP_CIPHER_CTX *ctx) |
533 | { | 544 | { |
@@ -540,6 +551,7 @@ ssh_rijndael_cleanup(EVP_CIPHER_CTX *ctx) | |||
540 | } | 551 | } |
541 | return (1); | 552 | return (1); |
542 | } | 553 | } |
554 | |||
543 | static const EVP_CIPHER * | 555 | static const EVP_CIPHER * |
544 | evp_rijndael(void) | 556 | evp_rijndael(void) |
545 | { | 557 | { |