Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions tests/test_brc105.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ def test_unknown_nonce_rejected(self):

def test_tampered_nonce_rejected(self):
nonce = self.manager.create()
# Flip a byte in the random part
tampered = "ff" + nonce[2:]
# Flip the first byte of the random part. XOR with 0xff guarantees a
# change regardless of the original value — a plain "ff" + nonce[2:]
# would be a no-op (and falsely pass) ~1/256 of the time, when the
# random first byte already happened to be 0xff.
flipped = f"{int(nonce[:2], 16) ^ 0xFF:02x}"
tampered = flipped + nonce[2:]
# Remove from store so we test the HMAC check path
self.manager._nonces[tampered] = self.manager._nonces.pop(nonce)
assert not self.manager.verify(tampered)
Expand Down
Loading