Functional Weave
Code in TypeScript

crypto.pbkdf2-sha256@1.0.0

vectors.json

4,123 bytes · view raw

[
  {"name": "RFC 7914 section 11: \"passwd\" / \"salt\", 1 iteration, 64 bytes (two blocks)", "args": [[112, 97, 115, 115, 119, 100], [115, 97, 108, 116], 1, 64], "expect": [85, 172, 4, 110, 86, 227, 8, 159, 236, 22, 145, 194, 37, 68, 182, 5, 249, 65, 133, 33, 109, 222, 4, 101, 230, 139, 157, 87, 194, 13, 172, 188, 73, 202, 156, 204, 241, 121, 182, 69, 153, 22, 100, 179, 157, 119, 239, 49, 124, 113, 184, 69, 177, 227, 11, 213, 9, 17, 32, 65, 211, 161, 151, 131]},
  {"name": "RFC 7914 section 11: \"Password\" / \"NaCl\", 80,000 iterations, 64 bytes", "args": [[80, 97, 115, 115, 119, 111, 114, 100], [78, 97, 67, 108], 80000, 64], "expect": [77, 220, 216, 246, 11, 152, 190, 33, 131, 12, 238, 94, 242, 39, 1, 249, 100, 26, 68, 24, 208, 76, 4, 20, 174, 255, 8, 135, 107, 52, 171, 86, 161, 212, 37, 161, 34, 88, 51, 84, 154, 219, 132, 27, 81, 201, 179, 23, 106, 39, 43, 222, 187, 161, 208, 120, 71, 143, 98, 179, 151, 243, 60, 141]},
  {"name": "RFC 6070's inputs with SHA-256: 1 iteration", "args": [[112, 97, 115, 115, 119, 111, 114, 100], [115, 97, 108, 116], 1, 32], "expect": [18, 15, 182, 207, 252, 248, 179, 44, 67, 231, 34, 82, 86, 196, 248, 55, 168, 101, 72, 201, 44, 204, 53, 72, 8, 5, 152, 124, 183, 11, 225, 123]},
  {"name": "RFC 6070's inputs with SHA-256: 2 iterations", "args": [[112, 97, 115, 115, 119, 111, 114, 100], [115, 97, 108, 116], 2, 32], "expect": [174, 77, 12, 149, 175, 107, 70, 211, 45, 10, 223, 249, 40, 240, 109, 208, 42, 48, 63, 142, 243, 194, 81, 223, 214, 226, 216, 90, 149, 71, 76, 67]},
  {"name": "RFC 6070's inputs with SHA-256: 4096 iterations", "args": [[112, 97, 115, 115, 119, 111, 114, 100], [115, 97, 108, 116], 4096, 32], "expect": [197, 228, 120, 213, 146, 136, 200, 65, 170, 83, 13, 182, 132, 92, 76, 141, 150, 40, 147, 160, 1, 206, 78, 17, 164, 150, 56, 115, 170, 152, 19, 74]},
  {"name": "RFC 6070's inputs with SHA-256: long password and salt, 40 bytes cut from two blocks", "args": [[112, 97, 115, 115, 119, 111, 114, 100, 80, 65, 83, 83, 87, 79, 82, 68, 112, 97, 115, 115, 119, 111, 114, 100], [115, 97, 108, 116, 83, 65, 76, 84, 115, 97, 108, 116, 83, 65, 76, 84, 115, 97, 108, 116, 83, 65, 76, 84, 115, 97, 108, 116, 83, 65, 76, 84, 115, 97, 108, 116], 4096, 40], "expect": [52, 140, 137, 219, 203, 211, 43, 47, 50, 216, 20, 184, 17, 110, 132, 207, 43, 23, 52, 126, 188, 24, 0, 24, 28, 78, 42, 31, 184, 221, 83, 225, 198, 53, 81, 140, 125, 172, 71, 233]},
  {"name": "RFC 6070's inputs with SHA-256: NUL bytes inside password and salt, 16 bytes", "args": [[112, 97, 115, 115, 0, 119, 111, 114, 100], [115, 97, 0, 108, 116], 4096, 16], "expect": [137, 182, 157, 5, 22, 248, 41, 137, 60, 105, 98, 38, 101, 10, 134, 135]},
  {"name": "a password longer than 64 bytes is hashed first, as HMAC requires (hashlib as the reference)", "args": [[65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90], [115, 97, 108, 116], 3, 32], "expect": [9, 49, 133, 24, 41, 76, 78, 138, 90, 59, 13, 19, 48, 156, 20, 90, 25, 210, 255, 202, 49, 170, 31, 31, 35, 246, 76, 127, 54, 202, 172, 146]},
  {"name": "an empty password and a one-byte key (hashlib as the reference)", "args": [[], [115, 97, 108, 116], 2, 1], "expect": [98]},
  {"name": "zero iterations", "args": [[112], [115], 0, 32], "expectError": "iterations must be a whole number of at least 1"},
  {"name": "a fractional iteration count", "args": [[112], [115], 1.5, 32], "expectError": "iterations must be a whole number of at least 1"},
  {"name": "a zero-length key", "args": [[112], [115], 1, 0], "expectError": "keyLength must be a whole number of at least 1"},
  {"name": "a salt byte above 255", "args": [[112], [300], 1, 32], "expectError": "salt must be a list of integers from 0 to 255"},
  {"name": "a password given as text rather than bytes", "args": [["password"], [115], 1, 32], "expectError": "password must be a list of integers from 0 to 255"}
]