Class TeeBCPGInputStream

java.lang.Object
org.pgpainless.decryption_verification.TeeBCPGInputStream

public class TeeBCPGInputStream extends Object
Since we need to update signatures with data from the underlying stream, this class is used to tee out the data. Unfortunately we cannot simply override BCPGInputStream.read() to tee the data out though, since BCPGInputStream.readPacket() inconsistently calls a mix of BCPGInputStream.read() and InputStream.read() of the underlying stream. This would cause the second length byte to get swallowed up. Therefore, this class delegates the teeing to an TeeBCPGInputStream.DelayedTeeInputStream which wraps the underlying stream. Since calling BCPGInputStream.nextPacketTag() reads up to and including the next packets tag, we need to delay teeing out that byte to signature verifiers. Hence, the reading methods of the TeeBCPGInputStream handle pushing this byte to the output stream using TeeBCPGInputStream.DelayedTeeInputStream.squeeze().
  • Field Details

  • Constructor Details

    • TeeBCPGInputStream

      public TeeBCPGInputStream(org.bouncycastle.bcpg.BCPGInputStream inputStream, OutputStream outputStream)
  • Method Details

    • nextPacketTag

      public OpenPgpPacket nextPacketTag() throws IOException
      Throws:
      IOException
    • readPacket

      public org.bouncycastle.bcpg.Packet readPacket() throws IOException
      Throws:
      IOException
    • readCompressedData

      public org.bouncycastle.openpgp.PGPCompressedData readCompressedData() throws IOException
      Throws:
      IOException
    • readLiteralData

      public org.bouncycastle.openpgp.PGPLiteralData readLiteralData() throws IOException
      Throws:
      IOException
    • readEncryptedDataList

      public org.bouncycastle.openpgp.PGPEncryptedDataList readEncryptedDataList() throws IOException
      Throws:
      IOException
    • readOnePassSignature

      public org.bouncycastle.openpgp.PGPOnePassSignature readOnePassSignature() throws org.bouncycastle.openpgp.PGPException, IOException
      Throws:
      org.bouncycastle.openpgp.PGPException
      IOException
    • readSignature

      public org.bouncycastle.openpgp.PGPSignature readSignature() throws org.bouncycastle.openpgp.PGPException, IOException
      Throws:
      org.bouncycastle.openpgp.PGPException
      IOException
    • readMarker

      public org.bouncycastle.bcpg.MarkerPacket readMarker() throws IOException
      Throws:
      IOException
    • close

      public void close() throws IOException
      Throws:
      IOException