ContentInfoParser.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms
  5. {
  6. /**
  7. * Produce an object suitable for an Asn1OutputStream.
  8. * <pre>
  9. * ContentInfo ::= SEQUENCE {
  10. * contentType ContentType,
  11. * content
  12. * [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL }
  13. * </pre>
  14. */
  15. public class ContentInfoParser
  16. {
  17. private readonly DerObjectIdentifier m_contentType;
  18. private readonly Asn1TaggedObjectParser m_content;
  19. public ContentInfoParser(Asn1SequenceParser seq)
  20. {
  21. m_contentType = (DerObjectIdentifier)seq.ReadObject();
  22. m_content = (Asn1TaggedObjectParser)seq.ReadObject();
  23. }
  24. public DerObjectIdentifier ContentType
  25. {
  26. get { return m_contentType; }
  27. }
  28. public IAsn1Convertible GetContent(int tag)
  29. {
  30. if (null == m_content)
  31. return null;
  32. // TODO[cms] Ideally we could enforce the claimed tag
  33. //return Asn1Utilities.ParseContextBaseUniversal(content, 0, true, tag);
  34. return Asn1Utilities.ParseExplicitContextBaseObject(m_content, 0);
  35. }
  36. }
  37. }
  38. #pragma warning restore
  39. #endif