Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected void Arrange()
_timeout = TimeSpan.FromSeconds(5);
_serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
_dataReceivedByServer = new List<byte>();
_serverIdentification = Encoding.UTF8.GetBytes("SSH-2.0\r\n");
_serverIdentification = "SSH-2.0\r\n"u8.ToArray();

_server = new AsyncSocketListener(_serverEndPoint);
_server.Start();
Expand Down
1 change: 1 addition & 0 deletions src/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462;net6.0;net7.0</TargetFrameworks>
<LangVersion>11</LangVersion>
<!--
Even though we're not interested in producing XML docs for test projects, we have to enable this in order to have the .NET Compiler
Platform analyzers produce the IDE0005 (Remove unnecessary import) diagnostic.
Expand Down
4 changes: 2 additions & 2 deletions src/Renci.SshNet/PrivateKeyFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,9 @@ private static Key ParseOpenSshV1Key(byte[] keyFileData, string passPhrase)
var keyReader = new SshDataReader(keyFileData);

// check magic header
var authMagic = Encoding.UTF8.GetBytes("openssh-key-v1\0");
var authMagic = "openssh-key-v1\0"u8;
var keyHeaderBytes = keyReader.ReadBytes(authMagic.Length);
if (!authMagic.IsEqualTo(keyHeaderBytes))
if (!authMagic.SequenceEqual(keyHeaderBytes))
{
throw new SshException("This openssh key does not contain the 'openssh-key-v1' format magic header");
}
Expand Down
5 changes: 5 additions & 0 deletions src/Renci.SshNet/Renci.SshNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AssemblyName>Renci.SshNet</AssemblyName>
<TargetFrameworks>net462;netstandard2.0;net6.0;net7.0</TargetFrameworks>
<LangVersion>11</LangVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net462' ">
Expand All @@ -13,6 +14,10 @@
<PackageReference Include="SshNet.Security.Cryptography" Version="[1.3.0]" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'net462' ">
<PackageReference Include="System.Memory" Version="4.5.5" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net7.0' ">
<DefineConstants>FEATURE_SOCKET_TAP;FEATURE_SOCKET_APM;FEATURE_SOCKET_EAP;FEATURE_DNS_SYNC;FEATURE_DNS_APM;FEATURE_DNS_TAP</DefineConstants>
</PropertyGroup>
Expand Down
18 changes: 9 additions & 9 deletions src/Renci.SshNet/Security/Cryptography/EcdsaKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public override BigInteger[] Public
{
get
{
byte[] curve;
ReadOnlySpan<byte> curve;
byte[] qx;
byte[] qy;
#if NETFRAMEWORK
Expand All @@ -167,16 +167,16 @@ public override BigInteger[] Public
switch (magic)
{
case KeyBlobMagicNumber.BCRYPT_ECDSA_PUBLIC_P256_MAGIC:
curve = Encoding.ASCII.GetBytes("nistp256");
curve = "nistp256"u8;
break;
case KeyBlobMagicNumber.BCRYPT_ECDSA_PUBLIC_P384_MAGIC:
curve = Encoding.ASCII.GetBytes("nistp384");
curve = "nistp384"u8;
break;
case KeyBlobMagicNumber.BCRYPT_ECDSA_PUBLIC_P521_MAGIC:
curve = Encoding.ASCII.GetBytes("nistp521");
curve = "nistp521"u8;
break;
default:
throw new SshException("Unexpected Curve Magic: " + magic);
throw new SshException($"Unexpected Curve Magic: {magic}");
}
#pragma warning restore IDE0010 // Add missing cases
#else
Expand All @@ -187,15 +187,15 @@ public override BigInteger[] Public
{
case "ECDSA_P256":
case "nistP256":
curve = Encoding.ASCII.GetBytes("nistp256");
curve = "nistp256"u8;
break;
case "ECDSA_P384":
case "nistP384":
curve = Encoding.ASCII.GetBytes("nistp384");
curve = "nistp384"u8;
break;
case "ECDSA_P521":
case "nistP521":
curve = Encoding.ASCII.GetBytes("nistp521");
curve = "nistp521"u8;
break;
default:
throw new SshException("Unexpected Curve Name: " + parameter.Curve.Oid.FriendlyName);
Expand All @@ -210,7 +210,7 @@ public override BigInteger[] Public
Buffer.BlockCopy(qy, 0, q, qx.Length + 1, qy.Length);

// returns Curve-Name and x/y as ECPoint
return new[] { new BigInteger(curve.Reverse()), new BigInteger(q.Reverse()) };
return new[] { new BigInteger(curve.ToArray().Reverse()), new BigInteger(q.Reverse()) };
}
set
{
Expand Down