<PackageReference Include="SSH.NET" Version="2023.0.0" />

SshDataSignature

sealed class SshDataSignature : SshData
using Renci.SshNet.Common; using System; using System.Globalization; namespace Renci.SshNet.Security.Cryptography { internal sealed class SshDataSignature : SshData { private readonly int _signature_size; private byte[] _signature_r; private byte[] _signature_s; public byte[] Signature { get { byte[] array = new byte[_signature_size]; Buffer.BlockCopy(_signature_r, 0, array, 0, _signature_r.Length); Buffer.BlockCopy(_signature_s, 0, array, _signature_r.Length, _signature_s.Length); return array; } set { byte[] array = new byte[_signature_size / 2]; Buffer.BlockCopy(value, 0, array, 0, array.Length); BigInteger bigInteger = array.ToBigInteger2(); _signature_r = bigInteger.ToByteArray().Reverse(); byte[] array2 = new byte[_signature_size / 2]; Buffer.BlockCopy(value, array.Length, array2, 0, array2.Length); bigInteger = array2.ToBigInteger2(); _signature_s = bigInteger.ToByteArray().Reverse(); } } protected override int BufferCapacity => base.BufferCapacity + 4 + _signature_r.Length + 4 + _signature_s.Length; public SshDataSignature(int sig_size) { _signature_size = sig_size; } public SshDataSignature(byte[] data, int sig_size) { _signature_size = sig_size; Load(data); } protected override void LoadData() { _signature_r = ReadBinary().TrimLeadingZeros().Pad(_signature_size / 2); _signature_s = ReadBinary().TrimLeadingZeros().Pad(_signature_size / 2); } protected override void SaveData() { BigInteger bigInteger = _signature_r.ToBigInteger2(); WriteBinaryString(bigInteger.ToByteArray().Reverse()); bigInteger = _signature_s.ToBigInteger2(); WriteBinaryString(bigInteger.ToByteArray().Reverse()); } public new byte[] ReadBinary() { uint num = ReadUInt32(); if (num > 2147483647) throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Strings longer than {0} is not supported.", 2147483647)); return ReadBytes((int)num); } } }