There are test vectors for PBKDF2-HMAC-SHA1 in RFC6070. There are test vectors for HMAC-SHA2 in RFC4231.
But so far I haven't found test vectors for PBKDF2-HMAC-SHA2 anywhere.
I'm most interested in SHA256, so I'll post some vectors I calculated with my implementation. I'd be happy if someone could verify/confirm them, or contribute their own.
Test vectors for PBKDF2-HMAC-SHA256:
Input values were taken from RFC6070; c is the number of rounds.
I implemented PBKDF2 using the standard hashlib and hmac modules in Python and checked the output against both the RFC 6070 vectors and the vectors you posted – it matches.
Here are the vectors I get with a larger
dkLen
to match the larger digest output size. This is the output ofpbkdf2-test-vectors.py sha256
, which takes about 10 minutes to run.I should probably finally post what I did awhile ago based on this very question!
At my Github repository, I have compiled test vectors for
Tests started with RFC6070 and those in the answer by @ChristianAichinger above for PBKDF2-HMAC-SHA-256, and added a few dozen more to implement more stringent tests, such as boundary conditions around certain sizes of password and salt (15/16/17 bytes, 63/64/65 bytes, 127/128/129 bytes, 1025 bytes etc.), large iteration counts, large output size counts, and so on and so forth.
I then gathered up many instances of PBKDF2, and validated these test vectors against every major implementation I was able to find (all also included in the above repository, sometimes including Windows MinGW executables and generally including Linux compilation instructions), including
Given that I'm seeing identical results across 7 implementations using 5 different languages using multiple major cryptographic libraries, I'm extremely confident that not only are the test vectors provided accurate, but that the implementations provided can be used as a set to validate any other test vector set desired. If they all agree, then it's correct.