Archived Forum Post

Index of archived forum posts

Question:

PBKDF2 with SHA256 won't work

Mar 14 '14 at 11:18

I'm trying to use CkCrypt2 Pbkdf2 function with HMAC-SHA256. In your documentation I find: "The hashAlg may be "md5", "sha1", "md2", etc." - So I used "sha256". But

Pbkdf2((char*)&plain[0], "ANSI", "sha256", _salt, iterations, keylen, "hex", out);

returns true, but out is empty. Using "sha1" it returns a result. Is "sha256" valid and implemented?


Answer

It should be valid. I'll give it a quick test to verify..


Answer

It worked fine for me. Please provide the exact inputs for each arg so I can duplicate exactly what you did. Also, what programming language, operating system, .NET Framework, Visual Studio version, architecture, Perl version, Python version, etc. would you need for a new build, just in case it works for me with the same inputs?


Answer

Thanx A LOT for your fast investigation!

I'm using the latest C++ library v9.4.1SP1 under VS2013

plain is: "password", salt is "salt", iterations is: 4096, keylen is: 256

Code is:

const char* _salt = lib.encodeBytes(&salt[0], salt.size(), "hex");
CkString out;
bool res = lib.Pbkdf2((char*)&plain[0], "ANSI", "sha256", _salt, iterations, keylen, "hex", out);
const char* c = out.getAnsi();

res is true, but c is empty.

As I said, with "sha1" c has a valid result.

Strange: When I set (wrong) "sha2", result is SAME as with "sha1"...


Answer

Are there any news? Could you reproduce this problem?


Answer

Try these new builds:

32-bit: http://www.chilkatsoft.com/preRelease/chilkat-9.5.0-x86-vc12.zip

64-bit: http://www.chilkatsoft.com/preRelease/chilkat-9.5.0-x86_64-vc12.zip