OtherRecipientInfo.cs 2.6 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. [Obsolete("Use GetInstance() instead")]
  19. public OtherRecipientInfo(
  20. Asn1Sequence seq)
  21. {
  22. oriType = DerObjectIdentifier.GetInstance(seq[0]);
  23. oriValue = seq[1];
  24. }
  25. /**
  26. * return a OtherRecipientInfo object from a tagged object.
  27. *
  28. * @param obj the tagged object holding the object we want.
  29. * @param explicitly true if the object is meant to be explicitly
  30. * tagged false otherwise.
  31. * @exception ArgumentException if the object held by the
  32. * tagged object cannot be converted.
  33. */
  34. public static OtherRecipientInfo GetInstance(
  35. Asn1TaggedObject obj,
  36. bool explicitly)
  37. {
  38. return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
  39. }
  40. /**
  41. * return a OtherRecipientInfo object from the given object.
  42. *
  43. * @param obj the object we want converted.
  44. * @exception ArgumentException if the object cannot be converted.
  45. */
  46. public static OtherRecipientInfo GetInstance(
  47. object obj)
  48. {
  49. if (obj == null)
  50. return null;
  51. OtherRecipientInfo existing = obj as OtherRecipientInfo;
  52. if (existing != null)
  53. return existing;
  54. return new OtherRecipientInfo(Asn1Sequence.GetInstance(obj));
  55. }
  56. public virtual DerObjectIdentifier OriType
  57. {
  58. get { return oriType; }
  59. }
  60. public virtual Asn1Encodable OriValue
  61. {
  62. get { return oriValue; }
  63. }
  64. /**
  65. * Produce an object suitable for an Asn1OutputStream.
  66. * <pre>
  67. * OtherRecipientInfo ::= Sequence {
  68. * oriType OBJECT IDENTIFIER,
  69. * oriValue ANY DEFINED BY oriType }
  70. * </pre>
  71. */
  72. public override Asn1Object ToAsn1Object()
  73. {
  74. return new DerSequence(oriType, oriValue);
  75. }
  76. }
  77. }
  78. #pragma warning restore
  79. #endif