DerOctetString.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1
  5. {
  6. public class DerOctetString
  7. : Asn1OctetString
  8. {
  9. /// <param name="str">The octets making up the octet string.</param>
  10. public DerOctetString(
  11. byte[] str)
  12. : base(str)
  13. {
  14. }
  15. public DerOctetString(IAsn1Convertible obj)
  16. : this(obj.ToAsn1Object())
  17. {
  18. }
  19. public DerOctetString(Asn1Encodable obj)
  20. : base(obj.GetEncoded(Der))
  21. {
  22. }
  23. internal override int EncodedLength(bool withID)
  24. {
  25. return Asn1OutputStream.GetLengthOfEncodingDL(withID, str.Length);
  26. }
  27. internal override void Encode(Asn1OutputStream asn1Out, bool withID)
  28. {
  29. asn1Out.WriteEncodingDL(withID, Asn1Tags.OctetString, str);
  30. }
  31. internal static void Encode(Asn1OutputStream asn1Out, bool withID, byte[] buf, int off, int len)
  32. {
  33. asn1Out.WriteEncodingDL(withID, Asn1Tags.OctetString, buf, off, len);
  34. }
  35. internal static int EncodedLength(bool withID, int contentsLength)
  36. {
  37. return Asn1OutputStream.GetLengthOfEncodingDL(withID, contentsLength);
  38. }
  39. }
  40. }
  41. #pragma warning restore
  42. #endif