TestCipher.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Microsoft.VisualStudio.TestTools.UnitTesting;
  6. using Renci.SshNet.Security;
  7. using Renci.SshNet.Tests.Properties;
  8. namespace Renci.SshNet.Tests.Security
  9. {
  10. [TestClass]
  11. public class TestCipher
  12. {
  13. [TestMethod]
  14. public void Test_Cipher_TripleDESCBC_Connection()
  15. {
  16. var connectionInfo = new PasswordConnectionInfo(Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD);
  17. connectionInfo.Encryptions.Clear();
  18. connectionInfo.Encryptions.Add("3des-cbc", typeof(CipherTripleDes192Cbc));
  19. using (var client = new SshClient(connectionInfo))
  20. {
  21. client.Connect();
  22. client.Disconnect();
  23. }
  24. }
  25. [TestMethod]
  26. public void Test_Cipher_AEes128CBC_Connection()
  27. {
  28. var connectionInfo = new PasswordConnectionInfo(Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD);
  29. connectionInfo.Encryptions.Clear();
  30. connectionInfo.Encryptions.Add("aes128-cbc", typeof(CipherAes128Cbc));
  31. using (var client = new SshClient(connectionInfo))
  32. {
  33. client.Connect();
  34. client.Disconnect();
  35. }
  36. }
  37. [TestMethod]
  38. public void Test_Cipher_Aes192CBC_Connection()
  39. {
  40. var connectionInfo = new PasswordConnectionInfo(Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD);
  41. connectionInfo.Encryptions.Clear();
  42. connectionInfo.Encryptions.Add("aes192-cbc", typeof(CipherAes192Cbc));
  43. using (var client = new SshClient(connectionInfo))
  44. {
  45. client.Connect();
  46. client.Disconnect();
  47. }
  48. }
  49. [TestMethod]
  50. public void Test_Cipher_Aes256CBC_Connection()
  51. {
  52. var connectionInfo = new PasswordConnectionInfo(Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD);
  53. connectionInfo.Encryptions.Clear();
  54. connectionInfo.Encryptions.Add("aes256-cbc", typeof(CipherAes256Cbc));
  55. using (var client = new SshClient(connectionInfo))
  56. {
  57. client.Connect();
  58. client.Disconnect();
  59. }
  60. }
  61. [TestMethod]
  62. public void Test_Cipher_Aes128CTR_Connection()
  63. {
  64. var connectionInfo = new PasswordConnectionInfo(Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD);
  65. connectionInfo.Encryptions.Clear();
  66. connectionInfo.Encryptions.Add("aes128-ctr", typeof(CipherAes128Ctr));
  67. using (var client = new SshClient(connectionInfo))
  68. {
  69. client.Connect();
  70. client.Disconnect();
  71. }
  72. }
  73. [TestMethod]
  74. public void Test_Cipher_Aes192CTR_Connection()
  75. {
  76. var connectionInfo = new PasswordConnectionInfo(Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD);
  77. connectionInfo.Encryptions.Clear();
  78. connectionInfo.Encryptions.Add("aes192-ctr", typeof(CipherAes192Ctr));
  79. using (var client = new SshClient(connectionInfo))
  80. {
  81. client.Connect();
  82. client.Disconnect();
  83. }
  84. }
  85. [TestMethod]
  86. public void Test_Cipher_Aes256CTR_Connection()
  87. {
  88. var connectionInfo = new PasswordConnectionInfo(Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD);
  89. connectionInfo.Encryptions.Clear();
  90. connectionInfo.Encryptions.Add("aes256-ctr", typeof(CipherAes256Ctr));
  91. using (var client = new SshClient(connectionInfo))
  92. {
  93. client.Connect();
  94. client.Disconnect();
  95. }
  96. }
  97. [TestMethod]
  98. public void Test_Cipher_BlowfishCBC_Connection()
  99. {
  100. var connectionInfo = new PasswordConnectionInfo(Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD);
  101. connectionInfo.Encryptions.Clear();
  102. connectionInfo.Encryptions.Add("blowfish-cbc", typeof(CipherBlowfish));
  103. using (var client = new SshClient(connectionInfo))
  104. {
  105. client.Connect();
  106. client.Disconnect();
  107. }
  108. }
  109. [TestMethod]
  110. public void Test_Cipher_Cast128CBC_Connection()
  111. {
  112. var connectionInfo = new PasswordConnectionInfo(Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD);
  113. connectionInfo.Encryptions.Clear();
  114. connectionInfo.Encryptions.Add("cast128-cbc", typeof(CipherCast128Cbc));
  115. using (var client = new SshClient(connectionInfo))
  116. {
  117. client.Connect();
  118. client.Disconnect();
  119. }
  120. }
  121. }
  122. }