mirror of
https://github.com/borgbackup/borg.git
synced 2026-06-11 01:41:57 -04:00
FileHashingWrapper: support and use sha256
Cryptographically strong and often hw accelerated nowadays. Also support by borgstore hash method.
This commit is contained in:
parent
9389d98c6d
commit
53b48f0940
1 changed files with 5 additions and 15 deletions
|
|
@ -5,8 +5,6 @@ from hmac import compare_digest
|
|||
from collections.abc import Callable
|
||||
from pathlib import Path
|
||||
|
||||
from xxhash import xxh64
|
||||
|
||||
from ..helpers import IntegrityError
|
||||
from ..logger import create_logger
|
||||
|
||||
|
|
@ -106,20 +104,12 @@ class FileHashingWrapper(FileLikeWrapper):
|
|||
self.hash.update(str(self.tell()).encode())
|
||||
|
||||
|
||||
class SHA512FileHashingWrapper(FileHashingWrapper):
|
||||
ALGORITHM = "SHA512"
|
||||
FACTORY = hashlib.sha512
|
||||
class SHA256FileHashingWrapper(FileHashingWrapper):
|
||||
ALGORITHM = "SHA256"
|
||||
FACTORY = hashlib.sha256
|
||||
|
||||
|
||||
class XXH64FileHashingWrapper(FileHashingWrapper):
|
||||
ALGORITHM = "XXH64"
|
||||
FACTORY = xxh64
|
||||
|
||||
|
||||
SUPPORTED_ALGORITHMS = {
|
||||
SHA512FileHashingWrapper.ALGORITHM: SHA512FileHashingWrapper,
|
||||
XXH64FileHashingWrapper.ALGORITHM: XXH64FileHashingWrapper,
|
||||
}
|
||||
SUPPORTED_ALGORITHMS = {SHA256FileHashingWrapper.ALGORITHM: SHA256FileHashingWrapper}
|
||||
|
||||
|
||||
class FileIntegrityError(IntegrityError):
|
||||
|
|
@ -137,7 +127,7 @@ class IntegrityCheckedFile(FileLikeWrapper):
|
|||
self.file_opened = override_fd is None
|
||||
self.digests = {}
|
||||
|
||||
hash_cls = XXH64FileHashingWrapper
|
||||
hash_cls = SHA256FileHashingWrapper
|
||||
|
||||
if not write:
|
||||
algorithm_and_digests = self.load_integrity_data(path, integrity_data)
|
||||
|
|
|
|||
Loading…
Reference in a new issue