summaryrefslogtreecommitdiff
path: root/src/common/crypto.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-05-04 09:59:24 -0400
committerNick Mathewson <nickm@torproject.org>2016-05-16 08:26:00 -0400
commit62c5a1fa45efcb52eb3ce9d0cce04e31490a5468 (patch)
tree42f56910d734949f907653b52a0a909b88438d2d /src/common/crypto.c
parentb688945dfbc8b0a27f510db259ec7c1aaa4bfb34 (diff)
downloadtor-62c5a1fa45efcb52eb3ce9d0cce04e31490a5468.tar.gz
tor-62c5a1fa45efcb52eb3ce9d0cce04e31490a5468.zip
Mark even more crypto lines (the fragile_assert ones) as unreachable
Diffstat (limited to 'src/common/crypto.c')
-rw-r--r--src/common/crypto.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 8fdcfc1503..fb5dd06b5e 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -938,6 +938,10 @@ crypto_pk_copy_full(crypto_pk_t *env)
new_key = RSAPublicKey_dup(env->key);
}
if (!new_key) {
+ /* LCOV_EXCL_START
+ *
+ * We can't cause RSA*Key_dup() to fail, so we can't really test this.
+ */
log_err(LD_CRYPTO, "Unable to duplicate a %s key: openssl failed.",
privatekey?"private":"public");
crypto_log_errors(LOG_ERR,
@@ -945,6 +949,7 @@ crypto_pk_copy_full(crypto_pk_t *env)
"Duplicating a public key");
tor_fragile_assert();
return NULL;
+ /* LCOV_EXCL_STOP */
}
return crypto_new_pk_from_rsa_(new_key);
@@ -1695,8 +1700,10 @@ crypto_digest_algorithm_get_name(digest_algorithm_t alg)
case DIGEST_SHA3_512:
return "sha3-512";
default:
+ // LCOV_EXCL_START
tor_fragile_assert();
return "??unknown_digest??";
+ // LCOV_EXCL_STOP
}
}
@@ -1886,8 +1893,10 @@ crypto_digest_add_bytes(crypto_digest_t *digest, const char *data,
keccak_digest_update(&digest->d.sha3, (const uint8_t *)data, len);
break;
default:
+ /* LCOV_EXCL_START */
tor_fragile_assert();
break;
+ /* LCOV_EXCL_STOP */
}
}
@@ -1929,10 +1938,10 @@ crypto_digest_get_digest(crypto_digest_t *digest,
//LCOV_EXCL_START
case DIGEST_SHA3_256: /* FALLSTHROUGH */
case DIGEST_SHA3_512:
- log_warn(LD_BUG, "Handling unexpected algorithm %d", digest->algorithm);
- tor_assert(0); /* This is fatal, because it should never happen. */
default:
- tor_assert(0); /* Unreachable. */
+ log_warn(LD_BUG, "Handling unexpected algorithm %d", digest->algorithm);
+ /* This is fatal, because it should never happen. */
+ tor_assert_unreached();
break;
//LCOV_EXCL_STOP
}