CipherInfo.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Renci.SshNet.Security.Cryptography;
  6. namespace Renci.SshNet
  7. {
  8. /// <summary>
  9. /// Holds information about key size and cipher to use
  10. /// </summary>
  11. public class CipherInfo
  12. {
  13. /// <summary>
  14. /// Gets the size of the key.
  15. /// </summary>
  16. /// <value>
  17. /// The size of the key.
  18. /// </value>
  19. public int KeySize { get; private set; }
  20. /// <summary>
  21. /// Gets the cipher.
  22. /// </summary>
  23. public Func<byte[], byte[], BlockCipher> Cipher { get; private set; }
  24. /// <summary>
  25. /// Initializes a new instance of the <see cref="CipherInfo"/> class.
  26. /// </summary>
  27. /// <param name="keySize">Size of the key.</param>
  28. /// <param name="cipher">The cipher.</param>
  29. public CipherInfo(int keySize, Func<byte[], byte[], BlockCipher> cipher)
  30. {
  31. this.KeySize = keySize;
  32. this.Cipher = (key, iv) => (cipher(key.Take(this.KeySize / 8).ToArray(), iv));
  33. }
  34. }
  35. }