]> git.deb.at Git - rhonda/impostor.hazel.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorjs6pak <kubastaron@hotmail.com>
Wed, 10 Nov 2021 13:57:11 +0000 (14:57 +0100)
committerjs6pak <kubastaron@hotmail.com>
Wed, 10 Nov 2021 14:00:20 +0000 (15:00 +0100)
# Conflicts:
# Hazel.UnitTests/ThreadLimitedUdpConnectionTests.cs
# Hazel.UnitTests/UnityUdpConnectionTests.cs
# Hazel/FewerThreads/ThreadLimitedUdpConnectionListener.cs
# Hazel/Hazel.csproj
# README.md

1  2 
Hazel.UnitTests/ThreadLimitedUdpConnectionTests.cs
Hazel.UnitTests/UnityUdpConnectionTests.cs
Hazel/Crypto/AesGcm.cs
Hazel/Crypto/CryptoProvider.cs
Hazel/Crypto/DefaultAes.cs
Hazel/Crypto/IAes.cs
Hazel/FewerThreads/ThreadLimitedUdpConnectionListener.cs
Hazel/Hazel.csproj

index 0000000000000000000000000000000000000000,4be16280beb4d6bd5198d4533208fbdef3fb2d88..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
mode 000000,100644..100644
--- /dev/null
index 0000000000000000000000000000000000000000,5151ae25fdb41a9addbb3633ff6261792a8e2dee..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
mode 000000,100644..100644
--- /dev/null
Simple merge
index 0000000000000000000000000000000000000000,2c56c7095542704e236a78d592f656e96e4b9486..8a38d77fa300262ab6c0940565f3395fc6342ff2
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,36 +1,30 @@@
 -using System;
 -using System.Collections.Generic;
 -using System.Linq;
 -using System.Text;
 -using System.Threading.Tasks;
 -
 -namespace Hazel.Crypto
++namespace Impostor.Hazel.Crypto
+ {
+     public static class CryptoProvider
+     {
+         public delegate IAes CreateAesOverrideDelegate(ByteSpan key);
+         /// <summary>
+         /// Override the default AES creation function
+         /// </summary>
+         public static CreateAesOverrideDelegate OverrideCreateAes = null;
+         /// <summary>
+         /// Create a new AES cipher
+         /// </summary>
+         /// <param name="key">Encrtyption key</param>
+         public static IAes CreateAes(ByteSpan key)
+         {
+             if (OverrideCreateAes != null)
+             {
+                 IAes result = OverrideCreateAes(key);
+                 if (null != result)
+                 {
+                     return result;
+                 }
+             }
+             return new DefaultAes(key);
+         }
+     }
+ }
index 0000000000000000000000000000000000000000,da72fb82e620bbc4a277370aed80be07a71eb21e..6db66e6c7a218e241539ed8eaba7f5066412e353
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,49 +1,49 @@@
 -namespace Hazel.Crypto
+ using System;
+ using System.Security.Cryptography;
++namespace Impostor.Hazel.Crypto
+ {
+     /// <summary>
+     /// AES provider using the default System.Security.Cryptography implementation
+     /// </summary>
+     public class DefaultAes : IAes
+     {
+         private readonly ICryptoTransform encryptor_;
+         /// <summary>
+         /// Create a new default instance of the AES block cipher
+         /// </summary>
+         /// <param name="key">Encryption key</param>
+         public DefaultAes(ByteSpan key)
+         {
+             // Create the AES block cipher
+             using (Aes aes = Aes.Create())
+             {
+                 aes.KeySize = key.Length * 8;
+                 aes.BlockSize = aes.KeySize;
+                 aes.Mode = CipherMode.ECB;
+                 aes.Padding = PaddingMode.Zeros;
+                 aes.Key = key.ToArray();
+                 this.encryptor_ = aes.CreateEncryptor();
+             }
+         }
+         /// <inheritdoc/>
+         public void Dispose()
+         {
+             this.encryptor_.Dispose();
+         }
+         /// <inheritdoc/>
+         public int EncryptBlock(ByteSpan inputSpan, ByteSpan outputSpan)
+         {
+             if (inputSpan.Length != outputSpan.Length)
+             {
+                 throw new ArgumentException($"ouputSpan length ({outputSpan.Length}) does not match inputSpan length ({inputSpan.Length})", nameof(outputSpan));
+             }
+             return this.encryptor_.TransformBlock(inputSpan.GetUnderlyingArray(), inputSpan.Offset, inputSpan.Length, outputSpan.GetUnderlyingArray(), outputSpan.Offset);
+         }
+     }
+ }
index 0000000000000000000000000000000000000000,6c494cd9641b309372a54e71c3ce0147d290b000..e437d0337d7c906c5446753f503f10e3eb260a20
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,27 +1,23 @@@
 -using System.Collections.Generic;
 -using System.Linq;
 -using System.Text;
 -using System.Threading.Tasks;
