summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas Waldmann <tw@waldmann-edv.de>2023-08-29 22:32:30 +0200
committerThomas Waldmann <tw@waldmann-edv.de>2023-08-29 22:32:30 +0200
commitbfead4b288833f890523d8881797ff6b345edaf9 (patch)
tree33e6bbc45952e365da0c6872e1ce48477a041ec0 /src
parenta2ee13fd341dcd004b4a06b17d6f2fc759327861 (diff)
fixup with msgpack data types related fixes
Diffstat (limited to 'src')
-rw-r--r--src/borg/crypto/key.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/borg/crypto/key.py b/src/borg/crypto/key.py
index ebaee58a2..aa46b2900 100644
--- a/src/borg/crypto/key.py
+++ b/src/borg/crypto/key.py
@@ -307,27 +307,29 @@ class KeyBase:
unpacker = get_limited_unpacker("archive")
unpacker.feed(data)
unpacked = unpacker.unpack()
- if b"tam" not in unpacked:
+ if "tam" not in unpacked:
if tam_required:
- archive_name = unpacked.get(b"name", b"<unknown>").decode("ascii", "replace")
+ archive_name = unpacked.get("name", "<unknown>")
raise ArchiveTAMRequiredError(archive_name)
else:
logger.debug("TAM not found and not required")
return unpacked, False
- tam = unpacked.pop(b"tam", None)
+ tam = unpacked.pop("tam", None)
if not isinstance(tam, dict):
raise ArchiveTAMInvalid()
- tam_type = tam.get(b"type", b"<none>").decode("ascii", "replace")
+ tam_type = tam.get("type", "<none>")
if tam_type != "HKDF_HMAC_SHA512":
if tam_required:
raise TAMUnsupportedSuiteError(repr(tam_type))
else:
logger.debug("Ignoring TAM made with unsupported suite, since TAM is not required: %r", tam_type)
return unpacked, False
- tam_hmac = tam.get(b"hmac")
- tam_salt = tam.get(b"salt")
- if not isinstance(tam_salt, bytes) or not isinstance(tam_hmac, bytes):
+ tam_hmac = tam.get("hmac")
+ tam_salt = tam.get("salt")
+ if not isinstance(tam_salt, (bytes, str)) or not isinstance(tam_hmac, (bytes, str)):
raise ArchiveTAMInvalid()
+ tam_hmac = want_bytes(tam_hmac) # legacy
+ tam_salt = want_bytes(tam_salt) # legacy
offset = data.index(tam_hmac)
data[offset : offset + 64] = bytes(64)
tam_key = self._tam_key(tam_salt, context=b"archive")