From 96a8bbe470e5920411c5fe1ce5bd91498ec20ff6 Mon Sep 17 00:00:00 2001 From: red binder Date: Mon, 22 Jun 2026 13:42:06 +0200 Subject: [PATCH] hash the guest user password --- rnex-core/src/nex/account.rs | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/rnex-core/src/nex/account.rs b/rnex-core/src/nex/account.rs index eb542ff..08b2cdf 100644 --- a/rnex-core/src/nex/account.rs +++ b/rnex-core/src/nex/account.rs @@ -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, }