DHKeyParameters.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. using System;
  3. using Org.BouncyCastle.Asn1;
  4. using Org.BouncyCastle.Asn1.Pkcs;
  5. using Org.BouncyCastle.Utilities;
  6. namespace Org.BouncyCastle.Crypto.Parameters
  7. {
  8. public class DHKeyParameters
  9. : AsymmetricKeyParameter
  10. {
  11. private readonly DHParameters parameters;
  12. private readonly DerObjectIdentifier algorithmOid;
  13. protected DHKeyParameters(
  14. bool isPrivate,
  15. DHParameters parameters)
  16. : this(isPrivate, parameters, PkcsObjectIdentifiers.DhKeyAgreement)
  17. {
  18. }
  19. protected DHKeyParameters(
  20. bool isPrivate,
  21. DHParameters parameters,
  22. DerObjectIdentifier algorithmOid)
  23. : base(isPrivate)
  24. {
  25. // TODO Should we allow parameters to be null?
  26. this.parameters = parameters;
  27. this.algorithmOid = algorithmOid;
  28. }
  29. public DHParameters Parameters
  30. {
  31. get { return parameters; }
  32. }
  33. public DerObjectIdentifier AlgorithmOid
  34. {
  35. get { return algorithmOid; }
  36. }
  37. public override bool Equals(
  38. object obj)
  39. {
  40. if (obj == this)
  41. return true;
  42. DHKeyParameters other = obj as DHKeyParameters;
  43. if (other == null)
  44. return false;
  45. return Equals(other);
  46. }
  47. protected bool Equals(
  48. DHKeyParameters other)
  49. {
  50. return Org.BouncyCastle.Utilities.Platform.Equals(parameters, other.parameters)
  51. && base.Equals(other);
  52. }
  53. public override int GetHashCode()
  54. {
  55. int hc = base.GetHashCode();
  56. if (parameters != null)
  57. {
  58. hc ^= parameters.GetHashCode();
  59. }
  60. return hc;
  61. }
  62. }
  63. }
  64. #endif