diff options
| author | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-08-04 23:53:30 +0200 |
|---|---|---|
| committer | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-08-04 23:53:30 +0200 |
| commit | cc03f40d9fb1d68bfd945284a3ff5067dfd8475a (patch) | |
| tree | 899b9cfae976c92579543653f904453fc1c2ab8f /Kernel/Sources/User.cxx | |
| parent | fb0ca452cda3bdc4a13f278c115f2dcd9360d818 (diff) | |
[IMP] [unstable] User password hashing, and renamed newoskrnl.dll to newoskrnl.lib.
[IMP] [unstable] Using paths for usernames. Such as \Local\Super on
192.168.2.4 for example.
Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Kernel/Sources/User.cxx')
| -rw-r--r-- | Kernel/Sources/User.cxx | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/Kernel/Sources/User.cxx b/Kernel/Sources/User.cxx index 60981551..e0ccaf6b 100644 --- a/Kernel/Sources/User.cxx +++ b/Kernel/Sources/User.cxx @@ -26,9 +26,19 @@ namespace Kernel /// \brief Constructs a token by hashing the password. /// \param password password to hash. /// \return the hashed password - const Char* cred_construct_token(const Char* password) + const Int32 cred_construct_token(Char* password, User* user) { - return nullptr; + if (!password || !user) + return -1; + + for (Size i_pass = 0; i_pass < rt_string_len(password); ++i_pass) + { + Char cur_chr = password[i_pass]; + password[i_pass] = cur_chr + (user->IsStdUser() ? 0xCF : 0xEF); + } + + + return 0; } } @@ -90,7 +100,7 @@ namespace Kernel return view; } - Bool UserManager::LogIn(User* user, const Char* password) noexcept + Bool UserManager::TryLogIn(User* user, const Char* password) noexcept { if (!password || !user) @@ -119,9 +129,25 @@ namespace Kernel } else { - auto tok = Detail::cred_construct_token(password); + Char generated_token[255] = { 0 }; + + // ================================================== // + // Provide password on token variable. + // ================================================== // + + rt_copy_memory((VoidPtr)password, generated_token, rt_string_len(password)); + + // ================================================== // + // Construct token. + // ================================================== // + + Detail::cred_construct_token(generated_token, user); + + // ================================================== // + // Checks if it matches the current token we have. + // ================================================== // - if (rt_string_cmp((Char*)token, tok, rt_string_len(tok))) + if (rt_string_cmp((Char*)token, generated_token, rt_string_len(password))) { kcout << "newoskrnl: Incorrect credentials.\r"; @@ -146,7 +172,7 @@ namespace Kernel } else { - this->LogOff(); + this->TryLogOff(); } } @@ -156,12 +182,12 @@ namespace Kernel return true; } - User* UserManager::Current() noexcept + User* UserManager::GetCurrent() noexcept { return fCurrentUser; } - Void UserManager::LogOff() noexcept + Void UserManager::TryLogOff() noexcept { if (!fCurrentUser) return; |
