def test_signature(self): key = self.keys random_words = randomword(255) signature = key.sign(random_words) self.assertTrue(key.verify(random_words, signature)) self.assertFalse(key.verify(randomword(255), signature)) self.assertFalse(key.verify(random_words, randomword(255)))
def test_verify_with_other_key(self): key1 = self.keys key2 = generate_keys() random_word = randomword(2 ** 10) signature = key1.sign(random_word) # now verify that key2 does not verify the signature self.assertFalse(key2.verify(random_word, signature))
def test_sign_small_string(self): """ Test that we can sign and verify a small string """ key = self.keys for i in range(1, 11): random_word = randomword(2 ** i) signature = key.sign(random_word) try: self.assertTrue(key.verify(random_word, signature)) except AssertionError: print("Failed to sign string of length {}".format(2 ** i)) raise
def test_long_word(self): rawdata = bytes(randomword(30).encode()) blocks = split(rawdata, 15) self.assertEqual(assemble(blocks), rawdata) self.assertNotEqual(assemble(blocks[:-1]), rawdata)
def test_no_padd(self): rawdata = bytes(randomword(30).encode()) blocks = split(rawdata, 10) self.assertEqual(assemble(blocks), rawdata)
def test_all_word(self): for i in range(1, 2 ** 10): rawdata = bytes(randomword(i).encode()) blocks = split(rawdata, 15) self.assertEqual(assemble(blocks), rawdata)