Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Hold signatures to the length SHA-256 gives
The fake HMAC returned 16 bytes, so the checks signed with signatures
half the real length, and a signature cut short passed. tohex's output
was never pinned either, so dropping its zero padding stayed
consistent with itself and passed.
Diffstat (limited to 'tests/extensions/harness.lua')
| -rw-r--r-- | tests/extensions/harness.lua | 5 |
1 file changed, 4 insertions, 1 deletion
diff --git a/tests/extensions/harness.lua b/tests/extensions/harness.lua index 1a669ff..ead3c97 100644 --- a/tests/extensions/harness.lua +++ b/tests/extensions/harness.lua @@ -311,11 +311,14 @@ function harness.stub_auth_modules() return table.concat(out) end, }) + -- An HMAC-SHA256 is 32 bytes, twice what one fake digest gives, so two + -- of different input are joined to make signatures the real length. preload("openssl.hmac", { new = function(key, algorithm) return { final = function(self, payload) - return fake_digest_bytes(key .. "\1" .. algorithm .. "\1" .. payload) + local text = key .. "\1" .. algorithm .. "\1" .. payload + return fake_digest_bytes(text) .. fake_digest_bytes("\2" .. text) end, } end, |
