diff --git a/zerotier-core-crypto/src/lib.rs b/zerotier-core-crypto/src/lib.rs index 7b476dc87..b22671e9a 100644 --- a/zerotier-core-crypto/src/lib.rs +++ b/zerotier-core-crypto/src/lib.rs @@ -16,6 +16,7 @@ pub mod kbkdf; pub mod random; pub mod secret; pub mod hex; +pub mod varint; pub use aes_gmac_siv; pub use rand_core; diff --git a/zerotier-network-hypervisor/src/util/varint.rs b/zerotier-core-crypto/src/varint.rs similarity index 96% rename from zerotier-network-hypervisor/src/util/varint.rs rename to zerotier-core-crypto/src/varint.rs index 484e81595..e8500c871 100644 --- a/zerotier-network-hypervisor/src/util/varint.rs +++ b/zerotier-core-crypto/src/varint.rs @@ -7,7 +7,6 @@ */ use std::io::{Read, Write}; -use crate::vl1::buffer::Buffer; /// Write a variable length integer, which can consume up to 10 bytes. pub fn write(w: &mut W, mut v: u64) -> std::io::Result<()> { @@ -49,7 +48,7 @@ pub fn read(r: &mut R) -> std::io::Result<(u64, usize)> { #[cfg(test)] mod tests { - use crate::util::varint::*; + use crate::varint::*; #[test] fn varint() { diff --git a/zerotier-network-hypervisor/src/util/mod.rs b/zerotier-network-hypervisor/src/util/mod.rs index 6ff2cffed..4a6dd1b9f 100644 --- a/zerotier-network-hypervisor/src/util/mod.rs +++ b/zerotier-network-hypervisor/src/util/mod.rs @@ -8,9 +8,9 @@ pub mod pool; pub mod gate; -pub mod varint; pub use zerotier_core_crypto::hex; +pub use zerotier_core_crypto::varint; pub(crate) const ZEROES: [u8; 64] = [0_u8; 64]; @@ -109,6 +109,7 @@ pub(crate) fn load_u64_be(d: &[u8]) -> u64 { /// Mix bits in a 64-bit integer. /// https://nullprogram.com/blog/2018/07/31/ +#[inline(always)] pub(crate) fn hash64(mut x: u64) -> u64 { x ^= x.wrapping_shr(30); x = x.wrapping_mul(0xbf58476d1ce4e5b9);