diff options
author | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2019-07-30 15:28:11 +0200 |
---|---|---|
committer | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2019-07-30 15:28:11 +0200 |
commit | 1cfd5aea1aba4b01905414351df13e8f5d4dfb1c (patch) | |
tree | 1ddc2d7a08a486676e9cf045f31a1fe0d5714bc5 /src/handshake/macs.rs | |
parent | Begin work on MAC field processing (diff) | |
download | wireguard-rs-1cfd5aea1aba4b01905414351df13e8f5d4dfb1c.tar.xz wireguard-rs-1cfd5aea1aba4b01905414351df13e8f5d4dfb1c.zip |
Move to nested handshake message structure
Having the nested structure:
Handshake Message:
Noise part (zerocopy message)
MAC footer part (zerocopy message)
Greatly simplifies processing the MAC fields,
since the MAC footer covers the noise part, which can
be accessed as bytes using AsBytes.
Diffstat (limited to '')
-rw-r--r-- | src/handshake/macs.rs | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/src/handshake/macs.rs b/src/handshake/macs.rs index c8b97e3..05546a7 100644 --- a/src/handshake/macs.rs +++ b/src/handshake/macs.rs @@ -4,7 +4,7 @@ use blake2::Blake2s; use subtle::ConstantTimeEq; use x25519_dalek::PublicKey; -use zerocopy::{AsBytes, ByteSlice, FromBytes, LayoutVerified}; +use super::messages::{CookieReply, MacsFooter}; const LABEL_MAC1: &[u8] = b"mac1----"; const LABEL_COOKIE: &[u8] = b"cookie--"; @@ -38,22 +38,6 @@ macro_rules! MAC { }}; } -#[repr(C)] -#[derive(Copy, Clone, FromBytes, AsBytes)] -pub struct MacsFooter { - pub f_mac1: [u8; SIZE_MAC], - pub f_mac2: [u8; SIZE_MAC], -} - -impl Default for MacsFooter { - fn default() -> Self { - Self { - f_mac1: [0u8; SIZE_MAC], - f_mac2: [0u8; SIZE_MAC], - } - } -} - struct Generator { mac1_key: [u8; 32], cookie_value: [u8; 16], |