DHPublicKey.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
  5. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X9
  6. {
  7. public class DHPublicKey
  8. : Asn1Encodable
  9. {
  10. private readonly DerInteger y;
  11. public static DHPublicKey GetInstance(Asn1TaggedObject obj, bool isExplicit)
  12. {
  13. return GetInstance(DerInteger.GetInstance(obj, isExplicit));
  14. }
  15. public static DHPublicKey GetInstance(object obj)
  16. {
  17. if (obj == null || obj is DHPublicKey)
  18. return (DHPublicKey)obj;
  19. if (obj is DerInteger)
  20. return new DHPublicKey((DerInteger)obj);
  21. throw new ArgumentException("Invalid DHPublicKey: " + BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj");
  22. }
  23. public DHPublicKey(DerInteger y)
  24. {
  25. if (y == null)
  26. throw new ArgumentNullException("y");
  27. this.y = y;
  28. }
  29. public DerInteger Y
  30. {
  31. get { return this.y; }
  32. }
  33. public override Asn1Object ToAsn1Object()
  34. {
  35. return this.y;
  36. }
  37. }
  38. }
  39. #pragma warning restore
  40. #endif