]> andersk Git - openssh.git/blobdiff - kexgex.c
- markus@cvs.openbsd.org 2002/06/08 05:07:56
[openssh.git] / kexgex.c
index b50a7114f29116aa11c858094221f29af07002d3..2d4a58153151753d56e9cd24e025ad4897bd212a 100644 (file)
--- a/kexgex.c
+++ b/kexgex.c
@@ -24,7 +24,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: kexgex.c,v 1.16 2002/01/25 22:07:40 markus Exp $");
+RCSID("$OpenBSD: kexgex.c,v 1.22 2002/03/24 17:27:03 stevesk Exp $");
 
 #include <openssl/bn.h>
 
@@ -38,6 +38,7 @@ RCSID("$OpenBSD: kexgex.c,v 1.16 2002/01/25 22:07:40 markus Exp $");
 #include "dh.h"
 #include "ssh2.h"
 #include "compat.h"
+#include "monitor_wrap.h"
 
 static u_char *
 kexgex_hash(
@@ -53,7 +54,7 @@ kexgex_hash(
 {
        Buffer b;
        static u_char digest[EVP_MAX_MD_SIZE];
-       EVP_MD *evp_md = EVP_sha1();
+       const EVP_MD *evp_md = EVP_sha1();
        EVP_MD_CTX md;
 
        buffer_init(&b);
@@ -176,7 +177,8 @@ kexgex_client(Kex *kex)
        server_host_key = key_from_blob(server_host_key_blob, sbloblen);
        if (server_host_key == NULL)
                fatal("cannot decode server_host_key_blob");
-
+       if (server_host_key->type != kex->hostkey_type)
+               fatal("type mismatch for decoded server_host_key_blob");
        if (kex->verify_host_key == NULL)
                fatal("cannot verify server_host_key");
        if (kex->verify_host_key(server_host_key) == -1)
@@ -258,10 +260,10 @@ kexgex_server(Kex *kex)
 {
        BIGNUM *shared_secret = NULL, *dh_client_pub = NULL;
        Key *server_host_key;
-       DH *dh = dh;
+       DH *dh;
        u_char *kbuf, *hash, *signature = NULL, *server_host_key_blob = NULL;
-       u_int sbloblen, klen, kout;
-       int min = -1, max = -1, nbits = -1, type, slen;
+       u_int sbloblen, klen, kout, slen;
+       int min = -1, max = -1, nbits = -1, type;
 
        if (kex->load_host_key == NULL)
                fatal("Cannot load hostkey");
@@ -295,7 +297,8 @@ kexgex_server(Kex *kex)
                fatal("DH_GEX_REQUEST, bad parameters: %d !< %d !< %d",
                    min, nbits, max);
 
-       dh = choose_dh(min, nbits, max);
+       /* Contact privileged parent */
+       dh = PRIVSEP(choose_dh(min, nbits, max));
        if (dh == NULL)
                packet_disconnect("Protocol error: no matching DH grp found");
 
@@ -318,6 +321,7 @@ kexgex_server(Kex *kex)
        if ((dh_client_pub = BN_new()) == NULL)
                fatal("dh_client_pub == NULL");
        packet_get_bignum2(dh_client_pub);
+       packet_check_eom();
 
 #ifdef DEBUG_KEXDH
        fprintf(stderr, "dh_client_pub= ");
@@ -377,7 +381,7 @@ kexgex_server(Kex *kex)
 
        /* sign H */
        /* XXX hashlen depends on KEX */
-       key_sign(server_host_key, &signature, &slen, hash, 20);
+       PRIVSEP(key_sign(server_host_key, &signature, &slen, hash, 20));
 
        /* destroy_sensitive_data(); */
 
@@ -388,6 +392,7 @@ kexgex_server(Kex *kex)
        packet_put_bignum2(dh->pub_key);        /* f */
        packet_put_string(signature, slen);
        packet_send();
+
        xfree(signature);
        xfree(server_host_key_blob);
        /* have keys, free DH */
This page took 0.041392 seconds and 4 git commands to generate.