]> Cypherpunks.ru repositories - pygost.git/blobdiff - pygost/test_cms.py
Unused variable
[pygost.git] / pygost / test_cms.py
index da6c8596bd95005f305b9fc102740059004d6027..68354bef2a5cede09201c0153f4fb06b87982deb 100644 (file)
@@ -1,6 +1,6 @@
 # coding: utf-8
 # PyGOST -- Pure Python GOST cryptographic functions library
-# Copyright (C) 2015-2018 Sergey Matveev <stargrave@stargrave.org>
+# Copyright (C) 2015-2019 Sergey Matveev <stargrave@stargrave.org>
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -20,8 +20,7 @@ from unittest import skipIf
 from unittest import TestCase
 
 from pygost.gost28147 import cfb_decrypt
-from pygost.gost3410 import CURVE_PARAMS
-from pygost.gost3410 import GOST3410Curve
+from pygost.gost3410 import CURVES
 from pygost.gost3410 import prv_unmarshal
 from pygost.gost3410 import pub_unmarshal
 from pygost.gost3410 import public_key
@@ -68,7 +67,7 @@ class TestSigned(TestCase):
         self.assertIsNotNone(content_info["content"].defined)
         _, signed_data = content_info["content"].defined
         self.assertEqual(len(signed_data["signerInfos"]), 1)
-        curve = GOST3410Curve(*CURVE_PARAMS[curve_name])
+        curve = CURVES[curve_name]
         self.assertTrue(verify(
             curve,
             public_key(curve, prv_unmarshal(prv_key_raw)),
@@ -90,7 +89,7 @@ VNwDQ8enFItJZ8DEX4blZ8QtziNCMl5HbA==
         self.process_cms(
             content_info_raw,
             prv_key_raw,
-            "GostR3410_2001_CryptoPro_XchA_ParamSet",
+            "id-GostR3410-2001-CryptoPro-XchA-ParamSet",
             GOST34112012256,
             2001,
         )
@@ -109,7 +108,7 @@ PS+KRYxT8vhcsBLWWxDkc1McI7aF09hqtED36mQOfACzeJjEoUjALpmJob1V
         self.process_cms(
             content_info_raw,
             prv_key_raw,
-            "GostR3410_2012_TC26_ParamSetB",
+            "id-tc26-gost-3410-12-512-paramSetB",
             GOST34112012512,
             2012,
         )
@@ -166,7 +165,7 @@ class TestEnvelopedKTRI(TestCase):
             keker,
             plaintext_expected,
     ):
-        sbox = "Gost28147_tc26_ParamZ"
+        sbox = "id-tc26-gost-28147-param-Z"
         content_info, tail = ContentInfo().decode(content_info_raw, ctx={
             "defines_by_path": [
                 (
@@ -209,7 +208,7 @@ class TestEnvelopedKTRI(TestCase):
         spk = encrypted_key["transportParameters"]["ephemeralPublicKey"]["subjectPublicKey"]
         self.assertIsNotNone(spk.defined)
         _, pub_key_their = spk.defined
-        curve = GOST3410Curve(*CURVE_PARAMS[curve_name])
+        curve = CURVES[curve_name]
         kek = keker(curve, prv_key_our, bytes(pub_key_their), ukm)
         key_wrapped = bytes(encrypted_key["sessionEncryptedKey"]["encryptedKey"])
         mac = bytes(encrypted_key["sessionEncryptedKey"]["macKey"])
@@ -294,7 +293,7 @@ pRmMVN+YtRsrEHwH3ToQ/i4vrtgA+eONuKT2uKZFikxA+VNmeeGdhkgqETMihQ==
         self.process_cms(
             content_info_raw,
             prv_key_our,
-            "GostR3410_2001_CryptoPro_XchA_ParamSet",
+            "id-GostR3410-2001-CryptoPro-XchA-ParamSet",
             keker,
             b"Test data to encrypt.\n" * 100,
         )
@@ -325,7 +324,7 @@ FTAVBAj+1QzaXaN9FwYJKoUDBwECBQEBgAyK54euw0sHhEVEkA0=
         self.process_cms(
             content_info_raw,
             prv_key_our,
-            "GostR3410_2012_TC26_ParamSetB",
+            "id-tc26-gost-3410-12-512-paramSetB",
             keker,
             b"Test message",
         )
@@ -346,7 +345,7 @@ class TestEnvelopedKARI(TestCase):
             keker,
             plaintext_expected,
     ):
-        sbox = "Gost28147_tc26_ParamZ"
+        sbox = "id-tc26-gost-28147-param-Z"
         content_info, tail = ContentInfo().decode(content_info_raw, ctx={
             "defines_by_path": [
                 (
@@ -370,7 +369,7 @@ class TestEnvelopedKARI(TestCase):
                             },
                         ),
                     ),
-                ) for spki_algorithm in (
+                ) for _ in (
                     id_tc26_gost3410_2012_256,
                     id_tc26_gost3410_2012_512,
                 )
@@ -385,7 +384,7 @@ class TestEnvelopedKARI(TestCase):
         _, pub_key_their = kari["originator"]["originatorKey"]["publicKey"].defined
         ukm = bytes(kari["ukm"])
         rek = kari["recipientEncryptedKeys"][0]
-        curve = GOST3410Curve(*CURVE_PARAMS[curve_name])
+        curve = CURVES[curve_name]
         kek = keker(curve, prv_key_our, bytes(pub_key_their), ukm)
         self.assertIsNotNone(rek["encryptedKey"].defined)
         _, encrypted_key = rek["encryptedKey"].defined
@@ -427,7 +426,7 @@ UNjyuY+54uVcHw==
         self.process_cms(
             content_info_raw,
             prv_key_our,
-            "GostR3410_2001_CryptoPro_XchA_ParamSet",
+            "id-GostR3410-2001-CryptoPro-XchA-ParamSet",
             keker,
             b"Test message",
         )
@@ -458,7 +457,7 @@ WFUZEnEuAKcuG6dTOawEBLhi9hIwOgYJKoZIhvcNAQcBMB8GBiqFAwICFTAVBAiD
         self.process_cms(
             content_info_raw,
             prv_key_our,
-            "GostR3410_2012_TC26_ParamSetB",
+            "id-tc26-gost-3410-12-512-paramSetB",
             keker,
             b"Test message",
         )