summaryrefslogtreecommitdiff
path: root/roaming_common.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 /roaming_common.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 'roaming_common.c')
-rw-r--r--roaming_common.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/roaming_common.c b/roaming_common.c
index 86b3372ef..787bef04a 100644
--- a/roaming_common.c
+++ b/roaming_common.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: roaming_common.c,v 1.11 2013/11/03 10:37:19 djm Exp $ */ 1/* $OpenBSD: roaming_common.c,v 1.12 2014/01/09 23:20:00 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2004-2009 AppGate Network Security AB 3 * Copyright (c) 2004-2009 AppGate Network Security AB
4 * 4 *
@@ -36,6 +36,7 @@
36#include "cipher.h" 36#include "cipher.h"
37#include "buffer.h" 37#include "buffer.h"
38#include "roaming.h" 38#include "roaming.h"
39#include "digest.h"
39 40
40static size_t out_buf_size = 0; 41static size_t out_buf_size = 0;
41static char *out_buf = NULL; 42static char *out_buf = NULL;
@@ -225,9 +226,7 @@ resend_bytes(int fd, u_int64_t *offset)
225void 226void
226calculate_new_key(u_int64_t *key, u_int64_t cookie, u_int64_t challenge) 227calculate_new_key(u_int64_t *key, u_int64_t cookie, u_int64_t challenge)
227{ 228{
228 const EVP_MD *md = EVP_sha1(); 229 u_char hash[SSH_DIGEST_MAX_LENGTH];
229 EVP_MD_CTX ctx;
230 u_char hash[EVP_MAX_MD_SIZE];
231 Buffer b; 230 Buffer b;
232 231
233 buffer_init(&b); 232 buffer_init(&b);
@@ -235,12 +234,11 @@ calculate_new_key(u_int64_t *key, u_int64_t cookie, u_int64_t challenge)
235 buffer_put_int64(&b, cookie); 234 buffer_put_int64(&b, cookie);
236 buffer_put_int64(&b, challenge); 235 buffer_put_int64(&b, challenge);
237 236
238 EVP_DigestInit(&ctx, md); 237 if (ssh_digest_buffer(SSH_DIGEST_SHA1, &b, hash, sizeof(hash)) != 0)
239 EVP_DigestUpdate(&ctx, buffer_ptr(&b), buffer_len(&b)); 238 fatal("%s: digest_buffer failed", __func__);
240 EVP_DigestFinal(&ctx, hash, NULL);
241 239
242 buffer_clear(&b); 240 buffer_clear(&b);
243 buffer_append(&b, hash, EVP_MD_size(md)); 241 buffer_append(&b, hash, ssh_digest_bytes(SSH_DIGEST_SHA1));
244 *key = buffer_get_int64(&b); 242 *key = buffer_get_int64(&b);
245 buffer_free(&b); 243 buffer_free(&b);
246} 244}