DHValidationParms.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 DHValidationParms
  8. : Asn1Encodable
  9. {
  10. private readonly DerBitString seed;
  11. private readonly DerInteger pgenCounter;
  12. public static DHValidationParms GetInstance(Asn1TaggedObject obj, bool isExplicit)
  13. {
  14. return GetInstance(Asn1Sequence.GetInstance(obj, isExplicit));
  15. }
  16. public static DHValidationParms GetInstance(object obj)
  17. {
  18. if (obj == null || obj is DHValidationParms)
  19. return (DHValidationParms)obj;
  20. if (obj is Asn1Sequence)
  21. return new DHValidationParms((Asn1Sequence)obj);
  22. throw new ArgumentException("Invalid DHValidationParms: " + BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj");
  23. }
  24. public DHValidationParms(DerBitString seed, DerInteger pgenCounter)
  25. {
  26. if (seed == null)
  27. throw new ArgumentNullException("seed");
  28. if (pgenCounter == null)
  29. throw new ArgumentNullException("pgenCounter");
  30. this.seed = seed;
  31. this.pgenCounter = pgenCounter;
  32. }
  33. private DHValidationParms(Asn1Sequence seq)
  34. {
  35. if (seq.Count != 2)
  36. throw new ArgumentException("Bad sequence size: " + seq.Count, "seq");
  37. this.seed = DerBitString.GetInstance(seq[0]);
  38. this.pgenCounter = DerInteger.GetInstance(seq[1]);
  39. }
  40. public DerBitString Seed
  41. {
  42. get { return this.seed; }
  43. }
  44. public DerInteger PgenCounter
  45. {
  46. get { return this.pgenCounter; }
  47. }
  48. public override Asn1Object ToAsn1Object()
  49. {
  50. return new DerSequence(seed, pgenCounter);
  51. }
  52. }
  53. }
  54. #pragma warning restore
  55. #endif