def test_mac_vectors(self): k1, k2 = _mac_ks(self.ciph.encrypt, 8) self.assertSequenceEqual(hexenc(k1), "5f459b3342521424") self.assertSequenceEqual(hexenc(k2), "be8b366684a42848") self.assertSequenceEqual( hexenc(mac(self.ciph.encrypt, 8, hexdec(self.plaintext))[:4]), "154e7210", )
def test_mac_vectors(self): k1, k2 = _mac_ks(self.ciph.encrypt, 16) self.assertSequenceEqual(hexenc(k1), "297d82bc4d39e3ca0de0573298151dc7") self.assertSequenceEqual(hexenc(k2), "52fb05789a73c7941bc0ae65302a3b8e") self.assertSequenceEqual( hexenc(mac(self.ciph.encrypt, 16, hexdec(self.plaintext))[:8]), "336f4d296059fbe3", )
def mac(self, text): res = gost3413.mac(self.enc, self.blen, text) return res
def test_mac_applies(self): for _ in range(100): data = urandom(randint(0, 16 * 2)) ciph = GOST3412Magma(urandom(32)) mac(ciph.encrypt, 8, data)