DHKeyParameters.cs 1.8 KB

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