/// <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(); }
[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"); }
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); }
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."); }
/// <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); }
/// <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)); } }
[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."); }
/// <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; }
/// <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); }
/// <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); } }
/// <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); } }
/// <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(); }
public PrivateKeyAgentKey(KeyHostAlgorithm key, string comment) { this.Key = key; this.Comment = comment; }
/// <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; }
/// <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; }
/// <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; }
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; }
public PrivateKeyAgentKey AddSsh2(KeyHostAlgorithm key, string comment) { return Add(this.keysSsh2, key, comment); }