jos3k4 / crypto-js

Automatically exported from code.google.com/p/crypto-js
0 stars 0 forks source link

PBKDF2 with other hashing algorithms #86

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a new html5 page with the PBKDF2 example script from the documentation
2. Add the necessary scripts from the rollup folder (pbkdf2.js, all hmac-*.js)
3. Add 'hasher: CryptoJS.SHA256' (or any other SHA algorithm) in the 
cfg-parameter of the PBKDF2 function.
4. The script will stop executing at the first for-loop in the compute function.

What is the expected output?
A key computed by the password based key derivation function with the SHA256 
algorithm.

What do you see instead?
Nothing. Also, no error was thrown by the debugger.

What version of the product are you using? On what operating system?
CryptoJS v3.1.2 on Windows 8 with Firefox 19.0.2 and IE 10

Please provide any additional information below.
I am aware that the hasher-parameter is not documented in version 3.x, although 
it was available in version 2.x. When looking at the source code, the hasher 
parameter still seems to be present in version 3.x.

Original issue reported on code.google.com by hoeew...@gmail.com on 25 Mar 2013 at 7:46

GoogleCodeExporter commented 9 years ago
In the PBKDF2 config, you'll need to pass CryptoJS.algo.SHA256 rather than 
CryptoJS.SHA256. The former is the actual "class", while the latter is a 
convenience/shortcut function. Admittedly the example doesn't make this clear. 
I'll update that when I can. Also, in the next major revision, there will no 
longer be a distinction between the class and the shortcut function.

Original comment by Jeff.Mott.OR on 25 Mar 2013 at 8:26

GoogleCodeExporter commented 9 years ago

Original comment by Jeff.Mott.OR on 26 Mar 2013 at 9:24

GoogleCodeExporter commented 9 years ago
I have this issue when using the correct hasher parameter suggested above.

CryptoJS.PBKDF2(password, salt, { hasher:CryptoJS.algo.SHA256 });

Here is the chrome console error output:
Uncaught TypeError: Object [object Array] has no method 'clamp' pbkdf2.js:16
g.algo.HMAC.g.lib.Base.extend.init pbkdf2.js:16
c.hasOwnProperty.c.init aes.js:7
l.Base.create aes.js:7
j.PBKDF2.e.extend.compute pbkdf2.js:18
g.PBKDF2 pbkdf2.js:19

The same error also arises using CryptoJS.PBKDF2(password, salt, { 
hasher:CryptoJS.algo.SHA1 }).

Original comment by KevinRausch on 28 May 2013 at 12:56

GoogleCodeExporter commented 9 years ago
Where are the password and salt values coming from?

Original comment by Jeff.Mott.OR on 28 May 2013 at 1:04

GoogleCodeExporter commented 9 years ago
The password and salt were wrong. I'm migrating from SJCL to CryptoJS and I was 
stupidly using their string parser. Issue fixed. Thanks for your time.

Original comment by KevinRausch on 28 May 2013 at 1:20