Exemple #1
0
 def runTest(self):
     m = GOST341194()
     c = m.copy()
     m.update(b"foobar")
     c.update(b"foo")
     c.update(b"bar")
     self.assertEqual(m.digest(), c.digest())
Exemple #2
0
 def test_50(self):
     self.assertEqual(
         GOST341194(
             b"Suppose the original message has length = 50 bytes",
             "GostR3411_94_CryptoProParamSet",
         ).hexdigest(),
         "c3730c5cbccacf915ac292676f21e8bd4ef75331d9405e5f1a61dc3130a65011",
     )
Exemple #3
0
 def test_32(self):
     self.assertEqual(
         GOST341194(
             b"This is message, length=32 bytes",
             "GostR3411_94_CryptoProParamSet",
         ).hexdigest(),
         "2cefc2f7b7bdc514e18ea57fa74ff357e7fa17d652c75f69cb1be7893ede48eb",
     )
Exemple #4
0
 def test_dog(self):
     self.assertEqual(
         GOST341194(
             b"The quick brown fox jumps over the lazy dog",
             "GostR3411_94_CryptoProParamSet",
         ).hexdigest(),
         "9004294a361a508c586fe53d1f1b02746765e71b765472786e4770d565830a76",
     )
Exemple #5
0
 def test_message_digest(self):
     self.assertEqual(
         GOST341194(
             b"message digest",
             "GostR3411_94_CryptoProParamSet",
         ).hexdigest(),
         "bc6041dd2aa401ebfa6e9886734174febdb4729aa972d60f549ac39b29721ba0",
     )
Exemple #6
0
 def test_dog(self):
     self.assertEqual(
         GOST341194(
             b"The quick brown fox jumps over the lazy dog",
             "GostR3411_94_TestParamSet",
         ).hexdigest(),
         "77b7fa410c9ac58a25f49bca7d0468c9296529315eaca76bd1a10f376d1f4294",
     )
Exemple #7
0
 def test_cog(self):
     self.assertEqual(
         GOST341194(
             b"The quick brown fox jumps over the lazy cog",
             "GostR3411_94_TestParamSet",
         ).hexdigest(),
         "a3ebc4daaab78b0be131dab5737a7f67e602670d543521319150d2e14eeec445",
     )
Exemple #8
0
 def test_rfc50(self):
     self.assertEqual(
         GOST341194(
             b"Suppose the original message has length = 50 bytes",
             "GostR3411_94_TestParamSet",
         ).hexdigest(),
         "471aba57a60a770d3a76130635c1fbea4ef14de51f78b4ae57dd893b62f55208",
     )
Exemple #9
0
 def test_rfc32(self):
     self.assertEqual(
         GOST341194(
             b"This is message, length=32 bytes",
             "GostR3411_94_TestParamSet",
         ).hexdigest(),
         "b1c466d37519b82e8319819ff32595e047a28cb6f83eff1c6916a815a637fffa",
     )
Exemple #10
0
def kek_34102001(curve, prv, pub, ukm):
    """ Key agreement (34.10-2001, 34.11-94)

    :param GOST3410Curve curve: curve to use
    :param long prv: private key
    :param pub: public key
    :type pub: (long, long)
    :param long ukm: user keying material, VKO-factor
    :returns: Key Encryption Key (shared key)
    :rtype: bytes, 32 bytes

    Shared Key Encryption Key computation is based on
    :rfc:`4357` VKO GOST R 34.10-2001 with little-endian
    hash output.
    """
    return GOST341194(
        kek(curve, prv, pub, ukm, mode=2001),
        "id-GostR3411-94-CryptoProParamSet",
    ).digest()
Exemple #11
0
 def test_empty(self):
     self.assertEqual(
         GOST341194(b"", "GostR3411_94_CryptoProParamSet").hexdigest(),
         "981e5f3ca30c841487830f84fb433e13ac1101569b9c13584ac483234cd656c0",
     )
Exemple #12
0
 def test_Us(self):
     self.assertEqual(
         GOST341194(128 * b"U",
                    "GostR3411_94_CryptoProParamSet").hexdigest(),
         "1c4ac7614691bbf427fa2316216be8f10d92edfd37cd1027514c1008f649c4e8",
     )
Exemple #13
0
 def test_Us(self):
     self.assertEqual(
         GOST341194(128 * b"U", "GostR3411_94_TestParamSet").hexdigest(),
         "53a3a3ed25180cef0c1d85a074273e551c25660a87062a52d926a9e8fe5733a4",
     )
Exemple #14
0
 def test_a(self):
     self.assertEqual(
         GOST341194(b"a", "GostR3411_94_CryptoProParamSet").hexdigest(),
         "e74c52dd282183bf37af0079c9f78055715a103f17e3133ceff1aacf2f403011",
     )
Exemple #15
0
 def test_message_digest(self):
     self.assertEqual(
         GOST341194(b"message digest",
                    "GostR3411_94_TestParamSet").hexdigest(),
         "ad4434ecb18f2c99b60cbe59ec3d2469582b65273f48de72db2fde16a4889a4d",
     )
Exemple #16
0
 def test_abc(self):
     self.assertEqual(
         GOST341194(b"abc", "GostR3411_94_TestParamSet").hexdigest(),
         "f3134348c44fb1b2a277729e2285ebb5cb5e0f29c975bc753b70497c06a4d51d",
     )
Exemple #17
0
 def test_a(self):
     self.assertEqual(
         GOST341194(b"a", "GostR3411_94_TestParamSet").hexdigest(),
         "d42c539e367c66e9c88a801f6649349c21871b4344c6a573f849fdce62f314dd",
     )
Exemple #18
0
 def test_empty(self):
     self.assertEqual(
         GOST341194(b"", "GostR3411_94_TestParamSet").hexdigest(),
         "ce85b99cc46752fffee35cab9a7b0278abb4c2d2055cff685af4912c49490f8d",
     )
Exemple #19
0
 def test_abc(self):
     self.assertEqual(
         GOST341194(b"abc", "GostR3411_94_CryptoProParamSet").hexdigest(),
         "b285056dbf18d7392d7677369524dd14747459ed8143997e163b2986f92fd42c",
     )