OtherInfo.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System.Collections;
  4. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X9
  5. {
  6. /**
  7. * ANS.1 def for Diffie-Hellman key exchange OtherInfo structure. See
  8. * RFC 2631, or X9.42, for further details.
  9. */
  10. public class OtherInfo
  11. : Asn1Encodable
  12. {
  13. private KeySpecificInfo keyInfo;
  14. private Asn1OctetString partyAInfo;
  15. private Asn1OctetString suppPubInfo;
  16. public OtherInfo(
  17. KeySpecificInfo keyInfo,
  18. Asn1OctetString partyAInfo,
  19. Asn1OctetString suppPubInfo)
  20. {
  21. this.keyInfo = keyInfo;
  22. this.partyAInfo = partyAInfo;
  23. this.suppPubInfo = suppPubInfo;
  24. }
  25. public OtherInfo(
  26. Asn1Sequence seq)
  27. {
  28. IEnumerator e = seq.GetEnumerator();
  29. e.MoveNext();
  30. keyInfo = new KeySpecificInfo((Asn1Sequence) e.Current);
  31. while (e.MoveNext())
  32. {
  33. DerTaggedObject o = (DerTaggedObject) e.Current;
  34. if (o.TagNo == 0)
  35. {
  36. partyAInfo = (Asn1OctetString) o.GetObject();
  37. }
  38. else if ((int) o.TagNo == 2)
  39. {
  40. suppPubInfo = (Asn1OctetString) o.GetObject();
  41. }
  42. }
  43. }
  44. public KeySpecificInfo KeyInfo
  45. {
  46. get { return keyInfo; }
  47. }
  48. public Asn1OctetString PartyAInfo
  49. {
  50. get { return partyAInfo; }
  51. }
  52. public Asn1OctetString SuppPubInfo
  53. {
  54. get { return suppPubInfo; }
  55. }
  56. /**
  57. * Produce an object suitable for an Asn1OutputStream.
  58. * <pre>
  59. * OtherInfo ::= Sequence {
  60. * keyInfo KeySpecificInfo,
  61. * partyAInfo [0] OCTET STRING OPTIONAL,
  62. * suppPubInfo [2] OCTET STRING
  63. * }
  64. * </pre>
  65. */
  66. public override Asn1Object ToAsn1Object()
  67. {
  68. Asn1EncodableVector v = new Asn1EncodableVector(keyInfo);
  69. v.AddOptionalTagged(true, 0, partyAInfo);
  70. v.Add(new DerTaggedObject(2, suppPubInfo));
  71. return new DerSequence(v);
  72. }
  73. }
  74. }
  75. #pragma warning restore
  76. #endif