]> Cypherpunks.ru repositories - pygost.git/blobdiff - pygost/test_gost3412.py
Download link for 3.7 release
[pygost.git] / pygost / test_gost3412.py
index e7138b3c6aa5dbc2b708eb05149880ba58faaffe..e0b078608884b1e36cf122d550c8e72ecbc25158 100644 (file)
@@ -18,7 +18,8 @@
 from unittest import TestCase
 
 from pygost.gost3412 import C
-from pygost.gost3412 import GOST3412Kuz
+from pygost.gost3412 import GOST3412Kuznechik
+from pygost.gost3412 import GOST3412Magma
 from pygost.gost3412 import L
 from pygost.gost3412 import PI
 from pygost.utils import hexdec
@@ -102,7 +103,7 @@ class KuznechikTest(TestCase):
         self.assertEqual(C[7], hexdec("f6593616e6055689adfba18027aa2a08"))
 
     def test_roundkeys(self):
-        ciph = GOST3412Kuz(self.key)
+        ciph = GOST3412Kuznechik(self.key)
         self.assertEqual(ciph.ks[0], hexdec("8899aabbccddeeff0011223344556677"))
         self.assertEqual(ciph.ks[1], hexdec("fedcba98765432100123456789abcdef"))
         self.assertEqual(ciph.ks[2], hexdec("db31485315694343228d6aef8cc78c44"))
@@ -115,9 +116,23 @@ class KuznechikTest(TestCase):
         self.assertEqual(ciph.ks[9], hexdec("72e9dd7416bcf45b755dbaa88e4a4043"))
 
     def test_encrypt(self):
-        ciph = GOST3412Kuz(self.key)
+        ciph = GOST3412Kuznechik(self.key)
         self.assertEqual(ciph.encrypt(self.plaintext), self.ciphertext)
 
     def test_decrypt(self):
-        ciph = GOST3412Kuz(self.key)
+        ciph = GOST3412Kuznechik(self.key)
+        self.assertEqual(ciph.decrypt(self.ciphertext), self.plaintext)
+
+
+class MagmaTest(TestCase):
+    key = hexdec("ffeeddccbbaa99887766554433221100f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff")
+    plaintext = hexdec("fedcba9876543210")
+    ciphertext = hexdec("4ee901e5c2d8ca3d")
+
+    def test_encrypt(self):
+        ciph = GOST3412Magma(self.key)
+        self.assertEqual(ciph.encrypt(self.plaintext), self.ciphertext)
+
+    def test_decrypt(self):
+        ciph = GOST3412Magma(self.key)
         self.assertEqual(ciph.decrypt(self.ciphertext), self.plaintext)