ConstructedLazyDLEncoding.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  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
  5. {
  6. internal class ConstructedLazyDLEncoding
  7. : IAsn1Encoding
  8. {
  9. private readonly int m_tagClass;
  10. private readonly int m_tagNo;
  11. private readonly byte[] m_contentsOctets;
  12. internal ConstructedLazyDLEncoding(int tagClass, int tagNo, byte[] contentsOctets)
  13. {
  14. m_tagClass = tagClass;
  15. m_tagNo = tagNo;
  16. m_contentsOctets = contentsOctets;
  17. }
  18. void IAsn1Encoding.Encode(Asn1OutputStream asn1Out)
  19. {
  20. asn1Out.WriteIdentifier(Asn1Tags.Constructed | m_tagClass, m_tagNo);
  21. asn1Out.WriteDL(m_contentsOctets.Length);
  22. asn1Out.Write(m_contentsOctets, 0, m_contentsOctets.Length);
  23. }
  24. int IAsn1Encoding.GetLength()
  25. {
  26. return Asn1OutputStream.GetLengthOfIdentifier(m_tagNo)
  27. + Asn1OutputStream.GetLengthOfDL(m_contentsOctets.Length)
  28. + m_contentsOctets.Length;
  29. }
  30. }
  31. }
  32. #pragma warning restore
  33. #endif