diff options
author | Damien Miller <djm@mindrot.org> | 2014-01-10 10:58:53 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2014-01-10 10:58:53 +1100 |
commit | b3051d01e505c9c2dc00faab472a0d06fa6b0e65 (patch) | |
tree | c0ca49b5fc4e5e1a066157b4dbd9c68cfcd41d63 /kexgex.c | |
parent | e00e413dd16eb747fb2c15a099971d91c13cf70f (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 'kexgex.c')
-rw-r--r-- | kexgex.c | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: kexgex.c,v 1.27 2006/08/03 03:34:42 deraadt Exp $ */ | 1 | /* $OpenBSD: kexgex.c,v 1.28 2014/01/09 23:20:00 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2000 Niels Provos. All rights reserved. | 3 | * Copyright (c) 2000 Niels Provos. All rights reserved. |
4 | * Copyright (c) 2001 Markus Friedl. All rights reserved. | 4 | * Copyright (c) 2001 Markus Friedl. All rights reserved. |
@@ -36,10 +36,12 @@ | |||
36 | #include "cipher.h" | 36 | #include "cipher.h" |
37 | #include "kex.h" | 37 | #include "kex.h" |
38 | #include "ssh2.h" | 38 | #include "ssh2.h" |
39 | #include "digest.h" | ||
40 | #include "log.h" | ||
39 | 41 | ||
40 | void | 42 | void |
41 | kexgex_hash( | 43 | kexgex_hash( |
42 | const EVP_MD *evp_md, | 44 | int hash_alg, |
43 | char *client_version_string, | 45 | char *client_version_string, |
44 | char *server_version_string, | 46 | char *server_version_string, |
45 | char *ckexinit, int ckexinitlen, | 47 | char *ckexinit, int ckexinitlen, |
@@ -52,8 +54,7 @@ kexgex_hash( | |||
52 | u_char **hash, u_int *hashlen) | 54 | u_char **hash, u_int *hashlen) |
53 | { | 55 | { |
54 | Buffer b; | 56 | Buffer b; |
55 | static u_char digest[EVP_MAX_MD_SIZE]; | 57 | static u_char digest[SSH_DIGEST_MAX_LENGTH]; |
56 | EVP_MD_CTX md; | ||
57 | 58 | ||
58 | buffer_init(&b); | 59 | buffer_init(&b); |
59 | buffer_put_cstring(&b, client_version_string); | 60 | buffer_put_cstring(&b, client_version_string); |
@@ -84,15 +85,14 @@ kexgex_hash( | |||
84 | #ifdef DEBUG_KEXDH | 85 | #ifdef DEBUG_KEXDH |
85 | buffer_dump(&b); | 86 | buffer_dump(&b); |
86 | #endif | 87 | #endif |
87 | 88 | if (ssh_digest_buffer(hash_alg, &b, digest, sizeof(digest)) != 0) | |
88 | EVP_DigestInit(&md, evp_md); | 89 | fatal("%s: ssh_digest_buffer failed", __func__); |
89 | EVP_DigestUpdate(&md, buffer_ptr(&b), buffer_len(&b)); | ||
90 | EVP_DigestFinal(&md, digest, NULL); | ||
91 | 90 | ||
92 | buffer_free(&b); | 91 | buffer_free(&b); |
93 | *hash = digest; | 92 | |
94 | *hashlen = EVP_MD_size(evp_md); | 93 | #ifdef DEBUG_KEX |
95 | #ifdef DEBUG_KEXDH | 94 | dump_digest("hash", digest, ssh_digest_bytes(hash_alg)); |
96 | dump_digest("hash", digest, *hashlen); | ||
97 | #endif | 95 | #endif |
96 | *hash = digest; | ||
97 | *hashlen = ssh_digest_bytes(hash_alg); | ||
98 | } | 98 | } |