Created
November 21, 2021 23:26
-
-
Save oconnor663/2cb1a9bfad1c86d92395316e4abb2b99 to your computer and use it in GitHub Desktop.
HKDF collision between different salts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "scratch" | |
version = "0.1.0" | |
edition = "2021" | |
[dependencies] | |
hex = "0.4.3" | |
hkdf = "0.11.0" | |
sha2 = "0.9.8" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use hkdf::Hkdf; | |
use sha2::Sha256; | |
fn main() { | |
let ikm = b"my ikm"; | |
let info = b"my info"; | |
let salts: &[&[u8]] = &[b"my salt", b"my salt\0"]; | |
for salt in salts { | |
let h = Hkdf::<Sha256>::new(Some(&salt[..]), ikm); | |
let mut okm = [0u8; 32]; | |
h.expand(info, &mut okm).unwrap(); | |
println!("OKM is {}", hex::encode(&okm[..])); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OKM is 1d615d90d1171347e5567571e5c8196665ae2481ef603ded8da93e0824ef37f2 | |
OKM is 1d615d90d1171347e5567571e5c8196665ae2481ef603ded8da93e0824ef37f2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment