Comparison

spec/util_hashes_spec.lua @ 9964:f299d4917dd8

util.hashes: Add test vectors from RFC 6070 for PBKDF2 (aka SCRAM Hi()) Number 4 is disabled by default beacuse of how long time it takes
author Kim Alvefur <zash@zash.se>
date Fri, 19 Apr 2019 14:12:28 +0200
child 9969:61bc5c52c941
comparison
equal deleted inserted replaced
9963:90a3cd25f2ae 9964:f299d4917dd8
1 -- Test vectors from RFC 6070
2 local hashes = require "util.hashes";
3 local hex = require "util.hex";
4
5 -- Also see spec for util.hmac where HMAC test cases reside
6
7 describe("PBKDF2-SHA1", function ()
8 it("test vector 1", function ()
9 local P = "password"
10 local S = "salt"
11 local c = 1
12 local DK = "0c60c80f961f0e71f3a9b524af6012062fe037a6";
13 assert.equal(DK, hex.to(hashes.scram_Hi_sha1(P, S, c)));
14 end);
15 it("test vector 2", function ()
16 local P = "password"
17 local S = "salt"
18 local c = 2
19 local DK = "ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957";
20 assert.equal(DK, hex.to(hashes.scram_Hi_sha1(P, S, c)));
21 end);
22 it("test vector 3", function ()
23 local P = "password"
24 local S = "salt"
25 local c = 4096
26 local DK = "4b007901b765489abead49d926f721d065a429c1";
27 assert.equal(DK, hex.to(hashes.scram_Hi_sha1(P, S, c)));
28 end);
29 it("test vector 4 #SLOW", function ()
30 local P = "password"
31 local S = "salt"
32 local c = 16777216
33 local DK = "eefe3d61cd4da4e4e9945b3d6ba2158c2634e984";
34 assert.equal(DK, hex.to(hashes.scram_Hi_sha1(P, S, c)));
35 end);
36 end);
37