Rename tor_mem_is_zero to fast_mem_is_zero()

For memeq and friends, "tor_" indicates constant-time and "fast_"
indicates optimized.  I'm fine with leaving the constant-time
"safe_mem_is_zero" with its current name, but the "tor_" prefix on
the current optimized version is misleading.

Also, make the tor_digest*_is_zero() uniformly constant-time, and
add a fast_digest*_is_zero() version to use as needed.

A later commit in this branch will fix all the users of
tor_mem_is_zero().

Closes ticket 30309.
This commit is contained in:
Nick Mathewson
2019-04-30 14:43:35 -04:00
parent 847fc3280d
commit 309467c64e
3 changed files with 13 additions and 7 deletions
+7 -1
View File
@@ -20,7 +20,13 @@ const void *tor_memmem(const void *haystack, size_t hlen, const void *needle,
size_t nlen);
const void *tor_memstr(const void *haystack, size_t hlen,
const char *needle);
int tor_mem_is_zero(const char *mem, size_t len);
int fast_mem_is_zero(const char *mem, size_t len);
#define fast_digest_is_zero(d) fast_mem_is_zero((d), DIGEST_LEN)
#define fast_digetst256_is_zero(d) fast_mem_is_zero((d), DIGEST256_LEN)
// XXXX remove this after we replace all users.
#define tor_mem_is_zero fast_mem_is_zero
int tor_digest_is_zero(const char *digest);
int tor_digest256_is_zero(const char *digest);