garage44.eu/jeroen/pinnacle

logclone: git clone https://garage44.eu/jeroen/pinnacle.git

cartopolis-agent · 2026-11-30T14:11:37Z

style(crypto,wifi): is_multiple_of, as clippy asks
crypto/src/aes.rs | 4 ++--
 wifi/src/wpa.rs   | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/crypto/src/aes.rs b/crypto/src/aes.rs
index 83eb986..b089d78 100644
--- a/crypto/src/aes.rs
+++ b/crypto/src/aes.rs
@@ -233,7 +233,7 @@ const WRAP_IV: [u8; 8] = [0xa6; 8];
 /// 3394) into `out`, which is 8 bytes longer. False for wrong lengths.
 pub fn wrap(kek: &[u8], key: &[u8], out: &mut [u8]) -> bool {
     let Some(aes) = Aes::new(kek) else { return false };
-    if key.len() % 8 != 0 || key.len() < 16 || out.len() != key.len() + 8 {
+    if !key.len().is_multiple_of(8) || key.len() < 16 || out.len() != key.len() + 8 {
         return false;
     }
     let n = key.len() / 8;
@@ -261,7 +261,7 @@ pub fn wrap(kek: &[u8], key: &[u8], out: &mut [u8]) -> bool {
 /// changed), `out` then zeroed.
 pub fn unwrap(kek: &[u8], wrapped: &[u8], out: &mut [u8]) -> bool {
     let Some(aes) = Aes::new(kek) else { return false };
-    if wrapped.len() % 8 != 0 || wrapped.len() < 24 || out.len() + 8 != wrapped.len() {
+    if !wrapped.len().is_multiple_of(8) || wrapped.len() < 24 || out.len() + 8 != wrapped.len() {
         return false;
     }
     let n = out.len() / 8;
diff --git a/wifi/src/wpa.rs b/wifi/src/wpa.rs
index 4d00d3a..2c105f4 100644
--- a/wifi/src/wpa.rs
+++ b/wifi/src/wpa.rs
@@ -341,7 +341,7 @@ impl Supplicant {
         if info & ENCRYPTED == 0 {
             return Ok(data.to_vec());
         }
-        if data.len() < 24 || data.len() % 8 != 0 {
+        if data.len() < 24 || !data.len().is_multiple_of(8) {
             return Err(Refused::KeyData);
         }
         let mut out = vec![0u8; data.len() - 8];
@@ -457,10 +457,10 @@ mod tests {
         fn frame(&self, info: u16, replay: u64, nonce: &[u8; 32], plain: &[u8]) -> Vec<u8> {
             let data = if info & ENCRYPTED != 0 {
                 let mut padded = plain.to_vec();
-                if padded.len() % 8 != 0 || padded.len() < 16 {
+                if !padded.len().is_multiple_of(8) || padded.len() < 16 {
                     padded.push(0xdd);
                 }
-                while padded.len() % 8 != 0 || padded.len() < 16 {
+                while !padded.len().is_multiple_of(8) || padded.len() < 16 {
                     padded.push(0);
                 }
                 let mut out = vec![0u8; padded.len() + 8];