Software /
code /
prosody
Comparison
spec/util_hashes_spec.lua @ 10748:93293891709b
util.hashes: Fix output length of PBKDF2-HMAC-SHA256
Somehow it got SHA1's 20 byte output instead of the proper 32 = 256/8
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 22 Apr 2020 21:38:36 +0200 |
parent | 10747:63a89b876407 |
child | 12355:a0ff5c438e9d |
comparison
equal
deleted
inserted
replaced
10747:63a89b876407 | 10748:93293891709b |
---|---|
33 local DK = "eefe3d61cd4da4e4e9945b3d6ba2158c2634e984"; | 33 local DK = "eefe3d61cd4da4e4e9945b3d6ba2158c2634e984"; |
34 assert.equal(DK, hex.to(hashes.pbkdf2_hmac_sha1(P, S, c))); | 34 assert.equal(DK, hex.to(hashes.pbkdf2_hmac_sha1(P, S, c))); |
35 end); | 35 end); |
36 end); | 36 end); |
37 | 37 |
38 describe("PBKDF2-HMAC-SHA256", function () | |
39 it("test vector 1", function () | |
40 local P = "password"; | |
41 local S = "salt"; | |
42 local c = 1 | |
43 local DK = "120fb6cffcf8b32c43e7225256c4f837a86548c92ccc35480805987cb70be17b"; | |
44 assert.equal(DK, hex.to(hashes.pbkdf2_hmac_sha256(P, S, c))); | |
45 end); | |
46 it("test vector 2", function () | |
47 local P = "password"; | |
48 local S = "salt"; | |
49 local c = 2 | |
50 local DK = "ae4d0c95af6b46d32d0adff928f06dd02a303f8ef3c251dfd6e2d85a95474c43"; | |
51 assert.equal(DK, hex.to(hashes.pbkdf2_hmac_sha256(P, S, c))); | |
52 end); | |
53 end); | |
54 | |
55 |