diff --git a/implementations/go/I1K.noise.go b/implementations/go/I1K.noise.go index abf2d7a8..93f90b4a 100755 --- a/implementations/go/I1K.noise.go +++ b/implementations/go/I1K.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/I1K1.noise.go b/implementations/go/I1K1.noise.go index 24e04bf2..a80c6b11 100755 --- a/implementations/go/I1K1.noise.go +++ b/implementations/go/I1K1.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/I1N.noise.go b/implementations/go/I1N.noise.go index 392952f2..56517bae 100755 --- a/implementations/go/I1N.noise.go +++ b/implementations/go/I1N.noise.go @@ -240,7 +240,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/I1X.noise.go b/implementations/go/I1X.noise.go index cf955b3e..2e84287f 100755 --- a/implementations/go/I1X.noise.go +++ b/implementations/go/I1X.noise.go @@ -240,7 +240,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/I1X1.noise.go b/implementations/go/I1X1.noise.go index 631ac165..1ef0d1cf 100755 --- a/implementations/go/I1X1.noise.go +++ b/implementations/go/I1X1.noise.go @@ -240,7 +240,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/IK.noise.go b/implementations/go/IK.noise.go index e9895d95..0e81c725 100755 --- a/implementations/go/IK.noise.go +++ b/implementations/go/IK.noise.go @@ -241,7 +241,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/IK1.noise.go b/implementations/go/IK1.noise.go index 87562d36..f053e755 100755 --- a/implementations/go/IK1.noise.go +++ b/implementations/go/IK1.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/IKpsk1.noise.go b/implementations/go/IKpsk1.noise.go index bc3e8295..80d86b11 100755 --- a/implementations/go/IKpsk1.noise.go +++ b/implementations/go/IKpsk1.noise.go @@ -241,7 +241,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/IKpsk2.noise.go b/implementations/go/IKpsk2.noise.go index e81d1e18..545dda64 100755 --- a/implementations/go/IKpsk2.noise.go +++ b/implementations/go/IKpsk2.noise.go @@ -241,7 +241,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/IN.noise.go b/implementations/go/IN.noise.go index b5a0dd87..7afa08e6 100755 --- a/implementations/go/IN.noise.go +++ b/implementations/go/IN.noise.go @@ -239,7 +239,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/INpsk1.noise.go b/implementations/go/INpsk1.noise.go index 43b0b622..451dedb6 100755 --- a/implementations/go/INpsk1.noise.go +++ b/implementations/go/INpsk1.noise.go @@ -239,7 +239,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/INpsk2.noise.go b/implementations/go/INpsk2.noise.go index 51048d14..be2d7276 100755 --- a/implementations/go/INpsk2.noise.go +++ b/implementations/go/INpsk2.noise.go @@ -239,7 +239,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/IX.noise.go b/implementations/go/IX.noise.go index f3f574ad..63d31397 100755 --- a/implementations/go/IX.noise.go +++ b/implementations/go/IX.noise.go @@ -239,7 +239,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/IX1.noise.go b/implementations/go/IX1.noise.go index beeca654..6e121b4d 100755 --- a/implementations/go/IX1.noise.go +++ b/implementations/go/IX1.noise.go @@ -240,7 +240,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/IXpsk2.noise.go b/implementations/go/IXpsk2.noise.go index 82c8e4a2..d93ce905 100755 --- a/implementations/go/IXpsk2.noise.go +++ b/implementations/go/IXpsk2.noise.go @@ -239,7 +239,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/K.noise.go b/implementations/go/K.noise.go index 60d34232..2193e3d5 100755 --- a/implementations/go/K.noise.go +++ b/implementations/go/K.noise.go @@ -239,7 +239,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/K1K.noise.go b/implementations/go/K1K.noise.go index 8ae9db25..565e0ad8 100755 --- a/implementations/go/K1K.noise.go +++ b/implementations/go/K1K.noise.go @@ -243,7 +243,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/K1K1.noise.go b/implementations/go/K1K1.noise.go index 4f70ddd4..c736faf5 100755 --- a/implementations/go/K1K1.noise.go +++ b/implementations/go/K1K1.noise.go @@ -243,7 +243,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/K1N.noise.go b/implementations/go/K1N.noise.go index 98d4a32b..a8dc4186 100755 --- a/implementations/go/K1N.noise.go +++ b/implementations/go/K1N.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/K1X.noise.go b/implementations/go/K1X.noise.go index 755124c3..13731e0a 100755 --- a/implementations/go/K1X.noise.go +++ b/implementations/go/K1X.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/K1X1.noise.go b/implementations/go/K1X1.noise.go index aab9b651..cb59dc91 100755 --- a/implementations/go/K1X1.noise.go +++ b/implementations/go/K1X1.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/KK.noise.go b/implementations/go/KK.noise.go index b9b4a11d..c1a8810d 100755 --- a/implementations/go/KK.noise.go +++ b/implementations/go/KK.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/KK1.noise.go b/implementations/go/KK1.noise.go index 9c2997ff..ca784902 100755 --- a/implementations/go/KK1.noise.go +++ b/implementations/go/KK1.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/KKpsk0.noise.go b/implementations/go/KKpsk0.noise.go index 8454ee2b..5b78a7d8 100755 --- a/implementations/go/KKpsk0.noise.go +++ b/implementations/go/KKpsk0.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/KKpsk2.noise.go b/implementations/go/KKpsk2.noise.go index 063327d5..e21c6c0d 100755 --- a/implementations/go/KKpsk2.noise.go +++ b/implementations/go/KKpsk2.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/KN.noise.go b/implementations/go/KN.noise.go index 01e0af0a..42fbe858 100755 --- a/implementations/go/KN.noise.go +++ b/implementations/go/KN.noise.go @@ -241,7 +241,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/KNpsk0.noise.go b/implementations/go/KNpsk0.noise.go index 7ebf2758..c8b88672 100755 --- a/implementations/go/KNpsk0.noise.go +++ b/implementations/go/KNpsk0.noise.go @@ -241,7 +241,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/KNpsk2.noise.go b/implementations/go/KNpsk2.noise.go index b2a2f5ae..36fcc996 100755 --- a/implementations/go/KNpsk2.noise.go +++ b/implementations/go/KNpsk2.noise.go @@ -241,7 +241,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/KX.noise.go b/implementations/go/KX.noise.go index 248273a3..93ae5058 100755 --- a/implementations/go/KX.noise.go +++ b/implementations/go/KX.noise.go @@ -241,7 +241,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/KX1.noise.go b/implementations/go/KX1.noise.go index 87f0ed59..5adc1b22 100755 --- a/implementations/go/KX1.noise.go +++ b/implementations/go/KX1.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/KXpsk2.noise.go b/implementations/go/KXpsk2.noise.go index 8be92d0b..9097657d 100755 --- a/implementations/go/KXpsk2.noise.go +++ b/implementations/go/KXpsk2.noise.go @@ -241,7 +241,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/Kpsk0.noise.go b/implementations/go/Kpsk0.noise.go index f153f1d4..cb3458af 100755 --- a/implementations/go/Kpsk0.noise.go +++ b/implementations/go/Kpsk0.noise.go @@ -239,7 +239,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/N.noise.go b/implementations/go/N.noise.go index d69d0732..98949210 100755 --- a/implementations/go/N.noise.go +++ b/implementations/go/N.noise.go @@ -238,7 +238,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/NK.noise.go b/implementations/go/NK.noise.go index bfae6722..415d9e9f 100755 --- a/implementations/go/NK.noise.go +++ b/implementations/go/NK.noise.go @@ -241,7 +241,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/NK1.noise.go b/implementations/go/NK1.noise.go index c14b29be..9340a83d 100755 --- a/implementations/go/NK1.noise.go +++ b/implementations/go/NK1.noise.go @@ -241,7 +241,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/NKpsk0.noise.go b/implementations/go/NKpsk0.noise.go index ce181487..90ee6ec2 100755 --- a/implementations/go/NKpsk0.noise.go +++ b/implementations/go/NKpsk0.noise.go @@ -241,7 +241,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/NKpsk2.noise.go b/implementations/go/NKpsk2.noise.go index 0052641f..c2b36356 100755 --- a/implementations/go/NKpsk2.noise.go +++ b/implementations/go/NKpsk2.noise.go @@ -241,7 +241,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/NN.noise.go b/implementations/go/NN.noise.go index c69cb330..9283edbd 100755 --- a/implementations/go/NN.noise.go +++ b/implementations/go/NN.noise.go @@ -239,7 +239,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/NNpsk0.noise.go b/implementations/go/NNpsk0.noise.go index 0a34e5d0..ff876687 100755 --- a/implementations/go/NNpsk0.noise.go +++ b/implementations/go/NNpsk0.noise.go @@ -239,7 +239,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/NNpsk2.noise.go b/implementations/go/NNpsk2.noise.go index ff12e0ca..2c36b04b 100755 --- a/implementations/go/NNpsk2.noise.go +++ b/implementations/go/NNpsk2.noise.go @@ -239,7 +239,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/NX.noise.go b/implementations/go/NX.noise.go index ece30159..dd53ac3c 100755 --- a/implementations/go/NX.noise.go +++ b/implementations/go/NX.noise.go @@ -239,7 +239,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/NX1.noise.go b/implementations/go/NX1.noise.go index 71de765c..c44b2d61 100755 --- a/implementations/go/NX1.noise.go +++ b/implementations/go/NX1.noise.go @@ -240,7 +240,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/NXpsk2.noise.go b/implementations/go/NXpsk2.noise.go index 56f99dfa..893511d3 100755 --- a/implementations/go/NXpsk2.noise.go +++ b/implementations/go/NXpsk2.noise.go @@ -239,7 +239,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/Npsk0.noise.go b/implementations/go/Npsk0.noise.go index 84d9952f..2915b512 100755 --- a/implementations/go/Npsk0.noise.go +++ b/implementations/go/Npsk0.noise.go @@ -239,7 +239,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/X.noise.go b/implementations/go/X.noise.go index 5fb73506..0c1541e9 100755 --- a/implementations/go/X.noise.go +++ b/implementations/go/X.noise.go @@ -238,7 +238,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/X1K.noise.go b/implementations/go/X1K.noise.go index 349b42a1..d194b259 100755 --- a/implementations/go/X1K.noise.go +++ b/implementations/go/X1K.noise.go @@ -243,7 +243,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/X1K1.noise.go b/implementations/go/X1K1.noise.go index 7e5156dc..6e537867 100755 --- a/implementations/go/X1K1.noise.go +++ b/implementations/go/X1K1.noise.go @@ -243,7 +243,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/X1N.noise.go b/implementations/go/X1N.noise.go index 96ffe021..9abfc05f 100755 --- a/implementations/go/X1N.noise.go +++ b/implementations/go/X1N.noise.go @@ -241,7 +241,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/X1X.noise.go b/implementations/go/X1X.noise.go index 502f7f6e..ab238fb5 100755 --- a/implementations/go/X1X.noise.go +++ b/implementations/go/X1X.noise.go @@ -241,7 +241,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/X1X1.noise.go b/implementations/go/X1X1.noise.go index 2a74f8ae..7a73358b 100755 --- a/implementations/go/X1X1.noise.go +++ b/implementations/go/X1X1.noise.go @@ -241,7 +241,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/XK.noise.go b/implementations/go/XK.noise.go index ec25b11a..b76aac8d 100755 --- a/implementations/go/XK.noise.go +++ b/implementations/go/XK.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/XK1.noise.go b/implementations/go/XK1.noise.go index 305aada3..3be7dffa 100755 --- a/implementations/go/XK1.noise.go +++ b/implementations/go/XK1.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/XKpsk3.noise.go b/implementations/go/XKpsk3.noise.go index 0be7350f..e91ee055 100755 --- a/implementations/go/XKpsk3.noise.go +++ b/implementations/go/XKpsk3.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/XN.noise.go b/implementations/go/XN.noise.go index 2cddb8fd..b5db33bb 100755 --- a/implementations/go/XN.noise.go +++ b/implementations/go/XN.noise.go @@ -240,7 +240,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/XNpsk3.noise.go b/implementations/go/XNpsk3.noise.go index b0f719bc..62beeee9 100755 --- a/implementations/go/XNpsk3.noise.go +++ b/implementations/go/XNpsk3.noise.go @@ -240,7 +240,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/XX.noise.go b/implementations/go/XX.noise.go index 73b04f82..53af9a21 100755 --- a/implementations/go/XX.noise.go +++ b/implementations/go/XX.noise.go @@ -240,7 +240,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/XX1.noise.go b/implementations/go/XX1.noise.go index 9a80a212..27963043 100755 --- a/implementations/go/XX1.noise.go +++ b/implementations/go/XX1.noise.go @@ -240,7 +240,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/XXpsk3.noise.go b/implementations/go/XXpsk3.noise.go index afb69b06..691b649c 100755 --- a/implementations/go/XXpsk3.noise.go +++ b/implementations/go/XXpsk3.noise.go @@ -240,7 +240,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/Xpsk1.noise.go b/implementations/go/Xpsk1.noise.go index 0dbb762d..f94e644b 100755 --- a/implementations/go/Xpsk1.noise.go +++ b/implementations/go/Xpsk1.noise.go @@ -239,7 +239,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/I1K/I1K.noise.go b/implementations/go/tests/I1K/I1K.noise.go index 480cd544..d9b0d152 100755 --- a/implementations/go/tests/I1K/I1K.noise.go +++ b/implementations/go/tests/I1K/I1K.noise.go @@ -243,7 +243,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/I1K1/I1K1.noise.go b/implementations/go/tests/I1K1/I1K1.noise.go index 7def89b6..df036ba8 100755 --- a/implementations/go/tests/I1K1/I1K1.noise.go +++ b/implementations/go/tests/I1K1/I1K1.noise.go @@ -243,7 +243,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/I1N/I1N.noise.go b/implementations/go/tests/I1N/I1N.noise.go index 1b5cc82f..f1610bcc 100755 --- a/implementations/go/tests/I1N/I1N.noise.go +++ b/implementations/go/tests/I1N/I1N.noise.go @@ -241,7 +241,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/I1X/I1X.noise.go b/implementations/go/tests/I1X/I1X.noise.go index 1b005b31..a09d319a 100755 --- a/implementations/go/tests/I1X/I1X.noise.go +++ b/implementations/go/tests/I1X/I1X.noise.go @@ -241,7 +241,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/I1X1/I1X1.noise.go b/implementations/go/tests/I1X1/I1X1.noise.go index 0da4f27a..5b553fbd 100755 --- a/implementations/go/tests/I1X1/I1X1.noise.go +++ b/implementations/go/tests/I1X1/I1X1.noise.go @@ -241,7 +241,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/IK/IK.noise.go b/implementations/go/tests/IK/IK.noise.go index cdc179bf..d4856fa0 100755 --- a/implementations/go/tests/IK/IK.noise.go +++ b/implementations/go/tests/IK/IK.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/IK1/IK1.noise.go b/implementations/go/tests/IK1/IK1.noise.go index aa680b01..7f0c6e72 100755 --- a/implementations/go/tests/IK1/IK1.noise.go +++ b/implementations/go/tests/IK1/IK1.noise.go @@ -243,7 +243,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/IKpsk1/IKpsk1.noise.go b/implementations/go/tests/IKpsk1/IKpsk1.noise.go index 6cab4342..c81f40a8 100755 --- a/implementations/go/tests/IKpsk1/IKpsk1.noise.go +++ b/implementations/go/tests/IKpsk1/IKpsk1.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/IKpsk2/IKpsk2.noise.go b/implementations/go/tests/IKpsk2/IKpsk2.noise.go index de2e6d31..6f77a22d 100755 --- a/implementations/go/tests/IKpsk2/IKpsk2.noise.go +++ b/implementations/go/tests/IKpsk2/IKpsk2.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/IN/IN.noise.go b/implementations/go/tests/IN/IN.noise.go index fcf6fc88..cd6ba67c 100755 --- a/implementations/go/tests/IN/IN.noise.go +++ b/implementations/go/tests/IN/IN.noise.go @@ -240,7 +240,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/INpsk1/INpsk1.noise.go b/implementations/go/tests/INpsk1/INpsk1.noise.go index 5bde6d77..cba26ee6 100755 --- a/implementations/go/tests/INpsk1/INpsk1.noise.go +++ b/implementations/go/tests/INpsk1/INpsk1.noise.go @@ -240,7 +240,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/INpsk2/INpsk2.noise.go b/implementations/go/tests/INpsk2/INpsk2.noise.go index 51d0991c..18db27cd 100755 --- a/implementations/go/tests/INpsk2/INpsk2.noise.go +++ b/implementations/go/tests/INpsk2/INpsk2.noise.go @@ -240,7 +240,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/IX/IX.noise.go b/implementations/go/tests/IX/IX.noise.go index bd587ca5..ce88373e 100755 --- a/implementations/go/tests/IX/IX.noise.go +++ b/implementations/go/tests/IX/IX.noise.go @@ -240,7 +240,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/IX1/IX1.noise.go b/implementations/go/tests/IX1/IX1.noise.go index 992d29af..4c94612d 100755 --- a/implementations/go/tests/IX1/IX1.noise.go +++ b/implementations/go/tests/IX1/IX1.noise.go @@ -241,7 +241,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/IXpsk2/IXpsk2.noise.go b/implementations/go/tests/IXpsk2/IXpsk2.noise.go index 8bf7f0c5..f4588899 100755 --- a/implementations/go/tests/IXpsk2/IXpsk2.noise.go +++ b/implementations/go/tests/IXpsk2/IXpsk2.noise.go @@ -240,7 +240,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/K/K.noise.go b/implementations/go/tests/K/K.noise.go index f3938b90..69c4cc7f 100755 --- a/implementations/go/tests/K/K.noise.go +++ b/implementations/go/tests/K/K.noise.go @@ -240,7 +240,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/K1K/K1K.noise.go b/implementations/go/tests/K1K/K1K.noise.go index d0f7ec49..8a4b8ee4 100755 --- a/implementations/go/tests/K1K/K1K.noise.go +++ b/implementations/go/tests/K1K/K1K.noise.go @@ -244,7 +244,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/K1K1/K1K1.noise.go b/implementations/go/tests/K1K1/K1K1.noise.go index 84204cf0..f67109db 100755 --- a/implementations/go/tests/K1K1/K1K1.noise.go +++ b/implementations/go/tests/K1K1/K1K1.noise.go @@ -244,7 +244,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/K1N/K1N.noise.go b/implementations/go/tests/K1N/K1N.noise.go index fce20f01..ac70c69a 100755 --- a/implementations/go/tests/K1N/K1N.noise.go +++ b/implementations/go/tests/K1N/K1N.noise.go @@ -243,7 +243,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/K1X/K1X.noise.go b/implementations/go/tests/K1X/K1X.noise.go index ff3b0b0c..d9d6482b 100755 --- a/implementations/go/tests/K1X/K1X.noise.go +++ b/implementations/go/tests/K1X/K1X.noise.go @@ -243,7 +243,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/K1X1/K1X1.noise.go b/implementations/go/tests/K1X1/K1X1.noise.go index 3d9a3722..2c4af955 100755 --- a/implementations/go/tests/K1X1/K1X1.noise.go +++ b/implementations/go/tests/K1X1/K1X1.noise.go @@ -243,7 +243,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/KK/KK.noise.go b/implementations/go/tests/KK/KK.noise.go index e660d712..645bd8da 100755 --- a/implementations/go/tests/KK/KK.noise.go +++ b/implementations/go/tests/KK/KK.noise.go @@ -243,7 +243,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/KK1/KK1.noise.go b/implementations/go/tests/KK1/KK1.noise.go index c89c07a8..c6420f49 100755 --- a/implementations/go/tests/KK1/KK1.noise.go +++ b/implementations/go/tests/KK1/KK1.noise.go @@ -243,7 +243,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/KKpsk0/KKpsk0.noise.go b/implementations/go/tests/KKpsk0/KKpsk0.noise.go index ad013666..1fc73304 100755 --- a/implementations/go/tests/KKpsk0/KKpsk0.noise.go +++ b/implementations/go/tests/KKpsk0/KKpsk0.noise.go @@ -243,7 +243,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/KKpsk2/KKpsk2.noise.go b/implementations/go/tests/KKpsk2/KKpsk2.noise.go index d2d529ac..63fae774 100755 --- a/implementations/go/tests/KKpsk2/KKpsk2.noise.go +++ b/implementations/go/tests/KKpsk2/KKpsk2.noise.go @@ -243,7 +243,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/KN/KN.noise.go b/implementations/go/tests/KN/KN.noise.go index cc400226..74e8f0b4 100755 --- a/implementations/go/tests/KN/KN.noise.go +++ b/implementations/go/tests/KN/KN.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/KNpsk0/KNpsk0.noise.go b/implementations/go/tests/KNpsk0/KNpsk0.noise.go index 507f9453..a7772f68 100755 --- a/implementations/go/tests/KNpsk0/KNpsk0.noise.go +++ b/implementations/go/tests/KNpsk0/KNpsk0.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/KNpsk2/KNpsk2.noise.go b/implementations/go/tests/KNpsk2/KNpsk2.noise.go index 5a80c7ab..ccbd5cb3 100755 --- a/implementations/go/tests/KNpsk2/KNpsk2.noise.go +++ b/implementations/go/tests/KNpsk2/KNpsk2.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/KX/KX.noise.go b/implementations/go/tests/KX/KX.noise.go index 0a43bcc0..825409fc 100755 --- a/implementations/go/tests/KX/KX.noise.go +++ b/implementations/go/tests/KX/KX.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/KX1/KX1.noise.go b/implementations/go/tests/KX1/KX1.noise.go index 54b88f22..0c0305d3 100755 --- a/implementations/go/tests/KX1/KX1.noise.go +++ b/implementations/go/tests/KX1/KX1.noise.go @@ -243,7 +243,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/KXpsk2/KXpsk2.noise.go b/implementations/go/tests/KXpsk2/KXpsk2.noise.go index f978cd20..bb7d1392 100755 --- a/implementations/go/tests/KXpsk2/KXpsk2.noise.go +++ b/implementations/go/tests/KXpsk2/KXpsk2.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/Kpsk0/Kpsk0.noise.go b/implementations/go/tests/Kpsk0/Kpsk0.noise.go index d21f0f43..5d022d9f 100755 --- a/implementations/go/tests/Kpsk0/Kpsk0.noise.go +++ b/implementations/go/tests/Kpsk0/Kpsk0.noise.go @@ -240,7 +240,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/N/N.noise.go b/implementations/go/tests/N/N.noise.go index d9af285b..bd9b60b3 100755 --- a/implementations/go/tests/N/N.noise.go +++ b/implementations/go/tests/N/N.noise.go @@ -239,7 +239,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/NK/NK.noise.go b/implementations/go/tests/NK/NK.noise.go index 9f739c04..3dff7990 100755 --- a/implementations/go/tests/NK/NK.noise.go +++ b/implementations/go/tests/NK/NK.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/NK1/NK1.noise.go b/implementations/go/tests/NK1/NK1.noise.go index 3fa1e14d..13233c3a 100755 --- a/implementations/go/tests/NK1/NK1.noise.go +++ b/implementations/go/tests/NK1/NK1.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/NKpsk0/NKpsk0.noise.go b/implementations/go/tests/NKpsk0/NKpsk0.noise.go index 722d9cea..f279157f 100755 --- a/implementations/go/tests/NKpsk0/NKpsk0.noise.go +++ b/implementations/go/tests/NKpsk0/NKpsk0.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/NKpsk2/NKpsk2.noise.go b/implementations/go/tests/NKpsk2/NKpsk2.noise.go index 29443a06..0ee2f98b 100755 --- a/implementations/go/tests/NKpsk2/NKpsk2.noise.go +++ b/implementations/go/tests/NKpsk2/NKpsk2.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/NN/NN.noise.go b/implementations/go/tests/NN/NN.noise.go index 74cafe8a..87530e19 100755 --- a/implementations/go/tests/NN/NN.noise.go +++ b/implementations/go/tests/NN/NN.noise.go @@ -240,7 +240,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/NNpsk0/NNpsk0.noise.go b/implementations/go/tests/NNpsk0/NNpsk0.noise.go index 1f798e4c..1951828c 100755 --- a/implementations/go/tests/NNpsk0/NNpsk0.noise.go +++ b/implementations/go/tests/NNpsk0/NNpsk0.noise.go @@ -240,7 +240,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/NNpsk2/NNpsk2.noise.go b/implementations/go/tests/NNpsk2/NNpsk2.noise.go index 87ac5f2e..56dda733 100755 --- a/implementations/go/tests/NNpsk2/NNpsk2.noise.go +++ b/implementations/go/tests/NNpsk2/NNpsk2.noise.go @@ -240,7 +240,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/NX/NX.noise.go b/implementations/go/tests/NX/NX.noise.go index 76e20b37..5dfefa3f 100755 --- a/implementations/go/tests/NX/NX.noise.go +++ b/implementations/go/tests/NX/NX.noise.go @@ -240,7 +240,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/NX1/NX1.noise.go b/implementations/go/tests/NX1/NX1.noise.go index 8ce6cc59..d8ad960e 100755 --- a/implementations/go/tests/NX1/NX1.noise.go +++ b/implementations/go/tests/NX1/NX1.noise.go @@ -241,7 +241,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/NXpsk2/NXpsk2.noise.go b/implementations/go/tests/NXpsk2/NXpsk2.noise.go index dc601220..5f9186b4 100755 --- a/implementations/go/tests/NXpsk2/NXpsk2.noise.go +++ b/implementations/go/tests/NXpsk2/NXpsk2.noise.go @@ -240,7 +240,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/Npsk0/Npsk0.noise.go b/implementations/go/tests/Npsk0/Npsk0.noise.go index 38f4deaf..0e904776 100755 --- a/implementations/go/tests/Npsk0/Npsk0.noise.go +++ b/implementations/go/tests/Npsk0/Npsk0.noise.go @@ -240,7 +240,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/X/X.noise.go b/implementations/go/tests/X/X.noise.go index 282c7fe4..e1b3fe2b 100755 --- a/implementations/go/tests/X/X.noise.go +++ b/implementations/go/tests/X/X.noise.go @@ -239,7 +239,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/X1K/X1K.noise.go b/implementations/go/tests/X1K/X1K.noise.go index 7249bfc2..ef67e280 100755 --- a/implementations/go/tests/X1K/X1K.noise.go +++ b/implementations/go/tests/X1K/X1K.noise.go @@ -244,7 +244,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/X1K1/X1K1.noise.go b/implementations/go/tests/X1K1/X1K1.noise.go index aaed91fe..a4b0a7b8 100755 --- a/implementations/go/tests/X1K1/X1K1.noise.go +++ b/implementations/go/tests/X1K1/X1K1.noise.go @@ -244,7 +244,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/X1N/X1N.noise.go b/implementations/go/tests/X1N/X1N.noise.go index e3f246fb..f15925f9 100755 --- a/implementations/go/tests/X1N/X1N.noise.go +++ b/implementations/go/tests/X1N/X1N.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/X1X/X1X.noise.go b/implementations/go/tests/X1X/X1X.noise.go index 9d07a03c..0abaccce 100755 --- a/implementations/go/tests/X1X/X1X.noise.go +++ b/implementations/go/tests/X1X/X1X.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/X1X1/X1X1.noise.go b/implementations/go/tests/X1X1/X1X1.noise.go index f9b476c5..7100b04b 100755 --- a/implementations/go/tests/X1X1/X1X1.noise.go +++ b/implementations/go/tests/X1X1/X1X1.noise.go @@ -242,7 +242,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/XK/XK.noise.go b/implementations/go/tests/XK/XK.noise.go index 31dff1ab..d035c315 100755 --- a/implementations/go/tests/XK/XK.noise.go +++ b/implementations/go/tests/XK/XK.noise.go @@ -243,7 +243,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/XK1/XK1.noise.go b/implementations/go/tests/XK1/XK1.noise.go index f5aabc18..c2b5d060 100755 --- a/implementations/go/tests/XK1/XK1.noise.go +++ b/implementations/go/tests/XK1/XK1.noise.go @@ -243,7 +243,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/XKpsk3/XKpsk3.noise.go b/implementations/go/tests/XKpsk3/XKpsk3.noise.go index 71f38fa5..893dbe96 100755 --- a/implementations/go/tests/XKpsk3/XKpsk3.noise.go +++ b/implementations/go/tests/XKpsk3/XKpsk3.noise.go @@ -243,7 +243,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/XN/XN.noise.go b/implementations/go/tests/XN/XN.noise.go index 4b88752e..56e9247a 100755 --- a/implementations/go/tests/XN/XN.noise.go +++ b/implementations/go/tests/XN/XN.noise.go @@ -241,7 +241,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/XNpsk3/XNpsk3.noise.go b/implementations/go/tests/XNpsk3/XNpsk3.noise.go index 5c03010c..64710677 100755 --- a/implementations/go/tests/XNpsk3/XNpsk3.noise.go +++ b/implementations/go/tests/XNpsk3/XNpsk3.noise.go @@ -241,7 +241,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/XX/XX.noise.go b/implementations/go/tests/XX/XX.noise.go index 46ad4f8f..56135c84 100755 --- a/implementations/go/tests/XX/XX.noise.go +++ b/implementations/go/tests/XX/XX.noise.go @@ -241,7 +241,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/XX1/XX1.noise.go b/implementations/go/tests/XX1/XX1.noise.go index d096ce3e..daf2d355 100755 --- a/implementations/go/tests/XX1/XX1.noise.go +++ b/implementations/go/tests/XX1/XX1.noise.go @@ -241,7 +241,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/XXpsk3/XXpsk3.noise.go b/implementations/go/tests/XXpsk3/XXpsk3.noise.go index 5e907247..5c31d7c1 100755 --- a/implementations/go/tests/XXpsk3/XXpsk3.noise.go +++ b/implementations/go/tests/XXpsk3/XXpsk3.noise.go @@ -241,7 +241,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/implementations/go/tests/Xpsk1/Xpsk1.noise.go b/implementations/go/tests/Xpsk1/Xpsk1.noise.go index cd4009d0..4ce5f474 100755 --- a/implementations/go/tests/Xpsk1/Xpsk1.noise.go +++ b/implementations/go/tests/Xpsk1/Xpsk1.noise.go @@ -240,7 +240,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err } diff --git a/src/go/5state.go b/src/go/5state.go index bf5070e3..79dcd389 100755 --- a/src/go/5state.go +++ b/src/go/5state.go @@ -34,7 +34,9 @@ func decryptWithAd(cs *cipherstate, ad []byte, ciphertext []byte) (*cipherstate, return cs, []byte{}, false, err } valid, ad, plaintext := decrypt(cs.k, cs.n, ad, ciphertext) - cs = setNonce(cs, incrementNonce(cs.n)) + if valid { + cs = setNonce(cs, incrementNonce(cs.n)) + } return cs, plaintext, valid, err }