[Nym3-commit] r174 - trunk/nym3/Client
laurent at conuropsis.org
laurent at conuropsis.org
Tue Apr 5 23:16:01 CEST 2005
Author: laurent
Date: 2005-04-05 23:15:58 +0200 (Tue, 05 Apr 2005)
New Revision: 174
Modified:
trunk/nym3/Client/Account.py
trunk/nym3/Client/Config.py
trunk/nym3/Client/Keyring.py
trunk/nym3/Client/Main.py
Log:
Make Main.setupAccount and Keyring play together.
Modified: trunk/nym3/Client/Account.py
===================================================================
--- trunk/nym3/Client/Account.py 2005-04-05 15:59:38 UTC (rev 173)
+++ trunk/nym3/Client/Account.py 2005-04-05 21:15:58 UTC (rev 174)
@@ -112,8 +112,17 @@
return rtag
class Account:
- """Hold account data"""
+ """Hold account data. Specifically, this means:
+ - idTag is the identity string used to generate SURBs for this
+ account. It is therefore unique to this account. Additionnaly
+ it is used to name the subdirectory holding this account's data
+ - datafile is the file which holds all of this. A mere pickling
+ - index. What was that again?
+ - params is a dictionnary of misc parameters
+ - syn is the synopsis box (synbox)
+ - mbox is self explanatory"""
+
def __init__(self, config, nickname, create = 0):
"""Load from an existing account, or create a new, or fail"""
# Set data to dummy values
@@ -134,7 +143,6 @@
# Everything below this line has not been reread and can be considered
# work in progress.
self._lock()
-
def __del__(self):
"""Flushes the user account to the disk"""
Modified: trunk/nym3/Client/Config.py
===================================================================
--- trunk/nym3/Client/Config.py 2005-04-05 15:59:38 UTC (rev 173)
+++ trunk/nym3/Client/Config.py 2005-04-05 21:15:58 UTC (rev 174)
@@ -22,6 +22,8 @@
# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+import os
+
class Config:
def __init__(self):
@@ -31,6 +33,9 @@
#The path to the directory containing the user accounts
self.path = '.'
+ self.pubring_path = self.path + os.sep + "pubring"
+ self.secring_path = self.path + os.sep + "secring"
+
#address where surbs point to"""
self.defaultAddress = "smtp:nobody at nowhere.net"
Modified: trunk/nym3/Client/Keyring.py
===================================================================
--- trunk/nym3/Client/Keyring.py 2005-04-05 15:59:38 UTC (rev 173)
+++ trunk/nym3/Client/Keyring.py 2005-04-05 21:15:58 UTC (rev 174)
@@ -1,4 +1,5 @@
# $Id$
+# -*- coding: utf-8 -*-
#
# Copyright (c) 2004,2005 Jean-René Reinhard <jr at komite.net>
# and Laurent Fousse <laurent at komite.net>.
@@ -26,18 +27,23 @@
import random
from mixminion.Crypto import sha1, ctr_crypt, AES_KEY_LEN
+class NewKeyring(Exception): pass
+
class Keyring:
- """Class that holds a user keyring"""
+ """Class that holds a user keyring.
+ Keys are stored in a file and are accessed via an abstract
+ handle (a string)."""
+ # TODO : this would need locking. Somewhere.
def __init__(self, keyfile):
self.keyfile = keyfile
try:
f = open(keyfile, 'r')
self.datastring = f.read()
- f.close
+ f.close()
except IOError:
- raise "Duh"
+ raise NewKeyring()
self.status = 'encrypted'
def decrypt(self, passphrase):
@@ -55,7 +61,24 @@
self.status = 'clear'
self.passphrase = passphrase
- def save(self):
+ def _get_unused_handle(self):
+ handle = "42"
+ while self.data.has_key(handle):
+ handle = Mail.genmid(8)
+ return handle
+
+ def store(self, key):
+ handle = self._get_unused_handle()
+ self.data[handle] = key
+ return handle
+
+ def update_key(self, handle, key):
+ self.data[handle] = key
+
+ def get_key(self, handle):
+ return self.data[handle]
+
+ def save(self, passphrase):
"""Save the current keyring to file"""
salt = ""
for i in range(0, SALT_LEN):
Modified: trunk/nym3/Client/Main.py
===================================================================
--- trunk/nym3/Client/Main.py 2005-04-05 15:59:38 UTC (rev 173)
+++ trunk/nym3/Client/Main.py 2005-04-05 21:15:58 UTC (rev 174)
@@ -34,10 +34,12 @@
import nym3.Message as Message
import nym3.Common as Common
import nym3.Mail as Mail
+import nym3.Client.Keyring as Keyring
import mixminion.Crypto as _cr
class CLI:
- def __init__(self): pass
+ def __init__(self):
+ self.prompthidden = self.prompt # TODO
def prompt(self, s):
sys.stdout.write(s + ": ")
@@ -89,6 +91,27 @@
if not emailAddress:
emailAddress = ui.prompt("What is the default email address for "
"returning messages")
+ idKey = _cr.pk_generate()
+ encKey = _cr.pk_generate()
+ # We have gathered the relevant information for this account, except for
+ # the policy which we don't let the user change at this point for the sake
+ # of simplicity. So, let's store all of that in the account and prepare the
+ # message for the server.
+ try:
+ pubring = Keyring.Keyring(config.pubring_path)
+ except: pass
+ try:
+ secring = Keyring.Keyring(config.secring_path)
+ except Keyring.NewKeyring:
+ # The Keyring is new. We need to ask the user for a password.
+ # Twice.
+ while True:
+ passphrase1 = ui.prompthidden("Please enter a passphrase to"
+ " protect your secret keyring")
+ passphrase2 = ui.prompthidden("Again")
+ if passphrase1 == passphrase2: break
+ # TODO : warn for an empty passphrase.
+ ui.display("Passphrases do not match.")
def main(args):
More information about the Nym3-commit
mailing list