mirror of https://github.com/vinc/moros.git
Compare commits
7 Commits
4837929cfe
...
2e4395dad5
Author | SHA1 | Date |
---|---|---|
dependabot[bot] | 2e4395dad5 | |
Vincent Ollivier | 348b2b6d63 | |
Vincent Ollivier | d04d1a0539 | |
Vincent Ollivier | 6ab9ad713b | |
Vincent Ollivier | 3862a01513 | |
Vincent Ollivier | 1ff8d5d39c | |
dependabot[bot] | 2d85f60aac |
|
@ -1,6 +1,10 @@
|
|||
# Changelog
|
||||
|
||||
## Unreleased
|
||||
- Improve RNG (#602)
|
||||
- Fix invalid VGA palette reset (#605)
|
||||
- Improve VGA palette parser (#604)
|
||||
- Fix underflow errors in VGA driver (#603)
|
||||
|
||||
## 0.10.3 (2024-03-20)
|
||||
- Add ANSI OSC color palette support ([#566](https://github.com/vinc/moros/pull/566))
|
||||
|
|
|
@ -39,9 +39,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
|||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.13.1"
|
||||
version = "0.22.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
|
||||
checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51"
|
||||
|
||||
[[package]]
|
||||
name = "bit_field"
|
||||
|
|
|
@ -18,7 +18,7 @@ userspace = []
|
|||
[dependencies]
|
||||
acpi = "5.0.0"
|
||||
aml = "0.16.4"
|
||||
base64 = { version = "0.13.1", default-features = false }
|
||||
base64 = { version = "0.22.0", default-features = false }
|
||||
bit_field = "0.10.2"
|
||||
bootloader = { version = "0.9.28", features = ["map_physical_memory"] }
|
||||
lazy_static = { version = "1.4.0", features = ["spin_no_std"] }
|
||||
|
|
|
@ -224,7 +224,14 @@ pub fn read_dir(path: &str) -> Result<Vec<FileInfo>, ()> {
|
|||
}
|
||||
|
||||
#[test_case]
|
||||
fn test_file() {
|
||||
fn test_filename() {
|
||||
assert_eq!(filename("/path/to/file.txt"), "file.txt");
|
||||
assert_eq!(filename("/file.txt"), "file.txt");
|
||||
assert_eq!(filename("file.txt"), "file.txt");
|
||||
}
|
||||
|
||||
#[test_case]
|
||||
fn test_fs() {
|
||||
use crate::sys::fs::{dismount, format_mem, mount_mem};
|
||||
mount_mem();
|
||||
format_mem();
|
||||
|
|
|
@ -89,7 +89,7 @@ pub mod fs;
|
|||
pub mod io;
|
||||
pub mod process;
|
||||
pub mod prompt;
|
||||
pub mod random;
|
||||
pub mod rng;
|
||||
pub mod regex;
|
||||
pub mod syscall;
|
||||
pub mod time;
|
||||
|
|
|
@ -36,6 +36,7 @@ pub fn init(boot_info: &'static BootInfo) {
|
|||
sys::mem::init(boot_info);
|
||||
sys::acpi::init(); // Require MEM
|
||||
sys::cpu::init();
|
||||
sys::rng::init();
|
||||
sys::pci::init(); // Require MEM
|
||||
sys::net::init(); // Require PCI
|
||||
sys::ata::init();
|
||||
|
|
|
@ -9,7 +9,7 @@ use crate::sys::cmos::RTC;
|
|||
use crate::sys::console::Console;
|
||||
use crate::sys::net::socket::tcp::TcpSocket;
|
||||
use crate::sys::net::socket::udp::UdpSocket;
|
||||
use crate::sys::random::Random;
|
||||
use crate::sys::rng::Random;
|
||||
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
|
|
|
@ -54,7 +54,7 @@ pub mod net;
|
|||
pub mod pci;
|
||||
pub mod pic;
|
||||
pub mod process;
|
||||
pub mod random;
|
||||
pub mod rng;
|
||||
pub mod serial;
|
||||
pub mod syscall;
|
||||
pub mod time;
|
||||
|
|
|
@ -16,7 +16,7 @@ lazy_static! {
|
|||
}
|
||||
|
||||
fn random_port() -> u16 {
|
||||
49152 + sys::random::get_u16() % 16384
|
||||
49152 + sys::rng::get_u16() % 16384
|
||||
}
|
||||
|
||||
fn wait(duration: Duration) {
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
use crate::api::fs::{FileIO, IO};
|
||||
use crate::sys;
|
||||
|
||||
use rand::{RngCore, SeedableRng};
|
||||
use rand_hc::Hc128Rng;
|
||||
use x86_64::instructions::random::RdRand;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Random;
|
||||
|
||||
impl Random {
|
||||
pub fn new() -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
impl FileIO for Random {
|
||||
fn read(&mut self, buf: &mut [u8]) -> Result<usize, ()> {
|
||||
let n = buf.len();
|
||||
for i in 0..n {
|
||||
buf[i] = get_u64() as u8;
|
||||
}
|
||||
Ok(n)
|
||||
}
|
||||
|
||||
fn write(&mut self, _buf: &[u8]) -> Result<usize, ()> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn close(&mut self) {}
|
||||
|
||||
fn poll(&mut self, event: IO) -> bool {
|
||||
match event {
|
||||
IO::Read => true,
|
||||
IO::Write => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_u64() -> u64 {
|
||||
let mut seed = [0u8; 32];
|
||||
if let Some(rdrand) = RdRand::new() {
|
||||
for i in 0..4 {
|
||||
if let Some(rand) = rdrand.get_u64() {
|
||||
let bytes = rand.to_be_bytes();
|
||||
for j in 0..8 {
|
||||
seed[8 * i + j] = bytes[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// FIXME: RDRAND instruction is not available on old CPUs
|
||||
seed[0..8].clone_from_slice(&sys::time::ticks().to_be_bytes());
|
||||
seed[8..16].clone_from_slice(&sys::clock::realtime().to_be_bytes());
|
||||
seed[16..24].clone_from_slice(&sys::clock::uptime().to_be_bytes());
|
||||
seed[24..32].clone_from_slice(&sys::time::ticks().to_be_bytes());
|
||||
}
|
||||
let mut rng = Hc128Rng::from_seed(seed);
|
||||
rng.next_u64()
|
||||
}
|
||||
|
||||
pub fn get_u32() -> u32 {
|
||||
get_u64() as u32
|
||||
}
|
||||
|
||||
pub fn get_u16() -> u16 {
|
||||
get_u64() as u16
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
use crate::api::fs::{FileIO, IO};
|
||||
use crate::sys;
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
use rand::{RngCore, SeedableRng};
|
||||
use rand_hc::Hc128Rng;
|
||||
use sha2::{Digest, Sha256};
|
||||
use spin::Mutex;
|
||||
use x86_64::instructions::random::RdRand;
|
||||
|
||||
lazy_static! {
|
||||
static ref RNG: Mutex<Hc128Rng> = Mutex::new(Hc128Rng::from_seed([0; 32]));
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Random;
|
||||
|
||||
impl Random {
|
||||
pub fn new() -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
impl FileIO for Random {
|
||||
fn read(&mut self, buf: &mut [u8]) -> Result<usize, ()> {
|
||||
let n = buf.len();
|
||||
for chunk in buf.chunks_mut(8) {
|
||||
let bytes = get_u64().to_le_bytes();
|
||||
let count = chunk.len();
|
||||
chunk.clone_from_slice(&bytes[..count]);
|
||||
}
|
||||
Ok(n)
|
||||
}
|
||||
|
||||
fn write(&mut self, _buf: &[u8]) -> Result<usize, ()> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn close(&mut self) {}
|
||||
|
||||
fn poll(&mut self, event: IO) -> bool {
|
||||
match event {
|
||||
IO::Read => true,
|
||||
IO::Write => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_u64() -> u64 {
|
||||
RNG.lock().next_u64()
|
||||
}
|
||||
|
||||
pub fn get_u32() -> u32 {
|
||||
get_u64() as u32
|
||||
}
|
||||
|
||||
pub fn get_u16() -> u16 {
|
||||
get_u64() as u16
|
||||
}
|
||||
|
||||
pub fn init() {
|
||||
let mut seed = [0; 32];
|
||||
if let Some(rng) = RdRand::new() {
|
||||
log!("RNG RDRAND available");
|
||||
for chunk in seed.chunks_mut(8) {
|
||||
// NOTE: Intel's Software Developer's Manual, Volume 1, 7.3.17.1
|
||||
let mut retry = true;
|
||||
for _ in 0..10 { // Retry up to 10 times
|
||||
if let Some(num) = rng.get_u64() {
|
||||
chunk.clone_from_slice(&num.to_be_bytes());
|
||||
retry = false;
|
||||
break;
|
||||
} else {
|
||||
//debug!("RDRAND: read failed");
|
||||
}
|
||||
}
|
||||
if retry {
|
||||
//debug!("RDRAND: retry failed");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log!("RNG RDRAND unavailable");
|
||||
let mut hasher = Sha256::new();
|
||||
hasher.update(&sys::time::ticks().to_be_bytes());
|
||||
hasher.update(&sys::clock::realtime().to_be_bytes());
|
||||
hasher.update(&sys::clock::uptime().to_be_bytes());
|
||||
seed = hasher.finalize().into();
|
||||
}
|
||||
|
||||
*RNG.lock() = Hc128Rng::from_seed(seed);
|
||||
}
|
|
@ -2,12 +2,11 @@ use crate::api::console::Style;
|
|||
use crate::api::fs;
|
||||
use crate::api::process::ExitCode;
|
||||
|
||||
use alloc::format;
|
||||
use alloc::string::{String, ToString};
|
||||
|
||||
pub fn main(args: &[&str]) -> Result<(), ExitCode> {
|
||||
let n = args.len();
|
||||
if n != 3 {
|
||||
help();
|
||||
return Err(ExitCode::UsageError);
|
||||
}
|
||||
for i in 1..n {
|
||||
match args[i] {
|
||||
"-h" | "--help" => {
|
||||
|
@ -17,12 +16,26 @@ pub fn main(args: &[&str]) -> Result<(), ExitCode> {
|
|||
_ => continue,
|
||||
}
|
||||
}
|
||||
if n != 3 {
|
||||
help();
|
||||
return Err(ExitCode::UsageError);
|
||||
}
|
||||
|
||||
if args[2].is_empty() {
|
||||
error!("Could not write to ''");
|
||||
return Err(ExitCode::Failure);
|
||||
}
|
||||
|
||||
let source = args[1];
|
||||
let dest = args[2];
|
||||
let dest = destination(args[1], args[2]);
|
||||
|
||||
if fs::is_dir(source) {
|
||||
error!("Could not copy directory '{}'", source);
|
||||
return Err(ExitCode::Failure);
|
||||
}
|
||||
|
||||
if let Ok(contents) = fs::read_to_bytes(source) {
|
||||
if fs::write(dest, &contents).is_ok() {
|
||||
if fs::write(&dest, &contents).is_ok() {
|
||||
Ok(())
|
||||
} else {
|
||||
error!("Could not write to '{}'", dest);
|
||||
|
@ -34,6 +47,16 @@ pub fn main(args: &[&str]) -> Result<(), ExitCode> {
|
|||
}
|
||||
}
|
||||
|
||||
fn destination(source: &str, dest: &str) -> String {
|
||||
debug_assert!(!dest.is_empty());
|
||||
let mut dest = dest.trim_end_matches('/').to_string();
|
||||
if dest.is_empty() || fs::is_dir(&dest) {
|
||||
let file = fs::filename(source);
|
||||
dest = format!("{}/{}", dest, file);
|
||||
}
|
||||
dest
|
||||
}
|
||||
|
||||
fn help() {
|
||||
let csi_option = Style::color("LightCyan");
|
||||
let csi_title = Style::color("Yellow");
|
||||
|
@ -43,3 +66,24 @@ fn help() {
|
|||
csi_title, csi_reset, csi_option, csi_reset
|
||||
);
|
||||
}
|
||||
|
||||
#[test_case]
|
||||
fn test_destination() {
|
||||
use crate::{usr, sys};
|
||||
|
||||
sys::fs::mount_mem();
|
||||
sys::fs::format_mem();
|
||||
usr::install::copy_files(false);
|
||||
|
||||
assert_eq!(destination("foo.txt", "bar.txt"), "bar.txt");
|
||||
|
||||
assert_eq!(destination("foo.txt", "/"), "/foo.txt");
|
||||
assert_eq!(destination("foo.txt", "/tmp"), "/tmp/foo.txt");
|
||||
assert_eq!(destination("foo.txt", "/tmp/"), "/tmp/foo.txt");
|
||||
|
||||
assert_eq!(destination("/usr/vinc/foo.txt", "/"), "/foo.txt");
|
||||
assert_eq!(destination("/usr/vinc/foo.txt", "/tmp"), "/tmp/foo.txt");
|
||||
assert_eq!(destination("/usr/vinc/foo.txt", "/tmp/"), "/tmp/foo.txt");
|
||||
|
||||
sys::fs::dismount();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::api::console::Style;
|
||||
use crate::api::process::ExitCode;
|
||||
use crate::api::random;
|
||||
use crate::api::rng;
|
||||
use crate::api::syscall;
|
||||
use crate::sys::fs::OpenFlag;
|
||||
use crate::usr;
|
||||
|
@ -61,7 +61,7 @@ impl Message {
|
|||
pub fn query(qname: &str, qtype: QueryType, qclass: QueryClass) -> Self {
|
||||
let mut datagram = Vec::new();
|
||||
|
||||
let id = random::get_u16();
|
||||
let id = rng::get_u16();
|
||||
for b in id.to_be_bytes().iter() {
|
||||
datagram.push(*b); // Transaction ID
|
||||
}
|
||||
|
|
117
src/usr/httpd.rs
117
src/usr/httpd.rs
|
@ -23,6 +23,7 @@ use smoltcp::wire::IpAddress;
|
|||
|
||||
const MAX_CONNECTIONS: usize = 32;
|
||||
const POLL_DELAY_DIV: usize = 128;
|
||||
const INDEX: [&str; 4] = ["", "/index.html", "/index.htm", "/index.txt"];
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Request {
|
||||
|
@ -212,16 +213,14 @@ fn get(req: &Request, res: &mut Response) {
|
|||
res.body.extend_from_slice(b"<h1>Moved Permanently</h1>\r\n");
|
||||
} else {
|
||||
let mut not_found = true;
|
||||
for autocomplete in
|
||||
&["", "/index.html", "/index.htm", "/index.txt"]
|
||||
{
|
||||
let real_path = format!("{}{}", res.real_path, autocomplete);
|
||||
for index in INDEX {
|
||||
let real_path = format!("{}{}", res.real_path, index);
|
||||
if fs::is_dir(&real_path) {
|
||||
continue;
|
||||
}
|
||||
if let Ok(buf) = fs::read_to_bytes(&real_path) {
|
||||
res.code = 200;
|
||||
res.mime = content_type(&res.real_path);
|
||||
res.mime = content_type(&real_path);
|
||||
let tmp;
|
||||
res.body.extend_from_slice(
|
||||
if res.mime.starts_with("text/") {
|
||||
|
@ -338,6 +337,9 @@ pub fn main(args: &[&str]) -> Result<(), ExitCode> {
|
|||
i += 1;
|
||||
}
|
||||
|
||||
// NOTE: This specific format is needed by `join_path`
|
||||
let dir = format!("/{}", fs::realpath(&dir).trim_matches('/'));
|
||||
|
||||
if let Some((ref mut iface, ref mut device)) = *sys::net::NET.lock() {
|
||||
let mut sockets = SocketSet::new(vec![]);
|
||||
|
||||
|
@ -381,45 +383,57 @@ pub fn main(args: &[&str]) -> Result<(), ExitCode> {
|
|||
None => continue,
|
||||
};
|
||||
if socket.may_recv() {
|
||||
let res = socket.recv(|buf| {
|
||||
if let Some(req) = Request::from(endpoint.addr, buf) {
|
||||
let mut res = Response::new(req.clone());
|
||||
let sep = if req.path == "/" { "" } else { "/" };
|
||||
res.real_path = format!(
|
||||
"{}{}{}",
|
||||
dir,
|
||||
sep,
|
||||
req.path.strip_suffix('/').unwrap_or(&req.path)
|
||||
).replace("//", "/");
|
||||
|
||||
match req.verb.as_str() {
|
||||
"GET" => {
|
||||
get(&req, &mut res)
|
||||
}
|
||||
"PUT" if !read_only => {
|
||||
put(&req, &mut res)
|
||||
}
|
||||
"DELETE" if !read_only => {
|
||||
delete(&req, &mut res)
|
||||
}
|
||||
_ => {
|
||||
let s = b"<h1>Bad Request</h1>\r\n";
|
||||
res.body.extend_from_slice(s);
|
||||
res.code = 400;
|
||||
res.mime = "text/html".to_string();
|
||||
}
|
||||
// The amount of octets queued in the receive buffer may be
|
||||
// larger than the contiguous slice returned by `recv` so
|
||||
// we need to loop over chunks of it until it is empty.
|
||||
let recv_queue = socket.recv_queue();
|
||||
let mut receiving = true;
|
||||
let mut buf = vec![];
|
||||
while receiving {
|
||||
let res = socket.recv(|chunk| {
|
||||
buf.extend_from_slice(chunk);
|
||||
if buf.len() < recv_queue {
|
||||
return (chunk.len(), None);
|
||||
}
|
||||
res.end();
|
||||
println!("{}", res);
|
||||
(buf.len(), Some(res))
|
||||
} else {
|
||||
(0, None)
|
||||
receiving = false;
|
||||
|
||||
let addr = endpoint.addr;
|
||||
if let Some(req) = Request::from(addr, &buf) {
|
||||
let mut res = Response::new(req.clone());
|
||||
res.real_path = join_path(&dir, &req.path);
|
||||
|
||||
match req.verb.as_str() {
|
||||
"GET" => {
|
||||
get(&req, &mut res)
|
||||
}
|
||||
"PUT" if !read_only => {
|
||||
put(&req, &mut res)
|
||||
}
|
||||
"DELETE" if !read_only => {
|
||||
delete(&req, &mut res)
|
||||
}
|
||||
_ => {
|
||||
let s = b"<h1>Bad Request</h1>\r\n";
|
||||
res.body.extend_from_slice(s);
|
||||
res.code = 400;
|
||||
res.mime = "text/html".to_string();
|
||||
}
|
||||
}
|
||||
res.end();
|
||||
println!("{}", res);
|
||||
(chunk.len(), Some(res))
|
||||
} else {
|
||||
(0, None)
|
||||
}
|
||||
});
|
||||
if receiving {
|
||||
continue;
|
||||
}
|
||||
});
|
||||
if let Ok(Some(res)) = res {
|
||||
*keep_alive = res.is_persistent();
|
||||
for chunk in res.buf.chunks(buf_len) {
|
||||
send_queue.push_back(chunk.to_vec());
|
||||
if let Ok(Some(res)) = res {
|
||||
*keep_alive = res.is_persistent();
|
||||
for chunk in res.buf.chunks(buf_len) {
|
||||
send_queue.push_back(chunk.to_vec());
|
||||
}
|
||||
}
|
||||
}
|
||||
if socket.can_send() {
|
||||
|
@ -468,6 +482,15 @@ fn content_type(path: &str) -> String {
|
|||
}.to_string()
|
||||
}
|
||||
|
||||
// Join the requested file path to the root dir of the server
|
||||
fn join_path(dir: &str, path: &str) -> String {
|
||||
debug_assert!(dir.starts_with('/'));
|
||||
debug_assert!(path.starts_with('/'));
|
||||
let path = path.trim_matches('/');
|
||||
let sep = if dir == "/" || path == "" { "" } else { "/" };
|
||||
format!("{}{}{}", dir, sep, path)
|
||||
}
|
||||
|
||||
fn usage() {
|
||||
let csi_option = Style::color("LightCyan");
|
||||
let csi_title = Style::color("Yellow");
|
||||
|
@ -491,3 +514,13 @@ fn usage() {
|
|||
csi_option, csi_reset
|
||||
);
|
||||
}
|
||||
|
||||
#[test_case]
|
||||
fn test_join_path() {
|
||||
assert_eq!(join_path("/foo", "/bar/"), "/foo/bar");
|
||||
assert_eq!(join_path("/foo", "/bar"), "/foo/bar");
|
||||
assert_eq!(join_path("/foo", "/"), "/foo");
|
||||
assert_eq!(join_path("/", "/bar/"), "/bar");
|
||||
assert_eq!(join_path("/", "/bar"), "/bar");
|
||||
assert_eq!(join_path("/", "/"), "/");
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ use crate::{api, sys};
|
|||
use crate::api::console::Style;
|
||||
use crate::api::fs;
|
||||
use crate::api::process::ExitCode;
|
||||
use crate::api::random;
|
||||
use crate::api::rng;
|
||||
use crate::sys::console;
|
||||
|
||||
use alloc::collections::BTreeSet;
|
||||
|
@ -109,8 +109,8 @@ impl Game {
|
|||
fn seed(&mut self) {
|
||||
let n = self.seed_population;
|
||||
for _ in 0..n {
|
||||
let x = (random::get_u64() % (self.cols as u64)) as i64;
|
||||
let y = (random::get_u64() % (self.rows as u64)) as i64;
|
||||
let x = (rng::get_u64() % (self.cols as u64)) as i64;
|
||||
let y = (rng::get_u64() % (self.rows as u64)) as i64;
|
||||
self.grid.insert((x, y));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,10 @@ pub fn main(args: &[&str]) -> Result<(), ExitCode> {
|
|||
}
|
||||
|
||||
// TODO: Avoid doing copy+delete
|
||||
match usr::copy::main(args) {
|
||||
Ok(()) => usr::delete::main(&args[0..2]),
|
||||
_ => Err(ExitCode::Failure),
|
||||
if usr::copy::main(args).is_ok() {
|
||||
usr::delete::main(&args[0..2])
|
||||
} else {
|
||||
Err(ExitCode::Failure)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::api::console::Style;
|
||||
use crate::api::process::ExitCode;
|
||||
use crate::api::{console, io, random};
|
||||
use crate::api::{console, io, rng};
|
||||
|
||||
use alloc::format;
|
||||
use alloc::string::ToString;
|
||||
|
@ -52,7 +52,7 @@ impl Game {
|
|||
let zeros: Vec<_> = (0..16).filter(|i| self.board[*i] == 0).collect();
|
||||
|
||||
if !zeros.is_empty() {
|
||||
let i = (random::get_u64() as usize) % zeros.len();
|
||||
let i = (rng::get_u64() as usize) % zeros.len();
|
||||
self.board[zeros[i]] = 2;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ use crate::api::console::Style;
|
|||
use crate::api::fs;
|
||||
use crate::api::io;
|
||||
use crate::api::process::ExitCode;
|
||||
use crate::api::random;
|
||||
use crate::api::rng;
|
||||
use crate::api::syscall;
|
||||
use crate::{api, sys, usr};
|
||||
use alloc::collections::btree_map::BTreeMap;
|
||||
|
@ -165,7 +165,7 @@ pub fn hash(password: &str) -> String {
|
|||
|
||||
// Generating salt
|
||||
for i in 0..2 {
|
||||
let num = random::get_u64();
|
||||
let num = rng::get_u64();
|
||||
let buf = num.to_be_bytes();
|
||||
let n = buf.len();
|
||||
for j in 0..n {
|
||||
|
|
Loading…
Reference in New Issue