<PackageReference Include="BouncyCastle.Cryptography" Version="2.6.0" />

CmsProcessableByteArray

using Org.BouncyCastle.Asn1; using Org.BouncyCastle.Asn1.Cms; using Org.BouncyCastle.Utilities; using System.IO; namespace Org.BouncyCastle.Cms { public class CmsProcessableByteArray : CmsProcessable, CmsReadable { private readonly DerObjectIdentifier type; private readonly byte[] bytes; public DerObjectIdentifier Type => type; public CmsProcessableByteArray(byte[] bytes) { type = CmsObjectIdentifiers.Data; this.bytes = bytes; } public CmsProcessableByteArray(DerObjectIdentifier type, byte[] bytes) { this.bytes = bytes; this.type = type; } public byte[] GetByteArray() { return Arrays.Clone(bytes); } public virtual Stream GetInputStream() { return new MemoryStream(bytes, false); } public virtual void Write(Stream zOut) { zOut.Write(bytes, 0, bytes.Length); } } }