File: argon2_vectors.js

package info (click to toggle)
firefox 147.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,683,324 kB
  • sloc: cpp: 7,607,156; javascript: 6,532,492; ansic: 3,775,158; python: 1,415,368; xml: 634,556; asm: 438,949; java: 186,241; sh: 62,751; makefile: 18,079; objc: 13,092; perl: 12,808; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10; exp: 6
file content (66 lines) | stat: -rw-r--r-- 2,054 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
function getTestData() {
  // Test vectors from RFC 9106
  // https://www.rfc-editor.org/rfc/rfc9106

  // Test vectors from RFC 9106
  var testVectors = [
    // Argon2d test vector
    {
      algorithm: 'Argon2d',
      password: new Uint8Array(32).fill(0x01),
      params: {
        memory: 32,
        passes: 3,
        parallelism: 4,
        nonce: new Uint8Array(16).fill(0x02),
        secretValue: new Uint8Array(8).fill(0x03),
        associatedData: new Uint8Array(12).fill(0x04),
      },
      expected: new Uint8Array([
        0x51, 0x2b, 0x39, 0x1b, 0x6f, 0x11, 0x62, 0x97, 0x53, 0x71, 0xd3, 0x09,
        0x19, 0x73, 0x42, 0x94, 0xf8, 0x68, 0xe3, 0xbe, 0x39, 0x84, 0xf3, 0xc1,
        0xa1, 0x3a, 0x4d, 0xb9, 0xfa, 0xbe, 0x4a, 0xcb,
      ]),
    },
    // Argon2i test vector
    {
      algorithm: 'Argon2i',
      password: new Uint8Array(32).fill(0x01),
      params: {
        memory: 32,
        passes: 3,
        parallelism: 4,
        nonce: new Uint8Array(16).fill(0x02),
        secretValue: new Uint8Array(8).fill(0x03),
        associatedData: new Uint8Array(12).fill(0x04),
      },
      expected: new Uint8Array([
        0xc8, 0x14, 0xd9, 0xd1, 0xdc, 0x7f, 0x37, 0xaa, 0x13, 0xf0, 0xd7, 0x7f,
        0x24, 0x94, 0xbd, 0xa1, 0xc8, 0xde, 0x6b, 0x01, 0x6d, 0xd3, 0x88, 0xd2,
        0x99, 0x52, 0xa4, 0xc4, 0x67, 0x2b, 0x6c, 0xe8,
      ]),
    },
    // Argon2id test vector
    {
      algorithm: 'Argon2id',
      password: new Uint8Array(32).fill(0x01),
      params: {
        memory: 32,
        passes: 3,
        parallelism: 4,
        nonce: new Uint8Array(16).fill(0x02),
        secretValue: new Uint8Array(8).fill(0x03),
        associatedData: new Uint8Array(12).fill(0x04),
      },
      expected: new Uint8Array([
        0x0d, 0x64, 0x0d, 0xf5, 0x8d, 0x78, 0x76, 0x6c, 0x08, 0xc0, 0x37, 0xa3,
        0x4a, 0x8b, 0x53, 0xc9, 0xd0, 0x1e, 0xf0, 0x45, 0x2d, 0x75, 0xb6, 0x5e,
        0xb5, 0x25, 0x20, 0xe9, 0x6b, 0x01, 0xe6, 0x59,
      ]),
    },
  ];

  return {
    testVectors: testVectors,
  };
}