This is an automated email from the ASF dual-hosted git repository.

lgoldstein pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git

commit bec3884c2a41b999106bbd2842359422ff15154e
Author: Jeremy Norris <jeremy.nor...@localbackhaul.com>
AuthorDate: Mon Oct 12 15:15:57 2020 -0500

    [SSHD-506] Fix incrementing the invocation_counter part of the IV used in 
GCM cipher.
    
    Since the invocation_counter part of the IV is treated as a uint64,
    guarding against overflow by using Math.addExact() would incorrectly
    throw an ArithmeticException when it hits Long.MAX_VALUE.
---
 .../src/main/java/org/apache/sshd/common/cipher/BaseGCMCipher.java      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/sshd-common/src/main/java/org/apache/sshd/common/cipher/BaseGCMCipher.java 
b/sshd-common/src/main/java/org/apache/sshd/common/cipher/BaseGCMCipher.java
index c73cf32..5e43336 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/cipher/BaseGCMCipher.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/cipher/BaseGCMCipher.java
@@ -90,7 +90,7 @@ public class BaseGCMCipher extends BaseCipher {
         protected void incrementCounter() {
             int off = iv.length - Long.BYTES;
             long counter = BufferUtils.getLong(iv, off, Long.BYTES);
-            BufferUtils.putLong(Math.addExact(counter, 1L), iv, off, 
Long.BYTES);
+            BufferUtils.putLong(counter + 1L, iv, off, Long.BYTES);
         }
 
         @Override

Reply via email to