summary refs log tree commit diff
path: root/crypto/src/cms/CMSProcessableByteArray.cs
blob: b09935dd8fd37f04dd687885e8ee2670b0eb5f50 (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
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);
		}

        /// <returns>A clone of the byte array</returns>
        [Obsolete]
		public virtual object GetContent()
		{
			return bytes.Clone();
		}
	}
}