Skip to content
Merged
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
8 changes: 5 additions & 3 deletions src/cs/Ssh/Algorithms/ECDsa.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ public KeyPair(string keyAlgorithmName)
/// Use this constructor when the ECDSA private key is non-exportable
/// (for example, backed by CNG/KSP from a certificate imported by the
/// Azure Key Vault VM extension). The SSH library will call
/// <see cref="System.Security.Cryptography.ECDsa.SignData"/> and
/// <see cref="System.Security.Cryptography.ECDsa.VerifyData"/> on the
/// provided instance directly, without ever needing to export raw key material.
/// <see cref="System.Security.Cryptography.ECDsa.SignData(byte[], int, int, HashAlgorithmName)"/> and
/// <see cref="System.Security.Cryptography.ECDsa.VerifyData(byte[], int, int, byte[], HashAlgorithmName)"/>
/// on the provided instance directly, without ever needing to export raw key material.
/// </remarks>
public KeyPair(System.Security.Cryptography.ECDsa algorithm)
{
Expand All @@ -143,7 +143,9 @@ public KeyPair(System.Security.Cryptography.ECDsa algorithm)

// Determine the curve from the public key parameters (always exportable).
var p = algorithm.ExportParameters(false);
#pragma warning disable CA1308 // Normalize strings to uppercase
var curveName = p.Curve.Oid?.FriendlyName?.ToLowerInvariant() ?? string.Empty;
#pragma warning restore CA1308 // Normalize strings to uppercase
if (curveName.StartsWith("ecdsa_p", StringComparison.Ordinal))
{
curveName = "nistp" + curveName.Substring(7);
Expand Down
5 changes: 3 additions & 2 deletions src/cs/Ssh/Algorithms/Rsa.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ public KeyPair(int? keySizeInBits = null)
/// Use this constructor when the RSA private key is non-exportable
/// (for example, backed by CNG/KSP from a certificate imported by the
/// Azure Key Vault VM extension). The SSH library will call
/// <see cref="RSA.SignData"/> and <see cref="RSA.VerifyData"/> on the
/// provided instance directly, without ever needing to export raw key material.
/// <see cref="RSA.SignData(byte[], int, int, HashAlgorithmName, RSASignaturePadding)"/> and
/// <see cref="RSA.VerifyData(byte[], int, int, byte[], HashAlgorithmName, RSASignaturePadding)"/>
/// on the provided instance directly, without ever needing to export raw key material.
/// </remarks>
public KeyPair(RSA algorithm)
{
Expand Down
4 changes: 2 additions & 2 deletions src/cs/Ssh/IO/Buffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ public byte[] ToArray()
return Copy().Array;
}

#if SSH_ENABLE_SPAN
#pragma warning disable CA2225 // Operator overloads have named alternates
#if SSH_ENABLE_SPAN

public Span<byte> Span => new Span<byte>(Array, Offset, Count);

Expand All @@ -141,13 +141,13 @@ public byte[] ToArray()

public static implicit operator Memory<byte>(Buffer buffer) => buffer.Memory;

#pragma warning restore CA2225 // Operator overloads have named alternates
#endif

public static implicit operator Buffer(byte[] array)
{
return Buffer.From(array ?? System.Array.Empty<byte>());
}
#pragma warning restore CA2225 // Operator overloads have named alternates

public override bool Equals(object? obj)
{
Expand Down
1 change: 1 addition & 0 deletions src/cs/Ssh/Services/KeyExchangeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ private async Task HandleMessageAsync(
var clientExchangeValue = message.E;
var serverExchangeValue = keyExchange.StartKeyExchange();
var sharedSecret = keyExchange.DecryptKeyExchange(clientExchangeValue);

// RFC 8332 §3: Host key blob MUST use "ssh-rsa", not the signature algorithm name.
// PuTTY-based clients (FileZilla, WinSCP) reject host keys with wrong key type.
var hostKeyAndCerts = privateKey.GetPublicKeyBytes(publicKeyAlg.KeyAlgorithmName);
Expand Down
Loading