summaryrefslogtreecommitdiff
path: root/src/common
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
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')
-rw-r--r--src/common/crypto.c24
-rw-r--r--src/common/crypto.h6
-rw-r--r--src/common/tortls.c6
-rw-r--r--src/common/tortls.h8
4 files changed, 22 insertions, 22 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);
}
diff --git a/src/common/crypto.h b/src/common/crypto.h
index 73b94b77db..2aa49d3a1f 100644
--- a/src/common/crypto.h
+++ b/src/common/crypto.h
@@ -113,7 +113,7 @@ typedef enum {
**/
typedef struct {
char d[N_COMMON_DIGEST_ALGORITHMS][DIGEST256_LEN];
-} digests_t;
+} common_digests_t;
typedef struct crypto_pk_t crypto_pk_t;
typedef struct crypto_cipher_t crypto_cipher_t;
@@ -193,7 +193,7 @@ int crypto_pk_private_hybrid_decrypt(crypto_pk_t *env, char *to,
int crypto_pk_asn1_encode(crypto_pk_t *pk, char *dest, size_t dest_len);
crypto_pk_t *crypto_pk_asn1_decode(const char *str, size_t len);
int crypto_pk_get_digest(const crypto_pk_t *pk, char *digest_out);
-int crypto_pk_get_all_digests(crypto_pk_t *pk, digests_t *digests_out);
+int crypto_pk_get_all_digests(crypto_pk_t *pk, common_digests_t *digests_out);
int crypto_pk_get_fingerprint(crypto_pk_t *pk, char *fp_out,int add_space);
int crypto_pk_get_hashed_fingerprint(crypto_pk_t *pk, char *fp_out);
@@ -222,7 +222,7 @@ int crypto_digest256(char *digest, const char *m, size_t len,
digest_algorithm_t algorithm);
int crypto_digest512(char *digest, const char *m, size_t len,
digest_algorithm_t algorithm);
-int crypto_digest_all(digests_t *ds_out, const char *m, size_t len);
+int crypto_common_digests(common_digests_t *ds_out, const char *m, size_t len);
struct smartlist_t;
void crypto_digest_smartlist_prefix(char *digest_out, size_t len_out,
const char *prepend,
diff --git a/src/common/tortls.c b/src/common/tortls.c
index 6e4cd3d480..688a7554d4 100644
--- a/src/common/tortls.c
+++ b/src/common/tortls.c
@@ -685,7 +685,7 @@ MOCK_IMPL(STATIC tor_x509_cert_t *,
cert->cert = x509_cert;
- crypto_digest_all(&cert->cert_digests,
+ crypto_common_digests(&cert->cert_digests,
(char*)cert->encoded, cert->encoded_len);
if ((pkey = X509_get_pubkey(x509_cert)) &&
@@ -754,7 +754,7 @@ tor_x509_cert_get_der(const tor_x509_cert_t *cert,
/** Return a set of digests for the public key in <b>cert</b>, or NULL if this
* cert's public key is not one we know how to take the digest of. */
-const digests_t *
+const common_digests_t *
tor_x509_cert_get_id_digests(const tor_x509_cert_t *cert)
{
if (cert->pkey_digests_set)
@@ -764,7 +764,7 @@ tor_x509_cert_get_id_digests(const tor_x509_cert_t *cert)
}
/** Return a set of digests for the public key in <b>cert</b>. */
-const digests_t *
+const common_digests_t *
tor_x509_cert_get_cert_digests(const tor_x509_cert_t *cert)
{
return &cert->cert_digests;
diff --git a/src/common/tortls.h b/src/common/tortls.h
index 6a4ef9aebe..97ca8fda7d 100644
--- a/src/common/tortls.h
+++ b/src/common/tortls.h
@@ -82,8 +82,8 @@ struct tor_x509_cert_t {
uint8_t *encoded;
size_t encoded_len;
unsigned pkey_digests_set : 1;
- digests_t cert_digests;
- digests_t pkey_digests;
+ common_digests_t cert_digests;
+ common_digests_t pkey_digests;
};
/** Holds a SSL object and its associated data. Members are only
@@ -237,8 +237,8 @@ tor_x509_cert_t *tor_x509_cert_decode(const uint8_t *certificate,
size_t certificate_len);
void tor_x509_cert_get_der(const tor_x509_cert_t *cert,
const uint8_t **encoded_out, size_t *size_out);
-const digests_t *tor_x509_cert_get_id_digests(const tor_x509_cert_t *cert);
-const digests_t *tor_x509_cert_get_cert_digests(const tor_x509_cert_t *cert);
+const common_digests_t *tor_x509_cert_get_id_digests(const tor_x509_cert_t *cert);
+const common_digests_t *tor_x509_cert_get_cert_digests(const tor_x509_cert_t *cert);
int tor_tls_get_my_certs(int server,
const tor_x509_cert_t **link_cert_out,
const tor_x509_cert_t **id_cert_out);