DHPublicKey.cs 974 B

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