|
Bouncy Castle Cryptography Library 1.85 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.bouncycastle.openpgp.PGPCompressedData
A PGP compressed data object.
| Field Summary |
| Fields inherited from interface org.bouncycastle.bcpg.CompressionAlgorithmTags |
BZIP2, UNCOMPRESSED, ZIP, ZLIB |
| Constructor Summary | |
PGPCompressedData(BCPGInputStream pIn)
Construct a compressed data object, reading a single PacketTags.COMPRESSED_DATA
packet from the stream. |
|
PGPCompressedData(byte[] encData)
Construct a PGP compressed data object from the passed in byte array. |
|
PGPCompressedData(java.io.InputStream inStream)
Construct a PGP compressed data object from the passed in input stream. |
|
| Method Summary | |
int |
getAlgorithm()
Return the compression algorithm used for this packet. |
java.io.InputStream |
getDataStream()
Return an input stream that decompresses and returns data in the compressed packet. |
java.io.InputStream |
getDataStream(long limit)
Return an input stream that decompresses and returns data in the compressed packet, failing with a StreamOverflowException (an IOException) once more than
decompressed bytes have been read. |
java.io.InputStream |
getInputStream()
Return the raw input stream contained in the object. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public PGPCompressedData(byte[] encData)
throws java.io.IOException
encData - an encoding of PGP compressed data.
java.io.IOException - if an error occurs reading from the PGP input.
public PGPCompressedData(java.io.InputStream inStream)
throws java.io.IOException
inStream - an input stream containing an encoding of PGP compressed data.
java.io.IOException - if an error occurs reading from the PGP input.
public PGPCompressedData(BCPGInputStream pIn)
throws java.io.IOException
PacketTags.COMPRESSED_DATA
packet from the stream.
pIn - a PGP input stream, with a compressed data packet as the current packet.
java.io.IOException - if an error occurs reading the packet from the stream.| Method Detail |
public int getAlgorithm()
compression algorithm used for this packet.
public java.io.InputStream getInputStream()
Note that this stream is shared with the decompression stream, so consuming the returned stream will affect decompression.
public java.io.InputStream getDataStream()
throws PGPException
The OpenPGP compressed data packet carries no decompressed-length field, so the returned
stream is unbounded: a small compressed packet can expand into an arbitrarily large amount
of data (a "decompression bomb"). When processing untrusted input, a caller that buffers
the full decompressed output should bound it — by reading incrementally, or by using
getDataStream(long) to cap the number of decompressed bytes.
PGPException - if an error occurs constructing the decompression stream.
public java.io.InputStream getDataStream(long limit)
throws PGPException
StreamOverflowException (an IOException) once more than
decompressed bytes have been read. This caps the "decompression bomb"
amplification of an untrusted compressed packet for callers that buffer the decompressed
output.
The limit applies to the decompressed byte count. For BZIP2 the underlying decompressor still allocates its fixed working buffers — sized by the packet's block-size header, up to ~4.5MB — when the stream is constructed, independently of this limit.
limit - the maximum number of decompressed bytes that may be read, or a negative
value for no limit (equivalent to getDataStream()).
PGPException - if an error occurs constructing the decompression stream.
|
Bouncy Castle Cryptography Library 1.85 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||