mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-09-24 11:52:18 +00:00
Merge branch 'develop' of https://github.com/sshnet/SSH.NET into develop
This commit is contained in:
@@ -12,17 +12,13 @@
|
||||
<AssemblyName>Renci.SshNet</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;TUNING</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG;TUNING;FEATURE_HASH_MD5;FEATURE_HASH_SHA1;FEATURE_HASH_SHA256;FEATURE_HASH_SHA384;FEATURE_HASH_SHA512;FEATURE_HASH_RIPEMD160;FEATURE_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512;FEATURE_HMAC_RIPEMD160</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
@@ -30,7 +26,7 @@
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;TUNING</DefineConstants>
|
||||
<DefineConstants>TRACE;TUNING;FEATURE_HASH_MD5;FEATURE_HASH_SHA1;FEATURE_HASH_SHA256;FEATURE_HASH_SHA384;FEATURE_HASH_SHA512;FEATURE_HASH_RIPEMD160;FEATURE_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512;FEATURE_HMAC_RIPEMD160</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>bin\Release\Renci.SshNet.xml</DocumentationFile>
|
||||
@@ -657,29 +653,23 @@
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\DsaKey.cs">
|
||||
<Link>Security\Cryptography\DsaKey.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\MD5Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\MD5Hash.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HashAlgorithmFactory.cs">
|
||||
<Link>Security\Cryptography\HashAlgorithmFactory.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\RIPEMD160Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\RIPEMD160Hash.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMACMD5.cs">
|
||||
<Link>Security\Cryptography\HMACMD5.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\SHA1Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\SHA1Hash.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMACSHA1.cs">
|
||||
<Link>Security\Cryptography\HMACSHA1.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\SHA256Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\SHA256Hash.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMACSHA256.cs">
|
||||
<Link>Security\Cryptography\HMACSHA256.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\SHA2HashBase.cs">
|
||||
<Link>Security\Cryptography\Hashes\SHA2HashBase.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMACSHA384.cs">
|
||||
<Link>Security\Cryptography\HMACSHA384.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\SHA384Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\SHA384Hash.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\SHA512Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\SHA512Hash.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMAC.cs">
|
||||
<Link>Security\Cryptography\HMAC.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMACSHA512.cs">
|
||||
<Link>Security\Cryptography\HMACSHA512.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Key.cs">
|
||||
<Link>Security\Cryptography\Key.cs</Link>
|
||||
|
||||
@@ -17,10 +17,6 @@
|
||||
<SilverlightApplication>false</SilverlightApplication>
|
||||
<ValidateXaml>true</ValidateXaml>
|
||||
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
</PropertyGroup>
|
||||
<!-- This property group is only here to support building this project using the
|
||||
MSBuild 3.5 toolset. In order to work correctly with this older toolset, it needs
|
||||
@@ -33,7 +29,7 @@
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>Bin\Debug</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;SILVERLIGHT;TUNING</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG;SILVERLIGHT;TUNING;FEATURE_HASH_SHA1;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
@@ -44,7 +40,7 @@
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>Bin\Release</OutputPath>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;TUNING</DefineConstants>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;TUNING;FEATURE_HASH_SHA1;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
@@ -61,6 +57,10 @@
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.CSharp, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="Renci.Security.Cryptography, Version=1.0.0.0, Culture=neutral, PublicKeyToken=50c6375d29e47192, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Renci.Security.Cryptography.1.0.0\lib\sl4\Renci.Security.Cryptography.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="system" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml" />
|
||||
@@ -613,29 +613,23 @@
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\DsaKey.cs">
|
||||
<Link>Security\Cryptography\DsaKey.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\MD5Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\MD5Hash.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HashAlgorithmFactory.cs">
|
||||
<Link>Security\Cryptography\HashAlgorithmFactory.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\RIPEMD160Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\RIPEMD160Hash.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMACMD5.cs">
|
||||
<Link>Security\Cryptography\HMACMD5.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\SHA1Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\SHA1Hash.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMACSHA1.cs">
|
||||
<Link>Security\Cryptography\HMACSHA1.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\SHA256Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\SHA256Hash.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMACSHA256.cs">
|
||||
<Link>Security\Cryptography\HMACSHA256.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\SHA2HashBase.cs">
|
||||
<Link>Security\Cryptography\Hashes\SHA2HashBase.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMACSHA384.cs">
|
||||
<Link>Security\Cryptography\HMACSHA384.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\SHA384Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\SHA384Hash.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\SHA512Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\SHA512Hash.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMAC.cs">
|
||||
<Link>Security\Cryptography\HMAC.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMACSHA512.cs">
|
||||
<Link>Security\Cryptography\HMACSHA512.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Key.cs">
|
||||
<Link>Security\Cryptography\Key.cs</Link>
|
||||
@@ -893,6 +887,7 @@
|
||||
<None Include="..\Renci.SshNet.snk">
|
||||
<Link>Renci.SshNet.snk</Link>
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />
|
||||
<ProjectExtensions>
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Renci.Security.Cryptography" version="1.0.0" targetFramework="sl40" />
|
||||
</packages>
|
||||
@@ -17,11 +17,6 @@
|
||||
<SilverlightApplication>false</SilverlightApplication>
|
||||
<ValidateXaml>true</ValidateXaml>
|
||||
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<!-- This property group is only here to support building this project using the
|
||||
MSBuild 3.5 toolset. In order to work correctly with this older toolset, it needs
|
||||
@@ -34,7 +29,7 @@
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>Bin\Debug</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;SILVERLIGHT;TUNING</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG;SILVERLIGHT;TUNING;FEATURE_HASH_SHA1;FEATURE_HASH_SHA256;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
@@ -46,7 +41,7 @@
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>Bin\Release</OutputPath>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;TUNING</DefineConstants>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;TUNING;FEATURE_HASH_SHA1;FEATURE_HASH_SHA256;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
@@ -67,6 +62,10 @@
|
||||
<HintPath>C:\Program Files (x86)\Microsoft SDKs\Silverlight\v5.0\Libraries\Client\Microsoft.CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="Renci.Security.Cryptography, Version=1.0.0.0, Culture=neutral, PublicKeyToken=50c6375d29e47192, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Renci.Security.Cryptography.1.0.0\lib\sl5\Renci.Security.Cryptography.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="system" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml" />
|
||||
@@ -658,29 +657,23 @@
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\DsaKey.cs">
|
||||
<Link>Security\Cryptography\DsaKey.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\MD5Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\MD5Hash.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HashAlgorithmFactory.cs">
|
||||
<Link>Security\Cryptography\HashAlgorithmFactory.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\RIPEMD160Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\RIPEMD160Hash.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMACMD5.cs">
|
||||
<Link>Security\Cryptography\HMACMD5.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\SHA1Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\SHA1Hash.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMACSHA1.cs">
|
||||
<Link>Security\Cryptography\HMACSHA1.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\SHA256Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\SHA256Hash.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMACSHA256.cs">
|
||||
<Link>Security\Cryptography\HMACSHA256.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\SHA2HashBase.cs">
|
||||
<Link>Security\Cryptography\Hashes\SHA2HashBase.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMACSHA384.cs">
|
||||
<Link>Security\Cryptography\HMACSHA384.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\SHA384Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\SHA384Hash.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\SHA512Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\SHA512Hash.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMac.cs">
|
||||
<Link>Security\Cryptography\HMac.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMACSHA512.cs">
|
||||
<Link>Security\Cryptography\HMACSHA512.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Key.cs">
|
||||
<Link>Security\Cryptography\Key.cs</Link>
|
||||
@@ -925,6 +918,7 @@
|
||||
<None Include="..\Renci.SshNet.snk">
|
||||
<Link>Renci.SshNet.snk</Link>
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />
|
||||
<ProjectExtensions>
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Renci.Security.Cryptography" version="1.0.0" targetFramework="sl50" />
|
||||
</packages>
|
||||
@@ -14,11 +14,6 @@
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<TargetFrameworkProfile />
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -46,7 +41,7 @@
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
|
||||
<Reference Include="Moq">
|
||||
<HintPath>..\packages\Moq.4.2.1409.1722\lib\net35\Moq.dll</HintPath>
|
||||
<HintPath>..\..\packages\Moq.4.2.1409.1722\lib\net35\Moq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
@@ -775,18 +770,6 @@
|
||||
<Compile Include="..\Renci.SshNet.Tests\Classes\Security\Cryptography\DsaKeyTest.cs">
|
||||
<Link>Classes\Security\Cryptography\DsaKeyTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet.Tests\Classes\Security\Cryptography\Hashes\MD5HashTest.cs">
|
||||
<Link>Classes\Security\Cryptography\Hashes\MD5HashTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet.Tests\Classes\Security\Cryptography\Hashes\RIPEMD160HashTest.cs">
|
||||
<Link>Classes\Security\Cryptography\Hashes\RIPEMD160HashTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet.Tests\Classes\Security\Cryptography\Hashes\SHA1HashTest.cs">
|
||||
<Link>Classes\Security\Cryptography\Hashes\SHA1HashTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet.Tests\Classes\Security\Cryptography\Hashes\SHA256HashTest.cs">
|
||||
<Link>Classes\Security\Cryptography\Hashes\SHA256HashTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet.Tests\Classes\Security\Cryptography\HMacTest.cs">
|
||||
<Link>Classes\Security\Cryptography\HMacTest.cs</Link>
|
||||
</Compile>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using Renci.SshNet.Security.Cryptography;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
using Renci.SshNet.Tests.Properties;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Security.Cryptography
|
||||
@@ -20,7 +19,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography
|
||||
{
|
||||
var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
|
||||
connectionInfo.HmacAlgorithms.Clear();
|
||||
connectionInfo.HmacAlgorithms.Add("hmac-md5", new HashInfo(16 * 8, (key) => { return new HMac<MD5Hash>(key); }));
|
||||
connectionInfo.HmacAlgorithms.Add("hmac-md5", new HashInfo(16 * 8, HashAlgorithmFactory.CreateHMACMD5));
|
||||
|
||||
using (var client = new SshClient(connectionInfo))
|
||||
{
|
||||
@@ -35,7 +34,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography
|
||||
{
|
||||
var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
|
||||
connectionInfo.HmacAlgorithms.Clear();
|
||||
connectionInfo.HmacAlgorithms.Add("hmac-sha1", new HashInfo(20 * 8, (key) => { return new HMac<SHA1Hash>(key); }));
|
||||
connectionInfo.HmacAlgorithms.Add("hmac-sha1", new HashInfo(20 * 8, HashAlgorithmFactory.CreateHMACSHA1));
|
||||
|
||||
using (var client = new SshClient(connectionInfo))
|
||||
{
|
||||
@@ -50,7 +49,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography
|
||||
{
|
||||
var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
|
||||
connectionInfo.HmacAlgorithms.Clear();
|
||||
connectionInfo.HmacAlgorithms.Add("hmac-md5", new HashInfo(16 * 8, (key) => { return new HMac<MD5Hash>(key, 96); }));
|
||||
connectionInfo.HmacAlgorithms.Add("hmac-md5", new HashInfo(16 * 8, key => HashAlgorithmFactory.CreateHMACMD5(key, 96)));
|
||||
|
||||
using (var client = new SshClient(connectionInfo))
|
||||
{
|
||||
@@ -65,7 +64,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography
|
||||
{
|
||||
var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
|
||||
connectionInfo.HmacAlgorithms.Clear();
|
||||
connectionInfo.HmacAlgorithms.Add("hmac-sha1", new HashInfo(20 * 8, (key) => { return new HMac<SHA1Hash>(key, 96); }));
|
||||
connectionInfo.HmacAlgorithms.Add("hmac-sha1", new HashInfo(20 * 8, key => HashAlgorithmFactory.CreateHMACSHA1(key, 96)));
|
||||
|
||||
using (var client = new SshClient(connectionInfo))
|
||||
{
|
||||
@@ -80,7 +79,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography
|
||||
{
|
||||
var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
|
||||
connectionInfo.HmacAlgorithms.Clear();
|
||||
connectionInfo.HmacAlgorithms.Add("hmac-sha2-256", new HashInfo(32 * 8, (key) => { return new HMac<SHA256Hash>(key); }));
|
||||
connectionInfo.HmacAlgorithms.Add("hmac-sha2-256", new HashInfo(32 * 8, HashAlgorithmFactory.CreateHMACSHA256));
|
||||
|
||||
using (var client = new SshClient(connectionInfo))
|
||||
{
|
||||
@@ -95,7 +94,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography
|
||||
{
|
||||
var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
|
||||
connectionInfo.HmacAlgorithms.Clear();
|
||||
connectionInfo.HmacAlgorithms.Add("hmac-sha2-256-96", new HashInfo(32 * 8, (key) => { return new HMac<SHA256Hash>(key, 96); }));
|
||||
connectionInfo.HmacAlgorithms.Add("hmac-sha2-256-96", new HashInfo(32 * 8, (key) => HashAlgorithmFactory.CreateHMACSHA256(key, 96)));
|
||||
|
||||
using (var client = new SshClient(connectionInfo))
|
||||
{
|
||||
@@ -110,7 +109,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography
|
||||
{
|
||||
var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
|
||||
connectionInfo.HmacAlgorithms.Clear();
|
||||
connectionInfo.HmacAlgorithms.Add("hmac-ripemd160", new HashInfo(160, (key) => { return new HMac<RIPEMD160Hash>(key); }));
|
||||
connectionInfo.HmacAlgorithms.Add("hmac-ripemd160", new HashInfo(160, HashAlgorithmFactory.CreateHMACRIPEMD160));
|
||||
|
||||
using (var client = new SshClient(connectionInfo))
|
||||
{
|
||||
@@ -125,7 +124,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography
|
||||
{
|
||||
var connectionInfo = new PasswordConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD);
|
||||
connectionInfo.HmacAlgorithms.Clear();
|
||||
connectionInfo.HmacAlgorithms.Add("hmac-ripemd160@openssh.com", new HashInfo(160, (key) => { return new HMac<RIPEMD160Hash>(key); }));
|
||||
connectionInfo.HmacAlgorithms.Add("hmac-ripemd160@openssh.com", new HashInfo(160, HashAlgorithmFactory.CreateHMACRIPEMD160));
|
||||
|
||||
using (var client = new SshClient(connectionInfo))
|
||||
{
|
||||
@@ -133,65 +132,5 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography
|
||||
client.Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for HMac`1 Constructor
|
||||
///</summary>
|
||||
public void HMacConstructorTestHelper<T>()
|
||||
where T : HashAlgorithm, new()
|
||||
{
|
||||
byte[] key = null; // TODO: Initialize to an appropriate value
|
||||
HMac<T> target = new HMac<T>(key);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void HMacConstructorTest()
|
||||
{
|
||||
Assert.Inconclusive("No appropriate type parameter is found to satisfies the type constraint(s) of T. " +
|
||||
"Please call HMacConstructorTestHelper<T>() with appropriate type parameters.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Initialize
|
||||
///</summary>
|
||||
public void InitializeTestHelper<T>()
|
||||
where T : HashAlgorithm, new()
|
||||
{
|
||||
byte[] key = null; // TODO: Initialize to an appropriate value
|
||||
HMac<T> target = new HMac<T>(key); // TODO: Initialize to an appropriate value
|
||||
target.Initialize();
|
||||
Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void InitializeTest()
|
||||
{
|
||||
Assert.Inconclusive("No appropriate type parameter is found to satisfies the type constraint(s) of T. " +
|
||||
"Please call InitializeTestHelper<T>() with appropriate type parameters.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Key
|
||||
///</summary>
|
||||
public void KeyTestHelper<T>()
|
||||
where T : HashAlgorithm, new()
|
||||
{
|
||||
byte[] key = null; // TODO: Initialize to an appropriate value
|
||||
HMac<T> target = new HMac<T>(key); // TODO: Initialize to an appropriate value
|
||||
byte[] expected = null; // TODO: Initialize to an appropriate value
|
||||
byte[] actual;
|
||||
target.Key = expected;
|
||||
actual = target.Key;
|
||||
Assert.AreEqual(expected, actual);
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void KeyTest()
|
||||
{
|
||||
Assert.Inconclusive("No appropriate type parameter is found to satisfies the type constraint(s) of T. " +
|
||||
"Please call KeyTestHelper<T>() with appropriate type parameters.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Security.Cryptography;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Security.Cryptography
|
||||
{
|
||||
/// <summary>
|
||||
/// MD5 algorithm implementation
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class MD5HashTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for MD5Hash Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void MD5HashConstructorTest()
|
||||
{
|
||||
MD5Hash target = new MD5Hash();
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Initialize
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void InitializeTest()
|
||||
{
|
||||
MD5Hash target = new MD5Hash(); // TODO: Initialize to an appropriate value
|
||||
target.Initialize();
|
||||
Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for CanReuseTransform
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void CanReuseTransformTest()
|
||||
{
|
||||
MD5Hash target = new MD5Hash(); // TODO: Initialize to an appropriate value
|
||||
bool actual;
|
||||
actual = target.CanReuseTransform;
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for CanTransformMultipleBlocks
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void CanTransformMultipleBlocksTest()
|
||||
{
|
||||
MD5Hash target = new MD5Hash(); // TODO: Initialize to an appropriate value
|
||||
bool actual;
|
||||
actual = target.CanTransformMultipleBlocks;
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for HashSize
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void HashSizeTest()
|
||||
{
|
||||
MD5Hash target = new MD5Hash(); // TODO: Initialize to an appropriate value
|
||||
int actual;
|
||||
actual = target.HashSize;
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for InputBlockSize
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void InputBlockSizeTest()
|
||||
{
|
||||
MD5Hash target = new MD5Hash(); // TODO: Initialize to an appropriate value
|
||||
int actual;
|
||||
actual = target.InputBlockSize;
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for OutputBlockSize
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void OutputBlockSizeTest()
|
||||
{
|
||||
MD5Hash target = new MD5Hash(); // TODO: Initialize to an appropriate value
|
||||
int actual;
|
||||
actual = target.OutputBlockSize;
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Security.Cryptography;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Security.Cryptography
|
||||
{
|
||||
/// <summary>
|
||||
///This is a test class for RIPEMD160HashTest and is intended
|
||||
///to contain all RIPEMD160HashTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class RIPEMD160HashTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for RIPEMD160Hash Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void RIPEMD160HashConstructorTest()
|
||||
{
|
||||
RIPEMD160Hash target = new RIPEMD160Hash();
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Initialize
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void InitializeTest()
|
||||
{
|
||||
RIPEMD160Hash target = new RIPEMD160Hash(); // TODO: Initialize to an appropriate value
|
||||
target.Initialize();
|
||||
Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for CanReuseTransform
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void CanReuseTransformTest()
|
||||
{
|
||||
RIPEMD160Hash target = new RIPEMD160Hash();
|
||||
Assert.IsTrue(target.CanReuseTransform);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for CanTransformMultipleBlocks
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void CanTransformMultipleBlocksTest()
|
||||
{
|
||||
RIPEMD160Hash target = new RIPEMD160Hash();
|
||||
Assert.IsTrue(target.CanTransformMultipleBlocks);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for HashSize
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void HashSizeTest()
|
||||
{
|
||||
RIPEMD160Hash target = new RIPEMD160Hash();
|
||||
Assert.AreEqual(target.HashSize, 160);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for InputBlockSize
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void InputBlockSizeTest()
|
||||
{
|
||||
RIPEMD160Hash target = new RIPEMD160Hash();
|
||||
Assert.AreEqual(target.InputBlockSize, 64);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for OutputBlockSize
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void OutputBlockSizeTest()
|
||||
{
|
||||
RIPEMD160Hash target = new RIPEMD160Hash();
|
||||
Assert.AreEqual(target.OutputBlockSize, 64);
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void ComputeHash1()
|
||||
{
|
||||
RIPEMD160Hash target = new RIPEMD160Hash();
|
||||
var input = ASCIIEncoding.ASCII.GetBytes("a");
|
||||
var expeceted = new byte[] { 0x0b, 0xdc, 0x9d, 0x2d, 0x25, 0x6b, 0x3e, 0xe9, 0xda, 0xae, 0x34, 0x7b, 0xe6, 0xf4, 0xdc, 0x83, 0x5a, 0x46, 0x7f, 0xfe };
|
||||
var output = target.ComputeHash(input);
|
||||
Assert.IsTrue(output.SequenceEqual(expeceted));
|
||||
}
|
||||
|
||||
|
||||
[TestMethod()]
|
||||
public void ComputeHash2()
|
||||
{
|
||||
RIPEMD160Hash target = new RIPEMD160Hash();
|
||||
var input = ASCIIEncoding.ASCII.GetBytes("abc");
|
||||
var expeceted = new byte[] { 0x8e, 0xb2, 0x08, 0xf7, 0xe0, 0x5d, 0x98, 0x7a, 0x9b, 0x04, 0x4a, 0x8e, 0x98, 0xc6, 0xb0, 0x87, 0xf1, 0x5a, 0x0b, 0xfc };
|
||||
var output = target.ComputeHash(input);
|
||||
Assert.IsTrue(output.SequenceEqual(expeceted));
|
||||
}
|
||||
|
||||
|
||||
[TestMethod()]
|
||||
public void ComputeHash3()
|
||||
{
|
||||
RIPEMD160Hash target = new RIPEMD160Hash();
|
||||
var input = ASCIIEncoding.ASCII.GetBytes("message digest");
|
||||
var expeceted = new byte[] { 0x5d, 0x06, 0x89, 0xef, 0x49, 0xd2, 0xfa, 0xe5, 0x72, 0xb8, 0x81, 0xb1, 0x23, 0xa8, 0x5f, 0xfa, 0x21, 0x59, 0x5f, 0x36 };
|
||||
var output = target.ComputeHash(input);
|
||||
Assert.IsTrue(output.SequenceEqual(expeceted));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Security.Cryptography;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Security.Cryptography
|
||||
{
|
||||
/// <summary>
|
||||
/// SHA1 algorithm implementation
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class SHA1HashTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for SHA1Hash Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void SHA1HashConstructorTest()
|
||||
{
|
||||
SHA1Hash target = new SHA1Hash();
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Initialize
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void InitializeTest()
|
||||
{
|
||||
SHA1Hash target = new SHA1Hash(); // TODO: Initialize to an appropriate value
|
||||
target.Initialize();
|
||||
Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for CanReuseTransform
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void CanReuseTransformTest()
|
||||
{
|
||||
SHA1Hash target = new SHA1Hash(); // TODO: Initialize to an appropriate value
|
||||
bool actual;
|
||||
actual = target.CanReuseTransform;
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for CanTransformMultipleBlocks
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void CanTransformMultipleBlocksTest()
|
||||
{
|
||||
SHA1Hash target = new SHA1Hash(); // TODO: Initialize to an appropriate value
|
||||
bool actual;
|
||||
actual = target.CanTransformMultipleBlocks;
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for HashSize
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void HashSizeTest()
|
||||
{
|
||||
SHA1Hash target = new SHA1Hash(); // TODO: Initialize to an appropriate value
|
||||
int actual;
|
||||
actual = target.HashSize;
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for InputBlockSize
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void InputBlockSizeTest()
|
||||
{
|
||||
SHA1Hash target = new SHA1Hash(); // TODO: Initialize to an appropriate value
|
||||
int actual;
|
||||
actual = target.InputBlockSize;
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for OutputBlockSize
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void OutputBlockSizeTest()
|
||||
{
|
||||
SHA1Hash target = new SHA1Hash(); // TODO: Initialize to an appropriate value
|
||||
int actual;
|
||||
actual = target.OutputBlockSize;
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Security.Cryptography;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Security.Cryptography
|
||||
{
|
||||
/// <summary>
|
||||
/// SHA256 algorithm implementation.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class SHA256HashTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for SHA256Hash Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void SHA256HashConstructorTest()
|
||||
{
|
||||
SHA256Hash target = new SHA256Hash();
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Initialize
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void InitializeTest()
|
||||
{
|
||||
SHA256Hash target = new SHA256Hash(); // TODO: Initialize to an appropriate value
|
||||
target.Initialize();
|
||||
Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for CanReuseTransform
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void CanReuseTransformTest()
|
||||
{
|
||||
SHA256Hash target = new SHA256Hash(); // TODO: Initialize to an appropriate value
|
||||
bool actual;
|
||||
actual = target.CanReuseTransform;
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for CanTransformMultipleBlocks
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void CanTransformMultipleBlocksTest()
|
||||
{
|
||||
SHA256Hash target = new SHA256Hash(); // TODO: Initialize to an appropriate value
|
||||
bool actual;
|
||||
actual = target.CanTransformMultipleBlocks;
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for HashSize
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void HashSizeTest()
|
||||
{
|
||||
SHA256Hash target = new SHA256Hash(); // TODO: Initialize to an appropriate value
|
||||
int actual;
|
||||
actual = target.HashSize;
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for InputBlockSize
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void InputBlockSizeTest()
|
||||
{
|
||||
SHA256Hash target = new SHA256Hash(); // TODO: Initialize to an appropriate value
|
||||
int actual;
|
||||
actual = target.InputBlockSize;
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for OutputBlockSize
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void OutputBlockSizeTest()
|
||||
{
|
||||
SHA256Hash target = new SHA256Hash(); // TODO: Initialize to an appropriate value
|
||||
int actual;
|
||||
actual = target.OutputBlockSize;
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,7 +92,9 @@ namespace Renci.SshNet.Tests.Classes
|
||||
ServerSocket.Send(newKeys, 4, newKeys.Length - 4, SocketFlags.None);
|
||||
};
|
||||
|
||||
_serviceFactoryMock.Setup(p => p.CreateKeyExchange(ConnectionInfo.KeyExchangeAlgorithms, new[] { _keyExchangeAlgorithm })).Returns(_keyExchangeMock.Object);
|
||||
_serviceFactoryMock.Setup(
|
||||
p =>
|
||||
p.CreateKeyExchange(ConnectionInfo.KeyExchangeAlgorithms, new[] {_keyExchangeAlgorithm})).Returns(_keyExchangeMock.Object);
|
||||
_keyExchangeMock.Setup(p => p.Name).Returns(_keyExchangeAlgorithm);
|
||||
_keyExchangeMock.Setup(p => p.Start(Session, It.IsAny<KeyExchangeInitMessage>()));
|
||||
_keyExchangeMock.Setup(p => p.ExchangeHash).Returns(SessionId);
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>
|
||||
</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{C45379B9-17B1-4E89-BC2E-6D41726413E8}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
@@ -14,10 +12,6 @@
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -50,7 +44,7 @@
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
|
||||
<Reference Include="Moq">
|
||||
<HintPath>..\packages\Moq.4.2.1409.1722\lib\net40\Moq.dll</HintPath>
|
||||
<HintPath>..\..\packages\Moq.4.2.1409.1722\lib\net40\Moq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
@@ -295,9 +289,6 @@
|
||||
<Compile Include="Classes\Security\Cryptography\Ciphers\TwofishCipherTest.cs" />
|
||||
<Compile Include="Classes\Security\Cryptography\DsaDigitalSignatureTest.cs" />
|
||||
<Compile Include="Classes\Security\Cryptography\DsaKeyTest.cs" />
|
||||
<Compile Include="Classes\Security\Cryptography\Hashes\MD5HashTest.cs" />
|
||||
<Compile Include="Classes\Security\Cryptography\Hashes\SHA1HashTest.cs" />
|
||||
<Compile Include="Classes\Security\Cryptography\Hashes\SHA256HashTest.cs" />
|
||||
<Compile Include="Classes\Security\Cryptography\HMacTest.cs" />
|
||||
<Compile Include="Classes\Security\Cryptography\RsaDigitalSignatureTest.cs" />
|
||||
<Compile Include="Classes\Security\Cryptography\RsaKeyTest.cs" />
|
||||
@@ -495,7 +486,6 @@
|
||||
<Compile Include="Classes\Sftp\SftpListDirectoryAsyncResultTest.cs" />
|
||||
<Compile Include="Classes\Sftp\SftpSynchronizeDirectoriesAsyncResultTest.cs" />
|
||||
<Compile Include="Classes\Sftp\SftpUploadAsyncResultTest.cs" />
|
||||
<Compile Include="Classes\Security\Cryptography\Hashes\RIPEMD160HashTest.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Renci.SshNet\Renci.SshNet.csproj">
|
||||
|
||||
@@ -18,17 +18,13 @@
|
||||
<SilverlightApplication>false</SilverlightApplication>
|
||||
<ValidateXaml>true</ValidateXaml>
|
||||
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>Bin\Debug</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;SILVERLIGHT;WINDOWS_PHONE;TUNING</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG;SILVERLIGHT;WINDOWS_PHONE;TUNING;FEATURE_HASH_SHA1;FEATURE_HASH_SHA256;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
@@ -39,7 +35,7 @@
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>Bin\Release</OutputPath>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE;TUNING</DefineConstants>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE;TUNING;FEATURE_HASH_SHA1;FEATURE_HASH_SHA256;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
@@ -48,6 +44,10 @@
|
||||
<NoWarn>1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Renci.Security.Cryptography, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Renci.Security.Cryptography.1.0.0\lib\wp71\Renci.Security.Cryptography.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="system" />
|
||||
<Reference Include="System.Net" />
|
||||
</ItemGroup>
|
||||
@@ -607,29 +607,23 @@
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\DsaKey.cs">
|
||||
<Link>Security\Cryptography\DsaKey.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\MD5Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\MD5Hash.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HashAlgorithmFactory.cs">
|
||||
<Link>Security\Cryptography\HashAlgorithmFactory.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\RIPEMD160Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\RIPEMD160Hash.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMACMD5.cs">
|
||||
<Link>Security\Cryptography\HMACMD5.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\SHA1Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\SHA1Hash.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMACSHA1.cs">
|
||||
<Link>Security\Cryptography\HMACSHA1.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\SHA256Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\SHA256Hash.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMACSHA256.cs">
|
||||
<Link>Security\Cryptography\HMACSHA256.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\SHA2HashBase.cs">
|
||||
<Link>Security\Cryptography\Hashes\SHA2HashBase.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMACSHA384.cs">
|
||||
<Link>Security\Cryptography\HMACSHA384.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\SHA384Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\SHA384Hash.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\SHA512Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\SHA512Hash.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMAC.cs">
|
||||
<Link>Security\Cryptography\HMAC.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMACSHA512.cs">
|
||||
<Link>Security\Cryptography\HMACSHA512.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Key.cs">
|
||||
<Link>Security\Cryptography\Key.cs</Link>
|
||||
@@ -886,6 +880,9 @@
|
||||
</Compile>
|
||||
<Compile Include="Session.WP.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.CSharp.targets" />
|
||||
<ProjectExtensions />
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Renci.Security.Cryptography" version="1.0.0" targetFramework="wp71" />
|
||||
</packages>
|
||||
@@ -12,26 +12,18 @@
|
||||
<RootNamespace>Renci.SshNet</RootNamespace>
|
||||
<AssemblyName>Renci.SshNet</AssemblyName>
|
||||
<TargetFrameworkVersion>v8.0</TargetFrameworkVersion>
|
||||
<SilverlightVersion>
|
||||
</SilverlightVersion>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
<TargetFrameworkIdentifier>WindowsPhone</TargetFrameworkIdentifier>
|
||||
<SilverlightApplication>false</SilverlightApplication>
|
||||
<ValidateXaml>true</ValidateXaml>
|
||||
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
|
||||
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>Bin\Debug</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;SILVERLIGHT;WINDOWS_PHONE;TUNING</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG;SILVERLIGHT;WINDOWS_PHONE;TUNING;FEATURE_HASH_SHA1;FEATURE_HASH_SHA256;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
@@ -43,7 +35,7 @@
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>Bin\Release</OutputPath>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE;TUNING</DefineConstants>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE;TUNING;FEATURE_HASH_SHA1;FEATURE_HASH_SHA256;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
@@ -660,29 +652,23 @@
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\DsaKey.cs">
|
||||
<Link>Security\Cryptography\DsaKey.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\MD5Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\MD5Hash.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HashAlgorithmFactory.cs">
|
||||
<Link>Security\Cryptography\HashAlgorithmFactory.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\RIPEMD160Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\RIPEMD160Hash.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMACMD5.cs">
|
||||
<Link>Security\Cryptography\HMACMD5.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\SHA1Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\SHA1Hash.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMACSHA1.cs">
|
||||
<Link>Security\Cryptography\HMACSHA1.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\SHA256Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\SHA256Hash.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMACSHA256.cs">
|
||||
<Link>Security\Cryptography\HMACSHA256.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\SHA2HashBase.cs">
|
||||
<Link>Security\Cryptography\Hashes\SHA2HashBase.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMACSHA384.cs">
|
||||
<Link>Security\Cryptography\HMACSHA384.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\SHA384Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\SHA384Hash.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Hashes\SHA512Hash.cs">
|
||||
<Link>Security\Cryptography\Hashes\SHA512Hash.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMAC.cs">
|
||||
<Link>Security\Cryptography\HMAC.cs</Link>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\HMACSHA512.cs">
|
||||
<Link>Security\Cryptography\HMACSHA512.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Renci.SshNet\Security\Cryptography\Key.cs">
|
||||
<Link>Security\Cryptography\Key.cs</Link>
|
||||
@@ -937,11 +923,20 @@
|
||||
</Compile>
|
||||
<Compile Include="Session.WP.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Renci.Security.Cryptography, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Renci.Security.Cryptography.1.0.0\lib\wp8\Renci.Security.Cryptography.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).$(TargetFrameworkVersion).Overrides.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).CSharp.targets" />
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<UserProperties ProjectLinkReference="2f5f8c90-0bd1-424f-997c-7bc6280919d1" ProjectLinkerExcludeFilter="\\?desktop(\\.*)?$;\\?silverlight(\\.*)?$;\.desktop;\.silverlight;\.xaml;^service references(\\.*)?$;\.clientconfig;^web references(\\.*)?$" />
|
||||
<UserProperties ProjectLinkerExcludeFilter="\\?desktop(\\.*)?$;\\?silverlight(\\.*)?$;\.desktop;\.silverlight;\.xaml;^service references(\\.*)?$;\.clientconfig;^web references(\\.*)?$" ProjectLinkReference="2f5f8c90-0bd1-424f-997c-7bc6280919d1" />
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Renci.Security.Cryptography" version="1.0.0" targetFramework="wp80" />
|
||||
</packages>
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using Renci.SshNet.Security.Cryptography;
|
||||
using Renci.SshNet.Security;
|
||||
|
||||
@@ -54,7 +55,7 @@ namespace Renci.SshNet.Common
|
||||
|
||||
KeyLength = host.Key.KeyLength;
|
||||
|
||||
using (var md5 = new MD5Hash())
|
||||
using (var md5 = HashAlgorithmFactory.CreateMD5())
|
||||
{
|
||||
FingerPrint = md5.ComputeHash(host.Data);
|
||||
}
|
||||
|
||||
@@ -334,17 +334,17 @@ namespace Renci.SshNet
|
||||
|
||||
HmacAlgorithms = new Dictionary<string, HashInfo>
|
||||
{
|
||||
{"hmac-md5", new HashInfo(16*8, key => new HMac<MD5Hash>(key))},
|
||||
{"hmac-sha1", new HashInfo(20*8, key => new HMac<SHA1Hash>(key))},
|
||||
{"hmac-sha2-256", new HashInfo(32*8, key => new HMac<SHA256Hash>(key))},
|
||||
{"hmac-sha2-256-96", new HashInfo(32*8, key => new HMac<SHA256Hash>(key, 96))},
|
||||
//{"hmac-sha2-512", new HashInfo(64 * 8, key => new HMac<SHA512Hash>(key))},
|
||||
//{"hmac-sha2-512-96", new HashInfo(64 * 8, key => new HMac<SHA512Hash>(key, 96))},
|
||||
{"hmac-md5", new HashInfo(16*8, HashAlgorithmFactory.CreateHMACMD5)},
|
||||
{"hmac-md5-96", new HashInfo(16*8, key => HashAlgorithmFactory.CreateHMACMD5(key, 96))},
|
||||
{"hmac-sha1", new HashInfo(20*8, HashAlgorithmFactory.CreateHMACSHA1)},
|
||||
{"hmac-sha1-96", new HashInfo(20*8, key => HashAlgorithmFactory.CreateHMACSHA1(key, 96))},
|
||||
{"hmac-sha2-256", new HashInfo(32*8, HashAlgorithmFactory.CreateHMACSHA256)},
|
||||
{"hmac-sha2-256-96", new HashInfo(32*8, key => HashAlgorithmFactory.CreateHMACSHA256(key, 96))},
|
||||
{"hmac-sha2-512", new HashInfo(64 * 8, HashAlgorithmFactory.CreateHMACSHA512)},
|
||||
{"hmac-sha2-512-96", new HashInfo(64 * 8, key => HashAlgorithmFactory.CreateHMACSHA512(key, 96))},
|
||||
//{"umac-64@openssh.com", typeof(HMacSha1)},
|
||||
{"hmac-ripemd160", new HashInfo(160, key => new HMac<RIPEMD160Hash>(key))},
|
||||
{"hmac-ripemd160@openssh.com", new HashInfo(160, key => new HMac<RIPEMD160Hash>(key))},
|
||||
{"hmac-md5-96", new HashInfo(16*8, key => new HMac<MD5Hash>(key, 96))},
|
||||
{"hmac-sha1-96", new HashInfo(20*8, key => new HMac<SHA1Hash>(key, 96))},
|
||||
{"hmac-ripemd160", new HashInfo(160, HashAlgorithmFactory.CreateHMACRIPEMD160)},
|
||||
{"hmac-ripemd160@openssh.com", new HashInfo(160, HashAlgorithmFactory.CreateHMACRIPEMD160)},
|
||||
//{"none", typeof(...)},
|
||||
};
|
||||
|
||||
|
||||
@@ -279,7 +279,7 @@ namespace Renci.SshNet
|
||||
{
|
||||
var cipherKey = new List<byte>();
|
||||
|
||||
using (var md5 = new MD5Hash())
|
||||
using (var md5 = HashAlgorithmFactory.CreateMD5())
|
||||
{
|
||||
var passwordBytes = Encoding.UTF8.GetBytes(passphrase);
|
||||
|
||||
@@ -320,7 +320,7 @@ namespace Renci.SshNet
|
||||
|
||||
var cipherKey = new List<byte>();
|
||||
|
||||
using (var md5 = new MD5Hash())
|
||||
using (var md5 = HashAlgorithmFactory.CreateMD5())
|
||||
{
|
||||
var passwordBytes = Encoding.UTF8.GetBytes(passPhrase);
|
||||
|
||||
@@ -353,7 +353,6 @@ namespace Renci.SshNet
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,17 +12,13 @@
|
||||
<AssemblyName>Renci.SshNet</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;TUNING</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG;TUNING;FEATURE_HASH_MD5;FEATURE_HASH_SHA1;FEATURE_HASH_SHA256;FEATURE_HASH_SHA384;FEATURE_HASH_SHA512;FEATURE_HASH_RIPEMD160;FEATURE_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512;FEATURE_HMAC_RIPEMD160</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>bin\Debug\Renci.SshNet.xml</DocumentationFile>
|
||||
@@ -31,7 +27,7 @@
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TUNING</DefineConstants>
|
||||
<DefineConstants>TUNING;FEATURE_HASH_MD5;FEATURE_HASH_SHA1;FEATURE_HASH_SHA256;FEATURE_HASH_SHA384;FEATURE_HASH_SHA512;FEATURE_HASH_RIPEMD160;FEATURE_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512;FEATURE_HMAC_RIPEMD160</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>bin\Release\Renci.SshNet.xml</DocumentationFile>
|
||||
@@ -164,16 +160,12 @@
|
||||
<Compile Include="Messages\Transport\KeyExchangeEcdhInitMessage.cs" />
|
||||
<Compile Include="Messages\Transport\KeyExchangeEcdhReplyMessage.cs" />
|
||||
<Compile Include="Netconf\INetConfSession.cs" />
|
||||
<Compile Include="Security\Cryptography\Hashes\RIPEMD160Hash.cs" />
|
||||
<Compile Include="Security\Cryptography\Hashes\SHA2HashBase.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Security\Cryptography\Hashes\SHA384Hash.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Security\Cryptography\Hashes\SHA512Hash.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Security\Cryptography\HashAlgorithmFactory.cs" />
|
||||
<Compile Include="Security\Cryptography\HMACMD5.cs" />
|
||||
<Compile Include="Security\Cryptography\HMACSHA1.cs" />
|
||||
<Compile Include="Security\Cryptography\HMACSHA256.cs" />
|
||||
<Compile Include="Security\Cryptography\HMACSHA384.cs" />
|
||||
<Compile Include="Security\Cryptography\HMACSHA512.cs" />
|
||||
<Compile Include="Security\GroupExchangeHashData.cs" />
|
||||
<Compile Include="Security\IKeyExchange.cs" />
|
||||
<Compile Include="Security\KeyExchangeDiffieHellmanGroupExchangeShaBase.cs" />
|
||||
@@ -355,18 +347,6 @@
|
||||
<Compile Include="Security\Cryptography\DsaKey.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Security\Cryptography\Hashes\MD5Hash.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Security\Cryptography\Hashes\SHA1Hash.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Security\Cryptography\Hashes\SHA256Hash.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Security\Cryptography\HMAC.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Security\Cryptography\Key.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Renci.SshNet.Security.Cryptography
|
||||
|
||||
this._key = key;
|
||||
|
||||
this._hash = new SHA1Hash();
|
||||
this._hash = HashAlgorithmFactory.CreateSHA1();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,171 +0,0 @@
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Renci.SshNet.Security.Cryptography
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides HMAC algorithm implementation.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Class that implements <see cref="T:System.Security.Cryptography.HashAlgorithm" />.</typeparam>
|
||||
public class HMac<T> : KeyedHashAlgorithm where T : HashAlgorithm, new()
|
||||
{
|
||||
private HashAlgorithm _hash;
|
||||
//private bool _isHashing;
|
||||
private byte[] _innerPadding;
|
||||
private byte[] _outerPadding;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the size of the block.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The size of the block.
|
||||
/// </value>
|
||||
protected int BlockSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._hash.InputBlockSize;
|
||||
}
|
||||
}
|
||||
|
||||
private HMac()
|
||||
{
|
||||
// Create the hash algorithms.
|
||||
this._hash = new T();
|
||||
this.HashSizeValue = this._hash.HashSize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rfc 2104.
|
||||
/// </summary>
|
||||
/// <param name="key">The key.</param>
|
||||
/// <param name="hashSizeValue">The size, in bits, of the computed hash code.</param>
|
||||
public HMac(byte[] key, int hashSizeValue)
|
||||
: this(key)
|
||||
{
|
||||
this.HashSizeValue = hashSizeValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rfc 2104.
|
||||
/// </summary>
|
||||
/// <param name="key">The key.</param>
|
||||
public HMac(byte[] key)
|
||||
: this()
|
||||
{
|
||||
base.KeyValue = key;
|
||||
|
||||
this.InternalInitialize();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the key to use in the hash algorithm.
|
||||
/// </summary>
|
||||
/// <returns>The key to use in the hash algorithm.</returns>
|
||||
public override byte[] Key
|
||||
{
|
||||
get
|
||||
{
|
||||
return (byte[])base.KeyValue.Clone();
|
||||
}
|
||||
set
|
||||
{
|
||||
this.SetKey(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes an implementation of the <see cref="T:System.Security.Cryptography.HashAlgorithm" /> class.
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
this.InternalInitialize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hashes the core.
|
||||
/// </summary>
|
||||
/// <param name="rgb">The RGB.</param>
|
||||
/// <param name="ib">The ib.</param>
|
||||
/// <param name="cb">The cb.</param>
|
||||
protected override void HashCore(byte[] rgb, int ib, int cb)
|
||||
{
|
||||
this._hash.TransformBlock(rgb, ib, cb, rgb, ib);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finalizes the hash computation after the last data is processed by the cryptographic stream object.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The computed hash code.
|
||||
/// </returns>
|
||||
protected override byte[] HashFinal()
|
||||
{
|
||||
// Finalize the original hash.
|
||||
this._hash.TransformFinalBlock(new byte[0], 0, 0);
|
||||
|
||||
var hashValue = this._hash.Hash;
|
||||
|
||||
// Write the outer array.
|
||||
this._hash.TransformBlock(this._outerPadding, 0, this.BlockSize, this._outerPadding, 0);
|
||||
|
||||
// Write the inner hash and finalize the hash.
|
||||
this._hash.TransformFinalBlock(hashValue, 0, hashValue.Length);
|
||||
|
||||
return this._hash.Hash.Take(this.HashSize / 8).ToArray();
|
||||
}
|
||||
|
||||
private void InternalInitialize()
|
||||
{
|
||||
this.SetKey(base.KeyValue);
|
||||
}
|
||||
|
||||
private void SetKey(byte[] value)
|
||||
{
|
||||
this._hash.Initialize();
|
||||
|
||||
if (value.Length > this.BlockSize)
|
||||
{
|
||||
this.KeyValue = this._hash.ComputeHash(value);
|
||||
// No need to call Initialize, ComputeHash does it automatically.
|
||||
}
|
||||
else
|
||||
{
|
||||
this.KeyValue = (byte[]) value.Clone();
|
||||
}
|
||||
|
||||
this._innerPadding = new byte[this.BlockSize];
|
||||
this._outerPadding = new byte[this.BlockSize];
|
||||
|
||||
// Compute inner and outer padding.
|
||||
for (var i = 0; i < this.KeyValue.Length; i++)
|
||||
{
|
||||
this._innerPadding[i] = (byte)(0x36 ^ this.KeyValue[i]);
|
||||
this._outerPadding[i] = (byte)(0x5C ^ this.KeyValue[i]);
|
||||
}
|
||||
for (var i = this.KeyValue.Length; i < this.BlockSize; i++)
|
||||
{
|
||||
this._innerPadding[i] = 0x36;
|
||||
this._outerPadding[i] = 0x5C;
|
||||
}
|
||||
|
||||
this._hash.TransformBlock(this._innerPadding, 0, this.BlockSize, this._innerPadding, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases unmanaged and - optionally - managed resources
|
||||
/// </summary>
|
||||
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged ResourceMessages.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
if (this._hash != null)
|
||||
{
|
||||
this._hash.Clear();
|
||||
this._hash = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#if FEATURE_HMAC_MD5
|
||||
|
||||
using System.Linq;
|
||||
|
||||
namespace Renci.SshNet.Security.Cryptography
|
||||
{
|
||||
/// <summary>
|
||||
/// Computes a Hash-based Message Authentication Code (HMAC) by using the MD5 hash function.
|
||||
/// </summary>
|
||||
public class HMACMD5 : System.Security.Cryptography.HMACMD5
|
||||
{
|
||||
private readonly int _hashSize;
|
||||
|
||||
public HMACMD5(byte[] key)
|
||||
: base(key)
|
||||
{
|
||||
_hashSize = base.HashSize;
|
||||
}
|
||||
|
||||
public HMACMD5(byte[] key, int hashSize)
|
||||
: base(key)
|
||||
{
|
||||
_hashSize = hashSize;
|
||||
}
|
||||
|
||||
public override int HashSize
|
||||
{
|
||||
get { return _hashSize; }
|
||||
}
|
||||
|
||||
protected override byte[] HashFinal()
|
||||
{
|
||||
var hash = base.HashFinal();
|
||||
return hash.Take(HashSize / 8).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // FEATURE_HMAC_MD5
|
||||
@@ -0,0 +1,36 @@
|
||||
#if FEATURE_HMAC_SHA1
|
||||
|
||||
using System.Linq;
|
||||
|
||||
namespace Renci.SshNet.Security.Cryptography
|
||||
{
|
||||
public class HMACSHA1 : System.Security.Cryptography.HMACSHA1
|
||||
{
|
||||
private readonly int _hashSize;
|
||||
|
||||
public HMACSHA1(byte[] key)
|
||||
: base(key)
|
||||
{
|
||||
_hashSize = base.HashSize;
|
||||
}
|
||||
|
||||
public HMACSHA1(byte[] key, int hashSize)
|
||||
: base(key)
|
||||
{
|
||||
_hashSize = hashSize;
|
||||
}
|
||||
|
||||
public override int HashSize
|
||||
{
|
||||
get { return _hashSize; }
|
||||
}
|
||||
|
||||
protected override byte[] HashFinal()
|
||||
{
|
||||
var hash = base.HashFinal();
|
||||
return hash.Take(HashSize / 8).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // FEATURE_HMAC_SHA1
|
||||
@@ -0,0 +1,36 @@
|
||||
#if FEATURE_HMAC_SHA256
|
||||
|
||||
using System.Linq;
|
||||
|
||||
namespace Renci.SshNet.Security.Cryptography
|
||||
{
|
||||
public class HMACSHA256 : System.Security.Cryptography.HMACSHA256
|
||||
{
|
||||
private readonly int _hashSize;
|
||||
|
||||
public HMACSHA256(byte[] key)
|
||||
: base(key)
|
||||
{
|
||||
_hashSize = base.HashSize;
|
||||
}
|
||||
|
||||
public HMACSHA256(byte[] key, int hashSize)
|
||||
: base(key)
|
||||
{
|
||||
_hashSize = hashSize;
|
||||
}
|
||||
|
||||
public override int HashSize
|
||||
{
|
||||
get { return _hashSize; }
|
||||
}
|
||||
|
||||
protected override byte[] HashFinal()
|
||||
{
|
||||
var hash = base.HashFinal();
|
||||
return hash.Take(HashSize / 8).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // FEATURE_HMAC_SHA256
|
||||
@@ -0,0 +1,36 @@
|
||||
#if FEATURE_HMAC_SHA384
|
||||
|
||||
using System.Linq;
|
||||
|
||||
namespace Renci.SshNet.Security.Cryptography
|
||||
{
|
||||
public class HMACSHA384 : System.Security.Cryptography.HMACSHA384
|
||||
{
|
||||
private readonly int _hashSize;
|
||||
|
||||
public HMACSHA384(byte[] key)
|
||||
: base(key)
|
||||
{
|
||||
_hashSize = base.HashSize;
|
||||
}
|
||||
|
||||
public HMACSHA384(byte[] key, int hashSize)
|
||||
: base(key)
|
||||
{
|
||||
_hashSize = hashSize;
|
||||
}
|
||||
|
||||
public override int HashSize
|
||||
{
|
||||
get { return _hashSize; }
|
||||
}
|
||||
|
||||
protected override byte[] HashFinal()
|
||||
{
|
||||
var hash = base.HashFinal();
|
||||
return hash.Take(HashSize / 8).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // FEATURE_HMAC_SHA384
|
||||
@@ -0,0 +1,36 @@
|
||||
#if FEATURE_HMAC_SHA512
|
||||
|
||||
using System.Linq;
|
||||
|
||||
namespace Renci.SshNet.Security.Cryptography
|
||||
{
|
||||
public class HMACSHA512 : System.Security.Cryptography.HMACSHA512
|
||||
{
|
||||
private readonly int _hashSize;
|
||||
|
||||
public HMACSHA512(byte[] key)
|
||||
: base(key)
|
||||
{
|
||||
_hashSize = base.HashSize;
|
||||
}
|
||||
|
||||
public HMACSHA512(byte[] key, int hashSize)
|
||||
: base(key)
|
||||
{
|
||||
_hashSize = hashSize;
|
||||
}
|
||||
|
||||
public override int HashSize
|
||||
{
|
||||
get { return _hashSize; }
|
||||
}
|
||||
|
||||
protected override byte[] HashFinal()
|
||||
{
|
||||
var hash = base.HashFinal();
|
||||
return hash.Take(HashSize / 8).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // FEATURE_HMAC_SHA512
|
||||
@@ -0,0 +1,199 @@
|
||||
namespace Renci.SshNet.Security.Cryptography
|
||||
{
|
||||
internal static class HashAlgorithmFactory
|
||||
{
|
||||
#if FEATURE_HASH_MD5
|
||||
public static System.Security.Cryptography.MD5 CreateMD5()
|
||||
{
|
||||
return System.Security.Cryptography.MD5.Create();
|
||||
}
|
||||
#else
|
||||
public static Renci.Security.Cryptography.MD5 CreateMD5()
|
||||
{
|
||||
return new Renci.Security.Cryptography.MD5();
|
||||
}
|
||||
#endif // FEATURE_HASH_MD5
|
||||
|
||||
#if FEATURE_HASH_SHA1
|
||||
public static System.Security.Cryptography.SHA1 CreateSHA1()
|
||||
{
|
||||
return new System.Security.Cryptography.SHA1Managed();
|
||||
}
|
||||
#else
|
||||
public static Renci.Security.Cryptography.SHA1 CreateSHA1()
|
||||
{
|
||||
return new Renci.Security.Cryptography.SHA1();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if FEATURE_HASH_SHA256
|
||||
public static System.Security.Cryptography.SHA256 CreateSHA256()
|
||||
{
|
||||
return new System.Security.Cryptography.SHA256Managed();
|
||||
}
|
||||
#else
|
||||
public static Renci.Security.Cryptography.SHA256 CreateSHA256()
|
||||
{
|
||||
return new Renci.Security.Cryptography.SHA256();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if FEATURE_HASH_SHA384
|
||||
public static System.Security.Cryptography.SHA384 CreateSHA384()
|
||||
{
|
||||
return new System.Security.Cryptography.SHA384Managed();
|
||||
}
|
||||
#else
|
||||
public static Renci.Security.Cryptography.SHA384 CreateSHA384()
|
||||
{
|
||||
return new Renci.Security.Cryptography.SHA384();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if FEATURE_HASH_SHA512
|
||||
public static System.Security.Cryptography.SHA512 CreateSHA512()
|
||||
{
|
||||
return new System.Security.Cryptography.SHA512Managed();
|
||||
}
|
||||
#else
|
||||
public static Renci.Security.Cryptography.SHA512 CreateSHA512()
|
||||
{
|
||||
return new Renci.Security.Cryptography.SHA512();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if FEATURE_HASH_RIPEMD160
|
||||
public static System.Security.Cryptography.RIPEMD160 CreateRIPEMD160()
|
||||
{
|
||||
return new System.Security.Cryptography.RIPEMD160Managed();
|
||||
}
|
||||
#else
|
||||
public static Renci.Security.Cryptography.RIPEMD160 CreateRIPEMD160()
|
||||
{
|
||||
return new Renci.Security.Cryptography.RIPEMD160();
|
||||
}
|
||||
#endif // FEATURE_HASH_RIPEMD160
|
||||
|
||||
#if FEATURE_HMAC_MD5
|
||||
public static System.Security.Cryptography.HMACMD5 CreateHMACMD5(byte[] key)
|
||||
{
|
||||
return new System.Security.Cryptography.HMACMD5(key);
|
||||
}
|
||||
|
||||
public static HMACMD5 CreateHMACMD5(byte[] key, int hashSize)
|
||||
{
|
||||
return new HMACMD5(key, hashSize);
|
||||
}
|
||||
#else
|
||||
public static Renci.Security.Cryptography.HMACMD5 CreateHMACMD5(byte[] key)
|
||||
{
|
||||
return new Renci.Security.Cryptography.HMACMD5(key);
|
||||
}
|
||||
|
||||
public static Renci.Security.Cryptography.HMACMD5 CreateHMACMD5(byte[] key, int hashSize)
|
||||
{
|
||||
return new Renci.Security.Cryptography.HMACMD5(key, hashSize);
|
||||
}
|
||||
#endif // FEATURE_HMAC_MD5
|
||||
|
||||
#if FEATURE_HMAC_SHA1
|
||||
public static System.Security.Cryptography.HMACSHA1 CreateHMACSHA1(byte[] key)
|
||||
{
|
||||
return new System.Security.Cryptography.HMACSHA1(key);
|
||||
}
|
||||
|
||||
public static HMACSHA1 CreateHMACSHA1(byte[] key, int hashSize)
|
||||
{
|
||||
return new HMACSHA1(key, hashSize);
|
||||
}
|
||||
#else
|
||||
public static Renci.Security.Cryptography.HMACSHA1 CreateHMACSHA1(byte[] key)
|
||||
{
|
||||
return new Renci.Security.Cryptography.HMACSHA1(key);
|
||||
}
|
||||
|
||||
public static Renci.Security.Cryptography.HMACSHA1 CreateHMACSHA1(byte[] key, int hashSize)
|
||||
{
|
||||
return new Renci.Security.Cryptography.HMACSHA1(key, hashSize);
|
||||
}
|
||||
#endif // FEATURE_HMAC_SHA1
|
||||
|
||||
#if FEATURE_HMAC_SHA256
|
||||
public static System.Security.Cryptography.HMACSHA256 CreateHMACSHA256(byte[] key)
|
||||
{
|
||||
return new System.Security.Cryptography.HMACSHA256(key);
|
||||
}
|
||||
|
||||
public static HMACSHA256 CreateHMACSHA256(byte[] key, int hashSize)
|
||||
{
|
||||
return new HMACSHA256(key, hashSize);
|
||||
}
|
||||
#else
|
||||
public static Renci.Security.Cryptography.HMACSHA256 CreateHMACSHA256(byte[] key)
|
||||
{
|
||||
return new Renci.Security.Cryptography.HMACSHA256(key);
|
||||
}
|
||||
|
||||
public static Renci.Security.Cryptography.HMACSHA256 CreateHMACSHA256(byte[] key, int hashSize)
|
||||
{
|
||||
return new Renci.Security.Cryptography.HMACSHA256(key, hashSize);
|
||||
}
|
||||
#endif // FEATURE_HMAC_SHA256
|
||||
|
||||
#if FEATURE_HMAC_SHA384
|
||||
public static System.Security.Cryptography.HMACSHA384 CreateHMACSHA384(byte[] key)
|
||||
{
|
||||
return new System.Security.Cryptography.HMACSHA384(key);
|
||||
}
|
||||
|
||||
public static HMACSHA384 CreateHMACSHA384(byte[] key, int hashSize)
|
||||
{
|
||||
return new HMACSHA384(key, hashSize);
|
||||
}
|
||||
#else
|
||||
public static Renci.Security.Cryptography.HMACSHA384 CreateHMACSHA384(byte[] key)
|
||||
{
|
||||
return new Renci.Security.Cryptography.HMACSHA384(key);
|
||||
}
|
||||
|
||||
public static Renci.Security.Cryptography.HMACSHA384 CreateHMACSHA384(byte[] key, int hashSize)
|
||||
{
|
||||
return new Renci.Security.Cryptography.HMACSHA384(key, hashSize);
|
||||
}
|
||||
#endif // FEATURE_HMAC_SHA384
|
||||
|
||||
#if FEATURE_HMAC_SHA512
|
||||
public static System.Security.Cryptography.HMACSHA512 CreateHMACSHA512(byte[] key)
|
||||
{
|
||||
return new System.Security.Cryptography.HMACSHA512(key);
|
||||
}
|
||||
|
||||
public static HMACSHA512 CreateHMACSHA512(byte[] key, int hashSize)
|
||||
{
|
||||
return new HMACSHA512(key, hashSize);
|
||||
}
|
||||
#else
|
||||
public static Renci.Security.Cryptography.HMACSHA512 CreateHMACSHA512(byte[] key)
|
||||
{
|
||||
return new Renci.Security.Cryptography.HMACSHA512(key);
|
||||
}
|
||||
|
||||
public static Renci.Security.Cryptography.HMACSHA512 CreateHMACSHA512(byte[] key, int hashSize)
|
||||
{
|
||||
return new Renci.Security.Cryptography.HMACSHA512(key, hashSize);
|
||||
}
|
||||
#endif // FEATURE_HMAC_SHA512
|
||||
|
||||
#if FEATURE_HMAC_RIPEMD160
|
||||
public static System.Security.Cryptography.HMACRIPEMD160 CreateHMACRIPEMD160(byte[] key)
|
||||
{
|
||||
return new System.Security.Cryptography.HMACRIPEMD160(key);
|
||||
}
|
||||
#else
|
||||
public static Renci.Security.Cryptography.HMACRIPEMD160 CreateHMACRIPEMD160(byte[] key)
|
||||
{
|
||||
return new Renci.Security.Cryptography.HMACRIPEMD160(key);
|
||||
}
|
||||
#endif // FEATURE_HMAC_RIPEMD160
|
||||
}
|
||||
}
|
||||
@@ -1,385 +0,0 @@
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Renci.SshNet.Security.Cryptography
|
||||
{
|
||||
/// <summary>
|
||||
/// MD5 algorithm implementation
|
||||
/// </summary>
|
||||
public sealed class MD5Hash : HashAlgorithm
|
||||
{
|
||||
private readonly byte[] _buffer = new byte[4];
|
||||
private int _bufferOffset;
|
||||
private long _byteCount;
|
||||
private int H1, H2, H3, H4; // IV's
|
||||
private readonly int[] _hashValue = new int[16];
|
||||
private int _offset;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the size, in bits, of the computed hash code.
|
||||
/// </summary>
|
||||
/// <returns>The size, in bits, of the computed hash code.</returns>
|
||||
public override int HashSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return 128;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the input block size.
|
||||
/// </summary>
|
||||
/// <returns>The input block size.</returns>
|
||||
public override int InputBlockSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the output block size.
|
||||
/// </summary>
|
||||
/// <returns>The output block size.</returns>
|
||||
public override int OutputBlockSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current transform can be reused.
|
||||
/// </summary>
|
||||
/// <returns>Always true.</returns>
|
||||
public override bool CanReuseTransform
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether multiple blocks can be transformed.
|
||||
/// </summary>
|
||||
/// <returns>true if multiple blocks can be transformed; otherwise, false.</returns>
|
||||
public override bool CanTransformMultipleBlocks
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MD5Hash"/> class.
|
||||
/// </summary>
|
||||
public MD5Hash()
|
||||
{
|
||||
this.InternalInitialize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Routes data written to the object into the hash algorithm for computing the hash.
|
||||
/// </summary>
|
||||
/// <param name="array">The input to compute the hash code for.</param>
|
||||
/// <param name="ibStart">The offset into the byte array from which to begin using data.</param>
|
||||
/// <param name="cbSize">The number of bytes in the byte array to use as data.</param>
|
||||
protected override void HashCore(byte[] array, int ibStart, int cbSize)
|
||||
{
|
||||
// Fill the current word
|
||||
while ((this._bufferOffset != 0) && (cbSize > 0))
|
||||
{
|
||||
this.Update(array[ibStart]);
|
||||
ibStart++;
|
||||
cbSize--;
|
||||
}
|
||||
|
||||
// Process whole words.
|
||||
while (cbSize > this._buffer.Length)
|
||||
{
|
||||
this.ProcessWord(array, ibStart);
|
||||
|
||||
ibStart += this._buffer.Length;
|
||||
cbSize -= this._buffer.Length;
|
||||
this._byteCount += this._buffer.Length;
|
||||
}
|
||||
|
||||
// Load in the remainder.
|
||||
while (cbSize > 0)
|
||||
{
|
||||
this.Update(array[ibStart]);
|
||||
|
||||
ibStart++;
|
||||
cbSize--;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finalizes the hash computation after the last data is processed by the cryptographic stream object.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The computed hash code.
|
||||
/// </returns>
|
||||
protected override byte[] HashFinal()
|
||||
{
|
||||
long bitLength = (this._byteCount << 3);
|
||||
|
||||
// Add the pad bytes.
|
||||
this.Update((byte)128);
|
||||
|
||||
while (this._bufferOffset != 0)
|
||||
this.Update((byte)0);
|
||||
|
||||
if (this._offset > 14)
|
||||
{
|
||||
this.ProcessBlock();
|
||||
}
|
||||
|
||||
this._hashValue[14] = (int)(bitLength & 0xffffffff);
|
||||
this._hashValue[15] = (int)((ulong)bitLength >> 32);
|
||||
|
||||
this.ProcessBlock();
|
||||
|
||||
var output = new byte[16];
|
||||
|
||||
this.UnpackWord(H1, output, 0);
|
||||
this.UnpackWord(H2, output, 0 + 4);
|
||||
this.UnpackWord(H3, output, 0 + 8);
|
||||
this.UnpackWord(H4, output, 0 + 12);
|
||||
|
||||
this.Initialize();
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes an implementation of the <see cref="T:System.Security.Cryptography.HashAlgorithm"/> class.
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
this.InternalInitialize();
|
||||
}
|
||||
|
||||
private void InternalInitialize()
|
||||
{
|
||||
this._byteCount = 0;
|
||||
this._bufferOffset = 0;
|
||||
for (var i = 0; i < 4; i++)
|
||||
{
|
||||
this._buffer[i] = 0;
|
||||
}
|
||||
|
||||
H1 = unchecked((int)0x67452301);
|
||||
H2 = unchecked((int)0xefcdab89);
|
||||
H3 = unchecked((int)0x98badcfe);
|
||||
H4 = unchecked((int)0x10325476);
|
||||
|
||||
this._offset = 0;
|
||||
for (var i = 0; i != this._hashValue.Length; i++)
|
||||
{
|
||||
this._hashValue[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update(byte input)
|
||||
{
|
||||
this._buffer[this._bufferOffset++] = input;
|
||||
|
||||
if (this._bufferOffset == this._buffer.Length)
|
||||
{
|
||||
this.ProcessWord(this._buffer, 0);
|
||||
this._bufferOffset = 0;
|
||||
}
|
||||
|
||||
this._byteCount++;
|
||||
}
|
||||
|
||||
private void ProcessWord(byte[] input, int inOff)
|
||||
{
|
||||
this._hashValue[this._offset++] = (input[inOff] & 0xff) | ((input[inOff + 1] & 0xff) << 8)
|
||||
| ((input[inOff + 2] & 0xff) << 16) | ((input[inOff + 3] & 0xff) << 24);
|
||||
|
||||
if (this._offset == 16)
|
||||
{
|
||||
ProcessBlock();
|
||||
}
|
||||
}
|
||||
|
||||
private void UnpackWord(int word, byte[] outBytes, int outOff)
|
||||
{
|
||||
outBytes[outOff] = (byte)word;
|
||||
outBytes[outOff + 1] = (byte)((uint)word >> 8);
|
||||
outBytes[outOff + 2] = (byte)((uint)word >> 16);
|
||||
outBytes[outOff + 3] = (byte)((uint)word >> 24);
|
||||
}
|
||||
|
||||
//
|
||||
// round 1 left rotates
|
||||
//
|
||||
private const int S11 = 7;
|
||||
private const int S12 = 12;
|
||||
private const int S13 = 17;
|
||||
private const int S14 = 22;
|
||||
|
||||
//
|
||||
// round 2 left rotates
|
||||
//
|
||||
private const int S21 = 5;
|
||||
private const int S22 = 9;
|
||||
private const int S23 = 14;
|
||||
private const int S24 = 20;
|
||||
|
||||
//
|
||||
// round 3 left rotates
|
||||
//
|
||||
private const int S31 = 4;
|
||||
private const int S32 = 11;
|
||||
private const int S33 = 16;
|
||||
private const int S34 = 23;
|
||||
|
||||
//
|
||||
// round 4 left rotates
|
||||
//
|
||||
private const int S41 = 6;
|
||||
private const int S42 = 10;
|
||||
private const int S43 = 15;
|
||||
private const int S44 = 21;
|
||||
|
||||
/*
|
||||
* rotate int x left n bits.
|
||||
*/
|
||||
private static int RotateLeft(int x, int n)
|
||||
{
|
||||
return (x << n) | (int)((uint)x >> (32 - n));
|
||||
}
|
||||
|
||||
/*
|
||||
* F, G, H and I are the basic MD5 functions.
|
||||
*/
|
||||
private static int F(int u, int v, int w)
|
||||
{
|
||||
return (u & v) | (~u & w);
|
||||
}
|
||||
|
||||
private static int G(int u, int v, int w)
|
||||
{
|
||||
return (u & w) | (v & ~w);
|
||||
}
|
||||
|
||||
private static int H(int u, int v, int w)
|
||||
{
|
||||
return u ^ v ^ w;
|
||||
}
|
||||
|
||||
private static int K(int u, int v, int w)
|
||||
{
|
||||
return v ^ (u | ~w);
|
||||
}
|
||||
|
||||
private void ProcessBlock()
|
||||
{
|
||||
int a = H1;
|
||||
int b = H2;
|
||||
int c = H3;
|
||||
int d = H4;
|
||||
|
||||
//
|
||||
// Round 1 - F cycle, 16 times.
|
||||
//
|
||||
a = RotateLeft((a + F(b, c, d) + this._hashValue[0] + unchecked((int)0xd76aa478)), S11) + b;
|
||||
d = RotateLeft((d + F(a, b, c) + this._hashValue[1] + unchecked((int)0xe8c7b756)), S12) + a;
|
||||
c = RotateLeft((c + F(d, a, b) + this._hashValue[2] + unchecked((int)0x242070db)), S13) + d;
|
||||
b = RotateLeft((b + F(c, d, a) + this._hashValue[3] + unchecked((int)0xc1bdceee)), S14) + c;
|
||||
a = RotateLeft((a + F(b, c, d) + this._hashValue[4] + unchecked((int)0xf57c0faf)), S11) + b;
|
||||
d = RotateLeft((d + F(a, b, c) + this._hashValue[5] + unchecked((int)0x4787c62a)), S12) + a;
|
||||
c = RotateLeft((c + F(d, a, b) + this._hashValue[6] + unchecked((int)0xa8304613)), S13) + d;
|
||||
b = RotateLeft((b + F(c, d, a) + this._hashValue[7] + unchecked((int)0xfd469501)), S14) + c;
|
||||
a = RotateLeft((a + F(b, c, d) + this._hashValue[8] + unchecked((int)0x698098d8)), S11) + b;
|
||||
d = RotateLeft((d + F(a, b, c) + this._hashValue[9] + unchecked((int)0x8b44f7af)), S12) + a;
|
||||
c = RotateLeft((c + F(d, a, b) + this._hashValue[10] + unchecked((int)0xffff5bb1)), S13) + d;
|
||||
b = RotateLeft((b + F(c, d, a) + this._hashValue[11] + unchecked((int)0x895cd7be)), S14) + c;
|
||||
a = RotateLeft((a + F(b, c, d) + this._hashValue[12] + unchecked((int)0x6b901122)), S11) + b;
|
||||
d = RotateLeft((d + F(a, b, c) + this._hashValue[13] + unchecked((int)0xfd987193)), S12) + a;
|
||||
c = RotateLeft((c + F(d, a, b) + this._hashValue[14] + unchecked((int)0xa679438e)), S13) + d;
|
||||
b = RotateLeft((b + F(c, d, a) + this._hashValue[15] + unchecked((int)0x49b40821)), S14) + c;
|
||||
|
||||
//
|
||||
// Round 2 - G cycle, 16 times.
|
||||
//
|
||||
a = RotateLeft((a + G(b, c, d) + this._hashValue[1] + unchecked((int)0xf61e2562)), S21) + b;
|
||||
d = RotateLeft((d + G(a, b, c) + this._hashValue[6] + unchecked((int)0xc040b340)), S22) + a;
|
||||
c = RotateLeft((c + G(d, a, b) + this._hashValue[11] + unchecked((int)0x265e5a51)), S23) + d;
|
||||
b = RotateLeft((b + G(c, d, a) + this._hashValue[0] + unchecked((int)0xe9b6c7aa)), S24) + c;
|
||||
a = RotateLeft((a + G(b, c, d) + this._hashValue[5] + unchecked((int)0xd62f105d)), S21) + b;
|
||||
d = RotateLeft((d + G(a, b, c) + this._hashValue[10] + unchecked((int)0x02441453)), S22) + a;
|
||||
c = RotateLeft((c + G(d, a, b) + this._hashValue[15] + unchecked((int)0xd8a1e681)), S23) + d;
|
||||
b = RotateLeft((b + G(c, d, a) + this._hashValue[4] + unchecked((int)0xe7d3fbc8)), S24) + c;
|
||||
a = RotateLeft((a + G(b, c, d) + this._hashValue[9] + unchecked((int)0x21e1cde6)), S21) + b;
|
||||
d = RotateLeft((d + G(a, b, c) + this._hashValue[14] + unchecked((int)0xc33707d6)), S22) + a;
|
||||
c = RotateLeft((c + G(d, a, b) + this._hashValue[3] + unchecked((int)0xf4d50d87)), S23) + d;
|
||||
b = RotateLeft((b + G(c, d, a) + this._hashValue[8] + unchecked((int)0x455a14ed)), S24) + c;
|
||||
a = RotateLeft((a + G(b, c, d) + this._hashValue[13] + unchecked((int)0xa9e3e905)), S21) + b;
|
||||
d = RotateLeft((d + G(a, b, c) + this._hashValue[2] + unchecked((int)0xfcefa3f8)), S22) + a;
|
||||
c = RotateLeft((c + G(d, a, b) + this._hashValue[7] + unchecked((int)0x676f02d9)), S23) + d;
|
||||
b = RotateLeft((b + G(c, d, a) + this._hashValue[12] + unchecked((int)0x8d2a4c8a)), S24) + c;
|
||||
|
||||
//
|
||||
// Round 3 - H cycle, 16 times.
|
||||
//
|
||||
a = RotateLeft((a + H(b, c, d) + this._hashValue[5] + unchecked((int)0xfffa3942)), S31) + b;
|
||||
d = RotateLeft((d + H(a, b, c) + this._hashValue[8] + unchecked((int)0x8771f681)), S32) + a;
|
||||
c = RotateLeft((c + H(d, a, b) + this._hashValue[11] + unchecked((int)0x6d9d6122)), S33) + d;
|
||||
b = RotateLeft((b + H(c, d, a) + this._hashValue[14] + unchecked((int)0xfde5380c)), S34) + c;
|
||||
a = RotateLeft((a + H(b, c, d) + this._hashValue[1] + unchecked((int)0xa4beea44)), S31) + b;
|
||||
d = RotateLeft((d + H(a, b, c) + this._hashValue[4] + unchecked((int)0x4bdecfa9)), S32) + a;
|
||||
c = RotateLeft((c + H(d, a, b) + this._hashValue[7] + unchecked((int)0xf6bb4b60)), S33) + d;
|
||||
b = RotateLeft((b + H(c, d, a) + this._hashValue[10] + unchecked((int)0xbebfbc70)), S34) + c;
|
||||
a = RotateLeft((a + H(b, c, d) + this._hashValue[13] + unchecked((int)0x289b7ec6)), S31) + b;
|
||||
d = RotateLeft((d + H(a, b, c) + this._hashValue[0] + unchecked((int)0xeaa127fa)), S32) + a;
|
||||
c = RotateLeft((c + H(d, a, b) + this._hashValue[3] + unchecked((int)0xd4ef3085)), S33) + d;
|
||||
b = RotateLeft((b + H(c, d, a) + this._hashValue[6] + unchecked((int)0x04881d05)), S34) + c;
|
||||
a = RotateLeft((a + H(b, c, d) + this._hashValue[9] + unchecked((int)0xd9d4d039)), S31) + b;
|
||||
d = RotateLeft((d + H(a, b, c) + this._hashValue[12] + unchecked((int)0xe6db99e5)), S32) + a;
|
||||
c = RotateLeft((c + H(d, a, b) + this._hashValue[15] + unchecked((int)0x1fa27cf8)), S33) + d;
|
||||
b = RotateLeft((b + H(c, d, a) + this._hashValue[2] + unchecked((int)0xc4ac5665)), S34) + c;
|
||||
|
||||
//
|
||||
// Round 4 - K cycle, 16 times.
|
||||
//
|
||||
a = RotateLeft((a + K(b, c, d) + this._hashValue[0] + unchecked((int)0xf4292244)), S41) + b;
|
||||
d = RotateLeft((d + K(a, b, c) + this._hashValue[7] + unchecked((int)0x432aff97)), S42) + a;
|
||||
c = RotateLeft((c + K(d, a, b) + this._hashValue[14] + unchecked((int)0xab9423a7)), S43) + d;
|
||||
b = RotateLeft((b + K(c, d, a) + this._hashValue[5] + unchecked((int)0xfc93a039)), S44) + c;
|
||||
a = RotateLeft((a + K(b, c, d) + this._hashValue[12] + unchecked((int)0x655b59c3)), S41) + b;
|
||||
d = RotateLeft((d + K(a, b, c) + this._hashValue[3] + unchecked((int)0x8f0ccc92)), S42) + a;
|
||||
c = RotateLeft((c + K(d, a, b) + this._hashValue[10] + unchecked((int)0xffeff47d)), S43) + d;
|
||||
b = RotateLeft((b + K(c, d, a) + this._hashValue[1] + unchecked((int)0x85845dd1)), S44) + c;
|
||||
a = RotateLeft((a + K(b, c, d) + this._hashValue[8] + unchecked((int)0x6fa87e4f)), S41) + b;
|
||||
d = RotateLeft((d + K(a, b, c) + this._hashValue[15] + unchecked((int)0xfe2ce6e0)), S42) + a;
|
||||
c = RotateLeft((c + K(d, a, b) + this._hashValue[6] + unchecked((int)0xa3014314)), S43) + d;
|
||||
b = RotateLeft((b + K(c, d, a) + this._hashValue[13] + unchecked((int)0x4e0811a1)), S44) + c;
|
||||
a = RotateLeft((a + K(b, c, d) + this._hashValue[4] + unchecked((int)0xf7537e82)), S41) + b;
|
||||
d = RotateLeft((d + K(a, b, c) + this._hashValue[11] + unchecked((int)0xbd3af235)), S42) + a;
|
||||
c = RotateLeft((c + K(d, a, b) + this._hashValue[2] + unchecked((int)0x2ad7d2bb)), S43) + d;
|
||||
b = RotateLeft((b + K(c, d, a) + this._hashValue[9] + unchecked((int)0xeb86d391)), S44) + c;
|
||||
|
||||
H1 += a;
|
||||
H2 += b;
|
||||
H3 += c;
|
||||
H4 += d;
|
||||
|
||||
//
|
||||
// reset the offset and clean out the word buffer.
|
||||
//
|
||||
this._offset = 0;
|
||||
for (int i = 0; i != this._hashValue.Length; i++)
|
||||
{
|
||||
this._hashValue[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,518 +0,0 @@
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Renci.SshNet.Security.Cryptography
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public sealed class RIPEMD160Hash : HashAlgorithm
|
||||
{
|
||||
private const int DIGEST_SIZE = 20;
|
||||
|
||||
private readonly byte[] _buffer;
|
||||
private int _bufferOffset;
|
||||
private long _byteCount;
|
||||
private int _offset;
|
||||
private int H0, H1, H2, H3, H4; // IV's
|
||||
private readonly int[] X = new int[16];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the size, in bits, of the computed hash code.
|
||||
/// </summary>
|
||||
/// <returns>The size, in bits, of the computed hash code.</returns>
|
||||
public override int HashSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return DIGEST_SIZE * 8;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the input block size.
|
||||
/// </summary>
|
||||
/// <returns>The input block size.</returns>
|
||||
public override int InputBlockSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the output block size.
|
||||
/// </summary>
|
||||
/// <returns>The output block size.</returns>
|
||||
public override int OutputBlockSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current transform can be reused.
|
||||
/// </summary>
|
||||
/// <returns>Always true.</returns>
|
||||
public override bool CanReuseTransform
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether multiple blocks can be transformed.
|
||||
/// </summary>
|
||||
/// <returns>true if multiple blocks can be transformed; otherwise, false.</returns>
|
||||
public override bool CanTransformMultipleBlocks
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void HashCore(byte[] array, int ibStart, int cbSize)
|
||||
{
|
||||
//
|
||||
// fill the current word
|
||||
//
|
||||
while ((this._bufferOffset != 0) && (cbSize > 0))
|
||||
{
|
||||
this.Update(array[ibStart]);
|
||||
ibStart++;
|
||||
cbSize--;
|
||||
}
|
||||
|
||||
//
|
||||
// process whole words.
|
||||
//
|
||||
while (cbSize > this._buffer.Length)
|
||||
{
|
||||
this.ProcessWord(array, ibStart);
|
||||
|
||||
ibStart += this._buffer.Length;
|
||||
cbSize -= this._buffer.Length;
|
||||
this._byteCount += this._buffer.Length;
|
||||
}
|
||||
|
||||
//
|
||||
// load in the remainder.
|
||||
//
|
||||
while (cbSize > 0)
|
||||
{
|
||||
this.Update(array[ibStart]);
|
||||
|
||||
ibStart++;
|
||||
cbSize--;
|
||||
}
|
||||
}
|
||||
|
||||
protected override byte[] HashFinal()
|
||||
{
|
||||
var output = new byte[DIGEST_SIZE];
|
||||
long bitLength = (this._byteCount << 3);
|
||||
|
||||
//
|
||||
// add the pad bytes.
|
||||
//
|
||||
this.Update((byte)128);
|
||||
|
||||
while (this._bufferOffset != 0)
|
||||
Update((byte)0);
|
||||
ProcessLength(bitLength);
|
||||
ProcessBlock();
|
||||
|
||||
UnpackWord(H0, output, 0);
|
||||
UnpackWord(H1, output, 4);
|
||||
UnpackWord(H2, output, 8);
|
||||
UnpackWord(H3, output, 12);
|
||||
UnpackWord(H4, output, 16);
|
||||
|
||||
this.InternalInitialize();
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes an implementation of the <see cref="T:System.Security.Cryptography.HashAlgorithm" /> class.
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
this.InternalInitialize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RIPEMD160Hash" /> class.
|
||||
/// </summary>
|
||||
public RIPEMD160Hash()
|
||||
{
|
||||
this._buffer = new byte[4];
|
||||
this.InternalInitialize();
|
||||
}
|
||||
|
||||
private void ProcessWord(byte[] input, int inOff)
|
||||
{
|
||||
this.X[this._offset++] = (input[inOff] & 0xff) | ((input[inOff + 1] & 0xff) << 8)
|
||||
| ((input[inOff + 2] & 0xff) << 16) | ((input[inOff + 3] & 0xff) << 24);
|
||||
|
||||
if (this._offset == 16)
|
||||
{
|
||||
ProcessBlock();
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessLength(long bitLength)
|
||||
{
|
||||
if (this._offset > 14)
|
||||
{
|
||||
ProcessBlock();
|
||||
}
|
||||
|
||||
this.X[14] = (int)(bitLength & 0xffffffff);
|
||||
this.X[15] = (int)((ulong)bitLength >> 32);
|
||||
}
|
||||
|
||||
private void UnpackWord(int word, byte[] outBytes, int outOff)
|
||||
{
|
||||
outBytes[outOff] = (byte)word;
|
||||
outBytes[outOff + 1] = (byte)((uint)word >> 8);
|
||||
outBytes[outOff + 2] = (byte)((uint)word >> 16);
|
||||
outBytes[outOff + 3] = (byte)((uint)word >> 24);
|
||||
}
|
||||
|
||||
private void Update(byte input)
|
||||
{
|
||||
this._buffer[this._bufferOffset++] = input;
|
||||
|
||||
if (this._bufferOffset == this._buffer.Length)
|
||||
{
|
||||
ProcessWord(this._buffer, 0);
|
||||
this._bufferOffset = 0;
|
||||
}
|
||||
|
||||
this._byteCount++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reset the chaining variables to the IV values.
|
||||
/// </summary>
|
||||
private void InternalInitialize()
|
||||
{
|
||||
this._byteCount = 0;
|
||||
this._bufferOffset = 0;
|
||||
for (int i = 0; i < _buffer.Length; i++)
|
||||
{
|
||||
this._buffer[i] = 0;
|
||||
}
|
||||
|
||||
H0 = unchecked((int)0x67452301);
|
||||
H1 = unchecked((int)0xefcdab89);
|
||||
H2 = unchecked((int)0x98badcfe);
|
||||
H3 = unchecked((int)0x10325476);
|
||||
H4 = unchecked((int)0xc3d2e1f0);
|
||||
|
||||
this._offset = 0;
|
||||
|
||||
for (int i = 0; i != X.Length; i++)
|
||||
{
|
||||
this.X[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private int RL(int x, int n)
|
||||
{
|
||||
return (x << n) | (int)((uint)x >> (32 - n));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rounds 0-15
|
||||
/// </summary>
|
||||
/// <param name="x">The x.</param>
|
||||
/// <param name="y">The y.</param>
|
||||
/// <param name="z">The z.</param>
|
||||
/// <returns></returns>
|
||||
private int F1(int x, int y, int z)
|
||||
{
|
||||
return x ^ y ^ z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rounds 16-31
|
||||
/// </summary>
|
||||
/// <param name="x">The x.</param>
|
||||
/// <param name="y">The y.</param>
|
||||
/// <param name="z">The z.</param>
|
||||
/// <returns></returns>
|
||||
private int F2(int x, int y, int z)
|
||||
{
|
||||
return (x & y) | (~x & z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ounds 32-47
|
||||
/// </summary>
|
||||
/// <param name="x">The x.</param>
|
||||
/// <param name="y">The y.</param>
|
||||
/// <param name="z">The z.</param>
|
||||
/// <returns></returns>
|
||||
private int F3(int x, int y, int z)
|
||||
{
|
||||
return (x | ~y) ^ z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rounds 48-63
|
||||
/// </summary>
|
||||
/// <param name="x">The x.</param>
|
||||
/// <param name="y">The y.</param>
|
||||
/// <param name="z">The z.</param>
|
||||
/// <returns></returns>
|
||||
private int F4(int x, int y, int z)
|
||||
{
|
||||
return (x & z) | (y & ~z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ounds 64-79
|
||||
/// </summary>
|
||||
/// <param name="x">The x.</param>
|
||||
/// <param name="y">The y.</param>
|
||||
/// <param name="z">The z.</param>
|
||||
/// <returns></returns>
|
||||
private int F5(int x, int y, int z)
|
||||
{
|
||||
return x ^ (y | ~z);
|
||||
}
|
||||
|
||||
private void ProcessBlock()
|
||||
{
|
||||
int a, aa;
|
||||
int b, bb;
|
||||
int c, cc;
|
||||
int d, dd;
|
||||
int e, ee;
|
||||
|
||||
a = aa = H0;
|
||||
b = bb = H1;
|
||||
c = cc = H2;
|
||||
d = dd = H3;
|
||||
e = ee = H4;
|
||||
|
||||
//
|
||||
// Rounds 1 - 16
|
||||
//
|
||||
// left
|
||||
a = RL(a + F1(b, c, d) + this.X[0], 11) + e; c = RL(c, 10);
|
||||
e = RL(e + F1(a, b, c) + this.X[1], 14) + d; b = RL(b, 10);
|
||||
d = RL(d + F1(e, a, b) + this.X[2], 15) + c; a = RL(a, 10);
|
||||
c = RL(c + F1(d, e, a) + this.X[3], 12) + b; e = RL(e, 10);
|
||||
b = RL(b + F1(c, d, e) + this.X[4], 5) + a; d = RL(d, 10);
|
||||
a = RL(a + F1(b, c, d) + this.X[5], 8) + e; c = RL(c, 10);
|
||||
e = RL(e + F1(a, b, c) + this.X[6], 7) + d; b = RL(b, 10);
|
||||
d = RL(d + F1(e, a, b) + this.X[7], 9) + c; a = RL(a, 10);
|
||||
c = RL(c + F1(d, e, a) + this.X[8], 11) + b; e = RL(e, 10);
|
||||
b = RL(b + F1(c, d, e) + this.X[9], 13) + a; d = RL(d, 10);
|
||||
a = RL(a + F1(b, c, d) + this.X[10], 14) + e; c = RL(c, 10);
|
||||
e = RL(e + F1(a, b, c) + this.X[11], 15) + d; b = RL(b, 10);
|
||||
d = RL(d + F1(e, a, b) + this.X[12], 6) + c; a = RL(a, 10);
|
||||
c = RL(c + F1(d, e, a) + this.X[13], 7) + b; e = RL(e, 10);
|
||||
b = RL(b + F1(c, d, e) + this.X[14], 9) + a; d = RL(d, 10);
|
||||
a = RL(a + F1(b, c, d) + this.X[15], 8) + e; c = RL(c, 10);
|
||||
|
||||
// right
|
||||
aa = RL(aa + F5(bb, cc, dd) + this.X[5] + unchecked((int)0x50a28be6), 8) + ee; cc = RL(cc, 10);
|
||||
ee = RL(ee + F5(aa, bb, cc) + this.X[14] + unchecked((int)0x50a28be6), 9) + dd; bb = RL(bb, 10);
|
||||
dd = RL(dd + F5(ee, aa, bb) + this.X[7] + unchecked((int)0x50a28be6), 9) + cc; aa = RL(aa, 10);
|
||||
cc = RL(cc + F5(dd, ee, aa) + this.X[0] + unchecked((int)0x50a28be6), 11) + bb; ee = RL(ee, 10);
|
||||
bb = RL(bb + F5(cc, dd, ee) + this.X[9] + unchecked((int)0x50a28be6), 13) + aa; dd = RL(dd, 10);
|
||||
aa = RL(aa + F5(bb, cc, dd) + this.X[2] + unchecked((int)0x50a28be6), 15) + ee; cc = RL(cc, 10);
|
||||
ee = RL(ee + F5(aa, bb, cc) + this.X[11] + unchecked((int)0x50a28be6), 15) + dd; bb = RL(bb, 10);
|
||||
dd = RL(dd + F5(ee, aa, bb) + this.X[4] + unchecked((int)0x50a28be6), 5) + cc; aa = RL(aa, 10);
|
||||
cc = RL(cc + F5(dd, ee, aa) + this.X[13] + unchecked((int)0x50a28be6), 7) + bb; ee = RL(ee, 10);
|
||||
bb = RL(bb + F5(cc, dd, ee) + this.X[6] + unchecked((int)0x50a28be6), 7) + aa; dd = RL(dd, 10);
|
||||
aa = RL(aa + F5(bb, cc, dd) + this.X[15] + unchecked((int)0x50a28be6), 8) + ee; cc = RL(cc, 10);
|
||||
ee = RL(ee + F5(aa, bb, cc) + this.X[8] + unchecked((int)0x50a28be6), 11) + dd; bb = RL(bb, 10);
|
||||
dd = RL(dd + F5(ee, aa, bb) + this.X[1] + unchecked((int)0x50a28be6), 14) + cc; aa = RL(aa, 10);
|
||||
cc = RL(cc + F5(dd, ee, aa) + this.X[10] + unchecked((int)0x50a28be6), 14) + bb; ee = RL(ee, 10);
|
||||
bb = RL(bb + F5(cc, dd, ee) + this.X[3] + unchecked((int)0x50a28be6), 12) + aa; dd = RL(dd, 10);
|
||||
aa = RL(aa + F5(bb, cc, dd) + this.X[12] + unchecked((int)0x50a28be6), 6) + ee; cc = RL(cc, 10);
|
||||
|
||||
//
|
||||
// Rounds 16-31
|
||||
//
|
||||
// left
|
||||
e = RL(e + F2(a, b, c) + this.X[7] + unchecked((int)0x5a827999), 7) + d; b = RL(b, 10);
|
||||
d = RL(d + F2(e, a, b) + this.X[4] + unchecked((int)0x5a827999), 6) + c; a = RL(a, 10);
|
||||
c = RL(c + F2(d, e, a) + this.X[13] + unchecked((int)0x5a827999), 8) + b; e = RL(e, 10);
|
||||
b = RL(b + F2(c, d, e) + this.X[1] + unchecked((int)0x5a827999), 13) + a; d = RL(d, 10);
|
||||
a = RL(a + F2(b, c, d) + this.X[10] + unchecked((int)0x5a827999), 11) + e; c = RL(c, 10);
|
||||
e = RL(e + F2(a, b, c) + this.X[6] + unchecked((int)0x5a827999), 9) + d; b = RL(b, 10);
|
||||
d = RL(d + F2(e, a, b) + this.X[15] + unchecked((int)0x5a827999), 7) + c; a = RL(a, 10);
|
||||
c = RL(c + F2(d, e, a) + this.X[3] + unchecked((int)0x5a827999), 15) + b; e = RL(e, 10);
|
||||
b = RL(b + F2(c, d, e) + this.X[12] + unchecked((int)0x5a827999), 7) + a; d = RL(d, 10);
|
||||
a = RL(a + F2(b, c, d) + this.X[0] + unchecked((int)0x5a827999), 12) + e; c = RL(c, 10);
|
||||
e = RL(e + F2(a, b, c) + this.X[9] + unchecked((int)0x5a827999), 15) + d; b = RL(b, 10);
|
||||
d = RL(d + F2(e, a, b) + this.X[5] + unchecked((int)0x5a827999), 9) + c; a = RL(a, 10);
|
||||
c = RL(c + F2(d, e, a) + this.X[2] + unchecked((int)0x5a827999), 11) + b; e = RL(e, 10);
|
||||
b = RL(b + F2(c, d, e) + this.X[14] + unchecked((int)0x5a827999), 7) + a; d = RL(d, 10);
|
||||
a = RL(a + F2(b, c, d) + this.X[11] + unchecked((int)0x5a827999), 13) + e; c = RL(c, 10);
|
||||
e = RL(e + F2(a, b, c) + this.X[8] + unchecked((int)0x5a827999), 12) + d; b = RL(b, 10);
|
||||
|
||||
// right
|
||||
ee = RL(ee + F4(aa, bb, cc) + this.X[6] + unchecked((int)0x5c4dd124), 9) + dd; bb = RL(bb, 10);
|
||||
dd = RL(dd + F4(ee, aa, bb) + this.X[11] + unchecked((int)0x5c4dd124), 13) + cc; aa = RL(aa, 10);
|
||||
cc = RL(cc + F4(dd, ee, aa) + this.X[3] + unchecked((int)0x5c4dd124), 15) + bb; ee = RL(ee, 10);
|
||||
bb = RL(bb + F4(cc, dd, ee) + this.X[7] + unchecked((int)0x5c4dd124), 7) + aa; dd = RL(dd, 10);
|
||||
aa = RL(aa + F4(bb, cc, dd) + this.X[0] + unchecked((int)0x5c4dd124), 12) + ee; cc = RL(cc, 10);
|
||||
ee = RL(ee + F4(aa, bb, cc) + this.X[13] + unchecked((int)0x5c4dd124), 8) + dd; bb = RL(bb, 10);
|
||||
dd = RL(dd + F4(ee, aa, bb) + this.X[5] + unchecked((int)0x5c4dd124), 9) + cc; aa = RL(aa, 10);
|
||||
cc = RL(cc + F4(dd, ee, aa) + this.X[10] + unchecked((int)0x5c4dd124), 11) + bb; ee = RL(ee, 10);
|
||||
bb = RL(bb + F4(cc, dd, ee) + this.X[14] + unchecked((int)0x5c4dd124), 7) + aa; dd = RL(dd, 10);
|
||||
aa = RL(aa + F4(bb, cc, dd) + this.X[15] + unchecked((int)0x5c4dd124), 7) + ee; cc = RL(cc, 10);
|
||||
ee = RL(ee + F4(aa, bb, cc) + this.X[8] + unchecked((int)0x5c4dd124), 12) + dd; bb = RL(bb, 10);
|
||||
dd = RL(dd + F4(ee, aa, bb) + this.X[12] + unchecked((int)0x5c4dd124), 7) + cc; aa = RL(aa, 10);
|
||||
cc = RL(cc + F4(dd, ee, aa) + this.X[4] + unchecked((int)0x5c4dd124), 6) + bb; ee = RL(ee, 10);
|
||||
bb = RL(bb + F4(cc, dd, ee) + this.X[9] + unchecked((int)0x5c4dd124), 15) + aa; dd = RL(dd, 10);
|
||||
aa = RL(aa + F4(bb, cc, dd) + this.X[1] + unchecked((int)0x5c4dd124), 13) + ee; cc = RL(cc, 10);
|
||||
ee = RL(ee + F4(aa, bb, cc) + this.X[2] + unchecked((int)0x5c4dd124), 11) + dd; bb = RL(bb, 10);
|
||||
|
||||
//
|
||||
// Rounds 32-47
|
||||
//
|
||||
// left
|
||||
d = RL(d + F3(e, a, b) + this.X[3] + unchecked((int)0x6ed9eba1), 11) + c; a = RL(a, 10);
|
||||
c = RL(c + F3(d, e, a) + this.X[10] + unchecked((int)0x6ed9eba1), 13) + b; e = RL(e, 10);
|
||||
b = RL(b + F3(c, d, e) + this.X[14] + unchecked((int)0x6ed9eba1), 6) + a; d = RL(d, 10);
|
||||
a = RL(a + F3(b, c, d) + this.X[4] + unchecked((int)0x6ed9eba1), 7) + e; c = RL(c, 10);
|
||||
e = RL(e + F3(a, b, c) + this.X[9] + unchecked((int)0x6ed9eba1), 14) + d; b = RL(b, 10);
|
||||
d = RL(d + F3(e, a, b) + this.X[15] + unchecked((int)0x6ed9eba1), 9) + c; a = RL(a, 10);
|
||||
c = RL(c + F3(d, e, a) + this.X[8] + unchecked((int)0x6ed9eba1), 13) + b; e = RL(e, 10);
|
||||
b = RL(b + F3(c, d, e) + this.X[1] + unchecked((int)0x6ed9eba1), 15) + a; d = RL(d, 10);
|
||||
a = RL(a + F3(b, c, d) + this.X[2] + unchecked((int)0x6ed9eba1), 14) + e; c = RL(c, 10);
|
||||
e = RL(e + F3(a, b, c) + this.X[7] + unchecked((int)0x6ed9eba1), 8) + d; b = RL(b, 10);
|
||||
d = RL(d + F3(e, a, b) + this.X[0] + unchecked((int)0x6ed9eba1), 13) + c; a = RL(a, 10);
|
||||
c = RL(c + F3(d, e, a) + this.X[6] + unchecked((int)0x6ed9eba1), 6) + b; e = RL(e, 10);
|
||||
b = RL(b + F3(c, d, e) + this.X[13] + unchecked((int)0x6ed9eba1), 5) + a; d = RL(d, 10);
|
||||
a = RL(a + F3(b, c, d) + this.X[11] + unchecked((int)0x6ed9eba1), 12) + e; c = RL(c, 10);
|
||||
e = RL(e + F3(a, b, c) + this.X[5] + unchecked((int)0x6ed9eba1), 7) + d; b = RL(b, 10);
|
||||
d = RL(d + F3(e, a, b) + this.X[12] + unchecked((int)0x6ed9eba1), 5) + c; a = RL(a, 10);
|
||||
|
||||
// right
|
||||
dd = RL(dd + F3(ee, aa, bb) + this.X[15] + unchecked((int)0x6d703ef3), 9) + cc; aa = RL(aa, 10);
|
||||
cc = RL(cc + F3(dd, ee, aa) + this.X[5] + unchecked((int)0x6d703ef3), 7) + bb; ee = RL(ee, 10);
|
||||
bb = RL(bb + F3(cc, dd, ee) + this.X[1] + unchecked((int)0x6d703ef3), 15) + aa; dd = RL(dd, 10);
|
||||
aa = RL(aa + F3(bb, cc, dd) + this.X[3] + unchecked((int)0x6d703ef3), 11) + ee; cc = RL(cc, 10);
|
||||
ee = RL(ee + F3(aa, bb, cc) + this.X[7] + unchecked((int)0x6d703ef3), 8) + dd; bb = RL(bb, 10);
|
||||
dd = RL(dd + F3(ee, aa, bb) + this.X[14] + unchecked((int)0x6d703ef3), 6) + cc; aa = RL(aa, 10);
|
||||
cc = RL(cc + F3(dd, ee, aa) + this.X[6] + unchecked((int)0x6d703ef3), 6) + bb; ee = RL(ee, 10);
|
||||
bb = RL(bb + F3(cc, dd, ee) + this.X[9] + unchecked((int)0x6d703ef3), 14) + aa; dd = RL(dd, 10);
|
||||
aa = RL(aa + F3(bb, cc, dd) + this.X[11] + unchecked((int)0x6d703ef3), 12) + ee; cc = RL(cc, 10);
|
||||
ee = RL(ee + F3(aa, bb, cc) + this.X[8] + unchecked((int)0x6d703ef3), 13) + dd; bb = RL(bb, 10);
|
||||
dd = RL(dd + F3(ee, aa, bb) + this.X[12] + unchecked((int)0x6d703ef3), 5) + cc; aa = RL(aa, 10);
|
||||
cc = RL(cc + F3(dd, ee, aa) + this.X[2] + unchecked((int)0x6d703ef3), 14) + bb; ee = RL(ee, 10);
|
||||
bb = RL(bb + F3(cc, dd, ee) + this.X[10] + unchecked((int)0x6d703ef3), 13) + aa; dd = RL(dd, 10);
|
||||
aa = RL(aa + F3(bb, cc, dd) + this.X[0] + unchecked((int)0x6d703ef3), 13) + ee; cc = RL(cc, 10);
|
||||
ee = RL(ee + F3(aa, bb, cc) + this.X[4] + unchecked((int)0x6d703ef3), 7) + dd; bb = RL(bb, 10);
|
||||
dd = RL(dd + F3(ee, aa, bb) + this.X[13] + unchecked((int)0x6d703ef3), 5) + cc; aa = RL(aa, 10);
|
||||
|
||||
//
|
||||
// Rounds 48-63
|
||||
//
|
||||
// left
|
||||
c = RL(c + F4(d, e, a) + this.X[1] + unchecked((int)0x8f1bbcdc), 11) + b; e = RL(e, 10);
|
||||
b = RL(b + F4(c, d, e) + this.X[9] + unchecked((int)0x8f1bbcdc), 12) + a; d = RL(d, 10);
|
||||
a = RL(a + F4(b, c, d) + this.X[11] + unchecked((int)0x8f1bbcdc), 14) + e; c = RL(c, 10);
|
||||
e = RL(e + F4(a, b, c) + this.X[10] + unchecked((int)0x8f1bbcdc), 15) + d; b = RL(b, 10);
|
||||
d = RL(d + F4(e, a, b) + this.X[0] + unchecked((int)0x8f1bbcdc), 14) + c; a = RL(a, 10);
|
||||
c = RL(c + F4(d, e, a) + this.X[8] + unchecked((int)0x8f1bbcdc), 15) + b; e = RL(e, 10);
|
||||
b = RL(b + F4(c, d, e) + this.X[12] + unchecked((int)0x8f1bbcdc), 9) + a; d = RL(d, 10);
|
||||
a = RL(a + F4(b, c, d) + this.X[4] + unchecked((int)0x8f1bbcdc), 8) + e; c = RL(c, 10);
|
||||
e = RL(e + F4(a, b, c) + this.X[13] + unchecked((int)0x8f1bbcdc), 9) + d; b = RL(b, 10);
|
||||
d = RL(d + F4(e, a, b) + this.X[3] + unchecked((int)0x8f1bbcdc), 14) + c; a = RL(a, 10);
|
||||
c = RL(c + F4(d, e, a) + this.X[7] + unchecked((int)0x8f1bbcdc), 5) + b; e = RL(e, 10);
|
||||
b = RL(b + F4(c, d, e) + this.X[15] + unchecked((int)0x8f1bbcdc), 6) + a; d = RL(d, 10);
|
||||
a = RL(a + F4(b, c, d) + this.X[14] + unchecked((int)0x8f1bbcdc), 8) + e; c = RL(c, 10);
|
||||
e = RL(e + F4(a, b, c) + this.X[5] + unchecked((int)0x8f1bbcdc), 6) + d; b = RL(b, 10);
|
||||
d = RL(d + F4(e, a, b) + this.X[6] + unchecked((int)0x8f1bbcdc), 5) + c; a = RL(a, 10);
|
||||
c = RL(c + F4(d, e, a) + this.X[2] + unchecked((int)0x8f1bbcdc), 12) + b; e = RL(e, 10);
|
||||
|
||||
// right
|
||||
cc = RL(cc + F2(dd, ee, aa) + this.X[8] + unchecked((int)0x7a6d76e9), 15) + bb; ee = RL(ee, 10);
|
||||
bb = RL(bb + F2(cc, dd, ee) + this.X[6] + unchecked((int)0x7a6d76e9), 5) + aa; dd = RL(dd, 10);
|
||||
aa = RL(aa + F2(bb, cc, dd) + this.X[4] + unchecked((int)0x7a6d76e9), 8) + ee; cc = RL(cc, 10);
|
||||
ee = RL(ee + F2(aa, bb, cc) + this.X[1] + unchecked((int)0x7a6d76e9), 11) + dd; bb = RL(bb, 10);
|
||||
dd = RL(dd + F2(ee, aa, bb) + this.X[3] + unchecked((int)0x7a6d76e9), 14) + cc; aa = RL(aa, 10);
|
||||
cc = RL(cc + F2(dd, ee, aa) + this.X[11] + unchecked((int)0x7a6d76e9), 14) + bb; ee = RL(ee, 10);
|
||||
bb = RL(bb + F2(cc, dd, ee) + this.X[15] + unchecked((int)0x7a6d76e9), 6) + aa; dd = RL(dd, 10);
|
||||
aa = RL(aa + F2(bb, cc, dd) + this.X[0] + unchecked((int)0x7a6d76e9), 14) + ee; cc = RL(cc, 10);
|
||||
ee = RL(ee + F2(aa, bb, cc) + this.X[5] + unchecked((int)0x7a6d76e9), 6) + dd; bb = RL(bb, 10);
|
||||
dd = RL(dd + F2(ee, aa, bb) + this.X[12] + unchecked((int)0x7a6d76e9), 9) + cc; aa = RL(aa, 10);
|
||||
cc = RL(cc + F2(dd, ee, aa) + this.X[2] + unchecked((int)0x7a6d76e9), 12) + bb; ee = RL(ee, 10);
|
||||
bb = RL(bb + F2(cc, dd, ee) + this.X[13] + unchecked((int)0x7a6d76e9), 9) + aa; dd = RL(dd, 10);
|
||||
aa = RL(aa + F2(bb, cc, dd) + this.X[9] + unchecked((int)0x7a6d76e9), 12) + ee; cc = RL(cc, 10);
|
||||
ee = RL(ee + F2(aa, bb, cc) + this.X[7] + unchecked((int)0x7a6d76e9), 5) + dd; bb = RL(bb, 10);
|
||||
dd = RL(dd + F2(ee, aa, bb) + this.X[10] + unchecked((int)0x7a6d76e9), 15) + cc; aa = RL(aa, 10);
|
||||
cc = RL(cc + F2(dd, ee, aa) + this.X[14] + unchecked((int)0x7a6d76e9), 8) + bb; ee = RL(ee, 10);
|
||||
|
||||
//
|
||||
// Rounds 64-79
|
||||
//
|
||||
// left
|
||||
b = RL(b + F5(c, d, e) + this.X[4] + unchecked((int)0xa953fd4e), 9) + a; d = RL(d, 10);
|
||||
a = RL(a + F5(b, c, d) + this.X[0] + unchecked((int)0xa953fd4e), 15) + e; c = RL(c, 10);
|
||||
e = RL(e + F5(a, b, c) + this.X[5] + unchecked((int)0xa953fd4e), 5) + d; b = RL(b, 10);
|
||||
d = RL(d + F5(e, a, b) + this.X[9] + unchecked((int)0xa953fd4e), 11) + c; a = RL(a, 10);
|
||||
c = RL(c + F5(d, e, a) + this.X[7] + unchecked((int)0xa953fd4e), 6) + b; e = RL(e, 10);
|
||||
b = RL(b + F5(c, d, e) + this.X[12] + unchecked((int)0xa953fd4e), 8) + a; d = RL(d, 10);
|
||||
a = RL(a + F5(b, c, d) + this.X[2] + unchecked((int)0xa953fd4e), 13) + e; c = RL(c, 10);
|
||||
e = RL(e + F5(a, b, c) + this.X[10] + unchecked((int)0xa953fd4e), 12) + d; b = RL(b, 10);
|
||||
d = RL(d + F5(e, a, b) + this.X[14] + unchecked((int)0xa953fd4e), 5) + c; a = RL(a, 10);
|
||||
c = RL(c + F5(d, e, a) + this.X[1] + unchecked((int)0xa953fd4e), 12) + b; e = RL(e, 10);
|
||||
b = RL(b + F5(c, d, e) + this.X[3] + unchecked((int)0xa953fd4e), 13) + a; d = RL(d, 10);
|
||||
a = RL(a + F5(b, c, d) + this.X[8] + unchecked((int)0xa953fd4e), 14) + e; c = RL(c, 10);
|
||||
e = RL(e + F5(a, b, c) + this.X[11] + unchecked((int)0xa953fd4e), 11) + d; b = RL(b, 10);
|
||||
d = RL(d + F5(e, a, b) + this.X[6] + unchecked((int)0xa953fd4e), 8) + c; a = RL(a, 10);
|
||||
c = RL(c + F5(d, e, a) + this.X[15] + unchecked((int)0xa953fd4e), 5) + b; e = RL(e, 10);
|
||||
b = RL(b + F5(c, d, e) + this.X[13] + unchecked((int)0xa953fd4e), 6) + a; d = RL(d, 10);
|
||||
|
||||
// right
|
||||
bb = RL(bb + F1(cc, dd, ee) + this.X[12], 8) + aa; dd = RL(dd, 10);
|
||||
aa = RL(aa + F1(bb, cc, dd) + this.X[15], 5) + ee; cc = RL(cc, 10);
|
||||
ee = RL(ee + F1(aa, bb, cc) + this.X[10], 12) + dd; bb = RL(bb, 10);
|
||||
dd = RL(dd + F1(ee, aa, bb) + this.X[4], 9) + cc; aa = RL(aa, 10);
|
||||
cc = RL(cc + F1(dd, ee, aa) + this.X[1], 12) + bb; ee = RL(ee, 10);
|
||||
bb = RL(bb + F1(cc, dd, ee) + this.X[5], 5) + aa; dd = RL(dd, 10);
|
||||
aa = RL(aa + F1(bb, cc, dd) + this.X[8], 14) + ee; cc = RL(cc, 10);
|
||||
ee = RL(ee + F1(aa, bb, cc) + this.X[7], 6) + dd; bb = RL(bb, 10);
|
||||
dd = RL(dd + F1(ee, aa, bb) + this.X[6], 8) + cc; aa = RL(aa, 10);
|
||||
cc = RL(cc + F1(dd, ee, aa) + this.X[2], 13) + bb; ee = RL(ee, 10);
|
||||
bb = RL(bb + F1(cc, dd, ee) + this.X[13], 6) + aa; dd = RL(dd, 10);
|
||||
aa = RL(aa + F1(bb, cc, dd) + this.X[14], 5) + ee; cc = RL(cc, 10);
|
||||
ee = RL(ee + F1(aa, bb, cc) + this.X[0], 15) + dd; bb = RL(bb, 10);
|
||||
dd = RL(dd + F1(ee, aa, bb) + this.X[3], 13) + cc; aa = RL(aa, 10);
|
||||
cc = RL(cc + F1(dd, ee, aa) + this.X[9], 11) + bb; ee = RL(ee, 10);
|
||||
bb = RL(bb + F1(cc, dd, ee) + this.X[11], 11) + aa; dd = RL(dd, 10);
|
||||
|
||||
dd += c + H1;
|
||||
H1 = H2 + d + ee;
|
||||
H2 = H3 + e + aa;
|
||||
H3 = H4 + a + bb;
|
||||
H4 = H0 + b + cc;
|
||||
H0 = dd;
|
||||
|
||||
//
|
||||
// reset the offset and clean out the word buffer.
|
||||
//
|
||||
this._offset = 0;
|
||||
for (int i = 0; i < X.Length; i++)
|
||||
{
|
||||
this.X[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,571 +0,0 @@
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Renci.SshNet.Security.Cryptography
|
||||
{
|
||||
/// <summary>
|
||||
/// SHA1 algorithm implementation
|
||||
/// </summary>
|
||||
public sealed class SHA1Hash : HashAlgorithm
|
||||
{
|
||||
private const int DIGEST_SIZE = 20;
|
||||
|
||||
private const uint Y1 = 0x5a827999;
|
||||
|
||||
private const uint Y2 = 0x6ed9eba1;
|
||||
|
||||
private const uint Y3 = 0x8f1bbcdc;
|
||||
|
||||
private const uint Y4 = 0xca62c1d6;
|
||||
|
||||
private uint H1, H2, H3, H4, H5;
|
||||
|
||||
private readonly uint[] _hashValue = new uint[80];
|
||||
|
||||
private int _offset;
|
||||
|
||||
private readonly byte[] _buffer;
|
||||
|
||||
private int _bufferOffset;
|
||||
|
||||
private long _byteCount;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the size, in bits, of the computed hash code.
|
||||
/// </summary>
|
||||
/// <returns>The size, in bits, of the computed hash code.</returns>
|
||||
public override int HashSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return DIGEST_SIZE * 8;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the input block size.
|
||||
/// </summary>
|
||||
/// <returns>The input block size.</returns>
|
||||
public override int InputBlockSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the output block size.
|
||||
/// </summary>
|
||||
/// <returns>The output block size.</returns>
|
||||
public override int OutputBlockSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current transform can be reused.
|
||||
/// </summary>
|
||||
/// <returns>Always true.</returns>
|
||||
public override bool CanReuseTransform
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether multiple blocks can be transformed.
|
||||
/// </summary>
|
||||
/// <returns>true if multiple blocks can be transformed; otherwise, false.</returns>
|
||||
public override bool CanTransformMultipleBlocks
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SHA1Hash"/> class.
|
||||
/// </summary>
|
||||
public SHA1Hash()
|
||||
{
|
||||
this._buffer = new byte[4];
|
||||
this.InternalInitialize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Routes data written to the object into the hash algorithm for computing the hash.
|
||||
/// </summary>
|
||||
/// <param name="array">The input to compute the hash code for.</param>
|
||||
/// <param name="ibStart">The offset into the byte array from which to begin using data.</param>
|
||||
/// <param name="cbSize">The number of bytes in the byte array to use as data.</param>
|
||||
protected override void HashCore(byte[] array, int ibStart, int cbSize)
|
||||
{
|
||||
// Fill the current word
|
||||
while ((this._bufferOffset != 0) && (cbSize > 0))
|
||||
{
|
||||
this.Update(array[ibStart]);
|
||||
ibStart++;
|
||||
cbSize--;
|
||||
}
|
||||
|
||||
// Process whole words.
|
||||
while (cbSize > this._buffer.Length)
|
||||
{
|
||||
this.ProcessWord(array, ibStart);
|
||||
|
||||
ibStart += this._buffer.Length;
|
||||
cbSize -= this._buffer.Length;
|
||||
this._byteCount += this._buffer.Length;
|
||||
}
|
||||
|
||||
// Load in the remainder.
|
||||
while (cbSize > 0)
|
||||
{
|
||||
this.Update(array[ibStart]);
|
||||
|
||||
ibStart++;
|
||||
cbSize--;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finalizes the hash computation after the last data is processed by the cryptographic stream object.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The computed hash code.
|
||||
/// </returns>
|
||||
protected override byte[] HashFinal()
|
||||
{
|
||||
var output = new byte[DIGEST_SIZE];
|
||||
long bitLength = (this._byteCount << 3);
|
||||
|
||||
//
|
||||
// add the pad bytes.
|
||||
//
|
||||
this.Update((byte)128);
|
||||
|
||||
while (this._bufferOffset != 0)
|
||||
this.Update((byte)0);
|
||||
|
||||
if (this._offset > 14)
|
||||
{
|
||||
this.ProcessBlock();
|
||||
}
|
||||
|
||||
this._hashValue[14] = (uint)((ulong)bitLength >> 32);
|
||||
this._hashValue[15] = (uint)((ulong)bitLength);
|
||||
|
||||
|
||||
this.ProcessBlock();
|
||||
|
||||
UInt32ToBigEndian(H1, output, 0);
|
||||
UInt32ToBigEndian(H2, output, 4);
|
||||
UInt32ToBigEndian(H3, output, 8);
|
||||
UInt32ToBigEndian(H4, output, 12);
|
||||
UInt32ToBigEndian(H5, output, 16);
|
||||
|
||||
this.Initialize();
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes an implementation of the <see cref="T:System.Security.Cryptography.HashAlgorithm"/> class.
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
this.InternalInitialize();
|
||||
}
|
||||
|
||||
private void InternalInitialize()
|
||||
{
|
||||
this._byteCount = 0;
|
||||
this._bufferOffset = 0;
|
||||
for (var i = 0; i < 4; i++)
|
||||
{
|
||||
this._buffer[i] = 0;
|
||||
}
|
||||
|
||||
H1 = 0x67452301;
|
||||
H2 = 0xefcdab89;
|
||||
H3 = 0x98badcfe;
|
||||
H4 = 0x10325476;
|
||||
H5 = 0xc3d2e1f0;
|
||||
|
||||
this._offset = 0;
|
||||
for (var i = 0; i != this._hashValue.Length; i++)
|
||||
{
|
||||
this._hashValue[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update(byte input)
|
||||
{
|
||||
this._buffer[this._bufferOffset++] = input;
|
||||
|
||||
if (this._bufferOffset == this._buffer.Length)
|
||||
{
|
||||
this.ProcessWord(this._buffer, 0);
|
||||
this._bufferOffset = 0;
|
||||
}
|
||||
|
||||
this._byteCount++;
|
||||
}
|
||||
|
||||
private void ProcessWord(byte[] input, int inOff)
|
||||
{
|
||||
this._hashValue[this._offset] = BigEndianToUInt32(input, inOff);
|
||||
|
||||
if (++this._offset == 16)
|
||||
{
|
||||
this.ProcessBlock();
|
||||
}
|
||||
}
|
||||
|
||||
private static uint F(uint u, uint v, uint w)
|
||||
{
|
||||
return (u & v) | (~u & w);
|
||||
}
|
||||
|
||||
private static uint H(uint u, uint v, uint w)
|
||||
{
|
||||
return u ^ v ^ w;
|
||||
}
|
||||
|
||||
private static uint G(uint u, uint v, uint w)
|
||||
{
|
||||
return (u & v) | (u & w) | (v & w);
|
||||
}
|
||||
|
||||
private void ProcessBlock()
|
||||
{
|
||||
//
|
||||
// expand 16 word block into 80 word block.
|
||||
//
|
||||
for (int i = 16; i < 80; i++)
|
||||
{
|
||||
uint t = _hashValue[i - 3] ^ _hashValue[i - 8] ^ _hashValue[i - 14] ^ _hashValue[i - 16];
|
||||
_hashValue[i] = t << 1 | t >> 31;
|
||||
}
|
||||
|
||||
//
|
||||
// set up working variables.
|
||||
//
|
||||
uint A = H1;
|
||||
uint B = H2;
|
||||
uint C = H3;
|
||||
uint D = H4;
|
||||
uint E = H5;
|
||||
|
||||
//
|
||||
// round 1
|
||||
//
|
||||
int idx = 0;
|
||||
|
||||
// E = rotateLeft(A, 5) + F(B, C, D) + E + X[idx++] + Y1
|
||||
// B = rotateLeft(B, 30)
|
||||
E += (A << 5 | (A >> 27)) + F(B, C, D) + _hashValue[idx++] + Y1;
|
||||
B = B << 30 | (B >> 2);
|
||||
|
||||
D += (E << 5 | (E >> 27)) + F(A, B, C) + _hashValue[idx++] + Y1;
|
||||
A = A << 30 | (A >> 2);
|
||||
|
||||
C += (D << 5 | (D >> 27)) + F(E, A, B) + _hashValue[idx++] + Y1;
|
||||
E = E << 30 | (E >> 2);
|
||||
|
||||
B += (C << 5 | (C >> 27)) + F(D, E, A) + _hashValue[idx++] + Y1;
|
||||
D = D << 30 | (D >> 2);
|
||||
|
||||
A += (B << 5 | (B >> 27)) + F(C, D, E) + _hashValue[idx++] + Y1;
|
||||
C = C << 30 | (C >> 2);
|
||||
// E = rotateLeft(A, 5) + F(B, C, D) + E + X[idx++] + Y1
|
||||
// B = rotateLeft(B, 30)
|
||||
E += (A << 5 | (A >> 27)) + F(B, C, D) + _hashValue[idx++] + Y1;
|
||||
B = B << 30 | (B >> 2);
|
||||
|
||||
D += (E << 5 | (E >> 27)) + F(A, B, C) + _hashValue[idx++] + Y1;
|
||||
A = A << 30 | (A >> 2);
|
||||
|
||||
C += (D << 5 | (D >> 27)) + F(E, A, B) + _hashValue[idx++] + Y1;
|
||||
E = E << 30 | (E >> 2);
|
||||
|
||||
B += (C << 5 | (C >> 27)) + F(D, E, A) + _hashValue[idx++] + Y1;
|
||||
D = D << 30 | (D >> 2);
|
||||
|
||||
A += (B << 5 | (B >> 27)) + F(C, D, E) + _hashValue[idx++] + Y1;
|
||||
C = C << 30 | (C >> 2);
|
||||
// E = rotateLeft(A, 5) + F(B, C, D) + E + X[idx++] + Y1
|
||||
// B = rotateLeft(B, 30)
|
||||
E += (A << 5 | (A >> 27)) + F(B, C, D) + _hashValue[idx++] + Y1;
|
||||
B = B << 30 | (B >> 2);
|
||||
|
||||
D += (E << 5 | (E >> 27)) + F(A, B, C) + _hashValue[idx++] + Y1;
|
||||
A = A << 30 | (A >> 2);
|
||||
|
||||
C += (D << 5 | (D >> 27)) + F(E, A, B) + _hashValue[idx++] + Y1;
|
||||
E = E << 30 | (E >> 2);
|
||||
|
||||
B += (C << 5 | (C >> 27)) + F(D, E, A) + _hashValue[idx++] + Y1;
|
||||
D = D << 30 | (D >> 2);
|
||||
|
||||
A += (B << 5 | (B >> 27)) + F(C, D, E) + _hashValue[idx++] + Y1;
|
||||
C = C << 30 | (C >> 2);
|
||||
// E = rotateLeft(A, 5) + F(B, C, D) + E + X[idx++] + Y1
|
||||
// B = rotateLeft(B, 30)
|
||||
E += (A << 5 | (A >> 27)) + F(B, C, D) + _hashValue[idx++] + Y1;
|
||||
B = B << 30 | (B >> 2);
|
||||
|
||||
D += (E << 5 | (E >> 27)) + F(A, B, C) + _hashValue[idx++] + Y1;
|
||||
A = A << 30 | (A >> 2);
|
||||
|
||||
C += (D << 5 | (D >> 27)) + F(E, A, B) + _hashValue[idx++] + Y1;
|
||||
E = E << 30 | (E >> 2);
|
||||
|
||||
B += (C << 5 | (C >> 27)) + F(D, E, A) + _hashValue[idx++] + Y1;
|
||||
D = D << 30 | (D >> 2);
|
||||
|
||||
A += (B << 5 | (B >> 27)) + F(C, D, E) + _hashValue[idx++] + Y1;
|
||||
C = C << 30 | (C >> 2);
|
||||
//
|
||||
// round 2
|
||||
//
|
||||
// E = rotateLeft(A, 5) + H(B, C, D) + E + X[idx++] + Y2
|
||||
// B = rotateLeft(B, 30)
|
||||
E += (A << 5 | (A >> 27)) + H(B, C, D) + _hashValue[idx++] + Y2;
|
||||
B = B << 30 | (B >> 2);
|
||||
|
||||
D += (E << 5 | (E >> 27)) + H(A, B, C) + _hashValue[idx++] + Y2;
|
||||
A = A << 30 | (A >> 2);
|
||||
|
||||
C += (D << 5 | (D >> 27)) + H(E, A, B) + _hashValue[idx++] + Y2;
|
||||
E = E << 30 | (E >> 2);
|
||||
|
||||
B += (C << 5 | (C >> 27)) + H(D, E, A) + _hashValue[idx++] + Y2;
|
||||
D = D << 30 | (D >> 2);
|
||||
|
||||
A += (B << 5 | (B >> 27)) + H(C, D, E) + _hashValue[idx++] + Y2;
|
||||
C = C << 30 | (C >> 2);
|
||||
// E = rotateLeft(A, 5) + H(B, C, D) + E + X[idx++] + Y2
|
||||
// B = rotateLeft(B, 30)
|
||||
E += (A << 5 | (A >> 27)) + H(B, C, D) + _hashValue[idx++] + Y2;
|
||||
B = B << 30 | (B >> 2);
|
||||
|
||||
D += (E << 5 | (E >> 27)) + H(A, B, C) + _hashValue[idx++] + Y2;
|
||||
A = A << 30 | (A >> 2);
|
||||
|
||||
C += (D << 5 | (D >> 27)) + H(E, A, B) + _hashValue[idx++] + Y2;
|
||||
E = E << 30 | (E >> 2);
|
||||
|
||||
B += (C << 5 | (C >> 27)) + H(D, E, A) + _hashValue[idx++] + Y2;
|
||||
D = D << 30 | (D >> 2);
|
||||
|
||||
A += (B << 5 | (B >> 27)) + H(C, D, E) + _hashValue[idx++] + Y2;
|
||||
C = C << 30 | (C >> 2);
|
||||
// E = rotateLeft(A, 5) + H(B, C, D) + E + X[idx++] + Y2
|
||||
// B = rotateLeft(B, 30)
|
||||
E += (A << 5 | (A >> 27)) + H(B, C, D) + _hashValue[idx++] + Y2;
|
||||
B = B << 30 | (B >> 2);
|
||||
|
||||
D += (E << 5 | (E >> 27)) + H(A, B, C) + _hashValue[idx++] + Y2;
|
||||
A = A << 30 | (A >> 2);
|
||||
|
||||
C += (D << 5 | (D >> 27)) + H(E, A, B) + _hashValue[idx++] + Y2;
|
||||
E = E << 30 | (E >> 2);
|
||||
|
||||
B += (C << 5 | (C >> 27)) + H(D, E, A) + _hashValue[idx++] + Y2;
|
||||
D = D << 30 | (D >> 2);
|
||||
|
||||
A += (B << 5 | (B >> 27)) + H(C, D, E) + _hashValue[idx++] + Y2;
|
||||
C = C << 30 | (C >> 2);
|
||||
// E = rotateLeft(A, 5) + H(B, C, D) + E + X[idx++] + Y2
|
||||
// B = rotateLeft(B, 30)
|
||||
E += (A << 5 | (A >> 27)) + H(B, C, D) + _hashValue[idx++] + Y2;
|
||||
B = B << 30 | (B >> 2);
|
||||
|
||||
D += (E << 5 | (E >> 27)) + H(A, B, C) + _hashValue[idx++] + Y2;
|
||||
A = A << 30 | (A >> 2);
|
||||
|
||||
C += (D << 5 | (D >> 27)) + H(E, A, B) + _hashValue[idx++] + Y2;
|
||||
E = E << 30 | (E >> 2);
|
||||
|
||||
B += (C << 5 | (C >> 27)) + H(D, E, A) + _hashValue[idx++] + Y2;
|
||||
D = D << 30 | (D >> 2);
|
||||
|
||||
A += (B << 5 | (B >> 27)) + H(C, D, E) + _hashValue[idx++] + Y2;
|
||||
C = C << 30 | (C >> 2);
|
||||
|
||||
//
|
||||
// round 3
|
||||
// E = rotateLeft(A, 5) + G(B, C, D) + E + X[idx++] + Y3
|
||||
// B = rotateLeft(B, 30)
|
||||
E += (A << 5 | (A >> 27)) + G(B, C, D) + _hashValue[idx++] + Y3;
|
||||
B = B << 30 | (B >> 2);
|
||||
|
||||
D += (E << 5 | (E >> 27)) + G(A, B, C) + _hashValue[idx++] + Y3;
|
||||
A = A << 30 | (A >> 2);
|
||||
|
||||
C += (D << 5 | (D >> 27)) + G(E, A, B) + _hashValue[idx++] + Y3;
|
||||
E = E << 30 | (E >> 2);
|
||||
|
||||
B += (C << 5 | (C >> 27)) + G(D, E, A) + _hashValue[idx++] + Y3;
|
||||
D = D << 30 | (D >> 2);
|
||||
|
||||
A += (B << 5 | (B >> 27)) + G(C, D, E) + _hashValue[idx++] + Y3;
|
||||
C = C << 30 | (C >> 2);
|
||||
// E = rotateLeft(A, 5) + G(B, C, D) + E + X[idx++] + Y3
|
||||
// B = rotateLeft(B, 30)
|
||||
E += (A << 5 | (A >> 27)) + G(B, C, D) + _hashValue[idx++] + Y3;
|
||||
B = B << 30 | (B >> 2);
|
||||
|
||||
D += (E << 5 | (E >> 27)) + G(A, B, C) + _hashValue[idx++] + Y3;
|
||||
A = A << 30 | (A >> 2);
|
||||
|
||||
C += (D << 5 | (D >> 27)) + G(E, A, B) + _hashValue[idx++] + Y3;
|
||||
E = E << 30 | (E >> 2);
|
||||
|
||||
B += (C << 5 | (C >> 27)) + G(D, E, A) + _hashValue[idx++] + Y3;
|
||||
D = D << 30 | (D >> 2);
|
||||
|
||||
A += (B << 5 | (B >> 27)) + G(C, D, E) + _hashValue[idx++] + Y3;
|
||||
C = C << 30 | (C >> 2);
|
||||
// E = rotateLeft(A, 5) + G(B, C, D) + E + X[idx++] + Y3
|
||||
// B = rotateLeft(B, 30)
|
||||
E += (A << 5 | (A >> 27)) + G(B, C, D) + _hashValue[idx++] + Y3;
|
||||
B = B << 30 | (B >> 2);
|
||||
|
||||
D += (E << 5 | (E >> 27)) + G(A, B, C) + _hashValue[idx++] + Y3;
|
||||
A = A << 30 | (A >> 2);
|
||||
|
||||
C += (D << 5 | (D >> 27)) + G(E, A, B) + _hashValue[idx++] + Y3;
|
||||
E = E << 30 | (E >> 2);
|
||||
|
||||
B += (C << 5 | (C >> 27)) + G(D, E, A) + _hashValue[idx++] + Y3;
|
||||
D = D << 30 | (D >> 2);
|
||||
|
||||
A += (B << 5 | (B >> 27)) + G(C, D, E) + _hashValue[idx++] + Y3;
|
||||
C = C << 30 | (C >> 2);
|
||||
// E = rotateLeft(A, 5) + G(B, C, D) + E + X[idx++] + Y3
|
||||
// B = rotateLeft(B, 30)
|
||||
E += (A << 5 | (A >> 27)) + G(B, C, D) + _hashValue[idx++] + Y3;
|
||||
B = B << 30 | (B >> 2);
|
||||
|
||||
D += (E << 5 | (E >> 27)) + G(A, B, C) + _hashValue[idx++] + Y3;
|
||||
A = A << 30 | (A >> 2);
|
||||
|
||||
C += (D << 5 | (D >> 27)) + G(E, A, B) + _hashValue[idx++] + Y3;
|
||||
E = E << 30 | (E >> 2);
|
||||
|
||||
B += (C << 5 | (C >> 27)) + G(D, E, A) + _hashValue[idx++] + Y3;
|
||||
D = D << 30 | (D >> 2);
|
||||
|
||||
A += (B << 5 | (B >> 27)) + G(C, D, E) + _hashValue[idx++] + Y3;
|
||||
C = C << 30 | (C >> 2);
|
||||
|
||||
//
|
||||
// round 4
|
||||
//
|
||||
// E = rotateLeft(A, 5) + H(B, C, D) + E + X[idx++] + Y4
|
||||
// B = rotateLeft(B, 30)
|
||||
E += (A << 5 | (A >> 27)) + H(B, C, D) + _hashValue[idx++] + Y4;
|
||||
B = B << 30 | (B >> 2);
|
||||
|
||||
D += (E << 5 | (E >> 27)) + H(A, B, C) + _hashValue[idx++] + Y4;
|
||||
A = A << 30 | (A >> 2);
|
||||
|
||||
C += (D << 5 | (D >> 27)) + H(E, A, B) + _hashValue[idx++] + Y4;
|
||||
E = E << 30 | (E >> 2);
|
||||
|
||||
B += (C << 5 | (C >> 27)) + H(D, E, A) + _hashValue[idx++] + Y4;
|
||||
D = D << 30 | (D >> 2);
|
||||
|
||||
A += (B << 5 | (B >> 27)) + H(C, D, E) + _hashValue[idx++] + Y4;
|
||||
C = C << 30 | (C >> 2);
|
||||
// E = rotateLeft(A, 5) + H(B, C, D) + E + X[idx++] + Y4
|
||||
// B = rotateLeft(B, 30)
|
||||
E += (A << 5 | (A >> 27)) + H(B, C, D) + _hashValue[idx++] + Y4;
|
||||
B = B << 30 | (B >> 2);
|
||||
|
||||
D += (E << 5 | (E >> 27)) + H(A, B, C) + _hashValue[idx++] + Y4;
|
||||
A = A << 30 | (A >> 2);
|
||||
|
||||
C += (D << 5 | (D >> 27)) + H(E, A, B) + _hashValue[idx++] + Y4;
|
||||
E = E << 30 | (E >> 2);
|
||||
|
||||
B += (C << 5 | (C >> 27)) + H(D, E, A) + _hashValue[idx++] + Y4;
|
||||
D = D << 30 | (D >> 2);
|
||||
|
||||
A += (B << 5 | (B >> 27)) + H(C, D, E) + _hashValue[idx++] + Y4;
|
||||
C = C << 30 | (C >> 2);
|
||||
// E = rotateLeft(A, 5) + H(B, C, D) + E + X[idx++] + Y4
|
||||
// B = rotateLeft(B, 30)
|
||||
E += (A << 5 | (A >> 27)) + H(B, C, D) + _hashValue[idx++] + Y4;
|
||||
B = B << 30 | (B >> 2);
|
||||
|
||||
D += (E << 5 | (E >> 27)) + H(A, B, C) + _hashValue[idx++] + Y4;
|
||||
A = A << 30 | (A >> 2);
|
||||
|
||||
C += (D << 5 | (D >> 27)) + H(E, A, B) + _hashValue[idx++] + Y4;
|
||||
E = E << 30 | (E >> 2);
|
||||
|
||||
B += (C << 5 | (C >> 27)) + H(D, E, A) + _hashValue[idx++] + Y4;
|
||||
D = D << 30 | (D >> 2);
|
||||
|
||||
A += (B << 5 | (B >> 27)) + H(C, D, E) + _hashValue[idx++] + Y4;
|
||||
C = C << 30 | (C >> 2);
|
||||
// E = rotateLeft(A, 5) + H(B, C, D) + E + X[idx++] + Y4
|
||||
// B = rotateLeft(B, 30)
|
||||
E += (A << 5 | (A >> 27)) + H(B, C, D) + _hashValue[idx++] + Y4;
|
||||
B = B << 30 | (B >> 2);
|
||||
|
||||
D += (E << 5 | (E >> 27)) + H(A, B, C) + _hashValue[idx++] + Y4;
|
||||
A = A << 30 | (A >> 2);
|
||||
|
||||
C += (D << 5 | (D >> 27)) + H(E, A, B) + _hashValue[idx++] + Y4;
|
||||
E = E << 30 | (E >> 2);
|
||||
|
||||
B += (C << 5 | (C >> 27)) + H(D, E, A) + _hashValue[idx++] + Y4;
|
||||
D = D << 30 | (D >> 2);
|
||||
|
||||
A += (B << 5 | (B >> 27)) + H(C, D, E) + _hashValue[idx++] + Y4;
|
||||
C = C << 30 | (C >> 2);
|
||||
|
||||
H1 += A;
|
||||
H2 += B;
|
||||
H3 += C;
|
||||
H4 += D;
|
||||
H5 += E;
|
||||
|
||||
//
|
||||
// reset start of the buffer.
|
||||
//
|
||||
this._offset = 0;
|
||||
for (int i = 0; i < this._hashValue.Length; i++)
|
||||
{
|
||||
this._hashValue[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static uint BigEndianToUInt32(byte[] bs, int off)
|
||||
{
|
||||
uint n = (uint)bs[off] << 24;
|
||||
n |= (uint)bs[++off] << 16;
|
||||
n |= (uint)bs[++off] << 8;
|
||||
n |= (uint)bs[++off];
|
||||
return n;
|
||||
}
|
||||
|
||||
private static void UInt32ToBigEndian(uint n, byte[] bs, int off)
|
||||
{
|
||||
bs[off] = (byte)(n >> 24);
|
||||
bs[++off] = (byte)(n >> 16);
|
||||
bs[++off] = (byte)(n >> 8);
|
||||
bs[++off] = (byte)(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,396 +0,0 @@
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Renci.SshNet.Security.Cryptography
|
||||
{
|
||||
/// <summary>
|
||||
/// SHA256 algorithm implementation.
|
||||
/// </summary>
|
||||
public class SHA256Hash : HashAlgorithm
|
||||
{
|
||||
private const int DIGEST_SIZE = 32;
|
||||
|
||||
private uint H1, H2, H3, H4, H5, H6, H7, H8;
|
||||
|
||||
private readonly uint[] X = new uint[64];
|
||||
|
||||
private int _offset;
|
||||
|
||||
private readonly byte[] _buffer;
|
||||
|
||||
private int _bufferOffset;
|
||||
|
||||
private long _byteCount;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the size, in bits, of the computed hash code.
|
||||
/// </summary>
|
||||
/// <returns>The size, in bits, of the computed hash code.</returns>
|
||||
public override int HashSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return DIGEST_SIZE * 8;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the input block size.
|
||||
/// </summary>
|
||||
/// <returns>The input block size.</returns>
|
||||
public override int InputBlockSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the output block size.
|
||||
/// </summary>
|
||||
/// <returns>The output block size.</returns>
|
||||
public override int OutputBlockSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current transform can be reused.
|
||||
/// </summary>
|
||||
/// <returns>Always true.</returns>
|
||||
public override bool CanReuseTransform
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether multiple blocks can be transformed.
|
||||
/// </summary>
|
||||
/// <returns>true if multiple blocks can be transformed; otherwise, false.</returns>
|
||||
public override bool CanTransformMultipleBlocks
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SHA1"/> class.
|
||||
/// </summary>
|
||||
public SHA256Hash()
|
||||
{
|
||||
this._buffer = new byte[4];
|
||||
this.InternalInitialize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Routes data written to the object into the hash algorithm for computing the hash.
|
||||
/// </summary>
|
||||
/// <param name="array">The input to compute the hash code for.</param>
|
||||
/// <param name="ibStart">The offset into the byte array from which to begin using data.</param>
|
||||
/// <param name="cbSize">The number of bytes in the byte array to use as data.</param>
|
||||
protected override void HashCore(byte[] array, int ibStart, int cbSize)
|
||||
{
|
||||
// Fill the current word
|
||||
while ((this._bufferOffset != 0) && (cbSize > 0))
|
||||
{
|
||||
this.Update(array[ibStart]);
|
||||
ibStart++;
|
||||
cbSize--;
|
||||
}
|
||||
|
||||
// Process whole words.
|
||||
while (cbSize > this._buffer.Length)
|
||||
{
|
||||
this.ProcessWord(array, ibStart);
|
||||
|
||||
ibStart += this._buffer.Length;
|
||||
cbSize -= this._buffer.Length;
|
||||
this._byteCount += this._buffer.Length;
|
||||
}
|
||||
|
||||
// Load in the remainder.
|
||||
while (cbSize > 0)
|
||||
{
|
||||
this.Update(array[ibStart]);
|
||||
|
||||
ibStart++;
|
||||
cbSize--;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finalizes the hash computation after the last data is processed by the cryptographic stream object.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The computed hash code.
|
||||
/// </returns>
|
||||
protected override byte[] HashFinal()
|
||||
{
|
||||
var output = new byte[DIGEST_SIZE];
|
||||
long bitLength = (this._byteCount << 3);
|
||||
|
||||
//
|
||||
// add the pad bytes.
|
||||
//
|
||||
this.Update((byte)128);
|
||||
|
||||
while (this._bufferOffset != 0)
|
||||
this.Update((byte)0);
|
||||
|
||||
if (this._offset > 14)
|
||||
{
|
||||
this.ProcessBlock();
|
||||
}
|
||||
|
||||
X[14] = (uint)((ulong)bitLength >> 32);
|
||||
X[15] = (uint)((ulong)bitLength);
|
||||
|
||||
|
||||
this.ProcessBlock();
|
||||
|
||||
UInt32_To_BE((uint)H1, output, 0);
|
||||
UInt32_To_BE((uint)H2, output, 0 + 4);
|
||||
UInt32_To_BE((uint)H3, output, 0 + 8);
|
||||
UInt32_To_BE((uint)H4, output, 0 + 12);
|
||||
UInt32_To_BE((uint)H5, output, 0 + 16);
|
||||
UInt32_To_BE((uint)H6, output, 0 + 20);
|
||||
UInt32_To_BE((uint)H7, output, 0 + 24);
|
||||
UInt32_To_BE((uint)H8, output, 0 + 28);
|
||||
|
||||
this.Initialize();
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes an implementation of the <see cref="T:System.Security.Cryptography.HashAlgorithm"/> class.
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
this.InternalInitialize();
|
||||
}
|
||||
|
||||
private void InternalInitialize()
|
||||
{
|
||||
this._byteCount = 0;
|
||||
this._bufferOffset = 0;
|
||||
for (int i = 0; i < this._buffer.Length; i++)
|
||||
{
|
||||
this._buffer[i] = 0;
|
||||
}
|
||||
|
||||
H1 = 0x6a09e667;
|
||||
H2 = 0xbb67ae85;
|
||||
H3 = 0x3c6ef372;
|
||||
H4 = 0xa54ff53a;
|
||||
H5 = 0x510e527f;
|
||||
H6 = 0x9b05688c;
|
||||
H7 = 0x1f83d9ab;
|
||||
H8 = 0x5be0cd19;
|
||||
|
||||
this._offset = 0;
|
||||
for (int i = 0; i < this.X.Length; i++)
|
||||
{
|
||||
this.X[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update(byte input)
|
||||
{
|
||||
this._buffer[this._bufferOffset++] = input;
|
||||
|
||||
if (this._bufferOffset == this._buffer.Length)
|
||||
{
|
||||
this.ProcessWord(this._buffer, 0);
|
||||
this._bufferOffset = 0;
|
||||
}
|
||||
|
||||
this._byteCount++;
|
||||
}
|
||||
|
||||
private static uint BE_To_UInt32(byte[] bs, int off)
|
||||
{
|
||||
uint n = (uint)bs[off] << 24;
|
||||
n |= (uint)bs[++off] << 16;
|
||||
n |= (uint)bs[++off] << 8;
|
||||
n |= (uint)bs[++off];
|
||||
return n;
|
||||
}
|
||||
|
||||
private static void UInt32_To_BE(uint n, byte[] bs, int off)
|
||||
{
|
||||
bs[off] = (byte)(n >> 24);
|
||||
bs[++off] = (byte)(n >> 16);
|
||||
bs[++off] = (byte)(n >> 8);
|
||||
bs[++off] = (byte)(n);
|
||||
}
|
||||
|
||||
private void ProcessWord(byte[] input, int inOff)
|
||||
{
|
||||
X[this._offset] = BE_To_UInt32(input, inOff);
|
||||
|
||||
if (++this._offset == 16)
|
||||
{
|
||||
ProcessBlock();
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessLength(long bitLength)
|
||||
{
|
||||
if (this._offset > 14)
|
||||
{
|
||||
ProcessBlock();
|
||||
}
|
||||
|
||||
X[14] = (uint)((ulong)bitLength >> 32);
|
||||
X[15] = (uint)((ulong)bitLength);
|
||||
}
|
||||
|
||||
private void ProcessBlock()
|
||||
{
|
||||
//
|
||||
// expand 16 word block into 64 word blocks.
|
||||
//
|
||||
for (int ti = 16; ti <= 63; ti++)
|
||||
{
|
||||
X[ti] = Theta1(X[ti - 2]) + X[ti - 7] + Theta0(X[ti - 15]) + X[ti - 16];
|
||||
}
|
||||
|
||||
//
|
||||
// set up working variables.
|
||||
//
|
||||
uint a = H1;
|
||||
uint b = H2;
|
||||
uint c = H3;
|
||||
uint d = H4;
|
||||
uint e = H5;
|
||||
uint f = H6;
|
||||
uint g = H7;
|
||||
uint h = H8;
|
||||
|
||||
int t = 0;
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
// t = 8 * i
|
||||
h += Sum1Ch(e, f, g) + K[t] + X[t];
|
||||
d += h;
|
||||
h += Sum0Maj(a, b, c);
|
||||
++t;
|
||||
|
||||
// t = 8 * i + 1
|
||||
g += Sum1Ch(d, e, f) + K[t] + X[t];
|
||||
c += g;
|
||||
g += Sum0Maj(h, a, b);
|
||||
++t;
|
||||
|
||||
// t = 8 * i + 2
|
||||
f += Sum1Ch(c, d, e) + K[t] + X[t];
|
||||
b += f;
|
||||
f += Sum0Maj(g, h, a);
|
||||
++t;
|
||||
|
||||
// t = 8 * i + 3
|
||||
e += Sum1Ch(b, c, d) + K[t] + X[t];
|
||||
a += e;
|
||||
e += Sum0Maj(f, g, h);
|
||||
++t;
|
||||
|
||||
// t = 8 * i + 4
|
||||
d += Sum1Ch(a, b, c) + K[t] + X[t];
|
||||
h += d;
|
||||
d += Sum0Maj(e, f, g);
|
||||
++t;
|
||||
|
||||
// t = 8 * i + 5
|
||||
c += Sum1Ch(h, a, b) + K[t] + X[t];
|
||||
g += c;
|
||||
c += Sum0Maj(d, e, f);
|
||||
++t;
|
||||
|
||||
// t = 8 * i + 6
|
||||
b += Sum1Ch(g, h, a) + K[t] + X[t];
|
||||
f += b;
|
||||
b += Sum0Maj(c, d, e);
|
||||
++t;
|
||||
|
||||
// t = 8 * i + 7
|
||||
a += Sum1Ch(f, g, h) + K[t] + X[t];
|
||||
e += a;
|
||||
a += Sum0Maj(b, c, d);
|
||||
++t;
|
||||
}
|
||||
|
||||
H1 += a;
|
||||
H2 += b;
|
||||
H3 += c;
|
||||
H4 += d;
|
||||
H5 += e;
|
||||
H6 += f;
|
||||
H7 += g;
|
||||
H8 += h;
|
||||
|
||||
//
|
||||
// reset the offset and clean out the word buffer.
|
||||
//
|
||||
this._offset = 0;
|
||||
for (int i = 0; i < this.X.Length; i++)
|
||||
{
|
||||
this.X[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static uint Sum1Ch(uint x, uint y, uint z)
|
||||
{
|
||||
// return Sum1(x) + Ch(x, y, z);
|
||||
return (((x >> 6) | (x << 26)) ^ ((x >> 11) | (x << 21)) ^ ((x >> 25) | (x << 7)))
|
||||
+ ((x & y) ^ ((~x) & z));
|
||||
}
|
||||
|
||||
private static uint Sum0Maj(uint x, uint y, uint z)
|
||||
{
|
||||
// return Sum0(x) + Maj(x, y, z);
|
||||
return (((x >> 2) | (x << 30)) ^ ((x >> 13) | (x << 19)) ^ ((x >> 22) | (x << 10)))
|
||||
+ ((x & y) ^ (x & z) ^ (y & z));
|
||||
}
|
||||
|
||||
private static uint Theta0(uint x)
|
||||
{
|
||||
return ((x >> 7) | (x << 25)) ^ ((x >> 18) | (x << 14)) ^ (x >> 3);
|
||||
}
|
||||
|
||||
private static uint Theta1(uint x)
|
||||
{
|
||||
return ((x >> 17) | (x << 15)) ^ ((x >> 19) | (x << 13)) ^ (x >> 10);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The SHA-256 Constants (represent the first 32 bits of the fractional parts of the cube roots of the first sixty-four prime numbers)
|
||||
/// </summary>
|
||||
private static readonly uint[] K = {
|
||||
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
|
||||
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
||||
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
|
||||
0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
||||
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
|
||||
0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
||||
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
|
||||
0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
||||
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
|
||||
0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
||||
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
|
||||
0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
||||
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
|
||||
0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
||||
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
|
||||
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,362 +0,0 @@
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Renci.SshNet.Security.Cryptography
|
||||
{
|
||||
/// <summary>
|
||||
/// SHA256 algorithm implementation.
|
||||
/// </summary>
|
||||
public abstract class SHA2HashBase : HashAlgorithm
|
||||
{
|
||||
protected ulong H1, H2, H3, H4, H5, H6, H7, H8;
|
||||
|
||||
private readonly ulong[] X = new ulong[80];
|
||||
|
||||
private int _offset;
|
||||
|
||||
private readonly byte[] _buffer;
|
||||
|
||||
private int _bufferOffset;
|
||||
|
||||
private long _byteCount1;
|
||||
|
||||
private long _byteCount2;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current transform can be reused.
|
||||
/// </summary>
|
||||
/// <returns>Always true.</returns>
|
||||
public override bool CanReuseTransform
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether multiple blocks can be transformed.
|
||||
/// </summary>
|
||||
/// <returns>true if multiple blocks can be transformed; otherwise, false.</returns>
|
||||
public override bool CanTransformMultipleBlocks
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SHA512Hash" /> class.
|
||||
/// </summary>
|
||||
protected SHA2HashBase()
|
||||
{
|
||||
this._buffer = new byte[8];
|
||||
|
||||
this.Initialize();
|
||||
}
|
||||
|
||||
protected override void HashCore(byte[] array, int ibStart, int cbSize)
|
||||
{
|
||||
// Fill the current word
|
||||
while ((this._bufferOffset != 0) && (cbSize > 0))
|
||||
{
|
||||
this.Update(array[ibStart]);
|
||||
|
||||
ibStart++;
|
||||
cbSize--;
|
||||
}
|
||||
|
||||
// Process whole words.
|
||||
while (cbSize > this._buffer.Length)
|
||||
{
|
||||
ProcessWord(array, ibStart);
|
||||
|
||||
ibStart += this._buffer.Length;
|
||||
cbSize -= this._buffer.Length;
|
||||
this._byteCount1 += this._buffer.Length;
|
||||
}
|
||||
|
||||
// Load in the remainder.
|
||||
while (cbSize > 0)
|
||||
{
|
||||
this.Update(array[ibStart]);
|
||||
|
||||
ibStart++;
|
||||
cbSize--;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
this._byteCount1 = 0;
|
||||
this._byteCount2 = 0;
|
||||
|
||||
this._bufferOffset = 0;
|
||||
for (int i = 0; i < this._buffer.Length; i++)
|
||||
{
|
||||
this._buffer[i] = 0;
|
||||
}
|
||||
|
||||
this._offset = 0;
|
||||
for (int i = 0; i < this.X.Length; i++)
|
||||
{
|
||||
this.X[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected void Finish()
|
||||
{
|
||||
this.AdjustByteCounts();
|
||||
|
||||
long lowBitLength = this._byteCount1 << 3;
|
||||
long hiBitLength = this._byteCount2;
|
||||
|
||||
//
|
||||
// add the pad bytes.
|
||||
//
|
||||
this.Update((byte)128);
|
||||
|
||||
while (this._bufferOffset != 0)
|
||||
{
|
||||
this.Update((byte)0);
|
||||
}
|
||||
|
||||
this.ProcessLength(lowBitLength, hiBitLength);
|
||||
|
||||
this.ProcessBlock();
|
||||
}
|
||||
|
||||
private void Update(byte input)
|
||||
{
|
||||
this._buffer[_bufferOffset++] = input;
|
||||
|
||||
if (this._bufferOffset == this._buffer.Length)
|
||||
{
|
||||
this.ProcessWord(this._buffer, 0);
|
||||
this._bufferOffset = 0;
|
||||
}
|
||||
|
||||
this._byteCount1++;
|
||||
}
|
||||
|
||||
private void ProcessWord(byte[] input, int inOff)
|
||||
{
|
||||
this.X[_offset] = SHA512Hash.BE_To_UInt64(input, inOff);
|
||||
|
||||
if (++_offset == 16)
|
||||
{
|
||||
ProcessBlock();
|
||||
}
|
||||
}
|
||||
|
||||
internal void ProcessLength(long lowW, long hiW)
|
||||
{
|
||||
if (_offset > 14)
|
||||
{
|
||||
this.ProcessBlock();
|
||||
}
|
||||
|
||||
this.X[14] = (ulong)hiW;
|
||||
this.X[15] = (ulong)lowW;
|
||||
}
|
||||
|
||||
private void ProcessBlock()
|
||||
{
|
||||
this.AdjustByteCounts();
|
||||
|
||||
//
|
||||
// expand 16 word block into 80 word blocks.
|
||||
//
|
||||
for (int ti = 16; ti <= 79; ++ti)
|
||||
{
|
||||
X[ti] = Sigma1(X[ti - 2]) + X[ti - 7] + Sigma0(X[ti - 15]) + X[ti - 16];
|
||||
}
|
||||
|
||||
//
|
||||
// set up working variables.
|
||||
//
|
||||
ulong a = H1;
|
||||
ulong b = H2;
|
||||
ulong c = H3;
|
||||
ulong d = H4;
|
||||
ulong e = H5;
|
||||
ulong f = H6;
|
||||
ulong g = H7;
|
||||
ulong h = H8;
|
||||
|
||||
int t = 0;
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
// t = 8 * i
|
||||
h += Sum1(e) + Ch(e, f, g) + K[t] + X[t++];
|
||||
d += h;
|
||||
h += Sum0(a) + Maj(a, b, c);
|
||||
|
||||
// t = 8 * i + 1
|
||||
g += Sum1(d) + Ch(d, e, f) + K[t] + X[t++];
|
||||
c += g;
|
||||
g += Sum0(h) + Maj(h, a, b);
|
||||
|
||||
// t = 8 * i + 2
|
||||
f += Sum1(c) + Ch(c, d, e) + K[t] + X[t++];
|
||||
b += f;
|
||||
f += Sum0(g) + Maj(g, h, a);
|
||||
|
||||
// t = 8 * i + 3
|
||||
e += Sum1(b) + Ch(b, c, d) + K[t] + X[t++];
|
||||
a += e;
|
||||
e += Sum0(f) + Maj(f, g, h);
|
||||
|
||||
// t = 8 * i + 4
|
||||
d += Sum1(a) + Ch(a, b, c) + K[t] + X[t++];
|
||||
h += d;
|
||||
d += Sum0(e) + Maj(e, f, g);
|
||||
|
||||
// t = 8 * i + 5
|
||||
c += Sum1(h) + Ch(h, a, b) + K[t] + X[t++];
|
||||
g += c;
|
||||
c += Sum0(d) + Maj(d, e, f);
|
||||
|
||||
// t = 8 * i + 6
|
||||
b += Sum1(g) + Ch(g, h, a) + K[t] + X[t++];
|
||||
f += b;
|
||||
b += Sum0(c) + Maj(c, d, e);
|
||||
|
||||
// t = 8 * i + 7
|
||||
a += Sum1(f) + Ch(f, g, h) + K[t] + X[t++];
|
||||
e += a;
|
||||
a += Sum0(b) + Maj(b, c, d);
|
||||
}
|
||||
|
||||
H1 += a;
|
||||
H2 += b;
|
||||
H3 += c;
|
||||
H4 += d;
|
||||
H5 += e;
|
||||
H6 += f;
|
||||
H7 += g;
|
||||
H8 += h;
|
||||
|
||||
//
|
||||
// reset the offset and clean out the word buffer.
|
||||
//
|
||||
this._offset = 0;
|
||||
for (int i = 0; i < this.X.Length; i++)
|
||||
{
|
||||
this.X[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adjust the byte counts so that byteCount2 represents the upper long (less 3 bits) word of the byte count.
|
||||
/// </summary>
|
||||
private void AdjustByteCounts()
|
||||
{
|
||||
if (this._byteCount1 > 0x1fffffffffffffffL)
|
||||
{
|
||||
this._byteCount2 += (long)((ulong)this._byteCount1 >> 61);
|
||||
this._byteCount1 &= 0x1fffffffffffffffL;
|
||||
}
|
||||
}
|
||||
|
||||
/* SHA-384 and SHA-512 functions (as for SHA-256 but for longs) */
|
||||
private static ulong Ch(ulong x, ulong y, ulong z)
|
||||
{
|
||||
return (x & y) ^ (~x & z);
|
||||
}
|
||||
|
||||
private static ulong Maj(ulong x, ulong y, ulong z)
|
||||
{
|
||||
return (x & y) ^ (x & z) ^ (y & z);
|
||||
}
|
||||
|
||||
private static ulong Sum0(ulong x)
|
||||
{
|
||||
return ((x << 36) | (x >> 28)) ^ ((x << 30) | (x >> 34)) ^ ((x << 25) | (x >> 39));
|
||||
}
|
||||
|
||||
private static ulong Sum1(ulong x)
|
||||
{
|
||||
return ((x << 50) | (x >> 14)) ^ ((x << 46) | (x >> 18)) ^ ((x << 23) | (x >> 41));
|
||||
}
|
||||
|
||||
private static ulong Sigma0(ulong x)
|
||||
{
|
||||
return ((x << 63) | (x >> 1)) ^ ((x << 56) | (x >> 8)) ^ (x >> 7);
|
||||
}
|
||||
|
||||
private static ulong Sigma1(ulong x)
|
||||
{
|
||||
return ((x << 45) | (x >> 19)) ^ ((x << 3) | (x >> 61)) ^ (x >> 6);
|
||||
}
|
||||
|
||||
/* SHA-384 and SHA-512 Constants
|
||||
* (represent the first 64 bits of the fractional parts of the
|
||||
* cube roots of the first sixty-four prime numbers)
|
||||
*/
|
||||
private static readonly ulong[] K =
|
||||
{
|
||||
0x428a2f98d728ae22, 0x7137449123ef65cd, 0xb5c0fbcfec4d3b2f, 0xe9b5dba58189dbbc,
|
||||
0x3956c25bf348b538, 0x59f111f1b605d019, 0x923f82a4af194f9b, 0xab1c5ed5da6d8118,
|
||||
0xd807aa98a3030242, 0x12835b0145706fbe, 0x243185be4ee4b28c, 0x550c7dc3d5ffb4e2,
|
||||
0x72be5d74f27b896f, 0x80deb1fe3b1696b1, 0x9bdc06a725c71235, 0xc19bf174cf692694,
|
||||
0xe49b69c19ef14ad2, 0xefbe4786384f25e3, 0x0fc19dc68b8cd5b5, 0x240ca1cc77ac9c65,
|
||||
0x2de92c6f592b0275, 0x4a7484aa6ea6e483, 0x5cb0a9dcbd41fbd4, 0x76f988da831153b5,
|
||||
0x983e5152ee66dfab, 0xa831c66d2db43210, 0xb00327c898fb213f, 0xbf597fc7beef0ee4,
|
||||
0xc6e00bf33da88fc2, 0xd5a79147930aa725, 0x06ca6351e003826f, 0x142929670a0e6e70,
|
||||
0x27b70a8546d22ffc, 0x2e1b21385c26c926, 0x4d2c6dfc5ac42aed, 0x53380d139d95b3df,
|
||||
0x650a73548baf63de, 0x766a0abb3c77b2a8, 0x81c2c92e47edaee6, 0x92722c851482353b,
|
||||
0xa2bfe8a14cf10364, 0xa81a664bbc423001, 0xc24b8b70d0f89791, 0xc76c51a30654be30,
|
||||
0xd192e819d6ef5218, 0xd69906245565a910, 0xf40e35855771202a, 0x106aa07032bbd1b8,
|
||||
0x19a4c116b8d2d0c8, 0x1e376c085141ab53, 0x2748774cdf8eeb99, 0x34b0bcb5e19b48a8,
|
||||
0x391c0cb3c5c95a63, 0x4ed8aa4ae3418acb, 0x5b9cca4f7763e373, 0x682e6ff3d6b2b8a3,
|
||||
0x748f82ee5defb2fc, 0x78a5636f43172f60, 0x84c87814a1f0ab72, 0x8cc702081a6439ec,
|
||||
0x90befffa23631e28, 0xa4506cebde82bde9, 0xbef9a3f7b2c67915, 0xc67178f2e372532b,
|
||||
0xca273eceea26619c, 0xd186b8c721c0c207, 0xeada7dd6cde0eb1e, 0xf57d4f7fee6ed178,
|
||||
0x06f067aa72176fba, 0x0a637dc5a2c898a6, 0x113f9804bef90dae, 0x1b710b35131c471b,
|
||||
0x28db77f523047d84, 0x32caab7b40c72493, 0x3c9ebe0a15c9bebc, 0x431d67c49c100d4c,
|
||||
0x4cc5d4becb3e42b6, 0x597f299cfc657e2a, 0x5fcb6fab3ad6faec, 0x6c44198c4a475817
|
||||
};
|
||||
|
||||
protected static void UInt32_To_BE(uint n, byte[] bs, int off)
|
||||
{
|
||||
bs[off] = (byte)(n >> 24);
|
||||
bs[++off] = (byte)(n >> 16);
|
||||
bs[++off] = (byte)(n >> 8);
|
||||
bs[++off] = (byte)(n);
|
||||
}
|
||||
protected static void UInt64_To_BE(ulong n, byte[] bs, int off)
|
||||
{
|
||||
UInt32_To_BE((uint)(n >> 32), bs, off);
|
||||
UInt32_To_BE((uint)(n), bs, off + 4);
|
||||
}
|
||||
protected static ulong BE_To_UInt64(byte[] bs)
|
||||
{
|
||||
uint hi = BE_To_UInt32(bs);
|
||||
uint lo = BE_To_UInt32(bs, 4);
|
||||
return ((ulong)hi << 32) | (ulong)lo;
|
||||
}
|
||||
protected static ulong BE_To_UInt64(byte[] bs, int off)
|
||||
{
|
||||
uint hi = BE_To_UInt32(bs, off);
|
||||
uint lo = BE_To_UInt32(bs, off + 4);
|
||||
return ((ulong)hi << 32) | (ulong)lo;
|
||||
}
|
||||
protected static uint BE_To_UInt32(byte[] bs, int off)
|
||||
{
|
||||
uint n = (uint)bs[off] << 24;
|
||||
n |= (uint)bs[++off] << 16;
|
||||
n |= (uint)bs[++off] << 8;
|
||||
n |= (uint)bs[++off];
|
||||
return n;
|
||||
}
|
||||
protected static uint BE_To_UInt32(byte[] bs)
|
||||
{
|
||||
uint n = (uint)bs[0] << 24;
|
||||
n |= (uint)bs[1] << 16;
|
||||
n |= (uint)bs[2] << 8;
|
||||
n |= (uint)bs[3];
|
||||
return n;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
namespace Renci.SshNet.Security.Cryptography
|
||||
{
|
||||
public class SHA384Hash : SHA2HashBase
|
||||
{
|
||||
private const int DIGEST_SIZE = 48;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the size, in bits, of the computed hash code.
|
||||
/// </summary>
|
||||
/// <returns>The size, in bits, of the computed hash code.</returns>
|
||||
public override int HashSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return DIGEST_SIZE * 8;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When overridden in a derived class, gets the input block size.
|
||||
/// </summary>
|
||||
/// <returns>The input block size.</returns>
|
||||
public override int InputBlockSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return DIGEST_SIZE * 2;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When overridden in a derived class, gets the output block size.
|
||||
/// </summary>
|
||||
/// <returns>The output block size.</returns>
|
||||
public override int OutputBlockSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return DIGEST_SIZE * 2;
|
||||
}
|
||||
}
|
||||
|
||||
protected override byte[] HashFinal()
|
||||
{
|
||||
var output = new byte[DIGEST_SIZE];
|
||||
|
||||
this.Finish();
|
||||
|
||||
SHA2HashBase.UInt64_To_BE(H1, output, 0);
|
||||
SHA2HashBase.UInt64_To_BE(H2, output, 8);
|
||||
SHA2HashBase.UInt64_To_BE(H3, output, 16);
|
||||
SHA2HashBase.UInt64_To_BE(H4, output, 24);
|
||||
SHA2HashBase.UInt64_To_BE(H5, output, 32);
|
||||
SHA2HashBase.UInt64_To_BE(H6, output, 40);
|
||||
|
||||
this.Initialize();
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
/* SHA-384 initial hash value
|
||||
* The first 64 bits of the fractional parts of the square roots
|
||||
* of the 9th through 16th prime numbers
|
||||
*/
|
||||
H1 = 0xcbbb9d5dc1059ed8;
|
||||
H2 = 0x629a292a367cd507;
|
||||
H3 = 0x9159015a3070dd17;
|
||||
H4 = 0x152fecd8f70e5939;
|
||||
H5 = 0x67332667ffc00b31;
|
||||
H6 = 0x8eb44a8768581511;
|
||||
H7 = 0xdb0c2e0d64f98fa7;
|
||||
H8 = 0x47b5481dbefa4fa4;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
namespace Renci.SshNet.Security.Cryptography
|
||||
{
|
||||
public class SHA512Hash : SHA2HashBase
|
||||
{
|
||||
private const int DIGEST_SIZE = 64;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the size, in bits, of the computed hash code.
|
||||
/// </summary>
|
||||
/// <returns>The size, in bits, of the computed hash code.</returns>
|
||||
public override int HashSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return DIGEST_SIZE * 8;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When overridden in a derived class, gets the input block size.
|
||||
/// </summary>
|
||||
/// <returns>The input block size.</returns>
|
||||
public override int InputBlockSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return DIGEST_SIZE * 2;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When overridden in a derived class, gets the output block size.
|
||||
/// </summary>
|
||||
/// <returns>The output block size.</returns>
|
||||
public override int OutputBlockSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return DIGEST_SIZE * 2;
|
||||
}
|
||||
}
|
||||
|
||||
protected override byte[] HashFinal()
|
||||
{
|
||||
var output = new byte[DIGEST_SIZE];
|
||||
|
||||
this.Finish();
|
||||
|
||||
SHA2HashBase.UInt64_To_BE(H1, output, 0);
|
||||
SHA2HashBase.UInt64_To_BE(H2, output, 8);
|
||||
SHA2HashBase.UInt64_To_BE(H3, output, 16);
|
||||
SHA2HashBase.UInt64_To_BE(H4, output, 24);
|
||||
SHA2HashBase.UInt64_To_BE(H5, output, 32);
|
||||
SHA2HashBase.UInt64_To_BE(H6, output, 40);
|
||||
SHA2HashBase.UInt64_To_BE(H7, output, 48);
|
||||
SHA2HashBase.UInt64_To_BE(H8, output, 56);
|
||||
|
||||
this.Initialize();
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
/* SHA-512 initial hash value
|
||||
* The first 64 bits of the fractional parts of the square roots
|
||||
* of the first eight prime numbers
|
||||
*/
|
||||
H1 = 0x6a09e667f3bcc908;
|
||||
H2 = 0xbb67ae8584caa73b;
|
||||
H3 = 0x3c6ef372fe94f82b;
|
||||
H4 = 0xa54ff53a5f1d36f1;
|
||||
H5 = 0x510e527fade682d1;
|
||||
H6 = 0x9b05688c2b3e6c1f;
|
||||
H7 = 0x1f83d9abfb41bd6b;
|
||||
H8 = 0x5be0cd19137e2179;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ namespace Renci.SshNet.Security.Cryptography
|
||||
public RsaDigitalSignature(RsaKey rsaKey)
|
||||
: base(new ObjectIdentifier(1, 3, 14, 3, 2, 26), new RsaCipher(rsaKey))
|
||||
{
|
||||
this._hash = new SHA1Hash();
|
||||
this._hash = HashAlgorithmFactory.CreateSHA1();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -16,15 +16,10 @@ namespace Renci.SshNet.Security
|
||||
public abstract class KeyExchange : Algorithm, IKeyExchange
|
||||
{
|
||||
private CipherInfo _clientCipherInfo;
|
||||
|
||||
private CipherInfo _serverCipherInfo;
|
||||
|
||||
private HashInfo _clientHashInfo;
|
||||
|
||||
private HashInfo _serverHashInfo;
|
||||
|
||||
private Type _compressionType;
|
||||
|
||||
private Type _decompressionType;
|
||||
|
||||
/// <summary>
|
||||
@@ -287,7 +282,7 @@ namespace Renci.SshNet.Security
|
||||
/// </summary>
|
||||
/// <param name="host">The host algorithm.</param>
|
||||
/// <returns>
|
||||
/// <c>true</c> if the specified host can be trusted; otherwise, <c>false</c>.
|
||||
/// <c>true</c> if the specified host can be trusted; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
protected bool CanTrustHostKey(KeyHostAlgorithm host)
|
||||
{
|
||||
@@ -323,7 +318,7 @@ namespace Renci.SshNet.Security
|
||||
/// </returns>
|
||||
protected virtual byte[] Hash(byte[] hashData)
|
||||
{
|
||||
using (var sha1 = new SHA1Hash())
|
||||
using (var sha1 = HashAlgorithmFactory.CreateSHA1())
|
||||
{
|
||||
return sha1.ComputeHash(hashData, 0, hashData.Length);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Renci.SshNet.Messages.Transport;
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
@@ -24,9 +24,9 @@ namespace Renci.SshNet.Security
|
||||
/// </returns>
|
||||
protected override byte[] Hash(byte[] hashBytes)
|
||||
{
|
||||
using (var md = new SHA256Hash())
|
||||
using (var sha256 = HashAlgorithmFactory.CreateSHA256())
|
||||
{
|
||||
return md.ComputeHash(hashBytes);
|
||||
return sha256.ComputeHash(hashBytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Transport;
|
||||
@@ -70,6 +71,7 @@ namespace Renci.SshNet
|
||||
/// </summary>
|
||||
/// <param name="clientAlgorithms">A <see cref="IDictionary{String, Type}"/> of the key exchange algorithms supported by the client where key is the name of the algorithm, and value is the type implementing this algorithm.</param>
|
||||
/// <param name="serverAlgorithms">The names of the key exchange algorithms supported by the SSH server.</param>
|
||||
/// <param name="hashAlgorithmFactory">The factory to use for creating <see cref="HashAlgorithm"/> instances.</param>
|
||||
/// <returns>
|
||||
/// A <see cref="IKeyExchange"/> that was negotiated between client and server.
|
||||
/// </returns>
|
||||
@@ -94,7 +96,7 @@ namespace Renci.SshNet
|
||||
throw new SshConnectionException("Failed to negotiate key exchange algorithm.", DisconnectReason.KeyExchangeFailed);
|
||||
}
|
||||
|
||||
return keyExchangeAlgorithmType.CreateInstance<KeyExchange>();
|
||||
return keyExchangeAlgorithmType.CreateInstance<IKeyExchange>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -479,6 +479,7 @@ namespace Renci.SshNet
|
||||
/// </summary>
|
||||
/// <param name="connectionInfo">The connection info.</param>
|
||||
/// <param name="serviceFactory">The factory to use for creating new services.</param>
|
||||
/// <exception cref="ArgumentNullException"><paramref name="connectionInfo"/> is <c>null</c>.</exception>
|
||||
/// <exception cref="ArgumentNullException"><paramref name="serviceFactory"/> is <c>null</c>.</exception>
|
||||
internal Session(ConnectionInfo connectionInfo, IServiceFactory serviceFactory)
|
||||
{
|
||||
@@ -487,9 +488,8 @@ namespace Renci.SshNet
|
||||
if (serviceFactory == null)
|
||||
throw new ArgumentNullException("serviceFactory");
|
||||
|
||||
ConnectionInfo = connectionInfo;
|
||||
//this.ClientVersion = string.Format(CultureInfo.CurrentCulture, "SSH-2.0-Renci.SshNet.SshClient.{0}", this.GetType().Assembly.GetName().Version);
|
||||
ClientVersion = "SSH-2.0-Renci.SshNet.SshClient.0.0.1";
|
||||
ConnectionInfo = connectionInfo;
|
||||
_serviceFactory = serviceFactory;
|
||||
_messageListenerCompleted = new ManualResetEvent(true);
|
||||
}
|
||||
@@ -1361,7 +1361,7 @@ namespace Renci.SshNet
|
||||
}
|
||||
|
||||
_keyExchange = _serviceFactory.CreateKeyExchange(ConnectionInfo.KeyExchangeAlgorithms,
|
||||
message.KeyExchangeAlgorithms);
|
||||
message.KeyExchangeAlgorithms);
|
||||
|
||||
ConnectionInfo.CurrentKeyExchangeAlgorithm = _keyExchange.Name;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user