From 0993e9e14605533360e66c61ba00561665e9ae48 Mon Sep 17 00:00:00 2001 From: Acrimon Date: Wed, 13 May 2020 01:08:33 +0200 Subject: [PATCH] Fix #556 --- server/Cargo.toml | 2 +- server/src/auth_provider.rs | 24 +++++++----------------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/server/Cargo.toml b/server/Cargo.toml index 128ca49644..165513ac2f 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -35,4 +35,4 @@ authc = { git = "https://gitlab.com/veloren/auth.git", rev = "65571ade0d954a0e0b libsqlite3-sys = { version = "0.9.1", features = ["bundled"] } diesel = { version = "1.4.3", features = ["sqlite"] } diesel_migrations = "1.4.0" -dotenv = "0.15.0" \ No newline at end of file +dotenv = "0.15.0" diff --git a/server/src/auth_provider.rs b/server/src/auth_provider.rs index 03c3db9960..61623b6076 100644 --- a/server/src/auth_provider.rs +++ b/server/src/auth_provider.rs @@ -5,24 +5,14 @@ use log::error; use std::str::FromStr; fn derive_uuid(username: &str) -> Uuid { - let mut state: [u8; 16] = [ - 52, 17, 19, 239, 52, 17, 19, 239, 52, 17, 19, 239, 52, 17, 19, 239, - ]; - for mix_byte_1 in username.as_bytes() { - for i in 0..16 { - let mix_byte_step: u8 = mix_byte_1 - .wrapping_pow(239) - .wrapping_mul((i as u8).wrapping_pow(43)); - let mix_byte_2 = state[(i + mix_byte_step as usize) % 16]; - let rot_step: u8 = mix_byte_1 - .wrapping_pow(29) - .wrapping_mul((i as u8).wrapping_pow(163)); - state[i] = (state[i] ^ mix_byte_1) - .wrapping_mul(mix_byte_2) - .rotate_left(rot_step as u32); - } + let mut state = 144066263297769815596495629667062367629; + + for byte in username.as_bytes() { + state ^= *byte as u128; + state = state.wrapping_mul(309485009821345068724781371); } - Uuid::from_slice(&state).unwrap() + + Uuid::from_slice(&state.to_be_bytes()).unwrap() } pub struct AuthProvider {