Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
Default negotiation is unchanged. Select SHA-3 with
`--checksum-choice` or include it in both peers' `RSYNC_CHECKSUM_LIST`.

- Added the opt-in SHA-256 transfer checksum `sha256` for builds with OpenSSL
SHA-256 support. Default negotiation is unchanged.

## Bug fixes

- Fixed `-X` transfers of user xattrs on NetBSD by using the native BSD
Expand Down
3 changes: 3 additions & 0 deletions checksum.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ struct name_num_item valid_checksums_items[] = {
{ CSUM_SHA3_512, NNI_EVP|NNI_EXPLICIT_ONLY, "sha3-512", NULL },
{ CSUM_SHA3_384, NNI_EVP|NNI_EXPLICIT_ONLY, "sha3-384", NULL },
{ CSUM_SHA3_256, NNI_EVP|NNI_EXPLICIT_ONLY, "sha3-256", NULL },
#endif
#ifdef SHA256_DIGEST_LENGTH
{ CSUM_SHA256, NNI_EVP|NNI_EXPLICIT_ONLY, "sha256", NULL },
#endif
{ CSUM_MD5, NNI_BUILTIN|NNI_EVP, "md5", NULL },
{ CSUM_MD4, NNI_BUILTIN|NNI_EVP, "md4", NULL },
Expand Down
9 changes: 5 additions & 4 deletions rsync.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -2040,15 +2040,16 @@ sign) if you want the local shell to expand it.
- `sha3-512`
- `sha3-384`
- `sha3-256`
- `sha256`
- `md5`
- `md4`
- `sha1`
- `none`

The `sha3-*` choices require an rsync built with OpenSSL support and
a libcrypto that provides SHA-3. They are not offered during default
negotiation. Use `--checksum-choice` or include them in both peers'
[`RSYNC_CHECKSUM_LIST`](#).
The `sha3-*` and `sha256` choices require an rsync built with OpenSSL
support and a libcrypto that provides the chosen digest. They are not
offered during default negotiation. Use `--checksum-choice` or include the
chosen digest in both peers' [`RSYNC_CHECKSUM_LIST`](#).

Run `rsync --version` to see the checksum choices available in your build.

Expand Down
17 changes: 9 additions & 8 deletions testsuite/tests/transfer/checksum-sha3.py → ...e/tests/transfer/checksum-explicit-evp.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python3
# SHA-3 checksum support (sha3-256, sha3-384, sha3-512).
#
# Transfer checksums that require an explicit choice.
import json
import os
from random import Random
Expand All @@ -15,10 +14,13 @@

metadata(transports={'pipe'}, mutates={'environment', 'filesystem'}, tags={'transfer', 'regression'})

ALGOS = ('sha3-256', 'sha3-384', 'sha3-512')
ALGOS = ('sha3-256', 'sha3-384', 'sha3-512', 'sha256')

choices = json.loads(run_rsync('-VV', capture_output=True).stdout)['checksum_list']
version = json.loads(run_rsync('-VV', capture_output=True).stdout)
choices = version['checksum_list']
available = [algo for algo in ALGOS if algo in choices]
if ('sha256' in choices) != ('sha256' in version['daemon_auth_list']):
test_fail('SHA-256 transfer availability does not match the linked EVP digest')
os.environ.pop('RSYNC_CHECKSUM_LIST', None)
protocol = forced_protocol()
legacy_checksum = protocol is not None and protocol < 30
Expand All @@ -27,7 +29,7 @@
makepath(FROMDIR / 'sub')
# Empty, small and chunk-spanning sizes (CHUNK_SIZE is 32k internally).
(FROMDIR / 'empty').write_bytes(b'')
(FROMDIR / 'small').write_text('hello sha-3\n')
(FROMDIR / 'small').write_text('hello checksum\n')
size = 70 * 1024
(FROMDIR / 'sub' / 'big').write_bytes(Random(0).getrandbits(size * 8).to_bytes(size, 'big'))

Expand Down Expand Up @@ -73,7 +75,7 @@ def check_checksum_list(algo):
if legacy_checksum:
# Without negotiation the list may allow MD4 or refuse it, not replace it.
if result.returncode != 4 or 'Failed to negotiate a checksum choice.' not in result.stderr:
test_fail(f'protocol {protocol}: expected a SHA-3-only list to be refused: {result}')
test_fail(f'protocol {protocol}: expected a {algo}-only list to be refused: {result}')
rmtree(TODIR)
result = transfer_with_checksum_list(f'{algo} md4')
expected = 'Client checksum: md4'
Expand Down Expand Up @@ -108,8 +110,7 @@ def check_checksum_list(algo):
run_rsync('-ac', f'--checksum-choice={algo},{algo}', src, dst)
check_tree(f'{algo},{algo} -c')

if available:
algo = available[0]
for algo in available:
check_checksum_list(algo)
with (TODIR / 'sub' / 'big').open('r+b') as stream:
stream.seek(32 * 1024)
Expand Down
Loading