[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Move code to check for zero digests into util.c



Update of /home/or/cvsroot/tor/src/common
In directory moria:/tmp/cvs-serv13611/src/common

Modified Files:
	util.c util.h 
Log Message:
Move code to check for zero digests into util.c

Index: util.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/util.c,v
retrieving revision 1.233
retrieving revision 1.234
diff -u -d -r1.233 -r1.234
--- util.c	15 Nov 2005 03:16:32 -0000	1.233
+++ util.c	30 Nov 2005 02:47:59 -0000	1.234
@@ -417,6 +417,15 @@
   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)                                      \

Index: util.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/util.h,v
retrieving revision 1.148
retrieving revision 1.149
diff -u -d -r1.148 -r1.149
--- util.h	1 Nov 2005 06:12:51 -0000	1.148
+++ util.h	30 Nov 2005 02:47:59 -0000	1.149
@@ -111,6 +111,7 @@
 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);