[crypto] start working on hash code

This commit is contained in:
c0repwn3r 2022-12-12 09:30:21 -05:00
parent bd9e953352
commit 306e47e827
Signed by: core
GPG Key ID: FDBF740DADDCEECF
5 changed files with 19 additions and 2 deletions

View File

@ -2,6 +2,5 @@
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" /> <mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/wginterface" vcs="Git" />
</component> </component>
</project> </project>

View File

@ -8,6 +8,7 @@ edition = "2021"
[dependencies] [dependencies]
cidr = "0.2.1" cidr = "0.2.1"
etherparse = "0.13.0" etherparse = "0.13.0"
blake2 = "0.10.5"
[target.'cfg(unix)'.dependencies] [target.'cfg(unix)'.dependencies]
tun = "0.5.4" tun = "0.5.4"

View File

@ -0,0 +1,10 @@
use std::error::Error;
use blake2::Blake2sVar;
pub fn crypto_hash(input: &[u8]) -> Result<[u8; 32], Box<dyn Error>> {
let mut hasher = Blake2sVar::new(32)?;
hasher.update(input);
let mut result_buf = [0u8; 32];
hasher.finalize_variable(&mut result_buf)?;
Ok(result_buf)
}

View File

@ -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--";

View File

@ -1 +1,2 @@
pub mod drivers; // Baremetal network drivers for various platforms pub mod drivers;
pub mod crypto;