Implements key support for host algorithm.
Inheritance: HostAlgorithm
コード例 #1
0
 /// <summary>
 /// Called when type specific data need to be loaded.
 /// </summary>
 protected override void LoadData()
 {
     base.LoadData();
     var ignored = this.ReadUInt32();
     this.Key = new KeyHostAlgorithm("ssh1", this.ReadRsaKey());
     this.Comment = this.ReadString();
 }
コード例 #2
0
 [Ignore] // placeholder for actual test
 public void KeyHostAlgorithmConstructorTest()
 {
     string name = string.Empty; // TODO: Initialize to an appropriate value
     Key key = null; // TODO: Initialize to an appropriate value
     KeyHostAlgorithm target = new KeyHostAlgorithm(name, key);
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
コード例 #3
0
        public PrivateKeyAgentKey AddSsh1(KeyHostAlgorithm key, string comment)
        {
            if (!(key.Key is RsaKey))
            {
                throw new SshException("SSH1 keys can only be RSA keys.");
            }

            return Add(this.keysSsh1, key, comment);
        }
コード例 #4
0
 public void DataTest()
 {
     string name = string.Empty; // TODO: Initialize to an appropriate value
     Key key = null; // TODO: Initialize to an appropriate value
     KeyHostAlgorithm target = new KeyHostAlgorithm(name, key); // TODO: Initialize to an appropriate value
     byte[] actual;
     actual = target.Data;
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
コード例 #5
0
        /// <summary>
        /// Determines whether the specified host key can be trusted.
        /// </summary>
        /// <param name="host">The host algorithm.</param>
        /// <returns>
        ///   <c>true</c> if the specified host can be trusted; otherwise, <c>false</c>.
        /// </returns>
        protected bool CanTrustHostKey(KeyHostAlgorithm host)
        {
            var args = new HostKeyEventArgs(host);

            if (this.HostKeyReceived != null)
            {
                this.HostKeyReceived(this, args);
            }

            return(args.CanTrust);
        }
コード例 #6
0
 /// <summary>
 /// Called when type specific data need to be loaded.
 /// </summary>
 protected override void LoadData()
 {
     int count = (int)this.ReadUInt32();
     this.Keys = new List<PrivateKeyAgentKey>(count);
     for (int i = 0; i < count; i++)
     {
         var key = new KeyHostAlgorithm("", new RsaKey(), this.ReadBytes());
         string comment = this.ReadString();
         this.Keys.Add(new PrivateKeyAgentKey(key, comment));
     }
 }
コード例 #7
0
 [Ignore] // placeholder for actual test
 public void SignTest()
 {
     string name = string.Empty; // TODO: Initialize to an appropriate value
     Key key = null; // TODO: Initialize to an appropriate value
     KeyHostAlgorithm target = new KeyHostAlgorithm(name, key); // TODO: Initialize to an appropriate value
     byte[] data = null; // TODO: Initialize to an appropriate value
     byte[] expected = null; // TODO: Initialize to an appropriate value
     byte[] actual;
     actual = target.Sign(data);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
コード例 #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HostKeyEventArgs"/> class.
        /// </summary>
        /// <param name="host">The host.</param>
        public HostKeyEventArgs(KeyHostAlgorithm host)
        {
            this.CanTrust = true;   //  Set default value

            this.HostKey = host.Data;

            this.KeyLength = host.Key.KeyLength;

            var md5 = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Md5);
            byte[] buffer;
            CryptographicBuffer.CopyToByteArray(md5.HashData(CryptographicBuffer.CreateFromByteArray(host.Data)), out buffer);
            this.FingerPrint = buffer;
        }
コード例 #9
0
ファイル: KeyExchange.cs プロジェクト: sp0x/ApkLoader
        /// <summary>
        /// Determines whether the specified host key can be trusted.
        /// </summary>
        /// <param name="host">The host algorithm.</param>
        /// <returns>
        /// <c>true</c> if the specified host can be trusted; otherwise, <c>false</c>.
        /// </returns>
        protected bool CanTrustHostKey(KeyHostAlgorithm host)
        {
            var handlers = HostKeyReceived;

            if (handlers != null)
            {
                var args = new HostKeyEventArgs(host);
                handlers(this, args);
                return(args.CanTrust);
            }

            return(true);
        }
コード例 #10
0
ファイル: HostKeyEventArgs.cs プロジェクト: nemec/Blossom
        /// <summary>
        /// Initializes a new instance of the <see cref="HostKeyEventArgs"/> class.
        /// </summary>
        /// <param name="host">The host.</param>
        public HostKeyEventArgs(KeyHostAlgorithm host)
        {
            this.CanTrust = true;   //  Set default value

            this.HostKey = host.Data;

            this.KeyLength = host.Key.KeyLength;

            using (var md5 = new MD5Hash())
            {
                this.FingerPrint = md5.ComputeHash(host.Data);
            }
        }
コード例 #11
0
ファイル: HostKeyEventArgs.cs プロジェクト: sshnet/SSH.NET
        /// <summary>
        /// Initializes a new instance of the <see cref="HostKeyEventArgs"/> class.
        /// </summary>
        /// <param name="host">The host.</param>
        public HostKeyEventArgs(KeyHostAlgorithm host)
        {
            CanTrust = true;   //  Set default value

            HostKey = host.Data;

            HostKeyName = host.Name;

            KeyLength = host.Key.KeyLength;

            using (var md5 = CryptoAbstraction.CreateMD5())
            {
                FingerPrint = md5.ComputeHash(host.Data);
            }
        }
コード例 #12
0
        /// <summary>
        /// Called when type specific data need to be loaded.
        /// </summary>
        protected override void LoadData()
        {
            base.LoadData();
            var keyType = this.ReadString();
            switch (keyType)
            {
                case "ssh-rsa":
                    this.Key = new KeyHostAlgorithm(keyType, this.ReadRsaKey());
                    break;
                case "ssh-dss":
                    this.Key = new KeyHostAlgorithm(keyType, this.ReadDsaKey());
                    break;
                default:
                    throw new SshException("Private key type '" + keyType + "' is not supported.");
            }

            this.Comment = this.ReadString();
        }
コード例 #13
0
 public PrivateKeyAgentKey(KeyHostAlgorithm key, string comment)
 {
     this.Key = key;
     this.Comment = comment;
 }
コード例 #14
0
ファイル: KeyExchange.cs プロジェクト: Youkyungjin/Crawler
        /// <summary>
        /// Determines whether the specified host key can be trusted.
        /// </summary>
        /// <param name="host">The host algorithm.</param>
        /// <returns>
        ///   <c>true</c> if the specified host can be trusted; otherwise, <c>false</c>.
        /// </returns>
        protected bool CanTrustHostKey(KeyHostAlgorithm host)
        {
            var args = new HostKeyEventArgs(host);

            if (this.HostKeyReceived != null)
            {
                this.HostKeyReceived(this, args);
            }

            return args.CanTrust;
        }
コード例 #15
0
ファイル: KeyExchange.cs プロジェクト: sshnet/SSH.NET
        /// <summary>
        /// Determines whether the specified host key can be trusted.
        /// </summary>
        /// <param name="host">The host algorithm.</param>
        /// <returns>
        /// <c>true</c> if the specified host can be trusted; otherwise, <c>false</c>.
        /// </returns>
        protected bool CanTrustHostKey(KeyHostAlgorithm host)
        {
            var handlers = HostKeyReceived;
            if (handlers != null)
            {
                var args = new HostKeyEventArgs(host);
                handlers(this, args);
                return args.CanTrust;
            }

            return true;
        }
コード例 #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RemoveIdentityMessage"/> class.
 /// </summary>
 /// <param name="serviceName">Name of the service.</param>
 /// <param name="username">Authentication username.</param>
 /// <param name="keyAlgorithmName">Name of private key algorithm.</param>
 /// <param name="keyData">Private key data.</param>
 public AddIdentityMessage(KeyHostAlgorithm key, string comment)
 {
     this.Key = key;
     this.Comment = comment;
 }
コード例 #17
0
        private static PrivateKeyAgentKey Add(List<PrivateKeyAgentKey> keys, KeyHostAlgorithm key, string comment)
        {
            var existingKey = GetKey(keys, key.Data);
            if (existingKey != null)
            {
                return null;
            }

            var agentKey = new PrivateKeyAgentKey(key, comment);
            keys.Add(agentKey);
            return agentKey;
        }
コード例 #18
0
 public PrivateKeyAgentKey AddSsh2(KeyHostAlgorithm key, string comment)
 {
     return Add(this.keysSsh2, key, comment);
 }