[Nym3-commit] r215 - trunk/nym3/Client
laurent at conuropsis.org
laurent at conuropsis.org
Sun May 1 18:45:04 CEST 2005
Author: laurent
Date: 2005-05-01 18:45:02 +0200 (Sun, 01 May 2005)
New Revision: 215
Modified:
trunk/nym3/Client/Account.py
trunk/nym3/Client/Main.py
Log:
Added client-side SUMMARY parsing.
Modified: trunk/nym3/Client/Account.py
===================================================================
--- trunk/nym3/Client/Account.py 2005-05-01 15:22:53 UTC (rev 214)
+++ trunk/nym3/Client/Account.py 2005-05-01 16:45:02 UTC (rev 215)
@@ -392,5 +392,10 @@
self.journal = {}
self.journal_status = 'ok'
+ def add_synset(self, midlist, bf, synset):
+ if self.synbox_status == 'unloaded': self._load_synbox()
+ t = (midlist, bf, synset)
+ self.synbox.append(t)
+
def add_enckey(self, key):
self['encKeys'].insert(0, key)
Modified: trunk/nym3/Client/Main.py
===================================================================
--- trunk/nym3/Client/Main.py 2005-05-01 15:22:53 UTC (rev 214)
+++ trunk/nym3/Client/Main.py 2005-05-01 16:45:02 UTC (rev 215)
@@ -83,6 +83,15 @@
print s
return sys.stdin.read()
+def decode_secring(config, ui):
+ secring = Keyring.Keyring(config.secring_path)
+ ui.display("You need to provide your passphrase to unlock your keyring")
+ while True:
+ passphrase1 = ui.prompthidden("Passphrase")
+ if secring.decrypt(passphrase1): break
+ ui.display("wrong passphrase")
+ return secring
+
def processMessage(msg, config, ui, nickname):
"""process incoming control message"""
@@ -111,7 +120,29 @@
# TODO raise some warnings, exec some automatic actions and warn
# the user
elif (com.ct() == SToCCODE['Summary']):
- pass
+ # We need to decrypt the set of synopsis to retrieve the MIDs
+ try:
+ secring = decode_secring(config, ui)
+ except Keyring.NewKeyring:
+ # The Keyring is new. That shouldn't happen
+ raise Exception('Bug keyring?')
+ clear = None
+ for k in account['encKeys']:
+ enckey = _cr.pk_decode_private_key(secring.get_key(k))
+ try:
+ clear = _cr.pk_decrypt(com.synSet, enckey)
+ break
+ except: pass
+ if not clear:
+ ui.display("Could not decrypt synopsis")
+ sys.exit(1)
+ midlist = []
+ while len(clear) > 0:
+ mid = clear[:20]
+ synlen = Message.strToIntBE(clear[20:22])
+ midlist.append(mid)
+ clear = clear[22 + synlen:]
+ account.add_synset(midlist, com.bf, com.synSet)
elif (com.ct() == SToCCODE['Msg']):
pass
elif (com.ct() == SToCCODE['Dropped']):
More information about the Nym3-commit
mailing list