Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Asm Hash is incorrect #78

Closed
MaxKingPor opened this issue May 4, 2024 · 2 comments · Fixed by #79
Closed

Windows Asm Hash is incorrect #78

MaxKingPor opened this issue May 4, 2024 · 2 comments · Fixed by #79

Comments

@MaxKingPor
Copy link

  • env
CC_x86_64-pc-windows-gnu = "x86_64-w64-mingw32-gcc"
  • toolchain stable-x86_64-pc-windows-gnu
$: rustc --version  
rustc 1.78.0 (9b00956e5 2024-04-29)
$: x86_64-w64-mingw32-gcc --version
x86_64-w64-mingw32-gcc.exe (x86_64-win32-seh-rev0, Built by MinGW-W64 project) 8.1.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$: Get-ComputerInfo | select WindowsProductName, WindowsVersion, OsHardwareAbstractionLayer

WindowsProductName             WindowsVersion OsHardwareAbstractionLayer
------------------             -------------- --------------------------
Windows Server 2022 Datacenter 2009           10.0.20348.2031  
  • Dependencies
sha2 = { version = "0.10.8", features = ["asm"] }
  • In Rust
let mut r = sha2::Sha256::new();
r.update(b"hello\n");
println!("{:x}", r.finalize());
// out: 
// 6a09e667bb67ae853c6ef372a54ff53a510e527f9b05688c1f83d9ab5be0cd19
  • In Python
r = hashlib.sha256(b"hello\n").hexdigest()
print(r)
# out
# 5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03
@MaxKingPor MaxKingPor changed the title Windaus Hash is incorrect Windows Asm Hash is incorrect May 4, 2024
@newpavlov
Copy link
Member

newpavlov commented May 5, 2024

Could you look into generated assembly? And check if the incorrect behavior is reproducible with other Rust versions? It's probably caused by some weird ABI issue...

We probably should simply raise compilation error when these crates get compiled on Windows, regardless whether it's MSVC or GNU toolchain.

@MaxKingPor
Copy link
Author

Could you look into generated assembly? And check if the incorrect behavior is reproducible with other Rust versions? It's probably caused by some weird ABI issue...

We probably should simply raise compilation error when these crates get compiled on Windows, regardless whether it's MSVC or GNU toolchain.

image
It's the same with toolchain 1.70-x86_64-pc-windows-gnu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants