<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 HashAlgorithm _hash; public RsaDigitalSignature(RsaKey rsaKey) : this(rsaKey, HashAlgorithmName.SHA1) { } public RsaDigitalSignature(RsaKey rsaKey, HashAlgorithmName hashAlgorithmName) : base(ObjectIdentifier.FromHashAlgorithmName(hashAlgorithmName), new RsaCipher(rsaKey)) { HashAlgorithm obj = CryptoConfig.CreateFromName(hashAlgorithmName.Name) as HashAlgorithm; if (obj == null) throw new ArgumentException(string.Format("Could not create {0} from `{1}`.", "HashAlgorithm", hashAlgorithmName), "hashAlgorithmName"); _hash = obj; } protected override byte[] Hash(byte[] input) { return _hash.ComputeHash(input); } public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } protected virtual void Dispose(bool disposing) { _hash.Dispose(); } } }