summaryrefslogtreecommitdiff
path: root/kexc25519.c
diff options
context:
space:
mode:
Diffstat (limited to 'kexc25519.c')
-rw-r--r--kexc25519.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/kexc25519.c b/kexc25519.c
index 348a7d50d..8dd363991 100644
--- a/kexc25519.c
+++ b/kexc25519.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kexc25519.c,v 1.2 2013/11/02 22:02:14 markus Exp $ */ 1/* $OpenBSD: kexc25519.c,v 1.3 2014/01/09 23:20:00 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2001, 2013 Markus Friedl. All rights reserved. 3 * Copyright (c) 2001, 2013 Markus Friedl. All rights reserved.
4 * Copyright (c) 2010 Damien Miller. All rights reserved. 4 * Copyright (c) 2010 Damien Miller. All rights reserved.
@@ -41,6 +41,7 @@
41#include "cipher.h" 41#include "cipher.h"
42#include "kex.h" 42#include "kex.h"
43#include "log.h" 43#include "log.h"
44#include "digest.h"
44 45
45extern int crypto_scalarmult_curve25519(u_char a[CURVE25519_SIZE], 46extern int crypto_scalarmult_curve25519(u_char a[CURVE25519_SIZE],
46 const u_char b[CURVE25519_SIZE], const u_char c[CURVE25519_SIZE]) 47 const u_char b[CURVE25519_SIZE], const u_char c[CURVE25519_SIZE])
@@ -78,7 +79,7 @@ kexc25519_shared_key(const u_char key[CURVE25519_SIZE],
78 79
79void 80void
80kex_c25519_hash( 81kex_c25519_hash(
81 const EVP_MD *evp_md, 82 int hash_alg,
82 char *client_version_string, 83 char *client_version_string,
83 char *server_version_string, 84 char *server_version_string,
84 char *ckexinit, int ckexinitlen, 85 char *ckexinit, int ckexinitlen,
@@ -90,8 +91,7 @@ kex_c25519_hash(
90 u_char **hash, u_int *hashlen) 91 u_char **hash, u_int *hashlen)
91{ 92{
92 Buffer b; 93 Buffer b;
93 EVP_MD_CTX md; 94 static u_char digest[SSH_DIGEST_MAX_LENGTH];
94 static u_char digest[EVP_MAX_MD_SIZE];
95 95
96 buffer_init(&b); 96 buffer_init(&b);
97 buffer_put_cstring(&b, client_version_string); 97 buffer_put_cstring(&b, client_version_string);
@@ -113,15 +113,14 @@ kex_c25519_hash(
113#ifdef DEBUG_KEX 113#ifdef DEBUG_KEX
114 buffer_dump(&b); 114 buffer_dump(&b);
115#endif 115#endif
116 EVP_DigestInit(&md, evp_md); 116 if (ssh_digest_buffer(hash_alg, &b, digest, sizeof(digest)) != 0)
117 EVP_DigestUpdate(&md, buffer_ptr(&b), buffer_len(&b)); 117 fatal("%s: digest_buffer failed", __func__);
118 EVP_DigestFinal(&md, digest, NULL);
119 118
120 buffer_free(&b); 119 buffer_free(&b);
121 120
122#ifdef DEBUG_KEX 121#ifdef DEBUG_KEX
123 dump_digest("hash", digest, EVP_MD_size(evp_md)); 122 dump_digest("hash", digest, ssh_digest_bytes(hash_alg));
124#endif 123#endif
125 *hash = digest; 124 *hash = digest;
126 *hashlen = EVP_MD_size(evp_md); 125 *hashlen = ssh_digest_bytes(hash_alg);
127} 126}