KeyExchangeECDH256.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using Org.BouncyCastle.Asn1.Sec;
  2. using Org.BouncyCastle.Asn1.X9;
  3. using Renci.SshNet.Abstractions;
  4. namespace Renci.SshNet.Security
  5. {
  6. internal sealed class KeyExchangeECDH256 : KeyExchangeECDH
  7. {
  8. /// <summary>
  9. /// Gets algorithm name.
  10. /// </summary>
  11. public override string Name
  12. {
  13. get { return "ecdh-sha2-nistp256"; }
  14. }
  15. #if NET8_0_OR_GREATER
  16. /// <summary>
  17. /// Gets the curve.
  18. /// </summary>
  19. protected override System.Security.Cryptography.ECCurve Curve
  20. {
  21. get
  22. {
  23. return System.Security.Cryptography.ECCurve.NamedCurves.nistP256;
  24. }
  25. }
  26. #endif
  27. /// <summary>
  28. /// Gets Curve Parameter.
  29. /// </summary>
  30. protected override X9ECParameters CurveParameter
  31. {
  32. get
  33. {
  34. return SecNamedCurves.GetByOid(SecObjectIdentifiers.SecP256r1);
  35. }
  36. }
  37. /// <summary>
  38. /// Gets the size, in bits, of the computed hash code.
  39. /// </summary>
  40. /// <value>
  41. /// The size, in bits, of the computed hash code.
  42. /// </value>
  43. protected override int HashSize
  44. {
  45. get { return 256; }
  46. }
  47. /// <summary>
  48. /// Hashes the specified data bytes.
  49. /// </summary>
  50. /// <param name="hashData">The hash data.</param>
  51. /// <returns>
  52. /// The hash of the data.
  53. /// </returns>
  54. protected override byte[] Hash(byte[] hashData)
  55. {
  56. return CryptoAbstraction.HashSHA256(hashData);
  57. }
  58. }
  59. }