mozilla-services / go-cose

go library for CBOR Object Signing and Encryption (COSE)
Mozilla Public License 2.0
40 stars 18 forks source link

Fix tests for tampered sig and modified payload #69

Closed fxamacker closed 4 years ago

fxamacker commented 4 years ago

Two tests used to modify a single byte of signature or payload by XORing it with itself, causing the target byte to be zero.

If the original data in the target byte was already zero, then nothing was changed, causing the test to fail.

Fix this by changing bitwise operation to XOR the target byte with a 1, so the target byte will always change by 1 bit.

Closes #68

g-k commented 4 years ago

Landing this. Tests pass to a branch I pushed https://github.com/mozilla-services/go-cose/compare/fxamacker/bugfix-flakytests?expand=1 (didn't have branch builds from forks enabled in CircleCI so I enabled that but didn't see an easy way to force a rebuild)