Functional Weave
Code in TypeScript

crypto.hmac-sha1@1.0.0

vectors.json

5,731 bytes · view raw

[
  {"name": "RFC 2202 test case 1: a 20-byte key of 0x0b", "args": [[11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11], [72, 105, 32, 84, 104, 101, 114, 101]], "expect": [182, 23, 49, 134, 85, 5, 114, 100, 226, 139, 192, 182, 251, 55, 140, 142, 241, 70, 190, 0]},
  {"name": "RFC 2202 test case 2: a key shorter than the output", "args": [[74, 101, 102, 101], [119, 104, 97, 116, 32, 100, 111, 32, 121, 97, 32, 119, 97, 110, 116, 32, 102, 111, 114, 32, 110, 111, 116, 104, 105, 110, 103, 63]], "expect": [239, 252, 223, 106, 229, 235, 47, 162, 210, 116, 22, 213, 241, 132, 223, 156, 37, 154, 124, 121]},
  {"name": "RFC 2202 test case 3: 50 bytes of 0xdd under 20 bytes of 0xaa", "args": [[170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170], [221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221]], "expect": [18, 93, 115, 66, 185, 172, 17, 205, 145, 163, 154, 244, 138, 161, 123, 79, 99, 241, 117, 211]},
  {"name": "RFC 2202 test case 4: a 25-byte counting key", "args": [[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], [205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205]], "expect": [76, 144, 7, 244, 2, 98, 80, 198, 188, 132, 20, 249, 191, 80, 200, 108, 45, 114, 53, 218]},
  {"name": "RFC 2202 test case 5: the full tag (the RFC also lists its 96-bit truncation)", "args": [[12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12], [84, 101, 115, 116, 32, 87, 105, 116, 104, 32, 84, 114, 117, 110, 99, 97, 116, 105, 111, 110]], "expect": [76, 26, 3, 66, 75, 85, 224, 127, 231, 242, 123, 225, 213, 139, 185, 50, 74, 154, 90, 4]},
  {"name": "RFC 2202 test case 6: an 80-byte key is hashed first", "args": [[170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170], [84, 101, 115, 116, 32, 85, 115, 105, 110, 103, 32, 76, 97, 114, 103, 101, 114, 32, 84, 104, 97, 110, 32, 66, 108, 111, 99, 107, 45, 83, 105, 122, 101, 32, 75, 101, 121, 32, 45, 32, 72, 97, 115, 104, 32, 75, 101, 121, 32, 70, 105, 114, 115, 116]], "expect": [170, 74, 229, 225, 82, 114, 208, 14, 149, 112, 86, 55, 206, 138, 59, 85, 237, 64, 33, 18]},
  {"name": "RFC 2202 test case 7: an 80-byte key and a 73-byte message", "args": [[170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170], [84, 101, 115, 116, 32, 85, 115, 105, 110, 103, 32, 76, 97, 114, 103, 101, 114, 32, 84, 104, 97, 110, 32, 66, 108, 111, 99, 107, 45, 83, 105, 122, 101, 32, 75, 101, 121, 32, 97, 110, 100, 32, 76, 97, 114, 103, 101, 114, 32, 84, 104, 97, 110, 32, 79, 110, 101, 32, 66, 108, 111, 99, 107, 45, 83, 105, 122, 101, 32, 68, 97, 116, 97]], "expect": [232, 233, 157, 15, 69, 35, 125, 120, 109, 107, 186, 167, 150, 92, 120, 8, 187, 255, 26, 145]},
  {"name": "the empty key and the empty message", "args": [[], []], "expect": [251, 219, 29, 27, 24, 170, 108, 8, 50, 75, 125, 100, 183, 31, 183, 99, 112, 105, 14, 29]},
  {"name": "a key of exactly one block (64 bytes) is used as is, not hashed (Python hmac as the reference)", "args": [[0, 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], [111, 110, 101, 32, 98, 108, 111, 99, 107]], "expect": [84, 136, 177, 216, 225, 14, 125, 188, 45, 185, 27, 231, 129, 163, 1, 21, 146, 226, 88, 166]},
  {"name": "a key one byte over the block is hashed (Python hmac as the reference)", "args": [[0, 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], [111, 110, 101, 32, 98, 108, 111, 99, 107]], "expect": [13, 95, 37, 153, 157, 45, 13, 176, 228, 60, 65, 172, 218, 216, 142, 72, 30, 121, 86, 216]},
  {"name": "RFC 4226 Appendix D: the HOTP secret at counter 0 (its HMAC is published)", "args": [[49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48], [0, 0, 0, 0, 0, 0, 0, 0]], "expect": [204, 147, 207, 24, 80, 141, 148, 147, 76, 100, 182, 93, 139, 167, 102, 127, 183, 205, 228, 176]},
  {"name": "a key byte above 255", "args": [[1, 256], [1]], "expectError": "key must be a list of integers from 0 to 255"},
  {"name": "a fractional message byte", "args": [[1], [0.5]], "expectError": "message must be a list of integers from 0 to 255"},
  {"name": "a message given as text rather than bytes", "args": [[1], "Hi There"], "expectError": "message must be a list of integers from 0 to 255"}
]