public byte[] GetContent() { CompressedData comData = CompressedData.GetInstance(contentInfo.Content); ContentInfo content = comData.EncapContentInfo; Asn1OctetString bytes = (Asn1OctetString)content.Content; //InflaterInputStream zIn = new InflaterInputStream(new MemoryStream(bytes.GetOctets(), false)); MemoryStream bOut = new MemoryStream(); byte[] buf = new byte[1024]; //int len; try { //while ((len = zIn.Read(buf, 0, buf.Length)) > 0) //{ // bOut.Write(buf, 0, len); //} } catch (IOException e) { throw new CmsException("exception reading compressed stream.", e); } return(bOut.ToArray()); }
public byte[] GetContent(int limit) { CompressedData instance = CompressedData.GetInstance(contentInfo.Content); ContentInfo encapContentInfo = instance.EncapContentInfo; Asn1OctetString asn1OctetString = (Asn1OctetString)encapContentInfo.Content; ZInputStream inStream = new ZInputStream(new MemoryStream(asn1OctetString.GetOctets(), writable: false)); try { return(CmsUtilities.StreamToByteArray(inStream, limit)); } catch (IOException e) { throw new CmsException("exception reading compressed stream.", e); } }
/** * Return the uncompressed content, throwing an exception if the data size * is greater than the passed in limit. If the content is exceeded getCause() * on the CMSException will contain a StreamOverflowException * * @param limit maximum number of bytes to read * @return the content read * @throws CMSException if there is an exception uncompressing the data. */ public byte[] GetContent(int limit) { CompressedData comData = CompressedData.GetInstance(contentInfo.Content); ContentInfo content = comData.EncapContentInfo; Asn1OctetString bytes = (Asn1OctetString)content.Content; ZInflaterInputStream zIn = new ZInflaterInputStream(new MemoryStream(bytes.GetOctets(), false)); try { return(CmsUtilities.StreamToByteArray(zIn, limit)); } catch (IOException e) { throw new CmsException("exception reading compressed stream.", e); } }
/** * Return the uncompressed content. * * @return the uncompressed content * @throws CmsException if there is an exception uncompressing the data. */ public byte[] GetContent() { CompressedData comData = CompressedData.GetInstance(ContentInfoInternal.Content); ContentInfo content = comData.EncapContentInfo; var bytes = (Asn1OctetString)content.Content; using (var zIn = new ZInputStream(bytes.GetOctetStream())) { try { return(CmsUtilities.StreamToByteArray(zIn)); } catch (IOException e) { throw new CmsException("exception reading compressed stream.", e); } } }
public byte[] GetContent(int limit) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0043: Expected O, but got Unknown CompressedData instance = CompressedData.GetInstance(contentInfo.Content); ContentInfo encapContentInfo = instance.EncapContentInfo; Asn1OctetString asn1OctetString = (Asn1OctetString)encapContentInfo.Content; ZInputStream inStream = new ZInputStream((Stream) new MemoryStream(asn1OctetString.GetOctets(), false)); try { return(CmsUtilities.StreamToByteArray((Stream)(object)inStream, limit)); } catch (IOException val) { IOException e = val; throw new CmsException("exception reading compressed stream.", (global::System.Exception)(object) e); } }
public byte[] GetContent() { CompressedData instance = CompressedData.GetInstance(contentInfo.Content); ContentInfo encapContentInfo = instance.EncapContentInfo; Asn1OctetString asn1OctetString = (Asn1OctetString)encapContentInfo.Content; ZInputStream zInputStream = new ZInputStream(asn1OctetString.GetOctetStream()); try { return(CmsUtilities.StreamToByteArray(zInputStream)); } catch (IOException e) { throw new CmsException("exception reading compressed stream.", e); } finally { Platform.Dispose(zInputStream); } }
/** * Return the uncompressed content. * * @return the uncompressed content * @throws CmsException if there is an exception uncompressing the data. */ public byte[] GetContent() { CompressedData comData = CompressedData.GetInstance(contentInfo.Content); ContentInfo content = comData.EncapContentInfo; Asn1OctetString bytes = (Asn1OctetString)content.Content; ZInflaterInputStream zIn = new ZInflaterInputStream(bytes.GetOctetStream()); try { return(CmsUtilities.StreamToByteArray(zIn)); } catch (IOException e) { throw new CmsException("exception reading compressed stream.", e); } finally { zIn.Close(); } }
/** * Return the uncompressed content. * * @return the uncompressed content * @throws CmsException if there is an exception uncompressing the data. */ public byte[] GetContent() { CompressedData comData = CompressedData.GetInstance(contentInfo.Content); ContentInfo content = comData.EncapContentInfo; Asn1OctetString bytes = (Asn1OctetString)content.Content; ZInputStream zIn = new ZInputStream(bytes.GetOctetStream()); try { return(CmsUtilities.StreamToByteArray(zIn)); } catch (IOException e) { throw new CmsException("exception reading compressed stream.", e); } finally { BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.Dispose(zIn); } }
public byte[] GetContent() { //IL_003c: Expected O, but got Unknown CompressedData instance = CompressedData.GetInstance(contentInfo.Content); ContentInfo encapContentInfo = instance.EncapContentInfo; Asn1OctetString asn1OctetString = (Asn1OctetString)encapContentInfo.Content; ZInputStream zInputStream = new ZInputStream(asn1OctetString.GetOctetStream()); try { return(CmsUtilities.StreamToByteArray((Stream)(object)zInputStream)); } catch (IOException val) { IOException e = val; throw new CmsException("exception reading compressed stream.", (global::System.Exception)(object) e); } finally { Platform.Dispose((Stream)(object)zInputStream); } }
private ITestResult CompressionTest() { try { ContentInfo info = ContentInfo.GetInstance( Asn1Object.FromByteArray(compData)); CompressedData data = CompressedData.GetInstance(info.Content); data = new CompressedData(data.CompressionAlgorithmIdentifier, data.EncapContentInfo); info = new ContentInfo(CmsObjectIdentifiers.CompressedData, data); if (!Arrays.AreEqual(info.GetEncoded(), compData)) { return(new SimpleTestResult(false, Name + ": CMS compression failed to re-encode")); } return(new SimpleTestResult(true, Name + ": Okay")); } catch (Exception e) { return(new SimpleTestResult(false, Name + ": CMS compression failed - " + e.ToString(), e)); } }