Skip to content

Commit

Permalink
Fix incorrect order of encrypt/decrypt and nonce incremental
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubtrnka authored and pavlenex committed Feb 2, 2024
1 parent 5b26146 commit 7f61e7a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions protocols/v2/noise-sv2/src/cipher_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ where
ad: &[u8],
data: &mut T,
) -> Result<(), aes_gcm::Error> {
self.set_n(self.get_n() + 1);
let n = self.nonce_to_bytes();
self.set_n(self.get_n() + 1);
if let Some(c) = self.get_cipher() {
match c.encrypt(&n, ad, data) {
Ok(_) => Ok(()),
Expand All @@ -63,8 +63,8 @@ where
ad: &[u8],
data: &mut T,
) -> Result<(), aes_gcm::Error> {
self.set_n(self.get_n() + 1);
let n = self.nonce_to_bytes();
self.set_n(self.get_n() + 1);
if let Some(c) = self.get_cipher() {
match c.decrypt(&n, ad, data) {
Ok(_) => Ok(()),
Expand Down

0 comments on commit 7f61e7a

Please sign in to comment.