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

sha2 is much slower than crate ring on windows an linux #632

Closed
zhuyu4839 opened this issue Nov 28, 2024 · 1 comment
Closed

sha2 is much slower than crate ring on windows an linux #632

zhuyu4839 opened this issue Nov 28, 2024 · 1 comment

Comments

@zhuyu4839
Copy link

zhuyu4839 commented Nov 28, 2024

the source code:

src/aes256sha256.rs

line 143~156

        let mut sha = sha2::Sha256::default();
        let mut extra = [0u8; 8];
        for _ in 0..(1u32 << num_cycles_power) {
            sha.update(&salt);
            sha.update(password);
            sha.update(extra);
            for item in &mut extra {
                *item = item.wrapping_add(1);
                if *item != 0 {
                    break;
                }
            }
        }
        sha.finalize().into()

slow than use crate ring

        let mut sha = Context::new(&SHA256);
        let mut extra = [0u8; 8];
        for _ in 0..(1u32 << num_cycles_power) {
            sha.update(&salt);
            sha.update(password);
            sha.update(&extra);
            for item in &mut extra {
                *item = item.wrapping_add(1);
                if *item != 0 {
                    break;
                }
            }
        }
        sha.finish().as_ref().try_into()
            .map_err(|_| crate::Error::other("AES256 sha256 hashing failed"))?
@zhuyu4839 zhuyu4839 changed the title sha2 is much slower than crate ring sha2 is much slower than crate ring on windows an linux Nov 28, 2024
@newpavlov
Copy link
Member

See #327

@newpavlov newpavlov closed this as not planned Won't fix, can't repro, duplicate, stale Nov 28, 2024
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

No branches or pull requests

2 participants