├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── appveyor.yml ├── build ├── build.proj └── nuget │ └── SshNet.Security.Cryptography.nuspec ├── src ├── .nuget │ └── NuGet.Config ├── SshNet.Security.Cryptography.NET20 │ ├── Properties │ │ └── AssemblyInfo.cs │ └── SshNet.Security.Cryptography.NET20.csproj ├── SshNet.Security.Cryptography.NET40 │ ├── Properties │ │ └── AssemblyInfo.cs │ └── SshNet.Security.Cryptography.NET40.csproj ├── SshNet.Security.Cryptography.NET45+Win8+WPA81 │ ├── Properties │ │ └── AssemblyInfo.cs │ └── SshNet.Security.Cryptography.NET45+Win8+WPA81.csproj ├── SshNet.Security.Cryptography.NET45 │ ├── Properties │ │ └── AssemblyInfo.cs │ └── SshNet.Security.Cryptography.NET45.csproj ├── SshNet.Security.Cryptography.NETStandard │ ├── Properties │ │ └── AssemblyInfo.cs │ └── SshNet.Security.Cryptography.NETStandard.csproj ├── SshNet.Security.Cryptography.Shared │ ├── HMAC.cs │ ├── HMACMD5.cs │ ├── HMACRIPEMD160.cs │ ├── HMACSHA1.cs │ ├── HMACSHA256.cs │ ├── HMACSHA384.cs │ ├── HMACSHA512.cs │ ├── HashAlgorithm.cs │ ├── HashProviderBase.cs │ ├── IHashProvider.cs │ ├── KeyedHashAlgorithm.cs │ ├── MD5.cs │ ├── MD5HashProvider.cs │ ├── Properties │ │ └── CommonAssemblyInfo.cs │ ├── RIPEMD160.cs │ ├── RIPEMD160HashProvider.cs │ ├── SHA1.cs │ ├── SHA1HashProvider.cs │ ├── SHA256.cs │ ├── SHA256HashProvider.cs │ ├── SHA2HashProviderBase.cs │ ├── SHA384.cs │ ├── SHA384HashProvider.cs │ ├── SHA512.cs │ ├── SHA512HashProvider.cs │ ├── SshNet.Security.Cryptography.Shared.projitems │ └── SshNet.Security.Cryptography.Shared.shproj ├── SshNet.Security.Cryptography.Silverlight4 │ ├── Properties │ │ └── AssemblyInfo.cs │ └── SshNet.Security.Cryptography.Silverlight4.csproj ├── SshNet.Security.Cryptography.Silverlight5 │ ├── Properties │ │ └── AssemblyInfo.cs │ └── SshNet.Security.Cryptography.Silverlight5.csproj ├── SshNet.Security.Cryptography.UAP10 │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SshNet.Security.Cryptography.UAP10.csproj │ └── project.json ├── SshNet.Security.Cryptography.VS2012.sln ├── SshNet.Security.Cryptography.VS2012.sln.DotSettings ├── SshNet.Security.Cryptography.VS2015.sln ├── SshNet.Security.Cryptography.VS2015.sln.DotSettings ├── SshNet.Security.Cryptography.VS2017.sln ├── SshNet.Security.Cryptography.WindowsPhone71 │ ├── Properties │ │ └── AssemblyInfo.cs │ └── SshNet.Security.Cryptography.WindowsPhone71.csproj ├── SshNet.Security.Cryptography.WindowsPhone80 │ ├── Properties │ │ └── AssemblyInfo.cs │ └── SshNet.Security.Cryptography.WindowsPhone80.csproj └── SshNet.Security.Cryptography.snk └── test ├── SshNet.Security.Cryptography.NET20.Tests ├── Properties │ └── AssemblyInfo.cs ├── SshNet.Security.Cryptography.NET20.Tests.csproj └── packages.config ├── SshNet.Security.Cryptography.NET40.Tests ├── Properties │ └── AssemblyInfo.cs ├── SshNet.Security.Cryptography.NET40.Tests.csproj └── packages.config ├── SshNet.Security.Cryptography.NET45+Win8+WPA81.Tests ├── Properties │ └── AssemblyInfo.cs ├── SshNet.Security.Cryptography.NET45+Win8+WPA81.Tests.csproj └── packages.config ├── SshNet.Security.Cryptography.Shared.Tests ├── Common │ ├── ByteExtensions.cs │ └── StringExtensions.cs ├── HMACMD5Test.cs ├── HMACRIPEMD160Test.cs ├── HMACSHA1Test.cs ├── HMACSHA256Test.cs ├── HMACSHA384Test.cs ├── HMACSHA512Test.cs ├── MD5Test.cs ├── Properties │ ├── AssemblyInfo.cs │ └── CommonAssemblyInfo.cs ├── RIPEMD160Test.cs ├── SHA1Test.cs ├── SHA256Test.cs ├── SHA384Test.cs ├── SHA512Test.cs ├── SshNet.Security.Cryptography.Shared.Tests.shproj └── SshNet.Security.Cryptography.Shared.projitems └── SshNet.Security.Cryptography.UAP10.Tests ├── Assets ├── LockScreenLogo.scale-200.png ├── SplashScreen.scale-200.png ├── Square150x150Logo.scale-200.png ├── Square44x44Logo.scale-200.png ├── Square44x44Logo.targetsize-24_altform-unplated.png ├── StoreLogo.png └── Wide310x150Logo.scale-200.png ├── Package.appxmanifest ├── Properties ├── AssemblyInfo.cs └── UnitTestApp.rd.xml ├── Renci.Security.Cryptography.UAP10.Tests.nuget.props ├── Renci.Security.Cryptography.UAP10.Tests.nuget.targets ├── SshNet.Security.Cryptography.UAP10.Tests.csproj ├── SshNet.Security.Cryptography.UAP10.Tests.nuget.props ├── SshNet.Security.Cryptography.UAP10.Tests.nuget.targets ├── SshNet.pfx ├── UnitTestApp.xaml ├── UnitTestApp.xaml.cs └── project.json /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | 3 | *.cs text 4 | *.xaml text 5 | *.sln text eol=crlf 6 | *.csproj text eol=crlf 7 | *.shproj text eol=crlf 8 | *.appxmanifest text eol=crlf 9 | 10 | *.png binary 11 | *.jpg binary 12 | *.dll binary 13 | *.pdb binary 14 | *.exe binary 15 | *.nupkg binary 16 | *.pdf binary 17 | *.snk binary 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Visual Studio build output 2 | src/**/bin/** 3 | src/**/obj/** 4 | test/**/bin/** 5 | test/**/obj/** 6 | test/SshNet.Security.Cryptography.UAP10.Tests/AppPackages/** 7 | 8 | # User-specific files 9 | *.suo 10 | *.user 11 | 12 | # NuGet packages 13 | packages/ 14 | 15 | # Visual Studio 2015 cache/options directory 16 | src/.vs/ 17 | 18 | # Automated build output 19 | build/target 20 | 21 | # Expanded/resolved project.json files 22 | project.lock.json 23 | x 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #SshNet.Security.Cryptography# 2 | 3 | [![Version](https://img.shields.io/nuget/vpre/SshNet.Security.Cryptography.svg)](https://www.nuget.org/packages/SshNet.Security.Cryptography) 4 | [![Build status](https://ci.appveyor.com/api/projects/status/r12lb7hjfjnefv6e/branch/master?svg=true)](https://ci.appveyor.com/project/drieseng/cryptography/branch/master) 5 | 6 | ##Introduction## 7 | This project groups some crypto classes that were previously part of **SSH.NET**, and makes them available for a broad set of target frameworks. 8 | 9 | ##Hash algorithms## 10 | 11 | **SshNet.Security.Cryptography** features the following hash functions: 12 | * md5 13 | * sha1 14 | * sha2-256 15 | * sha2-384 16 | * sha2-512 17 | * ripemd160 18 | 19 | ##Message Authentication Code## 20 | 21 | **SshNet.Security.Cryptography** includes the following MAC algorithms: 22 | * hmac-md5 23 | * hmac-sha1 24 | * hmac-sha2-256 25 | * hmac-sha2-384 26 | * hmac-sha2-512 27 | * hmac-ripemd160 28 | 29 | ##Framework Support## 30 | **SshNet.Security.Cryptography** is available for the following target frameworks: 31 | 32 | Target Framework Moniker | Frameworks 33 | :------------------------ | :--------------------------------------------------- 34 | net20 | .NET Framework 2.0 35 | net40 | .NET Framework 4.0 36 | net45 | .NET Framework 4.5 37 | netstandard1.0 | .NET Platform Standard 1.0 38 | netstandard1.3 | .NET Platform Standard 1.3 39 | portable-net45+win8+wpa81 | .NET Framework 4.5
Windows 8
Windows Phone 8.1 40 | sl4 | Silverlight 4 41 | sl5 | Silverlight 5 42 | uap10.0 | Universal Windows Platform 10 43 | wp71 | Windows Phone Silverlight 7.1 44 | wp8 | Windows Phone Silverlight 8.0 45 | 46 | In our codebase, we use the following conditional compilation symbols to identity features supported by a given target framework: 47 | 48 | Symbol | Description 49 | :----------------------------| :-------------------------------------------------------------------------------- 50 | FEATURE_CRYPTO_HASHALGORITHM | [HashAlgorithm](https://msdn.microsoft.com/en-us/library/system.security.cryptography.hashalgorithm.aspx) and [KeyedHashAlgorithm](https://msdn.microsoft.com/en-us/library/system.security.cryptography.keyedhashalgorithm.aspx) classes are available 51 | 52 | ##Build## 53 | The following software is required to build **SshNet.Security.Cryptography** in all its supported flavors: 54 | 55 | Software | net35 | net40 | net45 | netstandard1.0 | netstandard1.3 | portable-net45+win8+wpa81 | sl4 | sl5 | uap10.0 | wp71 | wp8 | 56 | --------------------------------- | :---: | :---: | :---: | :------------: | :------------: | :-----------------------: | :-: | :-: | :-----: | :--: | :-: | 57 | Windows Phone SDK 8.0 | | | | | | x | x | x | | x | x | 58 | Visual Studio 2012 Update 5 | x | x | | | | | x | x | | x | x | 59 | Visual Studio 2015 Update 3 | x | x | x | x | x | x | | x | x | | x | 60 | .NET Core 1.0 Visual Studio Tools | | | | x | x | | | | | | | 61 | 62 | **Note:** 63 | 64 | Where possible, we use the **Shared Project** concept - which was introduced in **Visual Studio 2015** - to share code between *flavors* of **SshNet.Security.Cryptography**. 65 | To avoid maintaining two sets of project files, these projects can only be built in **Visual Studio 2015** (or higher). 66 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | os: Visual Studio 2015 2 | 3 | before_build: 4 | - nuget restore src\SshNet.Security.Cryptography.VS2015.sln 5 | 6 | build: 7 | project: src\SshNet.Security.Cryptography.VS2015.sln 8 | verbosity: minimal 9 | 10 | test: 11 | assemblies: test\SshNet.Security.Cryptography.NET40.Tests\bin\Debug\SshNet.Security.Cryptography.Tests.dll 12 | -------------------------------------------------------------------------------- /build/build.proj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Release 5 | $(MSBuildThisFileDirectory) 6 | $(BuildRoot)target\nuget\nuget.exe 7 | $(MSBuildThisFileDirectory)msbuild 8 | 9 | 10 | 11 | $(MSBuildThisFileDirectory)..\src\SshNet.Security.Cryptography.VS2012.sln 12 | 14.0 13 | 14.0 14 | 15 | 16 | $(MSBuildThisFileDirectory)..\src\SshNet.Security.Cryptography.VS2015.sln 17 | 14.0 18 | 14.0 19 | 20 | 21 | $(MSBuildThisFileDirectory)..\src\SshNet.Security.Cryptography.VS2017.sln 22 | 15.0 23 | 15.0 24 | 25 | 26 | 27 | 28 | SshNet.Security.Cryptography.NET20\bin\$(Configuration) 29 | net20 30 | 31 | 32 | SshNet.Security.Cryptography.NET40\bin\$(Configuration) 33 | net40 34 | 35 | 36 | SshNet.Security.Cryptography.NET45\bin\$(Configuration) 37 | net45 38 | 39 | 40 | SshNet.Security.Cryptography.Silverlight4\bin\$(Configuration) 41 | sl4 42 | 43 | 44 | SshNet.Security.Cryptography.Silverlight5\bin\$(Configuration) 45 | sl5 46 | 47 | 48 | SshNet.Security.Cryptography.UAP10\bin\$(Configuration) 49 | uap10.0 50 | 51 | 52 | SshNet.Security.Cryptography.WindowsPhone71\bin\$(Configuration) 53 | wp71 54 | 55 | 56 | SshNet.Security.Cryptography.WindowsPhone80\bin\$(Configuration) 57 | wp8 58 | 59 | 60 | SshNet.Security.Cryptography.NET45+Win8+WPA81\bin\$(Configuration) 61 | portable-net45+win8+wpa81 62 | 63 | 64 | SshNet.Security.Cryptography.NETStandard\bin\$(Configuration)\netstandard1.0 65 | netstandard1.0 66 | 67 | 68 | SshNet.Security.Cryptography.NETStandard\bin\$(Configuration)\netstandard1.3 69 | netstandard1.3 70 | 71 | 72 | SshNet.Security.Cryptography.NETStandard\bin\$(Configuration)\netstandard2.0 73 | netstandard2.0 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | Configuration=Release;VisualStudioVersion=%(VisualStudioVersion.VisualStudioVersion) 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | Configuration=Release;VisualStudioVersion=%(VisualStudioVersion.VisualStudioVersion) 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 |
128 | 129 | 130 | 131 | 132 | 133 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /build/nuget/SshNet.Security.Cryptography.nuspec: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | SshNet.Security.Cryptography 5 | 1.3.0 6 | SshNet.Security.Cryptography 7 | Renci 8 | drieseng,olegkap 9 | false 10 | https://github.com/sshnet/Cryptography/blob/master/LICENSE 11 | https://github.com/sshnet/Cryptography/ 12 | Cryptographic functions for .NET 13 | Cryptographic functions for .NET 14 | https://github.com/sshnet/Cryptography/releases/tag/1.3.0 15 | 2010-2017, RENCI 16 | en-US 17 | crypto 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/.nuget/NuGet.Config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.NET20/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("SshNet.Security.Cryptography for .NET 2.0")] 5 | [assembly: Guid("4EE4F2DC-208D-42B2-B286-5E5DEC1DD766")] 6 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.NET20/SshNet.Security.Cryptography.NET20.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {FF9FE022-4B50-4B6A-97EA-A2ECFD5DE783} 8 | Library 9 | Properties 10 | SshNet.Security.Cryptography 11 | SshNet.Security.Cryptography 12 | v2.0 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | TRACE;DEBUG;FEATURE_CRYPTO_HASHALGORITHM 22 | prompt 23 | 4 24 | true 25 | bin\Debug\SshNet.Security.Cryptography.xml 26 | 27 | 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE;FEATURE_CRYPTO_HASHALGORITHM 32 | prompt 33 | 4 34 | true 35 | bin\Release\SshNet.Security.Cryptography.xml 36 | 37 | 38 | true 39 | 40 | 41 | ..\SshNet.Security.Cryptography.snk 42 | 43 | 44 | 45 | HashProviderBase.cs 46 | 47 | 48 | HMAC.cs 49 | 50 | 51 | HMACMD5.cs 52 | 53 | 54 | HMACRIPEMD160.cs 55 | 56 | 57 | HMACSHA1.cs 58 | 59 | 60 | HMACSHA256.cs 61 | 62 | 63 | HMACSHA384.cs 64 | 65 | 66 | HMACSHA512.cs 67 | 68 | 69 | IHashProvider.cs 70 | 71 | 72 | MD5.cs 73 | 74 | 75 | MD5HashProvider.cs 76 | 77 | 78 | Properties\CommonAssemblyInfo.cs 79 | 80 | 81 | RIPEMD160.cs 82 | 83 | 84 | RIPEMD160HashProvider.cs 85 | 86 | 87 | SHA1.cs 88 | 89 | 90 | SHA1HashProvider.cs 91 | 92 | 93 | SHA256.cs 94 | 95 | 96 | SHA256HashProvider.cs 97 | 98 | 99 | SHA2HashProviderBase.cs 100 | 101 | 102 | SHA384.cs 103 | 104 | 105 | SHA384HashProvider.cs 106 | 107 | 108 | SHA512.cs 109 | 110 | 111 | SHA512HashProvider.cs 112 | 113 | 114 | 115 | 116 | 117 | SshNet.Security.Cryptography.snk 118 | 119 | 120 | 121 | 128 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.NET40/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("SshNet.Security.Cryptography for .NET 4.0")] 5 | [assembly: Guid("5188A5FC-A40E-4C37-8ECE-3876783E706B")] 6 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.NET40/SshNet.Security.Cryptography.NET40.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {6A8919D5-1801-42C8-90EC-36A0CA7A406D} 8 | Library 9 | Properties 10 | SshNet.Security.Cryptography 11 | SshNet.Security.Cryptography 12 | v4.0 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | TRACE;DEBUG;FEATURE_CRYPTO_HASHALGORITHM 22 | prompt 23 | 4 24 | true 25 | bin\Debug\SshNet.Security.Cryptography.xml 26 | 27 | 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE;FEATURE_CRYPTO_HASHALGORITHM 32 | prompt 33 | 4 34 | bin\Release\SshNet.Security.Cryptography.xml 35 | true 36 | 37 | 38 | true 39 | 40 | 41 | ..\SshNet.Security.Cryptography.snk 42 | 43 | 44 | 45 | HashProviderBase.cs 46 | 47 | 48 | HMAC.cs 49 | 50 | 51 | HMACMD5.cs 52 | 53 | 54 | HMACRIPEMD160.cs 55 | 56 | 57 | HMACSHA1.cs 58 | 59 | 60 | HMACSHA256.cs 61 | 62 | 63 | HMACSHA384.cs 64 | 65 | 66 | HMACSHA512.cs 67 | 68 | 69 | IHashProvider.cs 70 | 71 | 72 | MD5.cs 73 | 74 | 75 | MD5HashProvider.cs 76 | 77 | 78 | Properties\CommonAssemblyInfo.cs 79 | 80 | 81 | RIPEMD160.cs 82 | 83 | 84 | RIPEMD160HashProvider.cs 85 | 86 | 87 | SHA1.cs 88 | 89 | 90 | SHA1HashProvider.cs 91 | 92 | 93 | SHA256.cs 94 | 95 | 96 | SHA256HashProvider.cs 97 | 98 | 99 | SHA2HashProviderBase.cs 100 | 101 | 102 | SHA384.cs 103 | 104 | 105 | SHA384HashProvider.cs 106 | 107 | 108 | SHA512.cs 109 | 110 | 111 | SHA512HashProvider.cs 112 | 113 | 114 | 115 | 116 | 117 | SshNet.Security.Cryptography.snk 118 | 119 | 120 | 121 | 128 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.NET45+Win8+WPA81/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("SshNet.Security.Cryptography for .NET 4.5, Windows 8 and Windows Phone 8.1")] 5 | [assembly: Guid("96C6BA09-BD79-474D-806B-0E112974C924")] 6 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.NET45+Win8+WPA81/SshNet.Security.Cryptography.NET45+Win8+WPA81.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 11.0 6 | Debug 7 | AnyCPU 8 | {F9CC3198-697C-439A-B64B-F9DFAF3EBFF7} 9 | Library 10 | Properties 11 | SshNet.Security.Cryptography 12 | SshNet.Security.Cryptography 13 | en-US 14 | 512 15 | {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 16 | Profile111 17 | v4.5 18 | 19 | 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | TRACE;DEBUG 25 | prompt 26 | 4 27 | true 28 | bin\Debug\SshNet.Security.Cryptography.xml 29 | 30 | 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | bin\Release\SshNet.Security.Cryptography.xml 38 | true 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 55 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.NET45/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("SshNet.Security.Cryptography for .NET 4.5")] 5 | [assembly: Guid("A31E209A-4C42-4C58-9F52-62F7552C22E2")] 6 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.NET45/SshNet.Security.Cryptography.NET45.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {34EFA5C7-4A8A-464B-B4C4-915B132483D6} 8 | Library 9 | Properties 10 | SshNet.Security.Cryptography 11 | SshNet.Security.Cryptography 12 | v4.5 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | TRACE;DEBUG;FEATURE_CRYPTO_HASHALGORITHM 22 | prompt 23 | 4 24 | bin\Debug\SshNet.Security.Cryptography.xml 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE;FEATURE_CRYPTO_HASHALGORITHM 31 | prompt 32 | 4 33 | bin\Release\SshNet.Security.Cryptography.xml 34 | 35 | 36 | 37 | 38 | 39 | 40 | 47 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.NETStandard/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | [assembly: AssemblyTitle("SshNet.Security.Cryptography for .NET Standard")] -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.NETStandard/SshNet.Security.Cryptography.NETStandard.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | netstandard1.0;netstandard1.3;netstandard2.0 4 | true 5 | SshNet.Security.Cryptography 6 | ../SshNet.Security.Cryptography.snk 7 | true 8 | false 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | $(DefineConstants);FEATURE_CRYPTO_HASHALGORITHM 19 | 20 | 21 | $(DefineConstants);FEATURE_CRYPTO_HASHALGORITHM 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.Shared/HMAC.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Security.Cryptography; 3 | 4 | namespace SshNet.Security.Cryptography 5 | { 6 | /// 7 | /// Provides HMAC algorithm implementation. 8 | /// 9 | public abstract class HMAC : KeyedHashAlgorithm 10 | { 11 | private IHashProvider _hashProvider; 12 | private byte[] _innerPadding; 13 | private byte[] _outerPadding; 14 | private readonly int _hashSize; 15 | 16 | /// 17 | /// Holds value indicating whether the inner padding was already written. 18 | /// 19 | private bool _innerPaddingWritten; 20 | 21 | /// 22 | /// Gets the size of the block. 23 | /// 24 | /// 25 | /// The size of the block. 26 | /// 27 | protected abstract int BlockSize { get; } 28 | 29 | /// 30 | /// Gets the size, in bits, of the computed hash code. 31 | /// 32 | /// 33 | /// The size, in bits, of the computed hash code. 34 | /// 35 | public override int HashSize { 36 | get { return _hashSize; } 37 | } 38 | 39 | /// 40 | /// Initializes a with the specified hash algorithm. 41 | /// 42 | /// The hash provider. 43 | /// is null. 44 | private HMAC(IHashProvider hashProvider) 45 | { 46 | if (hashProvider == null) 47 | throw new ArgumentNullException("hashProvider"); 48 | 49 | _hashProvider = hashProvider; 50 | _hashSize = _hashProvider.HashSize; 51 | } 52 | 53 | /// 54 | /// Initializes a with the specified hash algorithm, key and size of the computed 55 | /// hash code. 56 | /// 57 | /// The hash provider. 58 | /// The key. 59 | /// The size, in bits, of the computed hash code. 60 | /// is null. 61 | internal HMAC(IHashProvider hashProvider, byte[] key, int hashSize) 62 | : this(hashProvider, key) 63 | { 64 | _hashSize = hashSize; 65 | } 66 | 67 | /// 68 | /// Initializes a with the specified hash algorithm and key. 69 | /// 70 | /// The hash provider. 71 | /// The key. 72 | /// is null. 73 | internal HMAC(IHashProvider hashProvider, byte[] key) 74 | : this(hashProvider) 75 | { 76 | SetKey(key); 77 | } 78 | 79 | /// 80 | /// Gets or sets the key to use in the hash algorithm. 81 | /// 82 | /// 83 | /// The key to use in the hash algorithm. 84 | /// 85 | public override byte[] Key 86 | { 87 | get 88 | { 89 | return base.Key; 90 | } 91 | set 92 | { 93 | SetKey(value); 94 | } 95 | } 96 | 97 | /// 98 | /// Initializes an implementation of the class. 99 | /// 100 | public override void Initialize() 101 | { 102 | _hashProvider.Reset(); 103 | _innerPaddingWritten = false; 104 | } 105 | 106 | /// 107 | /// Hashes the core. 108 | /// 109 | /// The RGB. 110 | /// The ib. 111 | /// The cb. 112 | protected override void HashCore(byte[] rgb, int ib, int cb) 113 | { 114 | if (!_innerPaddingWritten) 115 | { 116 | // write the inner padding 117 | _hashProvider.TransformBlock(_innerPadding, 0, BlockSize, _innerPadding, 0); 118 | 119 | // ensure we only write inner padding once 120 | _innerPaddingWritten = true; 121 | } 122 | 123 | _hashProvider.HashCore(rgb, ib, cb); 124 | } 125 | 126 | /// 127 | /// Finalizes the hash computation after the last data is processed by the cryptographic stream object. 128 | /// 129 | /// 130 | /// The computed hash code. 131 | /// 132 | protected override byte[] HashFinal() 133 | { 134 | // finalize the original hash 135 | var hashValue = _hashProvider.ComputeHash(new byte[0]); 136 | 137 | // write the outer padding 138 | _hashProvider.TransformBlock(_outerPadding, 0, BlockSize, _outerPadding, 0); 139 | 140 | // write the inner hash and finalize the hash 141 | _hashProvider.TransformFinalBlock(hashValue, 0, hashValue.Length); 142 | 143 | var hash = _hashProvider.Hash; 144 | 145 | return GetTruncatedHash(hash); 146 | } 147 | 148 | /// 149 | /// Releases unmanaged and - optionally - managed resources 150 | /// 151 | /// true to release both managed and unmanaged resources; false to release only unmanaged ResourceMessages. 152 | protected override void Dispose(bool disposing) 153 | { 154 | base.Dispose(disposing); 155 | 156 | if (_hashProvider != null) 157 | { 158 | _hashProvider.Dispose(); 159 | _hashProvider = null; 160 | } 161 | } 162 | 163 | private byte[] GetTruncatedHash(byte[] hash) 164 | { 165 | var hashSizeBytes = HashSize / 8; 166 | if (hash.Length == hashSizeBytes) 167 | { 168 | return hash; 169 | } 170 | 171 | var truncatedHash = new byte[hashSizeBytes]; 172 | Buffer.BlockCopy(hash, 0, truncatedHash, 0, hashSizeBytes); 173 | return truncatedHash; 174 | } 175 | 176 | private void SetKey(byte[] value) 177 | { 178 | var shortenedKey = GetShortenedKey(value); 179 | 180 | _innerPadding = new byte[BlockSize]; 181 | _outerPadding = new byte[BlockSize]; 182 | 183 | // Compute inner and outer padding. 184 | for (var i = 0; i < shortenedKey.Length; i++) 185 | { 186 | _innerPadding[i] = (byte)(0x36 ^ shortenedKey[i]); 187 | _outerPadding[i] = (byte)(0x5C ^ shortenedKey[i]); 188 | } 189 | for (var i = shortenedKey.Length; i < BlockSize; i++) 190 | { 191 | _innerPadding[i] = 0x36; 192 | _outerPadding[i] = 0x5C; 193 | } 194 | 195 | // no need to explicitly clone as this is already done in the setter 196 | base.Key = shortenedKey; 197 | } 198 | 199 | /// 200 | /// Return a key that fits the of the . 201 | /// 202 | /// The key to shorten, if necessary. 203 | /// 204 | /// A hash of if is longer than the of the 205 | /// ; otherwise, . 206 | /// 207 | private byte[] GetShortenedKey(byte[] key) 208 | { 209 | if (key.Length > BlockSize) 210 | { 211 | return _hashProvider.ComputeHash(key); 212 | } 213 | 214 | return key; 215 | } 216 | } 217 | } 218 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.Shared/HMACMD5.cs: -------------------------------------------------------------------------------- 1 | namespace SshNet.Security.Cryptography 2 | { 3 | /// 4 | /// Computes a Hash-based Message Authentication Code (HMAC) by using the MD5 hash function. 5 | /// 6 | public class HMACMD5 : HMAC 7 | { 8 | /// 9 | /// Initializes a with the specified key. 10 | /// 11 | /// The key. 12 | public HMACMD5(byte[] key) 13 | : base(new MD5HashProvider(), key) 14 | { 15 | } 16 | 17 | /// 18 | /// Initializes a with the specified key and size of the computed hash code. 19 | /// 20 | /// The key. 21 | /// The size, in bits, of the computed hash code. 22 | public HMACMD5(byte[] key, int hashSize) 23 | : base(new MD5HashProvider(), key, hashSize) 24 | { 25 | } 26 | 27 | /// 28 | /// Gets or sets the block size, in bytes, to use in the hash value. 29 | /// 30 | /// 31 | /// The block size to use in the hash value. For this is 64 bytes. 32 | /// 33 | protected override int BlockSize 34 | { 35 | get { return 64; } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.Shared/HMACRIPEMD160.cs: -------------------------------------------------------------------------------- 1 | namespace SshNet.Security.Cryptography 2 | { 3 | /// 4 | /// Computes a Hash-based Message Authentication Code (HMAC) by using the hash function. 5 | /// 6 | public class HMACRIPEMD160 : HMAC 7 | { 8 | /// 9 | /// Initializes a with the specified key. 10 | /// 11 | /// The key. 12 | public HMACRIPEMD160(byte[] key) 13 | : base(new RIPEMD160HashProvider(), key) 14 | { 15 | } 16 | 17 | /// 18 | /// Gets or sets the block size, in bytes, to use in the hash value. 19 | /// 20 | /// 21 | /// The block size to use in the hash value. For this is 64 bytes. 22 | /// 23 | protected override int BlockSize 24 | { 25 | get { return 64; } 26 | } 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.Shared/HMACSHA1.cs: -------------------------------------------------------------------------------- 1 | namespace SshNet.Security.Cryptography 2 | { 3 | /// 4 | /// Computes a Hash-based Message Authentication Code (HMAC) by using the hash function. 5 | /// 6 | public class HMACSHA1 : HMAC 7 | { 8 | /// 9 | /// Initializes a with the specified key. 10 | /// 11 | /// The key. 12 | public HMACSHA1(byte[] key) 13 | : base(new SHA1HashProvider(), key) 14 | { 15 | } 16 | 17 | /// 18 | /// Initializes a with the specified key and size of the computed hash code. 19 | /// 20 | /// The key. 21 | /// The size, in bits, of the computed hash code. 22 | public HMACSHA1(byte[] key, int hashSize) 23 | : base(new SHA1HashProvider(), key, hashSize) 24 | { 25 | } 26 | 27 | /// 28 | /// Gets or sets the block size, in bytes, to use in the hash value. 29 | /// 30 | /// 31 | /// The block size to use in the hash value. For this is 64 bytes. 32 | /// 33 | protected override int BlockSize 34 | { 35 | get { return 64; } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.Shared/HMACSHA256.cs: -------------------------------------------------------------------------------- 1 | namespace SshNet.Security.Cryptography 2 | { 3 | /// 4 | /// Computes a Hash-based Message Authentication Code (HMAC) by using the hash function. 5 | /// 6 | public class HMACSHA256 : HMAC 7 | { 8 | /// 9 | /// Initializes a with the specified key. 10 | /// 11 | /// The key. 12 | public HMACSHA256(byte[] key) 13 | : base(new SHA256HashProvider(), key) 14 | { 15 | } 16 | 17 | /// 18 | /// Initializes a with the specified key and size of the computed hash code. 19 | /// 20 | /// The key. 21 | /// The size, in bits, of the computed hash code. 22 | public HMACSHA256(byte[] key, int hashSize) 23 | : base(new SHA256HashProvider(), key, hashSize) 24 | { 25 | } 26 | 27 | /// 28 | /// Gets or sets the block size, in bytes, to use in the hash value. 29 | /// 30 | /// 31 | /// The block size to use in the hash value. For this is 64 bytes. 32 | /// 33 | protected override int BlockSize 34 | { 35 | get { return 64; } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.Shared/HMACSHA384.cs: -------------------------------------------------------------------------------- 1 | namespace SshNet.Security.Cryptography 2 | { 3 | /// 4 | /// Computes a Hash-based Message Authentication Code (HMAC) by using the hash function. 5 | /// 6 | public class HMACSHA384 : HMAC 7 | { 8 | /// 9 | /// Initializes a with the specified key. 10 | /// 11 | /// The key. 12 | public HMACSHA384(byte[] key) 13 | : base(new SHA384HashProvider(), key) 14 | { 15 | } 16 | 17 | /// 18 | /// Initializes a with the specified key and size of the computed hash code. 19 | /// 20 | /// The key. 21 | /// The size, in bits, of the computed hash code. 22 | public HMACSHA384(byte[] key, int hashSize) 23 | : base(new SHA384HashProvider(), key, hashSize) 24 | { 25 | } 26 | 27 | /// 28 | /// Gets or sets the block size, in bytes, to use in the hash value. 29 | /// 30 | /// 31 | /// The block size to use in the hash value. For this is 128 bytes. 32 | /// 33 | protected override int BlockSize 34 | { 35 | get { return 128; } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.Shared/HMACSHA512.cs: -------------------------------------------------------------------------------- 1 | namespace SshNet.Security.Cryptography 2 | { 3 | /// 4 | /// Computes a Hash-based Message Authentication Code (HMAC) by using the hash function. 5 | /// 6 | public class HMACSHA512 : HMAC 7 | { 8 | /// 9 | /// Initializes a with the specified key. 10 | /// 11 | /// The key. 12 | public HMACSHA512(byte[] key) 13 | : base(new SHA512HashProvider(), key) 14 | { 15 | } 16 | 17 | /// 18 | /// Initializes a with the specified key and size of the computed hash code. 19 | /// 20 | /// The key. 21 | /// The size, in bits, of the computed hash code. 22 | public HMACSHA512(byte[] key, int hashSize) 23 | : base(new SHA512HashProvider(), key, hashSize) 24 | { 25 | } 26 | 27 | /// 28 | /// Gets or sets the block size, in bytes, to use in the hash value. 29 | /// 30 | /// 31 | /// The block size to use in the hash value. For this is 128 bytes. 32 | /// 33 | protected override int BlockSize 34 | { 35 | get { return 128; } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.Shared/IHashProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SshNet.Security.Cryptography 4 | { 5 | internal interface IHashProvider : IDisposable 6 | { 7 | /// 8 | /// Gets the size, in bits, of the computed hash code. 9 | /// 10 | /// 11 | /// The size, in bits, of the computed hash code. 12 | /// 13 | int HashSize { get; } 14 | 15 | /// 16 | /// Gets the input block size. 17 | /// 18 | /// 19 | /// The input block size. 20 | /// 21 | int InputBlockSize { get; } 22 | 23 | /// 24 | /// Gets the output block size. 25 | /// 26 | /// 27 | /// The output block size. 28 | /// 29 | int OutputBlockSize { get; } 30 | 31 | /// 32 | /// Gets the value of the computed hash code. 33 | /// 34 | /// 35 | /// The current value of the computed hash code. 36 | /// 37 | /// The object has already been disposed. 38 | byte[] Hash { get; } 39 | 40 | /// 41 | /// Resets an implementation of the to its initial state. 42 | /// 43 | void Reset(); 44 | 45 | /// 46 | /// Routes data written to the object into the hash algorithm for computing the hash. 47 | /// 48 | /// The input to compute the hash code for. 49 | /// The offset into the byte array from which to begin using data. 50 | /// The number of bytes in the byte array to use as data. 51 | void HashCore(byte[] array, int ibStart, int cbSize); 52 | 53 | /// 54 | /// Finalizes the hash computation after the last data is processed by the cryptographic stream object. 55 | /// 56 | /// 57 | /// The computed hash code. 58 | /// 59 | byte[] HashFinal(); 60 | 61 | /// 62 | /// Computes the hash value for the specified region of the input byte array and copies the specified 63 | /// region of the input byte array to the specified region of the output byte array. 64 | /// 65 | /// The input to compute the hash code for. 66 | /// The offset into the input byte array from which to begin using data. 67 | /// The number of bytes in the input byte array to use as data. 68 | /// A copy of the part of the input array used to compute the hash code. 69 | /// The offset into the output byte array from which to begin writing data. 70 | /// 71 | /// The number of bytes written. 72 | /// 73 | /// 74 | /// uses an invalid value. 75 | /// -or- 76 | /// has an invalid length. 77 | /// 78 | /// is null. 79 | /// is out of range. This parameter requires a non-negative number. 80 | /// The object has already been disposed. 81 | int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset); 82 | 83 | /// 84 | /// Computes the hash value for the specified region of the specified byte array. 85 | /// 86 | /// The input to compute the hash code for. 87 | /// The offset into the byte array from which to begin using data. 88 | /// The number of bytes in the byte array to use as data. 89 | /// 90 | /// An array that is a copy of the part of the input that is hashed. 91 | /// 92 | /// 93 | /// uses an invalid value. 94 | /// -or- 95 | /// has an invalid length. 96 | /// 97 | /// is null. 98 | /// is out of range. This parameter requires a non-negative number. 99 | /// The object has already been disposed. 100 | byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount); 101 | 102 | /// 103 | /// Computes the hash value for the input data. 104 | /// 105 | /// The input to compute the hash code for. 106 | /// 107 | /// The computed hash code. 108 | /// 109 | /// is null. 110 | /// The object has already been disposed. 111 | byte[] ComputeHash(byte[] buffer); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.Shared/KeyedHashAlgorithm.cs: -------------------------------------------------------------------------------- 1 | // TODO Remove this class, and add a dependency to the System.Security.Cryptography.Primitives 2 | // TODO package once this package is available from http://nuget.org with support for UAP 10.0. 3 | 4 | #if !FEATURE_CRYPTO_HASHALGORITHM 5 | 6 | // Licensed to the .NET Foundation under one or more agreements. 7 | // The .NET Foundation licenses this file to you under the MIT license. 8 | // See the LICENSE file in the project root for more information. 9 | 10 | namespace System.Security.Cryptography 11 | { 12 | /// 13 | /// Represents the abstract class from which all implementations of keyed 14 | /// hash algorithms must derive. 15 | /// 16 | public abstract class KeyedHashAlgorithm : HashAlgorithm 17 | { 18 | /// 19 | /// Gets or sets the key to use in the hash algorithm. 20 | /// 21 | /// 22 | /// The key to use in the hash algorithm. 23 | /// 24 | public virtual byte[] Key 25 | { 26 | get { return (byte[]) _key.Clone(); } 27 | 28 | set 29 | { 30 | _key = (byte[]) value.Clone(); 31 | } 32 | } 33 | 34 | /// 35 | /// Releases the unmanaged resources used by the and 36 | /// optionally releases the managed resources. 37 | /// 38 | /// true to release both managed and unmanaged resources; false to release only unmanaged resources. 39 | protected override void Dispose(bool disposing) 40 | { 41 | // For keyed hash algorithms, we always want to zero out the key value 42 | if (disposing) 43 | { 44 | if (_key != null) 45 | { 46 | Array.Clear(_key, 0, _key.Length); 47 | } 48 | _key = null; 49 | } 50 | base.Dispose(disposing); 51 | } 52 | 53 | private byte[] _key; 54 | } 55 | } 56 | #endif // !FEATURE_CRYPTO_KEYEDHASHALGORITHM 57 | 58 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.Shared/MD5.cs: -------------------------------------------------------------------------------- 1 | using System.Security.Cryptography; 2 | 3 | namespace SshNet.Security.Cryptography 4 | { 5 | /// 6 | /// MD5 algorithm implementation 7 | /// 8 | public sealed class MD5 : HashAlgorithm 9 | { 10 | private IHashProvider _hashProvider; 11 | 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | public MD5() 16 | { 17 | _hashProvider = new MD5HashProvider(); 18 | } 19 | 20 | /// 21 | /// Gets the size, in bits, of the computed hash code. 22 | /// 23 | /// 24 | /// The size, in bits, of the computed hash code. 25 | /// 26 | public override int HashSize 27 | { 28 | get 29 | { 30 | return _hashProvider.HashSize; 31 | } 32 | } 33 | 34 | /// 35 | /// Routes data written to the object into the hash algorithm for computing the hash. 36 | /// 37 | /// The input to compute the hash code for. 38 | /// The offset into the byte array from which to begin using data. 39 | /// The number of bytes in the byte array to use as data. 40 | protected override void HashCore(byte[] array, int ibStart, int cbSize) 41 | { 42 | _hashProvider.HashCore(array, ibStart, cbSize); 43 | } 44 | 45 | /// 46 | /// Finalizes the hash computation after the last data is processed by the cryptographic stream object. 47 | /// 48 | /// 49 | /// The computed hash code. 50 | /// 51 | protected override byte[] HashFinal() 52 | { 53 | return _hashProvider.HashFinal(); 54 | } 55 | 56 | /// 57 | /// Initializes an implementation of the class. 58 | /// 59 | public override void Initialize() 60 | { 61 | _hashProvider.Reset(); 62 | } 63 | 64 | /// 65 | /// Releases the unmanaged resources used by the and optionally releases the managed resources. 66 | /// 67 | /// true to release both managed and unmanaged resources; false to release only unmanaged resources. 68 | protected override void Dispose(bool disposing) 69 | { 70 | base.Dispose(disposing); 71 | 72 | if (disposing) 73 | { 74 | _hashProvider.Dispose(); 75 | _hashProvider = null; 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.Shared/Properties/CommonAssemblyInfo.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sshnet/Cryptography/816ed11058f0fcab5e9bea92a7438d53373af8eb/src/SshNet.Security.Cryptography.Shared/Properties/CommonAssemblyInfo.cs -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.Shared/RIPEMD160.cs: -------------------------------------------------------------------------------- 1 | using System.Security.Cryptography; 2 | 3 | namespace SshNet.Security.Cryptography 4 | { 5 | /// 6 | /// Cryptographic hash function based upon the Merkle–Damgård construction. 7 | /// 8 | public sealed class RIPEMD160 : HashAlgorithm 9 | { 10 | private IHashProvider _hashProvider; 11 | 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | public RIPEMD160() 16 | { 17 | _hashProvider = new RIPEMD160HashProvider(); 18 | } 19 | 20 | /// 21 | /// Gets the size, in bits, of the computed hash code. 22 | /// 23 | /// 24 | /// The size, in bits, of the computed hash code. 25 | /// 26 | public override int HashSize 27 | { 28 | get 29 | { 30 | return _hashProvider.HashSize; 31 | } 32 | } 33 | 34 | /// 35 | /// Routes data written to the object into the hash algorithm for computing the hash. 36 | /// 37 | /// The input to compute the hash code for. 38 | /// The offset into the byte array from which to begin using data. 39 | /// The number of bytes in the byte array to use as data. 40 | protected override void HashCore(byte[] array, int ibStart, int cbSize) 41 | { 42 | _hashProvider.HashCore(array, ibStart, cbSize); 43 | } 44 | 45 | /// 46 | /// Finalizes the hash computation after the last data is processed by the cryptographic stream object. 47 | /// 48 | /// 49 | /// The computed hash code. 50 | /// 51 | protected override byte[] HashFinal() 52 | { 53 | return _hashProvider.HashFinal(); 54 | } 55 | 56 | /// 57 | /// Initializes an implementation of the class. 58 | /// 59 | public override void Initialize() 60 | { 61 | _hashProvider.Reset(); 62 | } 63 | 64 | /// 65 | /// Releases the unmanaged resources used by the and optionally releases the managed resources. 66 | /// 67 | /// true to release both managed and unmanaged resources; false to release only unmanaged resources. 68 | protected override void Dispose(bool disposing) 69 | { 70 | base.Dispose(disposing); 71 | 72 | if (disposing) 73 | { 74 | _hashProvider.Dispose(); 75 | _hashProvider = null; 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.Shared/SHA1.cs: -------------------------------------------------------------------------------- 1 | using System.Security.Cryptography; 2 | 3 | namespace SshNet.Security.Cryptography 4 | { 5 | /// 6 | /// Computes the SHA1 hash for input data. 7 | /// 8 | public sealed class SHA1 : HashAlgorithm 9 | { 10 | private IHashProvider _hashProvider; 11 | 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | public SHA1() 16 | { 17 | _hashProvider = new SHA1HashProvider(); 18 | } 19 | 20 | /// 21 | /// Gets the size, in bits, of the computed hash code. 22 | /// 23 | /// 24 | /// The size, in bits, of the computed hash code. 25 | /// 26 | public override int HashSize 27 | { 28 | get 29 | { 30 | return _hashProvider.HashSize; 31 | } 32 | } 33 | 34 | /// 35 | /// Routes data written to the object into the hash algorithm for computing the hash. 36 | /// 37 | /// The input to compute the hash code for. 38 | /// The offset into the byte array from which to begin using data. 39 | /// The number of bytes in the byte array to use as data. 40 | protected override void HashCore(byte[] array, int ibStart, int cbSize) 41 | { 42 | _hashProvider.HashCore(array, ibStart, cbSize); 43 | } 44 | 45 | /// 46 | /// Finalizes the hash computation after the last data is processed by the cryptographic stream object. 47 | /// 48 | /// 49 | /// The computed hash code. 50 | /// 51 | protected override byte[] HashFinal() 52 | { 53 | return _hashProvider.HashFinal(); 54 | } 55 | 56 | /// 57 | /// Initializes an implementation of the class. 58 | /// 59 | public override void Initialize() 60 | { 61 | _hashProvider.Reset(); 62 | } 63 | 64 | /// 65 | /// Releases the unmanaged resources used by the and optionally releases the managed resources. 66 | /// 67 | /// true to release both managed and unmanaged resources; false to release only unmanaged resources. 68 | protected override void Dispose(bool disposing) 69 | { 70 | base.Dispose(disposing); 71 | 72 | if (disposing) 73 | { 74 | _hashProvider.Dispose(); 75 | _hashProvider = null; 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.Shared/SHA256.cs: -------------------------------------------------------------------------------- 1 | using System.Security.Cryptography; 2 | 3 | namespace SshNet.Security.Cryptography 4 | { 5 | /// 6 | /// Computes the SHA256 hash for input data. 7 | /// 8 | public class SHA256 : HashAlgorithm 9 | { 10 | private IHashProvider _hashProvider; 11 | 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | public SHA256() 16 | { 17 | _hashProvider = new SHA256HashProvider(); 18 | } 19 | 20 | /// 21 | /// Gets the size, in bits, of the computed hash code. 22 | /// 23 | /// 24 | /// The size, in bits, of the computed hash code. 25 | /// 26 | public override int HashSize 27 | { 28 | get 29 | { 30 | return _hashProvider.HashSize; 31 | } 32 | } 33 | 34 | /// 35 | /// Routes data written to the object into the hash algorithm for computing the hash. 36 | /// 37 | /// The input to compute the hash code for. 38 | /// The offset into the byte array from which to begin using data. 39 | /// The number of bytes in the byte array to use as data. 40 | protected override void HashCore(byte[] array, int ibStart, int cbSize) 41 | { 42 | _hashProvider.HashCore(array, ibStart, cbSize); 43 | } 44 | 45 | /// 46 | /// Finalizes the hash computation after the last data is processed by the cryptographic stream object. 47 | /// 48 | /// 49 | /// The computed hash code. 50 | /// 51 | protected override byte[] HashFinal() 52 | { 53 | return _hashProvider.HashFinal(); 54 | } 55 | 56 | /// 57 | /// Initializes an implementation of the class. 58 | /// 59 | public override void Initialize() 60 | { 61 | _hashProvider.Reset(); 62 | } 63 | 64 | /// 65 | /// Releases the unmanaged resources used by the and optionally releases the managed resources. 66 | /// 67 | /// true to release both managed and unmanaged resources; false to release only unmanaged resources. 68 | protected override void Dispose(bool disposing) 69 | { 70 | base.Dispose(disposing); 71 | 72 | if (disposing) 73 | { 74 | _hashProvider.Dispose(); 75 | _hashProvider = null; 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.Shared/SHA384.cs: -------------------------------------------------------------------------------- 1 | using System.Security.Cryptography; 2 | 3 | namespace SshNet.Security.Cryptography 4 | { 5 | /// 6 | /// Computes the SHA384 hash for input data. 7 | /// 8 | public class SHA384 : HashAlgorithm 9 | { 10 | private IHashProvider _hashProvider; 11 | 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | public SHA384() 16 | { 17 | _hashProvider = new SHA384HashProvider(); 18 | } 19 | 20 | /// 21 | /// Gets the size, in bits, of the computed hash code. 22 | /// 23 | /// 24 | /// The size, in bits, of the computed hash code. 25 | /// 26 | public override int HashSize 27 | { 28 | get 29 | { 30 | return _hashProvider.HashSize; 31 | } 32 | } 33 | 34 | /// 35 | /// Routes data written to the object into the hash algorithm for computing the hash. 36 | /// 37 | /// The input to compute the hash code for. 38 | /// The offset into the byte array from which to begin using data. 39 | /// The number of bytes in the byte array to use as data. 40 | protected override void HashCore(byte[] array, int ibStart, int cbSize) 41 | { 42 | _hashProvider.HashCore(array, ibStart, cbSize); 43 | } 44 | 45 | /// 46 | /// Finalizes the hash computation after the last data is processed by the cryptographic stream object. 47 | /// 48 | /// 49 | /// The computed hash code. 50 | /// 51 | protected override byte[] HashFinal() 52 | { 53 | return _hashProvider.HashFinal(); 54 | } 55 | 56 | /// 57 | /// Initializes an implementation of the class. 58 | /// 59 | public override void Initialize() 60 | { 61 | _hashProvider.Reset(); 62 | } 63 | 64 | /// 65 | /// Releases the unmanaged resources used by the and optionally releases the managed resources. 66 | /// 67 | /// true to release both managed and unmanaged resources; false to release only unmanaged resources. 68 | protected override void Dispose(bool disposing) 69 | { 70 | base.Dispose(disposing); 71 | 72 | if (disposing) 73 | { 74 | _hashProvider.Dispose(); 75 | _hashProvider = null; 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.Shared/SHA384HashProvider.cs: -------------------------------------------------------------------------------- 1 | namespace SshNet.Security.Cryptography 2 | { 3 | internal class SHA384HashProvider : SHA2HashProviderBase 4 | { 5 | private const int DigestSize = 48; 6 | 7 | public SHA384HashProvider() 8 | { 9 | InitializeHashValue(); 10 | } 11 | 12 | /// 13 | /// Gets the size, in bits, of the computed hash code. 14 | /// 15 | /// 16 | /// The size, in bits, of the computed hash code. 17 | /// 18 | public override int HashSize 19 | { 20 | get 21 | { 22 | return DigestSize * 8; 23 | } 24 | } 25 | 26 | /// 27 | /// When overridden in a derived class, gets the input block size. 28 | /// 29 | /// 30 | /// The input block size. 31 | /// 32 | public override int InputBlockSize 33 | { 34 | get 35 | { 36 | return DigestSize * 2; 37 | } 38 | } 39 | 40 | /// 41 | /// When overridden in a derived class, gets the output block size. 42 | /// 43 | /// 44 | /// The output block size. 45 | /// 46 | public override int OutputBlockSize 47 | { 48 | get 49 | { 50 | return DigestSize * 2; 51 | } 52 | } 53 | 54 | /// 55 | /// Finalizes the hash computation after the last data is processed by the cryptographic stream object. 56 | /// 57 | /// 58 | /// The computed hash code. 59 | /// 60 | public override byte[] HashFinal() 61 | { 62 | var output = new byte[DigestSize]; 63 | 64 | Finish(); 65 | 66 | UInt64_To_BE(H1, output, 0); 67 | UInt64_To_BE(H2, output, 8); 68 | UInt64_To_BE(H3, output, 16); 69 | UInt64_To_BE(H4, output, 24); 70 | UInt64_To_BE(H5, output, 32); 71 | UInt64_To_BE(H6, output, 40); 72 | 73 | return output; 74 | } 75 | 76 | /// 77 | /// Resets to its initial state. 78 | /// 79 | public override void Reset() 80 | { 81 | base.Reset(); 82 | 83 | InitializeHashValue(); 84 | } 85 | 86 | private void InitializeHashValue() 87 | { 88 | /* 89 | * SHA-384 initial hash value 90 | * The first 64 bits of the fractional parts of the square roots 91 | * of the 9th through 16th prime numbers 92 | */ 93 | H1 = 0xcbbb9d5dc1059ed8; 94 | H2 = 0x629a292a367cd507; 95 | H3 = 0x9159015a3070dd17; 96 | H4 = 0x152fecd8f70e5939; 97 | H5 = 0x67332667ffc00b31; 98 | H6 = 0x8eb44a8768581511; 99 | H7 = 0xdb0c2e0d64f98fa7; 100 | H8 = 0x47b5481dbefa4fa4; 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.Shared/SHA512.cs: -------------------------------------------------------------------------------- 1 | using System.Security.Cryptography; 2 | 3 | namespace SshNet.Security.Cryptography 4 | { 5 | /// 6 | /// Computes the SHA512 hash for input data. 7 | /// 8 | public class SHA512 : HashAlgorithm 9 | { 10 | private IHashProvider _hashProvider; 11 | 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | public SHA512() 16 | { 17 | _hashProvider = new SHA512HashProvider(); 18 | } 19 | 20 | /// 21 | /// Gets the size, in bits, of the computed hash code. 22 | /// 23 | /// 24 | /// The size, in bits, of the computed hash code. 25 | /// 26 | public override int HashSize 27 | { 28 | get 29 | { 30 | return _hashProvider.HashSize; 31 | } 32 | } 33 | 34 | /// 35 | /// Routes data written to the object into the hash algorithm for computing the hash. 36 | /// 37 | /// The input to compute the hash code for. 38 | /// The offset into the byte array from which to begin using data. 39 | /// The number of bytes in the byte array to use as data. 40 | protected override void HashCore(byte[] array, int ibStart, int cbSize) 41 | { 42 | _hashProvider.HashCore(array, ibStart, cbSize); 43 | } 44 | 45 | /// 46 | /// Finalizes the hash computation after the last data is processed by the cryptographic stream object. 47 | /// 48 | /// 49 | /// The computed hash code. 50 | /// 51 | protected override byte[] HashFinal() 52 | { 53 | return _hashProvider.HashFinal(); 54 | } 55 | 56 | /// 57 | /// Initializes an implementation of the class. 58 | /// 59 | public override void Initialize() 60 | { 61 | _hashProvider.Reset(); 62 | } 63 | 64 | /// 65 | /// Releases the unmanaged resources used by the and optionally releases the managed resources. 66 | /// 67 | /// true to release both managed and unmanaged resources; false to release only unmanaged resources. 68 | protected override void Dispose(bool disposing) 69 | { 70 | base.Dispose(disposing); 71 | 72 | if (disposing) 73 | { 74 | _hashProvider.Dispose(); 75 | _hashProvider = null; 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.Shared/SHA512HashProvider.cs: -------------------------------------------------------------------------------- 1 | namespace SshNet.Security.Cryptography 2 | { 3 | internal class SHA512HashProvider : SHA2HashProviderBase 4 | { 5 | private const int DigestSize = 64; 6 | 7 | public SHA512HashProvider() 8 | { 9 | InitializeHashValue(); 10 | } 11 | 12 | /// 13 | /// Gets the size, in bits, of the computed hash code. 14 | /// 15 | /// 16 | /// The size, in bits, of the computed hash code. 17 | /// 18 | public override int HashSize 19 | { 20 | get 21 | { 22 | return DigestSize * 8; 23 | } 24 | } 25 | 26 | /// 27 | /// When overridden in a derived class, gets the input block size. 28 | /// 29 | /// 30 | /// The input block size. 31 | /// 32 | public override int InputBlockSize 33 | { 34 | get 35 | { 36 | return DigestSize * 2; 37 | } 38 | } 39 | 40 | /// 41 | /// When overridden in a derived class, gets the output block size. 42 | /// 43 | /// 44 | /// The output block size. 45 | /// 46 | public override int OutputBlockSize 47 | { 48 | get 49 | { 50 | return DigestSize * 2; 51 | } 52 | } 53 | 54 | /// 55 | /// Finalizes the hash computation after the last data is processed by the cryptographic stream object. 56 | /// 57 | /// 58 | /// The computed hash code. 59 | /// 60 | public override byte[] HashFinal() 61 | { 62 | var output = new byte[DigestSize]; 63 | 64 | Finish(); 65 | 66 | UInt64_To_BE(H1, output, 0); 67 | UInt64_To_BE(H2, output, 8); 68 | UInt64_To_BE(H3, output, 16); 69 | UInt64_To_BE(H4, output, 24); 70 | UInt64_To_BE(H5, output, 32); 71 | UInt64_To_BE(H6, output, 40); 72 | UInt64_To_BE(H7, output, 48); 73 | UInt64_To_BE(H8, output, 56); 74 | 75 | return output; 76 | } 77 | 78 | /// 79 | /// Resets to its initial state. 80 | /// 81 | public override void Reset() 82 | { 83 | base.Reset(); 84 | 85 | InitializeHashValue(); 86 | } 87 | 88 | private void InitializeHashValue() 89 | { 90 | /* 91 | * SHA-512 initial hash value 92 | * The first 64 bits of the fractional parts of the square roots 93 | * of the first eight prime numbers 94 | */ 95 | H1 = 0x6a09e667f3bcc908; 96 | H2 = 0xbb67ae8584caa73b; 97 | H3 = 0x3c6ef372fe94f82b; 98 | H4 = 0xa54ff53a5f1d36f1; 99 | H5 = 0x510e527fade682d1; 100 | H6 = 0x9b05688c2b3e6c1f; 101 | H7 = 0x1f83d9abfb41bd6b; 102 | H8 = 0x5be0cd19137e2179; 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.Shared/SshNet.Security.Cryptography.Shared.projitems: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | fa210478-5ac9-4be3-8ed6-cb8f3ec8f99a 7 | 8 | 9 | SshNet.Security.Cryptography.Shared 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.Shared/SshNet.Security.Cryptography.Shared.shproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | fa210478-5ac9-4be3-8ed6-cb8f3ec8f99a 5 | 14.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.Silverlight4/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("Renci.SshNet.Security.Cryptography for Silverlight 4")] 5 | [assembly: Guid("D0CA51C0-40B7-4FF1-A709-50FEFCE7E1E2")] 6 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.Silverlight4/SshNet.Security.Cryptography.Silverlight4.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.50727 7 | 2.0 8 | {17B0CC1F-2BFB-4B17-A1D2-4F800962A475} 9 | {A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 10 | Library 11 | Properties 12 | SshNet.Security.Cryptography 13 | SshNet.Security.Cryptography 14 | Silverlight 15 | v4.0 16 | $(TargetFrameworkVersion) 17 | false 18 | true 19 | true 20 | 21 | 24 | 25 | v3.5 26 | 27 | 28 | true 29 | full 30 | false 31 | Bin\Debug 32 | TRACE;DEBUG;FEATURE_CRYPTO_HASHALGORITHM 33 | true 34 | true 35 | prompt 36 | 4 37 | true 38 | Bin\Debug\SshNet.Security.Cryptography.xml 39 | 40 | 41 | pdbonly 42 | true 43 | Bin\Release 44 | TRACE;FEATURE_CRYPTO_HASHALGORITHM 45 | true 46 | true 47 | prompt 48 | 4 49 | true 50 | Bin\Release\SshNet.Security.Cryptography.xml 51 | 52 | 53 | true 54 | 55 | 56 | ..\SshNet.Security.Cryptography.snk 57 | 58 | 59 | 60 | 61 | 62 | 63 | HashProviderBase.cs 64 | 65 | 66 | HMAC.cs 67 | 68 | 69 | HMACMD5.cs 70 | 71 | 72 | HMACRIPEMD160.cs 73 | 74 | 75 | HMACSHA1.cs 76 | 77 | 78 | HMACSHA256.cs 79 | 80 | 81 | HMACSHA384.cs 82 | 83 | 84 | HMACSHA512.cs 85 | 86 | 87 | IHashProvider.cs 88 | 89 | 90 | MD5.cs 91 | 92 | 93 | MD5HashProvider.cs 94 | 95 | 96 | Properties\CommonAssemblyInfo.cs 97 | 98 | 99 | RIPEMD160.cs 100 | 101 | 102 | RIPEMD160HashProvider.cs 103 | 104 | 105 | SHA1.cs 106 | 107 | 108 | SHA1HashProvider.cs 109 | 110 | 111 | SHA256.cs 112 | 113 | 114 | SHA256HashProvider.cs 115 | 116 | 117 | SHA2HashProviderBase.cs 118 | 119 | 120 | SHA384.cs 121 | 122 | 123 | SHA384HashProvider.cs 124 | 125 | 126 | SHA512.cs 127 | 128 | 129 | SHA512HashProvider.cs 130 | 131 | 132 | 133 | 134 | 135 | SshNet.Security.Cryptography.snk 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 153 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.Silverlight5/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("SshNet.Security.Cryptography for Silverlight 5")] 5 | [assembly: Guid("106D0FF0-FFEC-4B6D-AA4E-8F89B09B51C6")] 6 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.Silverlight5/SshNet.Security.Cryptography.Silverlight5.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.50727 7 | 2.0 8 | {AA7BB3E4-6146-432A-A472-5A5319050EE4} 9 | {A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 10 | Library 11 | Properties 12 | SshNet.Security.Cryptography 13 | SshNet.Security.Cryptography 14 | Silverlight 15 | v5.0 16 | $(TargetFrameworkVersion) 17 | false 18 | true 19 | true 20 | 21 | 24 | 25 | v3.5 26 | 27 | 28 | true 29 | full 30 | false 31 | Bin\Debug 32 | TRACE;DEBUG;FEATURE_CRYPTO_HASHALGORITHM 33 | true 34 | true 35 | prompt 36 | 4 37 | true 38 | Bin\Debug\SshNet.Security.Cryptography.xml 39 | 40 | 41 | pdbonly 42 | true 43 | Bin\Release 44 | TRACE;FEATURE_CRYPTO_HASHALGORITHM 45 | true 46 | true 47 | prompt 48 | 4 49 | Bin\Release\SshNet.Security.Cryptography.xml 50 | true 51 | 52 | 53 | true 54 | 55 | 56 | ..\SshNet.Security.Cryptography.snk 57 | 58 | 59 | 60 | 61 | 62 | 63 | HashProviderBase.cs 64 | 65 | 66 | HMAC.cs 67 | 68 | 69 | HMACMD5.cs 70 | 71 | 72 | HMACRIPEMD160.cs 73 | 74 | 75 | HMACSHA1.cs 76 | 77 | 78 | HMACSHA256.cs 79 | 80 | 81 | HMACSHA384.cs 82 | 83 | 84 | HMACSHA512.cs 85 | 86 | 87 | IHashProvider.cs 88 | 89 | 90 | MD5.cs 91 | 92 | 93 | MD5HashProvider.cs 94 | 95 | 96 | Properties\CommonAssemblyInfo.cs 97 | 98 | 99 | RIPEMD160.cs 100 | 101 | 102 | RIPEMD160HashProvider.cs 103 | 104 | 105 | SHA1.cs 106 | 107 | 108 | SHA1HashProvider.cs 109 | 110 | 111 | SHA256.cs 112 | 113 | 114 | SHA256HashProvider.cs 115 | 116 | 117 | SHA2HashProviderBase.cs 118 | 119 | 120 | SHA384.cs 121 | 122 | 123 | SHA384HashProvider.cs 124 | 125 | 126 | SHA512.cs 127 | 128 | 129 | SHA512HashProvider.cs 130 | 131 | 132 | 133 | 134 | 135 | SshNet.Security.Cryptography.snk 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 153 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.UAP10/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | [assembly: AssemblyTitle("SshNet.Security.Cryptography for UAP 10.0")] 4 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.UAP10/SshNet.Security.Cryptography.UAP10.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {427E4B4A-5245-45B5-B101-2556C9224C88} 8 | Library 9 | Properties 10 | SshNet.Security.Cryptography 11 | SshNet.Security.Cryptography 12 | en-US 13 | UAP 14 | 10.0.10240.0 15 | 10.0.10240.0 16 | 14 17 | 512 18 | {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 19 | 20 | 21 | AnyCPU 22 | true 23 | full 24 | false 25 | bin\Debug\ 26 | TRACE;DEBUG;FEATURE_CRYPTO_HASHALGORITHM 27 | prompt 28 | 4 29 | bin\Debug\SshNet.Security.Cryptography.xml 30 | true 31 | 32 | 33 | AnyCPU 34 | pdbonly 35 | true 36 | bin\Release\ 37 | TRACE;FEATURE_CRYPTO_HASHALGORITHM 38 | prompt 39 | 4 40 | true 41 | bin\Release\SshNet.Security.Cryptography.xml 42 | false 43 | 44 | 45 | x86 46 | true 47 | bin\x86\Debug\ 48 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP 49 | ;2008 50 | full 51 | x86 52 | false 53 | prompt 54 | 55 | 56 | x86 57 | bin\x86\Release\ 58 | TRACE;NETFX_CORE;WINDOWS_UWP 59 | true 60 | ;2008 61 | pdbonly 62 | x86 63 | false 64 | prompt 65 | 66 | 67 | ARM 68 | true 69 | bin\ARM\Debug\ 70 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP 71 | ;2008 72 | full 73 | ARM 74 | false 75 | prompt 76 | 77 | 78 | ARM 79 | bin\ARM\Release\ 80 | TRACE;NETFX_CORE;WINDOWS_UWP 81 | true 82 | ;2008 83 | pdbonly 84 | ARM 85 | false 86 | prompt 87 | 88 | 89 | x64 90 | true 91 | bin\x64\Debug\ 92 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP 93 | ;2008 94 | full 95 | x64 96 | false 97 | prompt 98 | 99 | 100 | x64 101 | bin\x64\Release\ 102 | TRACE;NETFX_CORE;WINDOWS_UWP 103 | true 104 | ;2008 105 | pdbonly 106 | x64 107 | false 108 | prompt 109 | 110 | 111 | 112 | 113 | SshNet.Security.Cryptography.snk 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 14.0 123 | 124 | 125 | true 126 | 127 | 128 | ..\SshNet.Security.Cryptography.snk 129 | 130 | 131 | 138 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.UAP10/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "System.IO": "4.1.0", 4 | "System.Security.Cryptography.Primitives": "4.0.0" 5 | }, 6 | "frameworks": { 7 | "uap10.0": {} 8 | }, 9 | "runtimes": { 10 | "win10-arm": {}, 11 | "win10-arm-aot": {}, 12 | "win10-x86": {}, 13 | "win10-x86-aot": {}, 14 | "win10-x64": {}, 15 | "win10-x64-aot": {} 16 | } 17 | } -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.VS2012.sln.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | DO_NOT_SHOW 3 | DO_NOT_SHOW 4 | DO_NOT_SHOW 5 | HMAC 6 | HMACMD 7 | HMACRIPEMD 8 | HMACSHA 9 | MD 10 | RIPEMD 11 | SHA -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.VS2015.sln.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | DO_NOT_SHOW 3 | DO_NOT_SHOW 4 | DO_NOT_SHOW 5 | HMAC 6 | HMACMD 7 | HMACRIPEMD 8 | HMACSHA 9 | MD 10 | RIPEMD 11 | SHA -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.VS2017.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26730.16 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "SshNet.Security.Cryptography.Shared.Tests", "..\test\SshNet.Security.Cryptography.Shared.Tests\SshNet.Security.Cryptography.Shared.Tests.shproj", "{7041AE9E-89F9-4C4A-8EC7-BBAC5B22B39D}" 7 | EndProject 8 | Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "SshNet.Security.Cryptography.Shared", "SshNet.Security.Cryptography.Shared\SshNet.Security.Cryptography.Shared.shproj", "{FA210478-5AC9-4BE3-8ED6-CB8F3EC8F99A}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SshNet.Security.Cryptography.NETStandard", "SshNet.Security.Cryptography.NETStandard\SshNet.Security.Cryptography.NETStandard.csproj", "{22332CE0-5127-4D1D-A953-D985052D3D28}" 11 | EndProject 12 | Global 13 | GlobalSection(SharedMSBuildProjectFiles) = preSolution 14 | ..\test\SshNet.Security.Cryptography.Shared.Tests\SshNet.Security.Cryptography.Shared.projitems*{7041ae9e-89f9-4c4a-8ec7-bbac5b22b39d}*SharedItemsImports = 13 15 | SshNet.Security.Cryptography.Shared\SshNet.Security.Cryptography.Shared.projitems*{fa210478-5ac9-4be3-8ed6-cb8f3ec8f99a}*SharedItemsImports = 13 16 | EndGlobalSection 17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 18 | Debug|Any CPU = Debug|Any CPU 19 | Debug|ARM = Debug|ARM 20 | Debug|x64 = Debug|x64 21 | Debug|x86 = Debug|x86 22 | Release|Any CPU = Release|Any CPU 23 | Release|ARM = Release|ARM 24 | Release|x64 = Release|x64 25 | Release|x86 = Release|x86 26 | EndGlobalSection 27 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 28 | {22332CE0-5127-4D1D-A953-D985052D3D28}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {22332CE0-5127-4D1D-A953-D985052D3D28}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {22332CE0-5127-4D1D-A953-D985052D3D28}.Debug|ARM.ActiveCfg = Debug|Any CPU 31 | {22332CE0-5127-4D1D-A953-D985052D3D28}.Debug|ARM.Build.0 = Debug|Any CPU 32 | {22332CE0-5127-4D1D-A953-D985052D3D28}.Debug|x64.ActiveCfg = Debug|Any CPU 33 | {22332CE0-5127-4D1D-A953-D985052D3D28}.Debug|x64.Build.0 = Debug|Any CPU 34 | {22332CE0-5127-4D1D-A953-D985052D3D28}.Debug|x86.ActiveCfg = Debug|Any CPU 35 | {22332CE0-5127-4D1D-A953-D985052D3D28}.Debug|x86.Build.0 = Debug|Any CPU 36 | {22332CE0-5127-4D1D-A953-D985052D3D28}.Release|Any CPU.ActiveCfg = Release|Any CPU 37 | {22332CE0-5127-4D1D-A953-D985052D3D28}.Release|Any CPU.Build.0 = Release|Any CPU 38 | {22332CE0-5127-4D1D-A953-D985052D3D28}.Release|ARM.ActiveCfg = Release|Any CPU 39 | {22332CE0-5127-4D1D-A953-D985052D3D28}.Release|ARM.Build.0 = Release|Any CPU 40 | {22332CE0-5127-4D1D-A953-D985052D3D28}.Release|x64.ActiveCfg = Release|Any CPU 41 | {22332CE0-5127-4D1D-A953-D985052D3D28}.Release|x64.Build.0 = Release|Any CPU 42 | {22332CE0-5127-4D1D-A953-D985052D3D28}.Release|x86.ActiveCfg = Release|Any CPU 43 | {22332CE0-5127-4D1D-A953-D985052D3D28}.Release|x86.Build.0 = Release|Any CPU 44 | EndGlobalSection 45 | GlobalSection(SolutionProperties) = preSolution 46 | HideSolutionNode = FALSE 47 | EndGlobalSection 48 | GlobalSection(ExtensibilityGlobals) = postSolution 49 | SolutionGuid = {E4493461-98D8-416C-B852-D9A1D09D718B} 50 | EndGlobalSection 51 | EndGlobal 52 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.WindowsPhone71/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("Renci.SshNet.Security.Cryptography for Windows Phone Silverlight 7.1")] 5 | [assembly: Guid("863900C1-1EE5-45E9-9D66-8470C56C1183")] 6 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.WindowsPhone71/SshNet.Security.Cryptography.WindowsPhone71.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 10.0.20506 7 | 2.0 8 | {502AFD0A-1084-4EFF-851B-E808B707E038} 9 | {C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 10 | Library 11 | Properties 12 | SshNet.Security.Cryptography 13 | SshNet.Security.Cryptography 14 | v4.0 15 | $(TargetFrameworkVersion) 16 | WindowsPhone71 17 | Silverlight 18 | false 19 | true 20 | true 21 | 22 | 23 | true 24 | full 25 | false 26 | Bin\Debug 27 | TRACE;DEBUG;FEATURE_CRYPTO_HASHALGORITHM 28 | true 29 | true 30 | prompt 31 | 4 32 | true 33 | Bin\Debug\SshNet.Security.Cryptography.xml 34 | 35 | 36 | pdbonly 37 | true 38 | Bin\Release 39 | TRACE;FEATURE_CRYPTO_HASHALGORITHM 40 | true 41 | true 42 | prompt 43 | 4 44 | Bin\Release\SshNet.Security.Cryptography.xml 45 | true 46 | 47 | 48 | 49 | HashProviderBase.cs 50 | 51 | 52 | HMAC.cs 53 | 54 | 55 | HMACMD5.cs 56 | 57 | 58 | HMACRIPEMD160.cs 59 | 60 | 61 | HMACSHA1.cs 62 | 63 | 64 | HMACSHA256.cs 65 | 66 | 67 | HMACSHA384.cs 68 | 69 | 70 | HMACSHA512.cs 71 | 72 | 73 | IHashProvider.cs 74 | 75 | 76 | MD5.cs 77 | 78 | 79 | MD5HashProvider.cs 80 | 81 | 82 | Properties\CommonAssemblyInfo.cs 83 | 84 | 85 | RIPEMD160.cs 86 | 87 | 88 | RIPEMD160HashProvider.cs 89 | 90 | 91 | SHA1.cs 92 | 93 | 94 | SHA1HashProvider.cs 95 | 96 | 97 | SHA256.cs 98 | 99 | 100 | SHA256HashProvider.cs 101 | 102 | 103 | SHA2HashProviderBase.cs 104 | 105 | 106 | SHA384.cs 107 | 108 | 109 | SHA384HashProvider.cs 110 | 111 | 112 | SHA512.cs 113 | 114 | 115 | SHA512HashProvider.cs 116 | 117 | 118 | 119 | 120 | 121 | 122 | 129 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.WindowsPhone80/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("SshNet.Security.Cryptography for Windows Phone Silverlight 8.0")] 5 | [assembly: Guid("ACAEB44A-54BB-4854-A2E4-0180B9D8D94F")] 6 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.WindowsPhone80/SshNet.Security.Cryptography.WindowsPhone80.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 10.0.20506 7 | 2.0 8 | {6640F3FF-3DE3-40DA-A043-438009D9E8C0} 9 | {C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 10 | Library 11 | Properties 12 | SshNet.Security.Cryptography 13 | SshNet.Security.Cryptography 14 | WindowsPhone 15 | v8.0 16 | $(TargetFrameworkVersion) 17 | false 18 | true 19 | 11.0 20 | true 21 | 22 | 23 | true 24 | full 25 | false 26 | Bin\Debug 27 | TRACE;DEBUG;FEATURE_CRYPTO_HASHALGORITHM 28 | true 29 | true 30 | prompt 31 | 4 32 | true 33 | Bin\Debug\SshNet.Security.Cryptography.xml 34 | 35 | 36 | pdbonly 37 | true 38 | Bin\Release 39 | TRACE;FEATURE_CRYPTO_HASHALGORITHM 40 | true 41 | true 42 | prompt 43 | 4 44 | Bin\Release\SshNet.Security.Cryptography.xml 45 | true 46 | 47 | 48 | true 49 | full 50 | false 51 | Bin\x86\Debug 52 | DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE 53 | true 54 | true 55 | prompt 56 | 4 57 | 58 | 59 | pdbonly 60 | true 61 | Bin\x86\Release 62 | TRACE;SILVERLIGHT;WINDOWS_PHONE 63 | true 64 | true 65 | prompt 66 | 4 67 | 68 | 69 | true 70 | full 71 | false 72 | Bin\ARM\Debug 73 | DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE 74 | true 75 | true 76 | prompt 77 | 4 78 | 79 | 80 | pdbonly 81 | true 82 | Bin\ARM\Release 83 | TRACE;SILVERLIGHT;WINDOWS_PHONE 84 | true 85 | true 86 | prompt 87 | 4 88 | 89 | 90 | 91 | HashProviderBase.cs 92 | 93 | 94 | HMAC.cs 95 | 96 | 97 | HMACMD5.cs 98 | 99 | 100 | HMACRIPEMD160.cs 101 | 102 | 103 | HMACSHA1.cs 104 | 105 | 106 | HMACSHA256.cs 107 | 108 | 109 | HMACSHA384.cs 110 | 111 | 112 | HMACSHA512.cs 113 | 114 | 115 | IHashProvider.cs 116 | 117 | 118 | MD5.cs 119 | 120 | 121 | MD5HashProvider.cs 122 | 123 | 124 | Properties\CommonAssemblyInfo.cs 125 | 126 | 127 | RIPEMD160.cs 128 | 129 | 130 | RIPEMD160HashProvider.cs 131 | 132 | 133 | SHA1.cs 134 | 135 | 136 | SHA1HashProvider.cs 137 | 138 | 139 | SHA256.cs 140 | 141 | 142 | SHA256HashProvider.cs 143 | 144 | 145 | SHA2HashProviderBase.cs 146 | 147 | 148 | SHA384.cs 149 | 150 | 151 | SHA384HashProvider.cs 152 | 153 | 154 | SHA512.cs 155 | 156 | 157 | SHA512HashProvider.cs 158 | 159 | 160 | 161 | 162 | 163 | 164 | 171 | -------------------------------------------------------------------------------- /src/SshNet.Security.Cryptography.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sshnet/Cryptography/816ed11058f0fcab5e9bea92a7438d53373af8eb/src/SshNet.Security.Cryptography.snk -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.NET20.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("Security.Cryptography.NET20.Tests")] 5 | [assembly: Guid("1cbce394-c7d4-44bf-ab1c-5fc142d6c6eb")] 6 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.NET20.Tests/SshNet.Security.Cryptography.NET20.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {30271F90-FF2A-4427-BF88-8EA37CA6110A} 8 | Library 9 | Properties 10 | SshNet.Security.Cryptography.Tests 11 | SshNet.Security.Cryptography.Tests 12 | v2.0 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | TRACE;DEBUG;FEATURE_HASHALGORITHM_TRANSFORM 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE;FEATURE_HASHALGORITHM_TRANSFORM 30 | prompt 31 | 4 32 | 33 | 34 | 35 | Common\ByteExtensions.cs 36 | 37 | 38 | Common\StringExtensions.cs 39 | 40 | 41 | HMACMD5Test.cs 42 | 43 | 44 | HMACRIPEMD160Test.cs 45 | 46 | 47 | HMACSHA1Test.cs 48 | 49 | 50 | HMACSHA256Test.cs 51 | 52 | 53 | HMACSHA384Test.cs 54 | 55 | 56 | HMACSHA512Test.cs 57 | 58 | 59 | MD5Test.cs 60 | 61 | 62 | Properties\CommonAssemblyInfo.cs 63 | 64 | 65 | RIPEMD160Test.cs 66 | 67 | 68 | SHA1Test.cs 69 | 70 | 71 | SHA256Test.cs 72 | 73 | 74 | SHA384Test.cs 75 | 76 | 77 | SHA512Test.cs 78 | 79 | 80 | 81 | 82 | 83 | ..\..\packages\xunit.1.9.2\lib\net20\xunit.dll 84 | True 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | {ff9fe022-4b50-4b6a-97ea-a2ecfd5de783} 93 | SshNet.Security.Cryptography.NET20 94 | 95 | 96 | 97 | 98 | 99 | 100 | 107 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.NET20.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.NET40.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("SshNet.Security.Cryptography.NET40.Tests")] 5 | [assembly: Guid("ed387b8d-87e5-48ed-ad90-1fc410f43e64")] 6 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.NET40.Tests/SshNet.Security.Cryptography.NET40.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {D1C3BADA-73AC-41B7-B6D0-629C3B75BBD0} 8 | Library 9 | Properties 10 | SshNet.Security.Cryptography.Tests 11 | SshNet.Security.Cryptography.Tests 12 | v4.0 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | TRACE;DEBUG;FEATURE_HASHALGORITHM_TRANSFORM 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE;FEATURE_HASHALGORITHM_TRANSFORM 30 | prompt 31 | 4 32 | 33 | 34 | 35 | Common\ByteExtensions.cs 36 | 37 | 38 | Common\StringExtensions.cs 39 | 40 | 41 | HMACMD5Test.cs 42 | 43 | 44 | HMACRIPEMD160Test.cs 45 | 46 | 47 | HMACSHA1Test.cs 48 | 49 | 50 | HMACSHA256Test.cs 51 | 52 | 53 | HMACSHA384Test.cs 54 | 55 | 56 | HMACSHA512Test.cs 57 | 58 | 59 | MD5Test.cs 60 | 61 | 62 | Properties\CommonAssemblyInfo.cs 63 | 64 | 65 | RIPEMD160Test.cs 66 | 67 | 68 | SHA1Test.cs 69 | 70 | 71 | SHA256Test.cs 72 | 73 | 74 | SHA384Test.cs 75 | 76 | 77 | SHA512Test.cs 78 | 79 | 80 | 81 | 82 | 83 | {6a8919d5-1801-42c8-90ec-36a0ca7a406d} 84 | SshNet.Security.Cryptography.NET40 85 | 86 | 87 | 88 | 89 | ..\..\packages\xunit.1.9.2\lib\net20\xunit.dll 90 | True 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 107 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.NET40.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.NET45+Win8+WPA81.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("SshNet.Security.Cryptography.NET45+Win8+WPA81.Tests")] 5 | [assembly: Guid("142cc284-c88d-4815-ad62-c14c4ca16a50")] 6 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.NET45+Win8+WPA81.Tests/SshNet.Security.Cryptography.NET45+Win8+WPA81.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 11.0 7 | Debug 8 | AnyCPU 9 | {52C7ED73-0D41-4FEF-8A88-1493563C0C77} 10 | Library 11 | Properties 12 | SshNet.Security.Cryptography.Tests 13 | SshNet.Security.Cryptography.Tests 14 | en-US 15 | 512 16 | {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 17 | Profile111 18 | v4.5 19 | 20 | 21 | 22 | 23 | true 24 | full 25 | false 26 | bin\Debug\ 27 | TRACE;DEBUG;FEATURE_HASHALGORITHM_TRANSFORM 28 | prompt 29 | 4 30 | 31 | 32 | pdbonly 33 | true 34 | bin\Release\ 35 | TRACE;FEATURE_HASHALGORITHM_TRANSFORM 36 | prompt 37 | 4 38 | 39 | 40 | 41 | 42 | 43 | 44 | ..\..\packages\xunit.abstractions.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.abstractions.dll 45 | True 46 | 47 | 48 | ..\..\packages\xunit.assert.2.1.0\lib\portable-net45+win8+wp8+wpa81\xunit.assert.dll 49 | True 50 | 51 | 52 | ..\..\packages\xunit.extensibility.core.2.1.0\lib\portable-net45+win8+wp8+wpa81\xunit.core.dll 53 | True 54 | 55 | 56 | ..\..\packages\xunit.extensibility.execution.2.1.0\lib\portable-net45+win8+wp8+wpa81\xunit.execution.dotnet.dll 57 | True 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | {f9cc3198-697c-439a-b64b-f9dfaf3ebff7} 66 | SshNet.Security.Cryptography.NET45+Win8+WPA81 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 77 | 78 | 79 | 80 | 87 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.NET45+Win8+WPA81.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.Shared.Tests/Common/ByteExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Text; 4 | 5 | namespace SshNet.Security.Cryptography.Common.Tests 6 | { 7 | public static class ByteExtensions 8 | { 9 | public static byte[] HexToByteArray(string hexString) 10 | { 11 | var bytes = new byte[hexString.Length / 2]; 12 | 13 | for (var i = 0; i < hexString.Length; i += 2) 14 | { 15 | var s = hexString.Substring(i, 2); 16 | bytes[i / 2] = byte.Parse(s, NumberStyles.HexNumber, null); 17 | } 18 | 19 | return bytes; 20 | } 21 | 22 | public static string ToHex(byte[] bytes) 23 | { 24 | var builder = new StringBuilder(bytes.Length * 2); 25 | 26 | foreach (byte b in bytes) 27 | { 28 | builder.Append(b.ToString("X2")); 29 | } 30 | 31 | return builder.ToString(); 32 | } 33 | 34 | public static byte[] Repeat(byte b, int count) 35 | { 36 | var value = new byte[count]; 37 | 38 | for (var i = 0; i < count; i++) 39 | { 40 | value[i] = b; 41 | } 42 | 43 | return value; 44 | } 45 | 46 | /// 47 | /// Returns a specified number of contiguous bytes from a given offset. 48 | /// 49 | /// The array to return a number of bytes from. 50 | /// The zero-based offset in at which to begin taking bytes. 51 | /// The number of bytes to take from . 52 | /// 53 | /// A array that contains the specified number of bytes at the specified offset 54 | /// of the input array. 55 | /// 56 | /// is null. 57 | /// 58 | /// When is zero and equals the length of , 59 | /// then is returned. 60 | /// 61 | public static byte[] Take(byte[] value, int offset, int count) 62 | { 63 | if (value == null) 64 | throw new ArgumentNullException("value"); 65 | 66 | if (count == 0) 67 | return new byte[0]; 68 | 69 | if (offset == 0 && value.Length == count) 70 | return value; 71 | 72 | var taken = new byte[count]; 73 | Buffer.BlockCopy(value, offset, taken, 0, count); 74 | return taken; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.Shared.Tests/Common/StringExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | namespace SshNet.Security.Cryptography.Common.Tests 4 | { 5 | public static class StringExtensions 6 | { 7 | public static string Repeat(string text, int count) 8 | { 9 | var sb = new StringBuilder(); 10 | 11 | for (var i = 0; i < count; i++) 12 | sb.Append(text); 13 | 14 | return sb.ToString(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.Shared.Tests/HMACRIPEMD160Test.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using SshNet.Security.Cryptography.Common.Tests; 3 | using Xunit; 4 | 5 | namespace SshNet.Security.Cryptography.Tests 6 | { 7 | /// 8 | /// Test cases are from https://tools.ietf.org/html/rfc2286. 9 | /// 10 | public class HMACRIPEMD160Test 11 | { 12 | [Fact] 13 | public void Rfc2286_1() 14 | { 15 | var key = ByteExtensions.Repeat(0x0b, 20); 16 | var data = ByteExtensions.HexToByteArray("4869205468657265"); // "Hi There" 17 | var expectedHash = ByteExtensions.HexToByteArray("24cb4bd67d20fc1a5d2ed7732dcc39377f0a5668"); 18 | var hmac = new HMACRIPEMD160(key); 19 | 20 | var actualHash = hmac.ComputeHash(data); 21 | 22 | Assert.Equal(expectedHash, actualHash); 23 | } 24 | 25 | [Fact] 26 | public void Rfc2286_2() 27 | { 28 | var key = ByteExtensions.HexToByteArray("4a656665"); // "Jefe"; 29 | var data = ByteExtensions.HexToByteArray("7768617420646f2079612077616e7420666f72206e6f7468696e673f"); // "what do ya want for nothing?" 30 | var expectedHash = ByteExtensions.HexToByteArray("dda6c0213a485a9e24f4742064a7f033b43c4069"); 31 | var hmac = new HMACRIPEMD160(key); 32 | 33 | var actualHash = hmac.ComputeHash(data); 34 | 35 | Assert.Equal(expectedHash, actualHash); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.Shared.Tests/HMACSHA1Test.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using SshNet.Security.Cryptography.Common.Tests; 3 | using Xunit; 4 | 5 | namespace SshNet.Security.Cryptography.Tests 6 | { 7 | /// 8 | /// Test cases are from https://tools.ietf.org/html/rfc2202. 9 | /// 10 | public class HMACSHA1Test 11 | { 12 | [Fact] 13 | public void Rfc2202_1() 14 | { 15 | var key = ByteExtensions.Repeat(0x0b, 20); 16 | var data = ByteExtensions.HexToByteArray("4869205468657265"); // "Hi There" 17 | var expectedHash = ByteExtensions.HexToByteArray("b617318655057264e28bc0b6fb378c8ef146be00"); 18 | var hmac = new HMACSHA1(key); 19 | 20 | var actualHash = hmac.ComputeHash(data); 21 | 22 | Assert.Equal(expectedHash, actualHash); 23 | } 24 | 25 | [Fact] 26 | public void Rfc2202_2() 27 | { 28 | var key = ByteExtensions.HexToByteArray("4a656665"); // "Jefe"; 29 | var data = ByteExtensions.HexToByteArray("7768617420646f2079612077616e7420666f72206e6f7468696e673f"); // "what do ya want for nothing?" 30 | var expectedHash = ByteExtensions.HexToByteArray("effcdf6ae5eb2fa2d27416d5f184df9c259a7c79"); 31 | var hmac = new HMACSHA1(key); 32 | 33 | var actualHash = hmac.ComputeHash(data); 34 | 35 | Assert.Equal(expectedHash, actualHash); 36 | } 37 | 38 | [Fact] 39 | public void Rfc2202_3() 40 | { 41 | var key = ByteExtensions.Repeat(0xaa, 20); 42 | var data = ByteExtensions.Repeat(0xdd, 50); 43 | var expectedHash = ByteExtensions.HexToByteArray("125d7342b9ac11cd91a39af48aa17b4f63f175d3"); 44 | var hmac = new HMACSHA1(key); 45 | 46 | var actualHash = hmac.ComputeHash(data); 47 | 48 | Assert.Equal(expectedHash, actualHash); 49 | } 50 | 51 | [Fact] 52 | public void Rfc2202_4() 53 | { 54 | var key = ByteExtensions.HexToByteArray("0102030405060708090a0b0c0d0e0f10111213141516171819"); 55 | var data = ByteExtensions.Repeat(0xcd, 50); 56 | var expectedHash = ByteExtensions.HexToByteArray("4c9007f4026250c6bc8414f9bf50c86c2d7235da"); 57 | var hmac = new HMACSHA1(key); 58 | 59 | var actualHash = hmac.ComputeHash(data); 60 | 61 | Assert.Equal(expectedHash, actualHash); 62 | } 63 | 64 | [Fact] 65 | public void Rfc2202_5() 66 | { 67 | var key = ByteExtensions.Repeat(0x0c, 20); 68 | var data = ByteExtensions.HexToByteArray("546573742057697468205472756e636174696f6e"); // "Test With Truncation" 69 | 70 | var expectedHash = ByteExtensions.HexToByteArray("4c1a03424b55e07fe7f27be1d58bb9324a9a5a04"); 71 | var hmac = new HMACSHA1(key); 72 | var actualHash = hmac.ComputeHash(data); 73 | Assert.Equal(expectedHash, actualHash); 74 | 75 | var expectedHash96 = ByteExtensions.HexToByteArray("4c1a03424b55e07fe7f27be1"); 76 | var hmac96 = new HMACSHA1(key, 96); 77 | var actualHash96 = hmac96.ComputeHash(data); 78 | Assert.Equal(expectedHash96, actualHash96); 79 | } 80 | 81 | [Fact] 82 | public void Rfc2202_6() 83 | { 84 | var key = ByteExtensions.Repeat(0xaa, 80); 85 | var data = ByteExtensions.HexToByteArray("54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374"); // "Test Using Larger Than Block-Size Key - Hash Key First" 86 | var expectedHash = ByteExtensions.HexToByteArray("aa4ae5e15272d00e95705637ce8a3b55ed402112"); 87 | var hmac = new HMACSHA1(key); 88 | 89 | var actualHash = hmac.ComputeHash(data); 90 | 91 | Assert.Equal(expectedHash, actualHash); 92 | } 93 | 94 | [Fact] 95 | public void Rfc2202_7() 96 | { 97 | var key = ByteExtensions.Repeat(0xaa, 80); 98 | var data = ByteExtensions.HexToByteArray("54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b657920616e64204c6172676572205468616e204f6e6520426c6f636b2d53697a652044617461"); // "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data" 99 | var expectedHash = ByteExtensions.HexToByteArray("e8e99d0f45237d786d6bbaa7965c7808bbff1a91"); 100 | var hmac = new HMACSHA1(key); 101 | 102 | var actualHash = hmac.ComputeHash(data); 103 | 104 | Assert.Equal(expectedHash, actualHash); 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.Shared.Tests/HMACSHA256Test.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using SshNet.Security.Cryptography.Common.Tests; 3 | using Xunit; 4 | 5 | namespace SshNet.Security.Cryptography.Tests 6 | { 7 | /// 8 | /// Test cases are from http://tools.ietf.org/html/rfc4231. 9 | /// 10 | public class HMACSHA256Test 11 | { 12 | [Fact] 13 | public void Rfc4231_1() 14 | { 15 | var key = ByteExtensions.Repeat(0x0b, 20); 16 | var data = ByteExtensions.HexToByteArray("4869205468657265"); // "Hi There" 17 | var expectedHash = ByteExtensions.HexToByteArray("b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7"); 18 | var hmac = new HMACSHA256(key); 19 | 20 | var actualHash = hmac.ComputeHash(data); 21 | 22 | Assert.Equal(expectedHash, actualHash); 23 | } 24 | 25 | /// 26 | /// Test with a key shorter than the length of the HMAC output. 27 | /// 28 | [Fact] 29 | public void Rfc4231_2() 30 | { 31 | var key = ByteExtensions.HexToByteArray("4a656665"); // "Jefe"; 32 | var data = ByteExtensions.HexToByteArray("7768617420646f2079612077616e7420666f72206e6f7468696e673f"); // "what do ya want for nothing?" 33 | var expectedHash = ByteExtensions.HexToByteArray("5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843"); 34 | var hmac = new HMACSHA256(key); 35 | 36 | var actualHash = hmac.ComputeHash(data); 37 | 38 | Assert.Equal(expectedHash, actualHash); 39 | } 40 | 41 | /// 42 | /// Test with a combined length of key and data that is larger than 64 bytes (= block-size of SHA-224 and SHA-256). 43 | /// 44 | [Fact] 45 | public void Rfc4231_3() 46 | { 47 | var key = ByteExtensions.Repeat(0xaa, 20); 48 | var data = ByteExtensions.Repeat(0xdd, 50); 49 | var expectedHash = ByteExtensions.HexToByteArray("773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe"); 50 | var hmac = new HMACSHA256(key); 51 | 52 | var actualHash = hmac.ComputeHash(data); 53 | 54 | Assert.Equal(expectedHash, actualHash); 55 | } 56 | 57 | /// 58 | /// Test with a combined length of key and data that is larger than 64 bytes (= block-size of SHA-224 and SHA-256). 59 | /// 60 | [Fact] 61 | public void Rfc4231_4() 62 | { 63 | var key = ByteExtensions.HexToByteArray("0102030405060708090a0b0c0d0e0f10111213141516171819"); 64 | var data = ByteExtensions.Repeat(0xcd, 50); 65 | var expectedHash = ByteExtensions.HexToByteArray("82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff46729665b"); 66 | var hmac = new HMACSHA256(key); 67 | 68 | var actualHash = hmac.ComputeHash(data); 69 | 70 | Assert.Equal(expectedHash, actualHash); 71 | } 72 | 73 | /// 74 | /// Test with a truncation of output to 128 bits. 75 | /// 76 | [Fact] 77 | public void Rfc4231_5() 78 | { 79 | var key = ByteExtensions.Repeat(0x0c, 20); 80 | var data = ByteExtensions.HexToByteArray("546573742057697468205472756e636174696f6e"); // "Test With Truncation" 81 | var expectedHash = ByteExtensions.HexToByteArray("a3b6167473100ee06e0c796c2955552b"); 82 | var hmac = new HMACSHA256(key, 128); 83 | 84 | var actualHash = hmac.ComputeHash(data); 85 | 86 | Assert.Equal(expectedHash, actualHash); 87 | } 88 | 89 | /// 90 | /// Test with a key larger than 128 bytes (= block-size of SHA-384 and SHA-512). 91 | /// 92 | [Fact] 93 | public void Rfc4231_6() 94 | { 95 | var key = ByteExtensions.Repeat(0xaa, 131); 96 | var data = ByteExtensions.HexToByteArray("54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374"); // "Test Using Larger Than Block-Size Key - Hash Key First" 97 | var expectedHash = ByteExtensions.HexToByteArray("60e431591ee0b67f0d8a26aacbf5b77f8e0bc6213728c5140546040f0ee37f54"); 98 | var hmac = new HMACSHA256(key); 99 | 100 | var actualHash = hmac.ComputeHash(data); 101 | 102 | Assert.Equal(expectedHash, actualHash); 103 | } 104 | 105 | /// 106 | /// Test with a key and data that is larger than 128 bytes (= block-size of SHA-384 and SHA-512). 107 | /// 108 | [Fact] 109 | public void Rfc4231_7() 110 | { 111 | var key = ByteExtensions.Repeat(0xaa, 131); 112 | var data = ByteExtensions.HexToByteArray("5468697320697320612074657374207573696e672061206c6172676572207468616e20626c6f636b2d73697a65206b657920616e642061206c6172676572207468616e20626c6f636b2d73697a6520646174612e20546865206b6579206e6565647320746f20626520686173686564206265666f7265206265696e6720757365642062792074686520484d414320616c676f726974686d2e"); // "This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm." 113 | var expectedHash = ByteExtensions.HexToByteArray("9b09ffa71b942fcb27635fbcd5b0e944bfdc63644f0713938a7f51535c3a35e2"); 114 | var hmac = new HMACSHA256(key); 115 | 116 | var actualHash = hmac.ComputeHash(data); 117 | 118 | Assert.Equal(expectedHash, actualHash); 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.Shared.Tests/HMACSHA384Test.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using SshNet.Security.Cryptography.Common.Tests; 3 | using Xunit; 4 | 5 | namespace SshNet.Security.Cryptography.Tests 6 | { 7 | /// 8 | /// Test cases are from http://tools.ietf.org/html/rfc4231. 9 | /// 10 | public class HMACSHA384Test 11 | { 12 | [Fact] 13 | public void Rfc4231_1() 14 | { 15 | var key = ByteExtensions.Repeat(0x0b, 20); 16 | var data = ByteExtensions.HexToByteArray("4869205468657265"); // "Hi There" 17 | var expectedHash = ByteExtensions.HexToByteArray("afd03944d84895626b0825f4ab46907f15f9dadbe4101ec682aa034c7cebc59cfaea9ea9076ede7f4af152e8b2fa9cb6"); 18 | var hmac = new HMACSHA384(key); 19 | 20 | var actualHash = hmac.ComputeHash(data); 21 | 22 | Assert.Equal(expectedHash, actualHash); 23 | } 24 | 25 | /// 26 | /// Test with a key shorter than the length of the HMAC output. 27 | /// 28 | [Fact] 29 | public void Rfc4231_2() 30 | { 31 | var key = ByteExtensions.HexToByteArray("4a656665"); // "Jefe" 32 | var data = ByteExtensions.HexToByteArray("7768617420646f2079612077616e7420666f72206e6f7468696e673f"); // "what do ya want for nothing?" 33 | var expectedHash = ByteExtensions.HexToByteArray("af45d2e376484031617f78d2b58a6b1b9c7ef464f5a01b47e42ec3736322445e8e2240ca5e69e2c78b3239ecfab21649"); 34 | var hmac = new HMACSHA384(key); 35 | 36 | var actualHash = hmac.ComputeHash(data); 37 | 38 | Assert.Equal(expectedHash, actualHash); 39 | } 40 | 41 | /// 42 | /// Test with a combined length of key and data that is larger than 64 bytes (= block-size of SHA-224 and SHA-256). 43 | /// 44 | [Fact] 45 | public void Rfc4231_3() 46 | { 47 | var key = ByteExtensions.Repeat(0xaa, 20); 48 | var data = ByteExtensions.Repeat(0xdd, 50); 49 | var expectedHash = ByteExtensions.HexToByteArray("88062608d3e6ad8a0aa2ace014c8a86f0aa635d947ac9febe83ef4e55966144b2a5ab39dc13814b94e3ab6e101a34f27"); 50 | var hmac = new HMACSHA384(key); 51 | 52 | var actualHash = hmac.ComputeHash(data); 53 | 54 | Assert.Equal(expectedHash, actualHash); 55 | } 56 | 57 | /// 58 | /// Test with a combined length of key and data that is larger than 64 bytes (= block-size of SHA-224 and SHA-256). 59 | /// 60 | [Fact] 61 | public void Rfc4231_4() 62 | { 63 | var key = ByteExtensions.HexToByteArray("0102030405060708090a0b0c0d0e0f10111213141516171819"); 64 | var data = ByteExtensions.Repeat(0xcd, 50); 65 | var expectedHash = ByteExtensions.HexToByteArray("3e8a69b7783c25851933ab6290af6ca77a9981480850009cc5577c6e1f573b4e6801dd23c4a7d679ccf8a386c674cffb"); 66 | var hmac = new HMACSHA384(key); 67 | 68 | var actualHash = hmac.ComputeHash(data); 69 | 70 | Assert.Equal(expectedHash, actualHash); 71 | } 72 | 73 | /// 74 | /// Test with a truncation of output to 128 bits. 75 | /// 76 | [Fact] 77 | public void Rfc4231_5() 78 | { 79 | var key = ByteExtensions.Repeat(0x0c, 20); 80 | var data = ByteExtensions.HexToByteArray("546573742057697468205472756e636174696f6e"); // "Test With Truncation" 81 | var expectedHash = ByteExtensions.HexToByteArray("3abf34c3503b2a23a46efc619baef897"); 82 | var hmac = new HMACSHA384(key, 128); 83 | 84 | var actualHash = hmac.ComputeHash(data); 85 | 86 | Assert.Equal(expectedHash, actualHash); 87 | } 88 | 89 | /// 90 | /// Test with a key larger than 128 bytes (= block-size of SHA-384 and SHA-512). 91 | /// 92 | [Fact] 93 | public void Rfc4231_6() 94 | { 95 | var key = ByteExtensions.Repeat(0xaa, 131); 96 | var data = ByteExtensions.HexToByteArray("54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374"); // "Test Using Larger Than Block-Size Key - Hash Key First" 97 | var expectedHash = ByteExtensions.HexToByteArray("4ece084485813e9088d2c63a041bc5b44f9ef1012a2b588f3cd11f05033ac4c60c2ef6ab4030fe8296248df163f44952"); 98 | var hmac = new HMACSHA384(key); 99 | 100 | var actualHash = hmac.ComputeHash(data); 101 | 102 | Assert.Equal(expectedHash, actualHash); 103 | } 104 | 105 | /// 106 | /// Test with a key and data that is larger than 128 bytes (= block-size of SHA-384 and SHA-512). 107 | /// 108 | [Fact] 109 | public void Rfc4231_7() 110 | { 111 | var key = ByteExtensions.Repeat(0xaa, 131); 112 | var data = ByteExtensions.HexToByteArray("5468697320697320612074657374207573696e672061206c6172676572207468616e20626c6f636b2d73697a65206b657920616e642061206c6172676572207468616e20626c6f636b2d73697a6520646174612e20546865206b6579206e6565647320746f20626520686173686564206265666f7265206265696e6720757365642062792074686520484d414320616c676f726974686d2e"); // "This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm." 113 | var expectedHash = ByteExtensions.HexToByteArray("6617178e941f020d351e2f254e8fd32c602420feb0b8fb9adccebb82461e99c5a678cc31e799176d3860e6110c46523e"); 114 | var hmac = new HMACSHA384(key); 115 | 116 | var actualHash = hmac.ComputeHash(data); 117 | 118 | Assert.Equal(expectedHash, actualHash); 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.Shared.Tests/HMACSHA512Test.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using SshNet.Security.Cryptography.Common.Tests; 3 | using Xunit; 4 | 5 | namespace SshNet.Security.Cryptography.Tests 6 | { 7 | /// 8 | /// Test cases are from http://tools.ietf.org/html/rfc4231. 9 | /// 10 | public class HMACSHA512Test 11 | { 12 | [Fact] 13 | public void Rfc4231_1() 14 | { 15 | var key = ByteExtensions.Repeat(0x0b, 20); 16 | var data = ByteExtensions.HexToByteArray("4869205468657265"); // "Hi There" 17 | var expectedHash = ByteExtensions.HexToByteArray("87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cdedaa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f1702e696c203a126854"); 18 | var hmac = new HMACSHA512(key); 19 | 20 | var actualHash = hmac.ComputeHash(data); 21 | 22 | Assert.Equal(expectedHash, actualHash); 23 | } 24 | 25 | /// 26 | /// Test with a key shorter than the length of the HMAC output. 27 | /// 28 | [Fact] 29 | public void Rfc4231_2() 30 | { 31 | var key = ByteExtensions.HexToByteArray("4a656665"); // "Jefe" 32 | var data = ByteExtensions.HexToByteArray("7768617420646f2079612077616e7420666f72206e6f7468696e673f"); // "what do ya want for nothing?" 33 | var expectedHash = ByteExtensions.HexToByteArray("164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce737"); 34 | var hmac = new HMACSHA512(key); 35 | 36 | var actualHash = hmac.ComputeHash(data); 37 | 38 | Assert.Equal(expectedHash, actualHash); 39 | } 40 | 41 | /// 42 | /// Test with a combined length of key and data that is larger than 64 bytes (= block-size of SHA-224 and SHA-256). 43 | /// 44 | [Fact] 45 | public void Rfc4231_3() 46 | { 47 | var key = ByteExtensions.Repeat(0xaa, 20); 48 | var data = ByteExtensions.Repeat(0xdd, 50); 49 | var expectedHash = ByteExtensions.HexToByteArray("fa73b0089d56a284efb0f0756c890be9b1b5dbdd8ee81a3655f83e33b2279d39bf3e848279a722c806b485a47e67c807b946a337bee8942674278859e13292fb"); 50 | var hmac = new HMACSHA512(key); 51 | 52 | var actualHash = hmac.ComputeHash(data); 53 | 54 | Assert.Equal(expectedHash, actualHash); 55 | } 56 | 57 | /// 58 | /// Test with a combined length of key and data that is larger than 64 bytes (= block-size of SHA-224 and SHA-256). 59 | /// 60 | [Fact] 61 | public void Rfc4231_4() 62 | { 63 | var key = ByteExtensions.HexToByteArray("0102030405060708090a0b0c0d0e0f10111213141516171819"); 64 | var data = ByteExtensions.Repeat(0xcd, 50); 65 | var expectedHash = ByteExtensions.HexToByteArray("b0ba465637458c6990e5a8c5f61d4af7e576d97ff94b872de76f8050361ee3dba91ca5c11aa25eb4d679275cc5788063a5f19741120c4f2de2adebeb10a298dd"); 66 | var hmac = new HMACSHA512(key); 67 | 68 | var actualHash = hmac.ComputeHash(data); 69 | 70 | Assert.Equal(expectedHash, actualHash); 71 | } 72 | 73 | /// 74 | /// Test with a truncation of output to 128 bits. 75 | /// 76 | [Fact] 77 | public void Rfc4231_5() 78 | { 79 | var key = ByteExtensions.Repeat(0x0c, 20); 80 | var data = ByteExtensions.HexToByteArray("546573742057697468205472756e636174696f6e"); // "Test With Truncation" 81 | var expectedHash = ByteExtensions.HexToByteArray("415fad6271580a531d4179bc891d87a6"); 82 | var hmac = new HMACSHA512(key, 128); 83 | 84 | var actualHash = hmac.ComputeHash(data); 85 | 86 | Assert.Equal(expectedHash, actualHash); 87 | } 88 | 89 | /// 90 | /// Test with a key larger than 128 bytes (= block-size of SHA-384 and SHA-512). 91 | /// 92 | [Fact] 93 | public void Rfc4231_6() 94 | { 95 | var key = ByteExtensions.Repeat(0xaa, 131); 96 | var data = ByteExtensions.HexToByteArray("54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374"); // "Test Using Larger Than Block-Size Key - Hash Key First" 97 | var expectedHash = ByteExtensions.HexToByteArray("80b24263c7c1a3ebb71493c1dd7be8b49b46d1f41b4aeec1121b013783f8f3526b56d037e05f2598bd0fd2215d6a1e5295e64f73f63f0aec8b915a985d786598"); 98 | var hmac = new HMACSHA512(key); 99 | 100 | var actualHash = hmac.ComputeHash(data); 101 | 102 | Assert.Equal(expectedHash, actualHash); 103 | } 104 | 105 | /// 106 | /// Test with a key and data that is larger than 128 bytes (= block-size of SHA-384 and SHA-512). 107 | /// 108 | [Fact] 109 | public void Rfc4231_7() 110 | { 111 | var key = ByteExtensions.Repeat(0xaa, 131); 112 | var data = ByteExtensions.HexToByteArray("5468697320697320612074657374207573696e672061206c6172676572207468616e20626c6f636b2d73697a65206b657920616e642061206c6172676572207468616e20626c6f636b2d73697a6520646174612e20546865206b6579206e6565647320746f20626520686173686564206265666f7265206265696e6720757365642062792074686520484d414320616c676f726974686d2e"); // "This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm." 113 | var expectedHash = ByteExtensions.HexToByteArray("e37b6a775dc87dbaa4dfa9f96e5e3ffddebd71f8867289865df5a32d20cdc944b6022cac3c4982b10d5eeb55c3e4de15134676fb6de0446065c97440fa8c6a58"); 114 | var hmac = new HMACSHA512(key); 115 | 116 | var actualHash = hmac.ComputeHash(data); 117 | 118 | Assert.Equal(expectedHash, actualHash); 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.Shared.Tests/MD5Test.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using SshNet.Security.Cryptography.Common.Tests; 3 | using Xunit; 4 | 5 | namespace SshNet.Security.Cryptography.Tests 6 | { 7 | /// 8 | /// Test cases are defined in RFC 1321, section A.5 9 | /// 10 | public class MD5Test 11 | { 12 | private readonly MD5 _hashAlgorithm; 13 | 14 | public MD5Test() 15 | { 16 | _hashAlgorithm = new MD5(); 17 | } 18 | 19 | [Fact] 20 | public void Rfc1321_1() 21 | { 22 | var data = new byte[0]; // "" 23 | var expectedHash = ByteExtensions.HexToByteArray("d41d8cd98f00b204e9800998ecf8427e"); 24 | 25 | var actualHash = _hashAlgorithm.ComputeHash(data); 26 | 27 | Assert.Equal(expectedHash, actualHash); 28 | } 29 | 30 | [Fact] 31 | public void Rfc1321_2() 32 | { 33 | var data = ByteExtensions.HexToByteArray("61"); // "a" 34 | var expectedHash = ByteExtensions.HexToByteArray("0cc175b9c0f1b6a831c399e269772661"); 35 | 36 | var actualHash = _hashAlgorithm.ComputeHash(data); 37 | 38 | Assert.Equal(expectedHash, actualHash); 39 | } 40 | 41 | [Fact] 42 | public void Rfc1321_3() 43 | { 44 | var data = ByteExtensions.HexToByteArray("616263"); // "abc" 45 | var expectedHash = ByteExtensions.HexToByteArray("900150983cd24fb0d6963f7d28e17f72"); 46 | 47 | var actualHash = _hashAlgorithm.ComputeHash(data); 48 | 49 | Assert.Equal(expectedHash, actualHash); 50 | } 51 | 52 | [Fact] 53 | public void Rfc1321_4() 54 | { 55 | var data = ByteExtensions.HexToByteArray("6d65737361676520646967657374"); // "message digest" 56 | var expectedHash = ByteExtensions.HexToByteArray("f96b697d7cb7938d525a2f31aaf161d0"); 57 | 58 | var actualHash = _hashAlgorithm.ComputeHash(data); 59 | 60 | Assert.Equal(expectedHash, actualHash); 61 | } 62 | 63 | [Fact] 64 | public void Rfc1321_5() 65 | { 66 | 67 | var data = ByteExtensions.HexToByteArray("6162636465666768696a6b6c6d6e6f707172737475767778797a"); // "abcdefghijklmnopqrstuvwxyz" 68 | var expectedHash = ByteExtensions.HexToByteArray("c3fcd3d76192e4007dfb496cca67e13b"); 69 | 70 | var actualHash = _hashAlgorithm.ComputeHash(data); 71 | 72 | Assert.Equal(expectedHash, actualHash); 73 | } 74 | 75 | [Fact] 76 | public void Rfc1321_6() 77 | { 78 | var data = ByteExtensions.HexToByteArray("4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a30313233343536373839"); // "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" 79 | var expectedHash = ByteExtensions.HexToByteArray("d174ab98d277d9f5a5611c2c9f419d9f"); 80 | 81 | var actualHash = _hashAlgorithm.ComputeHash(data); 82 | 83 | Assert.Equal(expectedHash, actualHash); 84 | } 85 | 86 | [Fact] 87 | public void Rfc1321_7() 88 | { 89 | var data = ByteExtensions.HexToByteArray(StringExtensions.Repeat("31323334353637383930", 8)); // "1234567890" * 8 90 | var expectedHash = ByteExtensions.HexToByteArray("57edf4a22be3c955ac49da2e2107b67a"); 91 | 92 | var actualHash = _hashAlgorithm.ComputeHash(data); 93 | 94 | Assert.Equal(expectedHash, actualHash); 95 | } 96 | } 97 | } 98 | 99 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.Shared.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("Renci.Common.Tests")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("Renci.Common.Tests")] 12 | [assembly: AssemblyCopyright("Copyright © 2016")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("a19015b9-f99f-445f-bb76-05a209998935")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.Shared.Tests/Properties/CommonAssemblyInfo.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sshnet/Cryptography/816ed11058f0fcab5e9bea92a7438d53373af8eb/test/SshNet.Security.Cryptography.Shared.Tests/Properties/CommonAssemblyInfo.cs -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.Shared.Tests/RIPEMD160Test.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using SshNet.Security.Cryptography.Common.Tests; 3 | using Xunit; 4 | 5 | namespace SshNet.Security.Cryptography.Tests 6 | { 7 | /// 8 | /// Test cases are from http://homes.esat.kuleuven.be/~bosselae/ripemd160.html. 9 | /// 10 | public class RIPEMD160Test 11 | { 12 | private readonly RIPEMD160 _hashAlgorithm; 13 | 14 | public RIPEMD160Test() 15 | { 16 | _hashAlgorithm = new RIPEMD160(); 17 | } 18 | 19 | [Fact] 20 | public void test_1() 21 | { 22 | var data = new byte[0]; // "" 23 | var expectedHash = ByteExtensions.HexToByteArray("9c1185a5c5e9fc54612808977ee8f548b2258d31"); 24 | 25 | var actualHash = _hashAlgorithm.ComputeHash(data); 26 | 27 | Assert.Equal(expectedHash, actualHash); 28 | } 29 | 30 | [Fact] 31 | public void test_2() 32 | { 33 | var data = ByteExtensions.HexToByteArray("61"); // "a" 34 | var expectedHash = ByteExtensions.HexToByteArray("0bdc9d2d256b3ee9daae347be6f4dc835a467ffe"); 35 | 36 | var actualHash = _hashAlgorithm.ComputeHash(data); 37 | 38 | Assert.Equal(expectedHash, actualHash); 39 | } 40 | 41 | [Fact] 42 | public void test_3() 43 | { 44 | var data = ByteExtensions.HexToByteArray("616263"); // "abc" 45 | var expectedHash = ByteExtensions.HexToByteArray("8eb208f7e05d987a9b044a8e98c6b087f15a0bfc"); 46 | 47 | var actualHash = _hashAlgorithm.ComputeHash(data); 48 | 49 | Assert.Equal(expectedHash, actualHash); 50 | } 51 | 52 | [Fact] 53 | public void test_4() 54 | { 55 | var data = ByteExtensions.HexToByteArray("6d65737361676520646967657374"); // "message digest" 56 | var expectedHash = ByteExtensions.HexToByteArray("5d0689ef49d2fae572b881b123a85ffa21595f36"); 57 | 58 | var actualHash = _hashAlgorithm.ComputeHash(data); 59 | 60 | Assert.Equal(expectedHash, actualHash); 61 | } 62 | 63 | [Fact] 64 | public void test_5() 65 | { 66 | var data = ByteExtensions.HexToByteArray("6162636465666768696a6b6c6d6e6f707172737475767778797a"); // "abcdefghijklmnopqrstuvwxyz" 67 | var expectedHash = ByteExtensions.HexToByteArray("f71c27109c692c1b56bbdceb5b9d2865b3708dbc"); 68 | 69 | var actualHash = _hashAlgorithm.ComputeHash(data); 70 | 71 | Assert.Equal(expectedHash, actualHash); 72 | } 73 | 74 | [Fact] 75 | public void test_6() 76 | { 77 | var data = ByteExtensions.HexToByteArray("6162636462636465636465666465666765666768666768696768696a68696a6b696a6b6c6a6b6c6d6b6c6d6e6c6d6e6f6d6e6f706e6f7071"); // "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" 78 | var expectedHash = ByteExtensions.HexToByteArray("12a053384a9c0c88e405a06c27dcf49ada62eb2b"); 79 | 80 | var actualHash = _hashAlgorithm.ComputeHash(data); 81 | 82 | Assert.Equal(expectedHash, actualHash); 83 | } 84 | 85 | [Fact] 86 | public void test_7() 87 | { 88 | var data = ByteExtensions.HexToByteArray("4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a30313233343536373839"); // "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" 89 | var expectedHash = ByteExtensions.HexToByteArray("b0e20b6e3116640286ed3a87a5713079b21f5189"); 90 | 91 | var actualHash = _hashAlgorithm.ComputeHash(data); 92 | 93 | Assert.Equal(expectedHash, actualHash); 94 | } 95 | 96 | [Fact] 97 | public void test_8() 98 | { 99 | var data = ByteExtensions.HexToByteArray(StringExtensions.Repeat("31323334353637383930", 8)); // "1234567890" x 8 100 | var expectedHash = ByteExtensions.HexToByteArray("9b752e45573d4b39f4dbd3323cab82bf63326bfb"); 101 | 102 | var actualHash = _hashAlgorithm.ComputeHash(data); 103 | 104 | Assert.Equal(expectedHash, actualHash); 105 | } 106 | 107 | [Fact] 108 | public void test_9() 109 | { 110 | var data = ByteExtensions.Repeat(0x61, 1000000); 111 | var expectedHash = ByteExtensions.HexToByteArray("52783243c1697bdbe16d37f97f68f08325dc1528"); 112 | 113 | var actualHash = _hashAlgorithm.ComputeHash(data); 114 | 115 | Assert.Equal(expectedHash, actualHash); 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.Shared.Tests/SHA256Test.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using SshNet.Security.Cryptography.Common.Tests; 3 | using Xunit; 4 | 5 | namespace SshNet.Security.Cryptography.Tests 6 | { 7 | /// 8 | /// Test cases are from http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf Appendix B 9 | /// 10 | public class SHA256Test 11 | { 12 | private readonly SHA256 _hashAlgorithm; 13 | 14 | public SHA256Test() 15 | { 16 | _hashAlgorithm = new SHA256(); 17 | } 18 | 19 | [Fact] 20 | public void Fips180_1() 21 | { 22 | var data = ByteExtensions.HexToByteArray("616263"); // "abc" 23 | var expectedHash = ByteExtensions.HexToByteArray("ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"); 24 | 25 | var actualHash = _hashAlgorithm.ComputeHash(data); 26 | 27 | Assert.Equal(expectedHash, actualHash); 28 | } 29 | 30 | [Fact] 31 | public void Fips180_2() 32 | { 33 | var data = ByteExtensions.HexToByteArray("6162636462636465636465666465666765666768666768696768696a68696a6b696a6b6c6a6b6c6d6b6c6d6e6c6d6e6f6d6e6f706e6f7071"); // "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" 34 | var expectedHash = ByteExtensions.HexToByteArray("248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"); 35 | 36 | var actualHash = _hashAlgorithm.ComputeHash(data); 37 | 38 | Assert.Equal(expectedHash, actualHash); 39 | } 40 | 41 | [Fact] 42 | public void Fips180_3() 43 | { 44 | var data = ByteExtensions.HexToByteArray(StringExtensions.Repeat("61", 1000000)); // "a" * 1000000 45 | var expectedHash = ByteExtensions.HexToByteArray("cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0"); 46 | 47 | var actualHash = _hashAlgorithm.ComputeHash(data); 48 | 49 | Assert.Equal(expectedHash, actualHash); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.Shared.Tests/SHA384Test.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using SshNet.Security.Cryptography.Common.Tests; 3 | using Xunit; 4 | 5 | namespace SshNet.Security.Cryptography.Tests 6 | { 7 | /// 8 | /// Test cases are from http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA_All.pdf 9 | /// 10 | public class SHA384Test 11 | { 12 | private readonly SHA384 _hashAlgorithm; 13 | 14 | public SHA384Test() 15 | { 16 | _hashAlgorithm = new SHA384(); 17 | } 18 | 19 | [Fact] 20 | public void NistShaAll_1() 21 | { 22 | var data = ByteExtensions.HexToByteArray("616263"); // "abc" 23 | var expectedHash = ByteExtensions.HexToByteArray("CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED1631A8B605A43FF5BED8086072BA1E7CC2358BAECA134C825A7"); 24 | 25 | var actualHash = _hashAlgorithm.ComputeHash(data); 26 | 27 | Assert.Equal(expectedHash, actualHash); 28 | } 29 | 30 | [Fact] 31 | public void NistShaAll_2() 32 | { 33 | var data = ByteExtensions.HexToByteArray("61626364656667686263646566676869636465666768696a6465666768696a6b65666768696a6b6c666768696a6b6c6d6768696a6b6c6d6e68696a6b6c6d6e6f696a6b6c6d6e6f706a6b6c6d6e6f70716b6c6d6e6f7071726c6d6e6f707172736d6e6f70717273746e6f707172737475"); // "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu" 34 | var expectedHash = ByteExtensions.HexToByteArray("09330C33F71147E83D192FC782CD1B4753111B173B3B05D22FA08086E3B0F712FCC7C71A557E2DB966C3E9FA91746039"); 35 | 36 | var actualHash = _hashAlgorithm.ComputeHash(data); 37 | 38 | Assert.Equal(expectedHash, actualHash); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.Shared.Tests/SHA512Test.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using SshNet.Security.Cryptography.Common.Tests; 3 | using Xunit; 4 | 5 | namespace SshNet.Security.Cryptography.Tests 6 | { 7 | /// 8 | /// Test cases are from http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA_All.pdf 9 | /// 10 | public class SHA512Test 11 | { 12 | private readonly SHA512 _hashAlgorithm; 13 | 14 | public SHA512Test() 15 | { 16 | _hashAlgorithm = new SHA512(); 17 | } 18 | 19 | [Fact] 20 | public void Fips180_1() 21 | { 22 | var data = ByteExtensions.HexToByteArray("616263"); // "abc" 23 | var expectedHash = ByteExtensions.HexToByteArray("ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f"); 24 | 25 | var actualHash = _hashAlgorithm.ComputeHash(data); 26 | 27 | Assert.Equal(expectedHash, actualHash); 28 | } 29 | 30 | [Fact] 31 | public void Fips180_2() 32 | { 33 | var data = ByteExtensions.HexToByteArray("61626364656667686263646566676869636465666768696a6465666768696a6b65666768696a6b6c666768696a6b6c6d6768696a6b6c6d6e68696a6b6c6d6e6f696a6b6c6d6e6f706a6b6c6d6e6f70716b6c6d6e6f7071726c6d6e6f707172736d6e6f70717273746e6f707172737475"); // "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu" 34 | var expectedHash = ByteExtensions.HexToByteArray("8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909"); 35 | 36 | var actualHash = _hashAlgorithm.ComputeHash(data); 37 | 38 | Assert.Equal(expectedHash, actualHash); 39 | } 40 | 41 | [Fact] 42 | public void Fips180_3() 43 | { 44 | var data = ByteExtensions.HexToByteArray(StringExtensions.Repeat("61", 1000000)); // "a" * 1000000 45 | var expectedHash = ByteExtensions.HexToByteArray("e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b"); 46 | 47 | var actualHash = _hashAlgorithm.ComputeHash(data); 48 | 49 | Assert.Equal(expectedHash, actualHash); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.Shared.Tests/SshNet.Security.Cryptography.Shared.Tests.shproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 7041ae9e-89f9-4c4a-8ec7-bbac5b22b39d 5 | 14.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.Shared.Tests/SshNet.Security.Cryptography.Shared.projitems: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | 7041ae9e-89f9-4c4a-8ec7-bbac5b22b39d 7 | 8 | 9 | SshNet.Security.Cryptography.Shared 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.UAP10.Tests/Assets/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sshnet/Cryptography/816ed11058f0fcab5e9bea92a7438d53373af8eb/test/SshNet.Security.Cryptography.UAP10.Tests/Assets/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.UAP10.Tests/Assets/SplashScreen.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sshnet/Cryptography/816ed11058f0fcab5e9bea92a7438d53373af8eb/test/SshNet.Security.Cryptography.UAP10.Tests/Assets/SplashScreen.scale-200.png -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.UAP10.Tests/Assets/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sshnet/Cryptography/816ed11058f0fcab5e9bea92a7438d53373af8eb/test/SshNet.Security.Cryptography.UAP10.Tests/Assets/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.UAP10.Tests/Assets/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sshnet/Cryptography/816ed11058f0fcab5e9bea92a7438d53373af8eb/test/SshNet.Security.Cryptography.UAP10.Tests/Assets/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.UAP10.Tests/Assets/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sshnet/Cryptography/816ed11058f0fcab5e9bea92a7438d53373af8eb/test/SshNet.Security.Cryptography.UAP10.Tests/Assets/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.UAP10.Tests/Assets/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sshnet/Cryptography/816ed11058f0fcab5e9bea92a7438d53373af8eb/test/SshNet.Security.Cryptography.UAP10.Tests/Assets/StoreLogo.png -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.UAP10.Tests/Assets/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sshnet/Cryptography/816ed11058f0fcab5e9bea92a7438d53373af8eb/test/SshNet.Security.Cryptography.UAP10.Tests/Assets/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.UAP10.Tests/Package.appxmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Renci.Security.Cryptography.UAP10.Tests 7 | SSH.NET 8 | Assets\StoreLogo.png 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.UAP10.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("SshNet.Security.Cryptography.UAP10.Tests")] 5 | [assembly: Guid("ed387b8d-87e5-48ed-ad90-1fc410f43e64")] 6 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.UAP10.Tests/Properties/UnitTestApp.rd.xml: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 20 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.UAP10.Tests/Renci.Security.Cryptography.UAP10.Tests.nuget.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(UserProfile)\.nuget\packages\ 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.UAP10.Tests/Renci.Security.Cryptography.UAP10.Tests.nuget.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(UserProfile)\.nuget\packages\ 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.UAP10.Tests/SshNet.Security.Cryptography.UAP10.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | x86 7 | {1CC697CE-F033-4E5E-9AED-4C397AE56C08} 8 | AppContainerExe 9 | Properties 10 | SshNet.Security.Cryptography.Tests 11 | SshNet.Security.Cryptography.Tests 12 | en-US 13 | UAP 14 | 10.0.10240.0 15 | 10.0.10240.0 16 | 14 17 | 512 18 | {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 19 | SshNet.pfx 20 | 14.0 21 | 31152E30F2CC4D4FF63E673158222C9435556C5C 22 | 23 | 24 | true 25 | bin\x86\Debug\ 26 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP 27 | ;2008 28 | full 29 | x64 30 | false 31 | prompt 32 | true 33 | 34 | 35 | bin\x86\Release\ 36 | TRACE;NETFX_CORE;WINDOWS_UWP 37 | true 38 | ;2008 39 | pdbonly 40 | x86 41 | false 42 | prompt 43 | true 44 | false 45 | 46 | 47 | true 48 | bin\ARM\Debug\ 49 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP 50 | ;2008 51 | full 52 | ARM 53 | false 54 | prompt 55 | true 56 | 57 | 58 | bin\ARM\Release\ 59 | TRACE;NETFX_CORE;WINDOWS_UWP 60 | true 61 | ;2008 62 | pdbonly 63 | ARM 64 | false 65 | prompt 66 | true 67 | true 68 | 69 | 70 | true 71 | bin\x64\Debug\ 72 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP 73 | ;2008 74 | full 75 | x64 76 | false 77 | prompt 78 | true 79 | 80 | 81 | bin\x64\Release\ 82 | TRACE;NETFX_CORE;WINDOWS_UWP 83 | true 84 | ;2008 85 | pdbonly 86 | x64 87 | false 88 | prompt 89 | true 90 | true 91 | 92 | 93 | false 94 | 95 | 96 | ..\..\src\SshNet.Security.Cryptography.snk 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | UnitTestApp.xaml 107 | 108 | 109 | 110 | 111 | MSBuild:Compile 112 | Designer 113 | 114 | 115 | 116 | 117 | Designer 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | {427e4b4a-5245-45b5-b101-2556c9224c88} 133 | SshNet.Security.Cryptography.UAP10 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 14.0 142 | 143 | 144 | 151 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.UAP10.Tests/SshNet.Security.Cryptography.UAP10.Tests.nuget.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(UserProfile)\.nuget\packages\ 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.UAP10.Tests/SshNet.Security.Cryptography.UAP10.Tests.nuget.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(UserProfile)\.nuget\packages\ 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.UAP10.Tests/SshNet.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sshnet/Cryptography/816ed11058f0fcab5e9bea92a7438d53373af8eb/test/SshNet.Security.Cryptography.UAP10.Tests/SshNet.pfx -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.UAP10.Tests/UnitTestApp.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.UAP10.Tests/UnitTestApp.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Windows.ApplicationModel; 3 | using Windows.ApplicationModel.Activation; 4 | using Windows.UI.Xaml; 5 | using Windows.UI.Xaml.Controls; 6 | using Windows.UI.Xaml.Navigation; 7 | 8 | namespace SshNet.Security.Cryptography.Tests 9 | { 10 | /// 11 | /// Provides application-specific behavior to supplement the default Application class. 12 | /// 13 | sealed partial class App : Application 14 | { 15 | /// 16 | /// Initializes the singleton application object. This is the first line of authored code 17 | /// executed, and as such is the logical equivalent of main() or WinMain(). 18 | /// 19 | public App() 20 | { 21 | InitializeComponent(); 22 | Suspending += OnSuspending; 23 | } 24 | 25 | /// 26 | /// Invoked when the application is launched normally by the end user. Other entry points 27 | /// will be used such as when the application is launched to open a specific file. 28 | /// 29 | /// Details about the launch request and process. 30 | protected override void OnLaunched(LaunchActivatedEventArgs e) 31 | { 32 | 33 | #if DEBUG 34 | if (System.Diagnostics.Debugger.IsAttached) 35 | { 36 | DebugSettings.EnableFrameRateCounter = true; 37 | } 38 | #endif 39 | 40 | Frame rootFrame = Window.Current.Content as Frame; 41 | 42 | // Do not repeat app initialization when the Window already has content, 43 | // just ensure that the window is active 44 | if (rootFrame == null) 45 | { 46 | // Create a Frame to act as the navigation context and navigate to the first page 47 | rootFrame = new Frame(); 48 | 49 | rootFrame.NavigationFailed += OnNavigationFailed; 50 | 51 | if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) 52 | { 53 | //TODO: Load state from previously suspended application 54 | } 55 | 56 | // Place the frame in the current Window 57 | Window.Current.Content = rootFrame; 58 | } 59 | 60 | Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.CreateDefaultUI(); 61 | 62 | // Ensure the current window is active 63 | Window.Current.Activate(); 64 | 65 | Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.Run(e.Arguments); 66 | } 67 | 68 | /// 69 | /// Invoked when Navigation to a certain page fails 70 | /// 71 | /// The Frame which failed navigation 72 | /// Details about the navigation failure 73 | void OnNavigationFailed(object sender, NavigationFailedEventArgs e) 74 | { 75 | throw new Exception("Failed to load Page " + e.SourcePageType.FullName); 76 | } 77 | 78 | /// 79 | /// Invoked when application execution is being suspended. Application state is saved 80 | /// without knowing whether the application will be terminated or resumed with the contents 81 | /// of memory still intact. 82 | /// 83 | /// The source of the suspend request. 84 | /// Details about the suspend request. 85 | private void OnSuspending(object sender, SuspendingEventArgs e) 86 | { 87 | var deferral = e.SuspendingOperation.GetDeferral(); 88 | //TODO: Save application state and stop any background activity 89 | deferral.Complete(); 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /test/SshNet.Security.Cryptography.UAP10.Tests/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | 4 | "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.0", 5 | "xunit": "2.1.0", 6 | "xunit.runner.visualstudio": "2.1.0" 7 | }, 8 | "frameworks": { 9 | "uap10.0": {} 10 | }, 11 | "runtimes": { 12 | "win10-arm": {}, 13 | "win10-arm-aot": {}, 14 | "win10-x86": {}, 15 | "win10-x86-aot": {}, 16 | "win10-x64": {}, 17 | "win10-x64-aot": {} 18 | } 19 | } --------------------------------------------------------------------------------