chiark / gitweb /
catacomb.c, ec.c: Bindings for the new EC2OSP/OS2ECP functions.
[catacomb-python] / pwsafe
diff --git a/pwsafe b/pwsafe
index a5d15eac6cd78c53444982bc78b5b47660722304..91684c75faec4053cb81a954460f0c5f72d4ed24 100644 (file)
--- a/pwsafe
+++ b/pwsafe
@@ -105,26 +105,9 @@ def cmd_create(av):
   else:
     tag = 'pwsafe'
 
-  ## Choose a passphrase, and generate master keys.
-  pp = C.ppread(tag, C.PMODE_VERIFY)
-  if not mac: mac = hash + '-hmac'
-  c = C.gcciphers[cipher]
-  h = C.gchashes[hash]
-  m = C.gcmacs[mac]
-  ppk = PW.PPK(pp, c, h, m)
-  ck = C.rand.block(c.keysz.default)
-  mk = C.rand.block(m.keysz.default)
-  k = Crypto(c, h, m, ck, mk)
-
-  ## Set up the database, storing the basic information we need.
-  db = G.open(file, 'n', 0600)
-  db['tag'] = tag
-  db['salt'] = ppk.salt
-  db['cipher'] = cipher
-  db['hash'] = hash
-  db['mac'] = mac
-  db['key'] = ppk.encrypt(wrapstr(ck) + wrapstr(mk))
-  db['magic'] = k.encrypt(C.rand.block(h.hashsz))
+  ## Set up the database.
+  if mac is None: mac = hash + '-hmac'
+  PW.create(file, C.gcciphers[cipher], C.gchashes[hash], C.gcmacs[mac], tag)
 
 def cmd_changepp(av):
   if len(av) != 0: