summary refs log tree commit diff
path: root/crypto/src/asn1/DerOutputStream.cs
blob: b8cbe9ee2e23f1045fb234ff292bb534e7f51951 (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
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.IO;

using Org.BouncyCastle.Utilities.IO;

namespace Org.BouncyCastle.Asn1
{
    [Obsolete("Use 'Asn1OutputStream' instead")]
    public class DerOutputStream
        : FilterStream
    {
        [Obsolete("Use 'Asn1OutputStream.Create' instead")]
        public DerOutputStream(Stream os)
            : base(os)
        {
        }

        public virtual void WriteObject(Asn1Encodable encodable)
        {
            Asn1OutputStream.Create(s, Asn1Encodable.Der).WriteObject(encodable);
        }

        public virtual void WriteObject(Asn1Object primitive)
        {
            Asn1OutputStream.Create(s, Asn1Encodable.Der).WriteObject(primitive);
        }
	}

    internal class DerOutputStreamNew
        : Asn1OutputStream
    {
        internal DerOutputStreamNew(Stream os)
            : base(os)
        {
        }

        internal override bool IsBer
        {
            get { return false; }
        }

        internal override void WritePrimitive(Asn1Object primitive, bool withID)
        {
            Asn1Set asn1Set = primitive as Asn1Set;
            if (null != asn1Set)
            {
                /*
                 * NOTE: Even a DerSet isn't necessarily already in sorted order (particularly from DerSetParser),
                 * so all sets have to be converted here.
                 */
                primitive = new DerSet(asn1Set.elements);
            }

            primitive.Encode(this, withID);
        }
    }
}