summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-08-25 11:39:38 -0400
committerNick Mathewson <nickm@torproject.org>2017-08-25 11:39:38 -0400
commitb91dce9454c3db669a07968b25a4fa03d8526917 (patch)
treed1e4aa46835978b63628a1dbd3e5782140cb72fa /src/or
parent0de3147bf1b7a76b99ced69bde6e2169bb9a0caa (diff)
parent6069c829f90576c04a0802d2a108378a2bbabb7a (diff)
downloadtor-b91dce9454c3db669a07968b25a4fa03d8526917.tar.gz
tor-b91dce9454c3db669a07968b25a4fa03d8526917.zip
Merge branch 'maint-0.3.1'
Diffstat (limited to 'src/or')
-rw-r--r--src/or/connection_or.c4
-rw-r--r--src/or/hibernate.c5
-rw-r--r--src/or/rendclient.c5
-rw-r--r--src/or/rendcommon.c5
-rw-r--r--src/or/rendservice.c9
-rw-r--r--src/or/router.c14
-rw-r--r--src/or/routerkeys.c4
-rw-r--r--src/or/routerparse.c5
8 files changed, 42 insertions, 9 deletions
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index 7c929e5272..c776afe942 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -1548,7 +1548,9 @@ connection_or_check_valid_tls_handshake(or_connection_t *conn,
}
if (identity_rcvd) {
- crypto_pk_get_digest(identity_rcvd, digest_rcvd_out);
+ if (crypto_pk_get_digest(identity_rcvd, digest_rcvd_out) < 0) {
+ return -1;
+ }
} else {
memset(digest_rcvd_out, 0, DIGEST_LEN);
}
diff --git a/src/or/hibernate.c b/src/or/hibernate.c
index f54109fc90..8c48a6f47d 100644
--- a/src/or/hibernate.c
+++ b/src/or/hibernate.c
@@ -587,7 +587,10 @@ accounting_set_wakeup_time(void)
char buf[ISO_TIME_LEN+1];
format_iso_time(buf, interval_start_time);
- crypto_pk_get_digest(get_server_identity_key(), digest);
+ if (crypto_pk_get_digest(get_server_identity_key(), digest) < 0) {
+ log_err(LD_BUG, "Error getting our key's digest.");
+ tor_assert(0);
+ }
d_env = crypto_digest_new();
crypto_digest_add_bytes(d_env, buf, ISO_TIME_LEN);
diff --git a/src/or/rendclient.c b/src/or/rendclient.c
index 0f430d1f88..55f79c50fb 100644
--- a/src/or/rendclient.c
+++ b/src/or/rendclient.c
@@ -227,6 +227,11 @@ rend_client_send_introduction(origin_circuit_t *introcirc,
klen = crypto_pk_asn1_encode(extend_info->onion_key,
tmp+v3_shift+7+DIGEST_LEN+2,
sizeof(tmp)-(v3_shift+7+DIGEST_LEN+2));
+ if (klen < 0) {
+ log_warn(LD_BUG,"Internal error: can't encode public key.");
+ status = -2;
+ goto perm_err;
+ }
set_uint16(tmp+v3_shift+7+DIGEST_LEN, htons(klen));
memcpy(tmp+v3_shift+7+DIGEST_LEN+2+klen, rendcirc->rend_data->rend_cookie,
REND_COOKIE_LEN);
diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c
index f7ae7c61f1..458a90058f 100644
--- a/src/or/rendcommon.c
+++ b/src/or/rendcommon.c
@@ -480,7 +480,10 @@ rend_encode_v2_descriptors(smartlist_t *descs_out,
tor_assert(descriptor_cookie);
}
/* Obtain service_id from public key. */
- crypto_pk_get_digest(service_key, service_id);
+ if (crypto_pk_get_digest(service_key, service_id) < 0) {
+ log_warn(LD_BUG, "Couldn't compute service key digest.");
+ return -1;
+ }
/* Calculate current time-period. */
time_period = get_time_period(now, period, service_id);
/* Determine how many seconds the descriptor will be valid. */
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index 8dbab2e2a7..99ba9b3d83 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -2666,7 +2666,14 @@ rend_service_decrypt_intro(
/* Check that this cell actually matches this service key */
/* first DIGEST_LEN bytes of request is intro or service pk digest */
- crypto_pk_get_digest(key, (char *)key_digest);
+ if (crypto_pk_get_digest(key, (char *)key_digest) < 0) {
+ if (err_msg_out)
+ *err_msg_out = tor_strdup("Couldn't compute RSA digest.");
+ log_warn(LD_BUG, "Couldn't compute key digest.");
+ status = -7;
+ goto err;
+ }
+
if (tor_memneq(key_digest, intro->pk, DIGEST_LEN)) {
if (err_msg_out) {
base32_encode(service_id, REND_SERVICE_ID_LEN_BASE32 + 1,
diff --git a/src/or/router.c b/src/or/router.c
index 7fad572657..c8e78659c0 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -257,7 +257,11 @@ set_server_identity_key(crypto_pk_t *k)
{
crypto_pk_free(server_identitykey);
server_identitykey = k;
- crypto_pk_get_digest(server_identitykey, server_identitykey_digest);
+ if (crypto_pk_get_digest(server_identitykey,
+ server_identitykey_digest) < 0) {
+ log_err(LD_BUG, "Couldn't compute our own identity key digest.");
+ tor_assert(0);
+ }
}
/** Make sure that we have set up our identity keys to match or not match as
@@ -956,8 +960,12 @@ init_keys(void)
}
cert = get_my_v3_authority_cert();
if (cert) {
- crypto_pk_get_digest(get_my_v3_authority_cert()->identity_key,
- v3_digest);
+ if (crypto_pk_get_digest(get_my_v3_authority_cert()->identity_key,
+ v3_digest) < 0) {
+ log_err(LD_BUG, "Couldn't compute my v3 authority identity key "
+ "digest.");
+ return -1;
+ }
v3_digest_set = 1;
}
}
diff --git a/src/or/routerkeys.c b/src/or/routerkeys.c
index 2f20758b5b..4822ff3be3 100644
--- a/src/or/routerkeys.c
+++ b/src/or/routerkeys.c
@@ -1338,7 +1338,9 @@ make_tap_onion_key_crosscert(const crypto_pk_t *onion_key,
uint8_t signed_data[DIGEST_LEN + ED25519_PUBKEY_LEN];
*len_out = 0;
- crypto_pk_get_digest(rsa_id_key, (char*)signed_data);
+ if (crypto_pk_get_digest(rsa_id_key, (char*)signed_data) < 0) {
+ return NULL;
+ }
memcpy(signed_data + DIGEST_LEN, master_id_key->pubkey, ED25519_PUBKEY_LEN);
int r = crypto_pk_private_sign(onion_key,
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 3449e6f6b5..9c11f4d07f 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -5297,7 +5297,10 @@ rend_parse_v2_service_descriptor(rend_service_descriptor_t **parsed_out,
"v2 rendezvous service descriptor") < 0)
goto err;
/* Verify that descriptor ID belongs to public key and secret ID part. */
- crypto_pk_get_digest(result->pk, public_key_hash);
+ if (crypto_pk_get_digest(result->pk, public_key_hash) < 0) {
+ log_warn(LD_REND, "Unable to compute rend descriptor public key digest");
+ goto err;
+ }
rend_get_descriptor_id_bytes(test_desc_id, public_key_hash,
secret_id_part);
if (tor_memneq(desc_id_out, test_desc_id, DIGEST_LEN)) {