PrimitiveEncodingSuffixed.cs 1.3 KB

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