X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=pygost%2Ftest_cms.py;h=68354bef2a5cede09201c0153f4fb06b87982deb;hb=f27d16a7447f7823cc3ffd75e43c1f1ec517c1ec;hp=a6f1ae6fd5c985c381249bb1c8ce4955bd19f1be;hpb=21a30721c31912c296e1faced73e2fd0db191be9;p=pygost.git diff --git a/pygost/test_cms.py b/pygost/test_cms.py index a6f1ae6..68354be 100644 --- a/pygost/test_cms.py +++ b/pygost/test_cms.py @@ -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", )