| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- using Renci.SshNet.Common;
- using Renci.SshNet.Security.Cryptography;
- namespace Renci.SshNet.Security
- {
- /// <summary>
- /// Base class for asymmetric cipher algorithms.
- /// </summary>
- public abstract class Key
- {
- /// <summary>
- /// Gets the default digital signature implementation for this key.
- /// </summary>
- protected internal abstract DigitalSignature DigitalSignature { get; }
- /// <summary>
- /// Gets the public key.
- /// </summary>
- /// <value>
- /// The public.
- /// </value>
- public abstract BigInteger[] Public { get; }
- /// <summary>
- /// Gets the length of the key.
- /// </summary>
- /// <value>
- /// The length of the key.
- /// </value>
- public abstract int KeyLength { get; }
- /// <summary>
- /// Gets or sets the key comment.
- /// </summary>
- public string Comment { get; set; }
- /// <summary>
- /// Signs the specified data with the key.
- /// </summary>
- /// <param name="data">The data to sign.</param>
- /// <returns>
- /// Signed data.
- /// </returns>
- public byte[] Sign(byte[] data)
- {
- return DigitalSignature.Sign(data);
- }
- /// <summary>
- /// Verifies the signature.
- /// </summary>
- /// <param name="data">The data to verify.</param>
- /// <param name="signature">The signature to verify against.</param>
- /// <returns><see langword="true"/> is signature was successfully verifies; otherwise <see langword="false"/>.</returns>
- public bool VerifySignature(byte[] data, byte[] signature)
- {
- return DigitalSignature.Verify(data, signature);
- }
- }
- }
|