I am developing an interface that takes as input an encrypted byte stream -- probably a very *large* one -- that generates output of more or less the same format.

The input format is this:

```
{N byte envelope}
    - encryption key IDs &c.
{X byte encrypted body}

```

The output format is the same.

Here's the usual use case (heavily pseudocoded, of course):

```
Message incomingMessage = new Message (inputStream);

ProcessingResults results = process (incomingMessage);

MessageEnvelope messageEnvelope = new MessageEnvelope ();
// set message encryption options &c. ...

Message outgoingMessage = new Message ();
outgoingMessage.setEnvelope (messageEnvelope);

writeProcessingResults (results, message);

message.writeToOutput (outputStream);

```

To me, it seems to make sense to use the same object to encapsulate this behaviour, but I'm at a bit of a loss as to how I should go about this. It isn't practical to load all of the encrypted body in at a time; I need to be able to stream it (so, I'll be using some kind of input stream filter to decrypt it) but at the same time I need to be able to write out new instances of this object. What's a good approach to making this work? What should `Message` look like internally?