Add streaming APIs to encrypt with compression

This commit is contained in:
M. Thiercelin 2023-01-24 17:27:38 +01:00
parent ffcaa7f87b
commit eccc1df619
No known key found for this signature in database
GPG key ID: 29581E7E24EBEC0A
8 changed files with 209 additions and 29 deletions

View file

@ -74,10 +74,26 @@ func TestSessionKey_EncryptDecryptStream(t *testing.T) {
}
func TestSessionKey_EncryptStreamCompatible(t *testing.T) {
enc := func(w io.Writer, meta *PlainMessageMetadata, kr *KeyRing) (io.WriteCloser, error) {
return testSessionKey.EncryptStream(w, meta, kr)
}
testSessionKey_EncryptStreamCompatible(enc, t)
}
func TestSessionKey_EncryptStreamWithCompressionCompatible(t *testing.T) {
enc := func(w io.Writer, meta *PlainMessageMetadata, kr *KeyRing) (io.WriteCloser, error) {
return testSessionKey.EncryptStreamWithCompression(w, meta, kr)
}
testSessionKey_EncryptStreamCompatible(enc, t)
}
type sessionKeyEncryptionFunction = func(io.Writer, *PlainMessageMetadata, *KeyRing) (io.WriteCloser, error)
func testSessionKey_EncryptStreamCompatible(enc sessionKeyEncryptionFunction, t *testing.T) {
messageBytes := []byte("Hello World!")
messageReader := bytes.NewReader(messageBytes)
var dataPacketBuf bytes.Buffer
messageWriter, err := testSessionKey.EncryptStream(
messageWriter, err := enc(
&dataPacketBuf,
testMeta,
keyRingTestPrivate,