From 684189769238ba5f49eae4d12a298ec641691d4e Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 29 May 2025 16:38:53 +0200 Subject: [PATCH] test_chunkpoints_unchanged: do not use blake2b_256 we want to get rid of legacy stuff(*) one day and sha256 is as good for this purpose (and might be even hw accelerated). (*) considered legacy due to the way it gives the key to the blake2b function (just padding and prepending it to the data, instead of using the key parameter, see #8867 ). --- src/borg/testsuite/chunker_slow_test.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/borg/testsuite/chunker_slow_test.py b/src/borg/testsuite/chunker_slow_test.py index a2cec4f61..da508f266 100644 --- a/src/borg/testsuite/chunker_slow_test.py +++ b/src/borg/testsuite/chunker_slow_test.py @@ -1,12 +1,16 @@ +from hashlib import sha256 from io import BytesIO from .chunker_test import cf from ..chunker import Chunker -from ..crypto.low_level import blake2b_256 from ..constants import * # NOQA from ..helpers import hex_to_bin +def H(data): + return sha256(data).digest() + + def test_chunkpoints_unchanged(): def twist(size): x = 1 @@ -28,10 +32,10 @@ def test_chunkpoints_unchanged(): for seed in (1849058162, 1234567653): fh = BytesIO(data) chunker = Chunker(seed, minexp, maxexp, maskbits, winsize) - chunks = [blake2b_256(b"", c) for c in cf(chunker.chunkify(fh, -1))] - runs.append(blake2b_256(b"", b"".join(chunks))) + chunks = [H(c) for c in cf(chunker.chunkify(fh, -1))] + runs.append(H(b"".join(chunks))) # The "correct" hash below matches the existing chunker behavior. # Future chunker optimisations must not change this, or existing repos will bloat. - overall_hash = blake2b_256(b"", b"".join(runs)) - assert overall_hash == hex_to_bin("b559b0ac8df8daaa221201d018815114241ea5c6609d98913cd2246a702af4e3") + overall_hash = H(b"".join(runs)) + assert overall_hash == hex_to_bin("a43d0ecb3ae24f38852fcc433a83dacd28fe0748d09cc73fc11b69cf3f1a7299")