[or-cvs] Add code to parse fingerprint files and compare routers aga...

Nick Mathewson nickm at seul.org
Fri Sep 26 20:41:26 UTC 2003


Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/tmp/cvs-serv24525/common

Modified Files:
	crypto.c crypto.h 
Log Message:
Add code to parse fingerprint files and compare routers against fingerprint files.

Index: crypto.c
===================================================================
RCS file: /home/or/cvsroot/src/common/crypto.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- crypto.c	26 Sep 2003 18:44:20 -0000	1.37
+++ crypto.c	26 Sep 2003 20:41:19 -0000	1.38
@@ -677,9 +677,25 @@
   }
   *bufp = '\0';
   assert(strlen(buf) == FINGERPRINT_LEN);
+  assert(crypto_pk_check_fingerprint_syntax(buf));
   strcpy(fp_out, buf);
   free(buf);
   return 0;
+}
+
+int 
+crypto_pk_check_fingerprint_syntax(const char *s)
+{
+  int i;
+  for (i = 0; i < FINGERPRINT_LEN; ++i) {
+    if ((i%5) == 4) {
+      if (!isspace(s[i])) return 0;
+    } else {
+      if (!isxdigit(s[i])) return 0;
+    }
+  }
+  if (s[FINGERPRINT_LEN]) return 0;
+  return 1;
 }
 
 /* symmetric crypto */

Index: crypto.h
===================================================================
RCS file: /home/or/cvsroot/src/common/crypto.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- crypto.h	26 Sep 2003 18:27:34 -0000	1.18
+++ crypto.h	26 Sep 2003 20:41:20 -0000	1.19
@@ -56,6 +56,7 @@
 int crypto_pk_public_checksig(crypto_pk_env_t *env, unsigned char *from, int fromlen, unsigned char *to);
 #define FINGERPRINT_LEN 49
 int crypto_pk_get_fingerprint(crypto_pk_env_t *pk, char *fp_out);
+int crypto_pk_check_fingerprint_syntax(const char *s);
 
 int base64_encode(char *dest, int destlen, char *src, int srclen);
 int base64_decode(char *dest, int destlen, char *src, int srclen);



More information about the tor-commits mailing list