Browse Source

bugfix: skip TAM check with BORG_WORKAROUNDS=authenticated_no_key

This is an emergency workaround for authenticated repos
if the user has lost the borg key.

We can't compute the TAM key without the borg key, so just
skip all the TAM stuff.
Thomas Waldmann 1 year ago
parent
commit
104cc196fc
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/borg/crypto/key.py

+ 2 - 2
src/borg/crypto/key.py

@@ -235,6 +235,8 @@ class KeyBase:
         unpacker = get_limited_unpacker('manifest')
         unpacker = get_limited_unpacker('manifest')
         unpacker.feed(data)
         unpacker.feed(data)
         unpacked = unpacker.unpack()
         unpacked = unpacker.unpack()
+        if AUTHENTICATED_NO_KEY:
+            return unpacked, True  # True is a lie.
         if b'tam' not in unpacked:
         if b'tam' not in unpacked:
             if tam_required:
             if tam_required:
                 raise TAMRequiredError(self.repository._location.canonical_path())
                 raise TAMRequiredError(self.repository._location.canonical_path())
@@ -258,8 +260,6 @@ class KeyBase:
         offset = data.index(tam_hmac)
         offset = data.index(tam_hmac)
         data[offset:offset + 64] = bytes(64)
         data[offset:offset + 64] = bytes(64)
         tam_key = self._tam_key(tam_salt, context=b'manifest')
         tam_key = self._tam_key(tam_salt, context=b'manifest')
-        if AUTHENTICATED_NO_KEY:
-            return unpacked, True  # True is a lie.
         calculated_hmac = hmac.digest(tam_key, data, 'sha512')
         calculated_hmac = hmac.digest(tam_key, data, 'sha512')
         if not hmac.compare_digest(calculated_hmac, tam_hmac):
         if not hmac.compare_digest(calculated_hmac, tam_hmac):
             raise TAMInvalid()
             raise TAMInvalid()