OtherRecipientInfo.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms
  5. {
  6. public class OtherRecipientInfo
  7. : Asn1Encodable
  8. {
  9. private readonly DerObjectIdentifier oriType;
  10. private readonly Asn1Encodable oriValue;
  11. public OtherRecipientInfo(
  12. DerObjectIdentifier oriType,
  13. Asn1Encodable oriValue)
  14. {
  15. this.oriType = oriType;
  16. this.oriValue = oriValue;
  17. }
  18. public OtherRecipientInfo(
  19. Asn1Sequence seq)
  20. {
  21. oriType = DerObjectIdentifier.GetInstance(seq[0]);
  22. oriValue = seq[1];
  23. }
  24. /**
  25. * return a OtherRecipientInfo object from a tagged object.
  26. *
  27. * @param obj the tagged object holding the object we want.
  28. * @param explicitly true if the object is meant to be explicitly
  29. * tagged false otherwise.
  30. * @exception ArgumentException if the object held by the
  31. * tagged object cannot be converted.
  32. */
  33. public static OtherRecipientInfo GetInstance(
  34. Asn1TaggedObject obj,
  35. bool explicitly)
  36. {
  37. return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
  38. }
  39. /**
  40. * return a OtherRecipientInfo object from the given object.
  41. *
  42. * @param obj the object we want converted.
  43. * @exception ArgumentException if the object cannot be converted.
  44. */
  45. public static OtherRecipientInfo GetInstance(
  46. object obj)
  47. {
  48. if (obj == null)
  49. return null;
  50. OtherRecipientInfo existing = obj as OtherRecipientInfo;
  51. if (existing != null)
  52. return existing;
  53. return new OtherRecipientInfo(Asn1Sequence.GetInstance(obj));
  54. }
  55. public virtual DerObjectIdentifier OriType
  56. {
  57. get { return oriType; }
  58. }
  59. public virtual Asn1Encodable OriValue
  60. {
  61. get { return oriValue; }
  62. }
  63. /**
  64. * Produce an object suitable for an Asn1OutputStream.
  65. * <pre>
  66. * OtherRecipientInfo ::= Sequence {
  67. * oriType OBJECT IDENTIFIER,
  68. * oriValue ANY DEFINED BY oriType }
  69. * </pre>
  70. */
  71. public override Asn1Object ToAsn1Object()
  72. {
  73. return new DerSequence(oriType, oriValue);
  74. }
  75. }
  76. }
  77. #pragma warning restore
  78. #endif