summary refs log tree commit diff
path: root/crypto/src/asn1/DerOctetString.cs
blob: bcd4e733338266698c1243e5dee5191e5dbcca37 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;

namespace Org.BouncyCastle.Asn1
{
    public class DerOctetString
        : Asn1OctetString
    {
		/// <param name="str">The octets making up the octet string.</param>
        public DerOctetString(
			byte[] str)
			: base(str)
        {
        }

        public DerOctetString(IAsn1Convertible obj)
            : this(obj.ToAsn1Object())
        {
        }

        public DerOctetString(Asn1Encodable obj)
            : base(obj.GetEncoded(Der))
        {
        }

        internal override int EncodedLength(bool withID)
        {
            return Asn1OutputStream.GetLengthOfEncodingDL(withID, str.Length);
        }

        internal override void Encode(Asn1OutputStream asn1Out, bool withID)
        {
            asn1Out.WriteEncodingDL(withID, Asn1Tags.OctetString, str);
        }

		internal static void Encode(Asn1OutputStream asn1Out, bool withID, byte[] buf, int off, int len)
		{
			asn1Out.WriteEncodingDL(withID, Asn1Tags.OctetString, buf, off, len);
		}

        internal static int EncodedLength(bool withID, int contentsLength)
        {
            return Asn1OutputStream.GetLengthOfEncodingDL(withID, contentsLength);
        }
    }
}