зеркало из https://github.com/mono/mono-tls.git
Renamed.
This commit is contained in:
Родитель
71362b8aca
Коммит
ba3428f11f
|
@ -308,17 +308,17 @@ namespace Mono.Security.NewTls.Console
|
|||
|
||||
#region ICryptoProvider implementation
|
||||
|
||||
public bool IsSupported (CryptoProviderType type)
|
||||
public bool IsSupported (CryptoTestHostType type)
|
||||
{
|
||||
if (type == CryptoProviderType.Mono)
|
||||
if (type == CryptoTestHostType.Mono)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public ICryptoTestProvider GetProvider (CryptoProviderType type)
|
||||
public ICryptoTestHost GetCryptoTestHost (CryptoTestHostType type)
|
||||
{
|
||||
switch (type) {
|
||||
case CryptoProviderType.Mono:
|
||||
case CryptoTestHostType.Mono:
|
||||
return new MonoCryptoProvider ();
|
||||
|
||||
default:
|
||||
|
|
|
@ -10,10 +10,10 @@ namespace Mono.Security.Instrumentation.Console
|
|||
|
||||
public class CryptoTestFactory : ITestParameterProvider
|
||||
{
|
||||
IList<ICryptoTestProvider> providers;
|
||||
IList<ICryptoTestHost> providers;
|
||||
|
||||
public Type Type {
|
||||
get { return typeof(ICryptoTestProvider); }
|
||||
get { return typeof(ICryptoTestHost); }
|
||||
}
|
||||
|
||||
public string Name {
|
||||
|
@ -26,7 +26,7 @@ namespace Mono.Security.Instrumentation.Console
|
|||
|
||||
public CryptoTestFactory (params string[] names)
|
||||
{
|
||||
providers = new List<ICryptoTestProvider> ();
|
||||
providers = new List<ICryptoTestHost> ();
|
||||
if (names != null && names.Length > 0) {
|
||||
foreach (var name in names) {
|
||||
providers.Add (GetProvider (name));
|
||||
|
@ -37,7 +37,7 @@ namespace Mono.Security.Instrumentation.Console
|
|||
}
|
||||
}
|
||||
|
||||
static ICryptoTestProvider GetProvider (string name)
|
||||
static ICryptoTestHost GetProvider (string name)
|
||||
{
|
||||
if (name == "mono")
|
||||
return new MonoCryptoTest ();
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Mono.Security.Instrumentation.Console
|
|||
{
|
||||
using Framework;
|
||||
|
||||
public class MonoCryptoTest : ICryptoTestProvider
|
||||
public class MonoCryptoTest : ICryptoTestHost
|
||||
{
|
||||
System.Threading.Tasks.Task Xamarin.AsyncTests.ITestInstance.Initialize (Xamarin.AsyncTests.TestContext ctx, System.Threading.CancellationToken cancellationToken)
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ namespace Mono.Security.Instrumentation.Console
|
|||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
byte[] ICryptoTestProvider.GetRandomBytes (int count)
|
||||
byte[] ICryptoTestHost.GetRandomBytes (int count)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Mono.Security.Instrumentation.Console
|
|||
{
|
||||
using Framework;
|
||||
|
||||
public class NativeCryptoTest : ICryptoTestProvider
|
||||
public class NativeCryptoTest : ICryptoTestHost
|
||||
{
|
||||
System.Threading.Tasks.Task Xamarin.AsyncTests.ITestInstance.Initialize (Xamarin.AsyncTests.TestContext ctx, System.Threading.CancellationToken cancellationToken)
|
||||
{
|
||||
|
@ -37,7 +37,7 @@ namespace Mono.Security.Instrumentation.Console
|
|||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
byte[] ICryptoTestProvider.GetRandomBytes (int count)
|
||||
byte[] ICryptoTestHost.GetRandomBytes (int count)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Mono.Security.Instrumentation.Tests
|
|||
using Framework;
|
||||
|
||||
[Explicit]
|
||||
[ParameterizedTestFixture (typeof (ICryptoTestProvider))]
|
||||
[ParameterizedTestFixture (typeof (ICryptoTestHost))]
|
||||
public abstract class CipherTest
|
||||
{
|
||||
public TestConfiguration Configuration {
|
||||
|
@ -22,7 +22,7 @@ namespace Mono.Security.Instrumentation.Tests
|
|||
private set;
|
||||
}
|
||||
|
||||
public ICryptoTestProvider Provider {
|
||||
public ICryptoTestHost Provider {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ namespace Mono.Security.Instrumentation.Tests
|
|||
}
|
||||
}
|
||||
|
||||
public CipherTest (TestConfiguration config, ICryptoTestProvider provider)
|
||||
public CipherTest (TestConfiguration config, ICryptoTestHost provider)
|
||||
{
|
||||
Configuration = config;
|
||||
Provider = provider;
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Mono.Security.Instrumentation.Tests
|
|||
using Framework;
|
||||
|
||||
[Category ("Crypto")]
|
||||
[ParameterizedTestFixture (typeof (ICryptoTestProvider))]
|
||||
[ParameterizedTestFixture (typeof (ICryptoTestHost))]
|
||||
public class CryptoTest
|
||||
{
|
||||
public TestConfiguration Configuration {
|
||||
|
@ -18,12 +18,12 @@ namespace Mono.Security.Instrumentation.Tests
|
|||
private set;
|
||||
}
|
||||
|
||||
public ICryptoTestProvider Provider {
|
||||
public ICryptoTestHost Provider {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public CryptoTest (TestConfiguration config, ICryptoTestProvider provider)
|
||||
public CryptoTest (TestConfiguration config, ICryptoTestHost provider)
|
||||
{
|
||||
Configuration = config;
|
||||
Provider = provider;
|
||||
|
@ -170,7 +170,7 @@ namespace Mono.Security.Instrumentation.Tests
|
|||
};
|
||||
|
||||
// Call this function to randomly generate these byte arrays.
|
||||
public static void Generate (ICryptoTestProvider provider)
|
||||
public static void Generate (ICryptoTestHost provider)
|
||||
{
|
||||
var rng = RandomNumberGenerator.Create ();
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace Mono.Security.Instrumentation.Tests
|
|||
Context.InitializeCBC (CipherSuiteCode.TLS_RSA_WITH_AES_128_CBC_SHA, GetField (TestKeyName), GetField (TestMacName), GetField (TestIvName));
|
||||
}
|
||||
|
||||
public TestCbcBlockCipher (TestConfiguration config, ICryptoTestProvider provider)
|
||||
public TestCbcBlockCipher (TestConfiguration config, ICryptoTestHost provider)
|
||||
: base (config, provider)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace Mono.Security.Instrumentation.Tests
|
|||
GetField (ImplicitNonce), GetField (ExplicitNonce));
|
||||
}
|
||||
|
||||
public TestGaloisCounterCipher (TestConfiguration config, ICryptoTestProvider provider)
|
||||
public TestGaloisCounterCipher (TestConfiguration config, ICryptoTestHost provider)
|
||||
: base (config, provider)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ using System;
|
|||
|
||||
namespace Mono.Security.NewTls.TestFramework
|
||||
{
|
||||
public enum CryptoProviderType
|
||||
public enum CryptoTestHostType
|
||||
{
|
||||
Mono,
|
||||
OpenSsl
|
|
@ -29,9 +29,9 @@ namespace Mono.Security.NewTls.TestFramework
|
|||
{
|
||||
public interface ICryptoProvider
|
||||
{
|
||||
bool IsSupported (CryptoProviderType type);
|
||||
bool IsSupported (CryptoTestHostType type);
|
||||
|
||||
ICryptoTestProvider GetProvider (CryptoProviderType type);
|
||||
ICryptoTestHost GetCryptoTestHost (CryptoTestHostType type);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ using Xamarin.AsyncTests;
|
|||
|
||||
namespace Mono.Security.NewTls.TestFramework
|
||||
{
|
||||
public interface ICryptoTestProvider : ITestInstance
|
||||
public interface ICryptoTestHost : ITestInstance
|
||||
{
|
||||
byte[] GetRandomBytes (int count);
|
||||
|
|
@ -34,7 +34,6 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ICryptoTestContext.cs" />
|
||||
<Compile Include="ICryptoTestProvider.cs" />
|
||||
<Compile Include="ILineBasedStream.cs" />
|
||||
<Compile Include="StreamWrapper.cs" />
|
||||
<Compile Include="ICertificate.cs" />
|
||||
|
@ -61,8 +60,9 @@
|
|||
<Compile Include="ConnectionHandlerFactory.cs" />
|
||||
<Compile Include="ConnectionException.cs" />
|
||||
<Compile Include="DependencyInjector.cs" />
|
||||
<Compile Include="CryptoProviderType.cs" />
|
||||
<Compile Include="ICryptoProvider.cs" />
|
||||
<Compile Include="ICryptoTestHost.cs" />
|
||||
<Compile Include="CryptoTestHostType.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
||||
<ProjectExtensions>
|
||||
|
|
|
@ -42,7 +42,7 @@ using Xamarin.AsyncTests;
|
|||
|
||||
namespace Mono.Security.NewTls.TestProvider
|
||||
{
|
||||
public class MonoCryptoProvider : ICryptoTestProvider
|
||||
public class MonoCryptoProvider : ICryptoTestHost
|
||||
{
|
||||
RandomNumberGenerator rng = RandomNumberGenerator.Create ();
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace Mono.Security.NewTls.Tests
|
|||
static bool IsOpenSslSupported ()
|
||||
{
|
||||
var provider = DependencyInjector.Get<ICryptoProvider> ();
|
||||
return provider.IsSupported (CryptoProviderType.OpenSsl);
|
||||
return provider.IsSupported (CryptoTestHostType.OpenSsl);
|
||||
}
|
||||
|
||||
static NewTlsTestFeatures ()
|
||||
|
@ -91,27 +91,27 @@ namespace Mono.Security.NewTls.Tests
|
|||
}
|
||||
|
||||
[AttributeUsage (AttributeTargets.Parameter | AttributeTargets.Property, AllowMultiple = false)]
|
||||
public class SelectCryptoProvider : TestParameterAttribute, ITestParameterSource<CryptoProviderType>
|
||||
public class SelectCryptoProvider : TestParameterAttribute, ITestParameterSource<CryptoTestHostType>
|
||||
{
|
||||
public SelectCryptoProvider (string filter = null, TestFlags flags = TestFlags.Hidden)
|
||||
: base (filter, flags)
|
||||
{
|
||||
}
|
||||
|
||||
public IEnumerable<CryptoProviderType> GetParameters (TestContext ctx, string filter)
|
||||
public IEnumerable<CryptoTestHostType> GetParameters (TestContext ctx, string filter)
|
||||
{
|
||||
if (filter != null) {
|
||||
if (filter.Equals ("mono"))
|
||||
yield return CryptoProviderType.Mono;
|
||||
yield return CryptoTestHostType.Mono;
|
||||
else if (filter.Equals ("openssl"))
|
||||
yield return CryptoProviderType.OpenSsl;
|
||||
yield return CryptoTestHostType.OpenSsl;
|
||||
yield break;
|
||||
}
|
||||
|
||||
if (ctx.IsEnabled (MonoCryptoProvider))
|
||||
yield return CryptoProviderType.Mono;
|
||||
yield return CryptoTestHostType.Mono;
|
||||
if (ctx.IsEnabled (OpenSslCryptoProvider))
|
||||
yield return CryptoProviderType.OpenSsl;
|
||||
yield return CryptoTestHostType.OpenSsl;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,16 +32,16 @@ namespace Mono.Security.NewTls.Tests
|
|||
using TestFramework;
|
||||
|
||||
[AsyncTestFixture]
|
||||
public class SimpleCryptoTest : ITestHost<ICryptoTestProvider>
|
||||
public class SimpleCryptoTest : ITestHost<ICryptoTestHost>
|
||||
{
|
||||
public ICryptoTestProvider CreateInstance (TestContext context)
|
||||
public ICryptoTestHost CreateInstance (TestContext context)
|
||||
{
|
||||
var provider = DependencyInjector.Get<ICryptoProvider> ();
|
||||
return provider.GetProvider (ProviderType);
|
||||
return provider.GetCryptoTestHost (ProviderType);
|
||||
}
|
||||
|
||||
[NewTlsTestFeatures.SelectCryptoProvider]
|
||||
public CryptoProviderType ProviderType {
|
||||
public CryptoTestHostType ProviderType {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ namespace Mono.Security.NewTls.Tests
|
|||
};
|
||||
|
||||
// Call this function to randomly generate these byte arrays.
|
||||
public static void Generate (ICryptoTestProvider provider)
|
||||
public static void Generate (ICryptoTestHost provider)
|
||||
{
|
||||
var seed1 = "master secret";
|
||||
DebugHelper.WriteCSharp ("TestSeed1", seed1);
|
||||
|
@ -253,49 +253,49 @@ namespace Mono.Security.NewTls.Tests
|
|||
#endregion
|
||||
|
||||
[AsyncTest]
|
||||
public void TestMasterSecret_Sha256 (TestContext ctx, [TestHost] ICryptoTestProvider provider)
|
||||
public void TestMasterSecret_Sha256 (TestContext ctx, [TestHost] ICryptoTestHost provider)
|
||||
{
|
||||
var output = provider.TestPRF (HandshakeHashType.SHA256, TestSecret1, TestSeed1, TestData1, PRF1.Length);
|
||||
ctx.Assert (output, Is.EqualTo (PRF1));
|
||||
}
|
||||
|
||||
[AsyncTest]
|
||||
public void TestKeyExpansion_Sha256 (TestContext ctx, [TestHost] ICryptoTestProvider provider)
|
||||
public void TestKeyExpansion_Sha256 (TestContext ctx, [TestHost] ICryptoTestHost provider)
|
||||
{
|
||||
var output = provider.TestPRF (HandshakeHashType.SHA256, TestSecret2, TestSeed2, TestData2, KeyExpansion2.Length);
|
||||
ctx.Assert (output, Is.EqualTo (KeyExpansion2));
|
||||
}
|
||||
|
||||
[AsyncTest]
|
||||
public void TestDigest_Sha256 (TestContext ctx, [TestHost] ICryptoTestProvider provider)
|
||||
public void TestDigest_Sha256 (TestContext ctx, [TestHost] ICryptoTestHost provider)
|
||||
{
|
||||
var output = provider.TestDigest (HandshakeHashType.SHA256, TestData4);
|
||||
ctx.Assert (output, Is.EqualTo (Digest4));
|
||||
}
|
||||
|
||||
[AsyncTest]
|
||||
public void TestDigest_Sha384 (TestContext ctx, [TestHost] ICryptoTestProvider provider)
|
||||
public void TestDigest_Sha384 (TestContext ctx, [TestHost] ICryptoTestHost provider)
|
||||
{
|
||||
var output = provider.TestDigest (HandshakeHashType.SHA384, TestData5);
|
||||
ctx.Assert (output, Is.EqualTo (Digest5));
|
||||
}
|
||||
|
||||
[AsyncTest]
|
||||
public void TestMasterSecret_Sha384 (TestContext ctx, [TestHost] ICryptoTestProvider provider)
|
||||
public void TestMasterSecret_Sha384 (TestContext ctx, [TestHost] ICryptoTestHost provider)
|
||||
{
|
||||
var output = provider.TestPRF (HandshakeHashType.SHA384, TestSecret3, TestSeed3, TestData3, PRF3.Length);
|
||||
ctx.Assert (output, Is.EqualTo (PRF3));
|
||||
}
|
||||
|
||||
[AsyncTest]
|
||||
public void TestKeyExpansion_Sha384 (TestContext ctx, [TestHost] ICryptoTestProvider provider)
|
||||
public void TestKeyExpansion_Sha384 (TestContext ctx, [TestHost] ICryptoTestHost provider)
|
||||
{
|
||||
var output = provider.TestPRF (HandshakeHashType.SHA384, TestSecret6, TestSeed6, TestData6, KeyExpansion6.Length);
|
||||
ctx.Assert (output, Is.EqualTo (KeyExpansion6));
|
||||
}
|
||||
|
||||
[AsyncTest]
|
||||
public void SimpleTest (TestContext ctx, [TestHost] ICryptoTestProvider provider)
|
||||
public void SimpleTest (TestContext ctx, [TestHost] ICryptoTestHost provider)
|
||||
{
|
||||
ctx.LogMessage ("SIMPLE TEST: {0}", provider);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче