summaryrefslogtreecommitdiff
path: root/kexecdh.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2014-01-10 10:58:53 +1100
committerDamien Miller <djm@mindrot.org>2014-01-10 10:58:53 +1100
commitb3051d01e505c9c2dc00faab472a0d06fa6b0e65 (patch)
treec0ca49b5fc4e5e1a066157b4dbd9c68cfcd41d63 /kexecdh.c
parente00e413dd16eb747fb2c15a099971d91c13cf70f (diff)
- djm@cvs.openbsd.org 2014/01/09 23:20:00
[digest.c digest.h hostfile.c kex.c kex.h kexc25519.c kexc25519c.c] [kexc25519s.c kexdh.c kexecdh.c kexecdhc.c kexecdhs.c kexgex.c kexgexc.c] [kexgexs.c key.c key.h roaming_client.c roaming_common.c schnorr.c] [schnorr.h ssh-dss.c ssh-ecdsa.c ssh-rsa.c sshconnect2.c] Introduce digest API and use it to perform all hashing operations rather than calling OpenSSL EVP_Digest* directly. Will make it easier to build a reduced-feature OpenSSH without OpenSSL in future; feedback, ok markus@
Diffstat (limited to 'kexecdh.c')
-rw-r--r--kexecdh.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/kexecdh.c b/kexecdh.c
index c948fe20a..c52c5e234 100644
--- a/kexecdh.c
+++ b/kexecdh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kexecdh.c,v 1.4 2013/04/19 01:06:50 djm Exp $ */ 1/* $OpenBSD: kexecdh.c,v 1.5 2014/01/09 23:20:00 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 * Copyright (c) 2010 Damien Miller. All rights reserved. 4 * Copyright (c) 2010 Damien Miller. All rights reserved.
@@ -44,10 +44,11 @@
44#include "cipher.h" 44#include "cipher.h"
45#include "kex.h" 45#include "kex.h"
46#include "log.h" 46#include "log.h"
47#include "digest.h"
47 48
48void 49void
49kex_ecdh_hash( 50kex_ecdh_hash(
50 const EVP_MD *evp_md, 51 int hash_alg,
51 const EC_GROUP *ec_group, 52 const EC_GROUP *ec_group,
52 char *client_version_string, 53 char *client_version_string,
53 char *server_version_string, 54 char *server_version_string,
@@ -60,8 +61,7 @@ kex_ecdh_hash(
60 u_char **hash, u_int *hashlen) 61 u_char **hash, u_int *hashlen)
61{ 62{
62 Buffer b; 63 Buffer b;
63 EVP_MD_CTX md; 64 static u_char digest[SSH_DIGEST_MAX_LENGTH];
64 static u_char digest[EVP_MAX_MD_SIZE];
65 65
66 buffer_init(&b); 66 buffer_init(&b);
67 buffer_put_cstring(&b, client_version_string); 67 buffer_put_cstring(&b, client_version_string);
@@ -83,17 +83,15 @@ kex_ecdh_hash(
83#ifdef DEBUG_KEX 83#ifdef DEBUG_KEX
84 buffer_dump(&b); 84 buffer_dump(&b);
85#endif 85#endif
86 EVP_DigestInit(&md, evp_md); 86 if (ssh_digest_buffer(hash_alg, &b, digest, sizeof(digest)) != 0)
87 EVP_DigestUpdate(&md, buffer_ptr(&b), buffer_len(&b)); 87 fatal("%s: ssh_digest_buffer failed", __func__);
88 EVP_DigestFinal(&md, digest, NULL);
89 88
90 buffer_free(&b); 89 buffer_free(&b);
91 90
92#ifdef DEBUG_KEX 91#ifdef DEBUG_KEX
93 dump_digest("hash", digest, EVP_MD_size(evp_md)); 92 dump_digest("hash", digest, ssh_digest_bytes(hash_alg));
94#endif 93#endif
95 *hash = digest; 94 *hash = digest;
96 *hashlen = EVP_MD_size(evp_md); 95 *hashlen = ssh_digest_bytes(hash_alg);
97} 96}
98
99#endif /* OPENSSL_HAS_ECC */ 97#endif /* OPENSSL_HAS_ECC */