[Nym3-commit] r246 - trunk/nym3/Client

laurent at conuropsis.org laurent at conuropsis.org
Sat May 7 14:11:08 CEST 2005


Author: laurent
Date: 2005-05-07 14:11:07 +0200 (Sat, 07 May 2005)
New Revision: 246

Modified:
   trunk/nym3/Client/Config.py
   trunk/nym3/Client/Main.py
Log:
decipher_string needs to follow specs ?\194?\1674.2.


Modified: trunk/nym3/Client/Config.py
===================================================================
--- trunk/nym3/Client/Config.py	2005-05-07 10:31:56 UTC (rev 245)
+++ trunk/nym3/Client/Config.py	2005-05-07 12:11:07 UTC (rev 246)
@@ -31,7 +31,7 @@
 	# through mixminion or output them on stdout
 	self.DEBUG = False
 	#The path to the directory containing the user accounts
-	self.path = '/tmp'
+	self.path = '/home/laurent/.nym3-account'
 
 	self.pubring_path = self.path + os.sep + "pubring"
 	self.secring_path = self.path + os.sep + "secring"

Modified: trunk/nym3/Client/Main.py
===================================================================
--- trunk/nym3/Client/Main.py	2005-05-07 10:31:56 UTC (rev 245)
+++ trunk/nym3/Client/Main.py	2005-05-07 12:11:07 UTC (rev 246)
@@ -37,6 +37,7 @@
 import nym3.Message as Message
 import nym3.Common as Common
 import nym3.Mail as Mail
+import nym3.Crypto as Crypto
 import nym3.Client.Keyring as Keyring
 import mixminion.Crypto as _cr
 import mixminion.ClientDirectory as _cl
@@ -106,18 +107,15 @@
     return secring
 
 def decipher_string(string, keyring, key_handles):
-    """decipher string with a key contained in keyring with a handle
-    among those provided in key_handles. returns the clear text if
-    it can be found, None otherwise"""
-    #TODO is it correct that any wrong key raises an exception in pk_decrypt?
+    """Wrapper around Crypto.nym_decrypt which tries every available
+       keys in keyring[key_handles] until one is able to decrypt"""
     clear = None
     for k in key_handles:
-	enckey = _cr.pk_decode_private_key(keyring.get_key(k))
+	enckey = keyring.get_key(k)
 	try:
-	    clear = _cr.pk_decrypt(string, enckey)
+	    clear = Crypto.nym_decrypt(string, enckey)
 	    break
-	except:
-	    pass
+	except: pass
     return clear
 
 def get_account_from_nickname(ui, config, nickname, fail_none):
@@ -419,6 +417,8 @@
     account = get_account_from_nickname(ui, config, nickname,
 	    "No nickname given, abort\nUse -n <nickname>")
     output_f = sys.stdout
+    secring = decode_secring(config, ui)
+    mbox = account.get_mbox()
     if output != None:
 	try:
 	    output_f = open(output, "w")
@@ -428,7 +428,8 @@
     for hmid in args:
 	mid = binascii.unhexlify(hmid)
 	if mbox.has_key(mid):
-	    output_f.write(mbox[mid])
+	    clear = decipher_string(mbox[mid], secring, account['encKeys'])
+	    output_f.write(clear)
 	else:
 	    ui.display("%s: no email relative to that mid" % hmid)
     if output_f != sys.stdout:



More information about the Nym3-commit mailing list