public static void GetECDiffieHellmanPublicKey_ThrowsForCorruptKey() { AsnEncodedData badData = new AsnEncodedData(new byte[] { 1, 2, 3, 4 }); PublicKey key = new PublicKey(GetTestECDHKey().Oid, badData, badData); Assert.ThrowsAny <CryptographicException>(() => key.GetECDiffieHellmanPublicKey()); }
public static void GetPublicKey_NullForDifferentAlgorithm() { byte[] spki = TestData.GostR3410SubjectPublicKeyInfo; PublicKey key = PublicKey.CreateFromSubjectPublicKeyInfo(spki, out _); Assert.Null(key.GetRSAPublicKey()); Assert.Null(key.GetECDsaPublicKey()); Assert.Null(key.GetECDiffieHellmanPublicKey()); }
public static void GetECDiffieHellmanPublicKey_ReturnsECDHKey() { PublicKey key = GetTestECDHKey(); using (ECDiffieHellman ecdh = key.GetECDiffieHellmanPublicKey()) { Assert.NotNull(ecdh); Assert.Equal(ecdh.ExportSubjectPublicKeyInfo(), key.ExportSubjectPublicKeyInfo()); } }