ElGamalParameter.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using System.Collections;
  5. using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
  6. using BestHTTP.SecureProtocol.Org.BouncyCastle.Math;
  7. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Oiw
  8. {
  9. public class ElGamalParameter
  10. : Asn1Encodable
  11. {
  12. internal DerInteger p, g;
  13. public ElGamalParameter(
  14. BigInteger p,
  15. BigInteger g)
  16. {
  17. this.p = new DerInteger(p);
  18. this.g = new DerInteger(g);
  19. }
  20. public ElGamalParameter(
  21. Asn1Sequence seq)
  22. {
  23. if (seq.Count != 2)
  24. throw new ArgumentException("Wrong number of elements in sequence", "seq");
  25. p = DerInteger.GetInstance(seq[0]);
  26. g = DerInteger.GetInstance(seq[1]);
  27. }
  28. public BigInteger P
  29. {
  30. get { return p.PositiveValue; }
  31. }
  32. public BigInteger G
  33. {
  34. get { return g.PositiveValue; }
  35. }
  36. public override Asn1Object ToAsn1Object()
  37. {
  38. return new DerSequence(p, g);
  39. }
  40. }
  41. }
  42. #pragma warning restore
  43. #endif