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

DsaDigitalSignature

Implements DSA digital signature algorithm.
using Renci.SshNet.Common; using System; using System.Runtime.CompilerServices; using System.Security.Cryptography; namespace Renci.SshNet.Security.Cryptography { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] public class DsaDigitalSignature : DigitalSignature, IDisposable { private readonly DsaKey _key; public DsaDigitalSignature(DsaKey key) { ThrowHelper.ThrowIfNull(key, "key"); _key = key; } public override bool Verify(byte[] input, byte[] signature) { using (SHA1 sHA = SHA1.Create()) { byte[] rgbHash = sHA.ComputeHash(input); return _key.DSA.VerifySignature(rgbHash, signature); } } public override byte[] Sign(byte[] input) { using (SHA1 sHA = SHA1.Create()) { byte[] rgbHash = sHA.ComputeHash(input); return _key.DSA.CreateSignature(rgbHash); } } public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } protected virtual void Dispose(bool disposing) { } } }