CipherTests.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using Renci.SshNet.IntegrationTests.Common;
  2. using Renci.SshNet.TestTools.OpenSSH;
  3. namespace Renci.SshNet.IntegrationTests
  4. {
  5. [TestClass]
  6. public class CipherTests : IntegrationTestBase
  7. {
  8. private IConnectionInfoFactory _connectionInfoFactory;
  9. private RemoteSshdConfig _remoteSshdConfig;
  10. [TestInitialize]
  11. public void SetUp()
  12. {
  13. _connectionInfoFactory = new LinuxVMConnectionFactory(SshServerHostName, SshServerPort);
  14. _remoteSshdConfig = new RemoteSshd(new LinuxAdminConnectionFactory(SshServerHostName, SshServerPort)).OpenConfig();
  15. }
  16. [TestCleanup]
  17. public void TearDown()
  18. {
  19. _remoteSshdConfig?.Reset();
  20. }
  21. [TestMethod]
  22. public void TripledesCbc()
  23. {
  24. DoTest(Cipher.TripledesCbc);
  25. }
  26. [TestMethod]
  27. public void Aes128Cbc()
  28. {
  29. DoTest(Cipher.Aes128Cbc);
  30. }
  31. [TestMethod]
  32. public void Aes192Cbc()
  33. {
  34. DoTest(Cipher.Aes192Cbc);
  35. }
  36. [TestMethod]
  37. public void Aes256Cbc()
  38. {
  39. DoTest(Cipher.Aes256Cbc);
  40. }
  41. [TestMethod]
  42. public void Aes128Ctr()
  43. {
  44. DoTest(Cipher.Aes128Ctr);
  45. }
  46. [TestMethod]
  47. public void Aes192Ctr()
  48. {
  49. DoTest(Cipher.Aes192Ctr);
  50. }
  51. [TestMethod]
  52. public void Aes256Ctr()
  53. {
  54. DoTest(Cipher.Aes256Ctr);
  55. }
  56. private void DoTest(Cipher cipher)
  57. {
  58. _remoteSshdConfig.ClearCiphers()
  59. .AddCipher(cipher)
  60. .Update()
  61. .Restart();
  62. using (var client = new SshClient(_connectionInfoFactory.Create()))
  63. {
  64. client.Connect();
  65. client.Disconnect();
  66. }
  67. }
  68. }
  69. }