Skip to content

Commit

Permalink
check: --verify-data does not need to decompress with new crypto modes
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasWaldmann committed Jul 20, 2022
1 parent 9d6c98d commit 6b1bff2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/borg/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from . import xattr
from .chunker import get_chunker, Chunk
from .cache import ChunkListEntry
from .crypto.key import key_factory
from .crypto.key import key_factory, AEADKeyBase
from .compress import Compressor, CompressionSpec
from .constants import * # NOQA
from .crypto.low_level import IntegrityError as IntegrityErrorBase
Expand Down Expand Up @@ -1714,7 +1714,13 @@ def verify_data(self):
chunk_data_iter = self.repository.get_many(chunk_ids)
else:
try:
self.key.decrypt(chunk_id, encrypted_data)
# for the new crypto, derived from AEADKeyBase, we know that it checks authenticity on
# the crypto.low_level level - invalid chunks will fail to AEAD authenticate.
# for these key types, we know that there is no need to decompress the data afterwards.
# for all other modes, we assume that we must decompress, so we can verify authenticity
# based on the plaintext MAC (via calling ._assert_id(id, plaintext)).
decompress = not isinstance(self.key, AEADKeyBase)
self.key.decrypt(chunk_id, encrypted_data, decompress=decompress)
except IntegrityErrorBase as integrity_error:
self.error_found = True
errors += 1
Expand Down

0 comments on commit 6b1bff2

Please sign in to comment.