HashInfo.cs 1.0 KB

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