def test_padding_message_length_field_2(self): l = 0xFFFF m = b'A' * l new_m = SHA1.pad_message(m) self.assertEqual(m, new_m[:l]) self.assertEqual(struct.unpack('>Q', new_m[-8:])[0], len(m) * 8)
def test_padding_1(self): m = b'abcde' new_m = SHA1.pad_message(m) correct_padded_message = b'abcde\x80' + b'\x00' * 57 + b'\x28' self.assertEqual(m, new_m[:len(m)]) self.assertEqual(new_m, correct_padded_message)
def test_padding_length_2(self): l = 64 m = b'A' * l new_m = SHA1.pad_message(m) self.assertEqual(m, new_m[:l]) self.assertEqual(len(new_m) % 64, 0)