initial import of main veilid core

This commit is contained in:
John Smith
2021-11-22 11:28:30 -05:00
parent c4cd54e020
commit 9e94a6a96f
218 changed files with 34880 additions and 1 deletions
+28
View File
@@ -0,0 +1,28 @@
use crate::*;
use rand::{CryptoRng, Error, RngCore};
#[derive(Clone, Copy, Debug, Default)]
pub struct VeilidRng;
impl CryptoRng for VeilidRng {}
impl RngCore for VeilidRng {
fn next_u32(&mut self) -> u32 {
intf::get_random_u32()
}
fn next_u64(&mut self) -> u64 {
intf::get_random_u64()
}
fn fill_bytes(&mut self, dest: &mut [u8]) {
if let Err(e) = self.try_fill_bytes(dest) {
panic!("Error: {}", e);
}
}
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
intf::random_bytes(dest).map_err(|err| Error::new(err))
}
}