summary refs log tree commit diff
path: root/crypto/src/cms/CMSProcessableByteArray.cs
blob: c0dd661f21df2a4d9e2ca922e00a7dbba20781b4 (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
using System;
using System.IO;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Asn1.Cms;

namespace Org.BouncyCastle.Cms
{
	/**
	* a holding class for a byte array of data to be processed.
	*/
	public class CmsProcessableByteArray
		: CmsProcessable, CmsReadable
	{
	    private readonly DerObjectIdentifier type;
		private readonly byte[] bytes;

        public CmsProcessableByteArray(byte[] bytes)
        {
            type = CmsObjectIdentifiers.Data;
			this.bytes = bytes;
		}

	    public CmsProcessableByteArray(DerObjectIdentifier type, byte[] bytes)
	    {
	        this.bytes = bytes;
	        this.type = type;
	    }

	    public DerObjectIdentifier Type
	    {
	        get { return type; }
	    }

        public virtual Stream GetInputStream()
		{
			return new MemoryStream(bytes, false);
		}

        public virtual void Write(Stream zOut)
		{
			zOut.Write(bytes, 0, bytes.Length);
		}
	}
}