summaryrefslogtreecommitdiff
path: root/src/common/crypto.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-02-10 15:28:19 -0500
committerNick Mathewson <nickm@torproject.org>2016-02-10 15:28:19 -0500
commit8a4bba06d27c99e7c1e7930761b3998a27787ce9 (patch)
tree7738b69de80a23c193a9daf34f4fba938558aa41 /src/common/crypto.c
parent39b597c2fd8b45ff61573c70c36e8a4846cf3a0e (diff)
downloadtor-8a4bba06d27c99e7c1e7930761b3998a27787ce9.tar.gz
tor-8a4bba06d27c99e7c1e7930761b3998a27787ce9.zip
Rename crypto_digest_all, and digests_t.
They are no longer "all" digests, but only the "common" digests. Part of 17795. This is an automated patch I made with a couple of perl one-liners: perl -i -pe 's/crypto_digest_all/crypto_common_digests/g;' src/*/*.[ch] perl -i -pe 's/\bdigests_t\b/common_digests_t/g;' src/*/*.[ch]
Diffstat (limited to 'src/common/crypto.c')
-rw-r--r--src/common/crypto.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 9f1ce93f98..2ebf203110 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, digests_t *digests_out)
+crypto_pk_get_all_digests(crypto_pk_t *pk, common_digests_t *digests_out)
{
unsigned char *buf = NULL;
int len;
@@ -1331,7 +1331,7 @@ crypto_pk_get_all_digests(crypto_pk_t *pk, digests_t *digests_out)
len = i2d_RSAPublicKey(pk->key, &buf);
if (len < 0 || buf == NULL)
return -1;
- if (crypto_digest_all(digests_out, (char*)buf, len) < 0) {
+ if (crypto_common_digests(digests_out, (char*)buf, len) < 0) {
OPENSSL_free(buf);
return -1;
}
@@ -1644,11 +1644,11 @@ crypto_digest512(char *digest, const char *m, size_t len,
== -1);
}
-/** Set the digests_t in <b>ds_out</b> to contain every digest on the
+/** Set the common_digests_t in <b>ds_out</b> to contain every digest on the
* <b>len</b> bytes in <b>m</b> that we know how to compute. Return 0 on
* success, -1 on failure. */
int
-crypto_digest_all(digests_t *ds_out, const char *m, size_t len)
+crypto_common_digests(common_digests_t *ds_out, const char *m, size_t len)
{
int i;
tor_assert(ds_out);
@@ -1757,7 +1757,7 @@ struct crypto_digest_t {
* when we free one.
*/
static size_t
-crypto_digest_alloc_bytes(digest_algorithm_t alg)
+crypto_common_digestsoc_bytes(digest_algorithm_t alg)
{
/* Helper: returns the number of bytes in the 'f' field of 'st' */
#define STRUCT_FIELD_SIZE(st, f) (sizeof( ((st*)0)->f ))
@@ -1788,7 +1788,7 @@ crypto_digest_t *
crypto_digest_new(void)
{
crypto_digest_t *r;
- r = tor_malloc(crypto_digest_alloc_bytes(DIGEST_SHA1));
+ r = tor_malloc(crypto_common_digestsoc_bytes(DIGEST_SHA1));
SHA1_Init(&r->d.sha1);
r->algorithm = DIGEST_SHA1;
return r;
@@ -1801,7 +1801,7 @@ crypto_digest256_new(digest_algorithm_t algorithm)
{
crypto_digest_t *r;
tor_assert(algorithm == DIGEST_SHA256 || algorithm == DIGEST_SHA3_256);
- r = tor_malloc(crypto_digest_alloc_bytes(algorithm));
+ r = tor_malloc(crypto_common_digestsoc_bytes(algorithm));
if (algorithm == DIGEST_SHA256)
SHA256_Init(&r->d.sha2);
else
@@ -1817,7 +1817,7 @@ crypto_digest512_new(digest_algorithm_t algorithm)
{
crypto_digest_t *r;
tor_assert(algorithm == DIGEST_SHA512 || algorithm == DIGEST_SHA3_512);
- r = tor_malloc(crypto_digest_alloc_bytes(algorithm));
+ r = tor_malloc(crypto_common_digestsoc_bytes(algorithm));
if (algorithm == DIGEST_SHA512)
SHA512_Init(&r->d.sha512);
else
@@ -1833,7 +1833,7 @@ crypto_digest_free(crypto_digest_t *digest)
{
if (!digest)
return;
- size_t bytes = crypto_digest_alloc_bytes(digest->algorithm);
+ size_t bytes = crypto_common_digestsoc_bytes(digest->algorithm);
memwipe(digest, 0, bytes);
tor_free(digest);
}
@@ -1893,7 +1893,7 @@ crypto_digest_get_digest(crypto_digest_t *digest,
return;
}
- const size_t alloc_bytes = crypto_digest_alloc_bytes(digest->algorithm);
+ const size_t alloc_bytes = crypto_common_digestsoc_bytes(digest->algorithm);
/* memcpy into a temporary ctx, since SHA*_Final clears the context */
memcpy(&tmpenv, digest, alloc_bytes);
switch (digest->algorithm) {
@@ -1925,7 +1925,7 @@ crypto_digest_t *
crypto_digest_dup(const crypto_digest_t *digest)
{
tor_assert(digest);
- const size_t alloc_bytes = crypto_digest_alloc_bytes(digest->algorithm);
+ const size_t alloc_bytes = crypto_common_digestsoc_bytes(digest->algorithm);
return tor_memdup(digest, alloc_bytes);
}
@@ -1940,7 +1940,7 @@ crypto_digest_assign(crypto_digest_t *into,
tor_assert(into);
tor_assert(from);
tor_assert(into->algorithm == from->algorithm);
- const size_t alloc_bytes = crypto_digest_alloc_bytes(from->algorithm);
+ const size_t alloc_bytes = crypto_common_digestsoc_bytes(from->algorithm);
memcpy(into,from,alloc_bytes);
}