diff --git a/pycryptomator/__init__.py b/pycryptomator/__init__.py index fe5db6d..5ac2c86 100644 --- a/pycryptomator/__init__.py +++ b/pycryptomator/__init__.py @@ -1,4 +1,4 @@ COPYRIGHT = '''Copyright (C)2024, by maxpat78.''' -__version__ = '1.12' +__version__ = '1.14' __all__ = ["Vault", "init_vault", "backupDirIds"] from .cryptomator import * diff --git a/pycryptomator/cryptomator.py b/pycryptomator/cryptomator.py index 10220c2..1c30a9c 100644 --- a/pycryptomator/cryptomator.py +++ b/pycryptomator/cryptomator.py @@ -161,9 +161,13 @@ def encryptName(p, dirId, name): def decryptName(p, dirId, name): "Decrypt a .c9r name" - assert name[-4:] == b'.c9r' - dname = d64(name[:-4], 1) - return aes_siv_decrypt(p.pk, p.hk, dname, dirId) + try: + assert name[-4:] == b'.c9r' + dname = d64(name[:-4], 1) + return aes_siv_decrypt(p.pk, p.hk, dname, dirId) + except: + print('ERROR: could not decrypt name', name.decode()) + return None def getInfo(p, virtualpath): "Query information about a vault's virtual path name and get a PathInfo object" @@ -733,10 +737,14 @@ def _walker(p, pathname, mode='walk'): if it.name.endswith('.c9s'): # deflated long name # A c9s dir contains the original encrypted long name (name.c9s) and encrypted contents (contents.c9r) ename = open(join(realpath, it.name, 'name.c9s')).read() - dname = p.decryptName(dirId.encode(), ename.encode()).decode() + dname = p.decryptName(dirId.encode(), ename.encode()) + if dname == None: continue + dname = dname.decode() if exists(join(realpath, it.name, 'contents.c9r')): is_dir = False else: - dname = p.decryptName(dirId.encode(), it.name.encode()).decode() + dname = p.decryptName(dirId.encode(), it.name.encode()) + if dname == None: continue + dname = dname.decode() sl = join(realpath, it.name, 'symlink.c9r') if is_dir and exists(sl): # Decrypt and look at symbolic link target