hash the guest user password

This commit is contained in:
red binder 2026-06-22 13:42:06 +02:00
commit 96a8bbe470

View file

@ -1,3 +1,4 @@
use md5::{Digest, Md5};
use macros::RmcSerialize;
use rnex_core::PID;
@ -11,16 +12,46 @@ pub struct Account {
impl Account {
pub fn new(pid: PID, username: &str, passwd: &str) -> Self {
let iteration_count = 65000;
// we do one iteration out here to ensure the key is always 16 bytes
let mut key: [u8; 16] = {
let mut md5 = Md5::new();
md5.update(passwd);
md5.finalize().try_into().unwrap()
};
for _ in 1..iteration_count {
let mut md5 = Md5::new();
md5.update(key);
key = md5.finalize().try_into().unwrap();
}
Self {
kerbros_password: passwd.as_bytes().into(),
kerbros_password: key.into(),
username: username.into(),
pid,
}
}
pub fn new_raw_password(pid: PID, username: &str, passwd: &[u8]) -> Self {
let iteration_count = 65000;
// we do one iteration out here to ensure the key is always 16 bytes
let mut key: [u8; 16] = {
let mut md5 = Md5::new();
md5.update(passwd);
md5.finalize().try_into().unwrap()
};
for _ in 1..iteration_count {
let mut md5 = Md5::new();
md5.update(key);
key = md5.finalize().try_into().unwrap();
}
Self {
kerbros_password: passwd.into(),
kerbros_password: key.into(),
username: username.into(),
pid,
}