RsaDigitalSignature
Implements RSA digital signature algorithm.
using Renci.SshNet.Abstractions;
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 HashAlgorithm _hash;
private bool _isDisposed;
public RsaDigitalSignature(RsaKey rsaKey)
: base(new ObjectIdentifier(1, 3, 14, 3, 2, 26), new RsaCipher(rsaKey))
{
_hash = CryptoAbstraction.CreateSHA1();
}
protected override byte[] Hash(byte[] input)
{
return _hash.ComputeHash(input);
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (!_isDisposed && disposing) {
HashAlgorithm hash = _hash;
if (hash != null) {
hash.Dispose();
_hash = null;
}
_isDisposed = true;
}
}
~RsaDigitalSignature()
{
Dispose(false);
}
}
}