using System;
using Renci.SshNet.Security.Cryptography;
using Renci.SshNet.Security;
namespace Renci.SshNet.Common
{
    /// 
    /// Provides data for the HostKeyReceived event.
    /// 
    public class HostKeyEventArgs : EventArgs
    {
        /// 
        /// Gets or sets a value indicating whether host key can be trusted.
        /// 
        /// 
        ///   true if host key can be trusted; otherwise, false.
        /// 
        public bool CanTrust { get; set; }
        /// 
        /// Gets the host key.
        /// 
        public byte[] HostKey { get; private set; }
        /// 
        /// Gets the host key name.
        /// 
        public string HostKeyName{ get; private set; }
        /// 
        /// Gets the finger print.
        /// 
        public byte[] FingerPrint { get; private set; }
        /// 
        /// Gets the length of the key in bits.
        /// 
        /// 
        /// The length of the key in bits.
        /// 
        public int KeyLength { get; private set; }
        /// 
        /// Initializes a new instance of the  class.
        /// 
        /// The host.
        public HostKeyEventArgs(KeyHostAlgorithm host)
        {
            this.CanTrust = true;   //  Set default value
            this.HostKey = host.Data;
            this.HostKeyName = host.Name;
            this.KeyLength = host.Key.KeyLength;
            using (var md5 = new MD5Hash())
            {
                this.FingerPrint = md5.ComputeHash(host.Data);
            }
        }
    }
}