diff options
author | Nick Mathewson <nickm@torproject.org> | 2005-11-30 02:47:59 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2005-11-30 02:47:59 +0000 |
commit | 6b49a93bd5d5446799ba77daa82640e87321af26 (patch) | |
tree | d9cdab183210aac7c6a104af28defb469dad90a5 /src/common | |
parent | 447a3a7ff273e528ce2e0227925b986a80bcbde4 (diff) | |
download | tor-6b49a93bd5d5446799ba77daa82640e87321af26.tar.gz tor-6b49a93bd5d5446799ba77daa82640e87321af26.zip |
Move code to check for zero digests into util.c
svn:r5468
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/util.c | 9 | ||||
-rw-r--r-- | src/common/util.h | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c index 8b010bd320..9d68d2ffc0 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -417,6 +417,15 @@ find_whitespace(const char *s) return s; } +/** Return true iff the DIGEST_LEN bytes in digest are all zero. */ +int +tor_digest_is_zero(const char *digest) +{ + static char ZERO_DIGEST[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; + + return !memcmp(digest, ZERO_DIGEST, DIGEST_LEN); +} + #define CHECK_STRTOX_RESULT() \ /* Was at least one character converted? */ \ if (endptr == s) \ diff --git a/src/common/util.h b/src/common/util.h index eabd4278b9..d9b253dc36 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -111,6 +111,7 @@ const char *hex_str(const char *from, size_t fromlen); const char *eat_whitespace(const char *s); const char *eat_whitespace_no_nl(const char *s); const char *find_whitespace(const char *s); +int tor_digest_is_zero(const char *digest); void base16_encode(char *dest, size_t destlen, const char *src, size_t srclen); int base16_decode(char *dest, size_t destlen, const char *src, size_t srclen); |