jvz commented on a change in pull request #132:
URL: https://github.com/apache/mina-sshd/pull/132#discussion_r427733788



##########
File path: 
sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
##########
@@ -1334,9 +1362,19 @@ protected void decode() throws Exception {
                 assert decoderBuffer.rpos() == Integer.BYTES;
                 int macSize = (inMac != null) ? inMacSize : 0;
                 // Check if the packet has been fully received
-                if (decoderBuffer.available() >= (decoderLength + macSize)) {
+                if (decoderBuffer.available() >= (decoderLength + macSize + 
authLen)) {
                     byte[] data = decoderBuffer.array();
-                    if (etmMode) {
+                    if (authMode) {
+                        final BaseGCMCipher cipher = (BaseGCMCipher) inCipher;
+                        cipher.incrementIV();
+                        // RFC 5647: packet length encoded in additional data 
and unencrypted
+                        int off = decoderBuffer.rpos();
+                        cipher.updateAAD(data, off - Integer.BYTES, 
Integer.BYTES);
+                        cipher.update(data, off, decoderLength);
+                        cipher.doFinal(data, Integer.BYTES + decoderLength);

Review comment:
       Finally, I figured out one of the problems. This use of the Cipher class 
is incorrect. When verifying an AT, that should be processed in `update` rather 
than `doFinal`.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to