changeset 602:92929d26b8db

Fix failure to provide default initialisation vector for AES CBC mode (I'm surprised pycrypto allowed this previously, but it doesn't now, thus catching my error). Also make debug output a bit more helpful
author Chris Cannam
date Tue, 03 Jul 2012 10:02:22 +0100
parents 2985c2a90146
children 10ef94e51f44
files easyhg.py
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/easyhg.py	Fri May 18 09:34:12 2012 +0100
+++ b/easyhg.py	Tue Jul 03 10:02:22 2012 +0100
@@ -53,12 +53,18 @@
 # "remember this password") feature without them
 #
 easyhg_authfile_imports_ok = True
+
 try:
     from Crypto.Cipher import AES
+except ImportError:
+    print "EasyHg: Failed to import Crypto.Cipher module required for authfile support (try installing PyCrypto?)"
+    easyhg_authfile_imports_ok = False
+
+try:
     import ConfigParser # Mercurial version won't write files
     import base64
 except ImportError:
-    print "EasyHg: Failed to import required modules for authfile support"
+    print "EasyHg: Failed to import modules (ConfigParser, base64) required for authfile support"
     easyhg_authfile_imports_ok = False
 
 
@@ -83,7 +89,8 @@
         self.remember = False
 
         if self.use_auth_file:
-            self.auth_cipher = AES.new(self.auth_key, AES.MODE_CBC)
+            self.auth_cipher = AES.new(self.auth_key, AES.MODE_CBC,
+                                       os.urandom(16))
             self.auth_file = os.path.expanduser(self.auth_file)
             self.load_auth_data()