|
@@ -22,6 +22,7 @@ from ..helpers import get_limited_unpacker
|
|
|
from ..helpers import bin_to_hex
|
|
|
from ..helpers import prepare_subprocess_env
|
|
|
from ..helpers import msgpack
|
|
|
+from ..helpers import workarounds
|
|
|
from ..item import Key, EncryptedKey
|
|
|
from ..platform import SaveFile
|
|
|
from .nonces import NonceManager
|
|
@@ -30,6 +31,10 @@ from .low_level import AES, bytes_to_long, bytes_to_int, num_aes_blocks, hmac_sh
|
|
|
PREFIX = b'\0' * 8
|
|
|
|
|
|
|
|
|
+# workaround for lost passphrase or key in "authenticated" or "authenticated-blake2" mode
|
|
|
+AUTHENTICATED_NO_KEY = 'authenticated_no_key' in workarounds
|
|
|
+
|
|
|
+
|
|
|
class NoPassphraseFailure(Error):
|
|
|
"""can not acquire a passphrase: {}"""
|
|
|
|
|
@@ -228,6 +233,8 @@ class KeyBase:
|
|
|
unpacker = get_limited_unpacker('manifest')
|
|
|
unpacker.feed(data)
|
|
|
unpacked = unpacker.unpack()
|
|
|
+ if AUTHENTICATED_NO_KEY:
|
|
|
+ return unpacked, True # True is a lie.
|
|
|
if b'tam' not in unpacked:
|
|
|
if tam_required:
|
|
|
raise TAMRequiredError(self.repository._location.canonical_path())
|
|
@@ -836,6 +843,19 @@ class AuthenticatedKeyBase(RepoKey):
|
|
|
# It's only authenticated, not encrypted.
|
|
|
logically_encrypted = False
|
|
|
|
|
|
+ def _load(self, key_data, passphrase):
|
|
|
+ if AUTHENTICATED_NO_KEY:
|
|
|
+ # fake _load if we have no key or passphrase
|
|
|
+ NOPE = bytes(32) # 256 bit all-zero
|
|
|
+ self.repository_id = NOPE
|
|
|
+ self.enc_key = NOPE
|
|
|
+ self.enc_hmac_key = NOPE
|
|
|
+ self.id_key = NOPE
|
|
|
+ self.chunk_seed = 0
|
|
|
+ self.tam_required = False
|
|
|
+ return True
|
|
|
+ return super()._load(key_data, passphrase)
|
|
|
+
|
|
|
def load(self, target, passphrase):
|
|
|
success = super().load(target, passphrase)
|
|
|
self.logically_encrypted = False
|
|
@@ -867,6 +887,8 @@ class AuthenticatedKeyBase(RepoKey):
|
|
|
if not decompress:
|
|
|
return payload
|
|
|
data = self.decompress(payload)
|
|
|
+ if AUTHENTICATED_NO_KEY:
|
|
|
+ return data
|
|
|
self.assert_id(id, data)
|
|
|
return data
|
|
|
|