[or-cvs] Continue attack on magic numbers; use new crypto wrappers w...

Nick Mathewson nickm at seul.org
Tue Apr 6 20:16:14 UTC 2004


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

Modified Files:
	crypto.c util.c util.h 
Log Message:
Continue attack on magic numbers; use new crypto wrappers where possible

Index: crypto.c
===================================================================
RCS file: /home/or/cvsroot/src/common/crypto.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- crypto.c	5 Apr 2004 17:36:30 -0000	1.71
+++ crypto.c	6 Apr 2004 20:16:11 -0000	1.72
@@ -560,6 +560,12 @@
   if (!cipher) return -1;
   if (crypto_cipher_generate_key(cipher)<0)
     goto err;
+  /* You can't just run around RSA-encrypting any bitstream: if it's
+   * greater than the RSA key, then OpenSSL will happily encrypt, and
+   * later decrypt to the wrong value.  So we set the first bit of
+   * 'cipher->key' to 0 if we aren't padding.  This means that our
+   * symmetric key is really only 127 bits.
+   */
   if (padding == PK_NO_PADDING)
     cipher->key[0] &= 0x7f;
   if (crypto_cipher_encrypt_init_cipher(cipher)<0)

Index: util.c
===================================================================
RCS file: /home/or/cvsroot/src/common/util.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- util.c	6 Apr 2004 03:44:35 -0000	1.79
+++ util.c	6 Apr 2004 20:16:11 -0000	1.80
@@ -162,6 +162,15 @@
   *to = '\0';
 }
 
+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);
+  return buf;
+}
+
 /*
  * A simple smartlist interface to make an unordered list of acceptable
  * nodes and then choose a random one.

Index: util.h
===================================================================
RCS file: /home/or/cvsroot/src/common/util.h,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- util.h	6 Apr 2004 03:46:37 -0000	1.51
+++ util.h	6 Apr 2004 20:16:11 -0000	1.52
@@ -95,6 +95,7 @@
 #endif
 
 void hex_encode(const char *from, int fromlen, char *to);
+const char *hex_str(const char *from, int fromlen);
 
 typedef struct smartlist_t smartlist_t;
 



More information about the tor-commits mailing list