Skip to content

Use less xxh64, add SHA256FileHashingWrapper - #9672

Merged
ThomasWaldmann merged 6 commits into
borgbackup:masterfrom
ThomasWaldmann:less-xxh64
May 28, 2026
Merged

Use less xxh64, add SHA256FileHashingWrapper#9672
ThomasWaldmann merged 6 commits into
borgbackup:masterfrom
ThomasWaldmann:less-xxh64

Conversation

@ThomasWaldmann

Copy link
Copy Markdown
Member

No description provided.

Cryptographically strong and often hw accelerated nowadays.

Also support by borgstore hash method.
Likely we will use them less or not at all in future.
@ThomasWaldmann

Copy link
Copy Markdown
Member Author

@mr-raj12 Will also remove it from cache.py if that doesn't cause conflicts for you.

@codecov

codecov Bot commented May 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.78%. Comparing base (b45f233) to head (caf4d25).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/borg/cache.py 80.00% 0 Missing and 1 partial ⚠️
src/borg/helpers/parseformat.py 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9672      +/-   ##
==========================================
- Coverage   83.78%   83.78%   -0.01%     
==========================================
  Files          93       93              
  Lines       15653    15633      -20     
  Branches     2353     2349       -4     
==========================================
- Hits        13115    13098      -17     
+ Misses       1796     1795       -1     
+ Partials      742      740       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mr-raj12

Copy link
Copy Markdown
Contributor

@mr-raj12 Will also remove it from cache.py if that doesn't cause conflicts for you.

no

@ThomasWaldmann ThomasWaldmann changed the title Use less xxh64 Use less xxh64, add SHA256FileHashingWrapper May 28, 2026
@ThomasWaldmann

Copy link
Copy Markdown
Member Author

@mr-raj12 SHA256FileHashingWrapper is something you can use for your project.

@ThomasWaldmann
ThomasWaldmann merged commit 33afaa1 into borgbackup:master May 28, 2026
20 checks passed
@ThomasWaldmann

Copy link
Copy Markdown
Member Author

@mr-raj12 always update master before you start working on something.

@ThomasWaldmann
ThomasWaldmann deleted the less-xxh64 branch May 28, 2026 18:38
@mr-raj12

Copy link
Copy Markdown
Contributor

@mr-raj12 always update master before you start working on something.

sure

ThomasWaldmann added a commit to ThomasWaldmann/borg that referenced this pull request Jul 29, 2026
XXH64 (and the XXH64FileHashingWrapper) were removed in borgbackup#9672 / borgbackup#9750,
which switched borg 2.x file integrity to SHA256. But borg 1.x wrote
XXH64 checksums into the repo index/hints integrity data, so we need
XXH64 to verify those files when reading a borg 1.x (legacy) repository
during `borg transfer`.

Rather than re-introducing the external "xxhash" PyPI package (and the
libxxhash system dependency on msys2 that borgbackup#9750 dropped), add a small,
dependency-free, streaming XXH64 implementation in cython to
crypto.low_level. It is only used on the read path; borg 2.x native
repos keep using SHA256. XXH64 is non-cryptographic and must not be used
as a security mechanism.

Tests use the official xxHash sanity-check vectors (the test buffer
generator is transcribed verbatim from xxHash tests/sanity_test.c) and
cover all code paths, streaming vs one-shot, and a legacy XXH64
integrity round-trip through IntegrityCheckedFile.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants