From 0024a422ba6e4459d50dca87deb369cb1d2906af Mon Sep 17 00:00:00 2001 From: Will Dillon Date: Thu, 6 Nov 2025 11:29:47 -0800 Subject: Finally building again; what a nightmare --- src/crypto.rs | 28 ++++++++++++++-------------- src/packet.rs | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/crypto.rs b/src/crypto.rs index 8bad0e6..d967f50 100644 --- a/src/crypto.rs +++ b/src/crypto.rs @@ -1,18 +1,17 @@ use std::str::FromStr; +use tokio_util::bytes::{Buf, BufMut, Bytes, BytesMut}; +use hex::{decode, decode_to_slice}; use ed25519_dalek::hazmat::ExpandedSecretKey; use curve25519_dalek::{constants, edwards::CompressedEdwardsY}; -use tokio_util::bytes::{Buf, BufMut, Bytes, BytesMut}; use x25519_dalek::StaticSecret; +// use aes::{Aes256, cipher::{Block, BlockDecryptMut, KeyInit}}; + use sha2::{Sha256}; use hmac::{Hmac, Mac}; - -use aes::{Aes256, cipher::{Block, BlockDecryptMut, KeyInit}}; - type HmacSha256 = Hmac; -use hex::{decode, decode_to_slice}; #[derive(Debug)] pub enum MeshcoreCryptoError { @@ -56,7 +55,7 @@ impl SharedSecret { } pub fn get_hmac(&self, ciphertext: Bytes) -> Result { - if let Ok(mut mac) = HmacSha256::new_from_slice(&self.0) { + if let Ok(mut mac) = HmacSha256::new_from_slice(&self.0) { mac.update(&ciphertext); let result = mac.finalize(); let mut bytes = Bytes::copy_from_slice(&result.into_bytes()); @@ -68,12 +67,13 @@ impl SharedSecret { } pub fn decrypt(&self, ciphertext: Bytes) -> Bytes { - let mut aes = Aes256::new((&self.0).into()); + // let mut aes = Aes256::new((&self.0).into()); - let mut block = Block::clone_from_slice(&ciphertext); - aes.decrypt_block_mut(&mut block); + // let mut block = Block::clone_from_slice(&ciphertext); + // aes.decrypt_block_mut(&mut block); - Bytes::copy_from_slice(&block) + // Bytes::copy_from_slice(&block) + ciphertext } } @@ -98,7 +98,7 @@ impl TryFrom for PublicKey { return Err(MeshcoreCryptoError::TryFromSliceError) } - Ok(PublicKey(CompressedEdwardsY(slice))) + Ok(PublicKey(curve25519_dalek::edwards::CompressedEdwardsY(slice))) } } @@ -157,15 +157,15 @@ impl SharedSecret { } pub struct Keychain { - pub private_keys: Vec, - pub public_keys: Vec, + // pub private_keys: Vec, + // pub public_keys: Vec, // secrets: HashMap } #[cfg(test)] mod tests { - use curve25519_dalek::Scalar; + // use curve25519_dalek::Scalar; use hex::{decode_to_slice, encode}; use super::*; diff --git a/src/packet.rs b/src/packet.rs index 1c37513..5788100 100644 --- a/src/packet.rs +++ b/src/packet.rs @@ -4,7 +4,7 @@ use chrono::{DateTime, Local, Utc}; use hex::decode; use tokio_util::bytes::{Buf, Bytes}; use structdiff::{Difference, StructDiff}; -use crate::crypto::{PrivateKey, PublicKey, SharedSecret}; +use crate::crypto::{PublicKey, SharedSecret}; #[derive(PartialEq, Debug, Clone, Difference)] #[difference(expose)] -- cgit v1.2.3