]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
hex_encode is obsoleted by base16_encode, and never actually worked in the first...
authorNick Mathewson <nickm@torproject.org>
Sat, 7 Aug 2004 01:03:33 +0000 (01:03 +0000)
committerNick Mathewson <nickm@torproject.org>
Sat, 7 Aug 2004 01:03:33 +0000 (01:03 +0000)
svn:r2175

src/common/util.c
src/common/util.h
src/or/rendmid.c
src/or/rendservice.c

index 252f566dee904527925ef355dc83ed70e0768807..717285babe9ec7d6cddbdcb05f1371cd63c3431b 100644 (file)
@@ -234,22 +234,6 @@ void set_uint32(char *cp, uint32_t v)
 }
 #endif
 
-/** Encode the first <b>fromlen</b> bytes stored at <b>from</b> in hexidecimal;
- * write the result as a NUL-terminated string to <b>to</b>.  <b>to</b> must
- * have at least (2*fromlen)+1 bytes of free space.
- */
-void hex_encode(const char *from, int fromlen, char *to)
-{
-  const unsigned char *fp = from;
-  static const char TABLE[] = "0123456789abcdef";
-  tor_assert(from && fromlen>=0 && to);
-  while (fromlen--) {
-    *to++ = TABLE[*fp >> 4];
-    *to++ = TABLE[*fp & 7];
-    ++fp;
-  }
-  *to = '\0';
-}
 
 /** Return a pointer to a NUL-terminated hexidecimal string encoding
  * the first <b>fromlen</b> bytes of <b>from</b>. (fromlen must be \<= 32.) The
@@ -261,7 +245,7 @@ const char *hex_str(const char *from, int fromlen)
   static char buf[65];
   if (fromlen>(sizeof(buf)-1)/2)
     fromlen = (sizeof(buf)-1)/2;
-  hex_encode(from,fromlen,buf);
+  base16_encode(buf,64,from,fromlen);
   return buf;
 }
 
index 8ee05b2fc199aa4efca853e48f8043742204e75d..4dafccc52f3fcdf9777f1379727ffb286356c144 100644 (file)
@@ -133,7 +133,6 @@ void set_uint32(char *cp, uint32_t v);
 #endif
 #endif
 
-void hex_encode(const char *from, int fromlen, char *to);
 const char *hex_str(const char *from, int fromlen);
 
 /** Generic resizeable array. */
index 6c2b372956238ef5ae0f51b4731ec690d1d3b6af..cc5045b2a73f66adf4b48b99522de980ae166e9d 100644 (file)
@@ -208,7 +208,7 @@ rend_mid_establish_rendezvous(circuit_t *circ, const char *request, int request_
   memcpy(circ->rend_cookie, request, REND_COOKIE_LEN);
 
 
-  hex_encode(request,4,hexid);
+  base16_encode(hexid,9,request,4);
 
   log_fn(LOG_INFO, "Established rendezvous point on circuit %d for cookie %s",
          circ->p_circ_id, hexid);
@@ -230,7 +230,7 @@ rend_mid_rendezvous(circuit_t *circ, const char *request, int request_len)
   char hexid[9];
 
   if (request_len>=4) {
-    hex_encode(request,4,hexid);
+    base16_encode(hexid,9,request,4);
     log_fn(LOG_INFO, "Got request for rendezvous from circuit %d to cookie %s",
            circ->p_circ_id, hexid);
   }
index ff25704f3f901222407199b560a6fa31394eccd3..836f119e22a369ab8c4de94545320116cf17065c 100644 (file)
@@ -417,7 +417,7 @@ rend_service_introduce(circuit_t *circuit, const char *request, int request_len)
     return -1;
   }
   r_cookie = ptr;
-  hex_encode(r_cookie,4,hexcookie);
+  base16_encode(hexcookie,9,r_cookie,4);
 
   /* Try DH handshake... */
   dh = crypto_dh_new();
@@ -637,7 +637,7 @@ rend_service_rendezvous_has_opened(circuit_t *circuit)
   hop = circuit->build_state->pending_final_cpath;
   tor_assert(hop);
 
-  hex_encode(circuit->rend_cookie, 4, hexcookie);
+  base16_encode(hexcookie,9,circuit->rend_cookie,4);
   base32_encode(serviceid, REND_SERVICE_ID_LEN+1,
                 circuit->rend_pk_digest,10);