Hello,
I'd like to have your opinion on a refactoring of the aead_gcm code to support out-of-place decryption (and aliased in-place decryption). I have a use case discussed within the following publication: https://dl.acm.org/doi/10.1145/3787927.3787929. Out-of-place decryption may offer protocols using graviola to opt for the optimization discussed within this paper (contiguous zero-copy receiver). Existing secure transports, like rustls and application using it could also potentially benefit from contiguous zero-copy.
To implement out-of-place decryption, I am thinking of minimizing code changes by:
- Introducing an enum at the 'mid' level to encapsulate the caller's intent (either in place, or out-of-place decryption). It could be something as follows:
pub enum OpenIO<'a> {
InPlace(&'a mut [u8]),
OutOfPlace { ciphertext_and_tag_in: &'a [u8], plaintext_out: &'a mut [u8] },
}
And then changing the decrypt's interface:
pub fn decrypt(
&self,
nonce: &[u8; 12],
aad: &[u8],
open: OpenIO<'_>,
tag: &[u8]
) -> Result<(), Error>
And then at the 'low' level, we would have an in_ptr and out_ptr in the decrypt's interface which may or may not alias. What do you think?
Hello,
I'd like to have your opinion on a refactoring of the
aead_gcmcode to support out-of-place decryption (and aliased in-place decryption). I have a use case discussed within the following publication: https://dl.acm.org/doi/10.1145/3787927.3787929. Out-of-place decryption may offer protocols using graviola to opt for the optimization discussed within this paper (contiguous zero-copy receiver). Existing secure transports, like rustls and application using it could also potentially benefit from contiguous zero-copy.To implement out-of-place decryption, I am thinking of minimizing code changes by:
And then changing the decrypt's interface:
And then at the 'low' level, we would have an in_ptr and out_ptr in the decrypt's interface which may or may not alias. What do you think?