diff --git a/.idea/vcs.xml b/.idea/vcs.xml index f379199..94a25f7 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -2,6 +2,5 @@ - \ No newline at end of file diff --git a/quicktap/Cargo.toml b/quicktap/Cargo.toml index ac0480d..f57e36a 100644 --- a/quicktap/Cargo.toml +++ b/quicktap/Cargo.toml @@ -8,6 +8,7 @@ edition = "2021" [dependencies] cidr = "0.2.1" etherparse = "0.13.0" +blake2 = "0.10.5" [target.'cfg(unix)'.dependencies] tun = "0.5.4" \ No newline at end of file diff --git a/quicktap/src/crypto/hashes.rs b/quicktap/src/crypto/hashes.rs new file mode 100644 index 0000000..0a77555 --- /dev/null +++ b/quicktap/src/crypto/hashes.rs @@ -0,0 +1,10 @@ +use std::error::Error; +use blake2::Blake2sVar; + +pub fn crypto_hash(input: &[u8]) -> Result<[u8; 32], Box> { + let mut hasher = Blake2sVar::new(32)?; + hasher.update(input); + let mut result_buf = [0u8; 32]; + hasher.finalize_variable(&mut result_buf)?; + Ok(result_buf) +} \ No newline at end of file diff --git a/quicktap/src/crypto/mod.rs b/quicktap/src/crypto/mod.rs new file mode 100644 index 0000000..d28851c --- /dev/null +++ b/quicktap/src/crypto/mod.rs @@ -0,0 +1,6 @@ +pub mod hashes; + +pub const CONSTURCTION: &str = "Noise_IKpsk2_25519_ChaChaPoly_BLAKE2s"; +pub const IDENTIFIER: &str = "WireGuard v1 zx2c4 Jason@zx2c4.com"; +pub const LABEL_MAC1: &str = "mac1----"; +pub const LABEL_COOKIE: &str = "cookie--"; \ No newline at end of file diff --git a/quicktap/src/lib.rs b/quicktap/src/lib.rs index a44f2df..a41b036 100644 --- a/quicktap/src/lib.rs +++ b/quicktap/src/lib.rs @@ -1 +1,2 @@ -pub mod drivers; // Baremetal network drivers for various platforms \ No newline at end of file +pub mod drivers; +pub mod crypto; \ No newline at end of file