Skip to main content

max / synckit

Pin the Argon2 serde defaults and the parallelism ceiling The default_argon_* functions are the costs a v1 envelope re-derives under, so assert them against literals rather than against the constants they return. Extend the range test past zero parallelism to 17.
Co-Authored-By
Claude Opus 5 (1M context) <noreply@anthropic.com>
Author: Max Johnson <me@maxj.phd> · 2026-08-23 21:58 UTC
Signed with PGP, not checked
Commit: a4146a45628f1ddf00bbaca1361a4090aa418333
Parent: 1e82680
1 file changed, +13 insertions, -0 deletions
@@ -1857,6 +1857,8 @@
1857 1857 // Zero time / parallelism rejected.
1858 1858 assert!(derive_wrapping_key_with_params("pw", &salt, 65_536, 0, 1).is_err());
1859 1859 assert!(derive_wrapping_key_with_params("pw", &salt, 65_536, 3, 0).is_err());
1860 + // Inflated parallelism rejected at the ceiling (16), not only at zero.
1861 + assert!(derive_wrapping_key_with_params("pw", &salt, 65_536, 3, 17).is_err());
1860 1862 // The pinned production parameters are inside the accepted range.
1861 1863 assert!(
1862 1864 derive_wrapping_key_with_params(
@@ -1870,6 +1872,17 @@
1870 1872 );
1871 1873 }
1872 1874
1875 + /// The serde defaults are what a v1 envelope predating the cost fields
1876 + /// re-derives under, so they are wire format. Pinned against literals: an
1877 + /// assertion against the constants the functions return would hold however
1878 + /// the constants moved.
1879 + #[test]
1880 + fn argon2_serde_defaults_are_the_pinned_costs() {
1881 + assert_eq!(default_argon_mem(), 65_536);
1882 + assert_eq!(default_argon_time(), 3);
1883 + assert_eq!(default_argon_par(), 1);
1884 + }
1885 +
1873 1886 #[test]
1874 1887 fn blob_total_len_exceeding_input_is_rejected_not_allocated() {
1875 1888 let key = generate_master_key();