def test_const_compare_digest_fallback(self): target = hashlib.sha256(b"abcdef").digest() assert _const_compare_digest_backport(target, target) prefix = target[:-1] assert not _const_compare_digest_backport(target, prefix) suffix = target + b"0" assert not _const_compare_digest_backport(target, suffix) incorrect = hashlib.sha256(b"xyz").digest() assert not _const_compare_digest_backport(target, incorrect)
def test_const_compare_digest_fallback(self): target = hashlib.sha256(b'abcdef').digest() self.assertTrue(_const_compare_digest_backport(target, target)) prefix = target[:-1] self.assertFalse(_const_compare_digest_backport(target, prefix)) suffix = target + b'0' self.assertFalse(_const_compare_digest_backport(target, suffix)) incorrect = hashlib.sha256(b'xyz').digest() self.assertFalse(_const_compare_digest_backport(target, incorrect))
def test_const_compare_digest_fallback(self): target = hashlib.sha256(b'abcdef').digest() assert _const_compare_digest_backport(target, target) prefix = target[:-1] assert not _const_compare_digest_backport(target, prefix) suffix = target + b'0' assert not _const_compare_digest_backport(target, suffix) incorrect = hashlib.sha256(b'xyz').digest() assert not _const_compare_digest_backport(target, incorrect)
def test_const_compare_digest_fallback(self): target = hashlib.sha256(b'abcdef').digest() self.assertTrue(_const_compare_digest_backport(target, target)) prefix = target[:-1] self.assertFalse(_const_compare_digest_backport(target, prefix)) suffix = target + b'0' self.assertFalse(_const_compare_digest_backport(target, suffix)) incorrect = hashlib.sha256(b'xyz').digest() self.assertFalse(_const_compare_digest_backport(target, incorrect))