[crypto] start working on hash code
This commit is contained in:
parent
bd9e953352
commit
306e47e827
|
@ -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>
|
|
@ -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"
|
|
@ -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)
|
||||||
|
}
|
|
@ -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--";
|
|
@ -1 +1,2 @@
|
||||||
pub mod drivers; // Baremetal network drivers for various platforms
|
pub mod drivers;
|
||||||
|
pub mod crypto;
|
Loading…
Reference in New Issue