Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Security.Cryptography.Tests;
using Xunit;

namespace System.Security.Cryptography.EcDiffieHellman.Tests
{
[SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
public static class ECDiffieHellmanFactoryTests
{
[Fact]
public static void ECDiffieHellmanCreateDefault_Equals_SameInstance()
{
using ECDiffieHellman ecdh = ECDiffieHellmanFactory.Create();
AssertExtensions.TrueExpression(ecdh.Equals(ecdh));
}

[Fact]
public static void ECDiffieHellmanCreateKeySize_Equals_SameInstance()
{
using ECDiffieHellman ecdh = ECDiffieHellmanFactory.Create(256);
AssertExtensions.TrueExpression(ecdh.Equals(ecdh));
}

[Fact]
public static void ECDiffieHellmanCreateKeySize_Equals_DifferentInstance_FalseForSameKeyMaterial()
{
using ECDiffieHellman ecdh1 = ECDiffieHellmanFactory.Create();
using ECDiffieHellman ecdh2 = ECDiffieHellmanFactory.Create();
ecdh1.ImportParameters(EccTestData.GetNistP256ReferenceKey());
ecdh2.ImportParameters(EccTestData.GetNistP256ReferenceKey());
AssertExtensions.FalseExpression(ecdh1.Equals(ecdh2));
}

#if NET
[Fact]
public static void ECDiffieHellmanCreateCurve_Equals_SameInstance()
{
using ECDiffieHellman ecdh = ECDiffieHellmanFactory.Create(ECCurve.NamedCurves.nistP256);
AssertExtensions.TrueExpression(ecdh.Equals(ecdh));
}
#endif
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Security.Cryptography.Tests;
using Xunit;

namespace System.Security.Cryptography.EcDsa.Tests
{
[SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
public static class ECDsaFactoryTests
{
[Fact]
public static void ECDsaCreateDefault_Equals_SameInstance()
{
using ECDsa ecdsa = ECDsaFactory.Create();
AssertExtensions.TrueExpression(ecdsa.Equals(ecdsa));
}

[Fact]
public static void ECDsaCreateKeySize_Equals_SameInstance()
{
using ECDsa ecdsa = ECDsaFactory.Create(256);
AssertExtensions.TrueExpression(ecdsa.Equals(ecdsa));
}

[Fact]
public static void ECDsaCreateKeySize_Equals_DifferentInstance_FalseForSameKeyMaterial()
{
using ECDsa ecdsa1 = ECDsaFactory.Create();
using ECDsa ecdsa2 = ECDsaFactory.Create();
ecdsa1.ImportParameters(EccTestData.GetNistP256ReferenceKey());
ecdsa2.ImportParameters(EccTestData.GetNistP256ReferenceKey());
AssertExtensions.FalseExpression(ecdsa1.Equals(ecdsa2));
}

#if NET
[Fact]
public static void ECDsaCreateCurve_Equals_SameInstance()
{
using ECDsa ecdsa = ECDsaFactory.Create(ECCurve.NamedCurves.nistP256);
AssertExtensions.TrueExpression(ecdsa.Equals(ecdsa));
}
#endif
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Xunit;

namespace System.Security.Cryptography.Rsa.Tests
{
[SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
public static class RSAFactoryTests
{
[Fact]
public static void RSACreateDefault_Equals_SameInstance()
{
using RSA rsa = RSAFactory.Create();
AssertExtensions.TrueExpression(rsa.Equals(rsa));
}

[Fact]
public static void RSACreateKeySize_Equals_SameInstance()
{
using RSA rsa = RSAFactory.Create(2048);
AssertExtensions.TrueExpression(rsa.Equals(rsa));
}

[Fact]
public static void RSACreateParameters_Equals_SameInstance()
{
using RSA rsa = RSAFactory.Create(TestData.RSA2048Params);
AssertExtensions.TrueExpression(rsa.Equals(rsa));
}

[Fact]
public static void RSACreateParameters_Equals_DifferentInstance_FalseForSameKeyMaterial()
{
using RSA rsa1 = RSAFactory.Create(TestData.RSA2048Params);
using RSA rsa2 = RSAFactory.Create(TestData.RSA2048Params);
AssertExtensions.FalseExpression(rsa1.Equals(rsa2));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
<Compile Include="ECDiffieHellmanCngProvider.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\ECDiffieHellman\ECDiffieHellmanFactory.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\ECDiffieHellman\ECDiffieHellmanFactory.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\ECDiffieHellman\ECDiffieHellmanFactoryTests.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\ECDiffieHellman\ECDiffieHellmanFactoryTests.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\ByteUtils.cs"
Link="CommonTest\System\Security\Cryptography\ByteUtils.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\CngKeyWrapper.cs"
Expand All @@ -54,6 +56,8 @@
<Compile Include="ECDsaCngProvider.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\ECDsa\ECDsaFactory.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\ECDsa\ECDsaFactory.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\ECDsa\ECDsaFactoryTests.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\ECDsa\ECDsaFactoryTests.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\ECDsa\ECDsaImportExport.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\ECDsa\ECDsaImportExport.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\ECDsa\ECDsaStub.cs"
Expand All @@ -73,6 +77,8 @@
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\RSA\KeyGeneration.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\RSA\RSAFactory.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\RSA\RSAFactory.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\RSA\RSAFactoryTests.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\RSA\RSAFactoryTests.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\RSA\RSATestHelpers.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\RSA\RSATestHelpers.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\RSA\SignVerify.cs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\RSA\KeyGeneration.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\RSA\RSAFactory.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\RSA\RSAFactory.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\RSA\RSAFactoryTests.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\RSA\RSAFactoryTests.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\RSA\RSATestHelpers.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\RSA\RSATestHelpers.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\RSA\SignVerify.cs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\EC\EccTestData.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\ECDiffieHellman\ECDiffieHellmanFactory.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\ECDiffieHellman\ECDiffieHellmanFactory.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\ECDiffieHellman\ECDiffieHellmanFactoryTests.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\ECDiffieHellman\ECDiffieHellmanFactoryTests.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\ECDiffieHellman\ECDiffieHellmanTests.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\ECDiffieHellman\ECDiffieHellmanTests.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\ECDiffieHellman\ECDiffieHellmanTests.Hash.cs"
Expand All @@ -46,6 +48,8 @@
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\ECDiffieHellman\ECDiffieHellmanTests.Xml.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\ECDsa\ECDsaFactory.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\ECDsa\ECDsaFactory.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\ECDsa\ECDsaFactoryTests.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\ECDsa\ECDsaFactoryTests.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\ECDsa\ECDsaImportExport.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\ECDsa\ECDsaImportExport.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\ECDsa\ECDsaSignatureFormatTests.cs"
Expand All @@ -66,6 +70,8 @@
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\RSA\KeyGeneration.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\RSA\RSAFactory.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\RSA\RSAFactory.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\RSA\RSAFactoryTests.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\RSA\RSAFactoryTests.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\RSA\RSATestHelpers.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\RSA\RSATestHelpers.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\RSA\SignVerify.cs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ public override byte[] ExportEncryptedPkcs8PrivateKey(

public override byte[] ExportSubjectPublicKeyInfo() => _wrapped.ExportSubjectPublicKeyInfo();

public override bool Equals(object? obj) => _wrapped.Equals(obj);

public override int GetHashCode() => _wrapped.GetHashCode();

public override string ToString() => _wrapped.ToString()!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,6 @@ public override bool TrySignHash(ReadOnlySpan<byte> hash, Span<byte> destination
public override bool VerifyHash(ReadOnlySpan<byte> hash, ReadOnlySpan<byte> signature) =>
_wrapped.VerifyHash(hash, signature);

public override bool Equals(object? obj) => _wrapped.Equals(obj);

public override int GetHashCode() => _wrapped.GetHashCode();

public override string ToString() => _wrapped.ToString()!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,6 @@ protected override void Dispose(bool disposing)
base.Dispose(disposing);
}

public override bool Equals(object? obj) => _wrapped.Equals(obj);

public override int GetHashCode() => _wrapped.GetHashCode();

public override string ToString() => _wrapped.ToString()!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\ECDiffieHellman\ECDiffieHellmanKeyPemTests.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\ECDiffieHellman\ECDiffieHellmanFactory.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\ECDiffieHellman\ECDiffieHellmanFactory.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\ECDiffieHellman\ECDiffieHellmanFactoryTests.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\ECDiffieHellman\ECDiffieHellmanFactoryTests.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\ECDiffieHellman\ECDiffieHellmanTests.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\ECDiffieHellman\ECDiffieHellmanTests.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\ECDiffieHellman\ECDiffieHellmanTests.Hash.cs"
Expand All @@ -357,6 +359,8 @@
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\ECDiffieHellman\ECDiffieHellmanTests.Xml.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\ECDsa\ECDsaFactory.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\ECDsa\ECDsaFactory.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\ECDsa\ECDsaFactoryTests.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\ECDsa\ECDsaFactoryTests.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\ECDsa\ECDsaImportExport.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\ECDsa\ECDsaImportExport.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\ECDsa\ECDsaKeyFileTests.cs"
Expand Down Expand Up @@ -413,6 +417,8 @@
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\RSA\KeyGeneration.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\RSA\RSAFactory.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\RSA\RSAFactory.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\RSA\RSAFactoryTests.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\RSA\RSAFactoryTests.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\RSA\RSAKeyExchangeFormatter.cs"
Link="CommonTest\System\Security\Cryptography\AlgorithmImplementations\RSA\RSAKeyExchangeFormatter.cs" />
<Compile Include="$(CommonTestPath)System\Security\Cryptography\AlgorithmImplementations\RSA\RSAKeyFileTests.cs"
Expand Down
Loading