X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Futil%2Fchacha20poly1305rfc.rs;h=5fddb57eb36a0c1a2d119baeabd7d0a757509ee6;hb=f961daef33ad1e999c83aafbf654db449e0e93e0;hp=befe5d19f5f18f06454fd9140caf3fe026e9e8ec;hpb=ee805e97ff0888bcfd9dabc0de1027ae6b75163e;p=rust-lightning diff --git a/lightning/src/util/chacha20poly1305rfc.rs b/lightning/src/util/chacha20poly1305rfc.rs index befe5d19..5fddb57e 100644 --- a/lightning/src/util/chacha20poly1305rfc.rs +++ b/lightning/src/util/chacha20poly1305rfc.rs @@ -74,6 +74,11 @@ mod real_chachapoly { self.mac.raw_result(out_tag); } + pub fn encrypt_full_message_in_place(&mut self, input_output: &mut [u8], out_tag: &mut [u8]) { + self.encrypt_in_place(input_output); + self.finish_and_get_tag(out_tag); + } + // Encrypt `input_output` in-place. To finish and calculate the tag, use `finish_and_get_tag` // below. pub(super) fn encrypt_in_place(&mut self, input_output: &mut [u8]) { @@ -284,12 +289,17 @@ mod fuzzy_chachapoly { self.finished = true; } + pub fn encrypt_full_message_in_place(&mut self, input_output: &mut [u8], out_tag: &mut [u8]) { + self.encrypt_in_place(input_output); + self.finish_and_get_tag(out_tag); + } + pub(super) fn encrypt_in_place(&mut self, _input_output: &mut [u8]) { assert!(self.finished == false); - self.finished = true; } pub(super) fn finish_and_get_tag(&mut self, out_tag: &mut [u8]) { + assert!(self.finished == false); out_tag.copy_from_slice(&self.tag); self.finished = true; }