[or-cvs] Parse and generate service descriptors

Nick Mathewson nickm at seul.org
Wed Mar 31 02:04:08 UTC 2004


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

Modified Files:
	Makefile.am or.h test.c 
Log Message:
Parse and generate service descriptors

Index: Makefile.am
===================================================================
RCS file: /home/or/cvsroot/src/or/Makefile.am,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- Makefile.am	20 Mar 2004 04:59:29 -0000	1.27
+++ Makefile.am	31 Mar 2004 02:04:06 -0000	1.28
@@ -5,14 +5,14 @@
 bin_PROGRAMS = tor
 
 tor_SOURCES = buffers.c circuit.c command.c connection.c \
-             connection_or.c config.c dirserv.c \
+             connection_or.c config.c dirserv.c rendcommon.c \
              onion.c router.c routerlist.c directory.c dns.c connection_edge.c \
              rephist.c cpuworker.c main.c tor_main.c
 
 tor_LDADD = ../common/libor.a
 
 test_SOURCES = buffers.c circuit.c command.c connection.c \
-             connection_or.c config.c dirserv.c \
+             connection_or.c config.c dirserv.c rendcommon.c \
              onion.c router.c routerlist.c directory.c dns.c connection_edge.c \
              rephist.c cpuworker.c main.c test.c
 

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.262
retrieving revision 1.263
diff -u -d -r1.262 -r1.263
--- or.h	30 Mar 2004 22:57:49 -0000	1.262
+++ or.h	31 Mar 2004 02:04:06 -0000	1.263
@@ -972,6 +972,20 @@
 /* length of 'y' portion of 'y.onion' URL. */
 #define REND_SERVICE_ID_LEN 16
 
+typedef struct rend_service_descriptor_t {
+  crypto_pk_env_t *pk;
+  time_t timestamp;
+  int n_intro_points;
+  char **intro_points;
+} rend_service_descriptor_t;
+
+void rend_service_descriptor_free(rend_service_descriptor_t *desc);
+int rend_encode_service_descriptor(rend_service_descriptor_t *desc,
+                                   crypto_pk_env_t *key,
+                                   char **str_out,
+                                   int *len_out);
+rend_service_descriptor_t *rend_parse_service_descriptor(const char *str, int len);
+
 #endif
 
 /*

Index: test.c
===================================================================
RCS file: /home/or/cvsroot/src/or/test.c,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- test.c	30 Mar 2004 19:47:32 -0000	1.69
+++ test.c	31 Mar 2004 02:04:06 -0000	1.70
@@ -804,6 +804,40 @@
   test_eq(0, is_recommended_version("a", ""));
 }
 
+void test_rend_fns()
+{
+  rend_service_descriptor_t *d1, *d2;
+  char *encoded;
+  int len;
+  crypto_pk_env_t *pk1;
+  time_t now;
+  pk1 = crypto_new_pk_env(CRYPTO_PK_RSA);
+
+  test_assert(!crypto_pk_generate_key(pk1));
+  d1 = tor_malloc_zero(sizeof(rend_service_descriptor_t));
+  d1->pk = pk1;
+  now = time(NULL);
+  d1->timestamp = now;
+  d1->n_intro_points = 3;
+  d1->intro_points = tor_malloc(sizeof(char*)*3);
+  d1->intro_points[0] = tor_strdup("tom");
+  d1->intro_points[1] = tor_strdup("crow");
+  d1->intro_points[2] = tor_strdup("joel");
+  test_assert(! rend_encode_service_descriptor(d1, pk1, &encoded, &len));
+  d2 = rend_parse_service_descriptor(encoded, len);
+  test_assert(d2);
+
+  test_assert(!crypto_pk_cmp_keys(d1->pk, d2->pk));
+  test_eq(d2->timestamp, now);
+  test_eq(d2->n_intro_points, 3);
+  test_streq(d2->intro_points[0], "tom");
+  test_streq(d2->intro_points[1], "crow");
+  test_streq(d2->intro_points[2], "joel");
+
+  rend_service_descriptor_free(d1);
+  rend_service_descriptor_free(d2);
+}
+
 int
 main(int c, char**v){
 #if 0
@@ -830,6 +864,8 @@
   puts("\n========================= Directory Formats ===============");
 //  add_stream_log(LOG_DEBUG, NULL, stdout);
   test_dir_format();
+  puts("\n========================= Rendezvous functionality ========");
+  test_rend_fns();
   puts("");
 
   if (have_failed)



More information about the tor-commits mailing list