diff options
author | Damien Miller <djm@mindrot.org> | 2014-05-15 14:24:09 +1000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2014-05-15 14:24:09 +1000 |
commit | 1f0311c7c7d10c94ff7f823de9c5b2ed79368b14 (patch) | |
tree | ae708c2a25f84a04bcb04f2dbf3e8039e0f692bc /kex.c | |
parent | c5893785564498cea73cb60d2cf199490483e080 (diff) |
- markus@cvs.openbsd.org 2014/04/29 18:01:49
[auth.c authfd.c authfile.c bufaux.c cipher.c cipher.h hostfile.c]
[kex.c key.c mac.c monitor.c monitor_wrap.c myproposal.h packet.c]
[roaming_client.c ssh-agent.c ssh-keygen.c ssh-keyscan.c ssh-keysign.c]
[ssh-pkcs11.h ssh.c sshconnect.c sshconnect2.c sshd.c]
make compiling against OpenSSL optional (make OPENSSL=no);
reduces algorithms to curve25519, aes-ctr, chacha, ed25519;
allows us to explore further options; with and ok djm
Diffstat (limited to 'kex.c')
-rw-r--r-- | kex.c | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: kex.c,v 1.98 2014/02/02 03:44:31 djm Exp $ */ | 1 | /* $OpenBSD: kex.c,v 1.99 2014/04/29 18:01:49 markus Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. | 3 | * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. |
4 | * | 4 | * |
@@ -33,7 +33,9 @@ | |||
33 | #include <stdlib.h> | 33 | #include <stdlib.h> |
34 | #include <string.h> | 34 | #include <string.h> |
35 | 35 | ||
36 | #ifdef WITH_OPENSSL | ||
36 | #include <openssl/crypto.h> | 37 | #include <openssl/crypto.h> |
38 | #endif | ||
37 | 39 | ||
38 | #include "xmalloc.h" | 40 | #include "xmalloc.h" |
39 | #include "ssh2.h" | 41 | #include "ssh2.h" |
@@ -70,12 +72,13 @@ struct kexalg { | |||
70 | int hash_alg; | 72 | int hash_alg; |
71 | }; | 73 | }; |
72 | static const struct kexalg kexalgs[] = { | 74 | static const struct kexalg kexalgs[] = { |
75 | #ifdef WITH_OPENSSL | ||
73 | { KEX_DH1, KEX_DH_GRP1_SHA1, 0, SSH_DIGEST_SHA1 }, | 76 | { KEX_DH1, KEX_DH_GRP1_SHA1, 0, SSH_DIGEST_SHA1 }, |
74 | { KEX_DH14, KEX_DH_GRP14_SHA1, 0, SSH_DIGEST_SHA1 }, | 77 | { KEX_DH14, KEX_DH_GRP14_SHA1, 0, SSH_DIGEST_SHA1 }, |
75 | { KEX_DHGEX_SHA1, KEX_DH_GEX_SHA1, 0, SSH_DIGEST_SHA1 }, | 78 | { KEX_DHGEX_SHA1, KEX_DH_GEX_SHA1, 0, SSH_DIGEST_SHA1 }, |
76 | #ifdef HAVE_EVP_SHA256 | 79 | #ifdef HAVE_EVP_SHA256 |
77 | { KEX_DHGEX_SHA256, KEX_DH_GEX_SHA256, 0, SSH_DIGEST_SHA256 }, | 80 | { KEX_DHGEX_SHA256, KEX_DH_GEX_SHA256, 0, SSH_DIGEST_SHA256 }, |
78 | #endif | 81 | #endif /* HAVE_EVP_SHA256 */ |
79 | #ifdef OPENSSL_HAS_ECC | 82 | #ifdef OPENSSL_HAS_ECC |
80 | { KEX_ECDH_SHA2_NISTP256, KEX_ECDH_SHA2, | 83 | { KEX_ECDH_SHA2_NISTP256, KEX_ECDH_SHA2, |
81 | NID_X9_62_prime256v1, SSH_DIGEST_SHA256 }, | 84 | NID_X9_62_prime256v1, SSH_DIGEST_SHA256 }, |
@@ -84,12 +87,13 @@ static const struct kexalg kexalgs[] = { | |||
84 | # ifdef OPENSSL_HAS_NISTP521 | 87 | # ifdef OPENSSL_HAS_NISTP521 |
85 | { KEX_ECDH_SHA2_NISTP521, KEX_ECDH_SHA2, NID_secp521r1, | 88 | { KEX_ECDH_SHA2_NISTP521, KEX_ECDH_SHA2, NID_secp521r1, |
86 | SSH_DIGEST_SHA512 }, | 89 | SSH_DIGEST_SHA512 }, |
87 | # endif | 90 | # endif /* OPENSSL_HAS_NISTP521 */ |
88 | #endif | 91 | #endif /* OPENSSL_HAS_ECC */ |
89 | { KEX_DH1, KEX_DH_GRP1_SHA1, 0, SSH_DIGEST_SHA1 }, | 92 | { KEX_DH1, KEX_DH_GRP1_SHA1, 0, SSH_DIGEST_SHA1 }, |
93 | #endif /* WITH_OPENSSL */ | ||
90 | #ifdef HAVE_EVP_SHA256 | 94 | #ifdef HAVE_EVP_SHA256 |
91 | { KEX_CURVE25519_SHA256, KEX_C25519_SHA256, 0, SSH_DIGEST_SHA256 }, | 95 | { KEX_CURVE25519_SHA256, KEX_C25519_SHA256, 0, SSH_DIGEST_SHA256 }, |
92 | #endif | 96 | #endif /* HAVE_EVP_SHA256 */ |
93 | { NULL, -1, -1, -1}, | 97 | { NULL, -1, -1, -1}, |
94 | }; | 98 | }; |
95 | 99 | ||
@@ -615,6 +619,7 @@ kex_derive_keys(Kex *kex, u_char *hash, u_int hashlen, | |||
615 | } | 619 | } |
616 | } | 620 | } |
617 | 621 | ||
622 | #ifdef WITH_OPENSSL | ||
618 | void | 623 | void |
619 | kex_derive_keys_bn(Kex *kex, u_char *hash, u_int hashlen, const BIGNUM *secret) | 624 | kex_derive_keys_bn(Kex *kex, u_char *hash, u_int hashlen, const BIGNUM *secret) |
620 | { | 625 | { |
@@ -626,6 +631,7 @@ kex_derive_keys_bn(Kex *kex, u_char *hash, u_int hashlen, const BIGNUM *secret) | |||
626 | buffer_ptr(&shared_secret), buffer_len(&shared_secret)); | 631 | buffer_ptr(&shared_secret), buffer_len(&shared_secret)); |
627 | buffer_free(&shared_secret); | 632 | buffer_free(&shared_secret); |
628 | } | 633 | } |
634 | #endif | ||
629 | 635 | ||
630 | Newkeys * | 636 | Newkeys * |
631 | kex_get_newkeys(int mode) | 637 | kex_get_newkeys(int mode) |
@@ -637,6 +643,7 @@ kex_get_newkeys(int mode) | |||
637 | return ret; | 643 | return ret; |
638 | } | 644 | } |
639 | 645 | ||
646 | #ifdef WITH_SSH1 | ||
640 | void | 647 | void |
641 | derive_ssh1_session_id(BIGNUM *host_modulus, BIGNUM *server_modulus, | 648 | derive_ssh1_session_id(BIGNUM *host_modulus, BIGNUM *server_modulus, |
642 | u_int8_t cookie[8], u_int8_t id[16]) | 649 | u_int8_t cookie[8], u_int8_t id[16]) |
@@ -669,6 +676,7 @@ derive_ssh1_session_id(BIGNUM *host_modulus, BIGNUM *server_modulus, | |||
669 | explicit_bzero(nbuf, sizeof(nbuf)); | 676 | explicit_bzero(nbuf, sizeof(nbuf)); |
670 | explicit_bzero(obuf, sizeof(obuf)); | 677 | explicit_bzero(obuf, sizeof(obuf)); |
671 | } | 678 | } |
679 | #endif | ||
672 | 680 | ||
673 | #if defined(DEBUG_KEX) || defined(DEBUG_KEXDH) || defined(DEBUG_KEXECDH) | 681 | #if defined(DEBUG_KEX) || defined(DEBUG_KEXDH) || defined(DEBUG_KEXECDH) |
674 | void | 682 | void |