]> andersk Git - openssh.git/blobdiff - kexdh.c
- markus@cvs.openbsd.org 2001/11/07 22:53:21
[openssh.git] / kexdh.c
diff --git a/kexdh.c b/kexdh.c
index 7b6a22040a3e33016817ecec1e0d76dcc0c7aee0..b850a1a226ef3749b073094a1a4f15a39c16e8b9 100644 (file)
--- a/kexdh.c
+++ b/kexdh.c
@@ -23,7 +23,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: kexdh.c,v 1.3 2001/04/04 09:48:34 markus Exp $");
+RCSID("$OpenBSD: kexdh.c,v 1.7 2001/09/17 19:27:15 stevesk Exp $");
 
 #include <openssl/crypto.h>
 #include <openssl/bn.h>
@@ -38,13 +38,13 @@ RCSID("$OpenBSD: kexdh.c,v 1.3 2001/04/04 09:48:34 markus Exp $");
 #include "dh.h"
 #include "ssh2.h"
 
-u_char *
+static u_char *
 kex_dh_hash(
     char *client_version_string,
     char *server_version_string,
     char *ckexinit, int ckexinitlen,
     char *skexinit, int skexinitlen,
-    char *serverhostkeyblob, int sbloblen,
+    u_char *serverhostkeyblob, int sbloblen,
     BIGNUM *client_dh_pub,
     BIGNUM *server_dh_pub,
     BIGNUM *shared_secret)
@@ -55,8 +55,8 @@ kex_dh_hash(
        EVP_MD_CTX md;
 
        buffer_init(&b);
-       buffer_put_string(&b, client_version_string, strlen(client_version_string));
-       buffer_put_string(&b, server_version_string, strlen(server_version_string));
+       buffer_put_cstring(&b, client_version_string);
+       buffer_put_cstring(&b, server_version_string);
 
        /* kexinit messages: fake header: len+SSH2_MSG_KEXINIT */
        buffer_put_int(&b, ckexinitlen+1);
@@ -88,13 +88,13 @@ kex_dh_hash(
 
 /* client */
 
-void
+static void
 kexdh_client(Kex *kex)
 {
        BIGNUM *dh_server_pub = NULL, *shared_secret = NULL;
        DH *dh;
        Key *server_host_key;
-       char *server_host_key_blob = NULL, *signature = NULL;
+       u_char *server_host_key_blob = NULL, *signature = NULL;
        u_char *kbuf, *hash;
        u_int klen, kout, slen, sbloblen;
        int dlen, plen;
@@ -123,9 +123,10 @@ kexdh_client(Kex *kex)
        if (server_host_key == NULL)
                fatal("cannot decode server_host_key_blob");
 
-       if (kex->check_host_key == NULL)
-               fatal("cannot check server_host_key");
-       kex->check_host_key(server_host_key);
+       if (kex->verify_host_key == NULL)
+               fatal("cannot verify server_host_key");
+       if (kex->verify_host_key(server_host_key) == -1)
+               fatal("server_host_key verification failed");
 
        /* DH paramter f, server public DH key */
        dh_server_pub = BN_new();
@@ -173,7 +174,7 @@ kexdh_client(Kex *kex)
        BN_free(dh_server_pub);
        DH_free(dh);
 
-       if (key_verify(server_host_key, (u_char *)signature, slen, hash, 20) != 1)
+       if (key_verify(server_host_key, signature, slen, hash, 20) != 1)
                fatal("key_verify failed for server_host_key");
        key_free(server_host_key);
        xfree(signature);
@@ -192,7 +193,7 @@ kexdh_client(Kex *kex)
 
 /* server */
 
-void
+static void
 kexdh_server(Kex *kex)
 {
        BIGNUM *shared_secret = NULL, *dh_client_pub = NULL;
@@ -256,7 +257,7 @@ kexdh_server(Kex *kex)
            kex->server_version_string,
            buffer_ptr(&kex->peer), buffer_len(&kex->peer),
            buffer_ptr(&kex->my), buffer_len(&kex->my),
-           (char *)server_host_key_blob, sbloblen,
+           server_host_key_blob, sbloblen,
            dh_client_pub,
            dh->pub_key,
            shared_secret
@@ -279,9 +280,9 @@ kexdh_server(Kex *kex)
 
        /* send server hostkey, DH pubkey 'f' and singed H */
        packet_start(SSH2_MSG_KEXDH_REPLY);
-       packet_put_string((char *)server_host_key_blob, sbloblen);
+       packet_put_string(server_host_key_blob, sbloblen);
        packet_put_bignum2(dh->pub_key);        /* f */
-       packet_put_string((char *)signature, slen);
+       packet_put_string(signature, slen);
        packet_send();
 
        xfree(signature);
This page took 0.035602 seconds and 4 git commands to generate.