diff --git a/Renci.SshClient/Renci.SshNet/Security/Cryptography/DsaDigitalSignature.cs b/Renci.SshClient/Renci.SshNet/Security/Cryptography/DsaDigitalSignature.cs index aebf86d3..87cdc506 100644 --- a/Renci.SshClient/Renci.SshNet/Security/Cryptography/DsaDigitalSignature.cs +++ b/Renci.SshClient/Renci.SshNet/Security/Cryptography/DsaDigitalSignature.cs @@ -164,7 +164,7 @@ namespace Renci.SshNet.Security.Cryptography // Dispose managed ResourceMessages. if (this._hash != null) { - this._hash.Dispose(); + this._hash.Clear(); this._hash = null; } } diff --git a/Renci.SshClient/Renci.SshNet/Security/Cryptography/HMAC.cs b/Renci.SshClient/Renci.SshNet/Security/Cryptography/HMAC.cs index f0457357..8152ff6d 100644 --- a/Renci.SshClient/Renci.SshNet/Security/Cryptography/HMAC.cs +++ b/Renci.SshClient/Renci.SshNet/Security/Cryptography/HMAC.cs @@ -153,5 +153,16 @@ namespace Renci.SshNet.Security.Cryptography this._outerPadding[i] ^= this.KeyValue[i]; } } + + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + + if (this._hash != null) + { + this._hash.Clear(); + this._hash = null; + } + } } } diff --git a/Renci.SshClient/Renci.SshNet/Session.cs b/Renci.SshClient/Renci.SshNet/Session.cs index b4d6a646..56446e2b 100644 --- a/Renci.SshClient/Renci.SshNet/Session.cs +++ b/Renci.SshClient/Renci.SshNet/Session.cs @@ -1218,13 +1218,13 @@ namespace Renci.SshNet // Dispose of old ciphers and hash algorithms if (this._serverMac != null) { - this._serverMac.Dispose(); + this._serverMac.Clear(); this._serverMac = null; } if (this._clientMac != null) { - this._clientMac.Dispose(); + this._clientMac.Clear(); this._clientMac = null; }