Add EncryptReader#646
Conversation
bf2ee21 to
0962d50
Compare
Add EncryptReader function to encrypt io.Reader (pull-based encryption) and use it in command to get rid of io.Copy. Updates FiloSottile#644 Signed-off-by: Alexander Yastrebov <yastrebov.alex@gmail.com>
0962d50 to
f53ab87
Compare
|
This PR is nice and we need it, would it make sense to add this? func EncryptStream(src io.Reader, recipients ... Recipient) (dst io.Reader, error) {
pr, pw := io.Pipe()
return pr, EncryptReader(pw, src, recipients...)
}We wrap it currently as: https://gitlab.com/data-custodian/custodian/-/blob/88e7389ec5b837672f2b76fd82aaed68a4145e72/components/lib-common/pkg/crypto/reader.go |
I think this won't work as writes to pipe will block without corresponding reads. |
|
This PR adds a handy function but what you are looking for is the implementation of #644 |
|
I'm not sure I follow why this API is needed, or why it requires an internals refactor. Full pull-based encryption like in #644 I understand, and without an On the other hand, this without any other changes, right? Or am I missing something? |
yes, it avoids unnecessary buffering and copying. I'll close this to avoid confusion. |
|
Oh I see, it avoids one of the copies inside io.Copy. We could do that also by implementing ReaderFrom / WriterTo, right? If you’re hitting a throughput bottleneck, I can add that to the I/O improvements I’m working on. |
TBH, I did not, I just saw a possible optimisation. Making stream.Writer implement ReaderFrom is the better way. |
Add EncryptReader function to encrypt io.Reader (pull-based encryption) and use it in cmd/age to get rid of io.Copy.
Updates #644