[Nym3-commit] r179 - in trunk/nym3: . Client

laurent at conuropsis.org laurent at conuropsis.org
Sat Apr 9 15:24:06 CEST 2005


Author: laurent
Date: 2005-04-09 15:24:02 +0200 (Sat, 09 Apr 2005)
New Revision: 179

Modified:
   trunk/nym3/Client/Main.py
   trunk/nym3/Message.py
Log:
Go on with setupAccount and change Newpk as needed.


Modified: trunk/nym3/Client/Main.py
===================================================================
--- trunk/nym3/Client/Main.py	2005-04-08 19:43:54 UTC (rev 178)
+++ trunk/nym3/Client/Main.py	2005-04-09 13:24:02 UTC (rev 179)
@@ -138,7 +138,6 @@
 		passphrase1 = ui.prompthidden("Passphrase")
 		if secring.decrypt(passphrase1): break
 		ui.display("wrong passphrase")
-
     except Keyring.NewKeyring:
 	# The Keyring is new. We need to ask the user for a password.
 	# Twice.
@@ -157,7 +156,12 @@
     pubring.update_key(enctag, _cr.pk_encode_public_key(encKey))
     secring.save(passphrase1)
     pubring.save("nym3")
-    
+    createc = Message.Create()
+    createc.fromData(usernamelist, "POW") # TODO what was the proof of work?
+    newpkc = Message.Newpk()
+    newpkc.fromData(idKey, encKey)
+    surbc = Message.Surb()
+    surbc.fromData(account.generateSurbs(7))
 	
 def main(args):
     if len(args) < 2:

Modified: trunk/nym3/Message.py
===================================================================
--- trunk/nym3/Message.py	2005-04-08 19:43:54 UTC (rev 178)
+++ trunk/nym3/Message.py	2005-04-09 13:24:02 UTC (rev 179)
@@ -29,6 +29,7 @@
 
 import types
 import nym3.Common as Common
+import mixminion.Crypto as _cr
 
 
 # Every command type has a numerical code as described in nym-spec.
@@ -437,10 +438,8 @@
 	
 class Newpk(CommandCToS):
 	"""Newpk command
-	self.kid : identity key RSA modulus BE encoded (str)
-	self.kenc : encryption key RSA modulus BE  encoded (str)
-	self.idf : number of bits of kid is 1024*idf
-	self.encf : number of bits of kid is 1024*encf"""
+	self.idKey : identity RSA Key, ASN.1 encoded (str)
+	self.encKey : encryption RSA Key, ASN.1 encoded (str)"""
 	
 	def __init__(self):
 		"""Build a Newpk empty object"""
@@ -450,21 +449,16 @@
 		"""return a int for the code of the command"""
 		return CToSCODE['Newpk']
 
-	def fromData(self, sid, senc):
-		"""Fill a Newpk Object from 2 modulus (int)"""
-		id_l = nbBits(sid)
-		id_l2 = nbBits(senc)
-		if( ((id_l != 1024) and (id_l != 2048)) or ( (id_l2 != 1024) and (id_l2 != 2048))):
-			raise BadArgument("Newpk.fromData : sid or senc as not a valid size")
-		self.idf = id_l / 1024
-		self.encf = id_l2 / 1024
-		self.kid = sid
-		self.kenc = senc
-		#command body is small enough
+	def fromData(self, idKey, encKey):
+		"""Fill a Newpk Object from 2 Key objects"""
+		# TODO : add keylength compliance checks.
+		self.idKey = _cr.pk_encode_public_key(idKey)
+		self.encKey = _cr.pk_encode_public_key(encKey)
 
 	def fromStrReader(self, sr, cs):
 		"""Fill a Newpk Object from a StrReader
 		raise ParseError if it is malformed"""
+		# TODO : b0rken.
 		try:
 			id_l = strToIntBE(sr.next(2))
 			if((id_l != 128) and (id_l != 256)):
@@ -481,13 +475,10 @@
 			raise ParseError("Bad Formed Command : Newpk")
 
 	def __str__(self):
-		"""Give the string of the Command that would be sent in a control message"""
-		#TODO check assuming len(kid)=128 or 256
-
-		s=intToStrBE(128 * self.idf, 2) + intToStrBE(self.kid, 128*self.idf) + intToStrBE(self.kenc, 128*self.encf)
-		if(len(s)>=pow(256,3)): #should not be possible, otherwise bug
-			raise BadArgument("Newpk.__str__ : command body too long")
-		return chr(self.ct()) + intToStrBE(len(s),3) + s
+	    """Give the string of the Command that would be sent
+	       in a control message"""
+	    data = intToStrBE(len(self.idKey), 2) + self.idKey + self.encKey
+	    return chr(self.ct()) + intToStrBE(len(data), 3) + data
 	
 class Relay(CommandCToS):
 	"""Relay command



More information about the Nym3-commit mailing list