summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChelsea H. Komlo <chelsea.komlo@gmail.com>2016-11-17 22:45:24 -0500
committerChelsea H. Komlo <chelsea.komlo@gmail.com>2016-11-24 10:01:03 -0500
commit276d07a88a3b595aff9e28c7f1862563d2751b55 (patch)
treec5e66e2eecad627ba0d1ac02b19b040fea467350 /src
parent4614f8e6816d559f8fbe9ae0f42d751d3fb95c77 (diff)
downloadtor-276d07a88a3b595aff9e28c7f1862563d2751b55.tar.gz
tor-276d07a88a3b595aff9e28c7f1862563d2751b55.zip
crypto_digest returns expected error value of -1
Diffstat (limited to 'src')
-rw-r--r--src/common/crypto.c10
-rw-r--r--src/or/rendservice.c2
-rw-r--r--src/or/routerparse.c2
3 files changed, 8 insertions, 6 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index fff516cc8e..f59b6745ba 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -1506,7 +1506,7 @@ crypto_pk_get_hashed_fingerprint(crypto_pk_t *pk, char *fp_out)
if (crypto_pk_get_digest(pk, digest)) {
return -1;
}
- if (crypto_digest(hashed_digest, digest, DIGEST_LEN)) {
+ if (crypto_digest(hashed_digest, digest, DIGEST_LEN) < 0) {
return -1;
}
base16_encode(fp_out, FINGERPRINT_LEN + 1, hashed_digest, DIGEST_LEN);
@@ -1700,14 +1700,16 @@ crypto_cipher_decrypt_with_iv(const char *key,
/** Compute the SHA1 digest of the <b>len</b> bytes on data stored in
* <b>m</b>. Write the DIGEST_LEN byte result into <b>digest</b>.
- * Return 0 on success, 1 on failure.
+ * Return 0 on success, -1 on failure.
*/
int
crypto_digest(char *digest, const char *m, size_t len)
{
tor_assert(m);
tor_assert(digest);
- return (SHA1((const unsigned char*)m,len,(unsigned char*)digest) == NULL);
+ if(SHA1((const unsigned char*)m,len,(unsigned char*)digest) == NULL)
+ return -1;
+ return 0;
}
/** Compute a 256-bit digest of <b>len</b> bytes in data stored in <b>m</b>,
@@ -2628,7 +2630,7 @@ crypto_expand_key_material_TAP(const uint8_t *key_in, size_t key_in_len,
for (cp = key_out, i=0; cp < key_out+key_out_len;
++i, cp += DIGEST_LEN) {
tmp[key_in_len] = i;
- if (crypto_digest((char*)digest, (const char *)tmp, key_in_len+1))
+ if (crypto_digest((char*)digest, (const char *)tmp, key_in_len+1) < 0)
goto exit;
memcpy(cp, digest, MIN(DIGEST_LEN, key_out_len-(cp-key_out)));
}
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index 8ffd0bc319..4d25251f08 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -3084,7 +3084,7 @@ rend_service_intro_has_opened(origin_circuit_t *circuit)
len += 2;
memcpy(auth, circuit->cpath->prev->rend_circ_nonce, DIGEST_LEN);
memcpy(auth+DIGEST_LEN, "INTRODUCE", 9);
- if (crypto_digest(buf+len, auth, DIGEST_LEN+9))
+ if (crypto_digest(buf+len, auth, DIGEST_LEN+9) < 0)
goto err;
len += 20;
note_crypto_pk_op(REND_SERVER);
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 2cfd3fc58a..8f8d2b8cd9 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -4536,7 +4536,7 @@ router_get_hash_impl(const char *s, size_t s_len, char *digest,
return -1;
if (alg == DIGEST_SHA1) {
- if (crypto_digest(digest, start, end-start)) {
+ if (crypto_digest(digest, start, end-start) < 0) {
log_warn(LD_BUG,"couldn't compute digest");
return -1;
}