Functional Weave
Code in Python

crypto.constant-time-equal@1.0.0

vectors.json

2,079 bytes · view raw

[
  {"name": "two empty byte strings are equal", "args": [[], []], "expect": true},
  {"name": "the same bytes", "args": [[1, 2, 3], [1, 2, 3]], "expect": true},
  {"name": "the same 32-byte HMAC tag (RFC 4231 test case 1)", "args": [[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], [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]], "expect": true},
  {"name": "a tag differing only in its last bit, which an early-exit compare finds last", "args": [[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], [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, 246]], "expect": false},
  {"name": "a tag differing in its first byte", "args": [[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], [48, 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]], "expect": false},
  {"name": "a prefix of the other is not equal", "args": [[1, 2, 3], [1, 2]], "expect": false},
  {"name": "empty against non-empty", "args": [[], [0]], "expect": false},
  {"name": "the same bytes in a different order", "args": [[1, 2], [2, 1]], "expect": false},
  {"name": "zero bytes against no bytes: length counts", "args": [[0, 0], [0]], "expect": false},
  {"name": "a value above 255 in the first argument", "args": [[256], [0]], "expectError": "a must be a list of integers from 0 to 255"},
  {"name": "a fraction in the second argument", "args": [[1], [1.5]], "expectError": "b must be a list of integers from 0 to 255"},
  {"name": "a boolean is not a byte", "args": [[1], [true]], "expectError": "b must be a list of integers from 0 to 255"}
]