Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8ca64e6
Add .NET 10 target
mus65 Jun 1, 2025
cd391cb
fix IDE0031
mus65 Jul 15, 2025
fddb6e3
fix ca5399
mus65 Jul 15, 2025
bffe6a1
fix ca1515
mus65 Jul 15, 2025
c8fd34f
fix ca2002
mus65 Jul 15, 2025
4d1351a
fix ca1508
mus65 Jul 15, 2025
d2f660d
fix ca2000
mus65 Jul 15, 2025
6e9e74a
fix ca2025
mus65 Aug 14, 2025
76383f5
fix ca1849
mus65 Aug 14, 2025
d1b7291
fix Reverse() overloads
mus65 Sep 11, 2025
c0b525f
supress CA2002
mus65 Sep 11, 2025
a0a67e0
Use extension members for ThrowHelpers
mus65 Apr 18, 2025
6f8a60e
use extension members for CryptoAbstractions
mus65 Apr 18, 2025
b70f75e
use extension member for DateTime.UnixEpoch
mus65 May 9, 2025
7bc2828
use extension members for string.Join etc
mus65 May 9, 2025
7a836ae
use extension members for Convert.To/FromHexString
mus65 May 9, 2025
4211159
disable CA1508
mus65 Sep 27, 2025
8d5f47b
Merge remote-tracking branch 'upstream/develop' into net10
mus65 Oct 4, 2025
3454410
Merge remote-tracking branch 'upstream/develop' into net10
mus65 Oct 16, 2025
06ea59e
Update .NET 10 RC2
mus65 Oct 16, 2025
5a59ac9
Workaround Build Regression in .NET 10 RC2
mus65 Oct 16, 2025
76332f3
Merge remote-tracking branch 'upstream/develop' into net10
mus65 Oct 26, 2025
f55a8ae
suppress new warnings introduced by merge
mus65 Oct 26, 2025
a83ad5d
Merge remote-tracking branch 'upstream/develop' into net10
mus65 Nov 8, 2025
c93f536
Update to .NET 10 final release
mus65 Nov 11, 2025
1bdad1c
Revert "Workaround Build Regression in .NET 10 RC2"
mus65 Nov 11, 2025
52f30b8
Merge remote-tracking branch 'upstream/develop' into net10
mus65 Nov 15, 2025
6c3c06d
fix new warnings with MSTest 4 + .NET 10
mus65 Nov 15, 2025
327e6c6
use same Randomizer instance
mus65 Nov 15, 2025
5e7d01d
disable CA2000
mus65 Nov 15, 2025
fdd1dac
reduce CA1849 suppressions
mus65 Nov 15, 2025
9f19333
disable preview analyzers
mus65 Nov 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ dotnet_diagnostic.S2699.severity = none
# S2930: "IDisposables" should be disposed
# https://rules.sonarsource.com/csharp/RSPEC-2930/
#
# Duplicate of CA2000.
# too noisy.
dotnet_diagnostic.S2930.severity = none

# S2933: Fields that are only assigned in the constructor should be "readonly"
Expand Down Expand Up @@ -344,6 +344,10 @@ dotnet_diagnostic.S5659.severity = none
# https://rules.sonarsource.com/csharp/RSPEC-5773/
dotnet_diagnostic.S4581.severity = none

# S6966: Awaitable method should be used
# Duplicate of CA1849
dotnet_diagnostic.S6966.severity = none

#### StyleCop rules ####

# SA1003: Symbols must be spaced correctly
Expand Down Expand Up @@ -683,6 +687,10 @@ dotnet_diagnostic.CA1305.severity = none
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1309
dotnet_diagnostic.CA1309.severity = none

# CA1508: Avoid dead conditional code
# Too many false positives.
dotnet_diagnostic.CA1508.severity = none

# CA1510: Use ArgumentNullException throw helper
#
# This is only available in .NET 6.0 and higher. We'd need to use conditional compilation to only
Expand Down Expand Up @@ -726,6 +734,14 @@ dotnet_diagnostic.CA1848.severity = silent
# By default, this diagnostic is only reported for private members.
dotnet_code_quality.CA1859.api_surface = private,internal

# CA1873: Evaluation of this argument may be expensive and unnecessary if logging is disabled
dotnet_diagnostic.CA1873.severity = suggestion

