Skip to content

chore(deps): upgrade zstd to 0.14 - #174

Merged
WingZer0o merged 2 commits into
deps/rustcrypto-upgradesfrom
deps/170-zstd-0.14
Nov 27, 2026
Merged

WingZer0o merged 2 commits into
deps/rustcrypto-upgradesfrom
deps/170-zstd-0.14

Conversation

@WingZer0o

Copy link
Copy Markdown
Member

Summary

Upgrades zstd 0.13.6 → 0.14.5 (zstd-safe 7.4.2 → 8.4.0; zstd-sys stays 2.2.0+zstd.1.6.0). Cargo.lock was updated with cargo update -p zstd only, so no other crate moved.

  • Cargo.toml: floor raised to 0.14.5. The comment now describes that floor: it requires zstd-safe 8.4.0 / zstd-sys 2.2.0, which are above the patched versions for RUSTSEC-2026-0391 (zstd >=0.14.3), 0398/0403 (zstd-safe >=8.2.0) and 0410 (zstd-sys >=2.1.2).
  • default-features = false is unchanged.
  • src/compression/zstd.rs and src/error.rs are unchanged. No public API changes, so docs/EXAMPLES.md is unchanged too.
  • New test: a frame that cas-lib 0.7.1 (zstd 0.13.6) compressed before the upgrade is committed as a hex literal. The test checks that it still decompresses to the original 4352-byte payload, and that decompress_with_limit still rejects it with a limit one byte too small.

What I checked in the zstd 0.14.5 / zstd-safe 8.4.0 source

The crates ship no changelog, so I diffed them against 0.13.6 / 7.4.2 in ~/.cargo/registry.

  • Features: the defaults are still legacy, arrays and zdict_builder, so none of them were renamed, moved, or newly turned on. The new features (vendored, cmake, rust-backend, with-rust-allocator) are all opt-in. cargo tree -e features -i zstd-sys shows only std, which zstd always enables on zstd-safe. No legacy.
  • Decoder: Decoder::with_buffer now goes through a new try_with_buffer, but its behavior is the same. window_log_max is still the decoder_parameters! macro that sets DParameter::WindowLogMax, so the 2^27 cap is enforced as before. The test that a 2^28 window is rejected still passes.
  • Output limit: the zstd Decoder now overrides read_to_end, but our path calls Take::read_to_end, which reads through Take::read. The take(max + 1) cap still bounds the output, and nothing reserves memory based on the size a frame claims. (Only decode_all reserves from the declared size, capped at 32 MiB, and we don't use it.)
  • Encoder: copy_encode now reads up to 128 KiB first. When the whole input fits in that, it pledges the source size, so frames for small inputs record their decompressed size in the header. The compressed bytes for small inputs are therefore different from 0.13, but they are standard frames that every decoder accepts. The 128 KiB buffer is grown with try_reserve_exact, so failing to get that memory is an error instead of an abort.
  • Robustness gains: contexts are now created with CCtx::try_create / DCtx::try_create, so running out of memory returns an io::Error instead of panicking. zstd allocation errors are mapped to io::ErrorKind::OutOfMemory. We already turn every io::Error into CasError::CompressionFailed, so the FFI boundary is no more exposed than before.

Test results

  • cargo build --release --locked: OK
  • cargo test --release --locked (with network for Wycheproof): 229 passed, 0 failed. That includes 13 in compression.rs (the bomb, the exact 64 MiB boundary, one byte over, the window cap, concatenated frames, and the new 0.13 frame fixture) and the NIST KAT and Wycheproof suites.
  • cargo audit --deny unsound --deny yanked: no vulnerabilities and no warnings (1571 advisories, 144 crates).

Only tested locally on Windows. CI covers Linux and macOS.

Stacking

This is stacked on #173 (deps/167-digest-0.11) and targets deps/rustcrypto-upgrades. Until #173 merges, the diff also shows #173's commit.

Part of #170

🤖 Generated with Claude Code

WingZer0o and others added 2 commits November 27, 2026 10:55
Move the hash, HMAC and PBKDF2 crates onto the digest 0.11 stack:
sha2 0.10 -> 0.11.2, sha3 0.10 -> 0.12.0, blake2 0.10 -> 0.11.0,
hmac 0.12 -> 0.13.0, pbkdf2 0.12 -> 0.13.0.

- Drop the `sha2-hkdf` alias now that `sha2` itself is 0.11, and switch
  the `sha2_hkdf::` imports in src/kdf/hkdf.rs, src/key_exchange/x25519.rs
  and the key_exchange/symmetric tests back to `sha2::`.
- hmac 0.13 moved `new_from_slice` to the `KeyInit` trait; import it.
- sha3 0.12 no longer exposes a block-level core, so `Sha3_256` does not
  satisfy `EagerHash` and can't be used with `Hmac` / `pbkdf2_hmac_array`.
  PBKDF2-HMAC-SHA3-256 now uses `pbkdf2::<SimpleHmac<Sha3_256>>`, which
  computes the same HMAC and writes straight into the returned Vec. The
  PBKDF2 known-answer vectors pass unchanged.
- Targeted lockfile refreshes: hpke 0.15.2, uuid 1.29.3, zeroize 1.9.2
  (zeroize_derive 1.5.0).

No public API changes.

Part of #167

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move zstd 0.13.6 -> 0.14.5 (zstd-safe 7.4.2 -> 8.4.0; zstd-sys stays
2.2.0+zstd.1.6.0) with a targeted `cargo update -p zstd`.

- Keep `default-features = false`: 0.14 has the same default set
  (`legacy`, `arrays`, `zdict_builder`) and only adds opt-in features
  (`vendored`, `cmake`, `rust-backend`, `with-rust-allocator`), so the
  pre-v0.8 legacy decoders stay out (#107).
- Raise the floor to 0.14.5 and rewrite the Cargo.toml comment for it.
- The decompression path is unchanged: `read::Decoder::with_buffer`,
  `window_log_max` (still sets ZSTD_d_windowLogMax) and the `take(limit + 1)`
  output cap behave as before.
- Add a fixture frame compressed by cas-lib 0.7.1 (zstd 0.13.6) and check it
  still decompresses, and that the output limit still applies to it.

Part of #170.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@WingZer0o
WingZer0o merged commit 0335d0c into deps/rustcrypto-upgrades Nov 27, 2026
5 checks passed
This was referenced Nov 27, 2026
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.

1 participant