Source:
private byte[] unwrapConfidentialityProtectedMessage(byte[] message, int offset, int len) throws SaslException { int messageType = decodeByteOrderedInteger(message, offset + len - 6, 2); int extractedSeqNum = decodeByteOrderedInteger(message, offset + len - 4, 4); if (messageType != 1) { throw log.mechMessageTypeMustEqual(getMechanismName(), 1, messageType).toSaslException(); } if (extractedSeqNum != unwrapSeqNum) { throw log.mechBadSequenceNumberWhileUnwrapping(getMechanismName(), unwrapSeqNum, extractedSeqNum).toSaslException(); } byte[] clearText = null; try { clearText = unwrapCipher.update(message, offset, len - 6); if (clearText == null){ throw log.mechProblemDuringDecryptResultIsNull(getMechanismName()).toSaslException(); } } catch (Exception e) { throw log.mechProblemDuringDecrypt(getMechanismName(), e).toSaslException(); } byte[] hmac = new byte[10]; System.arraycopy(clearText, clearText.length - 10, hmac, 0, 10); byte[] decryptedMessage = null; if (unwrapCipher.getBlockSize() > 0) { int padSize = clearText[clearText.length - 10 - 1]; int decryptedMessageSize = clearText.length - 10; if (padSize < 8) { int i = clearText.length - 10 - 1; while (clearText[i] == padSize) { i--; } decryptedMessageSize = i + 1; } decryptedMessage = new byte[decryptedMessageSize]; System.arraycopy(clearText, 0, decryptedMessage, 0, decryptedMessageSize); } else { decryptedMessage = new byte[clearText.length - 10]; System.arraycopy(clearText, 0, decryptedMessage, 0, clearText.length - 10); } byte[] expectedHmac = computeHMAC(unwrapHmacKeyIntegrity, extractedSeqNum, hmacMD5, decryptedMessage, 0, decryptedMessage.length); if (Arrays2.equals(expectedHmac, 0, hmac, 0, 10) == false) { return NO_BYTES; } unwrapSeqNum++; return decryptedMessage; }

Target:
private byte[] unwrapConfidentialityProtectedMessage(byte[] message, int offset, int len) throws SaslException { int messageType = decodeByteOrderedInteger(message, offset + len - 6, 2); int extractedSeqNum = decodeByteOrderedInteger(message, offset + len - 4, 4); if (messageType != 1) { throw log.mechMessageTypeMustEqual(getMechanismName(), 1, messageType).toSaslException(); } if (extractedSeqNum != unwrapSeqNum) { throw log.mechBadSequenceNumberWhileUnwrapping(getMechanismName(), unwrapSeqNum, extractedSeqNum).toSaslException(); } byte[] clearText = null; try { clearText = unwrapCipher.update(message, offset, len - 6); } catch (Exception e) { throw log.mechProblemDuringDecrypt(getMechanismName(), e).toSaslException(); } if (clearText == null){ throw log.mechProblemDuringDecryptResultIsNull(getMechanismName()).toSaslException(); } byte[] hmac = new byte[10]; System.arraycopy(clearText, clearText.length - 10, hmac, 0, 10); byte[] decryptedMessage = null; if (unwrapCipher.getBlockSize() > 0) { int padSize = clearText[clearText.length - 10 - 1]; int decryptedMessageSize = clearText.length - 10; if (padSize < 8) { int i = clearText.length - 10 - 1; while (clearText[i] == padSize) { i--; } decryptedMessageSize = i + 1; } decryptedMessage = new byte[decryptedMessageSize]; System.arraycopy(clearText, 0, decryptedMessage, 0, decryptedMessageSize); } else { decryptedMessage = new byte[clearText.length - 10]; System.arraycopy(clearText, 0, decryptedMessage, 0, clearText.length - 10); } byte[] expectedHmac = computeHMAC(unwrapHmacKeyIntegrity, extractedSeqNum, hmacMD5, decryptedMessage, 0, decryptedMessage.length); if (Arrays2.equals(expectedHmac, 0, hmac, 0, 10) == false) { return NO_BYTES; } unwrapSeqNum++; return decryptedMessage; }