We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug In "Derive KDF key", if the Salt is in HEX mode and Salt contains multi-bytes of UTF-8, it will get the wrong result.
To Reproduce
hello
deadbeef
And it should output a06aeae0a8790070445991fd480c0d91 in CyberChef.
a06aeae0a8790070445991fd480c0d91
Reproduce Link
Expected behaviour As CyberChef use CryptoJS as backend for this recipe, here use CryptoJS to show the expected behaviour:
const CryptoJS = require("crypto-js"); // 4.1.1 const key = CryptoJS.EvpKDF( 'hello', CryptoJS.lib.WordArray.create([ 0xdeadbeef ], 4), { keySize: 4, hasher: CryptoJS.algo.MD5, iterations: 1, } ); console.log(key.toString()); // -> 467e8570f8a641fcd5411176b1740d53
Possible Cause In CyberChef's "Derive KDF key",
CyberChef/src/core/operations/DeriveEVPKey.mjs
Line 69 in 1bc8872
0xdeadbeef
Þ\xad¾ï
Next, in CryptoJS.EvpKDF, when appends salt to the hasher, https://github.com/brix/crypto-js/blob/4dcaa7afd08f48cd285463b8f9499cdb242605fa/src/core.js#L564 it will parse the "byte string" to its WordArray by Utf8.parse. So, the non-ASCII characters are encoded again, but in UTF-8 encoding, which gets c39ec2adc2bec3af.
CryptoJS.EvpKDF
salt
Utf8.parse
c39ec2adc2bec3af
That is, although the salt is 0xdeadbeef in frontend, but in fact it's treated as c39ec2adc2bec3af, and thus it gets the wrong result.
The text was updated successfully, but these errors were encountered:
Maybe related: #210
Sorry, something went wrong.
Fixed in #1767
No branches or pull requests
Describe the bug
In "Derive KDF key", if the Salt is in HEX mode and Salt contains multi-bytes of UTF-8, it will get the wrong result.
To Reproduce
hello
(UTF8)deadbeef
(HEX)And it should output
a06aeae0a8790070445991fd480c0d91
in CyberChef.Reproduce Link
Expected behaviour
As CyberChef use CryptoJS as backend for this recipe, here use CryptoJS to show the expected behaviour:
Possible Cause
In CyberChef's "Derive KDF key",
CyberChef/src/core/operations/DeriveEVPKey.mjs
Line 69 in 1bc8872
it first parses the hex sequence back to byte string. So,
0xdeadbeef
is parsed toÞ\xad¾ï
.Next, in
CryptoJS.EvpKDF
, when appendssalt
to the hasher,https://github.com/brix/crypto-js/blob/4dcaa7afd08f48cd285463b8f9499cdb242605fa/src/core.js#L564
it will parse the "byte string" to its WordArray by
Utf8.parse
. So, the non-ASCII characters are encoded again, but in UTF-8 encoding, which getsc39ec2adc2bec3af
.That is, although the salt is
0xdeadbeef
in frontend, but in fact it's treated asc39ec2adc2bec3af
, and thus it gets the wrong result.The text was updated successfully, but these errors were encountered: