signalapp / libsignal

Home to the Signal Protocol as well as other cryptographic primitives which make Signal possible.
GNU Affero General Public License v3.0
3.42k stars 398 forks source link

Feature request: stream encryption #422

Closed veselinovicst closed 2 years ago

veselinovicst commented 2 years ago

Hello everyone,

as this library is meant to be a replacement for https://github.com/signalapp/libsignal-protocol-java library, I would like to know if you have plans to support encryption of streams.

The official Signal Java library (linked above) only supports encryption of byte arrays, and for my current use case I would like to encrypt messages that are in form of a stream.

Any plans on this?

jrose-signal commented 2 years ago

I'm afraid not. The Signal message format uses protobufs, which are length-prefixed at the start of the message and for subcomponents of the message. While it would be possible to stream a protobuf as long as you know how long it's going to be ahead of time, the code to do so would be significantly more complicated than just working with the protobuf in-memory.

In theory, one could still stream the input plaintext even if the ciphertext protobuf is stored as a byte array, but that means memory use is still proportional to the length of the message, so it doesn't seem like much of a win. This format just isn't designed for arbitrarily-large messages.

veselinovicst commented 2 years ago

Hey, that makes sense.

Thank you for the detailed response.