# CA2000: Dispose objects before losing scope
#
# too noisy.
dotnet_diagnostic.CA2000.severity = suggestion

# CA2208: Instantiate argument exceptions correctly
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2208
#
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,33 @@ jobs:
uses: actions/setup-dotnet@v5

- name: Build Unit Tests .NET
run: dotnet build -f net9.0 test/Renci.SshNet.Tests/
run: dotnet build -f net10.0 test/Renci.SshNet.Tests/

- name: Build IntegrationTests .NET
run: dotnet build -f net9.0 test/Renci.SshNet.IntegrationTests/
run: dotnet build -f net10.0 test/Renci.SshNet.IntegrationTests/

- name: Run Unit Tests .NET
run: |
dotnet test \
-f net9.0 \
-f net10.0 \
--no-build \
--logger "console;verbosity=normal" \
--logger GitHubActions \
-p:CollectCoverage=true \
-p:CoverletOutputFormat=cobertura \
-p:CoverletOutput=../../coverlet/linux_unit_test_net_9_coverage.xml \
-p:CoverletOutput=../../coverlet/linux_unit_test_net_10_coverage.xml \
test/Renci.SshNet.Tests/

- name: Run Integration Tests .NET
run: |
dotnet test \
-f net9.0 \
-f net10.0 \
--no-build \
--logger "console;verbosity=normal" \
--logger GitHubActions \
-p:CollectCoverage=true \
-p:CoverletOutputFormat=cobertura \
-p:CoverletOutput=../../coverlet/linux_integration_test_net_9_coverage.xml \
-p:CoverletOutput=../../coverlet/linux_integration_test_net_10_coverage.xml \
test/Renci.SshNet.IntegrationTests/

- name: Archive Coverlet Results
Expand Down Expand Up @@ -82,13 +82,13 @@ jobs:
- name: Run Unit Tests .NET
run: |
dotnet test `
-f net9.0 `
-f net10.0 `
--no-build `
--logger "console;verbosity=normal" `
--logger GitHubActions `
-p:CollectCoverage=true `
-p:CoverletOutputFormat=cobertura `
-p:CoverletOutput=../../coverlet/windows_unit_test_net_9_coverage.xml `
-p:CoverletOutput=../../coverlet/windows_unit_test_net_10_coverage.xml `
test/Renci.SshNet.Tests/

- name: Run Unit Tests .NET Framework
Expand Down Expand Up @@ -173,7 +173,7 @@ jobs:
- name: Run Integration Tests .NET
run:
dotnet test `
-f net9.0 `
-f net10.0 `
--logger "console;verbosity=normal" `
--logger GitHubActions `
-p:CollectCoverage=true `
Expand Down
1 change: 0 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
-->
<PropertyGroup>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisLevel>preview-All</AnalysisLevel>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<!-- Should stay on LTS .NET releases. -->
<PackageVersion Include="Microsoft.Bcl.Cryptography" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.3" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="9.0.9" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="10.0.0" />
<PackageVersion Include="MSTest" Version="4.0.2" />
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.7.115" />
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "9.0.300",
"version": "10.0.100",
"rollForward": "latestFeature"
}
}
34 changes: 34 additions & 0 deletions src/Renci.SshNet/Abstractions/ConvertExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#nullable enable
#if !NET
using System.Text;
#endif

