diff options
| author | Will Dillon <william@housedillon.com> | 2025-11-08 07:13:50 +0000 |
|---|---|---|
| committer | Will Dillon <william@housedillon.com> | 2025-11-08 07:13:50 +0000 |
| commit | ed4ffa57be99980911dc52a83b106c8ea97cddfa (patch) | |
| tree | ad56fe5b9f4b5ab0d0675356952b78f23e6e07c2 /src | |
| parent | Getting pretty close to finished (diff) | |
| download | meshcore-rs-ed4ffa57be99980911dc52a83b106c8ea97cddfa.tar.gz meshcore-rs-ed4ffa57be99980911dc52a83b106c8ea97cddfa.zip | |
Got P2P decryption working
Diffstat (limited to 'src')
| -rw-r--r-- | src/identity.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/identity.rs b/src/identity.rs index 47ec956..5443b40 100644 --- a/src/identity.rs +++ b/src/identity.rs @@ -78,7 +78,16 @@ pub struct Keystore { } impl Keystore { - pub fn decrypt_and_id_p2p(&self, source: u8, dest: u8, mac: u16, data: &Bytes) -> Option<(Bytes, Identity, Contact)> { + pub fn decrypt_and_id_p2p(&self, source: u8, dest: u8, mac: u16, data: &Bytes) -> Option<(Bytes, Rc<String>, Rc<String>)> { + // Just brute-force all the secrets until one matches... + for identity in self.identities.iter() { + for secret in identity.1.secrets.iter() { + let result = secret.1.mac_then_decrypt(mac, data); + if let Some(result) = result { + return Some((result, identity.0.clone(), secret.0.clone())); + } + } + } None } |
