Archived Forum Post

Index of archived forum posts


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?


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


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?


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"...


Are there any news? Could you reproduce this problem?


Try these new builds: