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

RsaDigitalSignature

Implements RSA digital signature algorithm.
using Renci.SshNet.Common; using Renci.SshNet.Security.Cryptography.Ciphers; using System; using System.Security.Cryptography; namespace Renci.SshNet.Security.Cryptography { public class RsaDigitalSignature : CipherDigitalSignature, IDisposable { private readonly IncrementalHash _hash; public RsaDigitalSignature(RsaKey rsaKey) : this(rsaKey, HashAlgorithmName.SHA1) { } public RsaDigitalSignature(RsaKey rsaKey, HashAlgorithmName hashAlgorithmName) : base(ObjectIdentifier.FromHashAlgorithmName(hashAlgorithmName), new RsaCipher(rsaKey)) { _hash = IncrementalHash.CreateHash(hashAlgorithmName); } protected override byte[] Hash(byte[] input) { _hash.AppendData(input); return _hash.GetHashAndReset(); } public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } protected virtual void Dispose(bool disposing) { _hash.Dispose(); } } }