mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-15 00:43:45 +02:00
Move varint to crypto since a few of these utils will be useful everywhere.
This commit is contained in:
parent
6c504af012
commit
cd62b6a932
3 changed files with 4 additions and 3 deletions
|
@ -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;
|
||||
|
|
|
@ -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: Write>(w: &mut W, mut v: u64) -> std::io::Result<()> {
|
||||
|
@ -49,7 +48,7 @@ pub fn read<R: Read>(r: &mut R) -> std::io::Result<(u64, usize)> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::util::varint::*;
|
||||
use crate::varint::*;
|
||||
|
||||
#[test]
|
||||
fn varint() {
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue