Package org.pgpainless.decryption_verification

# 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()`.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`TeeBCPGInputStream.DelayedTeeInputStream`

## Field Summary

Fields
Modifier and Type
Field
Description
`protected final TeeBCPGInputStream.DelayedTeeInputStream`
`delayedTee`
`protected final org.bouncycastle.bcpg.BCPGInputStream`
`packetInputStream`

## Constructor Summary

Constructors
Constructor
Description
`TeeBCPGInputStream(org.bouncycastle.bcpg.BCPGInputStream inputStream, OutputStream outputStream)`

## Method Summary

Modifier and Type
Method
Description
`void`
`close()`
`OpenPgpPacket`
`nextPacketTag()`
`org.bouncycastle.openpgp.PGPCompressedData`
`readCompressedData()`
`org.bouncycastle.openpgp.PGPEncryptedDataList`
`readEncryptedDataList()`
`org.bouncycastle.openpgp.PGPLiteralData`
`readLiteralData()`
`org.bouncycastle.bcpg.MarkerPacket`
`readMarker()`
`org.bouncycastle.openpgp.PGPOnePassSignature`
`readOnePassSignature()`
`org.bouncycastle.bcpg.Packet`
`readPacket()`
`org.bouncycastle.openpgp.PGPSignature`
`readSignature()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### delayedTee

protected final TeeBCPGInputStream.DelayedTeeInputStream delayedTee

### packetInputStream

protected final org.bouncycastle.bcpg.BCPGInputStream packetInputStream

## 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`