Mercurial > hg > easyhg
comparison easyhg.py @ 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 | 533519ebc0cb |
children | e34de484415c |
comparison
equal
deleted
inserted
replaced
601:2985c2a90146 | 602:92929d26b8db |
---|---|
51 | 51 |
52 # These imports are optional, we just can't use the authfile (i.e. | 52 # These imports are optional, we just can't use the authfile (i.e. |
53 # "remember this password") feature without them | 53 # "remember this password") feature without them |
54 # | 54 # |
55 easyhg_authfile_imports_ok = True | 55 easyhg_authfile_imports_ok = True |
56 | |
56 try: | 57 try: |
57 from Crypto.Cipher import AES | 58 from Crypto.Cipher import AES |
59 except ImportError: | |
60 print "EasyHg: Failed to import Crypto.Cipher module required for authfile support (try installing PyCrypto?)" | |
61 easyhg_authfile_imports_ok = False | |
62 | |
63 try: | |
58 import ConfigParser # Mercurial version won't write files | 64 import ConfigParser # Mercurial version won't write files |
59 import base64 | 65 import base64 |
60 except ImportError: | 66 except ImportError: |
61 print "EasyHg: Failed to import required modules for authfile support" | 67 print "EasyHg: Failed to import modules (ConfigParser, base64) required for authfile support" |
62 easyhg_authfile_imports_ok = False | 68 easyhg_authfile_imports_ok = False |
63 | 69 |
64 | 70 |
65 class EasyHgAuthStore(object): | 71 class EasyHgAuthStore(object): |
66 | 72 |
81 self.auth_config = None | 87 self.auth_config = None |
82 self.auth_cipher = None | 88 self.auth_cipher = None |
83 self.remember = False | 89 self.remember = False |
84 | 90 |
85 if self.use_auth_file: | 91 if self.use_auth_file: |
86 self.auth_cipher = AES.new(self.auth_key, AES.MODE_CBC) | 92 self.auth_cipher = AES.new(self.auth_key, AES.MODE_CBC, |
93 os.urandom(16)) | |
87 self.auth_file = os.path.expanduser(self.auth_file) | 94 self.auth_file = os.path.expanduser(self.auth_file) |
88 self.load_auth_data() | 95 self.load_auth_data() |
89 | 96 |
90 def save(self): | 97 def save(self): |
91 if self.use_auth_file: | 98 if self.use_auth_file: |