[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[minion-cvs] Replace XXXX comments with DOCDOC, FFFF, etc as appropr...



Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.seul.org:/tmp/cvs-serv9405/lib/mixminion

Modified Files:
	BuildMessage.py Config.py MMTPClient.py Packet.py 
	ServerInfo.py ServerMain.py __init__.py benchmark.py 
Log Message:
Replace XXXX comments with DOCDOC, FFFF, etc as appropriate.

(XXXX is only for stuff that is definitely wrong, now.  FFFF is for 
stuff that should maybe be fixed for future releases; ???? is for stuff I'm
not sure about, and DOCDOOC is for missing documentation/comments.


Index: BuildMessage.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/BuildMessage.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- BuildMessage.py	22 Nov 2002 21:12:05 -0000	1.17
+++ BuildMessage.py	2 Dec 2002 03:30:07 -0000	1.18
@@ -40,7 +40,7 @@
 
 def buildEncryptedForwardMessage(payload, exitType, exitInfo, path1, path2,
 				 key, paddingPRNG=None, secretRNG=None):
-    """XXXX
+    """DOCDOC
     """
     if paddingPRNG is None: paddingPRNG = Crypto.AESCounterPRNG()
     if secretRNG is None: secretRNG = paddingPRNG
@@ -52,12 +52,12 @@
     rsaDataLen = key.get_modulus_bytes()-OAEP_OVERHEAD
     rsaPart = payload[:rsaDataLen]
     lionessPart = payload[rsaDataLen:]
-    # XXXX DOC
+    # DOCDOC
     while 1:
 	encrypted = Crypto.pk_encrypt(rsaPart, key)
 	if not (ord(encrypted[0]) & 0x80):
 	    break
-    #XXXX doc mode 'End-to-end encrypt'
+    # DOCDOC doc mode 'End-to-end encrypt'
     k = Crypto.Keyset(sessionKey).getLionessKeys("End-to-end encrypt")
     lionessPart = Crypto.lioness_encrypt(lionessPart, k)
     payload = encrypted + lionessPart
@@ -75,10 +75,10 @@
 
     payload = _encodePayload(payload, 0, paddingPRNG)
 
-    # XXXX Document this mode
+    # DOCDOC document this mode
     k = Crypto.Keyset(replyBlock.encryptionKey).getLionessKeys(
 	                 Crypto.PAYLOAD_ENCRYPT_MODE)
-    # XXXX Document why this is decrypt
+    # DOCDOC Document why this is decrypt
     payload = Crypto.lioness_decrypt(payload, k)
 
     return _buildMessage(payload, None, None,
@@ -125,7 +125,7 @@
 # Maybe we shouldn't even allow this to be called with userKey==None.
 def buildStatelessReplyBlock(path, exitType, exitInfo, userKey,
 			     expiryTime=0, secretRNG=None):
-    """XXXX DOC IS NOW WRONG HERE
+    """DOCDOC XXXX DOC IS NOW WRONG HERE
        (exitInfo doesn't include tag)
 
        Construct a 'stateless' reply block that does not require the
@@ -147,14 +147,14 @@
                   email: If true, delivers via SMTP; else delivers via MBOX
        """
 
-    #XXXX Out of sync with the spec.
+    # ???? Out of sync with the spec. 
     if secretRNG is None: secretRNG = Crypto.AESCounterPRNG()
 
     while 1:
 	seed = _getRandomTag(secretRNG)
 	if Crypto.sha1(seed+userKey+"Validate")[-1] == '\x00':
 	    break
-	
+
     prng = Crypto.AESCounterPRNG(Crypto.sha1(seed+userKey+"Generate")[:16])
 
     return buildReplyBlock(path, exitType, exitInfo, expiryTime, prng, seed)[0]
@@ -163,7 +163,7 @@
 # MESSAGE DECODING
 
 def decodePayload(payload, tag, key=None, storedKeys=None, userKey=None):
-    """ DOCDOC XXXX
+    """ DOCDOC 
         Contract: return payload on success; raise MixError on certain failure,
           return None if neither.
     """
@@ -190,15 +190,15 @@
 	p = decodeEncryptedForwardPayload(payload, tag, key)
 	if p is not None:
 	    return p
-	
+
     return None
 
 def decodeForwardPayload(payload):
-    "XXXX"
+    "DOCDOC"
     return decodePayloadImpl(payload)
 
 def decodeEncryptedForwardPayload(payload, tag, key):
-    "XXXX"
+    "DOCDOC"
     assert len(tag) == TAG_LEN
     assert len(payload) == PAYLOAD_LEN
     msg = tag+payload
@@ -207,16 +207,16 @@
     except Crypto.CryptoError, _:
 	return None
     rest = msg[key.get_modulus_bytes():]
-    #XXXX magic string
+    # XXXX magic string
     k = Crypto.Keyset(rsaPart[:SECRET_LEN]).getLionessKeys("End-to-end encrypt")
     rest = rsaPart[SECRET_LEN:] + Crypto.lioness_decrypt(rest, k)
     return decodePayloadImpl(rest)
 
 def decodeReplyPayload(payload, secrets, check=0):
-    "XXXX"
+    "DOCDOC"
     for sec in secrets:
 	k = Crypto.Keyset(sec).getLionessKeys(Crypto.PAYLOAD_ENCRYPT_MODE)
-	# XXXX document why this is encrypt
+	# DOCDOC document why this is encrypt
 	payload = Crypto.lioness_encrypt(payload, k)
 	if check and _checkPayload(payload):
 	    break
@@ -224,11 +224,11 @@
     return decodePayloadImpl(payload)
 
 def decodeStatelessReplyPayload(payload, tag, userKey):
-    "XXXX"
+    "DOCDOC"
     seed = Crypto.sha1(tag+userKey+"Generate")[:16]
     prng = Crypto.AESCounterPRNG(seed)
     secrets = [ prng.getBytes(SECRET_LEN) for _ in xrange(17) ]
-			
+
     return decodeReplyPayload(payload, secrets, check=1)
 
 #----------------------------------------------------------------------
@@ -497,7 +497,7 @@
     # these are irrelevant, as are the 4 bytes of adler-32 checksum at
     # the end.  Still, we can afford 6 bytes per payload, and
     # reconstructing the checksum to keep zlib happy is a bit of a pain.
-    # XXXX doc manditory '\x78\xDA' beginning in spec.
+    # DOCDOC doc manditory '\x78\xDA' beginning in spec.
     assert s[0] == '\x78' # deflate, 32K window
     assert s[1] == '\xda' # no dict, max compression
     return s
@@ -505,9 +505,9 @@
 def uncompressData(payload):
     """Uncompress a string 'payload'; raise ParseError if it is not valid
        compressed data."""
-    # XXXX ???? How to prevent zlib bombing?  Somebody could compress 28MB of
-    # XXXX ???? zero bytes down to fit in a single payload and use us to
-    # XXXX ???? mailbomb people, hard.
+    # FFFF We should prevent zlib bombing.  Somebody could compress 28MB of
+    # FFFF zero bytes down to fit in a single payload and use us to
+    # FFFF mailbomb people, hard.
     if len(payload) < 6 or payload[0:2] != '\x78\xDA':
 	raise ParseError("Invalid zlib header")
     try:

Index: Config.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Config.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- Config.py	21 Nov 2002 16:55:49 -0000	1.19
+++ Config.py	2 Dec 2002 03:30:07 -0000	1.20
@@ -755,6 +755,6 @@
 	return self.moduleManager
 
 def _validateHostSection(sec):
-    #XXXX
+    # FFFF
     pass
 

Index: MMTPClient.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/MMTPClient.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- MMTPClient.py	10 Sep 2002 14:45:30 -0000	1.9
+++ MMTPClient.py	2 Dec 2002 03:30:07 -0000	1.10
@@ -38,7 +38,7 @@
         self.sock.connect((self.targetIP,self.targetPort))
         
         self.tls = self.context.sock(self.sock.fileno())
-        #XXXX session resumption
+        # FFFF session resumption
         self.tls.connect()
         peer_pk = self.tls.get_peer_cert_pk()
         keyID = sha1(peer_pk.encode_key(public=1))

Index: Packet.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Packet.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- Packet.py	22 Nov 2002 21:12:05 -0000	1.15
+++ Packet.py	2 Dec 2002 03:30:07 -0000	1.16
@@ -453,7 +453,8 @@
 	return (type(self) == type(other) and self.ip == other.ip and
 		self.port == other.port and self.keyinfo == other.keyinfo)
 
-# XXXX Support subdomains and quotesd strings
+#DOCDOC
+# FFFF Support subdomains and quotesd strings
 _ATOM_PAT = r'[^\x00-\x20()\[\]()<>@,;:\\".\x7f-\xff]+'
 _LOCAL_PART_PAT = r"(?:%s)(?:\.(?:%s))*" % (_ATOM_PAT, _ATOM_PAT)
 _RFC822_PAT = r"\A%s@%s\Z" % (_LOCAL_PART_PAT, _LOCAL_PART_PAT)

Index: ServerInfo.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ServerInfo.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- ServerInfo.py	22 Nov 2002 21:11:15 -0000	1.20
+++ ServerInfo.py	2 Dec 2002 03:30:07 -0000	1.21
@@ -242,8 +242,8 @@
     serverKeys.mmtpKey = mmtpKey
     serverKeys.save()
 
-    # XXXX unused
-    allowIncoming = config['Incoming/MMTP'].get('Enabled', 0)
+    # FFFF unused
+    # allowIncoming = config['Incoming/MMTP'].get('Enabled', 0)
 
     nickname = config['Server']['Nickname']
     if not nickname:
@@ -351,8 +351,9 @@
     finally:
         f.close()
 
-    # XXXX for debugging: try to parse and validate the thing we just made.
-    # XXXX Remove this once we're more confident.
+    # This is for debugging: we try to parse and validate the descriptor 
+    #   we just made.
+    # FFFF Remove this once we're more confident.
     ServerInfo(string=info)
 
     return info

Index: ServerMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ServerMain.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- ServerMain.py	22 Nov 2002 21:12:05 -0000	1.14
+++ ServerMain.py	2 Dec 2002 03:30:07 -0000	1.15
@@ -38,16 +38,16 @@
 #                            mmtp.key
 #                            mmtp.cert
 #                      key_2/...
-#                 conf/miniond.conf 
+#                 conf/miniond.conf
 #                       ....
 
 class ServerKeyring:
-    """A ServerKeyRing remembers current and future keys, descriptors, and 
+    """A ServerKeyRing remembers current and future keys, descriptors, and
        hash logs for a mixminion server.
-       
+
        FFFF: We need a way to generate keys as needed
        """
-    # homeDir: server home directory 
+    # homeDir: server home directory
     # keyDir: server key directory
     # keySloppiness: fudge-factor: how forgiving are we about key liveness?
     # keyIntervals: list of (start, end, keyset Name)
@@ -72,7 +72,7 @@
     def checkKeys(self):
 	"""Internal method: read information about all this server's
 	   currently-prepared keys from disk."""
-        self.keyIntervals = [] 
+        self.keyIntervals = []
 	firstKey = sys.maxint
 	lastKey = 0
 
@@ -102,7 +102,7 @@
                 inf = ServerInfo(fname=si, assumeValid=1)
                 t1 = inf['Server']['Valid-After']
                 t2 = inf['Server']['Valid-Until']
-                self.keyIntervals.append( (t1, t2, keysetname) ) 
+                self.keyIntervals.append( (t1, t2, keysetname) )
 	    else:
 		getLog().warn("No server descriptor found for key %s"%dirname)
 
@@ -126,9 +126,10 @@
 	self._getLiveKey()       # Set up liveKey, nextKeyRotation.
 
     def getIdentityKey(self):
-	"""Return this server's identity key.  Generate one if it doesn't 
+	"""Return this server's identity key.  Generate one if it doesn't
 	   exist."""
-	password = None # FFFF unused
+        # FFFF Use this, somehow.
+	password = None
 	fn = os.path.join(self.keyDir, "identity.key")
 	bits = self.config['Server']['IdentityKeyBits']
 	if os.path.exists(fn):
@@ -143,7 +144,7 @@
 	    key = mixminion.Crypto.pk_generate(bits)
 	    mixminion.Crypto.pk_PEM_save(key, fn, password)
 	    getLog().info("Generated %s-bit identity key.", bits)
-	
+
 	return key
 
     def removeIdentityKey(self):
@@ -167,7 +168,8 @@
            make the first key become valid at'startAt'.  Otherwise, make the
 	   first key become valid right after the last key we currently have
 	   expires.  If we have no keys now, make the first key start now."""
-	password = None #FFFF
+        # FFFF Use this.
+	#password = None
 
 	if startAt is None:
 	    if self.keyIntervals:
@@ -176,7 +178,7 @@
 		startAt = time.time()+60
 
 	startAt = previousMidnight(startAt)
-	
+
 	firstKey, lastKey = self.keyRange
 
 	for _ in xrange(num):
@@ -193,7 +195,7 @@
 
 	    nextStart = startAt + self.config['Server']['PublicKeyLifetime'][2]
 
-	    getLog().info("Generating key %s to run from %s through %s (GMT)", 
+	    getLog().info("Generating key %s to run from %s through %s (GMT)",
 			  keyname, _date(startAt), _date(nextStart-3600))
  	    generateServerDescriptorAndKeys(config=self.config,
 					    identityKey=self.getIdentityKey(),
@@ -222,11 +224,11 @@
 	for dirname, (va, vu, name) in zip(dirs, self.keyIntervals):
             getLog().info("Removing%s key %s (valid from %s through %s)",
                         expiryStr, name, _date(va), _date(vu-3600))
-	    files = [ os.path.join(dirname,f) 
+	    files = [ os.path.join(dirname,f)
                                  for f in os.listdir(dirname) ]
 	    secureDelete(files, blocking=1)
 	    os.rmdir(dirname)
-	    
+
 	self.checkKeys()
 
     def _getLiveKey(self, when=None):
@@ -238,7 +240,7 @@
 	    return None
 
 	w = when
-	if when is None: 
+	if when is None:
 	    when = time.time()
 	    if when < self.nextKeyRotation:
 		return self.liveKey
@@ -248,7 +250,7 @@
 	if w is None:
 	    self.liveKey = k
 	    self.nextKeyRotation = k[1]
-		
+
 	return k
 
     def getNextKeyRotation(self):
@@ -262,7 +264,7 @@
 	keyset = ServerKeyset(self.keyDir, name, self.hashDir)
 	keyset.load()
 	return keyset
-	
+
     def getDHFile(self):
 	"""Return the filename for the diffie-helman parameters for the
 	   server.  Creates the file if it doesn't yet exist."""
@@ -275,7 +277,7 @@
             getLog().info("...done")
 
         return dhfile
-			    
+
     def getTLSContext(self):
 	"""Create and return a TLS context from the currently live key."""
         keys = self.getServerKeyset()
@@ -309,9 +311,9 @@
 
     def queueMessage(self, msg):
 	"""Add a message for delivery"""
-	mixminion.Queue.DeliveryQueue.queueMessage(self, None, msg)
-    
-    def deliverMessages(self, msgList):
+	self.queueDeliveryMessage(self, None, msg)
+
+    def _deliverMessages(self, msgList):
 	"Implementation of abstract method from DeliveryQueue."
 	ph = self.packetHandler
 	for handle, _, message, n_retries in msgList:
@@ -353,7 +355,7 @@
 	self.moduleManager = manager
 
     def mix(self):
-	"""Get a batch of messages, and queue them for delivery as 
+	"""Get a batch of messages, and queue them for delivery as
 	   appropriate."""
 	handles = self.queue.getBatch()
 	getLog().trace("Mixing %s messages", len(handles))
@@ -377,11 +379,11 @@
 	self.server = None
 
     def connectQueues(self, server):
-	"""Set the MMTPServer that this OutgoingQueue informs of its 
+	"""Set the MMTPServer that this OutgoingQueue informs of its
 	   deliverable messages."""
 	self.server = server
 
-    def deliverMessages(self, msgList):
+    def _deliverMessages(self, msgList):
 	"Implementation of abstract method from DeliveryQueue."
 	# Map from addr -> [ (handle, msg) ... ]
 	msgs = {}
@@ -425,7 +427,7 @@
 	    keylife = config['Server']['PublicKeyLifetime'][2]
 	    nKeys = ceilDiv(30*24*60*60, keylife)
 	    self.keyring.createKeys(nKeys)
-	    
+
 	self.packetHandler = self.keyring.getPacketHandler()
 	tlsContext = self.keyring.getTLSContext()
 	self.mmtpServer = _MMTPServer(config, tlsContext)
@@ -453,14 +455,16 @@
 	self.outgoingQueue.connectQueues(server=self.mmtpServer)
 	self.mmtpServer.connectQueues(incoming=self.incomingQueue,
 				      outgoing=self.outgoingQueue)
-	
+
     def run(self):
 	"""Run the server; don't return unless we hit an exception."""
 	# FFFF Use heapq to schedule events?
 	now = time.time()
-	nextMix = now + 60 # FFFF Configurable!
+	MIX_INTERVAL = 20  # FFFF Configurable!
+	nextMix = now + MIX_INTERVAL
 	nextShred = now + 6000
-	nextRotate = self.keyring.getNextKeyRotation() # FFFF use this.
+	#FFFF Unused
+	#nextRotate = self.keyring.getNextKeyRotation()
 	while 1:
 	    while time.time() < nextMix:
 		# Handle pending network events
@@ -468,11 +472,11 @@
 		# Process any new messages that have come in, placing them
 		# into the mix pool.
 		self.incomingQueue.sendReadyMessages()
-	    
+
 	    # Before we mix, we need to log the hashes to avoid replays.
 	    # FFFF We need to recover on server failure.
 	    self.packetHandler.syncLogs()
-	    
+
 	    getLog().trace("Mix interval elapsed")
 	    # Choose a set of outgoing messages; put them in outgoingqueue and
 	    # modulemanger
@@ -484,7 +488,7 @@
 
 	    # Choose next mix interval
 	    now = time.time()
-	    nextMix = now + 60
+	    nextMix = now + MIX_INTERVAL
 
 	    if now > nextShred:
 		# FFFF Configurable shred interval
@@ -503,7 +507,6 @@
 
 def usageAndExit(cmd):
     executable = sys.argv[0]
-    # XXXX show versioning info
     print >>sys.stderr, "Usage: %s %s [-h] [-f configfile]" % (executable, cmd)
     sys.exit(0)
 
@@ -531,6 +534,7 @@
 	print >>sys.stderr, "Error in configuration file %r"%configFile
 	print >>sys.stderr, str(e)
 	sys.exit(1)
+    return None #suppress pychecker warning
 
 #----------------------------------------------------------------------
 def runServer(cmd, args):
@@ -558,7 +562,7 @@
     getLog().info("Server shutting down")
     server.close()
     getLog().info("Server is shut down")
-    
+
     sys.exit(0)
 
 #----------------------------------------------------------------------
@@ -595,7 +599,7 @@
     for i in xrange(keys):
 	keyring.createKeys(1)
 	print >> sys.stderr, ".... (%s/%s done)" % (i+1,keys)
-    
+
 #----------------------------------------------------------------------
 def removeKeys(cmd, args):
     # FFFF Resist removing keys that have been published.
@@ -627,7 +631,7 @@
     keyring = ServerKeyring(config)
     keyring.checkKeys()
     # This is impossibly far in the future.
-    keyring.removeDeadKeys(now=(1L << 36)) 
+    keyring.removeDeadKeys(now=(1L << 36))
     if removeIdentity:
         keyring.removeIdentityKey()
     getLog().info("Done removing keys")

Index: __init__.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/__init__.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- __init__.py	21 Nov 2002 19:46:11 -0000	1.6
+++ __init__.py	2 Dec 2002 03:30:07 -0000	1.7
@@ -5,7 +5,7 @@
 
    Client and server code for type III anonymous remailers.
 
-   XXXX write more on principal interfaces"""
+   DOCDOC write more on principal interfaces"""
 
 __version__ = "0.0.1a0"
 __all__ = [ ]
@@ -22,4 +22,5 @@
 import mixminion.MMTPClient
 import mixminion.Packet
 import mixminion.ServerInfo
-
+import mixminion.ServerMain
+import mixminion.ClientMain

Index: benchmark.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/benchmark.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- benchmark.py	22 Nov 2002 21:12:05 -0000	1.12
+++ benchmark.py	2 Dec 2002 03:30:07 -0000	1.13
@@ -486,9 +486,8 @@
     print "                    header sha1: %3.1f%%" % (100*sha1_hdr/sp_ns)
     print "                    keygen sha1: %3.1f%%" % (500*sha1_key/sp_ns)
     print " (logs not included)"
-    # FFFF Time the logs too..?
-
-    # XXXX BUILDMESSAGE efficiency
+    # FFFF Time, including the hashlogs too.
+    # FFFF Time BuildMessage efficiency too.
 
 #----------------------------------------------------------------------
 
@@ -582,8 +581,6 @@
                 _ml.rsa_decode_key(x,public)
             p.get_public_key()
             _ml.rsa_make_public_key(n,e)
-
-	    # XXXX rest of rsa functionality
 
 #----------------------------------------------------------------------