mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-10-20 23:56:41 +08:00
Make ctor protected.
Remove this qualifier.
This commit is contained in:
@@ -166,7 +166,7 @@ namespace Renci.SshNet.Common
|
||||
/// </summary>
|
||||
/// <param name="asyncCallback">The async callback.</param>
|
||||
/// <param name="state">The state.</param>
|
||||
public AsyncResult(AsyncCallback asyncCallback, Object state)
|
||||
protected AsyncResult(AsyncCallback asyncCallback, Object state)
|
||||
: base(asyncCallback, state)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ namespace Renci.SshNet.Security.Cryptography
|
||||
public abstract class CipherDigitalSignature : DigitalSignature
|
||||
{
|
||||
private readonly AsymmetricCipher _cipher;
|
||||
|
||||
private readonly ObjectIdentifier _oid;
|
||||
|
||||
/// <summary>
|
||||
@@ -18,13 +17,13 @@ namespace Renci.SshNet.Security.Cryptography
|
||||
/// </summary>
|
||||
/// <param name="oid">The object identifier.</param>
|
||||
/// <param name="cipher">The cipher.</param>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -37,8 +36,8 @@ namespace Renci.SshNet.Security.Cryptography
|
||||
/// </returns>
|
||||
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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -75,15 +74,13 @@ namespace Renci.SshNet.Security.Cryptography
|
||||
/// <returns>DER Encoded byte array</returns>
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Renci.SshNet.Security
|
||||
/// Initializes a new instance of the <see cref="Key"/> class.
|
||||
/// </summary>
|
||||
/// <param name="data">DER encoded private key data.</param>
|
||||
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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Key"/> class.
|
||||
/// </summary>
|
||||
public Key()
|
||||
protected Key()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace Renci.SshNet.Security
|
||||
/// </returns>
|
||||
public byte[] Sign(byte[] data)
|
||||
{
|
||||
return this.DigitalSignature.Sign(data);
|
||||
return DigitalSignature.Sign(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -84,7 +84,7 @@ namespace Renci.SshNet.Security
|
||||
/// <returns><c>True</c> is signature was successfully verifies; otherwise <c>false</c>.</returns>
|
||||
public bool VerifySignature(byte[] data, byte[] signature)
|
||||
{
|
||||
return this.DigitalSignature.Verify(data, signature);
|
||||
return DigitalSignature.Verify(data, signature);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user