public void ShouldDeriveKey(ProviderType providerType) { // TODO: VipNet does not support this feature - https://infotecs.ru/forum/topic/10142-oshibka-pri-sozdanii-klyucha-shifrovaniya-na-osnove-dannyih-polzovatelya-cryptderivekey/ if (providerType.IsVipNet()) { Assert.Ignore("VipNet does not support this feature"); } // Given var initKey = new Gost_28147_89_SymmetricAlgorithm(providerType); // When Gost_28147_89_SymmetricAlgorithmBase randomKey1; Gost_28147_89_SymmetricAlgorithmBase randomKey2; Gost_28147_89_SymmetricAlgorithmBase randomKey3; using (var prf = new Gost_R3411_2012_512_PRF(initKey, Label, Seed)) { randomKey1 = prf.DeriveKey(); randomKey2 = prf.DeriveKey(); randomKey3 = prf.DeriveKey(); } // Then Assert.IsNotNull(randomKey1); Assert.IsNotNull(randomKey2); Assert.IsNotNull(randomKey3); AssertKeyIsValid(randomKey1); AssertKeyIsValid(randomKey2); AssertKeyIsValid(randomKey3); AssertKeysAreNotEqual(randomKey1, randomKey2); AssertKeysAreNotEqual(randomKey1, randomKey3); AssertKeysAreNotEqual(randomKey2, randomKey3); }
public void ShouldDeriveBytes(ProviderType providerType) { // Given var initKey = new Gost_28147_89_SymmetricAlgorithm(providerType); // When byte[] randomBytes1; byte[] randomBytes2; byte[] randomBytes3; using (var prf = new Gost_R3411_2012_512_PRF(initKey, Label, Seed)) { randomBytes1 = prf.DeriveBytes(); randomBytes2 = prf.DeriveBytes(); randomBytes3 = prf.DeriveBytes(); } // Then Assert.IsNotNull(randomBytes1); Assert.IsNotNull(randomBytes2); Assert.IsNotNull(randomBytes3); Assert.AreEqual(512, 8 * randomBytes1.Length); Assert.AreEqual(512, 8 * randomBytes2.Length); Assert.AreEqual(512, 8 * randomBytes3.Length); CollectionAssert.AreNotEqual(randomBytes1, randomBytes2); CollectionAssert.AreNotEqual(randomBytes1, randomBytes3); CollectionAssert.AreNotEqual(randomBytes2, randomBytes3); }