Functional Weave
Code in TypeScript

crypto.hmac-sha256@1.0.0

vectors.json

6,795 bytes · view raw

[
  {"name": "RFC 4231 test case 1: a 20-byte key", "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": [176, 52, 76, 97, 216, 219, 56, 83, 92, 168, 175, 206, 175, 11, 241, 43, 136, 29, 194, 0, 201, 131, 61, 167, 38, 233, 55, 108, 46, 50, 207, 247]},
  {"name": "RFC 4231 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": [91, 220, 193, 70, 191, 96, 117, 78, 106, 4, 36, 38, 8, 149, 117, 199, 90, 0, 63, 8, 157, 39, 57, 131, 157, 236, 88, 185, 100, 236, 56, 67]},
  {"name": "RFC 4231 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": [119, 62, 169, 30, 54, 128, 14, 70, 133, 77, 184, 235, 208, 145, 129, 167, 41, 89, 9, 139, 62, 248, 193, 34, 217, 99, 85, 20, 206, 213, 101, 254]},
  {"name": "RFC 4231 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": [130, 85, 138, 56, 154, 68, 60, 14, 164, 204, 129, 152, 153, 242, 8, 58, 133, 240, 250, 163, 229, 120, 248, 7, 122, 46, 63, 244, 103, 41, 102, 91]},
  {"name": "RFC 4231 test case 5: the full tag, whose first 16 bytes the RFC publishes (a3b61674...)", "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": [163, 182, 22, 116, 115, 16, 14, 224, 110, 12, 121, 108, 41, 85, 85, 43, 250, 111, 124, 10, 106, 138, 239, 139, 147, 248, 96, 170, 176, 205, 32, 197]},
  {"name": "RFC 4231 test case 6: a 131-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, 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": [96, 228, 49, 89, 30, 224, 182, 127, 13, 138, 38, 170, 203, 245, 183, 127, 142, 11, 198, 33, 55, 40, 197, 20, 5, 70, 4, 15, 14, 227, 127, 84]},
  {"name": "RFC 4231 test case 7: a long key and a message longer than a block", "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, 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, 104, 105, 115, 32, 105, 115, 32, 97, 32, 116, 101, 115, 116, 32, 117, 115, 105, 110, 103, 32, 97, 32, 108, 97, 114, 103, 101, 114, 32, 116, 104, 97, 110, 32, 98, 108, 111, 99, 107, 45, 115, 105, 122, 101, 32, 107, 101, 121, 32, 97, 110, 100, 32, 97, 32, 108, 97, 114, 103, 101, 114, 32, 116, 104, 97, 110, 32, 98, 108, 111, 99, 107, 45, 115, 105, 122, 101, 32, 100, 97, 116, 97, 46, 32, 84, 104, 101, 32, 107, 101, 121, 32, 110, 101, 101, 100, 115, 32, 116, 111, 32, 98, 101, 32, 104, 97, 115, 104, 101, 100, 32, 98, 101, 102, 111, 114, 101, 32, 98, 101, 105, 110, 103, 32, 117, 115, 101, 100, 32, 98, 121, 32, 116, 104, 101, 32, 72, 77, 65, 67, 32, 97, 108, 103, 111, 114, 105, 116, 104, 109, 46]], "expect": [155, 9, 255, 167, 27, 148, 47, 203, 39, 99, 95, 188, 213, 176, 233, 68, 191, 220, 99, 100, 79, 7, 19, 147, 138, 127, 81, 83, 92, 58, 53, 226]},
  {"name": "the empty key and the empty message", "args": [[], []], "expect": [182, 19, 103, 154, 8, 20, 217, 236, 119, 47, 149, 215, 120, 195, 95, 197, 255, 22, 151, 196, 147, 113, 86, 83, 198, 199, 18, 20, 66, 146, 197, 173]},
  {"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], [97, 98, 99]], "expect": [106, 181, 65, 180, 134, 157, 202, 113, 196, 202, 17, 216, 187, 27, 2, 83, 59, 120, 154, 85, 117, 131, 22, 20, 41, 41, 44, 116, 4, 188, 33, 246]},
  {"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], [97, 98, 99]], "expect": [223, 191, 254, 228, 103, 27, 173, 0, 237, 93, 30, 25, 153, 213, 94, 211, 176, 204, 119, 74, 195, 87, 249, 235, 246, 73, 193, 97, 36, 20, 252, 236]},
  {"name": "a key byte above 255", "args": [[1, 2, 256], [97]], "expectError": "key must be a list of integers from 0 to 255"},
  {"name": "a fractional message byte", "args": [[1, 2, 3], [97.5]], "expectError": "message must be a list of integers from 0 to 255"},
  {"name": "a message given as text rather than bytes", "args": [[1, 2, 3], ["abc"]], "expectError": "message must be a list of integers from 0 to 255"}
]