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

[minion-cvs] Fix error in path-length checking.



Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.mit.edu:/tmp/cvs-serv447/lib/mixminion

Modified Files:
	BuildMessage.py 
Log Message:
Fix error in path-length checking.

This was a weird one.  Remember how a path contains:

    RSA_ENCRYPTED SYM_ENCRYPTED_______________________
    datadata RSA_ENCRYPTED SYM_ENCRYPTED______________
             datadata RSA_ENCRYPTED SYM_ENCRYPTED_____
                   ......
                                       RSA_ENC SYM_ENC
                                       datadata padding  ?

Previously, if all of the 'datadata' chunks were big enough to fit
into a header, we were happy.  But there was an error case where all
of the 'datadata' chunks fit, but there isn't enough room to pad the
_final_ RSA-encrypted block up to 256 bytes.  Now we check for this
case too.



Index: BuildMessage.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/BuildMessage.py,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- BuildMessage.py	28 May 2003 06:37:30 -0000	1.46
+++ BuildMessage.py	11 Jun 2003 19:05:35 -0000	1.47
@@ -265,7 +265,7 @@
     elif err:
         raise UIError("Address and %s leg of path will not fit in one header",
                       ["first", "second"][err-1])
-
+    
 #----------------------------------------------------------------------
 # MESSAGE DECODING
 
@@ -666,10 +666,10 @@
            1) A list of routingtype/routinginfo tuples for the header
            2) The size (in bytes) added to the header in order to
               route to each of the nodes
-           3) Minimum size (in bytes) needed for the header.  If this
-              is greater than HEADER_LEN, we can't build the header at
-              all.
-        """
+           3) Minimum size (in bytes) needed for the header.
+
+       Raises MixError if the routing info is too big to fit into a single
+       header. """
     # Construct a list 'routing' of exitType, exitInfo.
     routing = [ (FWD_TYPE, node.getRoutingInfo().pack()) for
                 node in path[1:] ]
@@ -681,6 +681,12 @@
     # totalSize is the total number of bytes needed for header
     totalSize = reduce(operator.add, sizes)
     if totalSize > HEADER_LEN:
+        raise MixError("Routing info won't fit in header")
+
+    padding = HEADER_LEN-totalSize
+    # We can't underflow from the last header.  That means we *must* have
+    # enough space to pad the last routinginfo out to a public key size.
+    if padding+sizes[-1] < ENC_SUBHEADER_LEN:
         raise MixError("Routing info won't fit in header")
 
     return routing, sizes, totalSize