示例#1
0
 /// <exception cref="NSch.JSchException"></exception>
 public HashedHostKey(KnownHosts _enclosing, string host, int type, byte[] key) :
     base(host, type, key)
 {
     this._enclosing = _enclosing;
     if (this.host.StartsWith(KnownHosts.HashedHostKey.HASH_MAGIC) && Sharpen.Runtime.Substring
             (this.host, KnownHosts.HashedHostKey.HASH_MAGIC.Length).IndexOf(KnownHosts.HashedHostKey
                                                                             .HASH_DELIM) > 0)
     {
         string data = Sharpen.Runtime.Substring(this.host, KnownHosts.HashedHostKey.HASH_MAGIC
                                                 .Length);
         string _salt = Sharpen.Runtime.Substring(data, 0, data.IndexOf(KnownHosts.HashedHostKey
                                                                        .HASH_DELIM));
         string _hash = Sharpen.Runtime.Substring(data, data.IndexOf(KnownHosts.HashedHostKey
                                                                     .HASH_DELIM) + 1);
         this.salt = Util.FromBase64(Util.Str2byte(_salt), 0, _salt.Length);
         this.hash = Util.FromBase64(Util.Str2byte(_hash), 0, _hash.Length);
         if (this.salt.Length != 20 || this.hash.Length != 20)
         {
             // block size of hmac-sha1
             this.salt = null;
             this.hash = null;
             return;
         }
         this.hashed = true;
     }
 }
示例#2
0
			/// <exception cref="NSch.JSchException"></exception>
			public HashedHostKey(KnownHosts _enclosing, string host, int type, byte[] key) : 
				base(host, type, key)
			{
				this._enclosing = _enclosing;
				if (this.host.StartsWith(KnownHosts.HashedHostKey.HASH_MAGIC) && Sharpen.Runtime.Substring
					(this.host, KnownHosts.HashedHostKey.HASH_MAGIC.Length).IndexOf(KnownHosts.HashedHostKey
					.HASH_DELIM) > 0)
				{
					string data = Sharpen.Runtime.Substring(this.host, KnownHosts.HashedHostKey.HASH_MAGIC
						.Length);
					string _salt = Sharpen.Runtime.Substring(data, 0, data.IndexOf(KnownHosts.HashedHostKey
						.HASH_DELIM));
					string _hash = Sharpen.Runtime.Substring(data, data.IndexOf(KnownHosts.HashedHostKey
						.HASH_DELIM) + 1);
					this.salt = Util.FromBase64(Util.Str2byte(_salt), 0, _salt.Length);
					this.hash = Util.FromBase64(Util.Str2byte(_hash), 0, _hash.Length);
					if (this.salt.Length != 20 || this.hash.Length != 20)
					{
						// block size of hmac-sha1
						this.salt = null;
						this.hash = null;
						return;
					}
					this.hashed = true;
				}
			}
示例#3
0
 /// <exception cref="NSch.JSchException"></exception>
 public HashedHostKey(KnownHosts _enclosing, string host, byte[] key) : this(_enclosing, host,
                                                                             HostKey.GUESS, key)
 {
     this._enclosing = _enclosing;
 }
示例#4
0
			/// <exception cref="NSch.JSchException"></exception>
			public HashedHostKey(KnownHosts _enclosing, string host, byte[] key) : this(_enclosing, host, 
				HostKey.GUESS, key)
			{
				this._enclosing = _enclosing;
			}