diff options
author | Javali <javali@sci.fi> | 2014-04-17 12:50:23 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2014-04-17 12:50:23 +0200 |
commit | 1763e2d0347c38aa8f7167f6fcfd4401fd6995dc (patch) | |
tree | de81f62295b9cb10fa0c84391a0d73861fb9678a /contrib/importers | |
parent | 3f6b8a2038eea906b353894dcb160bf0d88f6fd7 (diff) | |
download | pass-1763e2d0347c38aa8f7167f6fcfd4401fd6995dc.tar.gz pass-1763e2d0347c38aa8f7167f6fcfd4401fd6995dc.tar.bz2 pass-1763e2d0347c38aa8f7167f6fcfd4401fd6995dc.zip |
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 <module>
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.
Diffstat (limited to 'contrib/importers')
-rwxr-xr-x | contrib/importers/revelation2pass.py | 26 |
1 files changed, 15 insertions, 11 deletions
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() |