From fd0995bd1be5e4e9c98f4252a5a8914ea78fae79 Mon Sep 17 00:00:00 2001 From: Saul Beck Date: Mon, 1 Jun 2026 17:31:25 +0100 Subject: [PATCH 1/3] chore: bump Rust edition to 2024 and update dependencies + clippy refactors Upgrade workspace and crates to Rust 2024 edition and apply tool-driven fixes: - Bump Rust edition from 2021 to 2024 across workspace crates (Cargo.toml, Cargo.nix) - Update `rustls-webpki` dependency to 0.103.13 - Apply `cargo fix --edition` changes - Add `use<>` lifetime capture in `impl Trait` return types for iterators - Apply Clippy suggestions and minor refactors - Simplify iterator-returning functions with correct lifetime capture syntax - Refactor `trystream_any` to fix warning --- Cargo.lock | 4 ++-- Cargo.nix | 16 ++++++++-------- Cargo.toml | 2 +- .../src/crd/secret_class/v1alpha1_impl.rs | 4 ++-- .../src/crd/secret_class/v1alpha2_impl.rs | 4 ++-- rust/operator-binary/src/utils.rs | 13 +++++++++---- rust/p12/Cargo.toml | 4 ++-- rust/p12/src/lib.rs | 4 ++-- 8 files changed, 28 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1392b60b..bc2d2c33 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3046,9 +3046,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.103.9" +version = "0.103.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7df23109aa6c1567d1c575b9952556388da57401e4ace1d15f79eedad0d8f53" +checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e" dependencies = [ "ring", "rustls-pki-types", diff --git a/Cargo.nix b/Cargo.nix index c3518d07..5ccb72e6 100644 --- a/Cargo.nix +++ b/Cargo.nix @@ -1180,7 +1180,7 @@ rec { "cert-tools" = rec { crateName = "cert-tools"; version = "0.1.1"; - edition = "2021"; + edition = "2024"; crateBin = [ { name = "cert-tools"; @@ -8109,7 +8109,7 @@ rec { "p12" = rec { crateName = "p12"; version = "0.0.0-dev"; - edition = "2021"; + edition = "2024"; src = lib.cleanSourceWith { filter = sourceFilter; src = ./rust/p12; }; authors = [ "hjiayz " @@ -10364,9 +10364,9 @@ rec { }; "rustls-webpki" = rec { crateName = "rustls-webpki"; - version = "0.103.9"; + version = "0.103.13"; edition = "2021"; - sha256 = "0lwg1nnyv7pp2lfwwjhy81bxm233am99jnsp3iymdhd6k8827pyp"; + sha256 = "0vkm7z9pnxz5qz66p2kmyy2pwx0g4jnsbqk5xzfhs4czcjl2ki31"; libName = "webpki"; dependencies = [ { @@ -11677,7 +11677,7 @@ rec { "stackable-krb5-provision-keytab" = rec { crateName = "stackable-krb5-provision-keytab"; version = "0.0.0-dev"; - edition = "2021"; + edition = "2024"; crateBin = [ { name = "stackable-krb5-provision-keytab"; @@ -11967,7 +11967,7 @@ rec { "stackable-secret-operator" = rec { crateName = "stackable-secret-operator"; version = "0.0.0-dev"; - edition = "2021"; + edition = "2024"; crateBin = [ { name = "stackable-secret-operator"; @@ -12152,7 +12152,7 @@ rec { "stackable-secret-operator-olm-deployer" = rec { crateName = "stackable-secret-operator-olm-deployer"; version = "0.0.0-dev"; - edition = "2021"; + edition = "2024"; crateBin = [ { name = "stackable-secret-operator-olm-deployer"; @@ -12217,7 +12217,7 @@ rec { "stackable-secret-operator-utils" = rec { crateName = "stackable-secret-operator-utils"; version = "0.0.0-dev"; - edition = "2021"; + edition = "2024"; src = lib.cleanSourceWith { filter = sourceFilter; src = ./rust/utils; }; libName = "stackable_secret_operator_utils"; authors = [ diff --git a/Cargo.toml b/Cargo.toml index ebeba896..0737c162 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ resolver = "2" version = "0.0.0-dev" authors = ["Stackable GmbH "] license = "OSL-3.0" -edition = "2021" +edition = "2024" repository = "https://github.com/stackabletech/secret-operator" [workspace.dependencies] diff --git a/rust/operator-binary/src/crd/secret_class/v1alpha1_impl.rs b/rust/operator-binary/src/crd/secret_class/v1alpha1_impl.rs index 2c9b80fe..75c0dcbd 100644 --- a/rust/operator-binary/src/crd/secret_class/v1alpha1_impl.rs +++ b/rust/operator-binary/src/crd/secret_class/v1alpha1_impl.rs @@ -20,7 +20,7 @@ impl SecretClassBackend { pub fn refers_to_config_map( &self, config_map: &PartialObjectMeta, - ) -> impl Iterator { + ) -> impl Iterator + use<> { let cm_namespace = config_map.metadata.namespace.as_deref(); match self { Self::K8sSearch(backend) => { @@ -40,7 +40,7 @@ impl SecretClassBackend { pub fn refers_to_secret( &self, secret: &PartialObjectMeta, - ) -> impl Iterator { + ) -> impl Iterator + use<> { match self { Self::AutoTls(backend) => { (backend.ca.secret == *secret).then_some(SearchNamespaceMatchCondition::True) diff --git a/rust/operator-binary/src/crd/secret_class/v1alpha2_impl.rs b/rust/operator-binary/src/crd/secret_class/v1alpha2_impl.rs index dc644750..22aaedf6 100644 --- a/rust/operator-binary/src/crd/secret_class/v1alpha2_impl.rs +++ b/rust/operator-binary/src/crd/secret_class/v1alpha2_impl.rs @@ -26,7 +26,7 @@ impl SecretClassBackend { pub fn refers_to_config_map( &self, config_map: &PartialObjectMeta, - ) -> impl Iterator { + ) -> impl Iterator + use<> { let cm_namespace = config_map.metadata.namespace.as_deref(); match self { Self::K8sSearch(backend) => { @@ -46,7 +46,7 @@ impl SecretClassBackend { pub fn refers_to_secret( &self, secret: &PartialObjectMeta, - ) -> impl Iterator { + ) -> impl Iterator + use<> { match self { Self::AutoTls(backend) => { (backend.ca.secret == *secret).then_some(SearchNamespaceMatchCondition::True) diff --git a/rust/operator-binary/src/utils.rs b/rust/operator-binary/src/utils.rs index 637377be..f7cb91aa 100644 --- a/rust/operator-binary/src/utils.rs +++ b/rust/operator-binary/src/utils.rs @@ -123,14 +123,19 @@ pub fn error_full_message(err: &dyn std::error::Error) -> String { /// Propagates `Ok(true)` and `Err(_)` from `stream`, otherwise returns `Ok(false)`. pub async fn trystream_any>, E>(stream: S) -> Result { pin_mut!(stream); - while let Some(value) = stream.next().await { - if let Ok(true) | Err(_) = value { - return value; + loop { + let next_item = stream.next().await; + match next_item { + Some(value) => { + if let Ok(true) | Err(_) = value { + return value; + } + } + None => break, } } Ok(false) } - /// Concatenate chunks of bytes, short-circuiting on [`Err`]. /// /// This is a byte-oriented equivalent to [`Iterator::collect::>`](`Iterator::collect`). diff --git a/rust/p12/Cargo.toml b/rust/p12/Cargo.toml index 21706521..d4e5ac58 100644 --- a/rust/p12/Cargo.toml +++ b/rust/p12/Cargo.toml @@ -2,14 +2,14 @@ name = "p12" version.workspace = true authors = ["hjiayz ", "Marc-Antoine Perennou "] -edition = "2021" +edition.workspace = true keywords = ["pkcs12", "pkcs"] description = "pure rust pkcs12 tool (Stackable fork)" homepage = "https://github.com/hjiayz/p12" repository = "https://github.com/hjiayz/p12" readme = "README.md" license = "MIT OR Apache-2.0" -rust-version = "1.56.0" +rust-version = "1.85.0" # Dependencies are tracked inline for now, to minimize divergence from upstream diff --git a/rust/p12/src/lib.rs b/rust/p12/src/lib.rs index 30a2006b..d8869f1a 100644 --- a/rust/p12/src/lib.rs +++ b/rust/p12/src/lib.rs @@ -644,12 +644,12 @@ fn pbepkcs12sha1(pass: &[u8], salt: &[u8], iterations: u64, id: u8, size: u64) - let d = [id; V as usize]; fn get_len(s: usize) -> usize { let s = s as u64; - (V * ((s + V - 1) / V)) as usize + (V * s.div_ceil(V)) as usize } let s = salt.iter().cycle().take(get_len(salt.len())); let p = pass.iter().cycle().take(get_len(pass.len())); let mut i: Vec = s.chain(p).cloned().collect(); - let c = (size + U - 1) / U; + let c = size.div_ceil(U); let mut a: Vec = vec![]; for _ in 1..c { let ai = pbepkcs12sha1core(&d, &i, &mut a, r); From 5ce2a5796e47831306f0070888ce62b787c14a7d Mon Sep 17 00:00:00 2001 From: Saul Beck Date: Wed, 3 Jun 2026 13:42:41 +0100 Subject: [PATCH 2/3] fix(krb5-provision-keytab): disambiguate into_future in CredentialCache Explicitly selecting TryFutureExt::into_future --- rust/krb5-provision-keytab/src/credential_cache.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rust/krb5-provision-keytab/src/credential_cache.rs b/rust/krb5-provision-keytab/src/credential_cache.rs index 01f9d498..44d1a9b0 100644 --- a/rust/krb5-provision-keytab/src/credential_cache.rs +++ b/rust/krb5-provision-keytab/src/credential_cache.rs @@ -94,10 +94,9 @@ impl CredentialCache { .expect("key was just confirmed to exist in cache"))) } else { tracing::info!("credential not found in cache, generating..."); - match mk_value(Ctx { + match TryFutureExt::into_future(mk_value(Ctx { cache_ref: self.cache_ref.clone(), - }) - .into_future() + })) .await { Ok(value) => { From 7a8d9bbf9dcac647d633eab915917356044c674b Mon Sep 17 00:00:00 2001 From: Saul Beck Date: Thu, 25 Jun 2026 11:20:13 +0100 Subject: [PATCH 3/3] Refactor: Ignore clippy, reverting loop and update git2 due to advisory --- Cargo.lock | 60 ++++----------- Cargo.nix | 123 ++++++------------------------ rust/operator-binary/src/utils.rs | 12 +-- rust/p12/src/lib.rs | 6 +- 4 files changed, 43 insertions(+), 158 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bc2d2c33..7f7ad098 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "adler2" @@ -309,9 +309,9 @@ dependencies = [ [[package]] name = "built" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4ad8f11f288f48ca24471bbd51ac257aaeaaa07adae295591266b792902ae64" +checksum = "5c0e531d93d39c34eef561e929e8a7f86d77a5af08aac4f6d6e39976c51858e9" dependencies = [ "chrono", "git2", @@ -1129,15 +1129,14 @@ dependencies = [ [[package]] name = "git2" -version = "0.20.4" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b88256088d75a56f8ecfa070513a775dd9107f6530ef14919dac831af9cfe2b" +checksum = "ddddbf932745a6be37109b6112d3ee09696106f848449069d3a57bba937ab82e" dependencies = [ "bitflags", "libc", "libgit2-sys", "log", - "url", ] [[package]] @@ -1380,7 +1379,7 @@ dependencies = [ "js-sys", "log", "wasm-bindgen", - "windows-core 0.62.2", + "windows-core", ] [[package]] @@ -1893,9 +1892,9 @@ checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112" [[package]] name = "libgit2-sys" -version = "0.18.3+1.9.2" +version = "0.18.5+1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9b3acc4b91781bb0b3386669d325163746af5f6e4f73e6d2d630e09a35f3487" +checksum = "005d6ae6eac1912906073e069f7db60b1fa98e052a68227824afe3e3a1c59ca2" dependencies = [ "cc", "libc", @@ -4611,7 +4610,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893" dependencies = [ "windows-collections", - "windows-core 0.61.2", + "windows-core", "windows-future", "windows-link 0.1.3", "windows-numerics", @@ -4623,7 +4622,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8" dependencies = [ - "windows-core 0.61.2", + "windows-core", ] [[package]] @@ -4635,21 +4634,8 @@ dependencies = [ "windows-implement", "windows-interface", "windows-link 0.1.3", - "windows-result 0.3.4", - "windows-strings 0.4.2", -] - -[[package]] -name = "windows-core" -version = "0.62.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" -dependencies = [ - "windows-implement", - "windows-interface", - "windows-link 0.2.1", - "windows-result 0.4.1", - "windows-strings 0.5.1", + "windows-result", + "windows-strings", ] [[package]] @@ -4658,7 +4644,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" dependencies = [ - "windows-core 0.61.2", + "windows-core", "windows-link 0.1.3", "windows-threading", ] @@ -4703,7 +4689,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" dependencies = [ - "windows-core 0.61.2", + "windows-core", "windows-link 0.1.3", ] @@ -4716,15 +4702,6 @@ dependencies = [ "windows-link 0.1.3", ] -[[package]] -name = "windows-result" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" -dependencies = [ - "windows-link 0.2.1", -] - [[package]] name = "windows-strings" version = "0.4.2" @@ -4734,15 +4711,6 @@ dependencies = [ "windows-link 0.1.3", ] -[[package]] -name = "windows-strings" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" -dependencies = [ - "windows-link 0.2.1", -] - [[package]] name = "windows-sys" version = "0.52.0" diff --git a/Cargo.nix b/Cargo.nix index 5ccb72e6..bcc3ca06 100644 --- a/Cargo.nix +++ b/Cargo.nix @@ -1037,9 +1037,9 @@ rec { }; "built" = rec { crateName = "built"; - version = "0.8.0"; - edition = "2021"; - sha256 = "0r5f08lpjsr6j5ajkbmd0ymfmajpq8ddbfvi8ji8rx48y88qzbgl"; + version = "0.8.1"; + edition = "2024"; + sha256 = "1saq332pd6g3svvc9ah8myjpfvgqlzl2ksb1ypp3976kjcfm63jw"; authors = [ "Lukas Lueg " ]; @@ -1063,6 +1063,7 @@ rec { "chrono" = [ "dep:chrono" ]; "dependency-tree" = [ "cargo-lock/dependency-tree" ]; "git2" = [ "dep:git2" ]; + "gix" = [ "dep:gix" ]; "semver" = [ "dep:semver" ]; }; resolvedDefaultFeatures = [ "chrono" "git2" ]; @@ -3637,9 +3638,9 @@ rec { }; "git2" = rec { crateName = "git2"; - version = "0.20.4"; - edition = "2018"; - sha256 = "0azykjpk3j6s354z23jkyq3r3pbmlw9ha1zsxkw5cnnpi1h2b23v"; + version = "0.21.0"; + edition = "2021"; + sha256 = "0bmqga9vlyx5sdlr0i28z0362s89xv9i4qcv20vvx9j54y9vzpfx"; authors = [ "Josh Triplett " "Alex Crichton " @@ -3661,17 +3662,14 @@ rec { name = "log"; packageId = "log"; } - { - name = "url"; - packageId = "url"; - } ]; features = { - "default" = [ "ssh" "https" ]; - "https" = [ "libgit2-sys/https" "openssl-sys" "openssl-probe" ]; + "cred" = [ "dep:url" ]; + "https" = [ "libgit2-sys/https" "openssl-sys" "openssl-probe" "cred" ]; "openssl-probe" = [ "dep:openssl-probe" ]; "openssl-sys" = [ "dep:openssl-sys" ]; - "ssh" = [ "libgit2-sys/ssh" ]; + "ssh" = [ "libgit2-sys/ssh" "cred" ]; + "unstable-sha256" = [ "libgit2-sys/unstable-sha256" ]; "vendored-libgit2" = [ "libgit2-sys/vendored" ]; "vendored-openssl" = [ "openssl-sys/vendored" "libgit2-sys/vendored-openssl" ]; "zlib-ng-compat" = [ "libgit2-sys/zlib-ng-compat" ]; @@ -4525,7 +4523,7 @@ rec { } { name = "windows-core"; - packageId = "windows-core 0.62.2"; + packageId = "windows-core"; target = { target, features }: ("windows" == target."os" or null); } ]; @@ -6347,10 +6345,10 @@ rec { }; "libgit2-sys" = rec { crateName = "libgit2-sys"; - version = "0.18.3+1.9.2"; + version = "0.18.5+1.9.4"; edition = "2021"; links = "git2"; - sha256 = "11rlbyihj3k35mnkxxz4yvsnlx33a4r9srl66c5vp08pp72arcy9"; + sha256 = "18lwqnhy7qxg4iw24s1a0n7aj7qbnryry1iy0w32k4f1xbk6lp80"; libName = "libgit2_sys"; libPath = "lib.rs"; authors = [ @@ -16226,7 +16224,7 @@ rec { } { name = "windows-core"; - packageId = "windows-core 0.61.2"; + packageId = "windows-core"; usesDefaultFeatures = false; } { @@ -16950,7 +16948,7 @@ rec { dependencies = [ { name = "windows-core"; - packageId = "windows-core 0.61.2"; + packageId = "windows-core"; usesDefaultFeatures = false; } ]; @@ -16958,7 +16956,7 @@ rec { "default" = [ "std" ]; }; }; - "windows-core 0.61.2" = rec { + "windows-core" = rec { crateName = "windows-core"; version = "0.61.2"; edition = "2021"; @@ -16985,51 +16983,12 @@ rec { } { name = "windows-result"; - packageId = "windows-result 0.3.4"; - usesDefaultFeatures = false; - } - { - name = "windows-strings"; - packageId = "windows-strings 0.4.2"; - usesDefaultFeatures = false; - } - ]; - features = { - "default" = [ "std" ]; - "std" = [ "windows-result/std" "windows-strings/std" ]; - }; - resolvedDefaultFeatures = [ "std" ]; - }; - "windows-core 0.62.2" = rec { - crateName = "windows-core"; - version = "0.62.2"; - edition = "2021"; - sha256 = "1swxpv1a8qvn3bkxv8cn663238h2jccq35ff3nsj61jdsca3ms5q"; - libName = "windows_core"; - dependencies = [ - { - name = "windows-implement"; - packageId = "windows-implement"; - usesDefaultFeatures = false; - } - { - name = "windows-interface"; - packageId = "windows-interface"; - usesDefaultFeatures = false; - } - { - name = "windows-link"; - packageId = "windows-link 0.2.1"; - usesDefaultFeatures = false; - } - { - name = "windows-result"; - packageId = "windows-result 0.4.1"; + packageId = "windows-result"; usesDefaultFeatures = false; } { name = "windows-strings"; - packageId = "windows-strings 0.5.1"; + packageId = "windows-strings"; usesDefaultFeatures = false; } ]; @@ -17048,7 +17007,7 @@ rec { dependencies = [ { name = "windows-core"; - packageId = "windows-core 0.61.2"; + packageId = "windows-core"; usesDefaultFeatures = false; } { @@ -17148,7 +17107,7 @@ rec { dependencies = [ { name = "windows-core"; - packageId = "windows-core 0.61.2"; + packageId = "windows-core"; usesDefaultFeatures = false; } { @@ -17161,7 +17120,7 @@ rec { "default" = [ "std" ]; }; }; - "windows-result 0.3.4" = rec { + "windows-result" = rec { crateName = "windows-result"; version = "0.3.4"; edition = "2021"; @@ -17182,25 +17141,7 @@ rec { }; resolvedDefaultFeatures = [ "std" ]; }; - "windows-result 0.4.1" = rec { - crateName = "windows-result"; - version = "0.4.1"; - edition = "2021"; - sha256 = "1d9yhmrmmfqh56zlj751s5wfm9a2aa7az9rd7nn5027nxa4zm0bp"; - libName = "windows_result"; - dependencies = [ - { - name = "windows-link"; - packageId = "windows-link 0.2.1"; - usesDefaultFeatures = false; - } - ]; - features = { - "default" = [ "std" ]; - }; - resolvedDefaultFeatures = [ "std" ]; - }; - "windows-strings 0.4.2" = rec { + "windows-strings" = rec { crateName = "windows-strings"; version = "0.4.2"; edition = "2021"; @@ -17221,24 +17162,6 @@ rec { }; resolvedDefaultFeatures = [ "std" ]; }; - "windows-strings 0.5.1" = rec { - crateName = "windows-strings"; - version = "0.5.1"; - edition = "2021"; - sha256 = "14bhng9jqv4fyl7lqjz3az7vzh8pw0w4am49fsqgcz67d67x0dvq"; - libName = "windows_strings"; - dependencies = [ - { - name = "windows-link"; - packageId = "windows-link 0.2.1"; - usesDefaultFeatures = false; - } - ]; - features = { - "default" = [ "std" ]; - }; - resolvedDefaultFeatures = [ "std" ]; - }; "windows-sys 0.52.0" = rec { crateName = "windows-sys"; version = "0.52.0"; diff --git a/rust/operator-binary/src/utils.rs b/rust/operator-binary/src/utils.rs index f7cb91aa..0e661676 100644 --- a/rust/operator-binary/src/utils.rs +++ b/rust/operator-binary/src/utils.rs @@ -123,15 +123,9 @@ pub fn error_full_message(err: &dyn std::error::Error) -> String { /// Propagates `Ok(true)` and `Err(_)` from `stream`, otherwise returns `Ok(false)`. pub async fn trystream_any>, E>(stream: S) -> Result { pin_mut!(stream); - loop { - let next_item = stream.next().await; - match next_item { - Some(value) => { - if let Ok(true) | Err(_) = value { - return value; - } - } - None => break, + while let Some(value) = stream.next().await { + if let Ok(true) | Err(_) = value { + return value; } } Ok(false) diff --git a/rust/p12/src/lib.rs b/rust/p12/src/lib.rs index d8869f1a..610cbd9a 100644 --- a/rust/p12/src/lib.rs +++ b/rust/p12/src/lib.rs @@ -635,7 +635,7 @@ fn pbepkcs12sha1core(d: &[u8], i: &[u8], a: &mut Vec, iterations: u64) -> Ve a.append(&mut ai.clone()); ai } - +#[allow(clippy::manual_div_ceil)] // This is a fork, ignoring errors #[allow(clippy::many_single_char_names)] fn pbepkcs12sha1(pass: &[u8], salt: &[u8], iterations: u64, id: u8, size: u64) -> Vec { const U: u64 = 160 / 8; @@ -644,12 +644,12 @@ fn pbepkcs12sha1(pass: &[u8], salt: &[u8], iterations: u64, id: u8, size: u64) - let d = [id; V as usize]; fn get_len(s: usize) -> usize { let s = s as u64; - (V * s.div_ceil(V)) as usize + (V * ((s + V - 1) / V)) as usize } let s = salt.iter().cycle().take(get_len(salt.len())); let p = pass.iter().cycle().take(get_len(pass.len())); let mut i: Vec = s.chain(p).cloned().collect(); - let c = size.div_ceil(U); + let c = (size + U - 1) / U; let mut a: Vec = vec![]; for _ in 1..c { let ai = pbepkcs12sha1core(&d, &i, &mut a, r);