ElGamalParameter.cs 992 B

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