Class OpenPGPMessageInputStream
- All Implemented Interfaces:
Closeable, AutoCloseable
InputStream that processes an OpenPGP message.
Its contents are the plaintext from the messages LiteralData packet.
You can get information about the message (signatures, encryption method, message metadata)
by reading ALL data from the stream, closing it with close() and then retrieving a OpenPGPMessageInputStream.Result object
by calling getResult().
Unauthenticated plaintext note: data read from this stream has not yet been checked for integrity.
Decryption is performed as the stream is read, and the integrity of the message is only established once
close() has returned without throwing. For a version 1 Symmetrically Encrypted and Integrity Protected
Data packet, the Modification Detection Code covers the whole message and is verified at the end of the data,
so every plaintext byte is emitted before the check runs; a tampered message is reported by an
IOException from the final read() or from close(), after the plaintext has already
been handed over. A caller should therefore treat everything read from this stream as unverified, and should not
act on it, pass it on or parse it further until close() has completed normally. RFC 9580 sec. 13.7
discusses what releasing decrypted data before confirming its integrity can leak.
A version 2 packet is not affected in the same way: it is encrypted with an AEAD algorithm in chunks, and each
chunk's authentication tag is verified before that chunk's plaintext is emitted, so the unverified window is
bounded by one chunk. Signature verification is separate from either and is only complete once
close() has returned and getResult() has been consulted.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Methods inherited from class InputStream
available, mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Field Details
-
MAX_RECURSION
public static int MAX_RECURSION
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
getResult
-