From 1763e2d0347c38aa8f7167f6fcfd4401fd6995dc Mon Sep 17 00:00:00 2001 From: Javali Date: Thu, 17 Apr 2014 12:50:23 +0200 Subject: revelation2pass: add plain XML import I found that revelatio2pass.py script doesn't work. It can not decrypt my password file. I got following error message: raceback (most recent call last): File "git/password-store/contrib/importers/revelation2pass.py", line 159, in main(args.FILE, verbose=args.verbose, xml=args.xml) File "git/password-store/contrib/importers/revelation2pass.py", line 140, in main cleardata_gz = decrypt_gz(password, data) File "git/password-store/contrib/importers/revelation2pass.py", line 117, in decrypt_gz ct = c.decrypt(cipher_text[28:]) File "/usr/lib/python2.7/site-packages/Crypto/Cipher/blockalgo.py", line 295, in decrypt return self._cipher.decrypt(ciphertext) I was unable to fix the problem, but I created a workaround, that add plain XML import option to the revelation2pass.py script. Revelation can export its password file as plain XML format. --- contrib/importers/revelation2pass.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'contrib/importers') diff --git a/contrib/importers/revelation2pass.py b/contrib/importers/revelation2pass.py index f04c1a8..cc2d01c 100755 --- a/contrib/importers/revelation2pass.py +++ b/contrib/importers/revelation2pass.py @@ -122,25 +122,29 @@ def decrypt_gz(key, cipher_text): ct = c.decrypt(cipher_text[28:], iv=iv) return ct -def main(datafile, verbose=False): +def main(datafile, verbose=False, xml=False): f = None with open(datafile, "rb") as f: # Encrypted data data = f.read() - password = getpass.getpass() - # Pad password - password += (chr(0) * (32 - len(password))) - # Decrypt. Decrypted data is compressed - cleardata_gz = decrypt_gz(password, data) - # Length of data padding - padlen = ord(cleardata_gz[-1]) - # Decompress actual data (15 is wbits [ref3] DON'T CHANGE, 2**15 is the (initial) buf size) - xmldata = zlib.decompress(cleardata_gz[:-padlen], 15, 2**15) + if xml: + xmldata = data + else: + password = getpass.getpass() + # Pad password + password += (chr(0) * (32 - len(password))) + # Decrypt. Decrypted data is compressed + cleardata_gz = decrypt_gz(password, data) + # Length of data padding + padlen = ord(cleardata_gz[-1]) + # Decompress actual data (15 is wbits [ref3] DON'T CHANGE, 2**15 is the (initial) buf size) + xmldata = zlib.decompress(cleardata_gz[:-padlen], 15, 2**15) root = etree.fromstring(xmldata) import_subentries(root, verbose=verbose) if __name__ == '__main__': parser = argparse.ArgumentParser() + parser.add_argument('-x', '--xml', help='read plain XML file', action='store_true') parser.add_argument('--verbose', '-v', action='count') parser.add_argument('FILE', help="the file storing the Revelation passwords") args = parser.parse_args() @@ -149,7 +153,7 @@ if __name__ == '__main__': sys.stderr.write(s+'\n') try: - main(args.FILE, verbose=args.verbose) + main(args.FILE, verbose=args.verbose, xml=args.xml) except KeyboardInterrupt: if args.verbose: traceback.print_exc() -- cgit v1.2.3