diff options
author | Nick Mathewson <nickm@torproject.org> | 2016-02-10 15:31:43 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2016-02-10 15:32:12 -0500 |
commit | 9746aed2baffeb3788552f8cdedc5611ab2f91b7 (patch) | |
tree | 210ad9e3e11b2a013668bc39f46bfe5ba6bf6925 /src/common/crypto.c | |
parent | 8a4bba06d27c99e7c1e7930761b3998a27787ce9 (diff) | |
download | tor-9746aed2baffeb3788552f8cdedc5611ab2f91b7.tar.gz tor-9746aed2baffeb3788552f8cdedc5611ab2f91b7.zip |
Another automated rename.
Also simplify crypto_common_digests() to have no loop.
Diffstat (limited to 'src/common/crypto.c')
-rw-r--r-- | src/common/crypto.c | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c index 2ebf203110..6c40c6eb15 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -1323,7 +1323,7 @@ crypto_pk_get_digest(const crypto_pk_t *pk, char *digest_out) /** Compute all digests of the DER encoding of <b>pk</b>, and store them * in <b>digests_out</b>. Return 0 on success, -1 on failure. */ int -crypto_pk_get_all_digests(crypto_pk_t *pk, common_digests_t *digests_out) +crypto_pk_get_common_digests(crypto_pk_t *pk, common_digests_t *digests_out) { unsigned char *buf = NULL; int len; @@ -1650,28 +1650,13 @@ crypto_digest512(char *digest, const char *m, size_t len, int crypto_common_digests(common_digests_t *ds_out, const char *m, size_t len) { - int i; tor_assert(ds_out); 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_COMMON_DIGEST_ALGORITHMS; ++i) { - switch (i) { - case DIGEST_SHA256: /* FALLSTHROUGH */ - case DIGEST_SHA3_256: - if (crypto_digest256(ds_out->d[i], m, len, i) < 0) - return -1; - 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; - default: - return -1; - } - } + if (crypto_digest256(ds_out->d[DIGEST_SHA256], m, len, DIGEST_SHA256) < 0) + return -1; + return 0; } |