diff options
author | David Goulet <dgoulet@torproject.org> | 2017-07-12 13:41:33 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2017-07-13 16:50:09 -0400 |
commit | f64689f3f00d72033ff7544ada4ccdfb7c328b36 (patch) | |
tree | ea4401f57e13999f49032d8464051874dec89081 /src/or/hs_common.c | |
parent | 1b048fbfaadec04f409ab8d120106025b009fec8 (diff) | |
download | tor-f64689f3f00d72033ff7544ada4ccdfb7c328b36.tar.gz tor-f64689f3f00d72033ff7544ada4ccdfb7c328b36.zip |
prop224: Don't use char * for binary data
It turns out that some char * sneaked in our hs_common.c code. Replace those
by uint8_t *.
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/hs_common.c')
-rw-r--r-- | src/or/hs_common.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/or/hs_common.c b/src/or/hs_common.c index 87c29d5819..22a845f911 100644 --- a/src/or/hs_common.c +++ b/src/or/hs_common.c @@ -367,7 +367,7 @@ rend_data_get_pk_digest(const rend_data_t *rend_data, size_t *len_out) * checksum_out must be large enough to receive 32 bytes (DIGEST256_LEN). */ static void build_hs_checksum(const ed25519_public_key_t *key, uint8_t version, - char *checksum_out) + uint8_t *checksum_out) { size_t offset = 0; char data[HS_SERVICE_ADDR_CHECKSUM_INPUT_LEN]; @@ -383,7 +383,8 @@ build_hs_checksum(const ed25519_public_key_t *key, uint8_t version, tor_assert(offset == HS_SERVICE_ADDR_CHECKSUM_INPUT_LEN); /* Hash the data payload to create the checksum. */ - crypto_digest256(checksum_out, data, sizeof(data), DIGEST_SHA3_256); + crypto_digest256((char *) checksum_out, data, sizeof(data), + DIGEST_SHA3_256); } /* Using an ed25519 public key, checksum and version to build the binary @@ -392,7 +393,7 @@ build_hs_checksum(const ed25519_public_key_t *key, uint8_t version, * * addr_out must be large enough to receive HS_SERVICE_ADDR_LEN bytes. */ static void -build_hs_address(const ed25519_public_key_t *key, const char *checksum, +build_hs_address(const ed25519_public_key_t *key, const uint8_t *checksum, uint8_t version, char *addr_out) { size_t offset = 0; @@ -416,7 +417,7 @@ build_hs_address(const ed25519_public_key_t *key, const char *checksum, * HS_SERVICE_ADDR_LEN bytes but doesn't need to be NUL terminated. */ static void hs_parse_address_impl(const char *address, ed25519_public_key_t *key_out, - char *checksum_out, uint8_t *version_out) + uint8_t *checksum_out, uint8_t *version_out) { size_t offset = 0; @@ -449,7 +450,7 @@ hs_parse_address_impl(const char *address, ed25519_public_key_t *key_out, * Return 0 if parsing went well; return -1 in case of error. */ int hs_parse_address(const char *address, ed25519_public_key_t *key_out, - char *checksum_out, uint8_t *version_out) + uint8_t *checksum_out, uint8_t *version_out) { char decoded[HS_SERVICE_ADDR_LEN]; @@ -485,8 +486,8 @@ int hs_address_is_valid(const char *address) { uint8_t version; - char checksum[HS_SERVICE_ADDR_CHECKSUM_LEN_USED]; - char target_checksum[DIGEST256_LEN]; + uint8_t checksum[HS_SERVICE_ADDR_CHECKSUM_LEN_USED]; + uint8_t target_checksum[DIGEST256_LEN]; ed25519_public_key_t key; /* Parse the decoded address into the fields we need. */ @@ -521,7 +522,8 @@ void hs_build_address(const ed25519_public_key_t *key, uint8_t version, char *addr_out) { - char checksum[DIGEST256_LEN], address[HS_SERVICE_ADDR_LEN]; + uint8_t checksum[DIGEST256_LEN]; + char address[HS_SERVICE_ADDR_LEN]; tor_assert(key); tor_assert(addr_out); |