diff options
author | Nick Mathewson <nickm@torproject.org> | 2016-01-27 13:10:17 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2016-01-27 13:10:17 -0500 |
commit | 39b597c2fd8b45ff61573c70c36e8a4846cf3a0e (patch) | |
tree | 3cdee49e030a2cf683a2e117472538987d9d76f9 /src/common/crypto.c | |
parent | 4770db8e992365c12c652f53a7d3fd84bae25bcb (diff) | |
download | tor-39b597c2fd8b45ff61573c70c36e8a4846cf3a0e.tar.gz tor-39b597c2fd8b45ff61573c70c36e8a4846cf3a0e.zip |
Restrict the meaning of digests_t to sha1+sha256.
This saves CPU and RAM when handling consensuses and x509 certs.
Closes ticket 17795; bug not in any released tor.
Diffstat (limited to 'src/common/crypto.c')
-rw-r--r-- | src/common/crypto.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c index a42c461b14..9f1ce93f98 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -1655,7 +1655,7 @@ crypto_digest_all(digests_t *ds_out, const char *m, size_t len) memset(ds_out, 0, sizeof(*ds_out)); if (crypto_digest(ds_out->d[DIGEST_SHA1], m, len) < 0) return -1; - for (i = DIGEST_SHA256; i < N_DIGEST_ALGORITHMS; ++i) { + for (i = DIGEST_SHA256; i < N_COMMON_DIGEST_ALGORITHMS; ++i) { switch (i) { case DIGEST_SHA256: /* FALLSTHROUGH */ case DIGEST_SHA3_256: @@ -1664,6 +1664,7 @@ crypto_digest_all(digests_t *ds_out, const char *m, size_t len) break; case DIGEST_SHA512: case DIGEST_SHA3_512: /* FALLSTHROUGH */ + tor_assert(0); /* These won't fit. */ if (crypto_digest512(ds_out->d[i], m, len, i) < 0) return -1; break; |