+ using System;
 -namespace Hazel.Crypto
++namespace Impostor.Hazel.Crypto
+ {
+     /// <summary>
+     /// AES encryption interface
+     /// </summary>
+     public interface IAes : IDisposable
+     {
+         /// <summary>
+         /// Encrypts the specified region of the input byte array and copies
+         /// the resulting transform to the specified region of the output
+         /// array.
+         /// </summary>
+         /// <param name="inputSpan">The input for which to encrypt</param>
+         /// <param name="outputSpan">
+         /// The otput to which to write the encrypted data. This span can
+         /// overlap with `inputSpan`.
+         /// </param>
+         /// <returns>The number of bytes written</returns>
+         int EncryptBlock(ByteSpan inputSpan, ByteSpan outputSpan);
+     }
+ }
index 0000000000000000000000000000000000000000,3053363fc54f8870769b1318a21ac90cde138b64..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
mode 000000,100644..100644
--- /dev/null
index b26153445a6902678da746eb6d7793d4ea696757,6b0b91dccf5c2f2e8cbdf51240008e3153e98448..34f75954cb1a13361f6160719f004b11366b353b
 -<?xml version="1.0" encoding="utf-8"?>
 -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 -  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
 +<Project Sdk="Microsoft.NET.Sdk">
 +
    <PropertyGroup>
 -    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
 -    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
 -    <ProjectGuid>{02CFBD30-D77D-400F-94B2-700F60EFDD7F}</ProjectGuid>
 -    <OutputType>Library</OutputType>
 -    <AppDesignerFolder>Properties</AppDesignerFolder>
 -    <RootNamespace>Hazel</RootNamespace>
 -    <AssemblyName>Hazel</AssemblyName>
 -    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
 -    <FileAlignment>512</FileAlignment>
 -    <TargetFrameworkProfile />
 -  </PropertyGroup>
 -  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
 -    <DebugSymbols>true</DebugSymbols>
 -    <DebugType>full</DebugType>
 -    <Optimize>false</Optimize>
 -    <OutputPath>bin\Debug\</OutputPath>
 -    <DefineConstants>DEBUG;TRACE</DefineConstants>
 -    <ErrorReport>prompt</ErrorReport>
 -    <WarningLevel>4</WarningLevel>
 -    <DocumentationFile>
 -    </DocumentationFile>
 -    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
 -    <Prefer32Bit>false</Prefer32Bit>
 -    <LangVersion>7.3</LangVersion>
 -  </PropertyGroup>
 -  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
 -    <DebugType>portable</DebugType>
 -    <Optimize>true</Optimize>
 -    <OutputPath>bin\Release\</OutputPath>
 -    <DefineConstants>TRACE</DefineConstants>
 -    <ErrorReport>prompt</ErrorReport>
 -    <WarningLevel>4</WarningLevel>
 -    <DocumentationFile>
 -    </DocumentationFile>
      <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
 -    <Prefer32Bit>false</Prefer32Bit>
 -    <LangVersion>7.3</LangVersion>
 -    <DebugSymbols>true</DebugSymbols>
 -  </PropertyGroup>
 -  <PropertyGroup>
 -    <SignAssembly>true</SignAssembly>
 -  </PropertyGroup>
 -  <PropertyGroup>
 -    <AssemblyOriginatorKeyFile>
 -    </AssemblyOriginatorKeyFile>
 -  </PropertyGroup>
 -  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugClient|AnyCPU'">
 -    <DebugSymbols>true</DebugSymbols>
 -    <OutputPath>bin\DebugClient\</OutputPath>
 -    <DefineConstants>DEBUG;TRACE</DefineConstants>
 -    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
 -    <DebugType>full</DebugType>
 -    <PlatformTarget>AnyCPU</PlatformTarget>
 -    <ErrorReport>prompt</ErrorReport>
 -    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
 -    <LangVersion>7.3</LangVersion>
 +    <TargetFramework>net5.0</TargetFramework>
 +    <DefineConstants>HAZEL_BAG</DefineConstants>
 +    <RootNamespace>Impostor.Hazel</RootNamespace>
    </PropertyGroup>
 +
 +  <ItemGroup>
 +    <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
 +      <_Parameter1>Hazel.UnitTests</_Parameter1>
 +    </AssemblyAttribute>
 +  </ItemGroup>
 +
    <ItemGroup>
 -    <Reference Include="System" />
 -    <Reference Include="System.Core" />
 -    <Reference Include="System.Xml.Linq" />
 -    <Reference Include="System.Data.DataSetExtensions" />
 -    <Reference Include="System.Data" />
 -    <Reference Include="System.Xml" />
 +    <PackageReference Include="Microsoft.Extensions.ObjectPool" Version="5.0.0" />
 +    <PackageReference Include="Serilog" Version="2.10.0" />
    </ItemGroup>
 +
    <ItemGroup>
 -    <Compile Include="ByteSpan.cs" />
 -    <Compile Include="ByteSpanExtensions.cs" />
 -    <Compile Include="Connection.cs" />
 -    <Compile Include="ConnectionListener.cs" />
 -    <Compile Include="ConnectionState.cs" />
 -    <Compile Include="Crypto\AesGcm.cs" />
 -    <Compile Include="Crypto\Const.cs" />
 -    <Compile Include="Crypto\CryptoProvider.cs" />
 -    <Compile Include="Crypto\DefaultAes.cs" />
 -    <Compile Include="Crypto\IAes.cs" />
 -    <Compile Include="Crypto\Sha256Stream.cs" />
 -    <Compile Include="Crypto\SpanCryptoExtensions.cs" />
 -    <Compile Include="Crypto\X25519.cs" />
 -    <Compile Include="DataReceivedEventArgs.cs" />
 -    <Compile Include="DisconnectedEventArgs.cs" />
 -    <Compile Include="Dtls\AesGcmRecordProtection.cs" />
 -    <Compile Include="Dtls\DtlsUnityConnection.cs" />
 -    <Compile Include="Dtls\DtlsConnectionListener.cs" />
 -    <Compile Include="Dtls\Handshake.cs" />
 -    <Compile Include="Dtls\IHandshakeCipherSuite.cs" />
 -    <Compile Include="Dtls\IRecordProtection.cs" />
 -    <Compile Include="Dtls\NullRecordProtection.cs" />
 -    <Compile Include="Dtls\PrfSha256.cs" />
 -    <Compile Include="Dtls\Record.cs" />
 -    <Compile Include="Dtls\X25519EcdheRsaSha256.cs" />
 -    <Compile Include="FewerThreads\HazelThreadPool.cs" />
 -    <Compile Include="FewerThreads\ThreadLimitedUdpConnectionListener.cs" />
 -    <Compile Include="FewerThreads\ThreadLimitedUdpServerConnection.cs" />
 -    <Compile Include="HazelException.cs" />
 -    <Compile Include="IPMode.cs" />
 -    <Compile Include="IRecyclable.cs" />
 -    <Compile Include="MessageReader.cs" />
 -    <Compile Include="NetworkConnection.cs" />
 -    <Compile Include="NetworkConnectionListener.cs" />
 -    <Compile Include="MessageWriter.cs" />
 -    <Compile Include="NewConnectionEventArgs.cs" />
 -    <Compile Include="ObjectPool.cs" />
 -    <Compile Include="Properties\AssemblyInfo.cs" />
 -    <Compile Include="SendOption.cs" />
 -    <Compile Include="Udp\SendOptionInternal.cs" />
 -    <Compile Include="ConnectionStatistics.cs" />
 -    <Compile Include="Udp\UdpBroadcaster.cs" />
 -    <Compile Include="Udp\UdpBroadcastListener.cs" />
 -    <Compile Include="Udp\UnityUdpClientConnection.cs" />
 -    <Compile Include="Udp\UdpClientConnection.cs" />
 -    <Compile Include="Udp\UdpConnection.cs">
 -      <SubType>Code</SubType>
 -    </Compile>
 -    <Compile Include="Udp\UdpConnection.KeepAlive.cs" />
 -    <Compile Include="Udp\UdpConnection.Reliable.cs" />
 -    <Compile Include="Udp\UdpConnectionListener.cs" />
 -    <Compile Include="Udp\UdpServerConnection.cs" />
 -    <Compile Include="UPnP\ILogger.cs" />
 -    <Compile Include="UPnP\NetUtility.cs" />
 -    <Compile Include="UPnP\UPnPHelper.cs" />
 +    <ProjectReference Include="..\..\Impostor.Api\Impostor.Api.csproj" />
    </ItemGroup>
 -  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 -  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
 -       Other similar extension points exist, see Microsoft.Common.targets.
 -  <Target Name="BeforeBuild">
 -  </Target>
 -  <Target Name="AfterBuild">
 -  </Target>
 -  -->
 -</Project>
 +
 +</Project>
++