namespace System
{
internal static class ConvertExtensions
{
extension(Convert)
{
#if !NET
public static byte[] FromHexString(string s)
{
return Org.BouncyCastle.Utilities.Encoders.Hex.Decode(s);
}

public static string ToHexString(byte[] inArray)
{
ArgumentNullException.ThrowIfNull(inArray);

var builder = new StringBuilder(inArray.Length * 2);

foreach (var b in inArray)
{
builder.Append(b.ToString("X2"));
}

return builder.ToString();
}
#endif
}
}
}
74 changes: 1 addition & 73 deletions src/Renci.SshNet/Abstractions/CryptoAbstraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,80 +7,8 @@ namespace Renci.SshNet.Abstractions
{
internal static class CryptoAbstraction
{
private static readonly RandomNumberGenerator Randomizer = RandomNumberGenerator.Create();
internal static readonly RandomNumberGenerator Randomizer = RandomNumberGenerator.Create();

internal static readonly SecureRandom SecureRandom = new SecureRandom(new CryptoApiRandomGenerator(Randomizer));

/// <summary>
/// Generates a <see cref="byte"/> array of the specified length, and fills it with a
/// cryptographically strong random sequence of values.
/// </summary>
/// <param name="length">The length of the array generate.</param>
public static byte[] GenerateRandom(int length)
{
var random = new byte[length];
Randomizer.GetBytes(random);
return random;
}

public static byte[] HashMD5(byte[] source)
{
#if NET
return MD5.HashData(source);
#else
using (var md5 = MD5.Create())
{
return md5.ComputeHash(source);
}
#endif
}

public static byte[] HashSHA1(byte[] source)
{
#if NET
return SHA1.HashData(source);
#else
using (var sha1 = SHA1.Create())
{
return sha1.ComputeHash(source);
}
#endif
}

public static byte[] HashSHA256(byte[] source)
{
#if NET
return SHA256.HashData(source);
#else
using (var sha256 = SHA256.Create())
{
return sha256.ComputeHash(source);
}
#endif
}

public static byte[] HashSHA384(byte[] source)
{
#if NET
return SHA384.HashData(source);
#else
using (var sha384 = SHA384.Create())
{
return sha384.ComputeHash(source);
}
#endif
}

public static byte[] HashSHA512(byte[] source)
{
#if NET
return SHA512.HashData(source);
#else
using (var sha512 = SHA512.Create())
{
return sha512.ComputeHash(source);
}
#endif
}
}
}
19 changes: 19 additions & 0 deletions src/Renci.SshNet/Abstractions/DateTimeExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#nullable enable
namespace System
{
internal static class DateTimeExtensions
{
extension(DateTime)
{
#if !NET
public static DateTime UnixEpoch
{
get
{
return new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
}
}
#endif
}
}
}
19 changes: 19 additions & 0 deletions src/Renci.SshNet/Abstractions/MD5Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#nullable enable
namespace System.Security.Cryptography
{
internal static class MD5Extensions
{
extension(MD5)
{
#if !NET
public static byte[] HashData(byte[] source)
{
using (var md5 = MD5.Create())
{
return md5.ComputeHash(source);
}
}
#endif
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#nullable enable
#if !NET
using Renci.SshNet.Abstractions;
#endif

namespace System.Security.Cryptography
{
internal static class RandomNumberGeneratorExtensions
{
extension(RandomNumberGenerator)
{
#if !NET
public static byte[] GetBytes(int length)
{
var random = new byte[length];
CryptoAbstraction.Randomizer.GetBytes(random);
return random;
}
#endif
}
}
}
18 changes: 18 additions & 0 deletions src/Renci.SshNet/Abstractions/SHA1Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace System.Security.Cryptography
{
internal static class SHA1Extensions
{
extension(SHA1)
{
#if !NET
public static byte[] HashData(byte[] source)
{
using (var sha1 = SHA1.Create())
{
return sha1.ComputeHash(source);
}
}
#endif
}
}
}
19 changes: 19 additions & 0 deletions src/Renci.SshNet/Abstractions/SHA256Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#nullable enable
namespace System.Security.Cryptography
{
internal static class SHA256Extensions
{
extension(SHA256)
{
#if !NET
public static byte[] HashData(byte[] source)
{
using (var sha256 = SHA256.Create())
{
return sha256.ComputeHash(source);
}
}
#endif
}
}
}
19 changes: 19 additions & 0 deletions src/Renci.SshNet/Abstractions/SHA384Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#nullable enable
namespace System.Security.Cryptography
{
internal static class SHA384Extensions
{
extension(SHA384)
{
#if !NET
public static byte[] HashData(byte[] source)
{
using (var sha384 = SHA384.Create())
{
return sha384.ComputeHash(source);
}
}
#endif
}
}
}
19 changes: 19 additions & 0 deletions src/Renci.SshNet/Abstractions/SHA512Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#nullable enable
namespace System.Security.Cryptography
{
internal static class SHA512Extensions
{
extension(SHA512)
{
#if !NET
public static byte[] HashData(byte[] source)
{
using (var sha512 = SHA512.Create())
{
return sha512.ComputeHash(source);
}
}
#endif
}
}
}
Loading