diff --git a/ChangeLog.md b/ChangeLog.md index cef1944ab..68fdfa86a 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -34,6 +34,11 @@ if keyboard grabbing is enabled. TurboVNC Viewers to incorrectly interpret Shift + vertical scroll wheel events as horizontal scroll wheel events. +8. Fixed an issue whereby the TurboVNC Viewer's built-in SSH client threw a +NullPointerException if a cipher algorithm supported by the SSH server but not +by the SSH client was specified using the `Ciphers` OpenSSH config file +keyword. + 3.1.3 ===== diff --git a/java/com/jcraft/jsch/Session.java b/java/com/jcraft/jsch/Session.java index a85e409cd..3bb4b1b20 100644 --- a/java/com/jcraft/jsch/Session.java +++ b/java/com/jcraft/jsch/Session.java @@ -1,7 +1,7 @@ /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. -Copyright (c) 2018, 2023-2024 D. R. Commander. All rights reserved. +Copyright (c) 2018, 2023-2025 D. R. Commander. All rights reserved. Copyright (c) 2020-2021 Jeremy Norris. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -1156,6 +1156,8 @@ private void updateKeys(KeyExchange kex) throws Exception{ String method; method=guess[KeyExchange.PROPOSAL_ENC_ALGS_STOC]; + if(getConfig(method)==null) + throw new JSchException("Unsupported cipher "+method); c=Class.forName(getConfig(method)); s2ccipher=(Cipher)(c.getDeclaredConstructor().newInstance()); while(s2ccipher.getBlockSize()>Es2c.length){ @@ -1174,6 +1176,8 @@ private void updateKeys(KeyExchange kex) throws Exception{ s2ccipher_size=s2ccipher.getIVSize(); method=guess[KeyExchange.PROPOSAL_MAC_ALGS_STOC]; + if(getConfig(method)==null) + throw new JSchException("Unsupported cipher "+method); c=Class.forName(getConfig(method)); s2cmac=(MAC)(c.getDeclaredConstructor().newInstance()); MACs2c = expandKey(buf, K, H, MACs2c, hash, s2cmac.getBlockSize()); @@ -1183,6 +1187,8 @@ private void updateKeys(KeyExchange kex) throws Exception{ s2cmac_result2=new byte[s2cmac.getBlockSize()]; method=guess[KeyExchange.PROPOSAL_ENC_ALGS_CTOS]; + if(getConfig(method)==null) + throw new JSchException("Unsupported cipher "+method); c=Class.forName(getConfig(method)); c2scipher=(Cipher)(c.getDeclaredConstructor().newInstance()); while(c2scipher.getBlockSize()>Ec2s.length){ @@ -1201,6 +1207,8 @@ private void updateKeys(KeyExchange kex) throws Exception{ c2scipher_size=c2scipher.getIVSize(); method=guess[KeyExchange.PROPOSAL_MAC_ALGS_CTOS]; + if(getConfig(method)==null) + throw new JSchException("Unsupported cipher "+method); c=Class.forName(getConfig(method)); c2smac=(MAC)(c.getDeclaredConstructor().newInstance()); MACc2s = expandKey(buf, K, H, MACc2s, hash, c2smac.getBlockSize());