[pass] revelation2pass add plain XML import
javali at sci.fi
javali at sci.fi
Thu Apr 17 09:58:16 CEST 2014
Hi
I found that revelatio2pass.py script doesn't work. It can not decrypt my password file. I got following error message:
Traceback (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)
ValueError: Input strings must be a multiple of 16 in length
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.
My patch is below:
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()
More information about the Password-Store
mailing list