diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | digest-openssl.c | 19 |
2 files changed, 16 insertions, 8 deletions
@@ -20,6 +20,11 @@ | |||
20 | ssh-add fatal()s part-way through (e.g. when listing keys from an | 20 | ssh-add fatal()s part-way through (e.g. when listing keys from an |
21 | agent that supports key types that ssh-add doesn't); | 21 | agent that supports key types that ssh-add doesn't); |
22 | bz#2234, reported by Phil Pennock | 22 | bz#2234, reported by Phil Pennock |
23 | - djm@cvs.openbsd.org 2014/07/03 03:26:43 | ||
24 | [digest-openssl.c] | ||
25 | use EVP_Digest() for one-shot hash instead of creating, updating, | ||
26 | finalising and destroying a context. | ||
27 | bz#2231, based on patch from Timo Teras | ||
23 | 28 | ||
24 | 20140702 | 29 | 20140702 |
25 | - OpenBSD CVS Sync | 30 | - OpenBSD CVS Sync |
diff --git a/digest-openssl.c b/digest-openssl.c index 7ec6bd260..6e8bf15d3 100644 --- a/digest-openssl.c +++ b/digest-openssl.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: digest-openssl.c,v 1.3 2014/06/24 01:13:21 djm Exp $ */ | 1 | /* $OpenBSD: digest-openssl.c,v 1.4 2014/07/03 03:26:43 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2013 Damien Miller <djm@mindrot.org> | 3 | * Copyright (c) 2013 Damien Miller <djm@mindrot.org> |
4 | * | 4 | * |
@@ -153,15 +153,18 @@ ssh_digest_free(struct ssh_digest_ctx *ctx) | |||
153 | int | 153 | int |
154 | ssh_digest_memory(int alg, const void *m, size_t mlen, u_char *d, size_t dlen) | 154 | ssh_digest_memory(int alg, const void *m, size_t mlen, u_char *d, size_t dlen) |
155 | { | 155 | { |
156 | struct ssh_digest_ctx *ctx = ssh_digest_start(alg); | 156 | const struct ssh_digest *digest = ssh_digest_by_alg(alg); |
157 | int r; | 157 | u_int mdlen; |
158 | 158 | ||
159 | if (ctx == NULL) | 159 | if (digest == NULL) |
160 | return SSH_ERR_INVALID_ARGUMENT; | ||
161 | if (dlen > UINT_MAX) | ||
160 | return SSH_ERR_INVALID_ARGUMENT; | 162 | return SSH_ERR_INVALID_ARGUMENT; |
161 | if ((r = ssh_digest_update(ctx, m, mlen) != 0) || | 163 | if (dlen < digest->digest_len) |
162 | (r = ssh_digest_final(ctx, d, dlen) != 0)) | 164 | return SSH_ERR_INVALID_ARGUMENT; |
163 | return r; | 165 | mdlen = dlen; |
164 | ssh_digest_free(ctx); | 166 | if (!EVP_Digest(m, mlen, d, &mdlen, digest->mdfunc(), NULL)) |
167 | return SSH_ERR_LIBCRYPTO_ERROR; | ||
165 | return 0; | 168 | return 0; |
166 | } | 169 | } |
167 | 170 | ||