diff --git a/src/Renci.SshNet/Common/AsyncResult.cs b/src/Renci.SshNet/Common/AsyncResult.cs index cb8adb0a..c5c643af 100644 --- a/src/Renci.SshNet/Common/AsyncResult.cs +++ b/src/Renci.SshNet/Common/AsyncResult.cs @@ -166,7 +166,7 @@ namespace Renci.SshNet.Common /// /// The async callback. /// The state. - public AsyncResult(AsyncCallback asyncCallback, Object state) + protected AsyncResult(AsyncCallback asyncCallback, Object state) : base(asyncCallback, state) { } diff --git a/src/Renci.SshNet/Security/Cryptography/CipherDigitalSignature.cs b/src/Renci.SshNet/Security/Cryptography/CipherDigitalSignature.cs index 921b12ee..88f6ddad 100644 --- a/src/Renci.SshNet/Security/Cryptography/CipherDigitalSignature.cs +++ b/src/Renci.SshNet/Security/Cryptography/CipherDigitalSignature.cs @@ -10,7 +10,6 @@ namespace Renci.SshNet.Security.Cryptography public abstract class CipherDigitalSignature : DigitalSignature { private readonly AsymmetricCipher _cipher; - private readonly ObjectIdentifier _oid; /// @@ -18,13 +17,13 @@ namespace Renci.SshNet.Security.Cryptography /// /// The object identifier. /// The cipher. - public CipherDigitalSignature(ObjectIdentifier oid, AsymmetricCipher cipher) + protected CipherDigitalSignature(ObjectIdentifier oid, AsymmetricCipher cipher) { if (cipher == null) throw new ArgumentNullException("cipher"); - this._cipher = cipher; - this._oid = oid; + _cipher = cipher; + _oid = oid; } /// @@ -37,8 +36,8 @@ namespace Renci.SshNet.Security.Cryptography /// public override bool Verify(byte[] input, byte[] signature) { - var encryptedSignature = this._cipher.Decrypt(signature); - var hashData = this.Hash(input); + var encryptedSignature = _cipher.Decrypt(signature); + var hashData = Hash(input); var expected = DerEncode(hashData); return expected.SequenceEqual(encryptedSignature); } @@ -53,12 +52,12 @@ namespace Renci.SshNet.Security.Cryptography public override byte[] Sign(byte[] input) { // Calculate hash value - var hashData = this.Hash(input); + var hashData = Hash(input); // Calculate DER string var derEncodedHash = DerEncode(hashData); - return this._cipher.Encrypt(derEncodedHash).TrimLeadingZero().ToArray(); + return _cipher.Encrypt(derEncodedHash).TrimLeadingZero().ToArray(); } /// @@ -75,15 +74,13 @@ namespace Renci.SshNet.Security.Cryptography /// DER Encoded byte array protected byte[] DerEncode(byte[] hashData) { - var data = new DerData(); - var alg = new DerData(); - alg.Write(this._oid); + alg.Write(_oid); alg.WriteNull(); + var data = new DerData(); data.Write(alg); data.Write(hashData); - return data.Encode(); } } diff --git a/src/Renci.SshNet/Security/Cryptography/Key.cs b/src/Renci.SshNet/Security/Cryptography/Key.cs index c13ede0e..5cf42187 100644 --- a/src/Renci.SshNet/Security/Cryptography/Key.cs +++ b/src/Renci.SshNet/Security/Cryptography/Key.cs @@ -40,7 +40,7 @@ namespace Renci.SshNet.Security /// Initializes a new instance of the class. /// /// DER encoded private key data. - public Key(byte[] data) + protected Key(byte[] data) { if (data == null) throw new ArgumentNullException("data"); @@ -54,13 +54,13 @@ namespace Renci.SshNet.Security keys.Add(der.ReadBigInteger()); } - this._privateKey = keys.ToArray(); + _privateKey = keys.ToArray(); } /// /// Initializes a new instance of the class. /// - public Key() + protected Key() { } @@ -73,7 +73,7 @@ namespace Renci.SshNet.Security /// public byte[] Sign(byte[] data) { - return this.DigitalSignature.Sign(data); + return DigitalSignature.Sign(data); } /// @@ -84,7 +84,7 @@ namespace Renci.SshNet.Security /// True is signature was successfully verifies; otherwise false. public bool VerifySignature(byte[] data, byte[] signature) { - return this.DigitalSignature.Verify(data, signature); + return DigitalSignature.Verify(data, signature); } } }