From 82452d8f6ce9c9ea14384a9e4809bc99a57962ff Mon Sep 17 00:00:00 2001 From: release-bot Date: Wed, 22 Mar 2023 06:53:15 +0000 Subject: [PATCH 001/301] [maven-release-plugin] prepare release jsch-0.2.8 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 61ad4c51..1f464a65 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.mwiede jsch jar - 0.2.8-SNAPSHOT + 0.2.8 JSch https://github.com/mwiede/jsch JSch is a pure Java implementation of SSH2 @@ -12,7 +12,7 @@ scm:git:https://github.com/mwiede/jsch.git scm:git:https://github.com/mwiede/jsch.git https://github.com/mwiede/jsch - HEAD + jsch-0.2.8 @@ -73,7 +73,7 @@ - 2023-03-21T03:04:14Z + 2023-03-22T06:51:44Z UTF-8 UTF-8 true From edfcfefe25a3cfea3990f1609c884e312ee1b5a8 Mon Sep 17 00:00:00 2001 From: release-bot Date: Wed, 22 Mar 2023 06:53:17 +0000 Subject: [PATCH 002/301] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 1f464a65..cecfbe82 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.mwiede jsch jar - 0.2.8 + 0.2.9-SNAPSHOT JSch https://github.com/mwiede/jsch JSch is a pure Java implementation of SSH2 @@ -12,7 +12,7 @@ scm:git:https://github.com/mwiede/jsch.git scm:git:https://github.com/mwiede/jsch.git https://github.com/mwiede/jsch - jsch-0.2.8 + HEAD @@ -73,7 +73,7 @@ - 2023-03-22T06:51:44Z + 2023-03-22T06:53:17Z UTF-8 UTF-8 true From 692bb9cad9c285a6cf5124063e7fd283a61b8911 Mon Sep 17 00:00:00 2001 From: Matthias Wiedemann Date: Wed, 22 Mar 2023 07:44:45 +0000 Subject: [PATCH 003/301] update version --- Readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 2af96bd4..21b87aeb 100644 --- a/Readme.md +++ b/Readme.md @@ -33,7 +33,7 @@ with com.github.mwiede jsch - 0.2.7 + 0.2.8 ``` @@ -43,7 +43,7 @@ When you have an artifact `foo:bar`, which contains `com.jcraft:jsch` as a trans com.github.mwiede jsch - 0.2.7 + 0.2.8 foo From 83b28b1c2add18300ea711d201b98c047d90aff8 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Sat, 25 Mar 2023 08:22:37 -0500 Subject: [PATCH 004/301] #293 allow UserAuthNone to be extended. --- ChangeLog.md | 2 ++ src/main/java/com/jcraft/jsch/Session.java | 24 ++++++------- .../java/com/jcraft/jsch/UserAuthNone.java | 35 +++++++++++-------- 3 files changed, 34 insertions(+), 27 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index daa2e1d6..fad72709 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,5 @@ +* [0.2.9](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.9) + * [#293](https://github.com/mwiede/jsch/issues/293) allow UserAuthNone to be extended. * [0.2.8](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.8) * [#287](https://github.com/mwiede/jsch/issues/287) add algorithm type information to algorithm negotiation logs. * [#289](https://github.com/mwiede/jsch/issues/289) wrap NoClassDefFoundError's for invalid private keys. diff --git a/src/main/java/com/jcraft/jsch/Session.java b/src/main/java/com/jcraft/jsch/Session.java index 857e580b..912cfab0 100644 --- a/src/main/java/com/jcraft/jsch/Session.java +++ b/src/main/java/com/jcraft/jsch/Session.java @@ -379,16 +379,16 @@ public void connect(int connectTimeout) throws JSchException { boolean auth = false; boolean auth_cancel = false; - UserAuth ua = null; + UserAuthNone uan = null; try { - Class c = - Class.forName(getConfig("userauth.none")).asSubclass(UserAuth.class); - ua = c.getDeclaredConstructor().newInstance(); + Class c = + Class.forName(getConfig("userauth.none")).asSubclass(UserAuthNone.class); + uan = c.getDeclaredConstructor().newInstance(); } catch (Exception e) { throw new JSchException(e.toString(), e); } - auth = ua.start(this); + auth = uan.start(this); String cmethods = getConfig("PreferredAuthentications"); @@ -396,12 +396,12 @@ public void connect(int connectTimeout) throws JSchException { String smethods = null; if (!auth) { - smethods = ((UserAuthNone) ua).getMethods(); + smethods = uan.getMethods(); if (smethods != null) { smethods = smethods.toLowerCase(); } else { // methods: publickey,password,keyboard-interactive - // smethods="publickey,password,keyboard-interactive"; + // smethods = "publickey,password,keyboard-interactive"; smethods = cmethods; } } @@ -426,7 +426,7 @@ public void connect(int connectTimeout) throws JSchException { continue; } - // System.err.println(" method: "+method); + // System.err.println(" method: " + method); if (getLogger().isEnabled(Logger.INFO)) { String str = "Authentications that can continue: "; @@ -439,7 +439,7 @@ public void connect(int connectTimeout) throws JSchException { getLogger().log(Logger.INFO, "Next authentication method: " + method); } - ua = null; + UserAuth ua = null; try { Class c = null; if (getConfig("userauth." + method) != null) { @@ -468,7 +468,7 @@ public void connect(int connectTimeout) throws JSchException { if (!tmp.equals(smethods)) { methodi = 0; } - // System.err.println("PartialAuth: "+methods); + // System.err.println("PartialAuth: " + methods); auth_cancel = false; continue loop; } catch (RuntimeException ee) { @@ -476,8 +476,8 @@ public void connect(int connectTimeout) throws JSchException { } catch (JSchException ee) { throw ee; } catch (Exception ee) { - // System.err.println("ee: "+ee); // SSH_MSG_DISCONNECT: 2 Too many authentication - // failures + // SSH_MSG_DISCONNECT: Too many authentication failures + // System.err.println("ee: " + ee); if (getLogger().isEnabled(Logger.WARN)) { getLogger().log(Logger.WARN, "an exception during authentication\n" + ee.toString()); diff --git a/src/main/java/com/jcraft/jsch/UserAuthNone.java b/src/main/java/com/jcraft/jsch/UserAuthNone.java index 24444063..a306a5cc 100644 --- a/src/main/java/com/jcraft/jsch/UserAuthNone.java +++ b/src/main/java/com/jcraft/jsch/UserAuthNone.java @@ -26,20 +26,21 @@ package com.jcraft.jsch; -class UserAuthNone extends UserAuth { - private static final int SSH_MSG_SERVICE_ACCEPT = 6; - private String methods = null; +public class UserAuthNone extends UserAuth { + protected static final int SSH_MSG_SERVICE_REQUEST = 5; + protected static final int SSH_MSG_SERVICE_ACCEPT = 6; + + private String methods; @Override public boolean start(Session session) throws Exception { super.start(session); - // send // byte SSH_MSG_SERVICE_REQUEST(5) // string service name "ssh-userauth" packet.reset(); - buf.putByte((byte) Session.SSH_MSG_SERVICE_REQUEST); + buf.putByte((byte) SSH_MSG_SERVICE_REQUEST); buf.putString(Util.str2byte("ssh-userauth")); session.write(packet); @@ -73,7 +74,7 @@ public boolean start(Session session) throws Exception { // string service name ("ssh-connection") // string "none" packet.reset(); - buf.putByte((byte) SSH_MSG_USERAUTH_REQUEST); + buf.putByte((byte) UserAuth.SSH_MSG_USERAUTH_REQUEST); buf.putString(_username); buf.putString(Util.str2byte("ssh-connection")); buf.putString(Util.str2byte("none")); @@ -83,10 +84,10 @@ public boolean start(Session session) throws Exception { buf = session.read(buf); command = buf.getCommand() & 0xff; - if (command == SSH_MSG_USERAUTH_SUCCESS) { + if (command == UserAuth.SSH_MSG_USERAUTH_SUCCESS) { return true; } - if (command == SSH_MSG_USERAUTH_BANNER) { + if (command == UserAuth.SSH_MSG_USERAUTH_BANNER) { buf.getInt(); buf.getByte(); buf.getByte(); @@ -101,22 +102,22 @@ public boolean start(Session session) throws Exception { } continue loop; } - if (command == SSH_MSG_USERAUTH_FAILURE) { + if (command == UserAuth.SSH_MSG_USERAUTH_FAILURE) { buf.getInt(); buf.getByte(); buf.getByte(); byte[] foo = buf.getString(); int partial_success = buf.getByte(); - methods = Util.byte2str(foo); - // System.err.println("UserAuthNONE: "+methods+ - // " partial_success:"+(partial_success!=0)); - // if(partial_success!=0){ + setMethods(Util.byte2str(foo)); + // System.err.println("UserAuthNone: " + methods + " partial_success:" + (partial_success != + // 0)); + // if (partial_success != 0) { // throw new JSchPartialAuthException(new String(foo)); // } break; } else { - // System.err.println("USERAUTH fail ("+command+")"); + // System.err.println("USERAUTH fail (" + command + ")"); throw new JSchException("USERAUTH fail (" + command + ")"); } } @@ -124,7 +125,11 @@ public boolean start(Session session) throws Exception { return false; } - String getMethods() { + protected String getMethods() { return methods; } + + protected void setMethods(String methods) { + this.methods = methods; + } } From 7b2b07477af135adf6c0a7b28f440734be0933b5 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Sat, 25 Mar 2023 08:23:40 -0500 Subject: [PATCH 005/301] Make JGSS module optional. --- ChangeLog.md | 1 + src/main/java9/module-info.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index fad72709..cb4eaf46 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,6 @@ * [0.2.9](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.9) * [#293](https://github.com/mwiede/jsch/issues/293) allow UserAuthNone to be extended. + * Make JGSS module optional. * [0.2.8](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.8) * [#287](https://github.com/mwiede/jsch/issues/287) add algorithm type information to algorithm negotiation logs. * [#289](https://github.com/mwiede/jsch/issues/289) wrap NoClassDefFoundError's for invalid private keys. diff --git a/src/main/java9/module-info.java b/src/main/java9/module-info.java index 28e87027..39da23f7 100644 --- a/src/main/java9/module-info.java +++ b/src/main/java9/module-info.java @@ -1,7 +1,7 @@ module com.jcraft.jsch { exports com.jcraft.jsch; - requires java.security.jgss; + requires static java.security.jgss; requires static java.logging; requires static org.apache.logging.log4j; requires static org.slf4j; From d727a7f9f1c00e8e33cee764e9ad0d3cf1efdfce Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Sat, 25 Mar 2023 08:26:16 -0500 Subject: [PATCH 006/301] Update dependencies. --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index cecfbe82..9bdc2328 100644 --- a/pom.xml +++ b/pom.xml @@ -218,7 +218,7 @@ com.github.valfirst slf4j-test - 2.8.1 + 2.9.0 test @@ -436,7 +436,7 @@ org.apache.maven.plugins maven-resources-plugin - 3.3.0 + 3.3.1 copy-licenses @@ -544,12 +544,12 @@ org.apache.maven.plugins maven-deploy-plugin - 3.1.0 + 3.1.1 org.apache.maven.plugins maven-install-plugin - 3.1.0 + 3.1.1 org.apache.maven.plugins From d30293f5cb4dc8a72ac4480aa93a4df4dca56685 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Sat, 25 Mar 2023 10:58:41 -0500 Subject: [PATCH 007/301] Tweak OSGi bundle manifest: Avoid self-import. Avoid `uses:="com.sun.jna"` on export. Mark JGSS as optional. Loosen import versions of dependencies. --- ChangeLog.md | 5 +++++ pom.xml | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index cb4eaf46..42dd3ca0 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,11 @@ * [0.2.9](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.9) * [#293](https://github.com/mwiede/jsch/issues/293) allow UserAuthNone to be extended. * Make JGSS module optional. + * Tweak OSGi bundle manifest: + * Avoid self-import. + * Avoid `uses:="com.sun.jna"` on export. + * Mark JGSS as optional. + * Loosen import versions of dependencies. * [0.2.8](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.8) * [#287](https://github.com/mwiede/jsch/issues/287) add algorithm type information to algorithm negotiation logs. * [#289](https://github.com/mwiede/jsch/issues/289) wrap NoClassDefFoundError's for invalid private keys. diff --git a/pom.xml b/pom.xml index 9bdc2328..d3c99736 100644 --- a/pom.xml +++ b/pom.xml @@ -391,7 +391,17 @@ 5.1.8 - com.jcraft.jsch + com.jcraft.jsch;-noimport:=true + + <_nouses>true + From e7aa1dfe90bb6aef0e38c4dc68946a69c2e6f21d Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Sat, 25 Mar 2023 15:01:10 -0500 Subject: [PATCH 008/301] Correctly adhere to the Multi-release JAR spec by ensuring all public classes under versioned directories preside over classes present in the top-level directory. --- ChangeLog.md | 1 + pom.xml | 5 ++ src/main/java/com/jcraft/jsch/JplLogger.java | 23 +++++++ .../KeyPairGenEdDSA.java} | 26 ++++++-- .../com/jcraft/jsch/jce/SignatureEd25519.java | 64 +++++++++++++++++++ .../com/jcraft/jsch/jce/SignatureEd448.java | 64 +++++++++++++++++++ .../com/jcraft/jsch/jce/XDH.java} | 34 +++++----- src/main/java11/com/jcraft/jsch/jce/XDH.java | 14 ++-- 8 files changed, 204 insertions(+), 27 deletions(-) create mode 100644 src/main/java/com/jcraft/jsch/JplLogger.java rename src/main/java/com/jcraft/jsch/{KeyPairGenXEC.java => jce/KeyPairGenEdDSA.java} (67%) create mode 100644 src/main/java/com/jcraft/jsch/jce/SignatureEd25519.java create mode 100644 src/main/java/com/jcraft/jsch/jce/SignatureEd448.java rename src/main/{java11/com/jcraft/jsch/jce/KeyPairGenXEC.java => java/com/jcraft/jsch/jce/XDH.java} (69%) diff --git a/ChangeLog.md b/ChangeLog.md index 42dd3ca0..cd3f917f 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -6,6 +6,7 @@ * Avoid `uses:="com.sun.jna"` on export. * Mark JGSS as optional. * Loosen import versions of dependencies. + * Correctly adhere to the Multi-release JAR spec by ensuring all public classes under versioned directories preside over classes present in the top-level directory. * [0.2.8](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.8) * [#287](https://github.com/mwiede/jsch/issues/287) add algorithm type information to algorithm negotiation logs. * [#289](https://github.com/mwiede/jsch/issues/289) wrap NoClassDefFoundError's for invalid private keys. diff --git a/pom.xml b/pom.xml index d3c99736..5e005130 100644 --- a/pom.xml +++ b/pom.xml @@ -620,7 +620,12 @@ com/jcraft/jsch/JavaVersion.class + com/jcraft/jsch/JplLogger.class com/jcraft/jsch/UnixDomainSocketFactory.class + com/jcraft/jsch/jce/KeyPairGenEdDSA.class + com/jcraft/jsch/jce/SignatureEd25519.class + com/jcraft/jsch/jce/SignatureEd448.class + com/jcraft/jsch/jce/XDH.class META-INF/versions/9/com/jcraft/jsch/JavaVersion.class META-INF/versions/10/com/jcraft/jsch/JavaVersion.class diff --git a/src/main/java/com/jcraft/jsch/JplLogger.java b/src/main/java/com/jcraft/jsch/JplLogger.java new file mode 100644 index 00000000..baf437ed --- /dev/null +++ b/src/main/java/com/jcraft/jsch/JplLogger.java @@ -0,0 +1,23 @@ +package com.jcraft.jsch; + +public class JplLogger implements com.jcraft.jsch.Logger { + + public JplLogger() { + throw new UnsupportedOperationException("JplLogger requires Java9+."); + } + + @Override + public boolean isEnabled(int level) { + throw new UnsupportedOperationException("JplLogger requires Java9+."); + } + + @Override + public void log(int level, String message) { + throw new UnsupportedOperationException("JplLogger requires Java9+."); + } + + @Override + public void log(int level, String message, Throwable cause) { + throw new UnsupportedOperationException("JplLogger requires Java9+."); + } +} diff --git a/src/main/java/com/jcraft/jsch/KeyPairGenXEC.java b/src/main/java/com/jcraft/jsch/jce/KeyPairGenEdDSA.java similarity index 67% rename from src/main/java/com/jcraft/jsch/KeyPairGenXEC.java rename to src/main/java/com/jcraft/jsch/jce/KeyPairGenEdDSA.java index fc4d5f0f..3f684ebc 100644 --- a/src/main/java/com/jcraft/jsch/KeyPairGenXEC.java +++ b/src/main/java/com/jcraft/jsch/jce/KeyPairGenEdDSA.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved. + * Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted * provided that the following conditions are met: @@ -24,8 +24,26 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package com.jcraft.jsch; +package com.jcraft.jsch.jce; -public interface KeyPairGenXEC { - void init(String name) throws Exception; +public class KeyPairGenEdDSA implements com.jcraft.jsch.KeyPairGenEdDSA { + + public KeyPairGenEdDSA() { + throw new UnsupportedOperationException("KeyPairGenEdDSA requires Java15+."); + } + + @Override + public void init(String name, int keylen) throws Exception { + throw new UnsupportedOperationException("KeyPairGenEdDSA requires Java15+."); + } + + @Override + public byte[] getPrv() { + throw new UnsupportedOperationException("KeyPairGenEdDSA requires Java15+."); + } + + @Override + public byte[] getPub() { + throw new UnsupportedOperationException("KeyPairGenEdDSA requires Java15+."); + } } diff --git a/src/main/java/com/jcraft/jsch/jce/SignatureEd25519.java b/src/main/java/com/jcraft/jsch/jce/SignatureEd25519.java new file mode 100644 index 00000000..9078c3b2 --- /dev/null +++ b/src/main/java/com/jcraft/jsch/jce/SignatureEd25519.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions + * and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided with + * the distribution. + * + * 3. The names of the authors may not be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.jcraft.jsch.jce; + +public class SignatureEd25519 implements com.jcraft.jsch.SignatureEdDSA { + + public SignatureEd25519() { + throw new UnsupportedOperationException("SignatureEd25519 requires Java15+."); + } + + @Override + public void init() throws Exception { + throw new UnsupportedOperationException("SignatureEd25519 requires Java15+."); + } + + @Override + public void setPubKey(byte[] y_arr) throws Exception { + throw new UnsupportedOperationException("SignatureEd25519 requires Java15+."); + } + + @Override + public void setPrvKey(byte[] bytes) throws Exception { + throw new UnsupportedOperationException("SignatureEd25519 requires Java15+."); + } + + @Override + public byte[] sign() throws Exception { + throw new UnsupportedOperationException("SignatureEd25519 requires Java15+."); + } + + @Override + public void update(byte[] foo) throws Exception { + throw new UnsupportedOperationException("SignatureEd25519 requires Java15+."); + } + + @Override + public boolean verify(byte[] sig) throws Exception { + throw new UnsupportedOperationException("SignatureEd25519 requires Java15+."); + } +} diff --git a/src/main/java/com/jcraft/jsch/jce/SignatureEd448.java b/src/main/java/com/jcraft/jsch/jce/SignatureEd448.java new file mode 100644 index 00000000..dedeee89 --- /dev/null +++ b/src/main/java/com/jcraft/jsch/jce/SignatureEd448.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions + * and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided with + * the distribution. + * + * 3. The names of the authors may not be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.jcraft.jsch.jce; + +public class SignatureEd448 implements com.jcraft.jsch.SignatureEdDSA { + + public SignatureEd448() { + throw new UnsupportedOperationException("SignatureEd448 requires Java15+."); + } + + @Override + public void init() throws Exception { + throw new UnsupportedOperationException("SignatureEd448 requires Java15+."); + } + + @Override + public void setPubKey(byte[] y_arr) throws Exception { + throw new UnsupportedOperationException("SignatureEd448 requires Java15+."); + } + + @Override + public void setPrvKey(byte[] bytes) throws Exception { + throw new UnsupportedOperationException("SignatureEd448 requires Java15+."); + } + + @Override + public byte[] sign() throws Exception { + throw new UnsupportedOperationException("SignatureEd448 requires Java15+."); + } + + @Override + public void update(byte[] foo) throws Exception { + throw new UnsupportedOperationException("SignatureEd448 requires Java15+."); + } + + @Override + public boolean verify(byte[] sig) throws Exception { + throw new UnsupportedOperationException("SignatureEd448 requires Java15+."); + } +} diff --git a/src/main/java11/com/jcraft/jsch/jce/KeyPairGenXEC.java b/src/main/java/com/jcraft/jsch/jce/XDH.java similarity index 69% rename from src/main/java11/com/jcraft/jsch/jce/KeyPairGenXEC.java rename to src/main/java/com/jcraft/jsch/jce/XDH.java index 1935bfd3..83379f1e 100644 --- a/src/main/java11/com/jcraft/jsch/jce/KeyPairGenXEC.java +++ b/src/main/java/com/jcraft/jsch/jce/XDH.java @@ -26,29 +26,29 @@ package com.jcraft.jsch.jce; -import java.security.*; -import java.security.interfaces.*; -import java.security.spec.*; +public class XDH implements com.jcraft.jsch.XDH { -public class KeyPairGenXEC implements com.jcraft.jsch.KeyPairGenXEC { - XECPublicKey pubKey; - XECPrivateKey prvKey; + public XDH() { + throw new UnsupportedOperationException("XDH requires Java11+."); + } + + @Override + public void init(String name, int keylen) throws Exception { + throw new UnsupportedOperationException("XDH requires Java11+."); + } @Override - public void init(String name) throws Exception { - KeyPairGenerator kpg = KeyPairGenerator.getInstance("XDH"); - NamedParameterSpec paramSpec = new NamedParameterSpec(name); - kpg.initialize(paramSpec); - KeyPair kp = kpg.genKeyPair(); - prvKey = (XECPrivateKey) kp.getPrivate(); - pubKey = (XECPublicKey) kp.getPublic(); + public byte[] getQ() throws Exception { + throw new UnsupportedOperationException("XDH requires Java11+."); } - XECPublicKey getPublicKey() { - return pubKey; + @Override + public byte[] getSecret(byte[] Q) throws Exception { + throw new UnsupportedOperationException("XDH requires Java11+."); } - XECPrivateKey getPrivateKey() { - return prvKey; + @Override + public boolean validate(byte[] u) throws Exception { + throw new UnsupportedOperationException("XDH requires Java11+."); } } diff --git a/src/main/java11/com/jcraft/jsch/jce/XDH.java b/src/main/java11/com/jcraft/jsch/jce/XDH.java index 3e1dadb5..a8856e7f 100644 --- a/src/main/java11/com/jcraft/jsch/jce/XDH.java +++ b/src/main/java11/com/jcraft/jsch/jce/XDH.java @@ -27,11 +27,11 @@ package com.jcraft.jsch.jce; import java.math.BigInteger; -import java.util.Arrays; import java.security.*; -import javax.crypto.*; import java.security.spec.*; import java.security.interfaces.*; +import java.util.Arrays; +import javax.crypto.*; public class XDH implements com.jcraft.jsch.XDH { byte[] Q_array; @@ -44,11 +44,13 @@ public class XDH implements com.jcraft.jsch.XDH { public void init(String name, int keylen) throws Exception { this.keylen = keylen; myKeyAgree = KeyAgreement.getInstance("XDH"); - KeyPairGenXEC kpair = new KeyPairGenXEC(); - kpair.init(name); - publicKey = kpair.getPublicKey(); + KeyPairGenerator kpg = KeyPairGenerator.getInstance("XDH"); + NamedParameterSpec paramSpec = new NamedParameterSpec(name); + kpg.initialize(paramSpec); + KeyPair kp = kpg.genKeyPair(); + publicKey = (XECPublicKey) kp.getPublic(); Q_array = rotate(publicKey.getU().toByteArray()); - myKeyAgree.init(kpair.getPrivateKey()); + myKeyAgree.init(kp.getPrivate()); } @Override From f07e4c947a11e374748cf3ee6a7176bd72c8fbd0 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Sat, 25 Mar 2023 15:49:42 -0500 Subject: [PATCH 009/301] Eliminate stray `System.err.println()` calls. --- ChangeLog.md | 1 + src/main/java/com/jcraft/jsch/ChannelSftp.java | 6 ++++-- src/main/java/com/jcraft/jsch/DHECN.java | 6 ++++-- src/main/java/com/jcraft/jsch/DHGEX.java | 12 ++++++++---- src/main/java/com/jcraft/jsch/DHGN.java | 11 ++++++----- src/main/java/com/jcraft/jsch/DHXEC.java | 6 ++++-- src/main/java/com/jcraft/jsch/HostKey.java | 4 +++- src/main/java/com/jcraft/jsch/KeyExchange.java | 16 ++++++++++------ src/main/java/com/jcraft/jsch/Session.java | 6 ++++-- src/main/java/com/jcraft/jsch/jce/HMAC.java | 6 +++++- src/main/java/com/jcraft/jsch/jce/MD5.java | 6 +----- src/main/java/com/jcraft/jsch/jce/SHA1.java | 6 +----- src/main/java/com/jcraft/jsch/jce/SHA224.java | 6 +----- src/main/java/com/jcraft/jsch/jce/SHA256.java | 6 +----- src/main/java/com/jcraft/jsch/jce/SHA384.java | 6 +----- src/main/java/com/jcraft/jsch/jce/SHA512.java | 6 +----- 16 files changed, 55 insertions(+), 55 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index cd3f917f..5bd68d86 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -7,6 +7,7 @@ * Mark JGSS as optional. * Loosen import versions of dependencies. * Correctly adhere to the Multi-release JAR spec by ensuring all public classes under versioned directories preside over classes present in the top-level directory. + * Eliminate stray `System.err.println()` calls. * [0.2.8](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.8) * [#287](https://github.com/mwiede/jsch/issues/287) add algorithm type information to algorithm negotiation logs. * [#289](https://github.com/mwiede/jsch/issues/289) wrap NoClassDefFoundError's for invalid private keys. diff --git a/src/main/java/com/jcraft/jsch/ChannelSftp.java b/src/main/java/com/jcraft/jsch/ChannelSftp.java index 4ede6f4c..849f0e3b 100644 --- a/src/main/java/com/jcraft/jsch/ChannelSftp.java +++ b/src/main/java/com/jcraft/jsch/ChannelSftp.java @@ -604,8 +604,10 @@ public void _put(InputStream src, String dst, SftpProgressMonitor monitor, int m int _ackid = ackid[0]; if (startid > _ackid || _ackid > seq - 1) { if (_ackid == seq) { - System.err.println( - "ack error: startid=" + startid + " seq=" + seq + " _ackid=" + _ackid); + if (getSession().getLogger().isEnabled(Logger.ERROR)) { + getSession().getLogger().log(Logger.ERROR, + "ack error: startid=" + startid + " seq=" + seq + " _ackid=" + _ackid); + } } else { throw new SftpException(SSH_FX_FAILURE, "ack error: startid=" + startid + " seq=" + seq + " _ackid=" + _ackid); diff --git a/src/main/java/com/jcraft/jsch/DHECN.java b/src/main/java/com/jcraft/jsch/DHECN.java index e0455247..f28c9ff8 100644 --- a/src/main/java/com/jcraft/jsch/DHECN.java +++ b/src/main/java/com/jcraft/jsch/DHECN.java @@ -62,7 +62,7 @@ public void init(Session session, byte[] V_S, byte[] V_C, byte[] I_S, byte[] I_C sha = c.getDeclaredConstructor().newInstance(); sha.init(); } catch (Exception e) { - System.err.println(e); + throw new JSchException(e.toString(), e); } buf = new Buffer(); @@ -111,7 +111,9 @@ public boolean next(Buffer _buf) throws Exception { j = _buf.getByte(); j = _buf.getByte(); if (j != SSH_MSG_KEX_ECDH_REPLY) { - System.err.println("type: must be SSH_MSG_KEX_ECDH_REPLY " + j); + if (session.getLogger().isEnabled(Logger.ERROR)) { + session.getLogger().log(Logger.ERROR, "type: must be SSH_MSG_KEX_ECDH_REPLY " + j); + } return false; } diff --git a/src/main/java/com/jcraft/jsch/DHGEX.java b/src/main/java/com/jcraft/jsch/DHGEX.java index 1c13879a..84aa51d4 100644 --- a/src/main/java/com/jcraft/jsch/DHGEX.java +++ b/src/main/java/com/jcraft/jsch/DHGEX.java @@ -68,7 +68,7 @@ public void init(Session session, byte[] V_S, byte[] V_C, byte[] I_S, byte[] I_C sha = c.getDeclaredConstructor().newInstance(); sha.init(); } catch (Exception e) { - System.err.println(e); + throw new JSchException(e.toString(), e); } buf = new Buffer(); @@ -87,7 +87,7 @@ public void init(Session session, byte[] V_S, byte[] V_C, byte[] I_S, byte[] I_C dh = c.getDeclaredConstructor().newInstance(); dh.init(); } catch (Exception e) { - throw e; + throw new JSchException(e.toString(), e); } packet.reset(); @@ -118,7 +118,9 @@ public boolean next(Buffer _buf) throws Exception { _buf.getByte(); j = _buf.getByte(); if (j != SSH_MSG_KEX_DH_GEX_GROUP) { - System.err.println("type: must be SSH_MSG_KEX_DH_GEX_GROUP " + j); + if (session.getLogger().isEnabled(Logger.ERROR)) { + session.getLogger().log(Logger.ERROR, "type: must be SSH_MSG_KEX_DH_GEX_GROUP " + j); + } return false; } @@ -158,7 +160,9 @@ public boolean next(Buffer _buf) throws Exception { j = _buf.getByte(); j = _buf.getByte(); if (j != SSH_MSG_KEX_DH_GEX_REPLY) { - System.err.println("type: must be SSH_MSG_KEX_DH_GEX_REPLY " + j); + if (session.getLogger().isEnabled(Logger.ERROR)) { + session.getLogger().log(Logger.ERROR, "type: must be SSH_MSG_KEX_DH_GEX_REPLY " + j); + } return false; } diff --git a/src/main/java/com/jcraft/jsch/DHGN.java b/src/main/java/com/jcraft/jsch/DHGN.java index ea68ee72..44aaadf8 100644 --- a/src/main/java/com/jcraft/jsch/DHGN.java +++ b/src/main/java/com/jcraft/jsch/DHGN.java @@ -64,7 +64,7 @@ public void init(Session session, byte[] V_S, byte[] V_C, byte[] I_S, byte[] I_C sha = c.getDeclaredConstructor().newInstance(); sha.init(); } catch (Exception e) { - System.err.println(e); + throw new JSchException(e.toString(), e); } buf = new Buffer(); @@ -75,8 +75,7 @@ public void init(Session session, byte[] V_S, byte[] V_C, byte[] I_S, byte[] I_C dh = c.getDeclaredConstructor().newInstance(); dh.init(); } catch (Exception e) { - // System.err.println(e); - throw e; + throw new JSchException(e.toString(), e); } dh.setP(P()); @@ -119,8 +118,10 @@ public boolean next(Buffer _buf) throws Exception { j = _buf.getInt(); j = _buf.getByte(); j = _buf.getByte(); - if (j != 31) { - System.err.println("type: must be 31 " + j); + if (j != SSH_MSG_KEXDH_REPLY) { + if (session.getLogger().isEnabled(Logger.ERROR)) { + session.getLogger().log(Logger.ERROR, "type: must be SSH_MSG_KEXDH_REPLY " + j); + } return false; } diff --git a/src/main/java/com/jcraft/jsch/DHXEC.java b/src/main/java/com/jcraft/jsch/DHXEC.java index b4942b80..a3576189 100644 --- a/src/main/java/com/jcraft/jsch/DHXEC.java +++ b/src/main/java/com/jcraft/jsch/DHXEC.java @@ -63,7 +63,7 @@ public void init(Session session, byte[] V_S, byte[] V_C, byte[] I_S, byte[] I_C sha = c.getDeclaredConstructor().newInstance(); sha.init(); } catch (Exception e) { - System.err.println(e); + throw new JSchException(e.toString(), e); } buf = new Buffer(); @@ -111,7 +111,9 @@ public boolean next(Buffer _buf) throws Exception { j = _buf.getByte(); j = _buf.getByte(); if (j != SSH_MSG_KEX_ECDH_REPLY) { - System.err.println("type: must be SSH_MSG_KEX_ECDH_REPLY " + j); + if (session.getLogger().isEnabled(Logger.ERROR)) { + session.getLogger().log(Logger.ERROR, "type: must be SSH_MSG_KEX_ECDH_REPLY " + j); + } return false; } diff --git a/src/main/java/com/jcraft/jsch/HostKey.java b/src/main/java/com/jcraft/jsch/HostKey.java index dd6178ac..51b6b8f1 100644 --- a/src/main/java/com/jcraft/jsch/HostKey.java +++ b/src/main/java/com/jcraft/jsch/HostKey.java @@ -122,7 +122,9 @@ public String getFingerPrint(JSch jsch) { Class c = Class.forName(JSch.getConfig(_c)).asSubclass(HASH.class); hash = c.getDeclaredConstructor().newInstance(); } catch (Exception e) { - System.err.println("getFingerPrint: " + e); + if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { + jsch.getInstanceLogger().log(Logger.ERROR, "getFingerPrint: " + e.getMessage(), e); + } } return Util.getFingerPrint(hash, key, false, true); } diff --git a/src/main/java/com/jcraft/jsch/KeyExchange.java b/src/main/java/com/jcraft/jsch/KeyExchange.java index 673dcfbd..7a3d508e 100644 --- a/src/main/java/com/jcraft/jsch/KeyExchange.java +++ b/src/main/java/com/jcraft/jsch/KeyExchange.java @@ -202,7 +202,9 @@ public String getFingerPrint() { Class c = Class.forName(session.getConfig(_c)).asSubclass(HASH.class); hash = c.getDeclaredConstructor().newInstance(); } catch (Exception e) { - System.err.println("getFingerPrint: " + e); + if (session.getLogger().isEnabled(Logger.ERROR)) { + session.getLogger().log(Logger.ERROR, "getFingerPrint: " + e.getMessage(), e); + } } return Util.getFingerPrint(hash, getHostKey(), true, false); } @@ -274,7 +276,7 @@ protected boolean verify(String alg, byte[] K_S, int index, byte[] sig_of_H) thr sig = c.getDeclaredConstructor().newInstance(); sig.init(); } catch (Exception e) { - System.err.println(e); + throw new JSchException(e.toString(), e); } sig.setPubKey(ee, n); sig.update(H); @@ -325,7 +327,7 @@ protected boolean verify(String alg, byte[] K_S, int index, byte[] sig_of_H) thr sig = c.getDeclaredConstructor().newInstance(); sig.init(); } catch (Exception e) { - System.err.println(e); + throw new JSchException(e.toString(), e); } sig.setPubKey(f, p, q, g); sig.update(H); @@ -368,7 +370,7 @@ protected boolean verify(String alg, byte[] K_S, int index, byte[] sig_of_H) thr sig = c.getDeclaredConstructor().newInstance(); sig.init(); } catch (Exception e) { - System.err.println(e); + throw new JSchException(e.toString(), e); } sig.setPubKey(r, s); @@ -400,7 +402,7 @@ protected boolean verify(String alg, byte[] K_S, int index, byte[] sig_of_H) thr sig = c.getDeclaredConstructor().newInstance(); sig.init(); } catch (Exception | NoClassDefFoundError e) { - System.err.println(e); + throw new JSchException(e.toString(), e); } sig.setPubKey(tmp); @@ -413,7 +415,9 @@ protected boolean verify(String alg, byte[] K_S, int index, byte[] sig_of_H) thr session.getLogger().log(Logger.INFO, "ssh_eddsa_verify: " + alg + " signature " + result); } } else { - System.err.println("unknown alg"); + if (session.getLogger().isEnabled(Logger.ERROR)) { + session.getLogger().log(Logger.ERROR, "unknown alg: " + alg); + } } return result; diff --git a/src/main/java/com/jcraft/jsch/Session.java b/src/main/java/com/jcraft/jsch/Session.java index 912cfab0..1ba845d7 100644 --- a/src/main/java/com/jcraft/jsch/Session.java +++ b/src/main/java/com/jcraft/jsch/Session.java @@ -1185,7 +1185,9 @@ Buffer read(Buffer buf) throws Exception { buf.buffer = foo; buf.index = 5 + uncompress_len[0]; } else { - System.err.println("fail in inflater"); + if (getLogger().isEnabled(Logger.ERROR)) { + getLogger().log(Logger.ERROR, "fail in inflater"); + } break; } } @@ -1324,7 +1326,7 @@ private void start_discard(Buffer buf, Cipher cipher, MAC mac, int mac_already, } catch (IOException e) { ioe = e; if (getLogger().isEnabled(Logger.ERROR)) { - getLogger().log(Logger.ERROR, "start_discard finished early due to " + e.getMessage()); + getLogger().log(Logger.ERROR, "start_discard finished early due to " + e.getMessage(), e); } } diff --git a/src/main/java/com/jcraft/jsch/jce/HMAC.java b/src/main/java/com/jcraft/jsch/jce/HMAC.java index 96705062..8321e14b 100644 --- a/src/main/java/com/jcraft/jsch/jce/HMAC.java +++ b/src/main/java/com/jcraft/jsch/jce/HMAC.java @@ -26,6 +26,8 @@ package com.jcraft.jsch.jce; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.Logger; import com.jcraft.jsch.MAC; import javax.crypto.*; import javax.crypto.spec.*; @@ -75,7 +77,9 @@ public void doFinal(byte[] buf, int offset) { try { mac.doFinal(buf, offset); } catch (ShortBufferException e) { - System.err.println(e); + if (JSch.getLogger().isEnabled(Logger.ERROR)) { + JSch.getLogger().log(Logger.ERROR, e.getMessage(), e); + } } } diff --git a/src/main/java/com/jcraft/jsch/jce/MD5.java b/src/main/java/com/jcraft/jsch/jce/MD5.java index 19267302..250b9b2e 100644 --- a/src/main/java/com/jcraft/jsch/jce/MD5.java +++ b/src/main/java/com/jcraft/jsch/jce/MD5.java @@ -40,11 +40,7 @@ public int getBlockSize() { @Override public void init() throws Exception { - try { - md = MessageDigest.getInstance("MD5"); - } catch (Exception e) { - System.err.println(e); - } + md = MessageDigest.getInstance("MD5"); } @Override diff --git a/src/main/java/com/jcraft/jsch/jce/SHA1.java b/src/main/java/com/jcraft/jsch/jce/SHA1.java index 5684536e..102f6178 100644 --- a/src/main/java/com/jcraft/jsch/jce/SHA1.java +++ b/src/main/java/com/jcraft/jsch/jce/SHA1.java @@ -40,11 +40,7 @@ public int getBlockSize() { @Override public void init() throws Exception { - try { - md = MessageDigest.getInstance("SHA-1"); - } catch (Exception e) { - System.err.println(e); - } + md = MessageDigest.getInstance("SHA-1"); } @Override diff --git a/src/main/java/com/jcraft/jsch/jce/SHA224.java b/src/main/java/com/jcraft/jsch/jce/SHA224.java index 44105378..f8acf879 100644 --- a/src/main/java/com/jcraft/jsch/jce/SHA224.java +++ b/src/main/java/com/jcraft/jsch/jce/SHA224.java @@ -40,11 +40,7 @@ public int getBlockSize() { @Override public void init() throws Exception { - try { - md = MessageDigest.getInstance("SHA-224"); - } catch (Exception e) { - System.err.println(e); - } + md = MessageDigest.getInstance("SHA-224"); } @Override diff --git a/src/main/java/com/jcraft/jsch/jce/SHA256.java b/src/main/java/com/jcraft/jsch/jce/SHA256.java index fbd1a0bc..3173ab7b 100644 --- a/src/main/java/com/jcraft/jsch/jce/SHA256.java +++ b/src/main/java/com/jcraft/jsch/jce/SHA256.java @@ -40,11 +40,7 @@ public int getBlockSize() { @Override public void init() throws Exception { - try { - md = MessageDigest.getInstance("SHA-256"); - } catch (Exception e) { - System.err.println(e); - } + md = MessageDigest.getInstance("SHA-256"); } @Override diff --git a/src/main/java/com/jcraft/jsch/jce/SHA384.java b/src/main/java/com/jcraft/jsch/jce/SHA384.java index bb176a75..d7505b69 100644 --- a/src/main/java/com/jcraft/jsch/jce/SHA384.java +++ b/src/main/java/com/jcraft/jsch/jce/SHA384.java @@ -38,11 +38,7 @@ public int getBlockSize() { @Override public void init() throws Exception { - try { - md = MessageDigest.getInstance("SHA-384"); - } catch (Exception e) { - System.err.println(e); - } + md = MessageDigest.getInstance("SHA-384"); } @Override diff --git a/src/main/java/com/jcraft/jsch/jce/SHA512.java b/src/main/java/com/jcraft/jsch/jce/SHA512.java index b7c5c291..1a8286db 100644 --- a/src/main/java/com/jcraft/jsch/jce/SHA512.java +++ b/src/main/java/com/jcraft/jsch/jce/SHA512.java @@ -38,11 +38,7 @@ public int getBlockSize() { @Override public void init() throws Exception { - try { - md = MessageDigest.getInstance("SHA-512"); - } catch (Exception e) { - System.err.println(e); - } + md = MessageDigest.getInstance("SHA-512"); } @Override From 2a69cd8bf9f02454b1b450b5d53b8b489d2b45d6 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Sat, 25 Mar 2023 18:36:30 -0500 Subject: [PATCH 010/301] Use failOnWarning instead of directly passing -Werror. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5e005130..b62775bb 100644 --- a/pom.xml +++ b/pom.xml @@ -312,9 +312,9 @@ 8 true true + true -Xlint:all,-processing,-classfile - -Werror From d18655b7416b154f16ca1c222abead0d609250bd Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Sun, 26 Mar 2023 00:07:34 -0500 Subject: [PATCH 011/301] Change PageantConnector to use JNA's built-in support for `User32.SendMessage()`. --- ChangeLog.md | 1 + .../com/jcraft/jsch/PageantConnector.java | 157 ++++++------------ 2 files changed, 52 insertions(+), 106 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 5bd68d86..432ed944 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -8,6 +8,7 @@ * Loosen import versions of dependencies. * Correctly adhere to the Multi-release JAR spec by ensuring all public classes under versioned directories preside over classes present in the top-level directory. * Eliminate stray `System.err.println()` calls. + * Change PageantConnector to use JNA's built-in support for `User32.SendMessage()`. * [0.2.8](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.8) * [#287](https://github.com/mwiede/jsch/issues/287) add algorithm type information to algorithm negotiation logs. * [#289](https://github.com/mwiede/jsch/issues/289) wrap NoClassDefFoundError's for invalid private keys. diff --git a/src/main/java/com/jcraft/jsch/PageantConnector.java b/src/main/java/com/jcraft/jsch/PageantConnector.java index 37949c30..30511c40 100644 --- a/src/main/java/com/jcraft/jsch/PageantConnector.java +++ b/src/main/java/com/jcraft/jsch/PageantConnector.java @@ -26,33 +26,28 @@ package com.jcraft.jsch; -import com.sun.jna.Platform; -import com.sun.jna.Native; import com.sun.jna.Memory; import com.sun.jna.Pointer; -import com.sun.jna.Structure; - -import com.sun.jna.win32.W32APIOptions; - -import com.sun.jna.platform.win32.WinNT.HANDLE; -import com.sun.jna.platform.win32.WinDef.HWND; +import com.sun.jna.platform.win32.BaseTSD.ULONG_PTR; +import com.sun.jna.platform.win32.Kernel32; +import com.sun.jna.platform.win32.User32; import com.sun.jna.platform.win32.WinBase; import com.sun.jna.platform.win32.WinBase.SECURITY_ATTRIBUTES; -import com.sun.jna.platform.win32.Kernel32; +import com.sun.jna.platform.win32.WinDef.HWND; +import com.sun.jna.platform.win32.WinDef.LPARAM; +import com.sun.jna.platform.win32.WinDef.LRESULT; import com.sun.jna.platform.win32.WinNT; +import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.platform.win32.WinUser; - -import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import java.util.List; +import com.sun.jna.platform.win32.WinUser.COPYDATASTRUCT; public class PageantConnector implements AgentConnector { private static final int AGENT_MAX_MSGLEN = 262144; - private static final int AGENT_COPYDATA_ID = 0x804e50ba; + private static final long AGENT_COPYDATA_ID = 0x804e50baL; - private User32 libU = null; - private Kernel32 libK = null; + private final User32 user32; + private final Kernel32 kernel32; public PageantConnector() throws AgentProxyException { if (!Util.getSystemProperty("os.name", "").startsWith("Windows")) { @@ -60,8 +55,8 @@ public PageantConnector() throws AgentProxyException { } try { - libU = User32.INSTANCE; - libK = Kernel32.INSTANCE; + user32 = User32.INSTANCE; + kernel32 = Kernel32.INSTANCE; } catch (UnsatisfiedLinkError | NoClassDefFoundError e) { throw new AgentProxyException(e.toString(), e); } @@ -74,35 +69,7 @@ public String getName() { @Override public boolean isAvailable() { - return libU.FindWindow("Pageant", "Pageant") != null; - } - - private interface User32 extends com.sun.jna.platform.win32.User32 { - User32 INSTANCE = Native.load("user32", User32.class, W32APIOptions.DEFAULT_OPTIONS); - - long SendMessage(HWND hWnd, int msg, WPARAM num1, byte[] num2); - } - - public static class COPYDATASTRUCT32 extends Structure { - public int dwData; - public int cbData; - public Pointer lpData; - - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] {"dwData", "cbData", "lpData"}); - } - } - - public static class COPYDATASTRUCT64 extends Structure { - public int dwData; - public long cbData; - public Pointer lpData; - - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] {"dwData", "cbData", "lpData"}); - } + return user32.FindWindow("Pageant", "Pageant") != null; } @Override @@ -111,40 +78,37 @@ public void query(Buffer buffer) throws AgentProxyException { throw new AgentProxyException("Query too large."); } - HWND hwnd = libU.FindWindow("Pageant", "Pageant"); + HWND hwnd = user32.FindWindow("Pageant", "Pageant"); if (hwnd == null) { throw new AgentProxyException("Pageant is not runnning."); } - String mapname = String.format("PageantRequest%08x", libK.GetCurrentThreadId()); + String mapname = String.format("PageantRequest%08x", kernel32.GetCurrentThreadId()); - // TODO - SECURITY_ATTRIBUTES psa = null; + HANDLE sharedFile = null; + Pointer sharedMemory = null; + try { + // TODO + SECURITY_ATTRIBUTES psa = null; - HANDLE sharedFile = libK.CreateFileMapping(WinBase.INVALID_HANDLE_VALUE, psa, - WinNT.PAGE_READWRITE, 0, AGENT_MAX_MSGLEN, mapname); - if (sharedFile == null || sharedFile == WinBase.INVALID_HANDLE_VALUE) { - throw new AgentProxyException("Unable to create shared file mapping."); - } + sharedFile = kernel32.CreateFileMapping(WinBase.INVALID_HANDLE_VALUE, psa, + WinNT.PAGE_READWRITE, 0, AGENT_MAX_MSGLEN, mapname); + if (sharedFile == null || sharedFile == WinBase.INVALID_HANDLE_VALUE) { + throw new AgentProxyException("Unable to create shared file mapping."); + } - Pointer sharedMemory = - Kernel32.INSTANCE.MapViewOfFile(sharedFile, WinNT.SECTION_MAP_WRITE, 0, 0, 0); + sharedMemory = kernel32.MapViewOfFile(sharedFile, WinNT.SECTION_MAP_WRITE, 0, 0, 0); + if (sharedMemory == null) { + throw new AgentProxyException("Unable to create shared file mapping."); + } - byte[] data = null; - long rcode = 0; - try { sharedMemory.write(0, buffer.buffer, 0, buffer.getLength()); - if (Platform.is64Bit()) { - COPYDATASTRUCT64 cds64 = new COPYDATASTRUCT64(); - data = install64(mapname, cds64); - rcode = sendMessage(hwnd, data); - } else { - COPYDATASTRUCT32 cds32 = new COPYDATASTRUCT32(); - data = install32(mapname, cds32); - rcode = sendMessage(hwnd, data); - } + COPYDATASTRUCT cds = createCDS(mapname); + long rcode = sendMessage(hwnd, cds); + // Dummy read to make sure COPYDATASTRUCT isn't GC'd early + long foo = cds.dwData.longValue(); buffer.rewind(); if (rcode != 0) { @@ -157,50 +121,31 @@ public void query(Buffer buffer) throws AgentProxyException { buffer.checkFreeSize(i); sharedMemory.read(4, buffer.buffer, 0, i); } else { - throw new AgentProxyException("User32.SendMessage() returned 0"); + throw new AgentProxyException( + "User32.SendMessage() returned 0 with cds.dwData: " + Long.toHexString(foo)); } } finally { if (sharedMemory != null) - libK.UnmapViewOfFile(sharedMemory); + kernel32.UnmapViewOfFile(sharedMemory); if (sharedFile != null) - libK.CloseHandle(sharedFile); - } - } - - private static byte[] install32(String mapname, COPYDATASTRUCT32 cds) { - cds.dwData = AGENT_COPYDATA_ID; - cds.cbData = mapname.length() + 1; - cds.lpData = new Memory(mapname.length() + 1); - { - byte[] foo = Util.str2byte(mapname, StandardCharsets.US_ASCII); - cds.lpData.write(0, foo, 0, foo.length); - cds.lpData.setByte(foo.length, (byte) 0); - cds.write(); + kernel32.CloseHandle(sharedFile); } - byte[] data = new byte[12]; - Pointer cdsp = cds.getPointer(); - cdsp.read(0, data, 0, 12); - return data; } - private static byte[] install64(String mapname, COPYDATASTRUCT64 cds) { - cds.dwData = AGENT_COPYDATA_ID; - cds.cbData = mapname.length() + 1; - cds.lpData = new Memory(mapname.length() + 1); - { - byte[] foo = Util.str2byte(mapname, StandardCharsets.US_ASCII); - cds.lpData.write(0, foo, 0, foo.length); - cds.lpData.setByte(foo.length, (byte) 0); - cds.write(); - } - byte[] data = new byte[24]; - Pointer cdsp = cds.getPointer(); - cdsp.read(0, data, 0, 24); - return data; + static COPYDATASTRUCT createCDS(String mapname) { + Memory foo = new Memory(mapname.length() + 1); + foo.setString(0, mapname, "US-ASCII"); + COPYDATASTRUCT cds = new COPYDATASTRUCT(); + cds.dwData = new ULONG_PTR(AGENT_COPYDATA_ID); + cds.cbData = (int) foo.size(); + cds.lpData = foo; + cds.write(); + return cds; } - long sendMessage(HWND hwnd, byte[] data) { - - return libU.SendMessage(hwnd, WinUser.WM_COPYDATA, null, data); + long sendMessage(HWND hwnd, COPYDATASTRUCT cds) { + LPARAM data = new LPARAM(Pointer.nativeValue(cds.getPointer())); + LRESULT result = user32.SendMessage(hwnd, WinUser.WM_COPYDATA, null, data); + return result.longValue(); } } From df05d913ee380b399ce6e7b3882faad96c572d69 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Sun, 26 Mar 2023 08:47:52 -0500 Subject: [PATCH 012/301] Remove now uneeded `_nouses` now that PageantConnector no longer exposes JNA. --- ChangeLog.md | 1 - pom.xml | 2 -- 2 files changed, 3 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 432ed944..ddec7b51 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -3,7 +3,6 @@ * Make JGSS module optional. * Tweak OSGi bundle manifest: * Avoid self-import. - * Avoid `uses:="com.sun.jna"` on export. * Mark JGSS as optional. * Loosen import versions of dependencies. * Correctly adhere to the Multi-release JAR spec by ensuring all public classes under versioned directories preside over classes present in the top-level directory. diff --git a/pom.xml b/pom.xml index b62775bb..19eb6a2e 100644 --- a/pom.xml +++ b/pom.xml @@ -392,8 +392,6 @@ com.jcraft.jsch;-noimport:=true - - <_nouses>true Date: Mon, 27 Mar 2023 05:41:20 -0500 Subject: [PATCH 013/301] Fix warnings with Java 20. --- pom.xml | 2 +- src/main/java/com/jcraft/jsch/Session.java | 2 +- src/main/java/com/jcraft/jsch/jbcrypt/BCrypt.java | 6 +++--- src/main/java/com/jcraft/jsch/jce/SignatureDSA.java | 8 ++++---- src/main/java/com/jcraft/jsch/jzlib/Deflate.java | 8 ++++---- src/main/java/com/jcraft/jsch/jzlib/Tree.java | 2 +- src/main/java15/com/jcraft/jsch/jce/KeyPairGenEdDSA.java | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/pom.xml b/pom.xml index 19eb6a2e..52fd0daa 100644 --- a/pom.xml +++ b/pom.xml @@ -314,7 +314,7 @@ true true - -Xlint:all,-processing,-classfile + -Xlint:all,-processing,-classfile,-options diff --git a/src/main/java/com/jcraft/jsch/Session.java b/src/main/java/com/jcraft/jsch/Session.java index 1ba845d7..39668d99 100644 --- a/src/main/java/com/jcraft/jsch/Session.java +++ b/src/main/java/com/jcraft/jsch/Session.java @@ -1554,7 +1554,7 @@ private byte[] expandKey(Buffer buf, byte[] K, byte[] H, byte[] key, HASH hash, } command = packet.buffer.getCommand(); recipient = c.getRecipient(); - length -= len; + length -= (int) len; c.rwsize -= len; sendit = true; } diff --git a/src/main/java/com/jcraft/jsch/jbcrypt/BCrypt.java b/src/main/java/com/jcraft/jsch/jbcrypt/BCrypt.java index c3741aec..4f4dab88 100644 --- a/src/main/java/com/jcraft/jsch/jbcrypt/BCrypt.java +++ b/src/main/java/com/jcraft/jsch/jbcrypt/BCrypt.java @@ -325,7 +325,7 @@ private static byte[] decode_base64(String s, int maxolen) throws IllegalArgumen if (c1 == -1 || c2 == -1) break; o = (byte) (c1 << 2); - o |= (c2 & 0x30) >> 4; + o |= (byte) ((c2 & 0x30) >> 4); rs.append((char) o); if (++olen >= maxolen || off >= slen) break; @@ -333,7 +333,7 @@ private static byte[] decode_base64(String s, int maxolen) throws IllegalArgumen if (c3 == -1) break; o = (byte) ((c2 & 0x0f) << 4); - o |= (c3 & 0x3c) >> 2; + o |= (byte) ((c3 & 0x3c) >> 2); rs.append((char) o); if (++olen >= maxolen || off >= slen) break; @@ -710,7 +710,7 @@ public static boolean checkpw(String plaintext, String hashed) { return false; byte ret = 0; for (int i = 0; i < try_bytes.length; i++) - ret |= hashed_bytes[i] ^ try_bytes[i]; + ret |= (byte) (hashed_bytes[i] ^ try_bytes[i]); return ret == 0; } } diff --git a/src/main/java/com/jcraft/jsch/jce/SignatureDSA.java b/src/main/java/com/jcraft/jsch/jce/SignatureDSA.java index fbbe11b0..7a62612a 100644 --- a/src/main/java/com/jcraft/jsch/jce/SignatureDSA.java +++ b/src/main/java/com/jcraft/jsch/jce/SignatureDSA.java @@ -131,15 +131,15 @@ public boolean verify(byte[] sig) throws Exception { tmp = new byte[length]; tmp[0] = (byte) 0x30; tmp[1] = (byte) (_frst.length + _scnd.length + 4); - tmp[1] += frst; - tmp[1] += scnd; + tmp[1] += (byte) frst; + tmp[1] += (byte) scnd; tmp[2] = (byte) 0x02; tmp[3] = (byte) _frst.length; - tmp[3] += frst; + tmp[3] += (byte) frst; System.arraycopy(_frst, 0, tmp, 4 + frst, _frst.length); tmp[4 + tmp[3]] = (byte) 0x02; tmp[5 + tmp[3]] = (byte) _scnd.length; - tmp[5 + tmp[3]] += scnd; + tmp[5 + tmp[3]] += (byte) scnd; System.arraycopy(_scnd, 0, tmp, 6 + tmp[3] + scnd, _scnd.length); sig = tmp; diff --git a/src/main/java/com/jcraft/jsch/jzlib/Deflate.java b/src/main/java/com/jcraft/jsch/jzlib/Deflate.java index e2dd7068..b79b22cc 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/Deflate.java +++ b/src/main/java/com/jcraft/jsch/jzlib/Deflate.java @@ -435,7 +435,7 @@ void scan_tree(short[] tree, // the tree to be scanned if (++count < max_count && curlen == nextlen) { continue; } else if (count < min_count) { - bl_tree[curlen * 2] += count; + bl_tree[curlen * 2] += (short) count; } else if (curlen != 0) { if (curlen != prevlen) bl_tree[curlen * 2]++; @@ -591,13 +591,13 @@ void send_bits(int value, int length) { if (bi_valid > Buf_size - len) { int val = value; // bi_buf |= (val << bi_valid); - bi_buf |= ((val << bi_valid) & 0xffff); + bi_buf |= (short) ((val << bi_valid) & 0xffff); put_short(bi_buf); bi_buf = (short) (val >>> (Buf_size - bi_valid)); bi_valid += len - Buf_size; } else { // bi_buf |= (value) << bi_valid; - bi_buf |= (((value) << bi_valid) & 0xffff); + bi_buf |= (short) (((value) << bi_valid) & 0xffff); bi_valid += len; } } @@ -659,7 +659,7 @@ boolean _tr_tally(int dist, // distance of matched string int in_length = strstart - block_start; int dcode; for (dcode = 0; dcode < D_CODES; dcode++) { - out_length += (int) dyn_dtree[dcode * 2] * (5L + Tree.extra_dbits[dcode]); + out_length += (int) dyn_dtree[dcode * 2] * (5 + Tree.extra_dbits[dcode]); } out_length >>>= 3; if ((matches < (last_lit / 2)) && out_length < in_length / 2) diff --git a/src/main/java/com/jcraft/jsch/jzlib/Tree.java b/src/main/java/com/jcraft/jsch/jzlib/Tree.java index 261311eb..abb55a4e 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/Tree.java +++ b/src/main/java/com/jcraft/jsch/jzlib/Tree.java @@ -205,7 +205,7 @@ void gen_bitlen(Deflate s) { if (m > max_code) continue; if (tree[m * 2 + 1] != bits) { - s.opt_len += ((long) bits - (long) tree[m * 2 + 1]) * (long) tree[m * 2]; + s.opt_len += (int) (((long) bits - (long) tree[m * 2 + 1]) * (long) tree[m * 2]); tree[m * 2 + 1] = (short) bits; } n--; diff --git a/src/main/java15/com/jcraft/jsch/jce/KeyPairGenEdDSA.java b/src/main/java15/com/jcraft/jsch/jce/KeyPairGenEdDSA.java index cf648614..100bd095 100644 --- a/src/main/java15/com/jcraft/jsch/jce/KeyPairGenEdDSA.java +++ b/src/main/java15/com/jcraft/jsch/jce/KeyPairGenEdDSA.java @@ -50,7 +50,7 @@ public void init(String name, int keylen) throws Exception { prv = prvKey.getBytes().get(); pub = rotate(point.getY().toByteArray()); if (point.isXOdd()) { - pub[pub.length - 1] |= 0x80; + pub[pub.length - 1] |= (byte) 0x80; } } From d81bcffefbb05a7588fbc33c719ba3ac9b9bf2e1 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Tue, 28 Mar 2023 13:57:36 -0500 Subject: [PATCH 014/301] Add error_prone_annotations to dependencyManagement to keep aligned with errorprone profile version. --- pom.xml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 52fd0daa..f0f0e2f3 100644 --- a/pom.xml +++ b/pom.xml @@ -80,6 +80,7 @@ 2.6.2 5.13.0 2.20.0 + 2.18.0 3.0.0 @@ -222,6 +223,15 @@ test + + + + com.google.errorprone + error_prone_annotations + ${errorprone.version} + + + @@ -715,7 +725,7 @@ com.google.errorprone error_prone_core - 2.18.0 + ${errorprone.version} From 6d583ce63da7a81a9724f473aefa34b9e4b6bb1e Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Tue, 28 Mar 2023 14:07:07 -0500 Subject: [PATCH 015/301] Add missing java10 source directory. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f0f0e2f3..a397c8bb 100644 --- a/pom.xml +++ b/pom.xml @@ -522,7 +522,7 @@ none com.jcraft.jsch com.jcraft.jsch.* - ${project.build.sourceDirectory}:${project.build.directory}/generated-sources/java-templates:${project.basedir}/src/main/java9:${project.basedir}/src/main/java11:${project.basedir}/src/main/java15:${project.basedir}/src/main/java16 + ${project.build.sourceDirectory}:${project.build.directory}/generated-sources/java-templates:${project.basedir}/src/main/java9:${project.basedir}/src/main/java10:${project.basedir}/src/main/java11:${project.basedir}/src/main/java15:${project.basedir}/src/main/java16 From 81463409e4b27c6f60fedb219e41065ee0673ce2 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Wed, 29 Mar 2023 12:53:07 -0500 Subject: [PATCH 016/301] Use try-with-resources. --- .../java/com/jcraft/jsch/ChannelSftp.java | 21 +++---------------- src/main/java/com/jcraft/jsch/KeyPair.java | 18 ++++++++-------- src/main/java/com/jcraft/jsch/KnownHosts.java | 11 ++-------- src/main/java/com/jcraft/jsch/Util.java | 8 ++----- 4 files changed, 16 insertions(+), 42 deletions(-) diff --git a/src/main/java/com/jcraft/jsch/ChannelSftp.java b/src/main/java/com/jcraft/jsch/ChannelSftp.java index 849f0e3b..c06d1a7f 100644 --- a/src/main/java/com/jcraft/jsch/ChannelSftp.java +++ b/src/main/java/com/jcraft/jsch/ChannelSftp.java @@ -432,14 +432,8 @@ public void put(String src, String dst, SftpProgressMonitor monitor, int mode) monitor.count(size_of_dst); } } - FileInputStream fis = null; - try { - fis = new FileInputStream(_src); + try (InputStream fis = new FileInputStream(_src)) { _put(fis, _dst, monitor, mode); - } finally { - if (fis != null) { - fis.close(); - } } } } catch (Exception e) { @@ -931,20 +925,11 @@ public void get(String src, String dst, SftpProgressMonitor monitor, int mode) } } - FileOutputStream fos = null; _dstExist = _dstFile.exists(); - try { - if (mode == OVERWRITE) { - fos = new FileOutputStream(_dst); - } else { - fos = new FileOutputStream(_dst, true); // append - } + try (OutputStream fos = mode == OVERWRITE ? new FileOutputStream(_dst) + : new FileOutputStream(_dst, true) /* append */) { // System.err.println("_get: "+_src+", "+_dst); _get(_src, fos, monitor, mode, new File(_dst).length()); - } finally { - if (fos != null) { - fos.close(); - } } } } catch (Exception e) { diff --git a/src/main/java/com/jcraft/jsch/KeyPair.java b/src/main/java/com/jcraft/jsch/KeyPair.java index f6826bec..e4b8ff61 100644 --- a/src/main/java/com/jcraft/jsch/KeyPair.java +++ b/src/main/java/com/jcraft/jsch/KeyPair.java @@ -249,9 +249,9 @@ public void writePublicKey(OutputStream out, String comment) { */ public void writePublicKey(String name, String comment) throws FileNotFoundException, IOException { - FileOutputStream fos = new FileOutputStream(name); - writePublicKey(fos, comment); - fos.close(); + try (OutputStream fos = new FileOutputStream(name)) { + writePublicKey(fos, comment); + } } /** @@ -297,9 +297,9 @@ public void writeSECSHPublicKey(OutputStream out, String comment) { */ public void writeSECSHPublicKey(String name, String comment) throws FileNotFoundException, IOException { - FileOutputStream fos = new FileOutputStream(name); - writeSECSHPublicKey(fos, comment); - fos.close(); + try (OutputStream fos = new FileOutputStream(name)) { + writeSECSHPublicKey(fos, comment); + } } /** @@ -321,9 +321,9 @@ public void writePrivateKey(String name) throws FileNotFoundException, IOExcepti */ public void writePrivateKey(String name, byte[] passphrase) throws FileNotFoundException, IOException { - FileOutputStream fos = new FileOutputStream(name); - writePrivateKey(fos, passphrase); - fos.close(); + try (OutputStream fos = new FileOutputStream(name)) { + writePrivateKey(fos, passphrase); + } } /** diff --git a/src/main/java/com/jcraft/jsch/KnownHosts.java b/src/main/java/com/jcraft/jsch/KnownHosts.java index 86e60f26..950c19ee 100644 --- a/src/main/java/com/jcraft/jsch/KnownHosts.java +++ b/src/main/java/com/jcraft/jsch/KnownHosts.java @@ -54,7 +54,7 @@ class KnownHosts implements HostKeyRepository { void setKnownHosts(String filename) throws JSchException { try { known_hosts = filename; - FileInputStream fis = new FileInputStream(Util.checkTilde(filename)); + InputStream fis = new FileInputStream(Util.checkTilde(filename)); setKnownHosts(fis); } catch (FileNotFoundException e) { // The non-existing file should be allowed. @@ -67,8 +67,7 @@ void setKnownHosts(InputStream input) throws JSchException { byte i; int j; boolean error = false; - try { - InputStream fis = input; + try (InputStream fis = input) { String host; String key = null; int type; @@ -265,12 +264,6 @@ void setKnownHosts(InputStream input) throws JSchException { if (e instanceof JSchException) throw (JSchException) e; throw new JSchException(e.toString(), e); - } finally { - try { - input.close(); - } catch (IOException e) { - throw new JSchException(e.toString(), e); - } } } diff --git a/src/main/java/com/jcraft/jsch/Util.java b/src/main/java/com/jcraft/jsch/Util.java index 03aefbb2..85628a19 100644 --- a/src/main/java/com/jcraft/jsch/Util.java +++ b/src/main/java/com/jcraft/jsch/Util.java @@ -29,6 +29,7 @@ import java.net.Socket; import java.io.File; import java.io.FileInputStream; +import java.io.InputStream; import java.io.IOException; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; @@ -512,8 +513,7 @@ private static int skipUTF8Char(byte b) { static byte[] fromFile(String _file) throws IOException { _file = checkTilde(_file); File file = new File(_file); - FileInputStream fis = new FileInputStream(_file); - try { + try (InputStream fis = new FileInputStream(_file)) { byte[] result = new byte[(int) (file.length())]; int len = 0; while (true) { @@ -522,11 +522,7 @@ static byte[] fromFile(String _file) throws IOException { break; len += i; } - fis.close(); return result; - } finally { - if (fis != null) - fis.close(); } } From f42eefa8039cabcbb36ca8b0cba70deff80cd0d1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Apr 2023 20:00:55 +0000 Subject: [PATCH 017/301] Bump jacoco-maven-plugin from 0.8.8 to 0.8.9 Bumps [jacoco-maven-plugin](https://github.com/jacoco/jacoco) from 0.8.8 to 0.8.9. - [Release notes](https://github.com/jacoco/jacoco/releases) - [Commits](https://github.com/jacoco/jacoco/compare/v0.8.8...v0.8.9) --- updated-dependencies: - dependency-name: org.jacoco:jacoco-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a397c8bb..d3eea24e 100644 --- a/pom.xml +++ b/pom.xml @@ -624,7 +624,7 @@ org.jacoco jacoco-maven-plugin - 0.8.8 + 0.8.9 com/jcraft/jsch/JavaVersion.class From 8786cce0189b814b2765298a801fdcac78104b6b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Apr 2023 20:00:47 +0000 Subject: [PATCH 018/301] Bump flatten-maven-plugin from 1.4.0 to 1.4.1 Bumps [flatten-maven-plugin](https://github.com/mojohaus/flatten-maven-plugin) from 1.4.0 to 1.4.1. - [Release notes](https://github.com/mojohaus/flatten-maven-plugin/releases) - [Commits](https://github.com/mojohaus/flatten-maven-plugin/compare/1.4.0...1.4.1) --- updated-dependencies: - dependency-name: org.codehaus.mojo:flatten-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d3eea24e..570cafc1 100644 --- a/pom.xml +++ b/pom.xml @@ -261,7 +261,7 @@ org.codehaus.mojo flatten-maven-plugin - 1.4.0 + 1.4.1 ossrh all From ab615c1195388be0bbd1a5d41e90fb1cbf4fca1a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Apr 2023 20:00:52 +0000 Subject: [PATCH 019/301] Bump cyclonedx-maven-plugin from 2.7.5 to 2.7.6 Bumps [cyclonedx-maven-plugin](https://github.com/CycloneDX/cyclonedx-maven-plugin) from 2.7.5 to 2.7.6. - [Release notes](https://github.com/CycloneDX/cyclonedx-maven-plugin/releases) - [Commits](https://github.com/CycloneDX/cyclonedx-maven-plugin/compare/cyclonedx-maven-plugin-2.7.5...cyclonedx-maven-plugin-2.7.6) --- updated-dependencies: - dependency-name: org.cyclonedx:cyclonedx-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d3eea24e..a51f07d9 100644 --- a/pom.xml +++ b/pom.xml @@ -536,7 +536,7 @@ org.cyclonedx cyclonedx-maven-plugin - 2.7.5 + 2.7.6 From 80ca57af6cfd19dab4878744431ec31d68bd7040 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Apr 2023 20:00:58 +0000 Subject: [PATCH 020/301] Bump maven-enforcer-plugin from 3.2.1 to 3.3.0 Bumps [maven-enforcer-plugin](https://github.com/apache/maven-enforcer) from 3.2.1 to 3.3.0. - [Release notes](https://github.com/apache/maven-enforcer/releases) - [Commits](https://github.com/apache/maven-enforcer/compare/enforcer-3.2.1...enforcer-3.3.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-enforcer-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d3eea24e..9cf35c83 100644 --- a/pom.xml +++ b/pom.xml @@ -237,7 +237,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 3.2.1 + 3.3.0 enforce-java From fa6341fd855c4725cd317a5791cad5e211b2ec3a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Apr 2023 20:01:08 +0000 Subject: [PATCH 021/301] Bump junit-jupiter from 1.17.6 to 1.18.0 Bumps [junit-jupiter](https://github.com/testcontainers/testcontainers-java) from 1.17.6 to 1.18.0. - [Release notes](https://github.com/testcontainers/testcontainers-java/releases) - [Changelog](https://github.com/testcontainers/testcontainers-java/blob/main/CHANGELOG.md) - [Commits](https://github.com/testcontainers/testcontainers-java/compare/1.17.6...1.18.0) --- updated-dependencies: - dependency-name: org.testcontainers:junit-jupiter dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d3eea24e..efed1a87 100644 --- a/pom.xml +++ b/pom.xml @@ -135,7 +135,7 @@ org.testcontainers junit-jupiter - 1.17.6 + 1.18.0 test From 20f908ce4e71917259c99deb88dcd763281de6fe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Apr 2023 19:59:09 +0000 Subject: [PATCH 022/301] Bump bcprov-jdk18on from 1.72 to 1.73 Bumps [bcprov-jdk18on](https://github.com/bcgit/bc-java) from 1.72 to 1.73. - [Release notes](https://github.com/bcgit/bc-java/releases) - [Changelog](https://github.com/bcgit/bc-java/blob/master/docs/releasenotes.html) - [Commits](https://github.com/bcgit/bc-java/commits) --- updated-dependencies: - dependency-name: org.bouncycastle:bcprov-jdk18on dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 57d7348c..2118ae74 100644 --- a/pom.xml +++ b/pom.xml @@ -87,7 +87,7 @@ org.bouncycastle bcprov-jdk18on - 1.72 + 1.73 true From 837ff008a1e462e3d1e5f67ebae8328b4bf42135 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Apr 2023 19:59:53 +0000 Subject: [PATCH 023/301] Bump cyclonedx-maven-plugin from 2.7.6 to 2.7.7 Bumps [cyclonedx-maven-plugin](https://github.com/CycloneDX/cyclonedx-maven-plugin) from 2.7.6 to 2.7.7. - [Release notes](https://github.com/CycloneDX/cyclonedx-maven-plugin/releases) - [Commits](https://github.com/CycloneDX/cyclonedx-maven-plugin/compare/cyclonedx-maven-plugin-2.7.6...cyclonedx-maven-plugin-2.7.7) --- updated-dependencies: - dependency-name: org.cyclonedx:cyclonedx-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2118ae74..f347277d 100644 --- a/pom.xml +++ b/pom.xml @@ -536,7 +536,7 @@ org.cyclonedx cyclonedx-maven-plugin - 2.7.6 + 2.7.7 From b45a78d40c001dcc53e403bf951b0cac10f5a3b6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Apr 2023 20:00:00 +0000 Subject: [PATCH 024/301] Bump maven-checkstyle-plugin from 3.2.1 to 3.2.2 Bumps [maven-checkstyle-plugin](https://github.com/apache/maven-checkstyle-plugin) from 3.2.1 to 3.2.2. - [Release notes](https://github.com/apache/maven-checkstyle-plugin/releases) - [Commits](https://github.com/apache/maven-checkstyle-plugin/compare/maven-checkstyle-plugin-3.2.1...maven-checkstyle-plugin-3.2.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-checkstyle-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2118ae74..d1e03aa3 100644 --- a/pom.xml +++ b/pom.xml @@ -582,7 +582,7 @@ org.apache.maven.plugins maven-checkstyle-plugin - 3.2.1 + 3.2.2 true true From 36de05b9be0ff3afae34578dd6aee2f7b3247265 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 May 2023 20:08:03 +0000 Subject: [PATCH 025/301] Bump junit-jupiter from 5.9.2 to 5.9.3 Bumps [junit-jupiter](https://github.com/junit-team/junit5) from 5.9.2 to 5.9.3. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.9.2...r5.9.3) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index abd4512f..ccc85b34 100644 --- a/pom.xml +++ b/pom.xml @@ -129,7 +129,7 @@ org.junit.jupiter junit-jupiter - 5.9.2 + 5.9.3 test From fba34c4e5f438f21c9f4bef46a71c895958307e5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 May 2023 20:08:08 +0000 Subject: [PATCH 026/301] Bump cyclonedx-maven-plugin from 2.7.7 to 2.7.8 Bumps [cyclonedx-maven-plugin](https://github.com/CycloneDX/cyclonedx-maven-plugin) from 2.7.7 to 2.7.8. - [Release notes](https://github.com/CycloneDX/cyclonedx-maven-plugin/releases) - [Commits](https://github.com/CycloneDX/cyclonedx-maven-plugin/compare/cyclonedx-maven-plugin-2.7.7...cyclonedx-maven-plugin-2.7.8) --- updated-dependencies: - dependency-name: org.cyclonedx:cyclonedx-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index abd4512f..8a43faeb 100644 --- a/pom.xml +++ b/pom.xml @@ -536,7 +536,7 @@ org.cyclonedx cyclonedx-maven-plugin - 2.7.7 + 2.7.8 From f018d286b473cd59067d5f56e96a9a7f2544bc52 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 May 2023 20:08:12 +0000 Subject: [PATCH 027/301] Bump jacoco-maven-plugin from 0.8.9 to 0.8.10 Bumps [jacoco-maven-plugin](https://github.com/jacoco/jacoco) from 0.8.9 to 0.8.10. - [Release notes](https://github.com/jacoco/jacoco/releases) - [Commits](https://github.com/jacoco/jacoco/compare/v0.8.9...v0.8.10) --- updated-dependencies: - dependency-name: org.jacoco:jacoco-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index abd4512f..e7fafa1f 100644 --- a/pom.xml +++ b/pom.xml @@ -624,7 +624,7 @@ org.jacoco jacoco-maven-plugin - 0.8.9 + 0.8.10 com/jcraft/jsch/JavaVersion.class From 5eaad416b6bfdd8098a66be9ded893d1f84404ce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 May 2023 19:58:56 +0000 Subject: [PATCH 028/301] Bump surefire.version from 3.0.0 to 3.1.0 Bumps `surefire.version` from 3.0.0 to 3.1.0. Updates `maven-surefire-plugin` from 3.0.0 to 3.1.0 - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.0.0...surefire-3.1.0) Updates `maven-failsafe-plugin` from 3.0.0 to 3.1.0 - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.0.0...surefire-3.1.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.apache.maven.plugins:maven-failsafe-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 09aa3400..71d04bca 100644 --- a/pom.xml +++ b/pom.xml @@ -81,7 +81,7 @@ 5.13.0 2.20.0 2.18.0 - 3.0.0 + 3.1.0 From 80a832fd237a887e4dcf73d0b5a49a04d91a874e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 May 2023 19:59:03 +0000 Subject: [PATCH 029/301] Bump maven-gpg-plugin from 3.0.1 to 3.1.0 Bumps [maven-gpg-plugin](https://github.com/apache/maven-gpg-plugin) from 3.0.1 to 3.1.0. - [Commits](https://github.com/apache/maven-gpg-plugin/compare/maven-gpg-plugin-3.0.1...maven-gpg-plugin-3.1.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-gpg-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 09aa3400..cde6d6c0 100644 --- a/pom.xml +++ b/pom.xml @@ -557,7 +557,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.0.1 + 3.1.0 org.apache.maven.plugins From e2cd592a2b97a64606e2a6a5cba0a4ac1f292d9a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 May 2023 19:58:12 +0000 Subject: [PATCH 030/301] Bump junit-jupiter from 1.18.0 to 1.18.1 Bumps [junit-jupiter](https://github.com/testcontainers/testcontainers-java) from 1.18.0 to 1.18.1. - [Release notes](https://github.com/testcontainers/testcontainers-java/releases) - [Changelog](https://github.com/testcontainers/testcontainers-java/blob/main/CHANGELOG.md) - [Commits](https://github.com/testcontainers/testcontainers-java/compare/1.18.0...1.18.1) --- updated-dependencies: - dependency-name: org.testcontainers:junit-jupiter dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6c48cdc6..842beacc 100644 --- a/pom.xml +++ b/pom.xml @@ -135,7 +135,7 @@ org.testcontainers junit-jupiter - 1.18.0 + 1.18.1 test From 7eac9d05c59cdbd76286fa9c1c42c3db74173364 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 May 2023 19:58:17 +0000 Subject: [PATCH 031/301] Bump maven-assembly-plugin from 3.5.0 to 3.6.0 Bumps [maven-assembly-plugin](https://github.com/apache/maven-assembly-plugin) from 3.5.0 to 3.6.0. - [Commits](https://github.com/apache/maven-assembly-plugin/compare/maven-assembly-plugin-3.5.0...maven-assembly-plugin-3.6.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-assembly-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6c48cdc6..563648c7 100644 --- a/pom.xml +++ b/pom.xml @@ -497,7 +497,7 @@ org.apache.maven.plugins maven-assembly-plugin - 3.5.0 + 3.6.0 attach-sources From 1b3c8399eab859a957907af80fa90036b8a00db4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 May 2023 19:58:22 +0000 Subject: [PATCH 032/301] Bump build-helper-maven-plugin from 3.3.0 to 3.4.0 Bumps [build-helper-maven-plugin](https://github.com/mojohaus/build-helper-maven-plugin) from 3.3.0 to 3.4.0. - [Release notes](https://github.com/mojohaus/build-helper-maven-plugin/releases) - [Commits](https://github.com/mojohaus/build-helper-maven-plugin/compare/build-helper-maven-plugin-3.3.0...3.4.0) --- updated-dependencies: - dependency-name: org.codehaus.mojo:build-helper-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6c48cdc6..71ea168a 100644 --- a/pom.xml +++ b/pom.xml @@ -286,7 +286,7 @@ org.codehaus.mojo build-helper-maven-plugin - 3.3.0 + 3.4.0 From ee5c365bdfa40656d4834984a635aa558a228a0f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 May 2023 19:58:26 +0000 Subject: [PATCH 033/301] Bump flatten-maven-plugin from 1.4.1 to 1.5.0 Bumps [flatten-maven-plugin](https://github.com/mojohaus/flatten-maven-plugin) from 1.4.1 to 1.5.0. - [Release notes](https://github.com/mojohaus/flatten-maven-plugin/releases) - [Commits](https://github.com/mojohaus/flatten-maven-plugin/compare/1.4.1...1.5.0) --- updated-dependencies: - dependency-name: org.codehaus.mojo:flatten-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6c48cdc6..8116e05b 100644 --- a/pom.xml +++ b/pom.xml @@ -261,7 +261,7 @@ org.codehaus.mojo flatten-maven-plugin - 1.4.1 + 1.5.0 ossrh all From c22462ac358c04dd7178a40feaa9e5616c16a25d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 May 2023 19:58:35 +0000 Subject: [PATCH 034/301] Bump errorprone.version from 2.18.0 to 2.19.1 Bumps `errorprone.version` from 2.18.0 to 2.19.1. Updates `error_prone_annotations` from 2.18.0 to 2.19.1 - [Release notes](https://github.com/google/error-prone/releases) - [Commits](https://github.com/google/error-prone/compare/v2.18.0...v2.19.1) Updates `error_prone_core` from 2.18.0 to 2.19.1 - [Release notes](https://github.com/google/error-prone/releases) - [Commits](https://github.com/google/error-prone/compare/v2.18.0...v2.19.1) --- updated-dependencies: - dependency-name: com.google.errorprone:error_prone_annotations dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.google.errorprone:error_prone_core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6c48cdc6..35174b6b 100644 --- a/pom.xml +++ b/pom.xml @@ -80,7 +80,7 @@ 2.6.2 5.13.0 2.20.0 - 2.18.0 + 2.19.1 3.1.0 From 32d2550f36ceee5a551d41fc97e3a4e436de0d15 Mon Sep 17 00:00:00 2001 From: Stephan Siano Date: Wed, 24 May 2023 11:10:48 +0200 Subject: [PATCH 035/301] Improve error handling in InputStream.close() for SFTP channels Fixes https://github.com/mwiede/jsch/issues/330 --- src/main/java/com/jcraft/jsch/ChannelSftp.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/jcraft/jsch/ChannelSftp.java b/src/main/java/com/jcraft/jsch/ChannelSftp.java index c06d1a7f..f216db71 100644 --- a/src/main/java/com/jcraft/jsch/ChannelSftp.java +++ b/src/main/java/com/jcraft/jsch/ChannelSftp.java @@ -1495,8 +1495,10 @@ public void close() throws IOException { rq.cancel(header, buf); try { _sendCLOSE(handle, header); + } catch (IOException e) { + throw e; } catch (Exception e) { - throw new IOException("error"); + throw new IOException(e.toString(), e); } } }; From 40cb1319b78086a25b1d3809e09149149206bb03 Mon Sep 17 00:00:00 2001 From: release-bot Date: Thu, 25 May 2023 19:42:59 +0000 Subject: [PATCH 036/301] [maven-release-plugin] prepare release jsch-0.2.9 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 9b2aeb4c..35b37655 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.mwiede jsch jar - 0.2.9-SNAPSHOT + 0.2.9 JSch https://github.com/mwiede/jsch JSch is a pure Java implementation of SSH2 @@ -12,7 +12,7 @@ scm:git:https://github.com/mwiede/jsch.git scm:git:https://github.com/mwiede/jsch.git https://github.com/mwiede/jsch - HEAD + jsch-0.2.9 @@ -73,7 +73,7 @@ - 2023-03-22T06:53:17Z + 2023-05-25T19:41:45Z UTF-8 UTF-8 true From f2af11251f47a3560112c2691d27ed752d9a65bf Mon Sep 17 00:00:00 2001 From: release-bot Date: Thu, 25 May 2023 19:43:01 +0000 Subject: [PATCH 037/301] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 35b37655..3b0d6e7f 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.mwiede jsch jar - 0.2.9 + 0.2.10-SNAPSHOT JSch https://github.com/mwiede/jsch JSch is a pure Java implementation of SSH2 @@ -12,7 +12,7 @@ scm:git:https://github.com/mwiede/jsch.git scm:git:https://github.com/mwiede/jsch.git https://github.com/mwiede/jsch - jsch-0.2.9 + HEAD @@ -73,7 +73,7 @@ - 2023-05-25T19:41:45Z + 2023-05-25T19:43:01Z UTF-8 UTF-8 true From 1a460e47b9ce9ece8903c54f26614afe1c6a4976 Mon Sep 17 00:00:00 2001 From: Matthias Wiedemann Date: Thu, 25 May 2023 21:58:14 +0200 Subject: [PATCH 038/301] Update Readme.md --- Readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 21b87aeb..1e6f8260 100644 --- a/Readme.md +++ b/Readme.md @@ -33,7 +33,7 @@ with com.github.mwiede jsch - 0.2.8 + 0.2.9 ``` @@ -43,7 +43,7 @@ When you have an artifact `foo:bar`, which contains `com.jcraft:jsch` as a trans com.github.mwiede jsch - 0.2.8 + 0.2.9 foo From 2ec886652715f7b013e13ae9852f2a6d2c6bdd7c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 May 2023 19:58:52 +0000 Subject: [PATCH 039/301] Bump guava from 31.1-jre to 32.0.0-jre Bumps [guava](https://github.com/google/guava) from 31.1-jre to 32.0.0-jre. - [Release notes](https://github.com/google/guava/releases) - [Commits](https://github.com/google/guava/commits) --- updated-dependencies: - dependency-name: com.google.guava:guava dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3b0d6e7f..24adccf9 100644 --- a/pom.xml +++ b/pom.xml @@ -164,7 +164,7 @@ com.google.guava guava - 31.1-jre + 32.0.0-jre test From 3883e381395b7efb96cca59a0a3926b1868f826c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 May 2023 19:59:00 +0000 Subject: [PATCH 040/301] Bump maven-checkstyle-plugin from 3.2.2 to 3.3.0 Bumps [maven-checkstyle-plugin](https://github.com/apache/maven-checkstyle-plugin) from 3.2.2 to 3.3.0. - [Commits](https://github.com/apache/maven-checkstyle-plugin/compare/maven-checkstyle-plugin-3.2.2...maven-checkstyle-plugin-3.3.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-checkstyle-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3b0d6e7f..9dbb5b05 100644 --- a/pom.xml +++ b/pom.xml @@ -582,7 +582,7 @@ org.apache.maven.plugins maven-checkstyle-plugin - 3.2.2 + 3.3.0 true true From b4f57d32177368583f7943bbdaf33bae4e90f300 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 May 2023 19:59:10 +0000 Subject: [PATCH 041/301] Bump maven-dependency-plugin from 3.5.0 to 3.6.0 Bumps [maven-dependency-plugin](https://github.com/apache/maven-dependency-plugin) from 3.5.0 to 3.6.0. - [Commits](https://github.com/apache/maven-dependency-plugin/compare/maven-dependency-plugin-3.5.0...maven-dependency-plugin-3.6.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-dependency-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3b0d6e7f..b626534d 100644 --- a/pom.xml +++ b/pom.xml @@ -577,7 +577,7 @@ org.apache.maven.plugins maven-dependency-plugin - 3.5.0 + 3.6.0 org.apache.maven.plugins From ebc591c9b11bb54fdbcebad7fd918c05c4227f09 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 May 2023 19:59:18 +0000 Subject: [PATCH 042/301] Bump maven-bundle-plugin from 5.1.8 to 5.1.9 Bumps maven-bundle-plugin from 5.1.8 to 5.1.9. --- updated-dependencies: - dependency-name: org.apache.felix:maven-bundle-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3b0d6e7f..0d829001 100644 --- a/pom.xml +++ b/pom.xml @@ -398,7 +398,7 @@ org.apache.felix maven-bundle-plugin - 5.1.8 + 5.1.9 com.jcraft.jsch;-noimport:=true From 825440b1532d345bb6cd8ce7527532d9ec19632d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 May 2023 19:59:27 +0000 Subject: [PATCH 043/301] Bump cyclonedx-maven-plugin from 2.7.8 to 2.7.9 Bumps [cyclonedx-maven-plugin](https://github.com/CycloneDX/cyclonedx-maven-plugin) from 2.7.8 to 2.7.9. - [Release notes](https://github.com/CycloneDX/cyclonedx-maven-plugin/releases) - [Commits](https://github.com/CycloneDX/cyclonedx-maven-plugin/compare/cyclonedx-maven-plugin-2.7.8...cyclonedx-maven-plugin-2.7.9) --- updated-dependencies: - dependency-name: org.cyclonedx:cyclonedx-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3b0d6e7f..4c8c08ae 100644 --- a/pom.xml +++ b/pom.xml @@ -536,7 +536,7 @@ org.cyclonedx cyclonedx-maven-plugin - 2.7.8 + 2.7.9 From 8673fbeb0b4aa94329ad87e3d3746aa059ff8325 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Jun 2023 19:58:25 +0000 Subject: [PATCH 044/301] Bump junit-jupiter from 1.18.1 to 1.18.3 Bumps [junit-jupiter](https://github.com/testcontainers/testcontainers-java) from 1.18.1 to 1.18.3. - [Release notes](https://github.com/testcontainers/testcontainers-java/releases) - [Changelog](https://github.com/testcontainers/testcontainers-java/blob/main/CHANGELOG.md) - [Commits](https://github.com/testcontainers/testcontainers-java/compare/1.18.1...1.18.3) --- updated-dependencies: - dependency-name: org.testcontainers:junit-jupiter dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d356b4a8..9fd16042 100644 --- a/pom.xml +++ b/pom.xml @@ -135,7 +135,7 @@ org.testcontainers junit-jupiter - 1.18.1 + 1.18.3 test From 4fff7579f452399e565d1eaffccc18f35d3b2f85 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Jun 2023 19:58:31 +0000 Subject: [PATCH 045/301] Bump maven-release-plugin from 3.0.0 to 3.0.1 Bumps [maven-release-plugin](https://github.com/apache/maven-release) from 3.0.0 to 3.0.1. - [Release notes](https://github.com/apache/maven-release/releases) - [Commits](https://github.com/apache/maven-release/compare/maven-release-3.0.0...maven-release-3.0.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-release-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d356b4a8..73f1e2d5 100644 --- a/pom.xml +++ b/pom.xml @@ -548,7 +548,7 @@ org.apache.maven.plugins maven-release-plugin - 3.0.0 + 3.0.1 false release From 3526cb3a564990a4783c15246b2b4c90b7c9a9ce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Jun 2023 19:58:37 +0000 Subject: [PATCH 046/301] Bump formatter-maven-plugin from 2.22.0 to 2.23.0 Bumps [formatter-maven-plugin](https://github.com/revelc/formatter-maven-plugin) from 2.22.0 to 2.23.0. - [Changelog](https://github.com/revelc/formatter-maven-plugin/blob/formatter-maven-plugin-2.23.0/CHANGELOG.md) - [Commits](https://github.com/revelc/formatter-maven-plugin/compare/formatter-maven-plugin-2.22.0...formatter-maven-plugin-2.23.0) --- updated-dependencies: - dependency-name: net.revelc.code.formatter:formatter-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d356b4a8..0edff9fb 100644 --- a/pom.xml +++ b/pom.xml @@ -604,7 +604,7 @@ net.revelc.code.formatter formatter-maven-plugin - 2.22.0 + 2.23.0 ${project.basedir}/eclipse-java-google-style.xml UTF-8 From 66364b49ded4bb6bf321b963660aca2584d50afd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Jun 2023 19:58:37 +0000 Subject: [PATCH 047/301] Bump surefire.version from 3.1.0 to 3.1.2 Bumps `surefire.version` from 3.1.0 to 3.1.2. Updates `maven-surefire-plugin` from 3.1.0 to 3.1.2 - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.1.0...surefire-3.1.2) Updates `maven-failsafe-plugin` from 3.1.0 to 3.1.2 - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.1.0...surefire-3.1.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.maven.plugins:maven-failsafe-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cc5b789d..1e1f64a9 100644 --- a/pom.xml +++ b/pom.xml @@ -81,7 +81,7 @@ 5.13.0 2.20.0 2.19.1 - 3.1.0 + 3.1.2 From 12127b4be7b5ad79e3a12b32b2d67bc137148b98 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Jun 2023 19:58:41 +0000 Subject: [PATCH 048/301] Bump guava from 32.0.0-jre to 32.0.1-jre Bumps [guava](https://github.com/google/guava) from 32.0.0-jre to 32.0.1-jre. - [Release notes](https://github.com/google/guava/releases) - [Commits](https://github.com/google/guava/commits) --- updated-dependencies: - dependency-name: com.google.guava:guava dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cc5b789d..8455fa92 100644 --- a/pom.xml +++ b/pom.xml @@ -164,7 +164,7 @@ com.google.guava guava - 32.0.0-jre + 32.0.1-jre test From 3bbcbe25cd4b2157b4ea5bb800ab92c34d982cdd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Jun 2023 19:58:36 +0000 Subject: [PATCH 049/301] Bump bcprov-jdk18on from 1.73 to 1.74 Bumps [bcprov-jdk18on](https://github.com/bcgit/bc-java) from 1.73 to 1.74. - [Changelog](https://github.com/bcgit/bc-java/blob/main/docs/releasenotes.html) - [Commits](https://github.com/bcgit/bc-java/commits) --- updated-dependencies: - dependency-name: org.bouncycastle:bcprov-jdk18on dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cc5b789d..b1e8b893 100644 --- a/pom.xml +++ b/pom.xml @@ -87,7 +87,7 @@ org.bouncycastle bcprov-jdk18on - 1.73 + 1.74 true From 2b33ea896b6405ecffc3c183e732e790aad7db00 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 22 Jun 2023 19:28:27 +0000 Subject: [PATCH 050/301] Bump errorprone.version from 2.19.1 to 2.20.0 Bumps `errorprone.version` from 2.19.1 to 2.20.0. Updates `error_prone_annotations` from 2.19.1 to 2.20.0 - [Release notes](https://github.com/google/error-prone/releases) - [Commits](https://github.com/google/error-prone/compare/v2.19.1...v2.20.0) Updates `error_prone_core` from 2.19.1 to 2.20.0 - [Release notes](https://github.com/google/error-prone/releases) - [Commits](https://github.com/google/error-prone/compare/v2.19.1...v2.20.0) --- updated-dependencies: - dependency-name: com.google.errorprone:error_prone_annotations dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.google.errorprone:error_prone_core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a2157800..7000ae1c 100644 --- a/pom.xml +++ b/pom.xml @@ -80,7 +80,7 @@ 2.6.2 5.13.0 2.20.0 - 2.19.1 + 2.20.0 3.1.2 From 377024059cc4e0180bf5bfa6532284a9d143b168 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Jun 2023 19:57:57 +0000 Subject: [PATCH 051/301] Bump bcprov-jdk18on from 1.74 to 1.75 Bumps [bcprov-jdk18on](https://github.com/bcgit/bc-java) from 1.74 to 1.75. - [Changelog](https://github.com/bcgit/bc-java/blob/main/docs/releasenotes.html) - [Commits](https://github.com/bcgit/bc-java/commits) --- updated-dependencies: - dependency-name: org.bouncycastle:bcprov-jdk18on dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a2157800..4b8b62e5 100644 --- a/pom.xml +++ b/pom.xml @@ -87,7 +87,7 @@ org.bouncycastle bcprov-jdk18on - 1.74 + 1.75 true From da8db874f207d09241c5da91465418bc4430e6a5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Jun 2023 19:58:01 +0000 Subject: [PATCH 052/301] Bump maven-clean-plugin from 3.2.0 to 3.3.1 Bumps [maven-clean-plugin](https://github.com/apache/maven-clean-plugin) from 3.2.0 to 3.3.1. - [Release notes](https://github.com/apache/maven-clean-plugin/releases) - [Commits](https://github.com/apache/maven-clean-plugin/compare/maven-clean-plugin-3.2.0...maven-clean-plugin-3.3.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-clean-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a2157800..bf28af7c 100644 --- a/pom.xml +++ b/pom.xml @@ -449,7 +449,7 @@ org.apache.maven.plugins maven-clean-plugin - 3.2.0 + 3.3.1 org.apache.maven.plugins From 5abee7237d1bf11e58a7fe4f8bd5d9fd3c8ee1ac Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Jun 2023 19:58:07 +0000 Subject: [PATCH 053/301] Bump commons-codec from 1.15 to 1.16.0 Bumps [commons-codec](https://github.com/apache/commons-codec) from 1.15 to 1.16.0. - [Changelog](https://github.com/apache/commons-codec/blob/master/RELEASE-NOTES.txt) - [Commits](https://github.com/apache/commons-codec/compare/rel/commons-codec-1.15...rel/commons-codec-1.16.0) --- updated-dependencies: - dependency-name: commons-codec:commons-codec dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a2157800..669eaf70 100644 --- a/pom.xml +++ b/pom.xml @@ -152,7 +152,7 @@ commons-codec commons-codec - 1.15 + 1.16.0 test From 31e841c785601e31bfb0a3ca73cd2ea860a4d909 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Jul 2023 19:52:03 +0000 Subject: [PATCH 054/301] Bump guava from 32.0.1-jre to 32.1.1-jre Bumps [guava](https://github.com/google/guava) from 32.0.1-jre to 32.1.1-jre. - [Release notes](https://github.com/google/guava/releases) - [Commits](https://github.com/google/guava/commits) --- updated-dependencies: - dependency-name: com.google.guava:guava dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a2157800..781fe9fd 100644 --- a/pom.xml +++ b/pom.xml @@ -164,7 +164,7 @@ com.google.guava guava - 32.0.1-jre + 32.1.1-jre test From 194b65fb0d840f4944569872a508b4191aaf5c75 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Fri, 14 Jul 2023 18:31:42 -0500 Subject: [PATCH 055/301] Update dependencies. --- .mvn/wrapper/maven-wrapper.properties | 2 +- pom.xml | 2 +- .../java/com/jcraft/jsch/Slf4jLoggerTest.java | 33 ++++++++++++------- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index d8b2495a..6d3a5665 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -14,5 +14,5 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.1/apache-maven-3.9.1-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.3/apache-maven-3.9.3-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar diff --git a/pom.xml b/pom.xml index 19cf2a6d..aa9792e4 100644 --- a/pom.xml +++ b/pom.xml @@ -219,7 +219,7 @@ com.github.valfirst slf4j-test - 2.9.0 + 3.0.1 test diff --git a/src/test/java/com/jcraft/jsch/Slf4jLoggerTest.java b/src/test/java/com/jcraft/jsch/Slf4jLoggerTest.java index 17d661ec..5ea2a6d1 100644 --- a/src/test/java/com/jcraft/jsch/Slf4jLoggerTest.java +++ b/src/test/java/com/jcraft/jsch/Slf4jLoggerTest.java @@ -9,18 +9,29 @@ import com.github.valfirst.slf4jtest.TestLoggerFactory; import java.util.Arrays; import java.util.Collections; +import java.util.EnumSet; import java.util.List; import java.util.Optional; +import java.util.Set; import java.util.stream.Collectors; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import uk.org.lidalia.slf4jext.ConventionalLevelHierarchy; +import org.slf4j.event.Level; public class Slf4jLoggerTest { private static final TestLogger logger = TestLoggerFactory.getTestLogger(JSch.class); + private final Set OFF_LEVELS = EnumSet.noneOf(Level.class); + private final Set TRACE_LEVELS = + EnumSet.of(Level.TRACE, Level.DEBUG, Level.INFO, Level.WARN, Level.ERROR); + private final Set DEBUG_LEVELS = + EnumSet.of(Level.DEBUG, Level.INFO, Level.WARN, Level.ERROR); + private final Set INFO_LEVELS = EnumSet.of(Level.INFO, Level.WARN, Level.ERROR); + private final Set WARN_LEVELS = EnumSet.of(Level.WARN, Level.ERROR); + private final Set ERROR_LEVELS = EnumSet.of(Level.ERROR); + private final Exception testException = new Exception("dummy exception"); @BeforeEach @@ -37,7 +48,7 @@ public static void afterAll() { public void testIsEnabled() { Slf4jLogger sl = new Slf4jLogger(); - logger.setEnabledLevelsForAllThreads(ConventionalLevelHierarchy.DEBUG_LEVELS); + logger.setEnabledLevelsForAllThreads(DEBUG_LEVELS); assertTrue(sl.isEnabled(com.jcraft.jsch.Logger.DEBUG), "debug should be enabled"); assertTrue(sl.isEnabled(com.jcraft.jsch.Logger.ERROR), "error should be enabled"); assertTrue(sl.isEnabled(com.jcraft.jsch.Logger.FATAL), "fatal should be enabled"); @@ -45,7 +56,7 @@ public void testIsEnabled() { assertTrue(sl.isEnabled(com.jcraft.jsch.Logger.WARN), "warn should be enabled"); assertFalse(sl.isEnabled(-1), "trace should not be enabled"); - logger.setEnabledLevelsForAllThreads(ConventionalLevelHierarchy.ERROR_LEVELS); + logger.setEnabledLevelsForAllThreads(ERROR_LEVELS); assertFalse(sl.isEnabled(com.jcraft.jsch.Logger.DEBUG), "debug should not be enabled"); assertTrue(sl.isEnabled(com.jcraft.jsch.Logger.ERROR), "error should be enabled"); assertTrue(sl.isEnabled(com.jcraft.jsch.Logger.FATAL), "fatal should be enabled"); @@ -53,7 +64,7 @@ public void testIsEnabled() { assertFalse(sl.isEnabled(com.jcraft.jsch.Logger.WARN), "warn should not be enabled"); assertFalse(sl.isEnabled(-1), "trace should not be enabled"); - logger.setEnabledLevelsForAllThreads(ConventionalLevelHierarchy.INFO_LEVELS); + logger.setEnabledLevelsForAllThreads(INFO_LEVELS); assertFalse(sl.isEnabled(com.jcraft.jsch.Logger.DEBUG), "debug should not be enabled"); assertTrue(sl.isEnabled(com.jcraft.jsch.Logger.ERROR), "error should be enabled"); assertTrue(sl.isEnabled(com.jcraft.jsch.Logger.FATAL), "fatal should be enabled"); @@ -61,7 +72,7 @@ public void testIsEnabled() { assertTrue(sl.isEnabled(com.jcraft.jsch.Logger.WARN), "warn should be enabled"); assertFalse(sl.isEnabled(-1), "trace should not be enabled"); - logger.setEnabledLevelsForAllThreads(ConventionalLevelHierarchy.OFF_LEVELS); + logger.setEnabledLevelsForAllThreads(OFF_LEVELS); assertFalse(sl.isEnabled(com.jcraft.jsch.Logger.DEBUG), "debug should not be enabled"); assertFalse(sl.isEnabled(com.jcraft.jsch.Logger.ERROR), "error should not be enabled"); assertFalse(sl.isEnabled(com.jcraft.jsch.Logger.FATAL), "fatal should not be enabled"); @@ -69,7 +80,7 @@ public void testIsEnabled() { assertFalse(sl.isEnabled(com.jcraft.jsch.Logger.WARN), "warn should not be enabled"); assertFalse(sl.isEnabled(-1), "trace should not be enabled"); - logger.setEnabledLevelsForAllThreads(ConventionalLevelHierarchy.TRACE_LEVELS); + logger.setEnabledLevelsForAllThreads(TRACE_LEVELS); assertTrue(sl.isEnabled(com.jcraft.jsch.Logger.DEBUG), "debug should be enabled"); assertTrue(sl.isEnabled(com.jcraft.jsch.Logger.ERROR), "error should be enabled"); assertTrue(sl.isEnabled(com.jcraft.jsch.Logger.FATAL), "fatal should be enabled"); @@ -77,7 +88,7 @@ public void testIsEnabled() { assertTrue(sl.isEnabled(com.jcraft.jsch.Logger.WARN), "warn should be enabled"); assertTrue(sl.isEnabled(-1), "trace should be enabled"); - logger.setEnabledLevelsForAllThreads(ConventionalLevelHierarchy.WARN_LEVELS); + logger.setEnabledLevelsForAllThreads(WARN_LEVELS); assertFalse(sl.isEnabled(com.jcraft.jsch.Logger.DEBUG), "debug should not be enabled"); assertTrue(sl.isEnabled(com.jcraft.jsch.Logger.ERROR), "error should be enabled"); assertTrue(sl.isEnabled(com.jcraft.jsch.Logger.FATAL), "fatal should be enabled"); @@ -95,25 +106,25 @@ public void testLogging() { List> expectedExceptions = Arrays.asList(Optional.empty(), Optional.ofNullable(null), Optional.of(testException)); - logger.setEnabledLevelsForAllThreads(ConventionalLevelHierarchy.TRACE_LEVELS); + logger.setEnabledLevelsForAllThreads(TRACE_LEVELS); sl.log(-1, "debug message"); sl.log(-1, "debug message with null cause", null); sl.log(-1, "debug message with cause", testException); checkMessages(expectedMessages, expectedExceptions); - logger.setEnabledLevelsForAllThreads(ConventionalLevelHierarchy.TRACE_LEVELS); + logger.setEnabledLevelsForAllThreads(TRACE_LEVELS); sl.log(com.jcraft.jsch.Logger.FATAL, "debug message"); sl.log(com.jcraft.jsch.Logger.FATAL, "debug message with null cause", null); sl.log(com.jcraft.jsch.Logger.FATAL, "debug message with cause", testException); checkMessages(expectedMessages, expectedExceptions); - logger.setEnabledLevelsForAllThreads(ConventionalLevelHierarchy.ERROR_LEVELS); + logger.setEnabledLevelsForAllThreads(ERROR_LEVELS); sl.log(-1, "debug message"); sl.log(-1, "debug message with null cause", null); sl.log(-1, "debug message with cause", testException); checkMessages(Collections.emptyList(), Collections.emptyList()); - logger.setEnabledLevelsForAllThreads(ConventionalLevelHierarchy.ERROR_LEVELS); + logger.setEnabledLevelsForAllThreads(ERROR_LEVELS); sl.log(com.jcraft.jsch.Logger.FATAL, "debug message"); sl.log(com.jcraft.jsch.Logger.FATAL, "debug message with null cause", null); sl.log(com.jcraft.jsch.Logger.FATAL, "debug message with cause", testException); From ae1e4f6cd031b90af8b5c65589670ebdf4702802 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Sun, 16 Jul 2023 08:22:19 -0500 Subject: [PATCH 056/301] Fix new Java 21 compiler warning: `possible 'this' escape before subclass is fully initialized`. --- ChangeLog.md | 2 + .../jcraft/jsch/ChannelAgentForwarding.java | 6 +- .../jcraft/jsch/ChannelDirectStreamLocal.java | 6 +- .../com/jcraft/jsch/ChannelDirectTCPIP.java | 6 +- .../jcraft/jsch/ChannelForwardedTCPIP.java | 6 +- .../java/com/jcraft/jsch/ChannelSftp.java | 6 +- src/main/java/com/jcraft/jsch/ChannelX11.java | 6 +- .../java/com/jcraft/jsch/IdentityFile.java | 19 ++- src/main/java/com/jcraft/jsch/JSch.java | 35 +++-- src/main/java/com/jcraft/jsch/KeyPair.java | 121 ++++++++++-------- src/main/java/com/jcraft/jsch/KeyPairDSA.java | 30 ++--- .../java/com/jcraft/jsch/KeyPairECDSA.java | 33 ++--- .../java/com/jcraft/jsch/KeyPairEd25519.java | 12 +- .../java/com/jcraft/jsch/KeyPairEd448.java | 12 +- .../java/com/jcraft/jsch/KeyPairEdDSA.java | 28 ++-- .../java/com/jcraft/jsch/KeyPairPKCS8.java | 38 +++--- src/main/java/com/jcraft/jsch/KeyPairRSA.java | 32 ++--- .../jcraft/jsch/LocalIdentityRepository.java | 8 +- src/main/java/com/jcraft/jsch/Session.java | 2 +- .../com/jcraft/jsch/AbstractBufferMargin.java | 46 +++---- .../java/com/jcraft/jsch/KeyPairTest.java | 2 +- .../java/com/jcraft/jsch/PktSize128IT.java | 9 +- .../java/com/jcraft/jsch/PktSize160IT.java | 9 +- .../java/com/jcraft/jsch/PktSize192IT.java | 9 +- .../java/com/jcraft/jsch/PktSize32768IT.java | 9 +- 25 files changed, 261 insertions(+), 231 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index ddec7b51..500abf19 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,5 @@ +* [0.2.10](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.10) + * Fix new Java 21 compiler warning: `possible 'this' escape before subclass is fully initialized`. * [0.2.9](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.9) * [#293](https://github.com/mwiede/jsch/issues/293) allow UserAuthNone to be extended. * Make JGSS module optional. diff --git a/src/main/java/com/jcraft/jsch/ChannelAgentForwarding.java b/src/main/java/com/jcraft/jsch/ChannelAgentForwarding.java index 64d788f2..eab9cbdb 100644 --- a/src/main/java/com/jcraft/jsch/ChannelAgentForwarding.java +++ b/src/main/java/com/jcraft/jsch/ChannelAgentForwarding.java @@ -66,9 +66,9 @@ class ChannelAgentForwarding extends Channel { ChannelAgentForwarding() { super(); - setLocalWindowSizeMax(LOCAL_WINDOW_SIZE_MAX); - setLocalWindowSize(LOCAL_WINDOW_SIZE_MAX); - setLocalPacketSize(LOCAL_MAXIMUM_PACKET_SIZE); + lwsize_max = LOCAL_WINDOW_SIZE_MAX; + lwsize = LOCAL_WINDOW_SIZE_MAX; + lmpsize = LOCAL_MAXIMUM_PACKET_SIZE; type = Util.str2byte("auth-agent@openssh.com"); rbuf = new Buffer(); diff --git a/src/main/java/com/jcraft/jsch/ChannelDirectStreamLocal.java b/src/main/java/com/jcraft/jsch/ChannelDirectStreamLocal.java index 1eef14e0..14f72c89 100644 --- a/src/main/java/com/jcraft/jsch/ChannelDirectStreamLocal.java +++ b/src/main/java/com/jcraft/jsch/ChannelDirectStreamLocal.java @@ -18,9 +18,9 @@ public class ChannelDirectStreamLocal extends ChannelDirectTCPIP { ChannelDirectStreamLocal() { super(); type = _type; - setLocalWindowSizeMax(LOCAL_WINDOW_SIZE_MAX); - setLocalWindowSize(LOCAL_WINDOW_SIZE_MAX); - setLocalPacketSize(LOCAL_MAXIMUM_PACKET_SIZE); + lwsize_max = LOCAL_WINDOW_SIZE_MAX; + lwsize = LOCAL_WINDOW_SIZE_MAX; + lmpsize = LOCAL_MAXIMUM_PACKET_SIZE; } @Override diff --git a/src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java b/src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java index 9465c7ae..a357a773 100644 --- a/src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java +++ b/src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java @@ -42,9 +42,9 @@ public class ChannelDirectTCPIP extends Channel { ChannelDirectTCPIP() { super(); type = _type; - setLocalWindowSizeMax(LOCAL_WINDOW_SIZE_MAX); - setLocalWindowSize(LOCAL_WINDOW_SIZE_MAX); - setLocalPacketSize(LOCAL_MAXIMUM_PACKET_SIZE); + lwsize_max = LOCAL_WINDOW_SIZE_MAX; + lwsize = LOCAL_WINDOW_SIZE_MAX; + lmpsize = LOCAL_MAXIMUM_PACKET_SIZE; } @Override diff --git a/src/main/java/com/jcraft/jsch/ChannelForwardedTCPIP.java b/src/main/java/com/jcraft/jsch/ChannelForwardedTCPIP.java index 5ec0805d..dad614b5 100644 --- a/src/main/java/com/jcraft/jsch/ChannelForwardedTCPIP.java +++ b/src/main/java/com/jcraft/jsch/ChannelForwardedTCPIP.java @@ -46,9 +46,9 @@ public class ChannelForwardedTCPIP extends Channel { ChannelForwardedTCPIP() { super(); - setLocalWindowSizeMax(LOCAL_WINDOW_SIZE_MAX); - setLocalWindowSize(LOCAL_WINDOW_SIZE_MAX); - setLocalPacketSize(LOCAL_MAXIMUM_PACKET_SIZE); + lwsize_max = LOCAL_WINDOW_SIZE_MAX; + lwsize = LOCAL_WINDOW_SIZE_MAX; + lmpsize = LOCAL_MAXIMUM_PACKET_SIZE; io = new IO(); connected = true; } diff --git a/src/main/java/com/jcraft/jsch/ChannelSftp.java b/src/main/java/com/jcraft/jsch/ChannelSftp.java index f216db71..c3dd3ac7 100644 --- a/src/main/java/com/jcraft/jsch/ChannelSftp.java +++ b/src/main/java/com/jcraft/jsch/ChannelSftp.java @@ -183,9 +183,9 @@ public int getBulkRequests() { public ChannelSftp() { super(); - setLocalWindowSizeMax(LOCAL_WINDOW_SIZE_MAX); - setLocalWindowSize(LOCAL_WINDOW_SIZE_MAX); - setLocalPacketSize(LOCAL_MAXIMUM_PACKET_SIZE); + lwsize_max = LOCAL_WINDOW_SIZE_MAX; + lwsize = LOCAL_WINDOW_SIZE_MAX; + lmpsize = LOCAL_MAXIMUM_PACKET_SIZE; } @Override diff --git a/src/main/java/com/jcraft/jsch/ChannelX11.java b/src/main/java/com/jcraft/jsch/ChannelX11.java index cbc442e9..7135eece 100644 --- a/src/main/java/com/jcraft/jsch/ChannelX11.java +++ b/src/main/java/com/jcraft/jsch/ChannelX11.java @@ -114,9 +114,9 @@ static void removeFakedCookie(Session session) { ChannelX11() { super(); - setLocalWindowSizeMax(LOCAL_WINDOW_SIZE_MAX); - setLocalWindowSize(LOCAL_WINDOW_SIZE_MAX); - setLocalPacketSize(LOCAL_MAXIMUM_PACKET_SIZE); + lwsize_max = LOCAL_WINDOW_SIZE_MAX; + lwsize = LOCAL_WINDOW_SIZE_MAX; + lmpsize = LOCAL_MAXIMUM_PACKET_SIZE; type = Util.str2byte("x11"); diff --git a/src/main/java/com/jcraft/jsch/IdentityFile.java b/src/main/java/com/jcraft/jsch/IdentityFile.java index 6c804bfc..89555674 100644 --- a/src/main/java/com/jcraft/jsch/IdentityFile.java +++ b/src/main/java/com/jcraft/jsch/IdentityFile.java @@ -29,24 +29,23 @@ import java.io.*; class IdentityFile implements Identity { - private JSch jsch; private KeyPair kpair; private String identity; - static IdentityFile newInstance(String prvfile, String pubfile, JSch jsch) throws JSchException { - KeyPair kpair = KeyPair.load(jsch, prvfile, pubfile); - return new IdentityFile(jsch, prvfile, kpair); + static IdentityFile newInstance(String prvfile, String pubfile, JSch.InstanceLogger instLogger) + throws JSchException { + KeyPair kpair = KeyPair.load(instLogger, prvfile, pubfile); + return new IdentityFile(prvfile, kpair); } - static IdentityFile newInstance(String name, byte[] prvkey, byte[] pubkey, JSch jsch) - throws JSchException { + static IdentityFile newInstance(String name, byte[] prvkey, byte[] pubkey, + JSch.InstanceLogger instLogger) throws JSchException { - KeyPair kpair = KeyPair.load(jsch, prvkey, pubkey); - return new IdentityFile(jsch, name, kpair); + KeyPair kpair = KeyPair.load(instLogger, prvkey, pubkey); + return new IdentityFile(name, kpair); } - private IdentityFile(JSch jsch, String name, KeyPair kpair) throws JSchException { - this.jsch = jsch; + private IdentityFile(String name, KeyPair kpair) throws JSchException { this.identity = name; this.kpair = kpair; } diff --git a/src/main/java/com/jcraft/jsch/JSch.java b/src/main/java/com/jcraft/jsch/JSch.java index d70f964e..575a94fc 100644 --- a/src/main/java/com/jcraft/jsch/JSch.java +++ b/src/main/java/com/jcraft/jsch/JSch.java @@ -242,9 +242,11 @@ public class JSch { config.put("ClearAllForwardings", "no"); } + final InstanceLogger instLogger = new InstanceLogger(); + private Vector sessionPool = new Vector<>(); - private IdentityRepository defaultIdentityRepository = new LocalIdentityRepository(this); + private IdentityRepository defaultIdentityRepository = new LocalIdentityRepository(instLogger); private IdentityRepository identityRepository = defaultIdentityRepository; @@ -291,7 +293,6 @@ public boolean isEnabled(int level) { public void log(int level, String message) {} }; static Logger logger = DEVNULL; - private Logger instLogger; public JSch() {} @@ -480,7 +481,7 @@ public void addIdentity(String prvkey, String passphrase) throws JSchException { * @see #addIdentity(String prvkey, String pubkey, byte[] passphrase) */ public void addIdentity(String prvkey, byte[] passphrase) throws JSchException { - Identity identity = IdentityFile.newInstance(prvkey, null, this); + Identity identity = IdentityFile.newInstance(prvkey, null, instLogger); addIdentity(identity, passphrase); } @@ -495,7 +496,7 @@ public void addIdentity(String prvkey, byte[] passphrase) throws JSchException { * @throws JSchException if passphrase is not right. */ public void addIdentity(String prvkey, String pubkey, byte[] passphrase) throws JSchException { - Identity identity = IdentityFile.newInstance(prvkey, pubkey, this); + Identity identity = IdentityFile.newInstance(prvkey, pubkey, instLogger); addIdentity(identity, passphrase); } @@ -511,7 +512,7 @@ public void addIdentity(String prvkey, String pubkey, byte[] passphrase) throws */ public void addIdentity(String name, byte[] prvkey, byte[] pubkey, byte[] passphrase) throws JSchException { - Identity identity = IdentityFile.newInstance(name, prvkey, pubkey, this); + Identity identity = IdentityFile.newInstance(name, prvkey, pubkey, instLogger); addIdentity(identity, passphrase); } @@ -669,10 +670,7 @@ public static void setLogger(Logger logger) { * statically set logger is returned. */ public Logger getInstanceLogger() { - if (this.instLogger == null) { - return logger; - } - return instLogger; + return instLogger.getLogger(); } /** @@ -682,7 +680,7 @@ public Logger getInstanceLogger() { * used */ public void setInstanceLogger(Logger logger) { - this.instLogger = logger; + instLogger.setLogger(logger); } /** @@ -694,4 +692,21 @@ public void setInstanceLogger(Logger logger) { public static Logger getLogger() { return logger; } + + static class InstanceLogger { + private Logger logger; + + private InstanceLogger() {} + + Logger getLogger() { + if (logger == null) { + return JSch.logger; + } + return logger; + } + + void setLogger(Logger logger) { + this.logger = logger; + } + } } diff --git a/src/main/java/com/jcraft/jsch/KeyPair.java b/src/main/java/com/jcraft/jsch/KeyPair.java index e4b8ff61..cd258739 100644 --- a/src/main/java/com/jcraft/jsch/KeyPair.java +++ b/src/main/java/com/jcraft/jsch/KeyPair.java @@ -64,15 +64,15 @@ public static KeyPair genKeyPair(JSch jsch, int type) throws JSchException { public static KeyPair genKeyPair(JSch jsch, int type, int key_size) throws JSchException { KeyPair kpair = null; if (type == DSA) { - kpair = new KeyPairDSA(jsch); + kpair = new KeyPairDSA(jsch.instLogger); } else if (type == RSA) { - kpair = new KeyPairRSA(jsch); + kpair = new KeyPairRSA(jsch.instLogger); } else if (type == ECDSA) { - kpair = new KeyPairECDSA(jsch); + kpair = new KeyPairECDSA(jsch.instLogger); } else if (type == ED25519) { - kpair = new KeyPairEd25519(jsch); + kpair = new KeyPairEd25519(jsch.instLogger); } else if (type == ED448) { - kpair = new KeyPairEd448(jsch); + kpair = new KeyPairEd448(jsch.instLogger); } if (kpair != null) { kpair.generate(key_size); @@ -108,7 +108,7 @@ public void setPublicKeyComment(String publicKeyComment) { protected String publicKeyComment = "no comment"; - JSch jsch = null; + JSch.InstanceLogger instLogger; protected Cipher cipher; private KDF kdf; private HASH sha1; @@ -118,7 +118,11 @@ public void setPublicKeyComment(String publicKeyComment) { private byte[] passphrase; public KeyPair(JSch jsch) { - this.jsch = jsch; + this(jsch.instLogger); + } + + KeyPair(JSch.InstanceLogger instLogger) { + this.instLogger = instLogger; } static byte[][] header = @@ -184,8 +188,8 @@ public void writePrivateKey(OutputStream out, byte[] passphrase) { out.write(cr); // out.close(); } catch (Exception e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to write private key", e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to write private key", e); } } } @@ -234,8 +238,8 @@ public void writePublicKey(OutputStream out, String comment) { out.write(Util.str2byte(comment)); out.write(cr); } catch (Exception e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to write public key", e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to write public key", e); } } } @@ -281,8 +285,8 @@ public void writeSECSHPublicKey(OutputStream out, String comment) { out.write(Util.str2byte("---- END SSH2 PUBLIC KEY ----")); out.write(cr); } catch (Exception e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to write public key", e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to write public key", e); } } } @@ -372,8 +376,8 @@ private byte[] encrypt(byte[] plain, byte[][] _iv, byte[] passphrase) { cipher.init(Cipher.ENCRYPT_MODE, key, iv); cipher.update(encoded, 0, encoded.length, encoded, 0); } catch (Exception e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to encrypt key", e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to encrypt key", e); } } Util.bzero(key); @@ -392,8 +396,8 @@ private byte[] decrypt(byte[] data, byte[] passphrase, byte[] iv) { cipher.update(data, 0, data.length, plain, 0); return plain; } catch (Exception e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to decrypt key", e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to decrypt key", e); } } return null; @@ -463,8 +467,8 @@ private Random genRandom() { Class.forName(JSch.getConfig("random")).asSubclass(Random.class); random = c.getDeclaredConstructor().newInstance(); } catch (Exception e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to create random", e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to create random", e); } } } @@ -477,8 +481,8 @@ private HASH genHash() { hash = c.getDeclaredConstructor().newInstance(); hash.init(); } catch (Exception e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to create hash", e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to create hash", e); } } return hash; @@ -490,8 +494,8 @@ private Cipher genCipher() { Class.forName(JSch.getConfig("3des-cbc")).asSubclass(Cipher.class); cipher = c.getDeclaredConstructor().newInstance(); } catch (Exception e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to create cipher", e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to create cipher", e); } } return cipher; @@ -562,8 +566,8 @@ synchronized byte[] genKey(byte[] passphrase, byte[] iv) { Util.bzero(tmp); } } catch (Exception e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to generate key from passphrase", e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to generate key from passphrase", e); } } return key; @@ -637,10 +641,15 @@ public static KeyPair load(JSch jsch, String prvkey) throws JSchException { if (!new File(pubkey).exists()) { pubkey = null; } - return load(jsch, prvkey, pubkey); + return load(jsch.instLogger, prvkey, pubkey); } public static KeyPair load(JSch jsch, String prvfile, String pubfile) throws JSchException { + return load(jsch.instLogger, prvfile, pubfile); + } + + static KeyPair load(JSch.InstanceLogger instLogger, String prvfile, String pubfile) + throws JSchException { byte[] prvkey = null; byte[] pubkey = null; @@ -665,13 +674,18 @@ public static KeyPair load(JSch jsch, String prvfile, String pubfile) throws JSc } try { - return load(jsch, prvkey, pubkey); + return load(instLogger, prvkey, pubkey); } finally { Util.bzero(prvkey); } } public static KeyPair load(JSch jsch, byte[] prvkey, byte[] pubkey) throws JSchException { + return load(jsch.instLogger, prvkey, pubkey); + } + + static KeyPair load(JSch.InstanceLogger instLogger, byte[] prvkey, byte[] pubkey) + throws JSchException { byte[] iv = new byte[8]; // 8 boolean encrypted = true; @@ -697,16 +711,16 @@ public static KeyPair load(JSch jsch, byte[] prvkey, byte[] pubkey) throws JSchE KeyPair kpair = null; if (_type.equals("ssh-rsa")) { - kpair = KeyPairRSA.fromSSHAgent(jsch, buf); + kpair = KeyPairRSA.fromSSHAgent(instLogger, buf); } else if (_type.equals("ssh-dss")) { - kpair = KeyPairDSA.fromSSHAgent(jsch, buf); + kpair = KeyPairDSA.fromSSHAgent(instLogger, buf); } else if (_type.equals("ecdsa-sha2-nistp256") || _type.equals("ecdsa-sha2-nistp384") || _type.equals("ecdsa-sha2-nistp521")) { - kpair = KeyPairECDSA.fromSSHAgent(jsch, buf); + kpair = KeyPairECDSA.fromSSHAgent(instLogger, buf); } else if (_type.equals("ssh-ed25519")) { - kpair = KeyPairEd25519.fromSSHAgent(jsch, buf); + kpair = KeyPairEd25519.fromSSHAgent(instLogger, buf); } else if (_type.equals("ssh-ed448")) { - kpair = KeyPairEd448.fromSSHAgent(jsch, buf); + kpair = KeyPairEd448.fromSSHAgent(instLogger, buf); } else { throw new JSchException("privatekey: invalid key " + _type); } @@ -717,7 +731,7 @@ public static KeyPair load(JSch jsch, byte[] prvkey, byte[] pubkey) throws JSchE byte[] buf = prvkey; if (buf != null) { - KeyPair ppk = loadPPK(jsch, buf); + KeyPair ppk = loadPPK(instLogger, buf); if (ppk != null) return ppk; } @@ -906,7 +920,7 @@ public static KeyPair load(JSch jsch, byte[] prvkey, byte[] pubkey) throws JSchE } if (vendor == VENDOR_OPENSSH_V1) { - return loadOpenSSHKeyv1(jsch, data); + return loadOpenSSHKeyv1(instLogger, data); } else if (data != null && data.length > 4 && // FSecure data[0] == (byte) 0x3f && data[1] == (byte) 0x6f && data[2] == (byte) 0xf9 && data[3] == (byte) 0xeb) { @@ -1077,25 +1091,25 @@ public static KeyPair load(JSch jsch, byte[] prvkey, byte[] pubkey) throws JSchE } } } catch (Exception ee) { - if (jsch.getInstanceLogger().isEnabled(Logger.WARN)) { - jsch.getInstanceLogger().log(Logger.WARN, "failed to parse public key", ee); + if (instLogger.getLogger().isEnabled(Logger.WARN)) { + instLogger.getLogger().log(Logger.WARN, "failed to parse public key", ee); } } } KeyPair kpair = null; if (type == DSA) { - kpair = new KeyPairDSA(jsch); + kpair = new KeyPairDSA(instLogger); } else if (type == RSA) { - kpair = new KeyPairRSA(jsch); + kpair = new KeyPairRSA(instLogger); } else if (type == ECDSA) { - kpair = new KeyPairECDSA(jsch, pubkey); + kpair = new KeyPairECDSA(instLogger, pubkey); } else if (type == ED25519) { - kpair = new KeyPairEd25519(jsch, pubkey, null); + kpair = new KeyPairEd25519(instLogger, pubkey, null); } else if (type == ED448) { - kpair = new KeyPairEd448(jsch, pubkey, null); + kpair = new KeyPairEd448(instLogger, pubkey, null); } else if (vendor == VENDOR_PKCS8) { - kpair = new KeyPairPKCS8(jsch); + kpair = new KeyPairPKCS8(instLogger); } if (kpair != null) { @@ -1127,7 +1141,8 @@ public static KeyPair load(JSch jsch, byte[] prvkey, byte[] pubkey) throws JSchE } } - static KeyPair loadOpenSSHKeyv1(JSch jsch, byte[] data) throws JSchException { + static KeyPair loadOpenSSHKeyv1(JSch.InstanceLogger instLogger, byte[] data) + throws JSchException { if (data == null) { throw new JSchException("invalid privatekey"); } @@ -1149,7 +1164,7 @@ static KeyPair loadOpenSSHKeyv1(JSch jsch, byte[] data) throws JSchException { } byte[] publickeyblob = buffer.getString(); - KeyPair kpair = parsePubkeyBlob(jsch, publickeyblob, null); + KeyPair kpair = parsePubkeyBlob(instLogger, publickeyblob, null); kpair.encrypted = !"none".equals(cipherName); kpair.publickeyblob = publickeyblob; kpair.vendor = VENDOR_OPENSSH_V1; @@ -1226,7 +1241,7 @@ public void finalize() { dispose(); } - static KeyPair loadPPK(JSch jsch, byte[] buf) throws JSchException { + static KeyPair loadPPK(JSch.InstanceLogger instLogger, byte[] buf) throws JSchException { byte[] pubkey = null; byte[] prvkey = null; byte[] _prvkey = null; @@ -1273,7 +1288,7 @@ static KeyPair loadPPK(JSch jsch, byte[] buf) throws JSchException { prvkey = Util.fromBase64(_prvkey, 0, _prvkey.length); pubkey = Util.fromBase64(pubkey, 0, pubkey.length); - KeyPair kpair = parsePubkeyBlob(jsch, pubkey, typ); + KeyPair kpair = parsePubkeyBlob(instLogger, pubkey, typ); kpair.encrypted = !v.get("Encryption").equals("none"); kpair.publickeyblob = pubkey; kpair.vendor = ppkVersion; @@ -1367,8 +1382,8 @@ static KeyPair loadPPK(JSch jsch, byte[] buf) throws JSchException { } } - private static KeyPair parsePubkeyBlob(JSch jsch, byte[] pubkeyblob, String typ) - throws JSchException { + private static KeyPair parsePubkeyBlob(JSch.InstanceLogger instLogger, byte[] pubkeyblob, + String typ) throws JSchException { Buffer _buf = new Buffer(pubkeyblob); _buf.skip(pubkeyblob.length); @@ -1386,7 +1401,7 @@ private static KeyPair parsePubkeyBlob(JSch jsch, byte[] pubkeyblob, String typ) byte[] n_array = new byte[_buf.getInt()]; _buf.getByte(n_array); - return new KeyPairRSA(jsch, n_array, pub_array, null); + return new KeyPairRSA(instLogger, n_array, pub_array, null); } else if (typ.equals("ssh-dss")) { byte[] p_array = new byte[_buf.getInt()]; _buf.getByte(p_array); @@ -1397,7 +1412,7 @@ private static KeyPair parsePubkeyBlob(JSch jsch, byte[] pubkeyblob, String typ) byte[] y_array = new byte[_buf.getInt()]; _buf.getByte(y_array); - return new KeyPairDSA(jsch, p_array, q_array, g_array, y_array, null); + return new KeyPairDSA(instLogger, p_array, q_array, g_array, y_array, null); } else if (typ.equals("ecdsa-sha2-nistp256") || typ.equals("ecdsa-sha2-nistp384") || typ.equals("ecdsa-sha2-nistp521")) { byte[] name = _buf.getString(); // nistpXXX @@ -1410,15 +1425,15 @@ private static KeyPair parsePubkeyBlob(JSch jsch, byte[] pubkeyblob, String typ) _buf.getByte(r_array); _buf.getByte(s_array); - return new KeyPairECDSA(jsch, name, r_array, s_array, null); + return new KeyPairECDSA(instLogger, name, r_array, s_array, null); } else if (typ.equals("ssh-ed25519") || typ.equals("ssh-ed448")) { byte[] pub_array = new byte[_buf.getInt()]; _buf.getByte(pub_array); if (typ.equals("ssh-ed25519")) { - return new KeyPairEd25519(jsch, pub_array, null); + return new KeyPairEd25519(instLogger, pub_array, null); } else { - return new KeyPairEd448(jsch, pub_array, null); + return new KeyPairEd448(instLogger, pub_array, null); } } else { throw new JSchException("key type " + typ + " is not supported"); diff --git a/src/main/java/com/jcraft/jsch/KeyPairDSA.java b/src/main/java/com/jcraft/jsch/KeyPairDSA.java index c4d15fa2..e7400f15 100644 --- a/src/main/java/com/jcraft/jsch/KeyPairDSA.java +++ b/src/main/java/com/jcraft/jsch/KeyPairDSA.java @@ -38,13 +38,13 @@ class KeyPairDSA extends KeyPair { // private int key_size=0; private int key_size = 1024; - KeyPairDSA(JSch jsch) { - this(jsch, null, null, null, null, null); + KeyPairDSA(JSch.InstanceLogger instLogger) { + this(instLogger, null, null, null, null, null); } - KeyPairDSA(JSch jsch, byte[] P_array, byte[] Q_array, byte[] G_array, byte[] pub_array, - byte[] prv_array) { - super(jsch); + KeyPairDSA(JSch.InstanceLogger instLogger, byte[] P_array, byte[] Q_array, byte[] G_array, + byte[] pub_array, byte[] prv_array) { + super(instLogger); this.P_array = P_array; this.Q_array = Q_array; this.G_array = G_array; @@ -136,8 +136,8 @@ boolean parse(byte[] plain) { byte[][] tmp = buf.getBytes(1, ""); prv_array = tmp[0]; } catch (JSchException e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to parse key", e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to parse key", e); } return false; } @@ -264,8 +264,8 @@ else if (vendor == VENDOR_OPENSSH_V1) { if (P_array != null) key_size = (new BigInteger(P_array)).bitLength(); } catch (Exception e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to parse key", e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to parse key", e); } return false; } @@ -322,8 +322,8 @@ public byte[] getSignature(byte[] data) { tmp[1] = sig; return Buffer.fromBytes(tmp).buffer; } catch (Exception e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to generate signature", e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to generate signature", e); } } return null; @@ -354,8 +354,8 @@ public Signature getVerifier() { dsa.setPubKey(pub_array, P_array, Q_array, G_array); return dsa; } catch (Exception e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to create verifier", e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to create verifier", e); } } return null; @@ -366,7 +366,7 @@ public Signature getVerifier(String alg) { return getVerifier(); } - static KeyPair fromSSHAgent(JSch jsch, Buffer buf) throws JSchException { + static KeyPair fromSSHAgent(JSch.InstanceLogger instLogger, Buffer buf) throws JSchException { byte[][] tmp = buf.getBytes(7, "invalid key format"); @@ -375,7 +375,7 @@ static KeyPair fromSSHAgent(JSch jsch, Buffer buf) throws JSchException { byte[] G_array = tmp[3]; byte[] pub_array = tmp[4]; byte[] prv_array = tmp[5]; - KeyPairDSA kpair = new KeyPairDSA(jsch, P_array, Q_array, G_array, pub_array, prv_array); + KeyPairDSA kpair = new KeyPairDSA(instLogger, P_array, Q_array, G_array, pub_array, prv_array); kpair.publicKeyComment = Util.byte2str(tmp[6]); kpair.vendor = VENDOR_OPENSSH; return kpair; diff --git a/src/main/java/com/jcraft/jsch/KeyPairECDSA.java b/src/main/java/com/jcraft/jsch/KeyPairECDSA.java index 489b16da..1d315856 100644 --- a/src/main/java/com/jcraft/jsch/KeyPairECDSA.java +++ b/src/main/java/com/jcraft/jsch/KeyPairECDSA.java @@ -46,12 +46,12 @@ class KeyPairECDSA extends KeyPair { private int key_size = 256; - KeyPairECDSA(JSch jsch) { - this(jsch, null, null, null, null); + KeyPairECDSA(JSch.InstanceLogger instLogger) { + this(instLogger, null, null, null, null); } - KeyPairECDSA(JSch jsch, byte[] pubkey) { - this(jsch, null, null, null, null); + KeyPairECDSA(JSch.InstanceLogger instLogger, byte[] pubkey) { + this(instLogger, null, null, null, null); if (pubkey != null) { byte[] name = new byte[8]; @@ -67,8 +67,9 @@ class KeyPairECDSA extends KeyPair { } } - KeyPairECDSA(JSch jsch, byte[] name, byte[] r_array, byte[] s_array, byte[] prv_array) { - super(jsch); + KeyPairECDSA(JSch.InstanceLogger instLogger, byte[] name, byte[] r_array, byte[] s_array, + byte[] prv_array) { + super(instLogger); if (name != null) this.name = name; this.r_array = r_array; @@ -166,8 +167,8 @@ boolean parse(byte[] plain) { prv_array = tmp[0]; key_size = prv_array.length >= 64 ? 521 : (prv_array.length >= 48 ? 384 : 256); } catch (JSchException e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to parse key", e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to parse key", e); } return false; } @@ -300,8 +301,8 @@ boolean parse(byte[] plain) { if (prv_array != null) key_size = prv_array.length >= 64 ? 521 : (prv_array.length >= 48 ? 384 : 256); } catch (Exception e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to parse key", e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to parse key", e); } return false; } @@ -362,8 +363,8 @@ public byte[] getSignature(byte[] data) { tmp[1] = sig; return Buffer.fromBytes(tmp).buffer; } catch (Exception e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to generate signature", e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to generate signature", e); } } return null; @@ -394,8 +395,8 @@ public Signature getVerifier() { ecdsa.setPubKey(r_array, s_array); return ecdsa; } catch (Exception e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to create verifier", e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to create verifier", e); } } return null; @@ -406,7 +407,7 @@ public Signature getVerifier(String alg) { return getVerifier(); } - static KeyPair fromSSHAgent(JSch jsch, Buffer buf) throws JSchException { + static KeyPair fromSSHAgent(JSch.InstanceLogger instLogger, Buffer buf) throws JSchException { byte[][] tmp = buf.getBytes(5, "invalid key format"); @@ -416,7 +417,7 @@ static KeyPair fromSSHAgent(JSch jsch, Buffer buf) throws JSchException { byte[] s_array = foo[1]; byte[] prv_array = tmp[3]; - KeyPairECDSA kpair = new KeyPairECDSA(jsch, name, r_array, s_array, prv_array); + KeyPairECDSA kpair = new KeyPairECDSA(instLogger, name, r_array, s_array, prv_array); kpair.publicKeyComment = Util.byte2str(tmp[4]); kpair.vendor = VENDOR_OPENSSH; return kpair; diff --git a/src/main/java/com/jcraft/jsch/KeyPairEd25519.java b/src/main/java/com/jcraft/jsch/KeyPairEd25519.java index 5552aeda..eb7990a5 100644 --- a/src/main/java/com/jcraft/jsch/KeyPairEd25519.java +++ b/src/main/java/com/jcraft/jsch/KeyPairEd25519.java @@ -32,12 +32,12 @@ class KeyPairEd25519 extends KeyPairEdDSA { private static int keySize = 32; - KeyPairEd25519(JSch jsch) { - this(jsch, null, null); + KeyPairEd25519(JSch.InstanceLogger instLogger) { + this(instLogger, null, null); } - KeyPairEd25519(JSch jsch, byte[] pub_array, byte[] prv_array) { - super(jsch, pub_array, prv_array); + KeyPairEd25519(JSch.InstanceLogger instLogger, byte[] pub_array, byte[] prv_array) { + super(instLogger, pub_array, prv_array); } @Override @@ -60,13 +60,13 @@ String getJceName() { return "Ed25519"; } - static KeyPair fromSSHAgent(JSch jsch, Buffer buf) throws JSchException { + static KeyPair fromSSHAgent(JSch.InstanceLogger instLogger, Buffer buf) throws JSchException { byte[][] tmp = buf.getBytes(4, "invalid key format"); byte[] pub_array = tmp[1]; byte[] prv_array = Arrays.copyOf(tmp[2], keySize); - KeyPairEd25519 kpair = new KeyPairEd25519(jsch, pub_array, prv_array); + KeyPairEd25519 kpair = new KeyPairEd25519(instLogger, pub_array, prv_array); kpair.publicKeyComment = Util.byte2str(tmp[3]); kpair.vendor = VENDOR_OPENSSH; return kpair; diff --git a/src/main/java/com/jcraft/jsch/KeyPairEd448.java b/src/main/java/com/jcraft/jsch/KeyPairEd448.java index 67c8da8c..e22093b6 100644 --- a/src/main/java/com/jcraft/jsch/KeyPairEd448.java +++ b/src/main/java/com/jcraft/jsch/KeyPairEd448.java @@ -32,12 +32,12 @@ class KeyPairEd448 extends KeyPairEdDSA { private static int keySize = 57; - KeyPairEd448(JSch jsch) { - this(jsch, null, null); + KeyPairEd448(JSch.InstanceLogger instLogger) { + this(instLogger, null, null); } - KeyPairEd448(JSch jsch, byte[] pub_array, byte[] prv_array) { - super(jsch, pub_array, prv_array); + KeyPairEd448(JSch.InstanceLogger instLogger, byte[] pub_array, byte[] prv_array) { + super(instLogger, pub_array, prv_array); } @Override @@ -60,13 +60,13 @@ String getJceName() { return "Ed448"; } - static KeyPair fromSSHAgent(JSch jsch, Buffer buf) throws JSchException { + static KeyPair fromSSHAgent(JSch.InstanceLogger instLogger, Buffer buf) throws JSchException { byte[][] tmp = buf.getBytes(4, "invalid key format"); byte[] pub_array = tmp[1]; byte[] prv_array = Arrays.copyOf(tmp[2], keySize); - KeyPairEd448 kpair = new KeyPairEd448(jsch, pub_array, prv_array); + KeyPairEd448 kpair = new KeyPairEd448(instLogger, pub_array, prv_array); kpair.publicKeyComment = Util.byte2str(tmp[3]); kpair.vendor = VENDOR_OPENSSH; return kpair; diff --git a/src/main/java/com/jcraft/jsch/KeyPairEdDSA.java b/src/main/java/com/jcraft/jsch/KeyPairEdDSA.java index a50f5b98..08ce3c23 100644 --- a/src/main/java/com/jcraft/jsch/KeyPairEdDSA.java +++ b/src/main/java/com/jcraft/jsch/KeyPairEdDSA.java @@ -32,8 +32,8 @@ abstract class KeyPairEdDSA extends KeyPair { private byte[] pub_array; private byte[] prv_array; - KeyPairEdDSA(JSch jsch, byte[] pub_array, byte[] prv_array) { - super(jsch); + KeyPairEdDSA(JSch.InstanceLogger instLogger, byte[] pub_array, byte[] prv_array) { + super(instLogger); this.pub_array = pub_array; this.prv_array = prv_array; } @@ -85,8 +85,8 @@ boolean parse(byte[] plain) { byte[][] tmp = buf.getBytes(1, ""); prv_array = tmp[0]; } catch (JSchException e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to parse key", e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to parse key", e); } return false; } @@ -110,8 +110,8 @@ boolean parse(byte[] plain) { publicKeyComment = Util.byte2str(buf.getString()); return true; } catch (Exception e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to parse key", e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to parse key", e); } return false; } @@ -126,14 +126,14 @@ boolean parse(byte[] plain) { prv_array = keypairgen.getPrv(); return true; } catch (Exception | NoClassDefFoundError e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to parse key", e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to parse key", e); } return false; } } else { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to parse key"); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to parse key"); } return false; } @@ -179,8 +179,8 @@ public byte[] getSignature(byte[] data, String alg) { tmp[1] = sig; return Buffer.fromBytes(tmp).buffer; } catch (Exception | NoClassDefFoundError e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to generate signature", e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to generate signature", e); } } return null; @@ -208,8 +208,8 @@ public Signature getVerifier(String alg) { eddsa.setPubKey(pub_array); return eddsa; } catch (Exception | NoClassDefFoundError e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to create verifier", e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to create verifier", e); } } return null; diff --git a/src/main/java/com/jcraft/jsch/KeyPairPKCS8.java b/src/main/java/com/jcraft/jsch/KeyPairPKCS8.java index 36d5a418..048bd80d 100644 --- a/src/main/java/com/jcraft/jsch/KeyPairPKCS8.java +++ b/src/main/java/com/jcraft/jsch/KeyPairPKCS8.java @@ -125,8 +125,8 @@ class KeyPairPKCS8 extends KeyPair { private KeyPair kpair = null; - KeyPairPKCS8(JSch jsch) { - super(jsch); + KeyPairPKCS8(JSch.InstanceLogger instLogger) { + super(instLogger); } @Override @@ -218,7 +218,7 @@ boolean parse(byte[] plain) { throw new ASN1Exception(); } - _kpair = new KeyPairRSA(jsch); + _kpair = new KeyPairRSA(instLogger); _kpair.copy(this); if (_kpair.parse(_data)) { kpair = _kpair; @@ -306,10 +306,10 @@ boolean parse(byte[] plain) { byte[] pub_array = (new BigInteger(G_array)) .modPow(new BigInteger(prv_array), new BigInteger(P_array)).toByteArray(); - _key = new KeyPairDSA(jsch, P_array, Q_array, G_array, pub_array, prv_array); + _key = new KeyPairDSA(instLogger, P_array, Q_array, G_array, pub_array, prv_array); _plain = _key.getPrivateKey(); - _kpair = new KeyPairDSA(jsch); + _kpair = new KeyPairDSA(instLogger); _kpair.copy(this); if (_kpair.parse(_plain)) { kpair = _kpair; @@ -408,10 +408,10 @@ boolean parse(byte[] plain) { byte[] r_array = tmp[0]; byte[] s_array = tmp[1]; - _key = new KeyPairECDSA(jsch, name, r_array, s_array, prv_array); + _key = new KeyPairECDSA(instLogger, name, r_array, s_array, prv_array); _plain = _key.getPrivateKey(); - _kpair = new KeyPairECDSA(jsch); + _kpair = new KeyPairECDSA(instLogger); _kpair.copy(this); if (_kpair.parse(_plain)) { kpair = _kpair; @@ -431,9 +431,9 @@ boolean parse(byte[] plain) { prv_array = curvePrivateKey.getContent(); if (Util.array_equals(privateKeyAlgorithmID, ed25519)) { - _kpair = new KeyPairEd25519(jsch); + _kpair = new KeyPairEd25519(instLogger); } else { - _kpair = new KeyPairEd448(jsch); + _kpair = new KeyPairEd448(instLogger); } _kpair.copy(this); if (_kpair.parse(prv_array)) { @@ -447,14 +447,14 @@ boolean parse(byte[] plain) { "unsupported privateKeyAlgorithm oid: " + Util.toHex(privateKeyAlgorithmID)); } } catch (ASN1Exception e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "PKCS8: failed to parse key: ASN1 parsing error", + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "PKCS8: failed to parse key: ASN1 parsing error", e); } return false; } catch (Exception e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "PKCS8: failed to parse key: " + e.getMessage(), + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "PKCS8: failed to parse key: " + e.getMessage(), e); } return false; @@ -766,15 +766,15 @@ public boolean decrypt(byte[] _passphrase) { throw new JSchException("failed to parse decrypted key"); } } catch (ASN1Exception e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, - "PKCS8: failed to decrypt key: ASN1 parsing error", e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "PKCS8: failed to decrypt key: ASN1 parsing error", + e); } return false; } catch (Exception e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, - "PKCS8: failed to decrypt key: " + e.getMessage(), e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "PKCS8: failed to decrypt key: " + e.getMessage(), + e); } return false; } finally { diff --git a/src/main/java/com/jcraft/jsch/KeyPairRSA.java b/src/main/java/com/jcraft/jsch/KeyPairRSA.java index 56b37491..af2c57f9 100644 --- a/src/main/java/com/jcraft/jsch/KeyPairRSA.java +++ b/src/main/java/com/jcraft/jsch/KeyPairRSA.java @@ -41,12 +41,12 @@ class KeyPairRSA extends KeyPair { private int key_size = 1024; - KeyPairRSA(JSch jsch) { - this(jsch, null, null, null); + KeyPairRSA(JSch.InstanceLogger instLogger) { + this(instLogger, null, null, null); } - KeyPairRSA(JSch jsch, byte[] n_array, byte[] pub_array, byte[] prv_array) { - super(jsch); + KeyPairRSA(JSch.InstanceLogger instLogger, byte[] n_array, byte[] pub_array, byte[] prv_array) { + super(instLogger); this.n_array = n_array; this.pub_array = pub_array; this.prv_array = prv_array; @@ -139,8 +139,8 @@ boolean parse(byte[] plain) { q_array = tmp[2]; c_array = tmp[3]; } catch (JSchException e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to parse key", e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to parse key", e); } return false; } @@ -170,8 +170,8 @@ boolean parse(byte[] plain) { return true; } - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to parse key"); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to parse key"); } return false; } @@ -342,8 +342,8 @@ boolean parse(byte[] plain) { } } catch (Exception e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to parse key", e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to parse key", e); } return false; } @@ -403,8 +403,8 @@ public byte[] getSignature(byte[] data, String alg) { tmp[1] = sig; return Buffer.fromBytes(tmp).buffer; } catch (Exception e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to generate signature", e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to generate signature", e); } } return null; @@ -433,21 +433,21 @@ public Signature getVerifier(String alg) { rsa.setPubKey(pub_array, n_array); return rsa; } catch (Exception e) { - if (jsch.getInstanceLogger().isEnabled(Logger.ERROR)) { - jsch.getInstanceLogger().log(Logger.ERROR, "failed to create verifier", e); + if (instLogger.getLogger().isEnabled(Logger.ERROR)) { + instLogger.getLogger().log(Logger.ERROR, "failed to create verifier", e); } } return null; } - static KeyPair fromSSHAgent(JSch jsch, Buffer buf) throws JSchException { + static KeyPair fromSSHAgent(JSch.InstanceLogger instLogger, Buffer buf) throws JSchException { byte[][] tmp = buf.getBytes(8, "invalid key format"); byte[] n_array = tmp[1]; byte[] pub_array = tmp[2]; byte[] prv_array = tmp[3]; - KeyPairRSA kpair = new KeyPairRSA(jsch, n_array, pub_array, prv_array); + KeyPairRSA kpair = new KeyPairRSA(instLogger, n_array, pub_array, prv_array); kpair.c_array = tmp[4]; // iqmp kpair.p_array = tmp[5]; kpair.q_array = tmp[6]; diff --git a/src/main/java/com/jcraft/jsch/LocalIdentityRepository.java b/src/main/java/com/jcraft/jsch/LocalIdentityRepository.java index 81e8cd74..c2a6328a 100644 --- a/src/main/java/com/jcraft/jsch/LocalIdentityRepository.java +++ b/src/main/java/com/jcraft/jsch/LocalIdentityRepository.java @@ -32,10 +32,10 @@ class LocalIdentityRepository implements IdentityRepository { private static final String name = "Local Identity Repository"; private Vector identities = new Vector<>(); - private JSch jsch; + private JSch.InstanceLogger instLogger; - LocalIdentityRepository(JSch jsch) { - this.jsch = jsch; + LocalIdentityRepository(JSch.InstanceLogger instLogger) { + this.instLogger = instLogger; } @Override @@ -82,7 +82,7 @@ public synchronized void add(Identity identity) { @Override public synchronized boolean add(byte[] identity) { try { - Identity _identity = IdentityFile.newInstance("from remote:", identity, null, jsch); + Identity _identity = IdentityFile.newInstance("from remote:", identity, null, instLogger); add(_identity); return true; } catch (JSchException e) { diff --git a/src/main/java/com/jcraft/jsch/Session.java b/src/main/java/com/jcraft/jsch/Session.java index 39668d99..97b3d708 100644 --- a/src/main/java/com/jcraft/jsch/Session.java +++ b/src/main/java/com/jcraft/jsch/Session.java @@ -3108,7 +3108,7 @@ private void applyConfig() throws JSchException { } if (ifile == null) continue; - Identity identity = IdentityFile.newInstance(ifile, null, jsch); + Identity identity = IdentityFile.newInstance(ifile, null, jsch.instLogger); ir.add(identity); } this.setIdentityRepository(ir); diff --git a/src/test/java/com/jcraft/jsch/AbstractBufferMargin.java b/src/test/java/com/jcraft/jsch/AbstractBufferMargin.java index 98cadfc2..0af63f77 100644 --- a/src/test/java/com/jcraft/jsch/AbstractBufferMargin.java +++ b/src/test/java/com/jcraft/jsch/AbstractBufferMargin.java @@ -45,26 +45,30 @@ public abstract class AbstractBufferMargin { private Slf4jLogConsumer sshdLogConsumer; @Container - public GenericContainer sshd = new GenericContainer<>( - new ImageFromDockerfile().withFileFromClasspath("asyncsshd.py", "docker/asyncsshd.py") - .withFileFromClasspath("ssh_host_ed448_key", "docker/ssh_host_ed448_key") - .withFileFromClasspath("ssh_host_ed448_key.pub", "docker/ssh_host_ed448_key.pub") - .withFileFromClasspath("ssh_host_rsa_key", "docker/ssh_host_rsa_key") - .withFileFromClasspath("ssh_host_rsa_key.pub", "docker/ssh_host_rsa_key.pub") - .withFileFromClasspath("ssh_host_ecdsa256_key", "docker/ssh_host_ecdsa256_key") - .withFileFromClasspath("ssh_host_ecdsa256_key.pub", "docker/ssh_host_ecdsa256_key.pub") - .withFileFromClasspath("ssh_host_ecdsa384_key", "docker/ssh_host_ecdsa384_key") - .withFileFromClasspath("ssh_host_ecdsa384_key.pub", "docker/ssh_host_ecdsa384_key.pub") - .withFileFromClasspath("ssh_host_ecdsa521_key", "docker/ssh_host_ecdsa521_key") - .withFileFromClasspath("ssh_host_ecdsa521_key.pub", "docker/ssh_host_ecdsa521_key.pub") - .withFileFromClasspath("ssh_host_ed25519_key", "docker/ssh_host_ed25519_key") - .withFileFromClasspath("ssh_host_ed25519_key.pub", "docker/ssh_host_ed25519_key.pub") - .withFileFromClasspath("ssh_host_dsa_key", "docker/ssh_host_dsa_key") - .withFileFromClasspath("ssh_host_dsa_key.pub", "docker/ssh_host_dsa_key.pub") - .withFileFromClasspath("authorized_keys", "docker/authorized_keys") - .withFileFromClasspath("Dockerfile", "docker/Dockerfile.asyncssh") - .withBuildArg("MAX_PKTSIZE", Integer.toString(maxPktSize()))) - .withExposedPorts(22); + public GenericContainer sshd; + + protected AbstractBufferMargin(int maxPktSize) { + sshd = new GenericContainer<>( + new ImageFromDockerfile().withFileFromClasspath("asyncsshd.py", "docker/asyncsshd.py") + .withFileFromClasspath("ssh_host_ed448_key", "docker/ssh_host_ed448_key") + .withFileFromClasspath("ssh_host_ed448_key.pub", "docker/ssh_host_ed448_key.pub") + .withFileFromClasspath("ssh_host_rsa_key", "docker/ssh_host_rsa_key") + .withFileFromClasspath("ssh_host_rsa_key.pub", "docker/ssh_host_rsa_key.pub") + .withFileFromClasspath("ssh_host_ecdsa256_key", "docker/ssh_host_ecdsa256_key") + .withFileFromClasspath("ssh_host_ecdsa256_key.pub", "docker/ssh_host_ecdsa256_key.pub") + .withFileFromClasspath("ssh_host_ecdsa384_key", "docker/ssh_host_ecdsa384_key") + .withFileFromClasspath("ssh_host_ecdsa384_key.pub", "docker/ssh_host_ecdsa384_key.pub") + .withFileFromClasspath("ssh_host_ecdsa521_key", "docker/ssh_host_ecdsa521_key") + .withFileFromClasspath("ssh_host_ecdsa521_key.pub", "docker/ssh_host_ecdsa521_key.pub") + .withFileFromClasspath("ssh_host_ed25519_key", "docker/ssh_host_ed25519_key") + .withFileFromClasspath("ssh_host_ed25519_key.pub", "docker/ssh_host_ed25519_key.pub") + .withFileFromClasspath("ssh_host_dsa_key", "docker/ssh_host_dsa_key") + .withFileFromClasspath("ssh_host_dsa_key.pub", "docker/ssh_host_dsa_key.pub") + .withFileFromClasspath("authorized_keys", "docker/authorized_keys") + .withFileFromClasspath("Dockerfile", "docker/Dockerfile.asyncssh") + .withBuildArg("MAX_PKTSIZE", Integer.toString(maxPktSize))) + .withExposedPorts(22); + } @BeforeAll public static void beforeAll() { @@ -101,8 +105,6 @@ public static void afterAll() { sshdLogger.clearAll(); } - protected abstract int maxPktSize(); - protected void doTestSftp(String cipher, String mac, String compression) throws Exception { JSch ssh = createRSAIdentity(); Session session = createSession(ssh); diff --git a/src/test/java/com/jcraft/jsch/KeyPairTest.java b/src/test/java/com/jcraft/jsch/KeyPairTest.java index 43fb4dc9..9ab555a3 100644 --- a/src/test/java/com/jcraft/jsch/KeyPairTest.java +++ b/src/test/java/com/jcraft/jsch/KeyPairTest.java @@ -156,7 +156,7 @@ void decryptEncryptedOpensshKey(String keyFile) throws URISyntaxException, JSchE final String prvkey = Paths.get(ClassLoader.getSystemResource(keyFile).toURI()).toFile().getAbsolutePath(); assertTrue(new File(prvkey).exists()); - IdentityFile identity = IdentityFile.newInstance(prvkey, null, jSch); + IdentityFile identity = IdentityFile.newInstance(prvkey, null, jSch.instLogger); // Decrypt the key file assertTrue(identity.getKeyPair().decrypt("secret123")); diff --git a/src/test/java/com/jcraft/jsch/PktSize128IT.java b/src/test/java/com/jcraft/jsch/PktSize128IT.java index fb095e73..a739d17b 100644 --- a/src/test/java/com/jcraft/jsch/PktSize128IT.java +++ b/src/test/java/com/jcraft/jsch/PktSize128IT.java @@ -5,6 +5,10 @@ public class PktSize128IT extends AbstractBufferMargin { + public PktSize128IT() { + super(128); + } + @ParameterizedTest @CsvSource(value = { // 16 byte tag (MAC doesn't matter) @@ -34,9 +38,4 @@ public void testSftp(String cipher, String mac, String compression) throws Excep public void testScp(String cipher, String mac, String compression) throws Exception { doTestScp(cipher, mac, compression); } - - @Override - protected int maxPktSize() { - return 128; - } } diff --git a/src/test/java/com/jcraft/jsch/PktSize160IT.java b/src/test/java/com/jcraft/jsch/PktSize160IT.java index b107c217..40c34872 100644 --- a/src/test/java/com/jcraft/jsch/PktSize160IT.java +++ b/src/test/java/com/jcraft/jsch/PktSize160IT.java @@ -5,6 +5,10 @@ public class PktSize160IT extends AbstractBufferMargin { + public PktSize160IT() { + super(160); + } + @ParameterizedTest @CsvSource(value = { // 32 byte MAC @@ -20,9 +24,4 @@ public void testSftp(String cipher, String mac, String compression) throws Excep public void testScp(String cipher, String mac, String compression) throws Exception { doTestScp(cipher, mac, compression); } - - @Override - protected int maxPktSize() { - return 160; - } } diff --git a/src/test/java/com/jcraft/jsch/PktSize192IT.java b/src/test/java/com/jcraft/jsch/PktSize192IT.java index 81af9b14..aa78cfaf 100644 --- a/src/test/java/com/jcraft/jsch/PktSize192IT.java +++ b/src/test/java/com/jcraft/jsch/PktSize192IT.java @@ -5,6 +5,10 @@ public class PktSize192IT extends AbstractBufferMargin { + public PktSize192IT() { + super(192); + } + @ParameterizedTest @CsvSource(value = { // 64 byte MAC @@ -12,9 +16,4 @@ public class PktSize192IT extends AbstractBufferMargin { public void testSftp(String cipher, String mac, String compression) throws Exception { doTestSftp(cipher, mac, compression); } - - @Override - protected int maxPktSize() { - return 192; - } } diff --git a/src/test/java/com/jcraft/jsch/PktSize32768IT.java b/src/test/java/com/jcraft/jsch/PktSize32768IT.java index e8f65dbc..e2e2e125 100644 --- a/src/test/java/com/jcraft/jsch/PktSize32768IT.java +++ b/src/test/java/com/jcraft/jsch/PktSize32768IT.java @@ -5,6 +5,10 @@ public class PktSize32768IT extends AbstractBufferMargin { + public PktSize32768IT() { + super(32768); + } + @ParameterizedTest @CsvSource(value = { // 16 byte tag (MAC doesn't matter) @@ -40,9 +44,4 @@ public void testSftp(String cipher, String mac, String compression) throws Excep public void testScp(String cipher, String mac, String compression) throws Exception { doTestScp(cipher, mac, compression); } - - @Override - protected int maxPktSize() { - return 32768; - } } From 705b54cb3576c9cd721058ecc3302cb036287109 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Mon, 17 Jul 2023 06:21:01 -0500 Subject: [PATCH 057/301] Eliminate KeyPair's public constructor since it cannot be meaningfully used by consumers. --- src/main/java/com/jcraft/jsch/KeyPair.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/com/jcraft/jsch/KeyPair.java b/src/main/java/com/jcraft/jsch/KeyPair.java index cd258739..7e29f888 100644 --- a/src/main/java/com/jcraft/jsch/KeyPair.java +++ b/src/main/java/com/jcraft/jsch/KeyPair.java @@ -117,10 +117,6 @@ public void setPublicKeyComment(String publicKeyComment) { private byte[] passphrase; - public KeyPair(JSch jsch) { - this(jsch.instLogger); - } - KeyPair(JSch.InstanceLogger instLogger) { this.instLogger = instLogger; } From 23b5265f83160ae41c47a7d39d92a3481bd6350b Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Mon, 17 Jul 2023 06:31:29 -0500 Subject: [PATCH 058/301] Tweak OSGi bundle manifest to allow Log4j 3. --- ChangeLog.md | 1 + pom.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 500abf19..dee777b8 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,6 @@ * [0.2.10](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.10) * Fix new Java 21 compiler warning: `possible 'this' escape before subclass is fully initialized`. + * Tweak OSGi bundle manifest to allow Log4j 3. * [0.2.9](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.9) * [#293](https://github.com/mwiede/jsch/issues/293) allow UserAuthNone to be extended. * Make JGSS module optional. diff --git a/pom.xml b/pom.xml index aa9792e4..3fdd037d 100644 --- a/pom.xml +++ b/pom.xml @@ -404,7 +404,7 @@ com.jcraft.jsch;-noimport:=true Date: Fri, 21 Jul 2023 09:19:08 -0500 Subject: [PATCH 059/301] #362 fix PEM key parsing to work with windows line endings. --- ChangeLog.md | 1 + src/main/java/com/jcraft/jsch/KeyPair.java | 9 ++++++--- src/test/java/com/jcraft/jsch/KeyPairTest.java | 2 ++ src/test/resources/docker/authorized_keys.KeyPairIT | 1 + src/test/resources/issue362_rsa | 3 +++ src/test/resources/issue362_rsa.pub | 1 + 6 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 src/test/resources/issue362_rsa create mode 100644 src/test/resources/issue362_rsa.pub diff --git a/ChangeLog.md b/ChangeLog.md index dee777b8..1062e35a 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,7 @@ * [0.2.10](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.10) * Fix new Java 21 compiler warning: `possible 'this' escape before subclass is fully initialized`. * Tweak OSGi bundle manifest to allow Log4j 3. + * [#362](https://github.com/mwiede/jsch/issues/362) fix PEM key parsing to work with windows line endings. * [0.2.9](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.9) * [#293](https://github.com/mwiede/jsch/issues/293) allow UserAuthNone to be extended. * Make JGSS module optional. diff --git a/src/main/java/com/jcraft/jsch/KeyPair.java b/src/main/java/com/jcraft/jsch/KeyPair.java index 7e29f888..041a4862 100644 --- a/src/main/java/com/jcraft/jsch/KeyPair.java +++ b/src/main/java/com/jcraft/jsch/KeyPair.java @@ -891,6 +891,7 @@ static KeyPair load(JSch.InstanceLogger instLogger, byte[] prvkey, byte[] pubkey start = 0; i = 0; + int xds = 0; int _len = _buf.length; while (i < _len) { @@ -898,8 +899,10 @@ static KeyPair load(JSch.InstanceLogger instLogger, byte[] prvkey, byte[] pubkey boolean xd = (_buf[i - 1] == '\r'); // ignore \n (or \r\n) System.arraycopy(_buf, i + 1, _buf, i - (xd ? 1 : 0), _len - (i + 1)); - if (xd) + if (xd) { _len--; + xds++; + } _len--; continue; } @@ -909,8 +912,8 @@ static KeyPair load(JSch.InstanceLogger instLogger, byte[] prvkey, byte[] pubkey i++; } - if (i - start > 0) - data = Util.fromBase64(_buf, start, i - start); + if (i - xds - start > 0) + data = Util.fromBase64(_buf, start, i - xds - start); Util.bzero(_buf); } diff --git a/src/test/java/com/jcraft/jsch/KeyPairTest.java b/src/test/java/com/jcraft/jsch/KeyPairTest.java index 9ab555a3..066382db 100644 --- a/src/test/java/com/jcraft/jsch/KeyPairTest.java +++ b/src/test/java/com/jcraft/jsch/KeyPairTest.java @@ -35,6 +35,8 @@ static Stream keyArgs() { Arguments.of("docker/ssh_host_dsa_key", null, "ssh-dss"), // encrypted dsa Arguments.of("encrypted_openssh_private_key_dsa", "secret123", "ssh-dss"), + // unencrypted RSA with windows (\r\n) line endings + Arguments.of("issue362_rsa", null, "ssh-rsa"), // ecdsa EC private key format Arguments.of("docker/id_ecdsa256", null, "ecdsa-sha2-nistp256"), // Arguments.of("docker/id_ecdsa384", null, "ecdsa-sha2-nistp384"), // diff --git a/src/test/resources/docker/authorized_keys.KeyPairIT b/src/test/resources/docker/authorized_keys.KeyPairIT index fc007f26..ac83da75 100644 --- a/src/test/resources/docker/authorized_keys.KeyPairIT +++ b/src/test/resources/docker/authorized_keys.KeyPairIT @@ -5,6 +5,7 @@ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDNVEfQu64p2GczvWj0AlncuNG+PzPd0jZ1/hfx/JDz ssh-dss AAAAB3NzaC1kc3MAAACBAKCQzxCEIM7yb5fbSmuJCz/+v40WEbULx4JKCXBb7zmRtDtweBqUJXDM1bMjQ4VwGB1EkfMZJQR7rPrOAxfdMdCpkqgPR0+xlljZLVarSJHwt1KR9EudUjUdD2ZrPlvPlG1sAyvMVTK5KCx2QaS2Bn/gukxrvT7DkaqCFHg2P7rLAAAAFQCF+m0B12XxhF1P+3hF3ktGmfYpywAAAIBX+azef1TX90FwS7vyngCrdJsOYqWtj1zQ8MlrwrWL0jdbjcIG/0vcq1x84LTgs+hAPylDBCGGJa/td88kJ6jIUeWiebRUG0zEH8LM+nehQA5O6TuEV3U0Dg73I0Mb04ZzN2GqYqW+KwHdiaU5M8XQv3V/PCmY8d7R5WcMKKDCcQAAAIEAmy0FgQoaWyHdD84b7zD0YjziMsVELAbGWwdxNuNe6wtACcctCdIQigQYaC2HwGjlDKVMjQfd4RWArshg7p0PlEw7//HSgoVhwcBbDpmWGCS6TxSSQpDmdDgiVegERMYjo2BZoZQTuJIx/BhQggVISkELwZfsi1BnPC5Aecq7ILI= test ssh-dss AAAAB3NzaC1kc3MAAACBAMKmaZwslPWE83wv+Ofl9oaMeOR03Yk0cyDc5fSAgjepXZQR5sps0KFORRufI6dLQHY4XLoyPc/Hr0ra+vY/l+p20cJVjQ07oosPU/d2eLdZ66rdjXCyrJPjFjnNJtumnBnJZqWGObKspnWk73vPOflReyGpUFe51PF1usur3uDLAAAAFQC3dSlxZZVNbvqjJpg8/oSMuG27/QAAAIEApkd3miYVc/Cl1QwdqwInIjby1yGNCfFsZALGBYc67lkd5lGBdNlL+fgi+BwC6UXu5OAqWB/b9OtvJR8NRcM77V252IER4t95t2ZdG66M1T5q1aOVL/ehPZFHf0oPXHJLcsybzqKFAtQj5hEbnrwJYW0fWi87C9LApplzPTVYQikAAACAUEu5tFmImzyQsUBMN/j1GWCCSVznjfRHkeGwx5koC0D2iK3mMphnF9avsoX2PrboEbGqy69JPCekKQiPPWxcQRTRqFS/ySkECJ5lJ2zJrW1whjLQEJbOq7WmusSML9UXCpNSwCqhJxPYx5a8Pq7lrrBP21jT/Z/A4m4c4wMkLXo= test ssh-dss AAAAB3NzaC1kc3MAAACBAPmIBCP1AA8EiTL0VAdzau+1KuRmPkg+H2du4zt4ifhzEx4MscZ7cpBsUAM/EBC/ECWTHzDiWyFFuenvxDlfTi9XxySdOKM6XGLkY7oLsY1y5bShyLrycxDD7MRQ8HpUc9TPzE2PDH4Od6o98e+vdXP0+IDUZGbSuwEnaABX/1+ZAAAAFQDIB9KUd1/gnzM4s4FXCQb7zCnjVwAAAIBptrE9g/ooRnh4bOWiA3/StxbjMRmA9f9bJbM55CinL4yf/GdGmeBp6YjDBxDyk1oXmVJ2hLVXgW6kETbt+D01SouCTgLPlFwLFhqZQ+A4JQOKuLIBaM92hI7sAfTewkxbmAk/e1vyOeyfcQDhbncESzVBZrheXC1fTKv7O2PgbgAAAIBKhGEiNwKNA/pfYvkEbX90/jVoIEKZfqTk+PB2gbVMT98LWPaexrDwEGuCCK3KOtMncDai+0r1ujf1hzNJ4z43Z1n15tPvAIwQsObTL+eUQkVjHA8LXOq8n4yYyPidkjGzWcfBAm4Lm6vKkzFM3VRouQIHpWpjRl3wGTJZkOoH0Q== test +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDY+326Z0bUOn8kYUc399P2mr7Eh0E7Nc9zPrv80B05ykfmsCM053SiGYQgwP5aBzZk83PdWdYIK12U9eO5WzTwT2po9PrZT0AvsBGnU7MkzSSlXX79e9ELbGYNWV4DafT/VHxVwCuoctG7XKUorGA3ZHxGbhNWyo/+6LNwyCMcxfpjpCelJWn4MTwFqs0DVme4R2Sy+LaVg3Nv5Vbbi27cIbA+6Orit2ajDUUCHJvcQlpGrM6x9w0zbt4pUI6yHPCHIIqZEPzj1285GCF6ZQzi0TMEf4wHtA8fN1Xgn1vBw+IEkrAAnQUeTWOR1nc6CDFEGTlyYlIuz634I4BwfhBl test ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBBcLHSACx0yr1S902vlRRnXA12YpaXIOkZUXoNFb01+CxQBgGpVTEVMuakLpIW/XcD9ltu+c6Czk5WnBKEoHNuI= test ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBPKyvhX/3Q32EEhZKF6s+fEzfQwabsSpXgFJ2LwpGxKFxzE2jw4Nvwe9W3YbPyrZU6K2MMA7p7ZdJwdDP/tQ9dhttOGGSkea9Cq4dcdgC9cdBuQ4aGb8crmY3Z5wc1dPxQ== test ecdsa-sha2-nistp521 AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1MjEAAACFBAG3XTlAFoQd4iIBt5KoTHJk46v1AdZSd+wfCSpc2/GCzHNGVqidrKCrypszpkQOW6vYG8riilyfF36rJa9ipjR+5gDApLIe/ix1Fknr8MU6nWoYv2+NBTsEcaS/VTeiUuMKftMtlO2wOaWFcbZBQUAlb3LDnpMyYKCqIXhhl4vqCxBukg== test diff --git a/src/test/resources/issue362_rsa b/src/test/resources/issue362_rsa new file mode 100644 index 00000000..0c0e41d8 --- /dev/null +++ b/src/test/resources/issue362_rsa @@ -0,0 +1,3 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEowIBAAKCAQEA2Pt9umdG1Dp/JGFHN/fT9pq+xIdBOzXPcz67/NAdOcpH5rAjNOd0ohmEIMD+Wgc2ZPNz3VnWCCtdlPXjuVs08E9qaPT62U9AL7ARp1OzJM0kpV1+/XvRC2xmDVleA2n0/1R8VcArqHLRu1ylKKxgN2R8Rm4TVsqP/uizcMgjHMX6Y6QnpSVp+DE8BarNA1ZnuEdksvi2lYNzb+VW24tu3CGwPujq4rdmow1FAhyb3EJaRqzOsfcNM27eKVCOshzwhyCKmRD849dvORghemUM4tEzBH+MB7QPHzdV4J9bwcPiBJKwAJ0FHk1jkdZ3OggxRBk5cmJSLs+t+COAcH4QZQIDAQABAoIBAGcA5AuEEWyYJFkZ0Nwxyq6LgTn8VywLfGJiCo2WIfmYHA/X1666nXSCFmYSF+yW9exwYbVXezI/m9ol7CfGs1fM61/Nw/M7GuZId+jt4+H5fIb/3lPo3jDFEaEOpoGKYCKBcdCnPFJnx0ZhUYoAYmCJVDF++bE+0aKZxu0oJPr35Lda1hBeCfrb8fDReAAU71jIoOGyuSyOXlCVyT+OmBhVme0u2xDpdY8cd5t9YueTK7BFNjNt3sJOI4L+2wRskNwxqHCrECtuOXmzEyza7vqo8cjRGSx1HZfqhoKgiRpRkRmSi8p+X1+DZOVZuCxc3BTZ7WrPgVZhu7u9hsISKyECgYEA+C9ajUNsx7Hx9gOg6Zvr+zV461PjKI/0n9g0DTZ5RHdcAfeNs3ugmsiDK6b9SayUW08EVyveJ1OJjT/NPvdP0/KhCAjUt+kN0j9f9CPdHKEWoboDca8u67dayOAhC10mNhoAp3tFQryfgpb678GIzqnXkVjGgyWC/8Z81AN7uAkCgYEA39CcJAUVMc6FigTwoMOkdOgNK6qCxAxkNBTdfB/cBBtG3h8g49n0u/fAMjkfL6awdl53j3jVCP4pUZgSSqArLb0aGo84G2vP92iN3d3j/kPiox22w8KG2XR7tHLWcc+CFfk8mdiKdPFxaWVQaYJ6htGq9LGqY3sw5lVzmk0wlH0CgYEAuWim/WGhoo4NdPzA+cTCRqlr7GJ/EY558fBS8ov/jGafFdkawztYgEnLtJDMKH4FVzFwzK65CCggWqWPb7rSqERaiOYQBFTXPnqZ9InWZczyW1/bstJs+yu/ZtIJ3bN5GHHUi0pMM882Wxjv3q12xu2bXbo0k0Uy2GIwXzM6+gECgYBDByur0eXeC7aMdhxGWTEoXdKL8D3HTtq3ikQmhzgR9sVLglEMS9rybCkgIWFImQgh+vqdehd64Pso130q4jrsMMTfjWLFO42Fz8ck2e4M2PHH3f89M0XFXBAsI3Q7k2SnBgRzIpmcmi5X3SKu5oehVqt3KroXnu4vHQpI/LL+1QKBgD3zxf795zFXw53iZXtKkzYNQhEMVRzbx6dQE+tguB0YCb2vPvYaxfejg/02hCQ4twIMuMK18v0Y9W7E34C0m++lP8UbnHdR0Dsg9ryH7OlUMp4662060HWDnDy79swB/Nnk9dxf+BoPIXGny84bEpk6cLoiHuL6TRpQhuJ292DW +-----END RSA PRIVATE KEY----- diff --git a/src/test/resources/issue362_rsa.pub b/src/test/resources/issue362_rsa.pub new file mode 100644 index 00000000..d378cbe0 --- /dev/null +++ b/src/test/resources/issue362_rsa.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDY+326Z0bUOn8kYUc399P2mr7Eh0E7Nc9zPrv80B05ykfmsCM053SiGYQgwP5aBzZk83PdWdYIK12U9eO5WzTwT2po9PrZT0AvsBGnU7MkzSSlXX79e9ELbGYNWV4DafT/VHxVwCuoctG7XKUorGA3ZHxGbhNWyo/+6LNwyCMcxfpjpCelJWn4MTwFqs0DVme4R2Sy+LaVg3Nv5Vbbi27cIbA+6Orit2ajDUUCHJvcQlpGrM6x9w0zbt4pUI6yHPCHIIqZEPzj1285GCF6ZQzi0TMEf4wHtA8fN1Xgn1vBw+IEkrAAnQUeTWOR1nc6CDFEGTlyYlIuz634I4BwfhBl test From 432eebe1e8f9bcf81ba3cddf1929d11eb4265515 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Fri, 21 Jul 2023 09:24:24 -0500 Subject: [PATCH 060/301] #361 guard against `UIKeyboardInteractive` implementations that include NULL elements in the `String[]` returned from `promptKeyboardInteractive()`. --- ChangeLog.md | 1 + src/main/java/com/jcraft/jsch/UserAuthKeyboardInteractive.java | 2 +- src/main/java/com/jcraft/jsch/UserAuthPassword.java | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 1062e35a..8ef5496f 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,7 @@ * Fix new Java 21 compiler warning: `possible 'this' escape before subclass is fully initialized`. * Tweak OSGi bundle manifest to allow Log4j 3. * [#362](https://github.com/mwiede/jsch/issues/362) fix PEM key parsing to work with windows line endings. + * [#361](https://github.com/mwiede/jsch/issues/361) guard against `UIKeyboardInteractive` implementations that include NULL elements in the `String[]` returned from `promptKeyboardInteractive()`. * [0.2.9](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.9) * [#293](https://github.com/mwiede/jsch/issues/293) allow UserAuthNone to be extended. * Make JGSS module optional. diff --git a/src/main/java/com/jcraft/jsch/UserAuthKeyboardInteractive.java b/src/main/java/com/jcraft/jsch/UserAuthKeyboardInteractive.java index c7aff920..cd5d5eda 100644 --- a/src/main/java/com/jcraft/jsch/UserAuthKeyboardInteractive.java +++ b/src/main/java/com/jcraft/jsch/UserAuthKeyboardInteractive.java @@ -141,7 +141,7 @@ public boolean start(Session session) throws Exception { if (_response != null) { response = new byte[_response.length][]; for (int i = 0; i < _response.length; i++) { - response[i] = Util.str2byte(_response[i]); + response[i] = _response[i] != null ? Util.str2byte(_response[i]) : Util.empty; } } } diff --git a/src/main/java/com/jcraft/jsch/UserAuthPassword.java b/src/main/java/com/jcraft/jsch/UserAuthPassword.java index 6d75da94..111e0def 100644 --- a/src/main/java/com/jcraft/jsch/UserAuthPassword.java +++ b/src/main/java/com/jcraft/jsch/UserAuthPassword.java @@ -127,7 +127,7 @@ public boolean start(Session session) throws Exception { throw new JSchAuthCancelException("password"); } - byte[] newpassword = Util.str2byte(response[0]); + byte[] newpassword = response[0] != null ? Util.str2byte(response[0]) : Util.empty; // send // byte SSH_MSG_USERAUTH_REQUEST(50) From a240218dd15af705829e955e6fc06bc3a0b18a8f Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Sat, 22 Jul 2023 05:40:19 -0500 Subject: [PATCH 061/301] Add a default implmentation of the deprecated `decrypt()` method to the `Identity` interface that throws an `UnsupportedOperationException`. --- ChangeLog.md | 1 + .../java/com/jcraft/jsch/AgentIdentity.java | 6 ------ src/main/java/com/jcraft/jsch/Identity.java | 12 ++++++++++-- .../java/com/jcraft/jsch/IdentityFile.java | 19 +++++-------------- 4 files changed, 16 insertions(+), 22 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 8ef5496f..ddc53f68 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -3,6 +3,7 @@ * Tweak OSGi bundle manifest to allow Log4j 3. * [#362](https://github.com/mwiede/jsch/issues/362) fix PEM key parsing to work with windows line endings. * [#361](https://github.com/mwiede/jsch/issues/361) guard against `UIKeyboardInteractive` implementations that include NULL elements in the `String[]` returned from `promptKeyboardInteractive()`. + * Add a default implmentation of the deprecated `decrypt()` method to the `Identity` interface that throws an `UnsupportedOperationException`. * [0.2.9](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.9) * [#293](https://github.com/mwiede/jsch/issues/293) allow UserAuthNone to be extended. * Make JGSS module optional. diff --git a/src/main/java/com/jcraft/jsch/AgentIdentity.java b/src/main/java/com/jcraft/jsch/AgentIdentity.java index 2fe5a2bc..3f83e4fb 100644 --- a/src/main/java/com/jcraft/jsch/AgentIdentity.java +++ b/src/main/java/com/jcraft/jsch/AgentIdentity.java @@ -60,12 +60,6 @@ public byte[] getSignature(byte[] data, String alg) { return agent.sign(blob, data, alg); } - @Override - @Deprecated - public boolean decrypt() { - throw new RuntimeException("not implemented"); - } - @Override public String getAlgName() { return algname; diff --git a/src/main/java/com/jcraft/jsch/Identity.java b/src/main/java/com/jcraft/jsch/Identity.java index 5aee38c8..f27c36bb 100644 --- a/src/main/java/com/jcraft/jsch/Identity.java +++ b/src/main/java/com/jcraft/jsch/Identity.java @@ -83,22 +83,30 @@ public default byte[] getSignature(byte[] data, String alg) { } /** + * This method is deprecated and the default implmentation of this method will throw an + * {@link UnsupportedOperationException}. + * * @deprecated The decryption should be done automatically in {@link #setPassphrase(byte[])} + * @return true if the decryption is succeeded or this identity is not cyphered. * @see #setPassphrase(byte[]) */ @Deprecated - public boolean decrypt(); + public default boolean decrypt() { + throw new UnsupportedOperationException("not implemented"); + } /** * Returns the name of the key algorithm. * - * @return "ssh-rsa" or "ssh-dss" + * @return the name of the key algorithm */ public String getAlgName(); /** * Returns the name of this identity. It will be useful to identify this object in the * {@link IdentityRepository}. + * + * @return the name of this identity */ public String getName(); diff --git a/src/main/java/com/jcraft/jsch/IdentityFile.java b/src/main/java/com/jcraft/jsch/IdentityFile.java index 89555674..af55a0b4 100644 --- a/src/main/java/com/jcraft/jsch/IdentityFile.java +++ b/src/main/java/com/jcraft/jsch/IdentityFile.java @@ -45,7 +45,7 @@ static IdentityFile newInstance(String name, byte[] prvkey, byte[] pubkey, return new IdentityFile(name, kpair); } - private IdentityFile(String name, KeyPair kpair) throws JSchException { + private IdentityFile(String name, KeyPair kpair) { this.identity = name; this.kpair = kpair; } @@ -94,30 +94,21 @@ public byte[] getSignature(byte[] data, String alg) { return kpair.getSignature(data, alg); } - /** - * @deprecated This method should not be invoked. - * @see #setPassphrase(byte[] passphrase) - */ - @Override - @Deprecated - public boolean decrypt() { - throw new RuntimeException("not implemented"); - } - /** * Returns the name of the key algorithm. * - * @return "ssh-rsa" or "ssh-dss" + * @return the name of the key algorithm */ @Override public String getAlgName() { - byte[] name = kpair.getKeyTypeName(); - return Util.byte2str(name); + return kpair.getKeyTypeString(); } /** * Returns the name of this identity. It will be useful to identify this object in the * {@link IdentityRepository}. + * + * @return the name of this identity */ @Override public String getName() { From 57469223f15de3263b9e7951e58b94389e8d8ef1 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Sat, 22 Jul 2023 05:57:15 -0500 Subject: [PATCH 062/301] Switch to Commons IO since Guava is no longer pulled in as a transitive dependency of SLF4J Test. --- pom.xml | 12 ++++++------ .../java/com/jcraft/jsch/AbstractBufferMargin.java | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 3fdd037d..654bea71 100644 --- a/pom.xml +++ b/pom.xml @@ -156,15 +156,15 @@ test - com.kohlschutter.junixsocket - junixsocket-native-common - ${junixsocket.version} + commons-io + commons-io + 2.13.0 test - com.google.guava - guava - 32.1.1-jre + com.kohlschutter.junixsocket + junixsocket-native-common + ${junixsocket.version} test diff --git a/src/test/java/com/jcraft/jsch/AbstractBufferMargin.java b/src/test/java/com/jcraft/jsch/AbstractBufferMargin.java index 0af63f77..508de07c 100644 --- a/src/test/java/com/jcraft/jsch/AbstractBufferMargin.java +++ b/src/test/java/com/jcraft/jsch/AbstractBufferMargin.java @@ -6,7 +6,6 @@ import com.github.valfirst.slf4jtest.LoggingEvent; import com.github.valfirst.slf4jtest.TestLogger; import com.github.valfirst.slf4jtest.TestLoggerFactory; -import com.google.common.io.ByteStreams; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -17,6 +16,7 @@ import java.util.List; import java.util.Random; import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.io.input.BoundedInputStream; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; @@ -209,7 +209,7 @@ private void doScp(Session session, boolean debugException) throws Exception { byte[] buf = new byte[17]; is.read(buf, 0, 17); sendAck(os); - Files.copy(ByteStreams.limit(is, 100L * 1024L), out); + Files.copy(new BoundedInputStream(is, 100L * 1024L), out); checkAck(is); sendAck(os); } From 932ee2797c26b25223418805a5bd93fbf8b07a36 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jul 2023 20:18:46 +0000 Subject: [PATCH 063/301] Bump org.junit.jupiter:junit-jupiter from 5.9.3 to 5.10.0 Bumps [org.junit.jupiter:junit-jupiter](https://github.com/junit-team/junit5) from 5.9.3 to 5.10.0. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.9.3...r5.10.0) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3fdd037d..99b40546 100644 --- a/pom.xml +++ b/pom.xml @@ -129,7 +129,7 @@ org.junit.jupiter junit-jupiter - 5.9.3 + 5.10.0 test From f0c664d91337e2de86c17f0551415a481df12de8 Mon Sep 17 00:00:00 2001 From: release-bot Date: Wed, 26 Jul 2023 14:00:10 +0000 Subject: [PATCH 064/301] [maven-release-plugin] prepare release jsch-0.2.10 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index c90f9b42..344dd42b 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.mwiede jsch jar - 0.2.10-SNAPSHOT + 0.2.10 JSch https://github.com/mwiede/jsch JSch is a pure Java implementation of SSH2 @@ -12,7 +12,7 @@ scm:git:https://github.com/mwiede/jsch.git scm:git:https://github.com/mwiede/jsch.git https://github.com/mwiede/jsch - HEAD + jsch-0.2.10 @@ -73,7 +73,7 @@ - 2023-05-25T19:43:01Z + 2023-07-26T13:59:00Z UTF-8 UTF-8 true From 22f6133c110695b317ecfbde747d8fb90b15ad01 Mon Sep 17 00:00:00 2001 From: release-bot Date: Wed, 26 Jul 2023 14:00:14 +0000 Subject: [PATCH 065/301] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 344dd42b..f496cff3 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.mwiede jsch jar - 0.2.10 + 0.2.11-SNAPSHOT JSch https://github.com/mwiede/jsch JSch is a pure Java implementation of SSH2 @@ -12,7 +12,7 @@ scm:git:https://github.com/mwiede/jsch.git scm:git:https://github.com/mwiede/jsch.git https://github.com/mwiede/jsch - jsch-0.2.10 + HEAD @@ -73,7 +73,7 @@ - 2023-07-26T13:59:00Z + 2023-07-26T14:00:14Z UTF-8 UTF-8 true From 37cdb811e605d5db3fde9584f55bad61f0771a73 Mon Sep 17 00:00:00 2001 From: Matthias Wiedemann Date: Thu, 27 Jul 2023 09:29:56 +0200 Subject: [PATCH 066/301] Update Readme.md --- Readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 1e6f8260..0c892ecb 100644 --- a/Readme.md +++ b/Readme.md @@ -33,7 +33,7 @@ with com.github.mwiede jsch - 0.2.9 + 0.2.10 ``` @@ -43,7 +43,7 @@ When you have an artifact `foo:bar`, which contains `com.jcraft:jsch` as a trans com.github.mwiede jsch - 0.2.9 + 0.2.10 foo From 46ae65b058226fe748f8983c74f7982de94c45aa Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Tue, 1 Aug 2023 07:08:53 -0500 Subject: [PATCH 067/301] Update dependencies. --- pom.xml | 4 ++-- src/main/java/com/jcraft/jsch/bc/CAST128CBC.java | 6 ++++-- src/main/java/com/jcraft/jsch/bc/CAST128CTR.java | 8 +++++--- src/main/java/com/jcraft/jsch/bc/SEEDCBC.java | 6 ++++-- src/main/java/com/jcraft/jsch/bc/TwofishCBC.java | 6 ++++-- src/main/java/com/jcraft/jsch/bc/TwofishCTR.java | 8 +++++--- 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index f496cff3..0133c58e 100644 --- a/pom.xml +++ b/pom.xml @@ -87,7 +87,7 @@ org.bouncycastle bcprov-jdk18on - 1.75 + 1.76 true @@ -405,7 +405,7 @@ Date: Tue, 1 Aug 2023 10:25:32 -0500 Subject: [PATCH 068/301] #369 fix multi-line PEM key parsing to work with windows line endings due to regression from previous fix for #362. --- ChangeLog.md | 2 + src/main/java/com/jcraft/jsch/KeyPair.java | 8 ++-- .../java/com/jcraft/jsch/KeyPairTest.java | 4 ++ .../docker/authorized_keys.KeyPairIT | 4 ++ .../encrypted_issue_369_rsa_opensshv1 | 39 +++++++++++++++++ .../encrypted_issue_369_rsa_opensshv1.pub | 1 + .../resources/encrypted_issue_369_rsa_pem | 42 +++++++++++++++++++ .../resources/encrypted_issue_369_rsa_pem.pub | 1 + src/test/resources/issue_369_rsa_opensshv1 | 39 +++++++++++++++++ .../resources/issue_369_rsa_opensshv1.pub | 1 + src/test/resources/issue_369_rsa_pem | 39 +++++++++++++++++ src/test/resources/issue_369_rsa_pem.pub | 1 + 12 files changed, 177 insertions(+), 4 deletions(-) create mode 100644 src/test/resources/encrypted_issue_369_rsa_opensshv1 create mode 100644 src/test/resources/encrypted_issue_369_rsa_opensshv1.pub create mode 100644 src/test/resources/encrypted_issue_369_rsa_pem create mode 100644 src/test/resources/encrypted_issue_369_rsa_pem.pub create mode 100644 src/test/resources/issue_369_rsa_opensshv1 create mode 100644 src/test/resources/issue_369_rsa_opensshv1.pub create mode 100644 src/test/resources/issue_369_rsa_pem create mode 100644 src/test/resources/issue_369_rsa_pem.pub diff --git a/ChangeLog.md b/ChangeLog.md index ddc53f68..7199735e 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,5 @@ +* [0.2.11](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.11) + * [#369](https://github.com/mwiede/jsch/issues/369) fix multi-line PEM key parsing to work with windows line endings due to regression from previous fix for [#362](https://github.com/mwiede/jsch/issues/362). * [0.2.10](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.10) * Fix new Java 21 compiler warning: `possible 'this' escape before subclass is fully initialized`. * Tweak OSGi bundle manifest to allow Log4j 3. diff --git a/src/main/java/com/jcraft/jsch/KeyPair.java b/src/main/java/com/jcraft/jsch/KeyPair.java index 041a4862..f967d219 100644 --- a/src/main/java/com/jcraft/jsch/KeyPair.java +++ b/src/main/java/com/jcraft/jsch/KeyPair.java @@ -891,7 +891,7 @@ static KeyPair load(JSch.InstanceLogger instLogger, byte[] prvkey, byte[] pubkey start = 0; i = 0; - int xds = 0; + boolean xds = false; int _len = _buf.length; while (i < _len) { @@ -901,7 +901,7 @@ static KeyPair load(JSch.InstanceLogger instLogger, byte[] prvkey, byte[] pubkey System.arraycopy(_buf, i + 1, _buf, i - (xd ? 1 : 0), _len - (i + 1)); if (xd) { _len--; - xds++; + xds = true; } _len--; continue; @@ -912,8 +912,8 @@ static KeyPair load(JSch.InstanceLogger instLogger, byte[] prvkey, byte[] pubkey i++; } - if (i - xds - start > 0) - data = Util.fromBase64(_buf, start, i - xds - start); + if (i - (xds ? 1 : 0) - start > 0) + data = Util.fromBase64(_buf, start, i - (xds ? 1 : 0) - start); Util.bzero(_buf); } diff --git a/src/test/java/com/jcraft/jsch/KeyPairTest.java b/src/test/java/com/jcraft/jsch/KeyPairTest.java index 066382db..f8b007e7 100644 --- a/src/test/java/com/jcraft/jsch/KeyPairTest.java +++ b/src/test/java/com/jcraft/jsch/KeyPairTest.java @@ -37,6 +37,10 @@ static Stream keyArgs() { Arguments.of("encrypted_openssh_private_key_dsa", "secret123", "ssh-dss"), // unencrypted RSA with windows (\r\n) line endings Arguments.of("issue362_rsa", null, "ssh-rsa"), + Arguments.of("issue_369_rsa_opensshv1", null, "ssh-rsa"), + Arguments.of("issue_369_rsa_pem", null, "ssh-rsa"), + Arguments.of("encrypted_issue_369_rsa_opensshv1", "secret123", "ssh-rsa"), + Arguments.of("encrypted_issue_369_rsa_pem", "secret123", "ssh-rsa"), // ecdsa EC private key format Arguments.of("docker/id_ecdsa256", null, "ecdsa-sha2-nistp256"), // Arguments.of("docker/id_ecdsa384", null, "ecdsa-sha2-nistp384"), // diff --git a/src/test/resources/docker/authorized_keys.KeyPairIT b/src/test/resources/docker/authorized_keys.KeyPairIT index ac83da75..555a29d4 100644 --- a/src/test/resources/docker/authorized_keys.KeyPairIT +++ b/src/test/resources/docker/authorized_keys.KeyPairIT @@ -6,6 +6,10 @@ ssh-dss AAAAB3NzaC1kc3MAAACBAKCQzxCEIM7yb5fbSmuJCz/+v40WEbULx4JKCXBb7zmRtDtweBqU ssh-dss AAAAB3NzaC1kc3MAAACBAMKmaZwslPWE83wv+Ofl9oaMeOR03Yk0cyDc5fSAgjepXZQR5sps0KFORRufI6dLQHY4XLoyPc/Hr0ra+vY/l+p20cJVjQ07oosPU/d2eLdZ66rdjXCyrJPjFjnNJtumnBnJZqWGObKspnWk73vPOflReyGpUFe51PF1usur3uDLAAAAFQC3dSlxZZVNbvqjJpg8/oSMuG27/QAAAIEApkd3miYVc/Cl1QwdqwInIjby1yGNCfFsZALGBYc67lkd5lGBdNlL+fgi+BwC6UXu5OAqWB/b9OtvJR8NRcM77V252IER4t95t2ZdG66M1T5q1aOVL/ehPZFHf0oPXHJLcsybzqKFAtQj5hEbnrwJYW0fWi87C9LApplzPTVYQikAAACAUEu5tFmImzyQsUBMN/j1GWCCSVznjfRHkeGwx5koC0D2iK3mMphnF9avsoX2PrboEbGqy69JPCekKQiPPWxcQRTRqFS/ySkECJ5lJ2zJrW1whjLQEJbOq7WmusSML9UXCpNSwCqhJxPYx5a8Pq7lrrBP21jT/Z/A4m4c4wMkLXo= test ssh-dss AAAAB3NzaC1kc3MAAACBAPmIBCP1AA8EiTL0VAdzau+1KuRmPkg+H2du4zt4ifhzEx4MscZ7cpBsUAM/EBC/ECWTHzDiWyFFuenvxDlfTi9XxySdOKM6XGLkY7oLsY1y5bShyLrycxDD7MRQ8HpUc9TPzE2PDH4Od6o98e+vdXP0+IDUZGbSuwEnaABX/1+ZAAAAFQDIB9KUd1/gnzM4s4FXCQb7zCnjVwAAAIBptrE9g/ooRnh4bOWiA3/StxbjMRmA9f9bJbM55CinL4yf/GdGmeBp6YjDBxDyk1oXmVJ2hLVXgW6kETbt+D01SouCTgLPlFwLFhqZQ+A4JQOKuLIBaM92hI7sAfTewkxbmAk/e1vyOeyfcQDhbncESzVBZrheXC1fTKv7O2PgbgAAAIBKhGEiNwKNA/pfYvkEbX90/jVoIEKZfqTk+PB2gbVMT98LWPaexrDwEGuCCK3KOtMncDai+0r1ujf1hzNJ4z43Z1n15tPvAIwQsObTL+eUQkVjHA8LXOq8n4yYyPidkjGzWcfBAm4Lm6vKkzFM3VRouQIHpWpjRl3wGTJZkOoH0Q== test ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDY+326Z0bUOn8kYUc399P2mr7Eh0E7Nc9zPrv80B05ykfmsCM053SiGYQgwP5aBzZk83PdWdYIK12U9eO5WzTwT2po9PrZT0AvsBGnU7MkzSSlXX79e9ELbGYNWV4DafT/VHxVwCuoctG7XKUorGA3ZHxGbhNWyo/+6LNwyCMcxfpjpCelJWn4MTwFqs0DVme4R2Sy+LaVg3Nv5Vbbi27cIbA+6Orit2ajDUUCHJvcQlpGrM6x9w0zbt4pUI6yHPCHIIqZEPzj1285GCF6ZQzi0TMEf4wHtA8fN1Xgn1vBw+IEkrAAnQUeTWOR1nc6CDFEGTlyYlIuz634I4BwfhBl test +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQD1ub4yJ8TCXgPaTtASEA034K+85zo2MDlRCB7tHgpmIpK7btPxizYEPEPywVnBRGMJnhIyKKHc7AHzCos3tkGVYNBlDGmnoaZTeZqhmsRSqqxHyfIRQ1T+aGIN4scliZ+iW8RI/djYyfPlcAR3Kku+Q3xsR5K2yzzxZiYB/rD9XjvRRtc7cYZlHaMe2NBtQhh3hamQVSEJMjfSCpq4okULk0UytXhdbPtP/tLDvqeK7op+q97hFS0wRY9xTaNM+qUhuhaKNbhuexgGQBk7We45LcR6O3XwjAB+X7owa4JtKx9oKY93+3qtM+5+6nRnFnkB/GL5fdKPmIswQ1vOSgGeEhg/M0yzX0PEMx4qfczpUp2rFtMTNg9O6Xz9qJCnZy/I1EmK6FEXerpEY0x41mY2NBBor9vataM9IxzJ1VIra8JYjnPqG48V9LFhSEpFfi1CquqJu1fmtxtH4YNWWNQECKp0s+WmxKAu2ZAAr1wl+tNkkiZOaDSluT14qMkSEjU= test +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCze/5G1FPKvgcnLXqHV4jbUfO+gi75BUKUWKBowdg63kr9e3GdGVmwtBBWTJMyxEWVtJMrH8CARWoyViILQy9oFfbbcwuAnfhVjdPVNpK7RL1ZwCCrsg6UDpE+Vp4rTWzUcDXUyI2MZrePJCwU0+UWdvoEJXwE2Nitb+sS802IsdlwiRj9knzKJ5rVcpGpQ0Qkc0jbeNDfznRAE8ARawkDLcXEio9V6t4psAWf3BbHGYec9PZAYcdzCHcwmLmTT/DSOF+ut2fxvjBydWJzGHmKyozlFNjThgXt0i0fcedLG0oAHNNBL8UeEYQ7H0glbT9rsnMqOAtgBYD/nJGfMkMMjP7NRS0Y0jtkmY8PQ3l7RkHTFeKVkKpKtyD3+LsfuOZkh5A6rhOZgMP9+22AZhIXGho9kJZSSF7B9CWa+TCr5iZo9lLXbeMFRrk5Ltg7BNHkO5Rx8SGroGYGkLXt89+eL+Ht1I4jbq1fWF55YQYnTOovvnNVVCp4i0c8KlNAqSM= test +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC96PvllVEOgtQdHnaoga3gi8md+/lUwBG0SOv4co9QaJ2kvJZDTiSLmJc4euEuciiplvzKpKSWSVqaZLboXiVVt8MnPmIwIlp8bhIqJ+0431FNWWq6RA/4EszHiARxMIwUqw+svN2GMm5fGr+PK3FR6mXGjiVlv4/5Vb0BCUjgB0vIqq123DmKpxrT6S3Ik5vYCCn0zKtuWxfxp3hpCqC2TdqD7/rFTX/AstmlhTO4FRDEK/7JNBSWY8+9/rQS/c/HSSW7qMGEoGFkELKSYFSdwLcyAMS1HySzNR1SuyBLDsOSaN5iWm5cBqKIK175Uc3Xe3fIn6+C5ld0m/nN75bw6QJiDH7I2jMYDTBpDqztBiqdjcSwvNTogGQg/oJLC7aAz+E5gfkTsg/Q6bPf6quyPIQ+KKH5v2YVFQIw2Te0X7/OZACsqUnCbGiDXCixPTTGoRypcR0MQDJxR497y7zvO4kiqQpsdBoELuhWSW8+9BcovL4/jSyqUEGvGYoh/QM= test +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCqGObM6DyGcra+/eBdm7mIvnLM9oUDUwpT3hRbF7S7V6bb64EuFlduGXJKK+i4/a/ls1Sm3GVwnWvwuRxrVXgv1497MYDzDcflfm+bQLUN38qNscVhn3jdtFuCTIc7VKmtEd9zn4HVzQhUYWq/oiqwOsDeP1QidWbNwgBthCxzhfdi9XUpdpT3Tm/mtLwEz8KZ2kP9VdfXBql6NI64COcI+B2nzE2YwxZsLGFj1orstRZ3WOLTJdLtQ1NhBQqTEwFD06Jhf50wo13xV84jWeZom+ylJQcj9njnfH8Kf7T+1eyBAqCPLvS6kM5Q9J6bGPj67Hkp96zPT/y3Gh1le80o3JrYjo20NqWzO+/OIXilrDoYdUKJbgoM7GXtMlxFNEnj7BIf6TLNZJY9bA6dw1yFs9wOl9LRhC1zUC6kESx8DIiqSpxrZTF0ScgvC/gKqX6K81ovJBklrAuTQpTqGKOW2eY5jqiRAVa7Gx8sPPtHkGqodD/sFOKurggVDf2Y1vs= test ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBBcLHSACx0yr1S902vlRRnXA12YpaXIOkZUXoNFb01+CxQBgGpVTEVMuakLpIW/XcD9ltu+c6Czk5WnBKEoHNuI= test ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBPKyvhX/3Q32EEhZKF6s+fEzfQwabsSpXgFJ2LwpGxKFxzE2jw4Nvwe9W3YbPyrZU6K2MMA7p7ZdJwdDP/tQ9dhttOGGSkea9Cq4dcdgC9cdBuQ4aGb8crmY3Z5wc1dPxQ== test ecdsa-sha2-nistp521 AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1MjEAAACFBAG3XTlAFoQd4iIBt5KoTHJk46v1AdZSd+wfCSpc2/GCzHNGVqidrKCrypszpkQOW6vYG8riilyfF36rJa9ipjR+5gDApLIe/ix1Fknr8MU6nWoYv2+NBTsEcaS/VTeiUuMKftMtlO2wOaWFcbZBQUAlb3LDnpMyYKCqIXhhl4vqCxBukg== test diff --git a/src/test/resources/encrypted_issue_369_rsa_opensshv1 b/src/test/resources/encrypted_issue_369_rsa_opensshv1 new file mode 100644 index 00000000..bb9a2709 --- /dev/null +++ b/src/test/resources/encrypted_issue_369_rsa_opensshv1 @@ -0,0 +1,39 @@ +-----BEGIN OPENSSH PRIVATE KEY----- +b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jdHIAAAAGYmNyeXB0AAAAGAAAABCd+5LZfU +vM8no5y5XUnD99AAAAEAAAAAEAAAGXAAAAB3NzaC1yc2EAAAADAQABAAABgQC96PvllVEO +gtQdHnaoga3gi8md+/lUwBG0SOv4co9QaJ2kvJZDTiSLmJc4euEuciiplvzKpKSWSVqaZL +boXiVVt8MnPmIwIlp8bhIqJ+0431FNWWq6RA/4EszHiARxMIwUqw+svN2GMm5fGr+PK3FR +6mXGjiVlv4/5Vb0BCUjgB0vIqq123DmKpxrT6S3Ik5vYCCn0zKtuWxfxp3hpCqC2TdqD7/ +rFTX/AstmlhTO4FRDEK/7JNBSWY8+9/rQS/c/HSSW7qMGEoGFkELKSYFSdwLcyAMS1HySz +NR1SuyBLDsOSaN5iWm5cBqKIK175Uc3Xe3fIn6+C5ld0m/nN75bw6QJiDH7I2jMYDTBpDq +ztBiqdjcSwvNTogGQg/oJLC7aAz+E5gfkTsg/Q6bPf6quyPIQ+KKH5v2YVFQIw2Te0X7/O +ZACsqUnCbGiDXCixPTTGoRypcR0MQDJxR497y7zvO4kiqQpsdBoELuhWSW8+9BcovL4/jS +yqUEGvGYoh/QMAAAWQCCm+hXX3/lj0BTGT+TRll0G/c21MVlKHmh4pSbWuWcVsNYf0Xk9T +AzQL2Aw2iIlCR0nZAb6fbeWkO7FcZwdUWgEH+qhUE5jnzsrGs8dVbuMQcCo//PRK5wPqGu +z1Na6IUSvuvVUk+t+spmVLOjbgKVmXD8NMz3yRrlb92bP/u10OWvHS2lQf8L4qyG0SCbsR ++mfKuuhquOvL+0hqeMwaMjcIeIDqF7XM3lYStliF8atc0KiyX3jNh3xzHZof791WmXgz6f +kHa0vpY/Ds84hkT0CKa7q7v08V2RXisdwfqs36sMMJDTSJbF8f72mSrX3ZiTDCRVzxxa7K +JOt6eKJMBlobsJvDq9cE1paypIiThIwdrcVKTtdk9QjWiVzalF5xrvYAO5rM9jt1RMvEHi +8uAuAz4rOqGlnNU3ruxTtyynAIk+Ao+TFxRwUfX053oJGCvvUgpQvIhK1PPTAJQxKL299C +Hsid01jDXujRCKURcFcBkjczHMV/Y35tBhRm31E5oQofONaejPLyna5RoKlfmw7feOqh1U +GhJPl0kX0RcOG4WafyXjDP8a4mlkukka2HxoVnI4DTo5rvNNifa1VN27jDcVJG9EoC4KdQ +Jn9jwrQtGgpYUC2Mw1yz8IImIjhzaOwuofuEa8XpSCDWN9EIF1+QNRFb8e8s8PkYG2qB3T +abxXFrZlXjG5xOpv2Nx5FfjLpzRXWNzyjy3boxJ2DMamcKoHsWV0FZe0dyoSWz0pVQc55Z +LcVH3pFM/mfyv5S3bEsoQsDHIoJJ1yAOHoAAKzKj8J6xqvXa6j71JIce68cIYx3Qrs3W92 +xrOAjVlE6M476C4lPJdNBxTdkClvgdnulzv56BYNAoBWtbuymZiwB1TZetSGDsDSdtD2rX +wNGHHdUceau+OEh+rsZpmFzBfN0ezyogzy+5FFVrlKFrcUnIlPm+1cgEncLES9AZttwkjx +HzUxdBgm7rq1sCB22Kld6dN5akRXGFC2DpU3t91XPw1lavTqudGC3ovMFfoFrfJPy95eVt +yAA73aHS93t0xZTxCkXff6sP0E2C/ztq38LP2SpvT7SZa250DLD+v3pdRgz5wYUNlnTlH/ +wvRdqHkEnQWwcOyoO33E/iZS/u88EjfMDMu3JbS/LR+0S7iZS5MSh8O3KUtNR51/qhP/Em +Q6v4R/2+odWi7yr0PrCsuyURaq44o12unHE2pzHmas5mN48+agF6thTUmiMR0csoMs/yEW +TeAbdPTEjxNc3cxvrMmnWhVCLFDNYRScq+O/PEWsPN7ofoYagUUM+TbgGGs7kWOOcyo/oN +gxMowxWX3sraUevHEpl8Fgbapl18W/ppNd1eIT965SiI2cHPzUW6aTPYW6y6BKOBHhX3np +EPf7ApjnUhuHF8Brvikgtu2eHoAA9gKFs/X7sOD8KWIhsV5tIr6psCqalOA4QGdMsmZuaW +GCIfeaCsMM/HcTJZzj8OBBpLAOC0/lSs8Y9qRqDK8Aid12Tp9FrtJKlvt5DsnsR8an4zsJ +e4k9sN7Z+bxVxKyhQulc16hSSUBJTQdCJ3fbdlyklTgx45maL8Q/bQhYlQ2y/EBIASwOwq +Gq5gJw1RNm2CaLBP/tjD+qCjIZ4DsPuHsdv1a51BGiTjt9YqV/eqXdZ+Npz89jFQw7WGc8 +AStzRvxNE7fIAZgK3LtlNNDpgEX0+g6VCPfiPrl8cvz003x1SMtSMYftPjbvuKosJaMu4K +g3t7vdQjTObNpuJMOcuTKiY3pJDBbNAcF1OKbzGpTF25zspvzHou60BKt1mQD4ktuSkh9k +IfwiPacrs5zA3S680z93Pt17M11tfMXgYpN7z34DCzdj5COdwo7Ei9Et3dxdv/Nzj83kxh +KmpEq3lxqRzHG2mb2h1zHQW3RR0= +-----END OPENSSH PRIVATE KEY----- diff --git a/src/test/resources/encrypted_issue_369_rsa_opensshv1.pub b/src/test/resources/encrypted_issue_369_rsa_opensshv1.pub new file mode 100644 index 00000000..2ba237d7 --- /dev/null +++ b/src/test/resources/encrypted_issue_369_rsa_opensshv1.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC96PvllVEOgtQdHnaoga3gi8md+/lUwBG0SOv4co9QaJ2kvJZDTiSLmJc4euEuciiplvzKpKSWSVqaZLboXiVVt8MnPmIwIlp8bhIqJ+0431FNWWq6RA/4EszHiARxMIwUqw+svN2GMm5fGr+PK3FR6mXGjiVlv4/5Vb0BCUjgB0vIqq123DmKpxrT6S3Ik5vYCCn0zKtuWxfxp3hpCqC2TdqD7/rFTX/AstmlhTO4FRDEK/7JNBSWY8+9/rQS/c/HSSW7qMGEoGFkELKSYFSdwLcyAMS1HySzNR1SuyBLDsOSaN5iWm5cBqKIK175Uc3Xe3fIn6+C5ld0m/nN75bw6QJiDH7I2jMYDTBpDqztBiqdjcSwvNTogGQg/oJLC7aAz+E5gfkTsg/Q6bPf6quyPIQ+KKH5v2YVFQIw2Te0X7/OZACsqUnCbGiDXCixPTTGoRypcR0MQDJxR497y7zvO4kiqQpsdBoELuhWSW8+9BcovL4/jSyqUEGvGYoh/QM= test diff --git a/src/test/resources/encrypted_issue_369_rsa_pem b/src/test/resources/encrypted_issue_369_rsa_pem new file mode 100644 index 00000000..b6469663 --- /dev/null +++ b/src/test/resources/encrypted_issue_369_rsa_pem @@ -0,0 +1,42 @@ +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: AES-128-CBC,D5AFEF41BADEB0A6ADDCC294C4C34402 + +BgIiIqe5ABrapndv+KDz2EoUj/QWtEJ81cCVLBJT05GTA93ZPYmwFOOHzwDtZN2n +36qqSkiytcPcF4onogR50qziz/k3cN38Eiiqyrm1kOrIkxaCUogy0I2vQvDSYr8v +CuW7btHpHpv8TlbWWNO2OGawH3ZYplNZoU8lPkHrGd8s0SdwHWjGm5pvKtbNRMjP +G8UYgBO4259oCRKpXbJJK2J7cH44itedZeiHPhh2gukqyFIaiu5m8ZG8X+sCnxw3 +DYYdm9C24uaC55Pfh7DTaGdvKXlprR816FUnqqF30Len+JegHbT3EG68PYsakIwr +O2h/jJo7Io61/w5lzoFoGrh2MJ73sHpsLk+ytQIghfUEHc1pBZnI9YcHhiHqEhUb +GZH/knfhR/V+OjFL8eXD+Mv6RHilxe22Dma0kk45B9rtAHa7wCtkRpQPBerUQ/Rz +uD39LPc5hS9tdvMVVZHJRCx10B+yvRo+CutuTpyZo27Hr5EtamGCgKU8BIr5EYaH +FkRAMy7Q+27kiXgD0H+DViyZZQ1gM09gxItQuw/E4tjjaAqsy/xnZtGdmKARqqZe +3oPXIv/bmLWrO9c2Hq8xFB5iJYRrzgmmt03RPMyrQLPw8gfbGVrehn1F9F5TLfdc +J2Ao2K+Bv7bTTh7OunwGXF/UmAphvREcH2yhB4VOr04R54z8Vo81x8kRJtTlbP1g +fsYHRK/BSG3R8pTge7MJwWLYW4lyGyNQ1G3NWbhsafbC2sBxm43uP1sO32SR7moe +t4Um+DzxNeVx1zaSuw0XSc/W87F5GuXKpYRmeaKo/EkC3LLKI2UFK/5iv9m3//Jn +6XPMA1jfiavN/hZwKTHImCdHP7uqEn0VwfmoNnSovZUcVikuPjToRPoxOYblPed4 +RDmsT1DrEO3zRiZ4wY/al1/Qs5ivojoAzwpuJDbG9C9H4B82gDvXcqAr8LeJS2gZ +9w3hD+8XJJMf3wA112RaoDJn7xzJC/fTmyq5tiS0pMkGP0bH9RVAVTVPoKLjs70m +oW81L/3Z6FK7t+6vDonQITZqal79jU7HNwb0Jelv95kT4jUtkzeLjLGgsBGRGBqg +ACAwFqMKqAZAmqCI2aai8ky054aNSi0CCEN+kQEs29BRzs7/+RdlPUZCQKeY9siT +5htrC1g8xn+F/HudIzcue6Vg0KmONCn/PjJbSjK5lyQc3PN8W6Fa6POJRZgHpkR/ +vfN+IJlh9vmU7CqZcT08SZDp/2x/eIq58yoBCBDwu46vr477+Vc25rSpl1Wt+9sj +PZ5WKLqHmPy8vBmG5nOv1p3OKHv/AL7LvhvBk/B33oK7mDI0HhGaHDmMyPrikI1n +DcStuKhNgtZxV6V5YLVfbGI92Q6bggyN9eslb2AMcPg3Jusw1wQHKtGBYTveQC3I +zakD00bl6eyR8L8GM7NQFlBWO6QAQRAjwbrop9uixrXFqJ+kcsJ2EXikhHOKpW8B +3uhmGkIokzbCy2SLy8ErzBPNea58vc4kI+CJEFANsrhOhrkIw+9+MVz6XnOUafb7 +mk4k9Vu+EdAT8zwFpdo4oDH3gO6Y7E6fzFvCWblXmy34xf2C2G7uxl2jHJFbqPxY +3sCcKfFMOZACsdiq4SqtgilzLvnyxf6QY704hIS4Tl6QpLVxshIDHVNW6TUJ7qwg +I1fDyFWFponmtV0pS28yYAEM7Eb4aoUvXWEeQh6PE+CPB/s/6UQ++IgM0INAt4kn +LIljwtHAcWtKvoWup4CHelnBpdEqzWjWbiopW1/166m6/BFNJKarUNZtuuj3vorU +rAi/pwNxQ9a32pNW9ox0ir/C04Aqb2Jj58BD+X/dw2PbfilHPNraOJqdiMn8802S +2Vlj8R3VpbeETBc8J4zRibV0ZL2TsNRlBPXAaCVJhBgqUdYGAeaLqioK3hdQqHA0 +y/c+DsjFwODP+jtfVYHTgKIeAS4BnUt/3TwfzdSC7CgdZztk9aPc9bhQrFM1rdZN +olV2k2nTHLtflLPvQWckL5W0vBYqELjwBCJ4fUG3aNRwoml00uYWWtliOA7qABW7 +dkX4Xx0iUwql00tEiugxHHOgC2S5cDmSeC2+emGFb8ca55nrxIkCJWG0wOm+/gtH +UDBHmgxD01dk4QFG5wF77AAIBXWuFcYVLp9wzgAIhnEqGbYy5+hzoCxYTjjIpUv5 +MA5A1z2Yc9n0Qvu08swzO9YvrRpQPy/3Ys2nVhLF8MSI6qn20o/sDYy8DAum4GIr +RaVuIIo7cnqkDGXjnVTtganrRfdS0YzUh7jkoxN0us9YBMKyJnNNIDMEJW5SOU2i +t2qluYBIdfEdvB/LWOgJt0YDQUtk0ed7RCQqauBKDPWLvZ+Q8j4DOdZgW8makCS1 +-----END RSA PRIVATE KEY----- diff --git a/src/test/resources/encrypted_issue_369_rsa_pem.pub b/src/test/resources/encrypted_issue_369_rsa_pem.pub new file mode 100644 index 00000000..92c85d94 --- /dev/null +++ b/src/test/resources/encrypted_issue_369_rsa_pem.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCqGObM6DyGcra+/eBdm7mIvnLM9oUDUwpT3hRbF7S7V6bb64EuFlduGXJKK+i4/a/ls1Sm3GVwnWvwuRxrVXgv1497MYDzDcflfm+bQLUN38qNscVhn3jdtFuCTIc7VKmtEd9zn4HVzQhUYWq/oiqwOsDeP1QidWbNwgBthCxzhfdi9XUpdpT3Tm/mtLwEz8KZ2kP9VdfXBql6NI64COcI+B2nzE2YwxZsLGFj1orstRZ3WOLTJdLtQ1NhBQqTEwFD06Jhf50wo13xV84jWeZom+ylJQcj9njnfH8Kf7T+1eyBAqCPLvS6kM5Q9J6bGPj67Hkp96zPT/y3Gh1le80o3JrYjo20NqWzO+/OIXilrDoYdUKJbgoM7GXtMlxFNEnj7BIf6TLNZJY9bA6dw1yFs9wOl9LRhC1zUC6kESx8DIiqSpxrZTF0ScgvC/gKqX6K81ovJBklrAuTQpTqGKOW2eY5jqiRAVa7Gx8sPPtHkGqodD/sFOKurggVDf2Y1vs= test diff --git a/src/test/resources/issue_369_rsa_opensshv1 b/src/test/resources/issue_369_rsa_opensshv1 new file mode 100644 index 00000000..2422781e --- /dev/null +++ b/src/test/resources/issue_369_rsa_opensshv1 @@ -0,0 +1,39 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIG4gIBAAKCAYEA9bm+MifEwl4D2k7QEhANN+CvvOc6NjA5UQge7R4KZiKSu27T +8Ys2BDxD8sFZwURjCZ4SMiih3OwB8wqLN7ZBlWDQZQxpp6GmU3maoZrEUqqsR8ny +EUNU/mhiDeLHJYmfolvESP3Y2Mnz5XAEdypLvkN8bEeStss88WYmAf6w/V470UbX +O3GGZR2jHtjQbUIYd4WpkFUhCTI30gqauKJFC5NFMrV4XWz7T/7Sw76niu6Kfqve +4RUtMEWPcU2jTPqlIboWijW4bnsYBkAZO1nuOS3Eejt18IwAfl+6MGuCbSsfaCmP +d/t6rTPufup0ZxZ5Afxi+X3Sj5iLMENbzkoBnhIYPzNMs19DxDMeKn3M6VKdqxbT +EzYPTul8/aiQp2cvyNRJiuhRF3q6RGNMeNZmNjQQaK/b2rWjPSMcydVSK2vCWI5z +6huPFfSxYUhKRX4tQqrqibtX5rcbR+GDVljUBAiqdLPlpsSgLtmQAK9cJfrTZJIm +Tmg0pbk9eKjJEhI1AgMBAAECggGAEOhyf2YAInWwoy1oIM4M8srZnNB2T3M7Bmne +Iue9xHBdk1sZZ1XyZhE1hbcrM2K+w9MmImBsXtS4f546nR9D3QD35fQYMwoq9TR5 +YORS3PNUfm4VY320E/tfv9/aXylcnCHfXDxnVudyileOXxrAcnuXTKYSINTUQTIL +rHh3ej+pMwnCVptFqaCD8GPv14zEPTkrxTwuVUEo2SGUqt6zjIvaJ5aYDSmqE0OQ +AhsU0Tj/u56c6/T2kos+xweWFH5siuTKHnC4GOxeFMlHOKohTVPUgkzzN9MbzuSA +YjZAknZeHTHcaWFtFFeSFBbmzVJZKfoDCC5ESpLYZLRgV9AqU0dsoDJUP5ET8lHx +uh4SNcCXR8acN3qkGSJRijAff2jdVQiLe0hqkMurhuJzArGHVpjphXWvDwxe8mLe +nrjheykKn6CuWkrJWoFUIrDUaCcY26p9dNFdxPrEZfgUpnzCiDCGDIgj1lJvt1U0 +ifx7ttUI45UC6URU/yR9EP2TvmRBAoHBAPwYRRjVacqINmAJFnU9+4eD22uOI1ed +bfMUqqwt4ivWWmKs0ZI+GJmXiYSWettuN+Rtv1KOK8SAZSz3OdSWcwLuz8dlh4O7 +cjjInaXTz9Tf4sqMaiC/IdZlmt6ngZ7ZG+r8zR9HhxUwy7Cs9GpYF5m3BJmZn1LZ +bP9TH3dqvZH5G+Wn8ltNl1pVKM6rC0ARKGBMa7Bo0rsv1rUvmEetaZu5iiah5r6h +XTmb5jPLEaMxklxkqfkOIHgairYegEip1QKBwQD5iDbu0QxiA3Uu7DeZx+6GHUY8 +ffKkYXcnKdXFNIbeBGFcHkWlmZeuA6IqcOBbFTHpSpKcRmVuzvmd3TtP4FcIQxuH +RqJ6TRMeXm+Y+GzBLeVKiOCrABsKapUy3TLTDtguAbFlTduuM1HOYmq5vCe3o2MK +tgpOKJEHaOWHzrznMRgehjoWTeq3WuuMZmbYfjDsDo7IleZslWkIokWD0U7SERBo +D05/x9x5fSNqyyjM8NZ/ik2ujPUR+WdCHtXqluECgcA/k59Zc/kKKvALqD8RsmAM +/SQJK/+dyQZBl6SzZ57yj0ycNhlkWGS714vG9GxnipRt93+YwmInXHonrPHYu1im +FLQyBVj3z/4uc+nOOGzhstTvYBojyBAwkc9M99GozfhMexUAHnnizjuQgw3hA/Zv +vchbNHMJ4eurOLtm0nScq8ZtVL26aQcSsQdpl5luvuT/5EYEZ2s96gKsDyTIbuOD +cnd05r/as7dfIAIebcg07/uJcZmsRfPKVmdFJswTh0ECgcBr8FU61ujRWQeOpZWj +is2N7Anezuhv3M1K/pi+9mrEjQaEb3/XE2p+VooGa89Q9wkhDiX/PaBQ320wsWsf +sT5Uj5rP2GkeGEsF3vnNJOD+a1j89dqhfak0x0gEuZRrocc3l3niBVzarM5dRUs/ +TrmrgRytnHM2veuGVgS7y10BcMYrJgrobQn0CHtNv1oLmgKVifKPp/AF1leZ6X/C +dn7u9XywVraxJYYkc1IntvvOMvvGLdBOiiDUhpr5Cheko2ECgcAEFU2CTCaTzV/s +xTySE3AK6flhNaxdwL0wjK0I8DUZhfpqrBJVnlfV35Y5dXWl09qR/f1r6ZQOg2Ew +HiUnsFq8XxAwvQ7SrrLvGY7OAxp4mSeUufP/uP9hNIZQoXof6gxosLxeTfDq4ddA +dWQCygbX8PQRrrg7BMqC1pRIGljwt7ijKy2H4RS8WteGlM+nTrps9iEImAqxoOAz +ky2V56s1enP1E+5C/1Hr6yyVSxBF46482Bpl2WvJG6BBQRV146E= +-----END RSA PRIVATE KEY----- diff --git a/src/test/resources/issue_369_rsa_opensshv1.pub b/src/test/resources/issue_369_rsa_opensshv1.pub new file mode 100644 index 00000000..f85c3b06 --- /dev/null +++ b/src/test/resources/issue_369_rsa_opensshv1.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQD1ub4yJ8TCXgPaTtASEA034K+85zo2MDlRCB7tHgpmIpK7btPxizYEPEPywVnBRGMJnhIyKKHc7AHzCos3tkGVYNBlDGmnoaZTeZqhmsRSqqxHyfIRQ1T+aGIN4scliZ+iW8RI/djYyfPlcAR3Kku+Q3xsR5K2yzzxZiYB/rD9XjvRRtc7cYZlHaMe2NBtQhh3hamQVSEJMjfSCpq4okULk0UytXhdbPtP/tLDvqeK7op+q97hFS0wRY9xTaNM+qUhuhaKNbhuexgGQBk7We45LcR6O3XwjAB+X7owa4JtKx9oKY93+3qtM+5+6nRnFnkB/GL5fdKPmIswQ1vOSgGeEhg/M0yzX0PEMx4qfczpUp2rFtMTNg9O6Xz9qJCnZy/I1EmK6FEXerpEY0x41mY2NBBor9vataM9IxzJ1VIra8JYjnPqG48V9LFhSEpFfi1CquqJu1fmtxtH4YNWWNQECKp0s+WmxKAu2ZAAr1wl+tNkkiZOaDSluT14qMkSEjU= test diff --git a/src/test/resources/issue_369_rsa_pem b/src/test/resources/issue_369_rsa_pem new file mode 100644 index 00000000..bdd875ba --- /dev/null +++ b/src/test/resources/issue_369_rsa_pem @@ -0,0 +1,39 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIG5AIBAAKCAYEAs3v+RtRTyr4HJy16h1eI21HzvoIu+QVClFigaMHYOt5K/Xtx +nRlZsLQQVkyTMsRFlbSTKx/AgEVqMlYiC0MvaBX223MLgJ34VY3T1TaSu0S9WcAg +q7IOlA6RPlaeK01s1HA11MiNjGa3jyQsFNPlFnb6BCV8BNjYrW/rEvNNiLHZcIkY +/ZJ8yiea1XKRqUNEJHNI23jQ3850QBPAEWsJAy3FxIqPVereKbAFn9wWxxmHnPT2 +QGHHcwh3MJi5k0/w0jhfrrdn8b4wcnVicxh5isqM5RTY04YF7dItH3HnSxtKABzT +QS/FHhGEOx9IJW0/a7JzKjgLYAWA/5yRnzJDDIz+zUUtGNI7ZJmPD0N5e0ZB0xXi +lZCqSrcg9/i7H7jmZIeQOq4TmYDD/fttgGYSFxoaPZCWUkhewfQlmvkwq+YmaPZS +123jBUa5OS7YOwTR5DuUcfEhq6BmBpC17fPfni/h7dSOI26tX1heeWEGJ0zqL75z +VVQqeItHPCpTQKkjAgMBAAECggGAHHtwvoyzP1koiW8OIqwha6x1oaXHDn1nM2Nd +EUKxraXZAKC2RtffA8uPTCKauVOsNzWQpSdExRY+4/4HKQJgY4QYyHpZOO/YmLsJ +AqzGXDFsWvHCPXzkE1q8ccgNEZIX0x57bGjnDYC/YFe9JxD5Kbd3tXC9XYeL2voH +s9ooU6jleJZJAPReGTZvu6+SremexqoExc9GVj3M9N4tfJYfuAFrgOT8GgZLexIT +0mp6st26R44YBd9+ZyLQx0V1LYthx+Z3uMA4BYyTc0P3TcgRiazIBjhFC7gcbFwR +kma/MFv9P4jvUeNYJuQIueF5Bb24/FvRYp5o6HGTiE2pGUv1DAGK1PvI711D1aDd +TAcLhwkzPog1C9KPyz3mAn6p6x8S8+Lk35AjGGBE7i3s6ZGJF17SJW7BwzKJ1vSe +XX9U3XLq3DErPx9AnQhCAiPihohx3Cm8Hy68NGSHjRdu5CeWJiczX0TKHUNSx6TM +Jo5Ew5Lplr01x5UsjDbwgEOPToEBAoHBAN5UGGcXgkQ2jn/pH/BOQ7FnHNtS0/lo +feBnUHLEGRnFylka3sRak0fF6bMj48NrGyiI9QFNv/NeHqwhjGYGVeK75HGJENPC +6Wlewifo6Nw/GxmBo0sewEZ8XEyqClIkpj1oOhIbkGyeT/dXZjbyvx+kdz0FTAyU +/fUB20Ai3rgS600r6GSQKloOs2iAnELugpkTYeB7Fiwe2613i4l7myVLowhwYhu3 +BBW5kg+ApasSTwloJlC454TO1RylJ/GwjwKBwQDOqslErBZfb2Lvm8DkequQ9kzp +dIw8pZoPLXkRsU+X2kifxCY9W6SWlgzMQptX/wWwI6QB7fMIwLB1Umtzuu7vwlzB ++NBgeflLdWlWT76/mc2GfbW9QsKvnAR2ar3z9GV+zmHp09NPddFn2bZdLlXl736p +4C8MfLTZlmSwwJm2MYyoGQB/NfMMrJ/yaAPJV+AdlE0hV3A+5a1cRim2n8rUVEHj +OJ4x7AqxA+xt88picKIAXEtTGyjsj6DQQdUBYC0CgcEAv00u/i3NSfKDpO4sLDK7 +rn8h5lobyQQvI5LiNw4i5vk4xnkHa37gMabLEvhzt6eGY9eMsYV7/+VhkQ0A6JzU +89Zml4av8vZIrwD5ISwYicLHB6hzoGSiX0QMi27YmJuuazIunXwYRk3mUtZiPi+b +Ype6fcf8Cut8pX/mbwZSC6ND0lBQk4800e7KUsYvLqxZtWtnEaf3iRk4PseZSkAQ +XAP8EXvZ/yz4F9VoJ2yzoEKNvXNfXJ/tnmn2F8LIXv9jAoHAccENwa/bLLKZyXt4 +xApFbygzE3kkS6l3UA1ei3+GaPYsbUxBJBrSUFTNPI0ZBmmHzvj/KFS6JkIxnpI8 +NNpa9DuOZPI4eDILJx68WVbRjpLwzqtZIpChqpl811VPsvz99LtSp6sBr8YQ+lGa +kFWV0Fdv579PBleKEA445BVPRjqlykzguiSO4JYQABSCqQumf4GGpuiDDwvKzXSN +N0ljElZCYfhjEuVyyRZ4x9iduGt4sCwdBeR4NSWlhZwGy5gNAoHBAMmDur+qZ5sL +bb+AVsIPOhS1Nk64QyXru6Bz0M6doY3pgZJRGmXPwqfpHFsVGrjFoYU0Xxz4zWJb +fY0UBJZfb2vgLcHGVYCUL6C6d+f0m6DFDB7iqY06hU7EirYzA6iAcKiIHgAbELB2 +7ux+jieXxWKaMsJWYgR7XQn/UbC5xuOPSazZ5ws3Hz8toUK1tsYjXe+RoZioij2f +Xm+9NXEFFGhLtOvepf9qw1fHlIIetCOJ/yrCJKVzFmzhUReGPAnmoA== +-----END RSA PRIVATE KEY----- diff --git a/src/test/resources/issue_369_rsa_pem.pub b/src/test/resources/issue_369_rsa_pem.pub new file mode 100644 index 00000000..2178b42d --- /dev/null +++ b/src/test/resources/issue_369_rsa_pem.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCze/5G1FPKvgcnLXqHV4jbUfO+gi75BUKUWKBowdg63kr9e3GdGVmwtBBWTJMyxEWVtJMrH8CARWoyViILQy9oFfbbcwuAnfhVjdPVNpK7RL1ZwCCrsg6UDpE+Vp4rTWzUcDXUyI2MZrePJCwU0+UWdvoEJXwE2Nitb+sS802IsdlwiRj9knzKJ5rVcpGpQ0Qkc0jbeNDfznRAE8ARawkDLcXEio9V6t4psAWf3BbHGYec9PZAYcdzCHcwmLmTT/DSOF+ut2fxvjBydWJzGHmKyozlFNjThgXt0i0fcedLG0oAHNNBL8UeEYQ7H0glbT9rsnMqOAtgBYD/nJGfMkMMjP7NRS0Y0jtkmY8PQ3l7RkHTFeKVkKpKtyD3+LsfuOZkh5A6rhOZgMP9+22AZhIXGho9kJZSSF7B9CWa+TCr5iZo9lLXbeMFRrk5Ltg7BNHkO5Rx8SGroGYGkLXt89+eL+Ht1I4jbq1fWF55YQYnTOovvnNVVCp4i0c8KlNAqSM= test From 2dd6dc2628370c21dd34349eacb5be64d7bd949b Mon Sep 17 00:00:00 2001 From: release-bot Date: Tue, 1 Aug 2023 16:37:41 +0000 Subject: [PATCH 069/301] [maven-release-plugin] prepare release jsch-0.2.11 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 0133c58e..560508f2 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.mwiede jsch jar - 0.2.11-SNAPSHOT + 0.2.11 JSch https://github.com/mwiede/jsch JSch is a pure Java implementation of SSH2 @@ -12,7 +12,7 @@ scm:git:https://github.com/mwiede/jsch.git scm:git:https://github.com/mwiede/jsch.git https://github.com/mwiede/jsch - HEAD + jsch-0.2.11 @@ -73,7 +73,7 @@ - 2023-07-26T14:00:14Z + 2023-08-01T16:36:10Z UTF-8 UTF-8 true From c7d97d8bafda69d3309215db9dd883e63c1e5002 Mon Sep 17 00:00:00 2001 From: release-bot Date: Tue, 1 Aug 2023 16:37:43 +0000 Subject: [PATCH 070/301] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 560508f2..bc802aca 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.mwiede jsch jar - 0.2.11 + 0.2.12-SNAPSHOT JSch https://github.com/mwiede/jsch JSch is a pure Java implementation of SSH2 @@ -12,7 +12,7 @@ scm:git:https://github.com/mwiede/jsch.git scm:git:https://github.com/mwiede/jsch.git https://github.com/mwiede/jsch - jsch-0.2.11 + HEAD @@ -73,7 +73,7 @@ - 2023-08-01T16:36:10Z + 2023-08-01T16:37:43Z UTF-8 UTF-8 true From ef773e597d832d6243542da0566f9ead9f5a1994 Mon Sep 17 00:00:00 2001 From: Matthias Wiedemann Date: Tue, 1 Aug 2023 20:15:41 +0200 Subject: [PATCH 071/301] Update Readme.md --- Readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 0c892ecb..dd214b9e 100644 --- a/Readme.md +++ b/Readme.md @@ -33,7 +33,7 @@ with com.github.mwiede jsch - 0.2.10 + 0.2.11 ``` @@ -43,7 +43,7 @@ When you have an artifact `foo:bar`, which contains `com.jcraft:jsch` as a trans com.github.mwiede jsch - 0.2.10 + 0.2.11 foo From 053a6b102f7d294f710f803570c81b6ede501ef5 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Wed, 2 Aug 2023 05:14:29 -0500 Subject: [PATCH 072/301] Further refine previous fixes for windows line endings in PEM keys from #369 & #362. --- ChangeLog.md | 2 ++ src/main/java/com/jcraft/jsch/KeyPair.java | 9 ++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 7199735e..11bb0d92 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,5 @@ +* [0.2.12](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.12) + * Further refine previous fixes for windows line endings in PEM keys from [#369](https://github.com/mwiede/jsch/issues/369) & [#362](https://github.com/mwiede/jsch/issues/362). * [0.2.11](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.11) * [#369](https://github.com/mwiede/jsch/issues/369) fix multi-line PEM key parsing to work with windows line endings due to regression from previous fix for [#362](https://github.com/mwiede/jsch/issues/362). * [0.2.10](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.10) diff --git a/src/main/java/com/jcraft/jsch/KeyPair.java b/src/main/java/com/jcraft/jsch/KeyPair.java index f967d219..498b8204 100644 --- a/src/main/java/com/jcraft/jsch/KeyPair.java +++ b/src/main/java/com/jcraft/jsch/KeyPair.java @@ -891,17 +891,16 @@ static KeyPair load(JSch.InstanceLogger instLogger, byte[] prvkey, byte[] pubkey start = 0; i = 0; - boolean xds = false; int _len = _buf.length; while (i < _len) { if (_buf[i] == '\n') { - boolean xd = (_buf[i - 1] == '\r'); + boolean xd = (i > 0 && _buf[i - 1] == '\r'); // ignore \n (or \r\n) System.arraycopy(_buf, i + 1, _buf, i - (xd ? 1 : 0), _len - (i + 1)); if (xd) { _len--; - xds = true; + i--; } _len--; continue; @@ -912,8 +911,8 @@ static KeyPair load(JSch.InstanceLogger instLogger, byte[] prvkey, byte[] pubkey i++; } - if (i - (xds ? 1 : 0) - start > 0) - data = Util.fromBase64(_buf, start, i - (xds ? 1 : 0) - start); + if (i - start > 0) + data = Util.fromBase64(_buf, start, i - start); Util.bzero(_buf); } From 3e0343bcefd14ed631bae5ea6770aeed679147bf Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Wed, 2 Aug 2023 05:16:41 -0500 Subject: [PATCH 073/301] Update dependencies. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bc802aca..dbc0db0a 100644 --- a/pom.xml +++ b/pom.xml @@ -80,7 +80,7 @@ 2.6.2 5.13.0 2.20.0 - 2.20.0 + 2.21.0 3.1.2 From e439958a60d8cccb72da4fd8cebb9b7edef6cf27 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Thu, 3 Aug 2023 05:56:12 -0500 Subject: [PATCH 074/301] Update dependencies. --- .mvn/wrapper/maven-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 6d3a5665..ac184013 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -14,5 +14,5 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.3/apache-maven-3.9.3-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.4/apache-maven-3.9.4-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar From f0226d03574195f1c0419a7d21603522d9372467 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Aug 2023 05:31:51 +0000 Subject: [PATCH 075/301] Bump errorprone.version from 2.20.0 to 2.21.1 Bumps `errorprone.version` from 2.20.0 to 2.21.1. Updates `com.google.errorprone:error_prone_annotations` from 2.20.0 to 2.21.1 - [Release notes](https://github.com/google/error-prone/releases) - [Commits](https://github.com/google/error-prone/compare/v2.20.0...v2.21.1) Updates `com.google.errorprone:error_prone_core` from 2.20.0 to 2.21.1 - [Release notes](https://github.com/google/error-prone/releases) - [Commits](https://github.com/google/error-prone/compare/v2.20.0...v2.21.1) --- updated-dependencies: - dependency-name: com.google.errorprone:error_prone_annotations dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.google.errorprone:error_prone_core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dbc0db0a..21bf3b5f 100644 --- a/pom.xml +++ b/pom.xml @@ -80,7 +80,7 @@ 2.6.2 5.13.0 2.20.0 - 2.21.0 + 2.21.1 3.1.2 From 478adaca774587f1fb60f4f7a59217bfe0b7c01e Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Tue, 8 Aug 2023 07:17:05 -0500 Subject: [PATCH 076/301] Update dependencies. --- pom.xml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 21bf3b5f..18b52430 100644 --- a/pom.xml +++ b/pom.xml @@ -77,7 +77,7 @@ UTF-8 UTF-8 true - 2.6.2 + 2.7.0 5.13.0 2.20.0 2.21.1 @@ -96,6 +96,13 @@ ${junixsocket.version} true + + com.kohlschutter + compiler-annotations + 1.5.6 + provided + true + net.java.dev.jna jna-jpms @@ -537,6 +544,10 @@ org.cyclonedx cyclonedx-maven-plugin 2.7.9 + + false + false + From 08fb56aa5639b5bb2c4ca9a098f371878666d614 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Aug 2023 19:46:03 +0000 Subject: [PATCH 077/301] Bump org.testcontainers:junit-jupiter from 1.18.3 to 1.19.0 Bumps [org.testcontainers:junit-jupiter](https://github.com/testcontainers/testcontainers-java) from 1.18.3 to 1.19.0. - [Release notes](https://github.com/testcontainers/testcontainers-java/releases) - [Changelog](https://github.com/testcontainers/testcontainers-java/blob/main/CHANGELOG.md) - [Commits](https://github.com/testcontainers/testcontainers-java/compare/1.18.3...1.19.0) --- updated-dependencies: - dependency-name: org.testcontainers:junit-jupiter dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 18b52430..0bf0564d 100644 --- a/pom.xml +++ b/pom.xml @@ -142,7 +142,7 @@ org.testcontainers junit-jupiter - 1.18.3 + 1.19.0 test From 54f60a42d79a5360ccc1880b99035a114145fe3a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Aug 2023 19:23:39 +0000 Subject: [PATCH 078/301] Bump org.apache.maven.plugins:maven-enforcer-plugin from 3.3.0 to 3.4.0 Bumps [org.apache.maven.plugins:maven-enforcer-plugin](https://github.com/apache/maven-enforcer) from 3.3.0 to 3.4.0. - [Release notes](https://github.com/apache/maven-enforcer/releases) - [Commits](https://github.com/apache/maven-enforcer/compare/enforcer-3.3.0...enforcer-3.4.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-enforcer-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 18b52430..32ebcc37 100644 --- a/pom.xml +++ b/pom.xml @@ -244,7 +244,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 3.3.0 + 3.4.0 enforce-java From 7a5b16d853f7ea5ed3573d3a407a102ba14e06c8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Sep 2023 19:44:45 +0000 Subject: [PATCH 079/301] Bump actions/checkout from 3 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/coverity.yml | 2 +- .github/workflows/javadoc.yml | 2 +- .github/workflows/maven.yml | 2 +- .github/workflows/release.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 73c8ad13..91aa6c1a 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -31,7 +31,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup JDK uses: actions/setup-java@v3 with: diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index 0159aa13..6906b7c6 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -7,7 +7,7 @@ jobs: coverity: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up build JDK uses: actions/setup-java@v3 with: diff --git a/.github/workflows/javadoc.yml b/.github/workflows/javadoc.yml index c96733e0..314f8ec9 100644 --- a/.github/workflows/javadoc.yml +++ b/.github/workflows/javadoc.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout 🛎ī¸ - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up build JDK uses: actions/setup-java@v3 with: diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index ba2a157d..d27a608b 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -19,7 +19,7 @@ jobs: matrix: java: ['8', '11', '17'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Cache local Maven repository uses: actions/cache@v3 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e9aa023e..95c9036f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,7 +17,7 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Runs a set of commands using the runners shell - name: Release From 44f40cf797b013d13e7bbe5565c4c8c1cfd3e4ad Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Sep 2023 19:55:58 +0000 Subject: [PATCH 080/301] Bump org.slf4j:slf4j-api from 2.0.7 to 2.0.9 Bumps org.slf4j:slf4j-api from 2.0.7 to 2.0.9. --- updated-dependencies: - dependency-name: org.slf4j:slf4j-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f1aaf33d..e9287f38 100644 --- a/pom.xml +++ b/pom.xml @@ -130,7 +130,7 @@ org.slf4j slf4j-api - 2.0.7 + 2.0.9 true From 237b769bb4c1f26efaed4aa684487c1f2d6e51d0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Sep 2023 19:47:31 +0000 Subject: [PATCH 081/301] Bump junixsocket.version from 2.7.0 to 2.7.1 Bumps `junixsocket.version` from 2.7.0 to 2.7.1. Updates `com.kohlschutter.junixsocket:junixsocket-common` from 2.7.0 to 2.7.1 - [Release notes](https://github.com/kohlschutter/junixsocket/releases) - [Commits](https://github.com/kohlschutter/junixsocket/compare/junixsocket-2.7.0...junixsocket-2.7.1) Updates `com.kohlschutter.junixsocket:junixsocket-native-common` from 2.7.0 to 2.7.1 - [Release notes](https://github.com/kohlschutter/junixsocket/releases) - [Commits](https://github.com/kohlschutter/junixsocket/compare/junixsocket-2.7.0...junixsocket-2.7.1) --- updated-dependencies: - dependency-name: com.kohlschutter.junixsocket:junixsocket-common dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.kohlschutter.junixsocket:junixsocket-native-common dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e9287f38..1c26640d 100644 --- a/pom.xml +++ b/pom.xml @@ -77,7 +77,7 @@ UTF-8 UTF-8 true - 2.7.0 + 2.7.1 5.13.0 2.20.0 2.21.1 From 91bbc76f07bb521cf431e9e597064831e0be9d4c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Sep 2023 19:47:39 +0000 Subject: [PATCH 082/301] Bump org.apache.maven.plugins:maven-enforcer-plugin from 3.4.0 to 3.4.1 Bumps [org.apache.maven.plugins:maven-enforcer-plugin](https://github.com/apache/maven-enforcer) from 3.4.0 to 3.4.1. - [Release notes](https://github.com/apache/maven-enforcer/releases) - [Commits](https://github.com/apache/maven-enforcer/compare/enforcer-3.4.0...enforcer-3.4.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-enforcer-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e9287f38..a91993dd 100644 --- a/pom.xml +++ b/pom.xml @@ -244,7 +244,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 3.4.0 + 3.4.1 enforce-java From 1327f830add33e3fb1f3c1c2987dd8fcf7553985 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Sep 2023 19:47:41 +0000 Subject: [PATCH 083/301] Bump com.kohlschutter:compiler-annotations from 1.5.6 to 1.5.7 Bumps com.kohlschutter:compiler-annotations from 1.5.6 to 1.5.7. --- updated-dependencies: - dependency-name: com.kohlschutter:compiler-annotations dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e9287f38..32306a71 100644 --- a/pom.xml +++ b/pom.xml @@ -99,7 +99,7 @@ com.kohlschutter compiler-annotations - 1.5.6 + 1.5.7 provided true From 48fc266ed4bbd772bc2f274b6e601540723c8fc6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Sep 2023 19:47:33 +0000 Subject: [PATCH 084/301] Bump junixsocket.version from 2.7.1 to 2.7.2 Bumps `junixsocket.version` from 2.7.1 to 2.7.2. Updates `com.kohlschutter.junixsocket:junixsocket-common` from 2.7.1 to 2.7.2 - [Release notes](https://github.com/kohlschutter/junixsocket/releases) - [Commits](https://github.com/kohlschutter/junixsocket/compare/junixsocket-2.7.1...junixsocket-2.7.2) Updates `com.kohlschutter.junixsocket:junixsocket-native-common` from 2.7.1 to 2.7.2 - [Release notes](https://github.com/kohlschutter/junixsocket/releases) - [Commits](https://github.com/kohlschutter/junixsocket/compare/junixsocket-2.7.1...junixsocket-2.7.2) --- updated-dependencies: - dependency-name: com.kohlschutter.junixsocket:junixsocket-common dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.kohlschutter.junixsocket:junixsocket-native-common dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2b7dad9f..e67ccf14 100644 --- a/pom.xml +++ b/pom.xml @@ -77,7 +77,7 @@ UTF-8 UTF-8 true - 2.7.1 + 2.7.2 5.13.0 2.20.0 2.21.1 From 081570a78732869ebedf2b8ec6ea451257e89bab Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Sep 2023 19:47:38 +0000 Subject: [PATCH 085/301] Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.5.0 to 3.6.0 Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.5.0 to 3.6.0. - [Release notes](https://github.com/apache/maven-javadoc-plugin/releases) - [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.5.0...maven-javadoc-plugin-3.6.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-javadoc-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2b7dad9f..c9207aef 100644 --- a/pom.xml +++ b/pom.xml @@ -523,7 +523,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.5.0 + 3.6.0 true none From ce2fc973f75cc983962ef19c0cda8a658a84f317 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Sep 2023 19:32:10 +0000 Subject: [PATCH 086/301] Bump errorprone.version from 2.21.1 to 2.22.0 Bumps `errorprone.version` from 2.21.1 to 2.22.0. Updates `com.google.errorprone:error_prone_annotations` from 2.21.1 to 2.22.0 - [Release notes](https://github.com/google/error-prone/releases) - [Commits](https://github.com/google/error-prone/compare/v2.21.1...v2.22.0) Updates `com.google.errorprone:error_prone_core` from 2.21.1 to 2.22.0 - [Release notes](https://github.com/google/error-prone/releases) - [Commits](https://github.com/google/error-prone/compare/v2.21.1...v2.22.0) --- updated-dependencies: - dependency-name: com.google.errorprone:error_prone_annotations dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.google.errorprone:error_prone_core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2b7dad9f..b932851b 100644 --- a/pom.xml +++ b/pom.xml @@ -80,7 +80,7 @@ 2.7.1 5.13.0 2.20.0 - 2.21.1 + 2.22.0 3.1.2 From ffc233c7b3272bf001c9ffa5ef46b63be2f81b32 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Sep 2023 19:32:13 +0000 Subject: [PATCH 087/301] Bump com.kohlschutter:compiler-annotations from 1.5.7 to 1.5.8 Bumps com.kohlschutter:compiler-annotations from 1.5.7 to 1.5.8. --- updated-dependencies: - dependency-name: com.kohlschutter:compiler-annotations dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2b7dad9f..07638d12 100644 --- a/pom.xml +++ b/pom.xml @@ -99,7 +99,7 @@ com.kohlschutter compiler-annotations - 1.5.7 + 1.5.8 provided true From d43dc816b484f77b8c298943e4aeecb63e58cff6 Mon Sep 17 00:00:00 2001 From: Matthias Wiedemann Date: Tue, 26 Sep 2023 08:11:41 +0000 Subject: [PATCH 088/301] #392 replace call to BigInteger.intValueExact to remain comptaible with android api 30 --- src/main/java/com/jcraft/jsch/KeyPairPKCS8.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/jcraft/jsch/KeyPairPKCS8.java b/src/main/java/com/jcraft/jsch/KeyPairPKCS8.java index 048bd80d..e1845cf1 100644 --- a/src/main/java/com/jcraft/jsch/KeyPairPKCS8.java +++ b/src/main/java/com/jcraft/jsch/KeyPairPKCS8.java @@ -862,6 +862,13 @@ static Cipher getCipher(byte[] id, ASN1 encryptparams, byte[][] ivp) throws Exce } static int parseASN1IntegerAsInt(byte[] content) { - return new BigInteger(content).intValueExact(); + BigInteger b = new BigInteger(content); + // https://github.com/mwiede/jsch/issues/392 not using intValueExact() because of Android + // incompatibility. + if (b.bitLength() <= 31) { + return b.intValue(); + } else { + throw new ArithmeticException("BigInteger out of int range"); + } } } From ae5fae3344a40b9f2f1389aca9758b3db8ef8871 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Oct 2023 19:14:57 +0000 Subject: [PATCH 089/301] Bump junixsocket.version from 2.7.2 to 2.8.1 Bumps `junixsocket.version` from 2.7.2 to 2.8.1. Updates `com.kohlschutter.junixsocket:junixsocket-common` from 2.7.2 to 2.8.1 - [Release notes](https://github.com/kohlschutter/junixsocket/releases) - [Commits](https://github.com/kohlschutter/junixsocket/compare/junixsocket-2.7.2...junixsocket-2.8.1) Updates `com.kohlschutter.junixsocket:junixsocket-native-common` from 2.7.2 to 2.8.1 - [Release notes](https://github.com/kohlschutter/junixsocket/releases) - [Commits](https://github.com/kohlschutter/junixsocket/compare/junixsocket-2.7.2...junixsocket-2.8.1) --- updated-dependencies: - dependency-name: com.kohlschutter.junixsocket:junixsocket-common dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.kohlschutter.junixsocket:junixsocket-native-common dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ecb23d1f..dff88276 100644 --- a/pom.xml +++ b/pom.xml @@ -77,7 +77,7 @@ UTF-8 UTF-8 true - 2.7.2 + 2.8.1 5.13.0 2.20.0 2.22.0 From 5bf0d8f7623c78050121ef2a8711ab12ea992992 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Oct 2023 19:15:00 +0000 Subject: [PATCH 090/301] Bump com.kohlschutter:compiler-annotations from 1.5.8 to 1.6.4 Bumps com.kohlschutter:compiler-annotations from 1.5.8 to 1.6.4. --- updated-dependencies: - dependency-name: com.kohlschutter:compiler-annotations dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ecb23d1f..9ce4250a 100644 --- a/pom.xml +++ b/pom.xml @@ -99,7 +99,7 @@ com.kohlschutter compiler-annotations - 1.5.8 + 1.6.4 provided true From ec6feec9ee4eb532609bba633c66d636ba731aae Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Oct 2023 19:15:08 +0000 Subject: [PATCH 091/301] Bump org.testcontainers:junit-jupiter from 1.19.0 to 1.19.1 Bumps [org.testcontainers:junit-jupiter](https://github.com/testcontainers/testcontainers-java) from 1.19.0 to 1.19.1. - [Release notes](https://github.com/testcontainers/testcontainers-java/releases) - [Changelog](https://github.com/testcontainers/testcontainers-java/blob/main/CHANGELOG.md) - [Commits](https://github.com/testcontainers/testcontainers-java/compare/1.19.0...1.19.1) --- updated-dependencies: - dependency-name: org.testcontainers:junit-jupiter dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ecb23d1f..8f4271d2 100644 --- a/pom.xml +++ b/pom.xml @@ -142,7 +142,7 @@ org.testcontainers junit-jupiter - 1.19.0 + 1.19.1 test From da1274b30b65642d54683794cc37054be9fa7055 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Oct 2023 19:15:16 +0000 Subject: [PATCH 092/301] Bump commons-io:commons-io from 2.13.0 to 2.14.0 Bumps commons-io:commons-io from 2.13.0 to 2.14.0. --- updated-dependencies: - dependency-name: commons-io:commons-io dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ecb23d1f..9ecfda01 100644 --- a/pom.xml +++ b/pom.xml @@ -165,7 +165,7 @@ commons-io commons-io - 2.13.0 + 2.14.0 test From 2581674158c4b935d96fef5b09450f129b8857ee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Oct 2023 19:21:20 +0000 Subject: [PATCH 093/301] Bump org.jacoco:jacoco-maven-plugin from 0.8.10 to 0.8.11 Bumps [org.jacoco:jacoco-maven-plugin](https://github.com/jacoco/jacoco) from 0.8.10 to 0.8.11. - [Release notes](https://github.com/jacoco/jacoco/releases) - [Commits](https://github.com/jacoco/jacoco/compare/v0.8.10...v0.8.11) --- updated-dependencies: - dependency-name: org.jacoco:jacoco-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 789ef309..4bef0cbc 100644 --- a/pom.xml +++ b/pom.xml @@ -635,7 +635,7 @@ org.jacoco jacoco-maven-plugin - 0.8.10 + 0.8.11 com/jcraft/jsch/JavaVersion.class From 9a4765750c6952cd2c83aa4172effaaf1fe6fb47 Mon Sep 17 00:00:00 2001 From: Martijn Vegter Date: Sat, 21 Oct 2023 16:31:17 +0200 Subject: [PATCH 094/301] Introduce specific JSchException for HostKey related failures --- .../jsch/JSchChangedHostKeyException.java | 39 +++++++++++++++++++ .../com/jcraft/jsch/JSchHostKeyException.java | 39 +++++++++++++++++++ .../jsch/JSchRevokedHostKeyException.java | 39 +++++++++++++++++++ .../jsch/JSchUnknownHostKeyException.java | 39 +++++++++++++++++++ src/main/java/com/jcraft/jsch/Session.java | 6 +-- 5 files changed, 159 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/jcraft/jsch/JSchChangedHostKeyException.java create mode 100644 src/main/java/com/jcraft/jsch/JSchHostKeyException.java create mode 100644 src/main/java/com/jcraft/jsch/JSchRevokedHostKeyException.java create mode 100644 src/main/java/com/jcraft/jsch/JSchUnknownHostKeyException.java diff --git a/src/main/java/com/jcraft/jsch/JSchChangedHostKeyException.java b/src/main/java/com/jcraft/jsch/JSchChangedHostKeyException.java new file mode 100644 index 00000000..4a1ee613 --- /dev/null +++ b/src/main/java/com/jcraft/jsch/JSchChangedHostKeyException.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions + * and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided with + * the distribution. + * + * 3. The names of the authors may not be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.jcraft.jsch; + +public class JSchChangedHostKeyException extends JSchHostKeyException { + private static final long serialVersionUID = -1L; + + JSchChangedHostKeyException() { + super(); + } + + JSchChangedHostKeyException(String s) { + super(s); + } +} diff --git a/src/main/java/com/jcraft/jsch/JSchHostKeyException.java b/src/main/java/com/jcraft/jsch/JSchHostKeyException.java new file mode 100644 index 00000000..91a3f896 --- /dev/null +++ b/src/main/java/com/jcraft/jsch/JSchHostKeyException.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions + * and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided with + * the distribution. + * + * 3. The names of the authors may not be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.jcraft.jsch; + +public abstract class JSchHostKeyException extends JSchException { + private static final long serialVersionUID = -1L; + + JSchHostKeyException() { + super(); + } + + JSchHostKeyException(String s) { + super(s); + } +} diff --git a/src/main/java/com/jcraft/jsch/JSchRevokedHostKeyException.java b/src/main/java/com/jcraft/jsch/JSchRevokedHostKeyException.java new file mode 100644 index 00000000..f25e2f67 --- /dev/null +++ b/src/main/java/com/jcraft/jsch/JSchRevokedHostKeyException.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions + * and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided with + * the distribution. + * + * 3. The names of the authors may not be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.jcraft.jsch; + +public class JSchRevokedHostKeyException extends JSchHostKeyException { + private static final long serialVersionUID = -1L; + + JSchRevokedHostKeyException() { + super(); + } + + JSchRevokedHostKeyException(String s) { + super(s); + } +} diff --git a/src/main/java/com/jcraft/jsch/JSchUnknownHostKeyException.java b/src/main/java/com/jcraft/jsch/JSchUnknownHostKeyException.java new file mode 100644 index 00000000..1957bda7 --- /dev/null +++ b/src/main/java/com/jcraft/jsch/JSchUnknownHostKeyException.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions + * and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided with + * the distribution. + * + * 3. The names of the authors may not be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.jcraft.jsch; + +public class JSchUnknownHostKeyException extends JSchHostKeyException { + private static final long serialVersionUID = -1L; + + JSchUnknownHostKeyException() { + super(); + } + + JSchUnknownHostKeyException(String s) { + super(s); + } +} diff --git a/src/main/java/com/jcraft/jsch/Session.java b/src/main/java/com/jcraft/jsch/Session.java index 97b3d708..2c9a13c4 100644 --- a/src/main/java/com/jcraft/jsch/Session.java +++ b/src/main/java/com/jcraft/jsch/Session.java @@ -892,10 +892,10 @@ private void checkHost(String chost, int port, KeyExchange kex) throws JSchExcep insert = true; } else { if (i == HostKeyRepository.NOT_INCLUDED) - throw new JSchException( + throw new JSchUnknownHostKeyException( "UnknownHostKey: " + chost + ". " + key_type + " key fingerprint is " + key_fprint); else - throw new JSchException("HostKey has been changed: " + chost); + throw new JSchChangedHostKeyException("HostKey has been changed: " + chost); } } @@ -916,7 +916,7 @@ private void checkHost(String chost, int port, KeyExchange kex) throws JSchExcep if (getLogger().isEnabled(Logger.INFO)) { getLogger().log(Logger.INFO, "Host '" + chost + "' has provided revoked key."); } - throw new JSchException("revoked HostKey: " + chost); + throw new JSchRevokedHostKeyException("revoked HostKey: " + chost); } } } From d299535853652ea4a95167629c206e3365ffac6b Mon Sep 17 00:00:00 2001 From: Martijn Vegter Date: Sat, 21 Oct 2023 13:33:17 +0200 Subject: [PATCH 095/301] Reset the sequence numbers on Session disconnect to support reconnection --- src/main/java/com/jcraft/jsch/Session.java | 9 + .../com/jcraft/jsch/SessionReconnectIT.java | 160 ++++++++++++++++++ 2 files changed, 169 insertions(+) create mode 100644 src/test/java/com/jcraft/jsch/SessionReconnectIT.java diff --git a/src/main/java/com/jcraft/jsch/Session.java b/src/main/java/com/jcraft/jsch/Session.java index 97b3d708..433554b1 100644 --- a/src/main/java/com/jcraft/jsch/Session.java +++ b/src/main/java/com/jcraft/jsch/Session.java @@ -93,6 +93,8 @@ public class Session { private byte[] MACc2s; private byte[] MACs2c; + // RFC 4253 6.4. each direction must run independently hence we have an incoming and outgoing + // sequence number private int seqi = 0; private int seqo = 0; @@ -1998,6 +2000,13 @@ public void disconnect() { } io = null; socket = null; + + // RFC 4253 6.4. the 'sequence_number' is never reset, even if keys/algorithms are renegotiated + // later. Hence we only reset these on session disconnect as the sequence has to start at zero + // for the first packet during (re)connect. + seqi = 0; + seqo = 0; + // synchronized(jsch.pool){ // jsch.pool.removeElement(this); // } diff --git a/src/test/java/com/jcraft/jsch/SessionReconnectIT.java b/src/test/java/com/jcraft/jsch/SessionReconnectIT.java new file mode 100644 index 00000000..f2b603ef --- /dev/null +++ b/src/test/java/com/jcraft/jsch/SessionReconnectIT.java @@ -0,0 +1,160 @@ +package com.jcraft.jsch; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; + +import com.github.valfirst.slf4jtest.LoggingEvent; +import com.github.valfirst.slf4jtest.TestLogger; +import com.github.valfirst.slf4jtest.TestLoggerFactory; +import java.io.IOException; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Base64; +import java.util.List; +import java.util.Random; +import org.apache.commons.codec.digest.DigestUtils; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.output.Slf4jLogConsumer; +import org.testcontainers.images.builder.ImageFromDockerfile; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; + +@Testcontainers +public class SessionReconnectIT { + + private static final int timeout = 2000; + private static final DigestUtils sha256sum = new DigestUtils(DigestUtils.getSha256Digest()); + private static final TestLogger jschLogger = TestLoggerFactory.getTestLogger(JSch.class); + private static final TestLogger sshdLogger = + TestLoggerFactory.getTestLogger(SessionReconnectIT.class); + + @TempDir + public Path tmpDir; + private Path in; + private Path out; + private String hash; + private Slf4jLogConsumer sshdLogConsumer; + + @Container + public GenericContainer sshd = new GenericContainer<>(new ImageFromDockerfile() + .withFileFromClasspath("dropbear_rsa_host_key", "docker/dropbear_rsa_host_key") + .withFileFromClasspath("authorized_keys", "docker/authorized_keys") + .withFileFromClasspath("Dockerfile", "docker/Dockerfile.dropbear")).withExposedPorts(22); + + @BeforeAll + public static void beforeAll() { + JSch.setLogger(new Slf4jLogger()); + } + + @BeforeEach + public void beforeEach() throws IOException { + if (sshdLogConsumer == null) { + sshdLogConsumer = new Slf4jLogConsumer(sshdLogger); + sshd.followOutput(sshdLogConsumer); + } + + in = tmpDir.resolve("in"); + out = tmpDir.resolve("out"); + Files.createFile(in); + try (OutputStream os = Files.newOutputStream(in)) { + byte[] data = new byte[1024]; + for (int i = 0; i < 1024 * 100; i += 1024) { + new Random().nextBytes(data); + os.write(data); + } + } + hash = sha256sum.digestAsHex(in); + + jschLogger.clearAll(); + sshdLogger.clearAll(); + } + + @AfterAll + public static void afterAll() { + JSch.setLogger(null); + jschLogger.clearAll(); + sshdLogger.clearAll(); + } + + @Test + public void testReconnectWithExtraAlgorithms() throws Exception { + JSch ssh = createRSAIdentity(); + Session session = createSession(ssh); + try { + doSftp(session, false); + fail("exception expected"); + } catch (JSchAlgoNegoFailException e) { + // Dropbear does not support rsa-sha2-512/rsa-sha2-256, so add ssh-rsa + String serverHostKey = session.getConfig("server_host_key") + ",ssh-rsa"; + String pubkeyAcceptedAlgorithms = session.getConfig("PubkeyAcceptedAlgorithms") + ",ssh-rsa"; + session.setConfig("server_host_key", serverHostKey); + session.setConfig("PubkeyAcceptedAlgorithms", pubkeyAcceptedAlgorithms); + doSftp(session, true); + } + } + + private JSch createRSAIdentity() throws Exception { + HostKey hostKey = readHostKey(getResourceFile("docker/ssh_host_rsa_key.pub")); + JSch ssh = new JSch(); + ssh.addIdentity(getResourceFile("docker/id_rsa"), getResourceFile("docker/id_rsa.pub"), null); + ssh.getHostKeyRepository().add(hostKey, null); + return ssh; + } + + private HostKey readHostKey(String fileName) throws Exception { + List lines = Files.readAllLines(Paths.get(fileName), UTF_8); + String[] split = lines.get(0).split("\\s+"); + String hostname = String.format("[%s]:%d", sshd.getHost(), sshd.getFirstMappedPort()); + return new HostKey(hostname, Base64.getDecoder().decode(split[1])); + } + + private Session createSession(JSch ssh) throws Exception { + Session session = ssh.getSession("root", sshd.getHost(), sshd.getFirstMappedPort()); + session.setConfig("StrictHostKeyChecking", "yes"); + session.setConfig("PreferredAuthentications", "publickey"); + return session; + } + + private void doSftp(Session session, boolean debugException) throws Exception { + try { + session.setTimeout(timeout); + session.connect(); + ChannelSftp sftp = (ChannelSftp) session.openChannel("sftp"); + sftp.connect(timeout); + sftp.put(in.toString(), "/root/test"); + sftp.get("/root/test", out.toString()); + sftp.disconnect(); + session.disconnect(); + } catch (Exception e) { + if (debugException) { + printInfo(); + } + throw e; + } + + assertEquals(1024L * 100L, Files.size(out)); + assertEquals(hash, sha256sum.digestAsHex(out)); + } + + private void printInfo() { + jschLogger.getAllLoggingEvents().stream().map(LoggingEvent::getFormattedMessage) + .forEach(System.out::println); + sshdLogger.getAllLoggingEvents().stream().map(LoggingEvent::getFormattedMessage) + .forEach(System.out::println); + System.out.println(""); + System.out.println(""); + System.out.println(""); + } + + private String getResourceFile(String fileName) { + return ResourceUtil.getResourceFile(getClass(), fileName); + } +} From 1037d3a615b5525b507094e36de2cf5a009af65c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Oct 2023 19:22:12 +0000 Subject: [PATCH 096/301] Bump errorprone.version from 2.22.0 to 2.23.0 Bumps `errorprone.version` from 2.22.0 to 2.23.0. Updates `com.google.errorprone:error_prone_annotations` from 2.22.0 to 2.23.0 - [Release notes](https://github.com/google/error-prone/releases) - [Commits](https://github.com/google/error-prone/compare/v2.22.0...v2.23.0) Updates `com.google.errorprone:error_prone_core` from 2.22.0 to 2.23.0 - [Release notes](https://github.com/google/error-prone/releases) - [Commits](https://github.com/google/error-prone/compare/v2.22.0...v2.23.0) --- updated-dependencies: - dependency-name: com.google.errorprone:error_prone_annotations dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.google.errorprone:error_prone_core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4bef0cbc..5739a5ba 100644 --- a/pom.xml +++ b/pom.xml @@ -80,7 +80,7 @@ 2.8.1 5.13.0 2.20.0 - 2.22.0 + 2.23.0 3.1.2 From 9e5e062b237955c0b612830472e310c21a84f8ea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:11:27 +0000 Subject: [PATCH 097/301] Bump log4j.version from 2.20.0 to 2.21.1 Bumps `log4j.version` from 2.20.0 to 2.21.1. Updates `org.apache.logging.log4j:log4j-api` from 2.20.0 to 2.21.1 Updates `org.apache.logging.log4j:log4j-core-test` from 2.20.0 to 2.21.1 --- updated-dependencies: - dependency-name: org.apache.logging.log4j:log4j-api dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.apache.logging.log4j:log4j-core-test dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5739a5ba..e08e29e2 100644 --- a/pom.xml +++ b/pom.xml @@ -79,7 +79,7 @@ true 2.8.1 5.13.0 - 2.20.0 + 2.21.1 2.23.0 3.1.2 From c164677101e3bac8707b786aa19f73de0640bbe7 Mon Sep 17 00:00:00 2001 From: Martijn Vegter Date: Tue, 24 Oct 2023 21:19:20 +0200 Subject: [PATCH 098/301] Introduce JSchSessionDisconnectException to allow the reasonCode to be retrieved without String parsing --- .../jsch/JSchSessionDisconnectException.java | 55 +++++++++++++++++++ src/main/java/com/jcraft/jsch/Session.java | 11 ++-- 2 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/jcraft/jsch/JSchSessionDisconnectException.java diff --git a/src/main/java/com/jcraft/jsch/JSchSessionDisconnectException.java b/src/main/java/com/jcraft/jsch/JSchSessionDisconnectException.java new file mode 100644 index 00000000..cb994f98 --- /dev/null +++ b/src/main/java/com/jcraft/jsch/JSchSessionDisconnectException.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions + * and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided with + * the distribution. + * + * 3. The names of the authors may not be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.jcraft.jsch; + +public class JSchSessionDisconnectException extends JSchException { + private static final long serialVersionUID = -1L; + + // RFC 4253 11.1. + private final int reasonCode; // RFC 4250 4.2.2. + private final String description; + private final String languageTag; + + JSchSessionDisconnectException(String s, int reasonCode, String description, String languageTag) { + super(s); + this.reasonCode = reasonCode; + this.description = description; + this.languageTag = languageTag; + } + + public int getReasonCode() { + return reasonCode; + } + + public String getDescription() { + return description; + } + + public String getLanguageTag() { + return languageTag; + } +} diff --git a/src/main/java/com/jcraft/jsch/Session.java b/src/main/java/com/jcraft/jsch/Session.java index 2c9a13c4..317c2a62 100644 --- a/src/main/java/com/jcraft/jsch/Session.java +++ b/src/main/java/com/jcraft/jsch/Session.java @@ -1199,10 +1199,13 @@ Buffer read(Buffer buf) throws Exception { buf.getInt(); buf.getShort(); int reason_code = buf.getInt(); - byte[] description = buf.getString(); - byte[] language_tag = buf.getString(); - throw new JSchException("SSH_MSG_DISCONNECT: " + reason_code + " " - + Util.byte2str(description) + " " + Util.byte2str(language_tag)); + byte[] description_array = buf.getString(); + byte[] language_tag_array = buf.getString(); + String description = Util.byte2str(description_array); + String language_tag = Util.byte2str(language_tag_array); + throw new JSchSessionDisconnectException( + "SSH_MSG_DISCONNECT: " + reason_code + " " + description + " " + language_tag, + reason_code, description, language_tag); // break; } else if (type == SSH_MSG_IGNORE) { } else if (type == SSH_MSG_UNIMPLEMENTED) { From 708a534c882e5ee812705165a617e3cfaa0c072a Mon Sep 17 00:00:00 2001 From: release-bot Date: Wed, 25 Oct 2023 07:40:10 +0000 Subject: [PATCH 099/301] [maven-release-plugin] prepare release jsch-0.2.12 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index e08e29e2..64aad964 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.mwiede jsch jar - 0.2.12-SNAPSHOT + 0.2.12 JSch https://github.com/mwiede/jsch JSch is a pure Java implementation of SSH2 @@ -12,7 +12,7 @@ scm:git:https://github.com/mwiede/jsch.git scm:git:https://github.com/mwiede/jsch.git https://github.com/mwiede/jsch - HEAD + jsch-0.2.12 @@ -73,7 +73,7 @@ - 2023-08-01T16:37:43Z + 2023-10-25T07:38:35Z UTF-8 UTF-8 true From 576c5113acc70fcbc6157b3b4aadb899873d2da2 Mon Sep 17 00:00:00 2001 From: release-bot Date: Wed, 25 Oct 2023 07:40:12 +0000 Subject: [PATCH 100/301] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 64aad964..27a10060 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.mwiede jsch jar - 0.2.12 + 0.2.13-SNAPSHOT JSch https://github.com/mwiede/jsch JSch is a pure Java implementation of SSH2 @@ -12,7 +12,7 @@ scm:git:https://github.com/mwiede/jsch.git scm:git:https://github.com/mwiede/jsch.git https://github.com/mwiede/jsch - jsch-0.2.12 + HEAD @@ -73,7 +73,7 @@ - 2023-10-25T07:38:35Z + 2023-10-25T07:40:12Z UTF-8 UTF-8 true From ca3b7e776333a5159cd334a863bb371c618f72c2 Mon Sep 17 00:00:00 2001 From: Matthias Wiedemann Date: Wed, 25 Oct 2023 10:11:31 +0200 Subject: [PATCH 101/301] Update ChangeLog.md --- ChangeLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 11bb0d92..25ebbbcd 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,8 @@ * [0.2.12](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.12) * Further refine previous fixes for windows line endings in PEM keys from [#369](https://github.com/mwiede/jsch/issues/369) & [#362](https://github.com/mwiede/jsch/issues/362). + * replace call to BigInteger.intValueExact to remain comptaible with Android [#397](https://github.com/mwiede/jsch/pull/397) + * Introduce JSchSessionDisconnectException to allow the reasonCode to be retrieved without String parsing [#416](https://github.com/mwiede/jsch/pull/416) + * Introduce specific JSchException for HostKey related failures [#410](https://github.com/mwiede/jsch/pull/410) * [0.2.11](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.11) * [#369](https://github.com/mwiede/jsch/issues/369) fix multi-line PEM key parsing to work with windows line endings due to regression from previous fix for [#362](https://github.com/mwiede/jsch/issues/362). * [0.2.10](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.10) From b993e82294e19d3238662d5c6b46bd5bbded7f77 Mon Sep 17 00:00:00 2001 From: Matthias Wiedemann Date: Wed, 25 Oct 2023 10:12:03 +0200 Subject: [PATCH 102/301] Update Readme.md --- Readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index dd214b9e..68262e4b 100644 --- a/Readme.md +++ b/Readme.md @@ -33,7 +33,7 @@ with com.github.mwiede jsch - 0.2.11 + 0.2.12 ``` @@ -43,7 +43,7 @@ When you have an artifact `foo:bar`, which contains `com.jcraft:jsch` as a trans com.github.mwiede jsch - 0.2.11 + 0.2.12 foo From 29228a71709e09887f11bb012da3b7ccd347021e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Oct 2023 19:55:07 +0000 Subject: [PATCH 103/301] Bump surefire.version from 3.1.2 to 3.2.1 Bumps `surefire.version` from 3.1.2 to 3.2.1. Updates `org.apache.maven.plugins:maven-surefire-plugin` from 3.1.2 to 3.2.1 - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.1.2...surefire-3.2.1) Updates `org.apache.maven.plugins:maven-failsafe-plugin` from 3.1.2 to 3.2.1 - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.1.2...surefire-3.2.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.apache.maven.plugins:maven-failsafe-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 27a10060..84534582 100644 --- a/pom.xml +++ b/pom.xml @@ -81,7 +81,7 @@ 5.13.0 2.21.1 2.23.0 - 3.1.2 + 3.2.1 From 3da808f06b8db440b8b39a031e78acbe2db3e0c2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Oct 2023 19:55:10 +0000 Subject: [PATCH 104/301] Bump org.apache.maven.plugins:maven-dependency-plugin Bumps [org.apache.maven.plugins:maven-dependency-plugin](https://github.com/apache/maven-dependency-plugin) from 3.6.0 to 3.6.1. - [Commits](https://github.com/apache/maven-dependency-plugin/compare/maven-dependency-plugin-3.6.0...maven-dependency-plugin-3.6.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-dependency-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 27a10060..768ae8c2 100644 --- a/pom.xml +++ b/pom.xml @@ -588,7 +588,7 @@ org.apache.maven.plugins maven-dependency-plugin - 3.6.0 + 3.6.1 org.apache.maven.plugins From 346230f78630da07584b735ff4fcc9cadadf81f6 Mon Sep 17 00:00:00 2001 From: Matthias Wiedemann Date: Mon, 30 Oct 2023 21:54:21 +0100 Subject: [PATCH 105/301] Create automerge.yml workflow which automerges PRs for dependencies having update on patch version and fulfil branch checks --- .github/workflows/automerge.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/automerge.yml diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml new file mode 100644 index 00000000..e8995433 --- /dev/null +++ b/.github/workflows/automerge.yml @@ -0,0 +1,23 @@ +name: Dependabot auto-merge patch versions +on: pull_request + +permissions: + contents: write + pull-requests: write + +jobs: + dependabot: + runs-on: ubuntu-latest + if: ${{ github.actor == 'dependabot[bot]' }} + steps: + - name: Dependabot metadata + id: metadata + uses: dependabot/fetch-metadata@v1 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + - name: Enable auto-merge for Dependabot PRs + if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}} + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} From 4840af9364a552f328815ec600b5092f78a9b964 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Oct 2023 20:55:50 +0000 Subject: [PATCH 106/301] Bump org.apache.maven.plugins:maven-checkstyle-plugin Bumps [org.apache.maven.plugins:maven-checkstyle-plugin](https://github.com/apache/maven-checkstyle-plugin) from 3.3.0 to 3.3.1. - [Commits](https://github.com/apache/maven-checkstyle-plugin/compare/maven-checkstyle-plugin-3.3.0...maven-checkstyle-plugin-3.3.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-checkstyle-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 84534582..604d798b 100644 --- a/pom.xml +++ b/pom.xml @@ -593,7 +593,7 @@ org.apache.maven.plugins maven-checkstyle-plugin - 3.3.0 + 3.3.1 true true From 9efa4c32a4ad61510a4dbb3898e0b5a9f067fd39 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Oct 2023 21:01:43 +0000 Subject: [PATCH 107/301] Bump org.cyclonedx:cyclonedx-maven-plugin from 2.7.9 to 2.7.10 Bumps [org.cyclonedx:cyclonedx-maven-plugin](https://github.com/CycloneDX/cyclonedx-maven-plugin) from 2.7.9 to 2.7.10. - [Release notes](https://github.com/CycloneDX/cyclonedx-maven-plugin/releases) - [Commits](https://github.com/CycloneDX/cyclonedx-maven-plugin/compare/cyclonedx-maven-plugin-2.7.9...cyclonedx-maven-plugin-2.7.10) --- updated-dependencies: - dependency-name: org.cyclonedx:cyclonedx-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 84534582..f383fa36 100644 --- a/pom.xml +++ b/pom.xml @@ -543,7 +543,7 @@ org.cyclonedx cyclonedx-maven-plugin - 2.7.9 + 2.7.10 false false From 57602cea316ab5a5a4242ca296cacf672eb4e3d3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Oct 2023 21:02:03 +0000 Subject: [PATCH 108/301] Bump junixsocket.version from 2.8.1 to 2.8.2 Bumps `junixsocket.version` from 2.8.1 to 2.8.2. Updates `com.kohlschutter.junixsocket:junixsocket-common` from 2.8.1 to 2.8.2 - [Release notes](https://github.com/kohlschutter/junixsocket/releases) - [Commits](https://github.com/kohlschutter/junixsocket/compare/junixsocket-2.8.1...junixsocket-2.8.2) Updates `com.kohlschutter.junixsocket:junixsocket-native-common` from 2.8.1 to 2.8.2 - [Release notes](https://github.com/kohlschutter/junixsocket/releases) - [Commits](https://github.com/kohlschutter/junixsocket/compare/junixsocket-2.8.1...junixsocket-2.8.2) --- updated-dependencies: - dependency-name: com.kohlschutter.junixsocket:junixsocket-common dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.kohlschutter.junixsocket:junixsocket-native-common dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 84534582..f61112ab 100644 --- a/pom.xml +++ b/pom.xml @@ -77,7 +77,7 @@ UTF-8 UTF-8 true - 2.8.1 + 2.8.2 5.13.0 2.21.1 2.23.0 From 823ef0234ff1b3c19b1d6d094994427fff3b5ee2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Nov 2023 19:16:03 +0000 Subject: [PATCH 109/301] Bump org.junit.jupiter:junit-jupiter from 5.10.0 to 5.10.1 Bumps [org.junit.jupiter:junit-jupiter](https://github.com/junit-team/junit5) from 5.10.0 to 5.10.1. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.10.0...r5.10.1) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1bee6d42..5f9d1397 100644 --- a/pom.xml +++ b/pom.xml @@ -136,7 +136,7 @@ org.junit.jupiter junit-jupiter - 5.10.0 + 5.10.1 test From 83ffcd0f59411ba722778b3e21055dc2fd76b59a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Nov 2023 19:16:08 +0000 Subject: [PATCH 110/301] Bump org.apache.maven.plugins:maven-clean-plugin from 3.3.1 to 3.3.2 Bumps [org.apache.maven.plugins:maven-clean-plugin](https://github.com/apache/maven-clean-plugin) from 3.3.1 to 3.3.2. - [Release notes](https://github.com/apache/maven-clean-plugin/releases) - [Commits](https://github.com/apache/maven-clean-plugin/compare/maven-clean-plugin-3.3.1...maven-clean-plugin-3.3.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-clean-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1bee6d42..04354cb5 100644 --- a/pom.xml +++ b/pom.xml @@ -456,7 +456,7 @@ org.apache.maven.plugins maven-clean-plugin - 3.3.1 + 3.3.2 org.apache.maven.plugins From 160ad7c740bb35843ba710c2b60acc60f702a3ac Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Nov 2023 19:16:11 +0000 Subject: [PATCH 111/301] Bump commons-io:commons-io from 2.14.0 to 2.15.0 Bumps commons-io:commons-io from 2.14.0 to 2.15.0. --- updated-dependencies: - dependency-name: commons-io:commons-io dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1bee6d42..65a3b7ba 100644 --- a/pom.xml +++ b/pom.xml @@ -165,7 +165,7 @@ commons-io commons-io - 2.14.0 + 2.15.0 test From e4e6d48bf7d11ec7e6de59ad27d34683ca1f45a0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Nov 2023 19:16:18 +0000 Subject: [PATCH 112/301] Bump org.codehaus.mojo:templating-maven-plugin from 1.0.0 to 3.0.0 Bumps [org.codehaus.mojo:templating-maven-plugin](https://github.com/mojohaus/templating-maven-plugin) from 1.0.0 to 3.0.0. - [Release notes](https://github.com/mojohaus/templating-maven-plugin/releases) - [Commits](https://github.com/mojohaus/templating-maven-plugin/compare/templating-maven-plugin-1.0.0...3.0.0) --- updated-dependencies: - dependency-name: org.codehaus.mojo:templating-maven-plugin dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1bee6d42..c6d8c131 100644 --- a/pom.xml +++ b/pom.xml @@ -312,7 +312,7 @@ org.codehaus.mojo templating-maven-plugin - 1.0.0 + 3.0.0 From 86bc2e6ef86d9bc8137887717149e7fa80d2cb22 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Mon, 13 Nov 2023 07:34:19 -0600 Subject: [PATCH 113/301] #411 add flush operation from is/jsch#39, with new config option to allow disabling in case it causes regressions. --- src/main/java/com/jcraft/jsch/Channel.java | 6 +++++- src/main/java/com/jcraft/jsch/ChannelSftp.java | 13 +++++++++++++ src/main/java/com/jcraft/jsch/JSch.java | 2 ++ src/main/java/com/jcraft/jsch/Session.java | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/jcraft/jsch/Channel.java b/src/main/java/com/jcraft/jsch/Channel.java index 5ebe102d..9474cf89 100644 --- a/src/main/java/com/jcraft/jsch/Channel.java +++ b/src/main/java/com/jcraft/jsch/Channel.java @@ -67,7 +67,11 @@ static Channel getChannel(String type, Session session) { ret = new ChannelForwardedTCPIP(); } if (type.equals("sftp")) { - ret = new ChannelSftp(); + ChannelSftp sftp = new ChannelSftp(); + boolean useWriteFlushWorkaround = + session.getConfig("use_sftp_write_flush_workaround").equals("yes"); + sftp.setUseWriteFlushWorkaround(useWriteFlushWorkaround); + ret = sftp; } if (type.equals("subsystem")) { ret = new ChannelSubsystem(); diff --git a/src/main/java/com/jcraft/jsch/ChannelSftp.java b/src/main/java/com/jcraft/jsch/ChannelSftp.java index c3dd3ac7..4848339e 100644 --- a/src/main/java/com/jcraft/jsch/ChannelSftp.java +++ b/src/main/java/com/jcraft/jsch/ChannelSftp.java @@ -157,6 +157,8 @@ public class ChannelSftp extends ChannelSession { private Charset fEncoding = StandardCharsets.UTF_8; private boolean fEncoding_is_utf8 = true; + private boolean useWriteFlushWorkaround = true; + private RequestQueue rq = new RequestQueue(16); /** @@ -181,6 +183,14 @@ public int getBulkRequests() { return rq.size(); } + public void setUseWriteFlushWorkaround(boolean useWriteFlushWorkaround) { + this.useWriteFlushWorkaround = useWriteFlushWorkaround; + } + + public boolean getUseWriteFlushWorkaround() { + return useWriteFlushWorkaround; + } + public ChannelSftp() { super(); lwsize_max = LOCAL_WINDOW_SIZE_MAX; @@ -754,6 +764,9 @@ public void write(byte[] d, int s, int len) throws IOException { try { int _len = len; while (_len > 0) { + if (useWriteFlushWorkaround && rwsize < 21 + handle.length + _len + 4) { + flush(); + } int sent = sendWRITE(handle, _offset[0], d, s, _len); writecount++; _offset[0] += sent; diff --git a/src/main/java/com/jcraft/jsch/JSch.java b/src/main/java/com/jcraft/jsch/JSch.java index 575a94fc..c1335964 100644 --- a/src/main/java/com/jcraft/jsch/JSch.java +++ b/src/main/java/com/jcraft/jsch/JSch.java @@ -228,6 +228,8 @@ public class JSch { config.put("try_additional_pubkey_algorithms", Util.getSystemProperty("jsch.try_additional_pubkey_algorithms", "yes")); config.put("enable_auth_none", Util.getSystemProperty("jsch.enable_auth_none", "yes")); + config.put("use_sftp_write_flush_workaround", + Util.getSystemProperty("jsch.use_sftp_write_flush_workaround", "yes")); config.put("CheckCiphers", Util.getSystemProperty("jsch.check_ciphers", "chacha20-poly1305@openssh.com")); diff --git a/src/main/java/com/jcraft/jsch/Session.java b/src/main/java/com/jcraft/jsch/Session.java index b0313f19..47cf3f19 100644 --- a/src/main/java/com/jcraft/jsch/Session.java +++ b/src/main/java/com/jcraft/jsch/Session.java @@ -3069,6 +3069,7 @@ private void applyConfig() throws JSchException { checkConfig(config, "enable_pubkey_auth_query"); checkConfig(config, "try_additional_pubkey_algorithms"); checkConfig(config, "enable_auth_none"); + checkConfig(config, "use_sftp_write_flush_workaround"); checkConfig(config, "cipher.c2s"); checkConfig(config, "cipher.s2c"); From 68831136473f04756402cb54000fe75cd3d4b87d Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Mon, 13 Nov 2023 07:34:44 -0600 Subject: [PATCH 114/301] Update dependencies. --- .mvn/wrapper/maven-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index ac184013..eacdc9ed 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -14,5 +14,5 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.4/apache-maven-3.9.4-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar From 17c93eacbca4e05d7ae21eb0b18a8dc745bbd32b Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Mon, 13 Nov 2023 07:35:55 -0600 Subject: [PATCH 115/301] Add Java 21 to CI pipeline and also use it by default for building. --- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/coverity.yml | 2 +- .github/workflows/javadoc.yml | 2 +- .github/workflows/maven.yml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 91aa6c1a..a9cd0a7b 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -36,7 +36,7 @@ jobs: uses: actions/setup-java@v3 with: distribution: 'zulu' - java-version: '17' + java-version: '21' check-latest: true cache: 'maven' diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index 6906b7c6..246e5967 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -12,7 +12,7 @@ jobs: uses: actions/setup-java@v3 with: distribution: 'zulu' - java-version: '17' + java-version: '21' check-latest: true cache: 'maven' - uses: vapier/coverity-scan-action@v1 diff --git a/.github/workflows/javadoc.yml b/.github/workflows/javadoc.yml index 314f8ec9..d4250399 100644 --- a/.github/workflows/javadoc.yml +++ b/.github/workflows/javadoc.yml @@ -16,7 +16,7 @@ jobs: uses: actions/setup-java@v3 with: distribution: 'zulu' - java-version: '17' + java-version: '21' check-latest: true - name: Build Javadoc run: mvn -B -V javadoc:javadoc --file pom.xml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index d27a608b..48a9f8dd 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - java: ['8', '11', '17'] + java: ['8', '11', '17', '21'] steps: - uses: actions/checkout@v4 - name: Cache local Maven repository @@ -31,7 +31,7 @@ jobs: uses: actions/setup-java@v3 with: distribution: 'zulu' - java-version: '17' + java-version: '21' check-latest: true - name: Build with Maven run: mvn -B -V -DskipTests=true package --file pom.xml From 063b5d0a0815826e01dedd9ce1bb0a62526a6cf4 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Mon, 13 Nov 2023 07:45:31 -0600 Subject: [PATCH 116/301] Switch CI pipelines to using maven wrapper and produce any execution error messages. --- .github/workflows/javadoc.yml | 2 +- .github/workflows/maven.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/javadoc.yml b/.github/workflows/javadoc.yml index d4250399..83d8ffdf 100644 --- a/.github/workflows/javadoc.yml +++ b/.github/workflows/javadoc.yml @@ -19,7 +19,7 @@ jobs: java-version: '21' check-latest: true - name: Build Javadoc - run: mvn -B -V javadoc:javadoc --file pom.xml + run: ./mvnw -B -V -e javadoc:javadoc - name: Deploy 🚀 uses: JamesIves/github-pages-deploy-action@v4 with: diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 48a9f8dd..8c624a1c 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -34,7 +34,7 @@ jobs: java-version: '21' check-latest: true - name: Build with Maven - run: mvn -B -V -DskipTests=true package --file pom.xml + run: ./mvnw -B -V -e -DskipTests=true package - uses: actions/upload-artifact@v3 with: name: java-${{ matrix.java }}-jars @@ -49,7 +49,7 @@ jobs: java-version: ${{ matrix.java }} check-latest: true - name: Test with Maven - run: mvn -B -V -P coverage verify -Denforcer.skip=true -Dmaven.resources.skip=true -Dmaven.main.skip=true -Dassembly.skipAssembly=true -Dmaven.javadoc.skip=true -DskipITs=false --file pom.xml + run: ./mvnw -B -V -e -P coverage verify -Denforcer.skip=true -Dmaven.resources.skip=true -Dmaven.main.skip=true -Dassembly.skipAssembly=true -Dmaven.javadoc.skip=true -DskipITs=false - uses: actions/upload-artifact@v3 with: name: java-${{ matrix.java }}-testresults From d702bda9d3b0a607f6b1cbd8f274beab02c28b8e Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Mon, 13 Nov 2023 09:45:35 -0600 Subject: [PATCH 117/301] #403 add a warning when Channel.getInputStream() or Channel.getExtInputStream() is called after Channel.connect(). --- src/main/java/com/jcraft/jsch/Channel.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/com/jcraft/jsch/Channel.java b/src/main/java/com/jcraft/jsch/Channel.java index 9474cf89..82abe288 100644 --- a/src/main/java/com/jcraft/jsch/Channel.java +++ b/src/main/java/com/jcraft/jsch/Channel.java @@ -208,6 +208,11 @@ public void setExtOutputStream(OutputStream out, boolean dontclose) { } public InputStream getInputStream() throws IOException { + Session _session = this.session; + if (_session != null && isConnected() && _session.getLogger().isEnabled(Logger.WARN)) { + _session.getLogger().log(Logger.WARN, "getInputStream() should be called before connect()"); + } + int max_input_buffer_size = 32 * 1024; try { max_input_buffer_size = Integer.parseInt(getSession().getConfig("max_input_buffer_size")); @@ -221,6 +226,12 @@ public InputStream getInputStream() throws IOException { } public InputStream getExtInputStream() throws IOException { + Session _session = this.session; + if (_session != null && isConnected() && _session.getLogger().isEnabled(Logger.WARN)) { + _session.getLogger().log(Logger.WARN, + "getExtInputStream() should be called before connect()"); + } + int max_input_buffer_size = 32 * 1024; try { max_input_buffer_size = Integer.parseInt(getSession().getConfig("max_input_buffer_size")); From 1d85db8626e0e57782fca8dbf894096fb45c723f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Nov 2023 19:11:33 +0000 Subject: [PATCH 118/301] Bump junixsocket.version from 2.8.2 to 2.8.3 Bumps `junixsocket.version` from 2.8.2 to 2.8.3. Updates `com.kohlschutter.junixsocket:junixsocket-common` from 2.8.2 to 2.8.3 - [Release notes](https://github.com/kohlschutter/junixsocket/releases) - [Commits](https://github.com/kohlschutter/junixsocket/compare/junixsocket-2.8.2...junixsocket-2.8.3) Updates `com.kohlschutter.junixsocket:junixsocket-native-common` from 2.8.2 to 2.8.3 - [Release notes](https://github.com/kohlschutter/junixsocket/releases) - [Commits](https://github.com/kohlschutter/junixsocket/compare/junixsocket-2.8.2...junixsocket-2.8.3) --- updated-dependencies: - dependency-name: com.kohlschutter.junixsocket:junixsocket-common dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.kohlschutter.junixsocket:junixsocket-native-common dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b7edec04..fd9835c7 100644 --- a/pom.xml +++ b/pom.xml @@ -77,7 +77,7 @@ UTF-8 UTF-8 true - 2.8.2 + 2.8.3 5.13.0 2.21.1 2.23.0 From f7230bf1d3a1023121ff1342365b410c50989670 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Nov 2023 19:11:40 +0000 Subject: [PATCH 119/301] Bump surefire.version from 3.2.1 to 3.2.2 Bumps `surefire.version` from 3.2.1 to 3.2.2. Updates `org.apache.maven.plugins:maven-surefire-plugin` from 3.2.1 to 3.2.2 - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.1...surefire-3.2.2) Updates `org.apache.maven.plugins:maven-failsafe-plugin` from 3.2.1 to 3.2.2 - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.1...surefire-3.2.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.maven.plugins:maven-failsafe-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b7edec04..99f3c189 100644 --- a/pom.xml +++ b/pom.xml @@ -81,7 +81,7 @@ 5.13.0 2.21.1 2.23.0 - 3.2.1 + 3.2.2 From d4954d2ca8ce6f2c257d6856d2d723addfcc2e75 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Nov 2023 19:11:45 +0000 Subject: [PATCH 120/301] Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.6.0 to 3.6.2 Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.6.0 to 3.6.2. - [Release notes](https://github.com/apache/maven-javadoc-plugin/releases) - [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.6.0...maven-javadoc-plugin-3.6.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-javadoc-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b7edec04..72fbef82 100644 --- a/pom.xml +++ b/pom.xml @@ -523,7 +523,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.6.0 + 3.6.2 true none From a24fac4314965a18d9f79f3a5b0e069f407fe682 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Nov 2023 19:11:48 +0000 Subject: [PATCH 121/301] Bump com.kohlschutter:compiler-annotations from 1.6.4 to 1.6.5 Bumps com.kohlschutter:compiler-annotations from 1.6.4 to 1.6.5. --- updated-dependencies: - dependency-name: com.kohlschutter:compiler-annotations dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b7edec04..6fd3fa1d 100644 --- a/pom.xml +++ b/pom.xml @@ -99,7 +99,7 @@ com.kohlschutter compiler-annotations - 1.6.4 + 1.6.5 provided true From 8b8d0295acda5ba49f1d415cd7fce1db4bf80944 Mon Sep 17 00:00:00 2001 From: release-bot Date: Mon, 13 Nov 2023 21:42:57 +0000 Subject: [PATCH 122/301] [maven-release-plugin] prepare release jsch-0.2.13 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index a474f2d1..191aa2cf 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.mwiede jsch jar - 0.2.13-SNAPSHOT + 0.2.13 JSch https://github.com/mwiede/jsch JSch is a pure Java implementation of SSH2 @@ -12,7 +12,7 @@ scm:git:https://github.com/mwiede/jsch.git scm:git:https://github.com/mwiede/jsch.git https://github.com/mwiede/jsch - HEAD + jsch-0.2.13 @@ -73,7 +73,7 @@ - 2023-10-25T07:40:12Z + 2023-11-13T21:41:40Z UTF-8 UTF-8 true From 67d0d8b8175fe994880adb808eb340b2d36aee2d Mon Sep 17 00:00:00 2001 From: release-bot Date: Mon, 13 Nov 2023 21:42:59 +0000 Subject: [PATCH 123/301] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 191aa2cf..46233a08 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.mwiede jsch jar - 0.2.13 + 0.2.14-SNAPSHOT JSch https://github.com/mwiede/jsch JSch is a pure Java implementation of SSH2 @@ -12,7 +12,7 @@ scm:git:https://github.com/mwiede/jsch.git scm:git:https://github.com/mwiede/jsch.git https://github.com/mwiede/jsch - jsch-0.2.13 + HEAD @@ -73,7 +73,7 @@ - 2023-11-13T21:41:40Z + 2023-11-13T21:42:59Z UTF-8 UTF-8 true From 5ec32bbe180d0b524a5ef9d44e8570b1355f6a68 Mon Sep 17 00:00:00 2001 From: Matthias Wiedemann Date: Tue, 14 Nov 2023 12:21:57 +0100 Subject: [PATCH 124/301] Update Readme.md --- Readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 68262e4b..8578e785 100644 --- a/Readme.md +++ b/Readme.md @@ -33,7 +33,7 @@ with com.github.mwiede jsch - 0.2.12 + 0.2.13 ``` @@ -43,7 +43,7 @@ When you have an artifact `foo:bar`, which contains `com.jcraft:jsch` as a trans com.github.mwiede jsch - 0.2.12 + 0.2.13 foo From d750a877a3031a29410e03bbedb720d1de20d8dd Mon Sep 17 00:00:00 2001 From: Matthias Wiedemann Date: Tue, 14 Nov 2023 12:26:31 +0100 Subject: [PATCH 125/301] Update ChangeLog.md --- ChangeLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 25ebbbcd..8e378c90 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,6 @@ +* [0.2.13](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.13) + * #411 Add flush operation from Fix added is/jsch#39, with new config option to allow disabling in case it causes regressions. + * #403 add a warning when Channel.getInputStream() or Channel.getExtInputStream() is called after Channel.connect(). * [0.2.12](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.12) * Further refine previous fixes for windows line endings in PEM keys from [#369](https://github.com/mwiede/jsch/issues/369) & [#362](https://github.com/mwiede/jsch/issues/362). * replace call to BigInteger.intValueExact to remain comptaible with Android [#397](https://github.com/mwiede/jsch/pull/397) From fb9fd7e5f2ba338464bc5e8df36bad846a7f87e6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Nov 2023 19:42:00 +0000 Subject: [PATCH 126/301] Bump org.testcontainers:junit-jupiter from 1.19.1 to 1.19.2 Bumps [org.testcontainers:junit-jupiter](https://github.com/testcontainers/testcontainers-java) from 1.19.1 to 1.19.2. - [Release notes](https://github.com/testcontainers/testcontainers-java/releases) - [Changelog](https://github.com/testcontainers/testcontainers-java/blob/main/CHANGELOG.md) - [Commits](https://github.com/testcontainers/testcontainers-java/compare/1.19.1...1.19.2) --- updated-dependencies: - dependency-name: org.testcontainers:junit-jupiter dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 46233a08..abded880 100644 --- a/pom.xml +++ b/pom.xml @@ -142,7 +142,7 @@ org.testcontainers junit-jupiter - 1.19.1 + 1.19.2 test From 4376de59818cb9a9d1e51b3660557f424b8135b3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Nov 2023 19:42:04 +0000 Subject: [PATCH 127/301] Bump org.bouncycastle:bcprov-jdk18on from 1.76 to 1.77 Bumps [org.bouncycastle:bcprov-jdk18on](https://github.com/bcgit/bc-java) from 1.76 to 1.77. - [Changelog](https://github.com/bcgit/bc-java/blob/main/docs/releasenotes.html) - [Commits](https://github.com/bcgit/bc-java/commits) --- updated-dependencies: - dependency-name: org.bouncycastle:bcprov-jdk18on dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 46233a08..9acda892 100644 --- a/pom.xml +++ b/pom.xml @@ -87,7 +87,7 @@ org.bouncycastle bcprov-jdk18on - 1.76 + 1.77 true From 23f691bd4fbbee170b131aa182569d85ac1aaa7d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Nov 2023 19:42:06 +0000 Subject: [PATCH 128/301] Bump log4j.version from 2.21.1 to 2.22.0 Bumps `log4j.version` from 2.21.1 to 2.22.0. Updates `org.apache.logging.log4j:log4j-api` from 2.21.1 to 2.22.0 Updates `org.apache.logging.log4j:log4j-core-test` from 2.21.1 to 2.22.0 --- updated-dependencies: - dependency-name: org.apache.logging.log4j:log4j-api dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.apache.logging.log4j:log4j-core-test dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 46233a08..c00752a9 100644 --- a/pom.xml +++ b/pom.xml @@ -79,7 +79,7 @@ true 2.8.3 5.13.0 - 2.21.1 + 2.22.0 2.23.0 3.2.2 From ffa4462df90475df4860792bba29220637a3b52f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Nov 2023 19:08:48 +0000 Subject: [PATCH 129/301] Bump org.testcontainers:junit-jupiter from 1.19.2 to 1.19.3 Bumps [org.testcontainers:junit-jupiter](https://github.com/testcontainers/testcontainers-java) from 1.19.2 to 1.19.3. - [Release notes](https://github.com/testcontainers/testcontainers-java/releases) - [Changelog](https://github.com/testcontainers/testcontainers-java/blob/main/CHANGELOG.md) - [Commits](https://github.com/testcontainers/testcontainers-java/compare/1.19.2...1.19.3) --- updated-dependencies: - dependency-name: org.testcontainers:junit-jupiter dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e336c9bf..e7f88fef 100644 --- a/pom.xml +++ b/pom.xml @@ -142,7 +142,7 @@ org.testcontainers junit-jupiter - 1.19.2 + 1.19.3 test From 4ace4895835e05dee5d94841e0882675ea9e52bf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Nov 2023 19:08:56 +0000 Subject: [PATCH 130/301] Bump org.codehaus.mojo:build-helper-maven-plugin from 3.4.0 to 3.5.0 Bumps [org.codehaus.mojo:build-helper-maven-plugin](https://github.com/mojohaus/build-helper-maven-plugin) from 3.4.0 to 3.5.0. - [Release notes](https://github.com/mojohaus/build-helper-maven-plugin/releases) - [Commits](https://github.com/mojohaus/build-helper-maven-plugin/compare/3.4.0...3.5.0) --- updated-dependencies: - dependency-name: org.codehaus.mojo:build-helper-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e336c9bf..21985341 100644 --- a/pom.xml +++ b/pom.xml @@ -293,7 +293,7 @@ org.codehaus.mojo build-helper-maven-plugin - 3.4.0 + 3.5.0 From 06fa7a604888f97db69a2b73f9065daeda7597a3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Dec 2023 19:13:53 +0000 Subject: [PATCH 131/301] Bump com.kohlschutter:compiler-annotations from 1.6.5 to 1.6.6 Bumps com.kohlschutter:compiler-annotations from 1.6.5 to 1.6.6. --- updated-dependencies: - dependency-name: com.kohlschutter:compiler-annotations dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e7f88fef..cf453b45 100644 --- a/pom.xml +++ b/pom.xml @@ -99,7 +99,7 @@ com.kohlschutter compiler-annotations - 1.6.5 + 1.6.6 provided true From cafb9624efaf7b9a0ae44c8f6b146211899ec5e7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Dec 2023 19:13:59 +0000 Subject: [PATCH 132/301] Bump commons-io:commons-io from 2.15.0 to 2.15.1 Bumps commons-io:commons-io from 2.15.0 to 2.15.1. --- updated-dependencies: - dependency-name: commons-io:commons-io dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e7f88fef..917992cb 100644 --- a/pom.xml +++ b/pom.xml @@ -165,7 +165,7 @@ commons-io commons-io - 2.15.0 + 2.15.1 test From 69e35f3a41b5ec8ca3902f2998fcf65c6a36d12b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Dec 2023 19:14:08 +0000 Subject: [PATCH 133/301] Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.6.2 to 3.6.3 Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.6.2 to 3.6.3. - [Release notes](https://github.com/apache/maven-javadoc-plugin/releases) - [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.6.2...maven-javadoc-plugin-3.6.3) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-javadoc-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e7f88fef..c483801e 100644 --- a/pom.xml +++ b/pom.xml @@ -523,7 +523,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.6.2 + 3.6.3 true none From f54e932eb1c957151b9dfca8feb81cfd63b73604 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Dec 2023 19:46:48 +0000 Subject: [PATCH 134/301] Bump actions/setup-java from 3 to 4 Bumps [actions/setup-java](https://github.com/actions/setup-java) from 3 to 4. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](https://github.com/actions/setup-java/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-java dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/coverity.yml | 2 +- .github/workflows/javadoc.yml | 2 +- .github/workflows/maven.yml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index a9cd0a7b..116ac77e 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -33,7 +33,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - name: Setup JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: '21' diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index 246e5967..e8bc0126 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -9,7 +9,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up build JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: '21' diff --git a/.github/workflows/javadoc.yml b/.github/workflows/javadoc.yml index 83d8ffdf..2dbd1d0c 100644 --- a/.github/workflows/javadoc.yml +++ b/.github/workflows/javadoc.yml @@ -13,7 +13,7 @@ jobs: - name: Checkout 🛎ī¸ uses: actions/checkout@v4 - name: Set up build JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: '21' diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 8c624a1c..382f52d1 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -28,7 +28,7 @@ jobs: restore-keys: | ${{ runner.os }}-${{ matrix.java }}-maven- - name: Set up build JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: '21' @@ -43,7 +43,7 @@ jobs: **/target/bom.* if: always() - name: Set up test JDK ${{ matrix.java }} - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: ${{ matrix.java }} From 73f8bee53d7b83ab451b5904d16cd30139411c86 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Mon, 11 Dec 2023 13:18:15 -0600 Subject: [PATCH 135/301] #450 use Socket.connect() with a timeout that has been supported since Java 1.4 instead of using old method of creating a separate thread and joining to that thread with timeout. --- src/main/java/com/jcraft/jsch/Util.java | 61 ++++++------------------- 1 file changed, 14 insertions(+), 47 deletions(-) diff --git a/src/main/java/com/jcraft/jsch/Util.java b/src/main/java/com/jcraft/jsch/Util.java index 85628a19..dde331e7 100644 --- a/src/main/java/com/jcraft/jsch/Util.java +++ b/src/main/java/com/jcraft/jsch/Util.java @@ -26,11 +26,13 @@ package com.jcraft.jsch; -import java.net.Socket; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.io.IOException; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.net.SocketTimeoutException; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.Vector; @@ -369,55 +371,20 @@ static boolean array_equals(byte[] foo, byte bar[]) { } static Socket createSocket(String host, int port, int timeout) throws JSchException { - Socket socket = null; - if (timeout == 0) { - try { - socket = new Socket(host, port); - return socket; - } catch (Exception e) { - String message = e.toString(); - throw new JSchException(message, e); - } - } - final String _host = host; - final int _port = port; - final Socket[] sockp = new Socket[1]; - final Exception[] ee = new Exception[1]; - String message = ""; - Thread tmp = new Thread(() -> { - sockp[0] = null; - try { - sockp[0] = new Socket(_host, _port); - } catch (Exception e) { - ee[0] = e; - if (sockp[0] != null && sockp[0].isConnected()) { - try { - sockp[0].close(); - } catch (Exception eee) { - } - } - sockp[0] = null; - } - }); - tmp.setName("Opening Socket " + host); - tmp.start(); + Socket socket = new Socket(); try { - tmp.join(timeout); - message = "timeout: "; - } catch (InterruptedException eee) { - } - if (sockp[0] != null && sockp[0].isConnected()) { - socket = sockp[0]; - } else { - message += "socket is not established"; - if (ee[0] != null) { - message = ee[0].toString(); + socket.connect(new InetSocketAddress(host, port), timeout); + return socket; + } catch (Exception e) { + try { + socket.close(); + } catch (Exception ignore) { } - tmp.interrupt(); - tmp = null; - throw new JSchException(message, ee[0]); + + String message = + e instanceof SocketTimeoutException ? "timeout: socket is not established" : e.toString(); + throw new JSchException(message, e); } - return socket; } static byte[] str2byte(String str, Charset encoding) { From 5d73d5d5128c7d6335fac0b3bed10a95d5301227 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Mon, 11 Dec 2023 13:18:35 -0600 Subject: [PATCH 136/301] Update dependencies. --- .mvn/wrapper/maven-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index eacdc9ed..346d645f 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -14,5 +14,5 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar From 1b22b209c3c85571946c9bdc57d15cff662911b6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Dec 2023 19:25:38 +0000 Subject: [PATCH 137/301] Bump jna.version from 5.13.0 to 5.14.0 Bumps `jna.version` from 5.13.0 to 5.14.0. Updates `net.java.dev.jna:jna-jpms` from 5.13.0 to 5.14.0 - [Changelog](https://github.com/java-native-access/jna/blob/master/CHANGES.md) - [Commits](https://github.com/java-native-access/jna/compare/5.13.0...5.14.0) Updates `net.java.dev.jna:jna-platform-jpms` from 5.13.0 to 5.14.0 - [Changelog](https://github.com/java-native-access/jna/blob/master/CHANGES.md) - [Commits](https://github.com/java-native-access/jna/compare/5.13.0...5.14.0) --- updated-dependencies: - dependency-name: net.java.dev.jna:jna-jpms dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: net.java.dev.jna:jna-platform-jpms dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 493d3d08..57419692 100644 --- a/pom.xml +++ b/pom.xml @@ -78,7 +78,7 @@ UTF-8 true 2.8.3 - 5.13.0 + 5.14.0 2.22.0 2.23.0 3.2.2 From bcccc1f5b72b9faca0c8b360c89a8c1973e2bbc9 Mon Sep 17 00:00:00 2001 From: release-bot Date: Thu, 14 Dec 2023 11:54:03 +0000 Subject: [PATCH 138/301] [maven-release-plugin] prepare release jsch-0.2.14 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 6cebeecf..38be2de1 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.mwiede jsch jar - 0.2.14-SNAPSHOT + 0.2.14 JSch https://github.com/mwiede/jsch JSch is a pure Java implementation of SSH2 @@ -12,7 +12,7 @@ scm:git:https://github.com/mwiede/jsch.git scm:git:https://github.com/mwiede/jsch.git https://github.com/mwiede/jsch - HEAD + jsch-0.2.14 @@ -73,7 +73,7 @@ - 2023-11-13T21:42:59Z + 2023-12-14T11:53:02Z UTF-8 UTF-8 true From 0606bb159d27307a2f9c5450f6a06ec122dddbcd Mon Sep 17 00:00:00 2001 From: release-bot Date: Thu, 14 Dec 2023 11:54:05 +0000 Subject: [PATCH 139/301] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 38be2de1..240690a2 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.mwiede jsch jar - 0.2.14 + 0.2.15-SNAPSHOT JSch https://github.com/mwiede/jsch JSch is a pure Java implementation of SSH2 @@ -12,7 +12,7 @@ scm:git:https://github.com/mwiede/jsch.git scm:git:https://github.com/mwiede/jsch.git https://github.com/mwiede/jsch - jsch-0.2.14 + HEAD @@ -73,7 +73,7 @@ - 2023-12-14T11:53:02Z + 2023-12-14T11:54:05Z UTF-8 UTF-8 true From 22523a9d22e11a4fcb99062011b99ac8b5ca7a8e Mon Sep 17 00:00:00 2001 From: Matthias Wiedemann Date: Thu, 14 Dec 2023 14:05:32 +0100 Subject: [PATCH 140/301] Update ChangeLog.md --- ChangeLog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 8e378c90..03bf6573 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,5 @@ +* [0.2.14](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.14) + * [#450](https://github.com/mwiede/jsch/issues/450) use Socket.connect() with a timeout that has been supported since Java 1.4 instead of using old method of creating a separate thread and joining to that thread with timeout. * [0.2.13](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.13) * #411 Add flush operation from Fix added is/jsch#39, with new config option to allow disabling in case it causes regressions. * #403 add a warning when Channel.getInputStream() or Channel.getExtInputStream() is called after Channel.connect(). From 5129375c79c06cfa104e6f238c8a5f4102c29af4 Mon Sep 17 00:00:00 2001 From: Matthias Wiedemann Date: Thu, 14 Dec 2023 14:06:08 +0100 Subject: [PATCH 141/301] Update Readme.md --- Readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 8578e785..31de4a53 100644 --- a/Readme.md +++ b/Readme.md @@ -33,7 +33,7 @@ with com.github.mwiede jsch - 0.2.13 + 0.2.14 ``` @@ -43,7 +43,7 @@ When you have an artifact `foo:bar`, which contains `com.jcraft:jsch` as a trans com.github.mwiede jsch - 0.2.13 + 0.2.14 foo From e5364919b1bbc736da6bd02776c1def16c09032b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Dec 2023 19:18:36 +0000 Subject: [PATCH 142/301] Bump surefire.version from 3.2.2 to 3.2.3 Bumps `surefire.version` from 3.2.2 to 3.2.3. Updates `org.apache.maven.plugins:maven-surefire-plugin` from 3.2.2 to 3.2.3 - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.2...surefire-3.2.3) Updates `org.apache.maven.plugins:maven-failsafe-plugin` from 3.2.2 to 3.2.3 - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.2...surefire-3.2.3) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.maven.plugins:maven-failsafe-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 240690a2..1f815b11 100644 --- a/pom.xml +++ b/pom.xml @@ -81,7 +81,7 @@ 5.14.0 2.22.0 2.23.0 - 3.2.2 + 3.2.3 From 64614697e0c4850e00ecd8cc4e3f99d6a95e88a4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Dec 2023 19:27:55 +0000 Subject: [PATCH 143/301] Bump actions/upload-artifact from 3 to 4 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3 to 4. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/maven.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 382f52d1..55e530ea 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -35,7 +35,7 @@ jobs: check-latest: true - name: Build with Maven run: ./mvnw -B -V -e -DskipTests=true package - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: java-${{ matrix.java }}-jars path: | @@ -50,7 +50,7 @@ jobs: check-latest: true - name: Test with Maven run: ./mvnw -B -V -e -P coverage verify -Denforcer.skip=true -Dmaven.resources.skip=true -Dmaven.main.skip=true -Dassembly.skipAssembly=true -Dmaven.javadoc.skip=true -DskipITs=false - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: java-${{ matrix.java }}-testresults path: | From c0826392fa17f2c538e31305e6f61af94db5189e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Dec 2023 19:28:01 +0000 Subject: [PATCH 144/301] Bump github/codeql-action from 2 to 3 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2 to 3. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/v2...v3) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql-analysis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 116ac77e..2adf1043 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -42,7 +42,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -56,7 +56,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v3 # ℹī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -69,4 +69,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 From ee39336be270e06901186582377ab3f7e89d12cc Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Mon, 18 Dec 2023 13:58:35 -0600 Subject: [PATCH 145/301] Adjust maven workflow to split unit & integrations into separate steps so that they can be executed via direct mojo calls and thus avoiding potentially reexecuting prior phases. --- .github/workflows/maven.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 382f52d1..b67de70d 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -34,7 +34,7 @@ jobs: java-version: '21' check-latest: true - name: Build with Maven - run: ./mvnw -B -V -e -DskipTests=true package + run: ./mvnw -B -V -e -DskipTests=true verify - uses: actions/upload-artifact@v3 with: name: java-${{ matrix.java }}-jars @@ -48,8 +48,10 @@ jobs: distribution: 'zulu' java-version: ${{ matrix.java }} check-latest: true - - name: Test with Maven - run: ./mvnw -B -V -e -P coverage verify -Denforcer.skip=true -Dmaven.resources.skip=true -Dmaven.main.skip=true -Dassembly.skipAssembly=true -Dmaven.javadoc.skip=true -DskipITs=false + - name: Unit Tests with Maven + run: ./mvnw -B -V -e jacoco:prepare-agent surefire:test jacoco:report + - name: Integration Tests with Maven + run: ./mvnw -B -V -e -DskipITs=false jacoco:prepare-agent-integration failsafe:integration-test failsafe:verify jacoco:report-integration - uses: actions/upload-artifact@v3 with: name: java-${{ matrix.java }}-testresults From 533c437108bb8a16f581d797b0e991754dcd781d Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Mon, 18 Dec 2023 13:59:19 -0600 Subject: [PATCH 146/301] Integrate Forbidden API Checker and resolve issues it flagged. --- pom.xml | 54 +++++++++++++++++++ src/main/java/com/jcraft/jsch/HostKey.java | 4 +- .../jsch/JSchAlgoNegoFailException.java | 4 +- .../java/com/jcraft/jsch/KeyExchange.java | 4 +- .../java/com/jcraft/jsch/OpenSSHConfig.java | 16 +++--- .../com/jcraft/jsch/PageantConnector.java | 4 +- src/main/java/com/jcraft/jsch/Session.java | 3 +- .../jsch/UserAuthKeyboardInteractive.java | 4 +- .../jsch/jzlib/InflaterInputStream.java | 3 +- .../com/jcraft/jsch/AbstractBufferMargin.java | 4 +- .../java/com/jcraft/jsch/Algorithms2IT.java | 24 +++++---- .../java/com/jcraft/jsch/Algorithms3IT.java | 8 +-- .../java/com/jcraft/jsch/AlgorithmsIT.java | 36 +++++++------ .../jsch/JSchAlgoNegoFailExceptionIT.java | 6 ++- .../jcraft/jsch/OpenSSH74ServerSigAlgsIT.java | 4 +- .../com/jcraft/jsch/OpenSSHConfigTest.java | 9 ++-- src/test/java/com/jcraft/jsch/SSHAgentIT.java | 4 +- .../java/com/jcraft/jsch/ServerSigAlgsIT.java | 8 +-- .../com/jcraft/jsch/SessionReconnectIT.java | 4 +- src/test/java/com/jcraft/jsch/UserAuthIT.java | 4 +- .../com/jcraft/jsch/jbcrypt/BCryptTest.java | 12 ++--- .../jcraft/jsch/jzlib/DeflateInflateTest.java | 15 +++--- .../jzlib/DeflaterInflaterStreamTest.java | 3 +- .../jcraft/jsch/jzlib/WrapperTypeTest.java | 9 ++-- 24 files changed, 170 insertions(+), 76 deletions(-) diff --git a/pom.xml b/pom.xml index 1f815b11..3dc16283 100644 --- a/pom.xml +++ b/pom.xml @@ -650,6 +650,19 @@ + + de.thetaphi + forbiddenapis + 3.6 + + + jdk-unsafe + jdk-deprecated + jdk-non-portable + jdk-reflection + + + @@ -805,5 +818,46 @@ + + forbiddenapis + + [16,) + + + + + de.thetaphi + forbiddenapis + + 16 + + + + check + + check + + + + jdk-system-out + + + + + testCheck + + testCheck + + + + commons-io-unsafe-2.14.0 + + + + + + + + diff --git a/src/main/java/com/jcraft/jsch/HostKey.java b/src/main/java/com/jcraft/jsch/HostKey.java index 51b6b8f1..0f9922b6 100644 --- a/src/main/java/com/jcraft/jsch/HostKey.java +++ b/src/main/java/com/jcraft/jsch/HostKey.java @@ -26,6 +26,8 @@ package com.jcraft.jsch; +import java.util.Locale; + public class HostKey { private static final byte[][] names = @@ -118,7 +120,7 @@ public String getKey() { public String getFingerPrint(JSch jsch) { HASH hash = null; try { - String _c = JSch.getConfig("FingerprintHash").toLowerCase(); + String _c = JSch.getConfig("FingerprintHash").toLowerCase(Locale.ROOT); Class c = Class.forName(JSch.getConfig(_c)).asSubclass(HASH.class); hash = c.getDeclaredConstructor().newInstance(); } catch (Exception e) { diff --git a/src/main/java/com/jcraft/jsch/JSchAlgoNegoFailException.java b/src/main/java/com/jcraft/jsch/JSchAlgoNegoFailException.java index fbdbf446..6e668250 100644 --- a/src/main/java/com/jcraft/jsch/JSchAlgoNegoFailException.java +++ b/src/main/java/com/jcraft/jsch/JSchAlgoNegoFailException.java @@ -1,5 +1,7 @@ package com.jcraft.jsch; +import java.util.Locale; + /** * Extension of {@link JSchException} to indicate when a connection fails during algorithm * negotiation. @@ -35,7 +37,7 @@ public String getServerProposal() { } private static String failString(int algorithmIndex, String jschProposal, String serverProposal) { - return String.format( + return String.format(Locale.ROOT, "Algorithm negotiation fail: algorithmName=\"%s\" jschProposal=\"%s\" serverProposal=\"%s\"", algorithmNameFromIndex(algorithmIndex), jschProposal, serverProposal); } diff --git a/src/main/java/com/jcraft/jsch/KeyExchange.java b/src/main/java/com/jcraft/jsch/KeyExchange.java index 7a3d508e..e686be76 100644 --- a/src/main/java/com/jcraft/jsch/KeyExchange.java +++ b/src/main/java/com/jcraft/jsch/KeyExchange.java @@ -26,6 +26,8 @@ package com.jcraft.jsch; +import java.util.Locale; + public abstract class KeyExchange { static final int PROPOSAL_KEX_ALGS = 0; @@ -198,7 +200,7 @@ protected static String[] guess(Session session, byte[] I_S, byte[] I_C) throws public String getFingerPrint() { HASH hash = null; try { - String _c = session.getConfig("FingerprintHash").toLowerCase(); + String _c = session.getConfig("FingerprintHash").toLowerCase(Locale.ROOT); Class c = Class.forName(session.getConfig(_c)).asSubclass(HASH.class); hash = c.getDeclaredConstructor().newInstance(); } catch (Exception e) { diff --git a/src/main/java/com/jcraft/jsch/OpenSSHConfig.java b/src/main/java/com/jcraft/jsch/OpenSSHConfig.java index 4dd6ff05..c56f63a8 100644 --- a/src/main/java/com/jcraft/jsch/OpenSSHConfig.java +++ b/src/main/java/com/jcraft/jsch/OpenSSHConfig.java @@ -36,6 +36,7 @@ import java.util.Arrays; import java.util.Hashtable; import java.util.List; +import java.util.Locale; import java.util.Set; import java.util.Vector; import java.util.stream.Collectors; @@ -75,9 +76,10 @@ */ public class OpenSSHConfig implements ConfigRepository { - private static final Set keysWithListAdoption = - Stream.of("KexAlgorithms", "Ciphers", "HostKeyAlgorithms", "MACs", "PubkeyAcceptedAlgorithms", - "PubkeyAcceptedKeyTypes").map(String::toUpperCase).collect(Collectors.toSet()); + private static final Set keysWithListAdoption = Stream + .of("KexAlgorithms", "Ciphers", "HostKeyAlgorithms", "MACs", "PubkeyAcceptedAlgorithms", + "PubkeyAcceptedKeyTypes") + .map(string -> string.toUpperCase(Locale.ROOT)).collect(Collectors.toSet()); /** * Parses the given string, and returns an instance of ConfigRepository. @@ -209,13 +211,13 @@ private String find(String key) { if (keymap.get(key) != null) { key = keymap.get(key); } - key = key.toUpperCase(); + key = key.toUpperCase(Locale.ROOT); String value = null; for (int i = 0; i < _configs.size(); i++) { Vector v = _configs.elementAt(i); for (int j = 0; j < v.size(); j++) { String[] kv = v.elementAt(j); - if (kv[0].toUpperCase().equals(key)) { + if (kv[0].toUpperCase(Locale.ROOT).equals(key)) { value = kv[1]; break; } @@ -255,13 +257,13 @@ private String find(String key) { } private String[] multiFind(String key) { - key = key.toUpperCase(); + key = key.toUpperCase(Locale.ROOT); Vector value = new Vector<>(); for (int i = 0; i < _configs.size(); i++) { Vector v = _configs.elementAt(i); for (int j = 0; j < v.size(); j++) { String[] kv = v.elementAt(j); - if (kv[0].toUpperCase().equals(key)) { + if (kv[0].toUpperCase(Locale.ROOT).equals(key)) { String foo = kv[1]; if (foo != null) { value.remove(foo); diff --git a/src/main/java/com/jcraft/jsch/PageantConnector.java b/src/main/java/com/jcraft/jsch/PageantConnector.java index 30511c40..898a8aab 100644 --- a/src/main/java/com/jcraft/jsch/PageantConnector.java +++ b/src/main/java/com/jcraft/jsch/PageantConnector.java @@ -40,6 +40,7 @@ import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.platform.win32.WinUser; import com.sun.jna.platform.win32.WinUser.COPYDATASTRUCT; +import java.util.Locale; public class PageantConnector implements AgentConnector { @@ -84,7 +85,8 @@ public void query(Buffer buffer) throws AgentProxyException { throw new AgentProxyException("Pageant is not runnning."); } - String mapname = String.format("PageantRequest%08x", kernel32.GetCurrentThreadId()); + String mapname = + String.format(Locale.ROOT, "PageantRequest%08x", kernel32.GetCurrentThreadId()); HANDLE sharedFile = null; Pointer sharedMemory = null; diff --git a/src/main/java/com/jcraft/jsch/Session.java b/src/main/java/com/jcraft/jsch/Session.java index 47cf3f19..963f43f9 100644 --- a/src/main/java/com/jcraft/jsch/Session.java +++ b/src/main/java/com/jcraft/jsch/Session.java @@ -37,6 +37,7 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Properties; import java.util.Vector; @@ -400,7 +401,7 @@ public void connect(int connectTimeout) throws JSchException { if (!auth) { smethods = uan.getMethods(); if (smethods != null) { - smethods = smethods.toLowerCase(); + smethods = smethods.toLowerCase(Locale.ROOT); } else { // methods: publickey,password,keyboard-interactive // smethods = "publickey,password,keyboard-interactive"; diff --git a/src/main/java/com/jcraft/jsch/UserAuthKeyboardInteractive.java b/src/main/java/com/jcraft/jsch/UserAuthKeyboardInteractive.java index cd5d5eda..2fbabdbe 100644 --- a/src/main/java/com/jcraft/jsch/UserAuthKeyboardInteractive.java +++ b/src/main/java/com/jcraft/jsch/UserAuthKeyboardInteractive.java @@ -26,6 +26,8 @@ package com.jcraft.jsch; +import java.util.Locale; + class UserAuthKeyboardInteractive extends UserAuth { @Override public boolean start(Session session) throws Exception { @@ -129,7 +131,7 @@ public boolean start(Session session) throws Exception { byte[][] response = null; if (password != null && prompt.length == 1 && !echo[0] - && prompt[0].toLowerCase().indexOf("password:") >= 0) { + && prompt[0].toLowerCase(Locale.ROOT).indexOf("password:") >= 0) { response = new byte[1][]; response[0] = password; password = null; diff --git a/src/main/java/com/jcraft/jsch/jzlib/InflaterInputStream.java b/src/main/java/com/jcraft/jsch/jzlib/InflaterInputStream.java index 12287c8d..6d5a90bb 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/InflaterInputStream.java +++ b/src/main/java/com/jcraft/jsch/jzlib/InflaterInputStream.java @@ -27,6 +27,7 @@ package com.jcraft.jsch.jzlib; import java.io.*; +import java.nio.charset.StandardCharsets; final class InflaterInputStream extends FilterInputStream { protected final Inflater inflater; @@ -223,7 +224,7 @@ byte[] getAvailIn() { void readHeader() throws IOException { - byte[] empty = "".getBytes(); + byte[] empty = "".getBytes(StandardCharsets.UTF_8); inflater.setInput(empty, 0, 0, false); inflater.setOutput(empty, 0, 0); diff --git a/src/test/java/com/jcraft/jsch/AbstractBufferMargin.java b/src/test/java/com/jcraft/jsch/AbstractBufferMargin.java index 508de07c..8b152b88 100644 --- a/src/test/java/com/jcraft/jsch/AbstractBufferMargin.java +++ b/src/test/java/com/jcraft/jsch/AbstractBufferMargin.java @@ -14,6 +14,7 @@ import java.nio.file.Paths; import java.util.Base64; import java.util.List; +import java.util.Locale; import java.util.Random; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.io.input.BoundedInputStream; @@ -140,7 +141,8 @@ private JSch createRSAIdentity() throws Exception { private HostKey readHostKey(String fileName) throws Exception { List lines = Files.readAllLines(Paths.get(fileName), UTF_8); String[] split = lines.get(0).split("\\s+"); - String hostname = String.format("[%s]:%d", sshd.getHost(), sshd.getFirstMappedPort()); + String hostname = + String.format(Locale.ROOT, "[%s]:%d", sshd.getHost(), sshd.getFirstMappedPort()); return new HostKey(hostname, Base64.getDecoder().decode(split[1])); } diff --git a/src/test/java/com/jcraft/jsch/Algorithms2IT.java b/src/test/java/com/jcraft/jsch/Algorithms2IT.java index a070f5d4..6c9e37d0 100644 --- a/src/test/java/com/jcraft/jsch/Algorithms2IT.java +++ b/src/test/java/com/jcraft/jsch/Algorithms2IT.java @@ -16,6 +16,7 @@ import java.nio.file.Paths; import java.util.Base64; import java.util.List; +import java.util.Locale; import java.util.Optional; import java.util.Random; import org.apache.commons.codec.digest.DigestUtils; @@ -146,7 +147,7 @@ public void testKEXs(String kex) throws Exception { session.setConfig("kex", kex); doSftp(session, true); - String expected = String.format("kex: algorithm: %s.*", kex); + String expected = String.format(Locale.ROOT, "kex: algorithm: %s.*", kex); checkLogs(expected); } @@ -177,9 +178,9 @@ public void testDHGEXSizes(String kex, String size) throws Exception { session.setConfig("dhgex_preferred", size); doSftp(session, true); - String expectedKex = String.format("kex: algorithm: %s.*", kex); - String expectedSizes = - String.format("SSH_MSG_KEX_DH_GEX_REQUEST\\(%s<%s<%s\\) sent", size, size, size); + String expectedKex = String.format(Locale.ROOT, "kex: algorithm: %s.*", kex); + String expectedSizes = String.format(Locale.ROOT, + "SSH_MSG_KEX_DH_GEX_REQUEST\\(%s<%s<%s\\) sent", size, size, size); checkLogs(expectedKex); checkLogs(expectedSizes); } @@ -235,7 +236,7 @@ public void testRSA(String keyType) throws Exception { session.setConfig("server_host_key", keyType); doSftp(session, true); - String expected = String.format("kex: host key algorithm: %s.*", keyType); + String expected = String.format(Locale.ROOT, "kex: host key algorithm: %s.*", keyType); checkLogs(expected); } @@ -250,8 +251,8 @@ public void testCiphers(String cipher, String compression) throws Exception { session.setConfig("compression.c2s", compression); doSftp(session, true); - String expectedS2C = String.format("kex: server->client cipher: %s.*", cipher); - String expectedC2S = String.format("kex: client->server cipher: %s.*", cipher); + String expectedS2C = String.format(Locale.ROOT, "kex: server->client cipher: %s.*", cipher); + String expectedC2S = String.format(Locale.ROOT, "kex: client->server cipher: %s.*", cipher); checkLogs(expectedS2C); checkLogs(expectedC2S); } @@ -274,8 +275,8 @@ public void testMACs(String mac, String compression) throws Exception { session.setConfig("cipher.c2s", "aes128-ctr"); doSftp(session, true); - String expectedS2C = String.format("kex: server->client .* MAC: %s.*", mac); - String expectedC2S = String.format("kex: client->server .* MAC: %s.*", mac); + String expectedS2C = String.format(Locale.ROOT, "kex: server->client .* MAC: %s.*", mac); + String expectedC2S = String.format(Locale.ROOT, "kex: client->server .* MAC: %s.*", mac); checkLogs(expectedS2C); checkLogs(expectedC2S); } @@ -304,7 +305,7 @@ public void testCompressionImpls(String impl) throws Exception { session.setConfig("zlib", impl); doSftp(session, true); - String expectedImpl = String.format("zlib using %s", impl); + String expectedImpl = String.format(Locale.ROOT, "zlib using %s", impl); String expectedS2C = "kex: server->client .* compression: zlib.*"; String expectedC2S = "kex: client->server .* compression: zlib.*"; checkLogs(expectedImpl); @@ -332,7 +333,8 @@ private JSch createEd448Identity() throws Exception { private HostKey readHostKey(String fileName) throws Exception { List lines = Files.readAllLines(Paths.get(fileName), UTF_8); String[] split = lines.get(0).split("\\s+"); - String hostname = String.format("[%s]:%d", sshd.getHost(), sshd.getFirstMappedPort()); + String hostname = + String.format(Locale.ROOT, "[%s]:%d", sshd.getHost(), sshd.getFirstMappedPort()); return new HostKey(hostname, Base64.getDecoder().decode(split[1])); } diff --git a/src/test/java/com/jcraft/jsch/Algorithms3IT.java b/src/test/java/com/jcraft/jsch/Algorithms3IT.java index 08705968..3da1f74b 100644 --- a/src/test/java/com/jcraft/jsch/Algorithms3IT.java +++ b/src/test/java/com/jcraft/jsch/Algorithms3IT.java @@ -14,6 +14,7 @@ import java.nio.file.Paths; import java.util.Base64; import java.util.List; +import java.util.Locale; import java.util.Optional; import java.util.Random; import org.apache.commons.codec.digest.DigestUtils; @@ -96,8 +97,8 @@ public void testCiphers(String cipher, String compression) throws Exception { session.setConfig("compression.c2s", compression); doSftp(session, true); - String expectedS2C = String.format("kex: server->client cipher: %s.*", cipher); - String expectedC2S = String.format("kex: client->server cipher: %s.*", cipher); + String expectedS2C = String.format(Locale.ROOT, "kex: server->client cipher: %s.*", cipher); + String expectedC2S = String.format(Locale.ROOT, "kex: client->server cipher: %s.*", cipher); checkLogs(expectedS2C); checkLogs(expectedC2S); } @@ -113,7 +114,8 @@ private JSch createRSAIdentity() throws Exception { private HostKey readHostKey(String fileName) throws Exception { List lines = Files.readAllLines(Paths.get(fileName), UTF_8); String[] split = lines.get(0).split("\\s+"); - String hostname = String.format("[%s]:%d", sshd.getHost(), sshd.getFirstMappedPort()); + String hostname = + String.format(Locale.ROOT, "[%s]:%d", sshd.getHost(), sshd.getFirstMappedPort()); return new HostKey(hostname, Base64.getDecoder().decode(split[1])); } diff --git a/src/test/java/com/jcraft/jsch/AlgorithmsIT.java b/src/test/java/com/jcraft/jsch/AlgorithmsIT.java index bc83053f..676970e2 100644 --- a/src/test/java/com/jcraft/jsch/AlgorithmsIT.java +++ b/src/test/java/com/jcraft/jsch/AlgorithmsIT.java @@ -18,6 +18,7 @@ import java.util.Arrays; import java.util.Base64; import java.util.List; +import java.util.Locale; import java.util.Optional; import java.util.Random; import org.apache.commons.codec.digest.DigestUtils; @@ -115,7 +116,7 @@ public void testJava11KEXs(String kex) throws Exception { session.setConfig("kex", kex); doSftp(session, true); - String expected = String.format("kex: algorithm: %s.*", kex); + String expected = String.format(Locale.ROOT, "kex: algorithm: %s.*", kex); checkLogs(expected); } @@ -128,7 +129,7 @@ public void testBCKEXs(String kex) throws Exception { session.setConfig("kex", kex); doSftp(session, true); - String expected = String.format("kex: algorithm: %s.*", kex); + String expected = String.format(Locale.ROOT, "kex: algorithm: %s.*", kex); checkLogs(expected); } @@ -144,7 +145,7 @@ public void testKEXs(String kex) throws Exception { session.setConfig("kex", kex); doSftp(session, true); - String expected = String.format("kex: algorithm: %s.*", kex); + String expected = String.format(Locale.ROOT, "kex: algorithm: %s.*", kex); checkLogs(expected); } @@ -164,9 +165,9 @@ public void testDHGEXSizes(String kex, String size) throws Exception { session.setConfig("dhgex_preferred", size); doSftp(session, true); - String expectedKex = String.format("kex: algorithm: %s.*", kex); - String expectedSizes = - String.format("SSH_MSG_KEX_DH_GEX_REQUEST\\(%s<%s<%s\\) sent", size, size, size); + String expectedKex = String.format(Locale.ROOT, "kex: algorithm: %s.*", kex); + String expectedSizes = String.format(Locale.ROOT, + "SSH_MSG_KEX_DH_GEX_REQUEST\\(%s<%s<%s\\) sent", size, size, size); checkLogs(expectedKex); checkLogs(expectedSizes); } @@ -257,7 +258,7 @@ public void testRSA(String keyType) throws Exception { session.setConfig("server_host_key", keyType); doSftp(session, true); - String expected = String.format("kex: host key algorithm: %s.*", keyType); + String expected = String.format(Locale.ROOT, "kex: host key algorithm: %s.*", keyType); checkLogs(expected); } @@ -296,8 +297,8 @@ public void testCiphers(String cipher, String compression) throws Exception { session.setConfig("compression.c2s", compression); doSftp(session, true); - String expectedS2C = String.format("kex: server->client cipher: %s.*", cipher); - String expectedC2S = String.format("kex: client->server cipher: %s.*", cipher); + String expectedS2C = String.format(Locale.ROOT, "kex: server->client cipher: %s.*", cipher); + String expectedC2S = String.format(Locale.ROOT, "kex: client->server cipher: %s.*", cipher); checkLogs(expectedS2C); checkLogs(expectedC2S); } @@ -329,8 +330,8 @@ public void testMACs(String mac, String compression) throws Exception { session.setConfig("cipher.c2s", "aes128-ctr"); doSftp(session, true); - String expectedS2C = String.format("kex: server->client .* MAC: %s.*", mac); - String expectedC2S = String.format("kex: client->server .* MAC: %s.*", mac); + String expectedS2C = String.format(Locale.ROOT, "kex: server->client .* MAC: %s.*", mac); + String expectedC2S = String.format(Locale.ROOT, "kex: client->server .* MAC: %s.*", mac); checkLogs(expectedS2C); checkLogs(expectedC2S); } @@ -344,8 +345,10 @@ public void testCompressions(String compression) throws Exception { session.setConfig("compression.c2s", compression); doSftp(session, true); - String expectedS2C = String.format("kex: server->client .* compression: %s.*", compression); - String expectedC2S = String.format("kex: client->server .* compression: %s.*", compression); + String expectedS2C = + String.format(Locale.ROOT, "kex: server->client .* compression: %s.*", compression); + String expectedC2S = + String.format(Locale.ROOT, "kex: client->server .* compression: %s.*", compression); checkLogs(expectedS2C); checkLogs(expectedC2S); } @@ -360,7 +363,7 @@ public void testCompressionImpls(String impl) throws Exception { session.setConfig("zlib@openssh.com", impl); doSftp(session, true); - String expectedImpl = String.format("zlib using %s", impl); + String expectedImpl = String.format(Locale.ROOT, "zlib using %s", impl); String expectedS2C = "kex: server->client .* compression: zlib@openssh\\.com.*"; String expectedC2S = "kex: client->server .* compression: zlib@openssh\\.com.*"; checkLogs(expectedImpl); @@ -392,7 +395,7 @@ public void testFingerprintHashes(String fingerprint) throws Exception { } catch (JSchException expected) { } - String expected = String.format("RSA key fingerprint is %s.", fingerprint); + String expected = String.format(Locale.ROOT, "RSA key fingerprint is %s.", fingerprint); List msgs = userInfo.getMessages().stream().map(msg -> msg.split("\n")) .flatMap(Arrays::stream).collect(toList()); Optional actual = msgs.stream().filter(msg -> msg.equals(expected)).findFirst(); @@ -460,7 +463,8 @@ private JSch createEd25519Identity() throws Exception { private HostKey readHostKey(String fileName) throws Exception { List lines = Files.readAllLines(Paths.get(fileName), UTF_8); String[] split = lines.get(0).split("\\s+"); - String hostname = String.format("[%s]:%d", sshd.getHost(), sshd.getFirstMappedPort()); + String hostname = + String.format(Locale.ROOT, "[%s]:%d", sshd.getHost(), sshd.getFirstMappedPort()); return new HostKey(hostname, Base64.getDecoder().decode(split[1])); } diff --git a/src/test/java/com/jcraft/jsch/JSchAlgoNegoFailExceptionIT.java b/src/test/java/com/jcraft/jsch/JSchAlgoNegoFailExceptionIT.java index 4352136c..e26ab53b 100644 --- a/src/test/java/com/jcraft/jsch/JSchAlgoNegoFailExceptionIT.java +++ b/src/test/java/com/jcraft/jsch/JSchAlgoNegoFailExceptionIT.java @@ -8,6 +8,7 @@ import java.nio.file.Paths; import java.util.Base64; import java.util.List; +import java.util.Locale; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; import org.testcontainers.containers.GenericContainer; @@ -62,7 +63,7 @@ public void testJSchAlgoNegoFailException(String algorithmName, String serverPro if (algorithmName.equals("kex")) { jschProposal += ",ext-info-c"; } - String message = String.format( + String message = String.format(Locale.ROOT, "Algorithm negotiation fail: algorithmName=\"%s\" jschProposal=\"%s\" serverProposal=\"%s\"", algorithmName, jschProposal, serverProposal); @@ -83,7 +84,8 @@ private JSch createRSAIdentity() throws Exception { private HostKey readHostKey(String fileName) throws Exception { List lines = Files.readAllLines(Paths.get(fileName), UTF_8); String[] split = lines.get(0).split("\\s+"); - String hostname = String.format("[%s]:%d", sshd.getHost(), sshd.getFirstMappedPort()); + String hostname = + String.format(Locale.ROOT, "[%s]:%d", sshd.getHost(), sshd.getFirstMappedPort()); return new HostKey(hostname, Base64.getDecoder().decode(split[1])); } diff --git a/src/test/java/com/jcraft/jsch/OpenSSH74ServerSigAlgsIT.java b/src/test/java/com/jcraft/jsch/OpenSSH74ServerSigAlgsIT.java index 104504a1..5b485ab4 100644 --- a/src/test/java/com/jcraft/jsch/OpenSSH74ServerSigAlgsIT.java +++ b/src/test/java/com/jcraft/jsch/OpenSSH74ServerSigAlgsIT.java @@ -14,6 +14,7 @@ import java.nio.file.Paths; import java.util.Base64; import java.util.List; +import java.util.Locale; import java.util.Optional; import java.util.Random; import org.apache.commons.codec.digest.DigestUtils; @@ -143,7 +144,8 @@ private JSch createRSAIdentity() throws Exception { private HostKey readHostKey(String fileName) throws Exception { List lines = Files.readAllLines(Paths.get(fileName), UTF_8); String[] split = lines.get(0).split("\\s+"); - String hostname = String.format("[%s]:%d", sshd.getHost(), sshd.getFirstMappedPort()); + String hostname = + String.format(Locale.ROOT, "[%s]:%d", sshd.getHost(), sshd.getFirstMappedPort()); return new HostKey(hostname, Base64.getDecoder().decode(split[1])); } diff --git a/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java b/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java index 67bc0b60..bb1bb9be 100644 --- a/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java +++ b/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java @@ -7,6 +7,7 @@ import java.io.IOException; import java.net.URISyntaxException; import java.nio.file.Paths; +import java.util.Locale; import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; @@ -15,8 +16,8 @@ class OpenSSHConfigTest { - Map keyMap = OpenSSHConfig.getKeymap().entrySet().stream().collect( - Collectors.toMap(entry -> entry.getValue().toUpperCase(), Map.Entry::getKey, (s, s2) -> s2)); + Map keyMap = OpenSSHConfig.getKeymap().entrySet().stream().collect(Collectors + .toMap(entry -> entry.getValue().toUpperCase(Locale.ROOT), Map.Entry::getKey, (s, s2) -> s2)); @Test void parseFile() throws IOException, URISyntaxException { @@ -52,7 +53,7 @@ void appendKexAlgorithms() throws IOException { void appendAlgorithms(String key) throws IOException { OpenSSHConfig parse = OpenSSHConfig.parse(key + " +someValue,someValue1"); ConfigRepository.Config config = parse.getConfig(""); - String mappedKey = Optional.ofNullable(keyMap.get(key.toUpperCase())).orElse(key); + String mappedKey = Optional.ofNullable(keyMap.get(key.toUpperCase(Locale.ROOT))).orElse(key); assertEquals(JSch.getConfig(mappedKey) + "," + "someValue,someValue1", config.getValue(mappedKey)); } @@ -63,7 +64,7 @@ void appendAlgorithms(String key) throws IOException { void prependAlgorithms(String key) throws IOException { OpenSSHConfig parse = OpenSSHConfig.parse(key + " ^someValue,someValue1"); ConfigRepository.Config config = parse.getConfig(""); - String mappedKey = Optional.ofNullable(keyMap.get(key.toUpperCase())).orElse(key); + String mappedKey = Optional.ofNullable(keyMap.get(key.toUpperCase(Locale.ROOT))).orElse(key); assertEquals("someValue,someValue1," + JSch.getConfig(mappedKey), config.getValue(mappedKey)); } diff --git a/src/test/java/com/jcraft/jsch/SSHAgentIT.java b/src/test/java/com/jcraft/jsch/SSHAgentIT.java index 0ab7c170..57afd010 100644 --- a/src/test/java/com/jcraft/jsch/SSHAgentIT.java +++ b/src/test/java/com/jcraft/jsch/SSHAgentIT.java @@ -18,6 +18,7 @@ import java.nio.file.Paths; import java.util.Base64; import java.util.List; +import java.util.Locale; import java.util.Random; import org.apache.commons.codec.digest.DigestUtils; import org.junit.jupiter.api.AfterAll; @@ -353,7 +354,8 @@ private JSch createEd25519Identity(USocketFactory factory) throws Exception { private HostKey readHostKey(String fileName) throws Exception { List lines = Files.readAllLines(Paths.get(fileName), UTF_8); String[] split = lines.get(0).split("\\s+"); - String hostname = String.format("[%s]:%d", sshd.getHost(), sshd.getFirstMappedPort()); + String hostname = + String.format(Locale.ROOT, "[%s]:%d", sshd.getHost(), sshd.getFirstMappedPort()); return new HostKey(hostname, Base64.getDecoder().decode(split[1])); } diff --git a/src/test/java/com/jcraft/jsch/ServerSigAlgsIT.java b/src/test/java/com/jcraft/jsch/ServerSigAlgsIT.java index 17478043..bc1aa0f5 100644 --- a/src/test/java/com/jcraft/jsch/ServerSigAlgsIT.java +++ b/src/test/java/com/jcraft/jsch/ServerSigAlgsIT.java @@ -14,6 +14,7 @@ import java.nio.file.Paths; import java.util.Base64; import java.util.List; +import java.util.Locale; import java.util.Optional; import java.util.Random; import org.apache.commons.codec.digest.DigestUtils; @@ -139,8 +140,8 @@ public void testNoServerSigAlgs() throws Exception { doSftp(session, true); String expectedKex = "kex: host key algorithm: rsa-sha2-512"; - String expectedPubkeysNoServerSigs = - String.format("No server-sig-algs found, using PubkeyAcceptedAlgorithms = %s", algos); + String expectedPubkeysNoServerSigs = String.format(Locale.ROOT, + "No server-sig-algs found, using PubkeyAcceptedAlgorithms = %s", algos); String expectedPreauthFail1 = "ssh-rsa-sha512@ssh.com preauth failure"; String expectedPreauthFail2 = "ssh-rsa-sha384@ssh.com preauth failure"; String expectedPreauthFail3 = "ssh-rsa-sha256@ssh.com preauth failure"; @@ -167,7 +168,8 @@ private JSch createRSAIdentity() throws Exception { private HostKey readHostKey(String fileName) throws Exception { List lines = Files.readAllLines(Paths.get(fileName), UTF_8); String[] split = lines.get(0).split("\\s+"); - String hostname = String.format("[%s]:%d", sshd.getHost(), sshd.getFirstMappedPort()); + String hostname = + String.format(Locale.ROOT, "[%s]:%d", sshd.getHost(), sshd.getFirstMappedPort()); return new HostKey(hostname, Base64.getDecoder().decode(split[1])); } diff --git a/src/test/java/com/jcraft/jsch/SessionReconnectIT.java b/src/test/java/com/jcraft/jsch/SessionReconnectIT.java index f2b603ef..80be660a 100644 --- a/src/test/java/com/jcraft/jsch/SessionReconnectIT.java +++ b/src/test/java/com/jcraft/jsch/SessionReconnectIT.java @@ -14,6 +14,7 @@ import java.nio.file.Paths; import java.util.Base64; import java.util.List; +import java.util.Locale; import java.util.Random; import org.apache.commons.codec.digest.DigestUtils; import org.junit.jupiter.api.AfterAll; @@ -112,7 +113,8 @@ private JSch createRSAIdentity() throws Exception { private HostKey readHostKey(String fileName) throws Exception { List lines = Files.readAllLines(Paths.get(fileName), UTF_8); String[] split = lines.get(0).split("\\s+"); - String hostname = String.format("[%s]:%d", sshd.getHost(), sshd.getFirstMappedPort()); + String hostname = + String.format(Locale.ROOT, "[%s]:%d", sshd.getHost(), sshd.getFirstMappedPort()); return new HostKey(hostname, Base64.getDecoder().decode(split[1])); } diff --git a/src/test/java/com/jcraft/jsch/UserAuthIT.java b/src/test/java/com/jcraft/jsch/UserAuthIT.java index a0e5fc11..774cae5f 100644 --- a/src/test/java/com/jcraft/jsch/UserAuthIT.java +++ b/src/test/java/com/jcraft/jsch/UserAuthIT.java @@ -14,6 +14,7 @@ import java.nio.file.Paths; import java.util.Base64; import java.util.List; +import java.util.Locale; import java.util.Random; import org.apache.commons.codec.digest.DigestUtils; import org.junit.jupiter.api.AfterAll; @@ -144,7 +145,8 @@ private JSch createRSAIdentity() throws Exception { private HostKey readHostKey(String fileName) throws Exception { List lines = Files.readAllLines(Paths.get(fileName), UTF_8); String[] split = lines.get(0).split("\\s+"); - String hostname = String.format("[%s]:%d", sshd.getHost(), sshd.getFirstMappedPort()); + String hostname = + String.format(Locale.ROOT, "[%s]:%d", sshd.getHost(), sshd.getFirstMappedPort()); return new HostKey(hostname, Base64.getDecoder().decode(split[1])); } diff --git a/src/test/java/com/jcraft/jsch/jbcrypt/BCryptTest.java b/src/test/java/com/jcraft/jsch/jbcrypt/BCryptTest.java index c4edcbdd..6f69f4c8 100644 --- a/src/test/java/com/jcraft/jsch/jbcrypt/BCryptTest.java +++ b/src/test/java/com/jcraft/jsch/jbcrypt/BCryptTest.java @@ -14,11 +14,11 @@ package com.jcraft.jsch.jbcrypt; -import org.junit.jupiter.api.Test; +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.jupiter.api.Assertions.*; import java.util.Arrays; - -import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; /** * JUnit unit tests for BCrypt routines @@ -246,14 +246,14 @@ public BCryptPbkdfTV(byte[] pass, byte[] salt, int rounds, byte[] out) { } BCryptPbkdfTV[] bcrypt_pbkdf_test_vectors = new BCryptPbkdfTV[] { - new BCryptPbkdfTV("password".getBytes(), "salt".getBytes(), 4, + new BCryptPbkdfTV("password".getBytes(UTF_8), "salt".getBytes(UTF_8), 4, new byte[] {(byte) 0x5b, (byte) 0xbf, (byte) 0x0c, (byte) 0xc2, (byte) 0x93, (byte) 0x58, (byte) 0x7f, (byte) 0x1c, (byte) 0x36, (byte) 0x35, (byte) 0x55, (byte) 0x5c, (byte) 0x27, (byte) 0x79, (byte) 0x65, (byte) 0x98, (byte) 0xd4, (byte) 0x7e, (byte) 0x57, (byte) 0x90, (byte) 0x71, (byte) 0xbf, (byte) 0x42, (byte) 0x7e, (byte) 0x9d, (byte) 0x8f, (byte) 0xbe, (byte) 0x84, (byte) 0x2a, (byte) 0xba, (byte) 0x34, (byte) 0xd9,}), - new BCryptPbkdfTV("password".getBytes(), "salt".getBytes(), 8, + new BCryptPbkdfTV("password".getBytes(UTF_8), "salt".getBytes(UTF_8), 8, new byte[] {(byte) 0xe1, (byte) 0x36, (byte) 0x7e, (byte) 0xc5, (byte) 0x15, (byte) 0x1a, (byte) 0x33, (byte) 0xfa, (byte) 0xac, (byte) 0x4c, (byte) 0xc1, (byte) 0xc1, (byte) 0x44, (byte) 0xcd, (byte) 0x23, (byte) 0xfa, (byte) 0x15, (byte) 0xd5, @@ -265,7 +265,7 @@ public BCryptPbkdfTV(byte[] pass, byte[] salt, int rounds, byte[] out) { (byte) 0xe7, (byte) 0x4b, (byte) 0xba, (byte) 0x51, (byte) 0x72, (byte) 0x3f, (byte) 0xef, (byte) 0xa9, (byte) 0xf9, (byte) 0x47, (byte) 0x4d, (byte) 0x65, (byte) 0x08, (byte) 0x84, (byte) 0x5e, (byte) 0x8d}), - new BCryptPbkdfTV("password".getBytes(), "salt".getBytes(), 42, + new BCryptPbkdfTV("password".getBytes(UTF_8), "salt".getBytes(UTF_8), 42, new byte[] {(byte) 0x83, (byte) 0x3c, (byte) 0xf0, (byte) 0xdc, (byte) 0xf5, (byte) 0x6d, (byte) 0xb6, (byte) 0x56, (byte) 0x08, (byte) 0xe8, (byte) 0xf0, (byte) 0xdc, (byte) 0x0c, (byte) 0xe8, (byte) 0x82, (byte) 0xbd}),}; diff --git a/src/test/java/com/jcraft/jsch/jzlib/DeflateInflateTest.java b/src/test/java/com/jcraft/jsch/jzlib/DeflateInflateTest.java index 7cfdf795..3d2489d5 100644 --- a/src/test/java/com/jcraft/jsch/jzlib/DeflateInflateTest.java +++ b/src/test/java/com/jcraft/jsch/jzlib/DeflateInflateTest.java @@ -1,6 +1,7 @@ package com.jcraft.jsch.jzlib; import static com.jcraft.jsch.jzlib.JZlib.*; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -90,7 +91,7 @@ public void testDeflaterAndInflaterCanDeflateAndInflateDataInLargeBuffer() { @Test public void testDeflaterAndInflaterCanDeflateAndInflateDataInSmallBuffer() { - byte[] data = "hello, hello!".getBytes(); + byte[] data = "hello, hello!".getBytes(UTF_8); err = deflater.init(Z_DEFAULT_COMPRESSION); assertEquals(Z_OK, err); @@ -142,8 +143,8 @@ public void testDeflaterAndInflaterCanDeflateAndInflateDataInSmallBuffer() { @Test public void testDeflaterAndInflaterSupportDictionary() { - byte[] hello = "hello".getBytes(); - byte[] dictionary = "hello, hello!".getBytes(); + byte[] hello = "hello".getBytes(UTF_8); + byte[] dictionary = "hello, hello!".getBytes(UTF_8); err = deflater.init(Z_DEFAULT_COMPRESSION); assertEquals(Z_OK, err); @@ -198,7 +199,7 @@ public void testDeflaterAndInflaterSupportDictionary() { @Test public void testDeflaterAndInflaterSupportSync() { - byte[] hello = "hello".getBytes(); + byte[] hello = "hello".getBytes(UTF_8); err = deflater.init(Z_DEFAULT_COMPRESSION); assertEquals(Z_OK, err); @@ -244,12 +245,12 @@ public void testDeflaterAndInflaterSupportSync() { byte[] actual = new byte[total_out]; System.arraycopy(uncompr, 0, actual, 0, total_out); - assertEquals(new String(hello), "hel" + new String(actual)); + assertEquals(new String(hello, UTF_8), "hel" + new String(actual, UTF_8)); } @Test public void testInflaterCanInflateGzipData() { - byte[] hello = "foo".getBytes(); + byte[] hello = "foo".getBytes(UTF_8); byte[] data = {(byte) 0x1f, (byte) 0x8b, (byte) 0x08, (byte) 0x18, (byte) 0x08, (byte) 0xeb, (byte) 0x7a, (byte) 0x0b, (byte) 0x00, (byte) 0x0b, (byte) 0x58, (byte) 0x00, (byte) 0x59, (byte) 0x00, (byte) 0x4b, (byte) 0xcb, (byte) 0xcf, (byte) 0x07, (byte) 0x00, (byte) 0x21, @@ -284,7 +285,7 @@ public void testInflaterCanInflateGzipData() { @Test public void testInflaterAndDeflaterCanSupportGzipData() { - byte[] data = "hello, hello!".getBytes(); + byte[] data = "hello, hello!".getBytes(UTF_8); err = deflater.init(Z_DEFAULT_COMPRESSION, 15 + 16); assertEquals(Z_OK, err); diff --git a/src/test/java/com/jcraft/jsch/jzlib/DeflaterInflaterStreamTest.java b/src/test/java/com/jcraft/jsch/jzlib/DeflaterInflaterStreamTest.java index 82c2f671..1e9b018d 100644 --- a/src/test/java/com/jcraft/jsch/jzlib/DeflaterInflaterStreamTest.java +++ b/src/test/java/com/jcraft/jsch/jzlib/DeflaterInflaterStreamTest.java @@ -1,6 +1,7 @@ package com.jcraft.jsch.jzlib; import static com.jcraft.jsch.jzlib.Package.*; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -94,7 +95,7 @@ public void testDeflaterAndInflaterCanDeflateAndInflateNowrapDataWithMaxWbits() Arrays.asList(randombuf(10240), "{\"color\":2,\"id\":\"EvLd4UG.CXjnk35o1e8LrYYQfHu0h.d*SqVJPoqmzXM::Ly::Snaps::Store::Commit\"}" - .getBytes()) + .getBytes(UTF_8)) .forEach(uncheckedConsumer(data1 -> { Deflater deflater = new Deflater(JZlib.Z_DEFAULT_COMPRESSION, JZlib.MAX_WBITS, true); diff --git a/src/test/java/com/jcraft/jsch/jzlib/WrapperTypeTest.java b/src/test/java/com/jcraft/jsch/jzlib/WrapperTypeTest.java index 91b24949..4ec42f9e 100644 --- a/src/test/java/com/jcraft/jsch/jzlib/WrapperTypeTest.java +++ b/src/test/java/com/jcraft/jsch/jzlib/WrapperTypeTest.java @@ -2,6 +2,7 @@ import static com.jcraft.jsch.jzlib.JZlib.*; import static com.jcraft.jsch.jzlib.Package.*; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -17,7 +18,7 @@ import org.junit.jupiter.api.Test; public class WrapperTypeTest { - private final byte[] data = "hello, hello!".getBytes(); + private final byte[] data = "hello, hello!".getBytes(UTF_8); private final int comprLen = 40000; private final int uncomprLen = comprLen; @@ -92,7 +93,7 @@ public void testZStreamCanDetectDataTypeOfInput() { c.good.forEach(w -> { ZStream inflater = inflate(compr, uncompr, w); int total_out = (int) inflater.total_out; - assertEquals(new String(data), new String(uncompr, 0, total_out)); + assertEquals(new String(data, UTF_8), new String(uncompr, 0, total_out, UTF_8)); }); c.bad.forEach(w -> { @@ -129,7 +130,7 @@ public void testDeflaterCanSupportWbitsPlus32() { assertEquals(Z_OK, err); int total_out = (int) inflater.total_out; - assertEquals(new String(data), new String(uncompr, 0, total_out)); + assertEquals(new String(data, UTF_8), new String(uncompr, 0, total_out, UTF_8)); deflater = new Deflater(); err = deflater.init(Z_BEST_SPEED, DEF_WBITS + 16, 9); @@ -156,7 +157,7 @@ public void testDeflaterCanSupportWbitsPlus32() { assertEquals(Z_OK, err); total_out = (int) inflater.total_out; - assertEquals(new String(data), new String(uncompr, 0, total_out)); + assertEquals(new String(data, UTF_8), new String(uncompr, 0, total_out, UTF_8)); } private void deflate(ZStream deflater, byte[] data, byte[] compr) { From 6214da974286a8b94a95f4cf6cec96e972ffd370 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Mon, 18 Dec 2023 14:00:02 -0600 Subject: [PATCH 147/301] #457 address CVE-2023-48795 by adding support for new strict key exchange extension. --- src/main/java/com/jcraft/jsch/JSch.java | 2 + .../jcraft/jsch/JSchStrictKexException.java | 39 ++++++++ src/main/java/com/jcraft/jsch/Session.java | 89 +++++++++++++++++- .../jsch/JSchAlgoNegoFailExceptionIT.java | 2 +- .../jcraft/jsch/JSchStrictKexExceptionIT.java | 91 +++++++++++++++++++ 5 files changed, 219 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/jcraft/jsch/JSchStrictKexException.java create mode 100644 src/test/java/com/jcraft/jsch/JSchStrictKexExceptionIT.java diff --git a/src/main/java/com/jcraft/jsch/JSch.java b/src/main/java/com/jcraft/jsch/JSch.java index c1335964..ae754305 100644 --- a/src/main/java/com/jcraft/jsch/JSch.java +++ b/src/main/java/com/jcraft/jsch/JSch.java @@ -45,6 +45,8 @@ public class JSch { "ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256")); config.put("prefer_known_host_key_types", Util.getSystemProperty("jsch.prefer_known_host_key_types", "yes")); + config.put("enable_strict_kex", Util.getSystemProperty("jsch.enable_strict_kex", "yes")); + config.put("require_strict_kex", Util.getSystemProperty("jsch.require_strict_kex", "no")); config.put("enable_server_sig_algs", Util.getSystemProperty("jsch.enable_server_sig_algs", "yes")); config.put("cipher.s2c", Util.getSystemProperty("jsch.cipher", diff --git a/src/main/java/com/jcraft/jsch/JSchStrictKexException.java b/src/main/java/com/jcraft/jsch/JSchStrictKexException.java new file mode 100644 index 00000000..3454c1d2 --- /dev/null +++ b/src/main/java/com/jcraft/jsch/JSchStrictKexException.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions + * and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided with + * the distribution. + * + * 3. The names of the authors may not be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.jcraft.jsch; + +public class JSchStrictKexException extends JSchException { + private static final long serialVersionUID = -1L; + + JSchStrictKexException() { + super(); + } + + JSchStrictKexException(String s) { + super(s); + } +} diff --git a/src/main/java/com/jcraft/jsch/Session.java b/src/main/java/com/jcraft/jsch/Session.java index 963f43f9..ede905e5 100644 --- a/src/main/java/com/jcraft/jsch/Session.java +++ b/src/main/java/com/jcraft/jsch/Session.java @@ -117,6 +117,11 @@ public class Session { private volatile boolean isConnected = false; + private volatile boolean initialKex = true; + private volatile boolean doStrictKex = false; + private boolean enable_strict_kex = true; + private boolean require_strict_kex = false; + private volatile boolean isAuthed = false; private Thread connectThread = null; @@ -194,6 +199,7 @@ public void connect(int connectTimeout) throws JSchException { if (isConnected) { throw new JSchException("session is already connected"); } + initialKex = true; io = new IO(); if (random == null) { @@ -308,6 +314,8 @@ public void connect(int connectTimeout) throws JSchException { getLogger().log(Logger.INFO, "Local version string: " + Util.byte2str(V_C)); } + enable_strict_kex = getConfig("enable_strict_kex").equals("yes"); + require_strict_kex = getConfig("require_strict_kex").equals("yes"); send_kexinit(); buf = read(buf); @@ -365,6 +373,7 @@ public void connect(int connectTimeout) throws JSchException { } receive_newkeys(buf, kex); + initialKex = false; } else { in_kex = false; throw new JSchException("invalid protocol(newkyes): " + buf.getCommand()); @@ -565,6 +574,21 @@ private KeyExchange receive_kexinit(Buffer buf) throws Exception { } System.arraycopy(buf.buffer, buf.s, I_S, 0, I_S.length); + if ((enable_strict_kex || require_strict_kex) && initialKex) { + doStrictKex = checkServerStrictKex(); + if (doStrictKex) { + if (getLogger().isEnabled(Logger.INFO)) { + getLogger().log(Logger.INFO, "Doing strict KEX"); + } + + if (seqi != 1) { + throw new JSchStrictKexException("KEXINIT not first packet from server"); + } + } else if (require_strict_kex) { + throw new JSchStrictKexException("Strict KEX not supported by server"); + } + } + if (!in_kex) { // We are in rekeying activated by the remote! send_kexinit(); } @@ -572,7 +596,9 @@ private KeyExchange receive_kexinit(Buffer buf) throws Exception { guess = KeyExchange.guess(this, I_S, I_C); if (guess[KeyExchange.PROPOSAL_KEX_ALGS].equals("ext-info-c") - || guess[KeyExchange.PROPOSAL_KEX_ALGS].equals("ext-info-s")) { + || guess[KeyExchange.PROPOSAL_KEX_ALGS].equals("ext-info-s") + || guess[KeyExchange.PROPOSAL_KEX_ALGS].equals("kex-strict-c-v00@openssh.com") + || guess[KeyExchange.PROPOSAL_KEX_ALGS].equals("kex-strict-s-v00@openssh.com")) { throw new JSchException("Invalid Kex negotiated: " + guess[KeyExchange.PROPOSAL_KEX_ALGS]); } @@ -595,6 +621,28 @@ private KeyExchange receive_kexinit(Buffer buf) throws Exception { return kex; } + private boolean checkServerStrictKex() { + Buffer sb = new Buffer(I_S); + sb.setOffSet(17); + byte[] sp = sb.getString(); // server proposal + + int l = 0; + int m = 0; + while (l < sp.length) { + while (l < sp.length && sp[l] != ',') + l++; + if (m == l) + continue; + if ("kex-strict-s-v00@openssh.com".equals(Util.byte2str(sp, m, l - m))) { + return true; + } + l++; + m = l; + } + + return false; + } + private volatile boolean in_kex = false; private volatile boolean in_prompt = false; private volatile String[] not_available_shks = null; @@ -683,6 +731,10 @@ private void send_kexinit() throws Exception { kex += ",ext-info-c"; } + if ((enable_strict_kex || require_strict_kex) && initialKex) { + kex += ",kex-strict-c-v00@openssh.com"; + } + String server_host_key = getConfig("server_host_key"); String[] not_available_shks = checkSignatures(getConfig("CheckSignatures")); // Cache for UserAuthPublicKey @@ -1177,7 +1229,9 @@ Buffer read(Buffer buf) throws Exception { } } - seqi++; + if (++seqi == 0 && (enable_strict_kex || require_strict_kex) && initialKex) { + throw new JSchStrictKexException("incoming sequence number wrapped during initial KEX"); + } if (inflater != null) { // inflater.uncompress(buf); @@ -1210,6 +1264,8 @@ Buffer read(Buffer buf) throws Exception { "SSH_MSG_DISCONNECT: " + reason_code + " " + description + " " + language_tag, reason_code, description, language_tag); // break; + } else if (initialKex && doStrictKex) { + break; } else if (type == SSH_MSG_IGNORE) { } else if (type == SSH_MSG_UNIMPLEMENTED) { buf.rewind(); @@ -1354,6 +1410,13 @@ byte[] getSessionId() { private void receive_newkeys(Buffer buf, KeyExchange kex) throws Exception { updateKeys(kex); in_kex = false; + if (doStrictKex) { + seqi = 0; + if (getLogger().isEnabled(Logger.INFO)) { + getLogger().log(Logger.INFO, + "Reset incoming sequence number after receiving SSH_MSG_NEWKEYS for strict KEX"); + } + } } private void updateKeys(KeyExchange kex) throws Exception { @@ -1621,13 +1684,29 @@ void write(Packet packet) throws Exception { } private void _write(Packet packet) throws Exception { + boolean initialKex = this.initialKex; + boolean doStrictKex = this.doStrictKex; + boolean enable_strict_kex = this.enable_strict_kex; + boolean require_strict_kex = this.require_strict_kex; + boolean resetSeqo = packet.buffer.getCommand() == SSH_MSG_NEWKEYS && doStrictKex; + synchronized (lock) { encode(packet); if (io != null) { io.put(packet); - seqo++; + if (++seqo == 0 && (enable_strict_kex || require_strict_kex) && initialKex) { + throw new JSchStrictKexException("outgoing sequence number wrapped during initial KEX"); + } + if (resetSeqo) { + seqo = 0; + } } } + + if (resetSeqo && io != null && getLogger().isEnabled(Logger.INFO)) { + getLogger().log(Logger.INFO, + "Reset outgoing sequence number after sending SSH_MSG_NEWKEYS for strict KEX"); + } } Runnable thread; @@ -2010,6 +2089,8 @@ public void disconnect() { // for the first packet during (re)connect. seqi = 0; seqo = 0; + initialKex = true; + doStrictKex = false; // synchronized(jsch.pool){ // jsch.pool.removeElement(this); @@ -3067,6 +3148,8 @@ private void applyConfig() throws JSchException { checkConfig(config, "kex"); checkConfig(config, "server_host_key"); checkConfig(config, "prefer_known_host_key_types"); + checkConfig(config, "enable_strict_kex"); + checkConfig(config, "require_strict_kex"); checkConfig(config, "enable_pubkey_auth_query"); checkConfig(config, "try_additional_pubkey_algorithms"); checkConfig(config, "enable_auth_none"); diff --git a/src/test/java/com/jcraft/jsch/JSchAlgoNegoFailExceptionIT.java b/src/test/java/com/jcraft/jsch/JSchAlgoNegoFailExceptionIT.java index e26ab53b..5bb4ec66 100644 --- a/src/test/java/com/jcraft/jsch/JSchAlgoNegoFailExceptionIT.java +++ b/src/test/java/com/jcraft/jsch/JSchAlgoNegoFailExceptionIT.java @@ -61,7 +61,7 @@ public void testJSchAlgoNegoFailException(String algorithmName, String serverPro JSchAlgoNegoFailException e = assertThrows(JSchAlgoNegoFailException.class, session::connect); if (algorithmName.equals("kex")) { - jschProposal += ",ext-info-c"; + jschProposal += ",ext-info-c,kex-strict-c-v00@openssh.com"; } String message = String.format(Locale.ROOT, "Algorithm negotiation fail: algorithmName=\"%s\" jschProposal=\"%s\" serverProposal=\"%s\"", diff --git a/src/test/java/com/jcraft/jsch/JSchStrictKexExceptionIT.java b/src/test/java/com/jcraft/jsch/JSchStrictKexExceptionIT.java new file mode 100644 index 00000000..e8a7fef6 --- /dev/null +++ b/src/test/java/com/jcraft/jsch/JSchStrictKexExceptionIT.java @@ -0,0 +1,91 @@ +package com.jcraft.jsch; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Base64; +import java.util.List; +import java.util.Locale; +import org.junit.jupiter.api.Test; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.images.builder.ImageFromDockerfile; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; + +@Testcontainers +public class JSchStrictKexExceptionIT { + + private static final int timeout = 2000; + + @Container + public GenericContainer sshd = new GenericContainer<>( + new ImageFromDockerfile().withFileFromClasspath("ssh_host_rsa_key", "docker/ssh_host_rsa_key") + .withFileFromClasspath("ssh_host_rsa_key.pub", "docker/ssh_host_rsa_key.pub") + .withFileFromClasspath("ssh_host_ecdsa256_key", "docker/ssh_host_ecdsa256_key") + .withFileFromClasspath("ssh_host_ecdsa256_key.pub", "docker/ssh_host_ecdsa256_key.pub") + .withFileFromClasspath("ssh_host_ecdsa384_key", "docker/ssh_host_ecdsa384_key") + .withFileFromClasspath("ssh_host_ecdsa384_key.pub", "docker/ssh_host_ecdsa384_key.pub") + .withFileFromClasspath("ssh_host_ecdsa521_key", "docker/ssh_host_ecdsa521_key") + .withFileFromClasspath("ssh_host_ecdsa521_key.pub", "docker/ssh_host_ecdsa521_key.pub") + .withFileFromClasspath("ssh_host_ed25519_key", "docker/ssh_host_ed25519_key") + .withFileFromClasspath("ssh_host_ed25519_key.pub", "docker/ssh_host_ed25519_key.pub") + .withFileFromClasspath("ssh_host_dsa_key", "docker/ssh_host_dsa_key") + .withFileFromClasspath("ssh_host_dsa_key.pub", "docker/ssh_host_dsa_key.pub") + .withFileFromClasspath("sshd_config", "docker/sshd_config") + .withFileFromClasspath("authorized_keys", "docker/authorized_keys") + .withFileFromClasspath("Dockerfile", "docker/Dockerfile")) + .withExposedPorts(22); + + @Test + public void testEnableStrictKexRequireStrictKex() throws Exception { + JSch ssh = createRSAIdentity(); + Session session = createSession(ssh); + session.setConfig("enable_strict_kex", "yes"); + session.setConfig("require_strict_kex", "yes"); + session.setTimeout(timeout); + + assertThrows(JSchStrictKexException.class, session::connect, + "Strict KEX not supported by server"); + } + + @Test + public void testNoEnableStrictKexRequireStrictKex() throws Exception { + JSch ssh = createRSAIdentity(); + Session session = createSession(ssh); + session.setConfig("enable_strict_kex", "no"); + session.setConfig("require_strict_kex", "yes"); + session.setTimeout(timeout); + + assertThrows(JSchStrictKexException.class, session::connect, + "Strict KEX not supported by server"); + } + + private JSch createRSAIdentity() throws Exception { + HostKey hostKey = readHostKey(getResourceFile("docker/ssh_host_rsa_key.pub")); + JSch ssh = new JSch(); + ssh.addIdentity(getResourceFile("docker/id_rsa"), getResourceFile("docker/id_rsa.pub"), null); + ssh.getHostKeyRepository().add(hostKey, null); + return ssh; + } + + private HostKey readHostKey(String fileName) throws Exception { + List lines = Files.readAllLines(Paths.get(fileName), UTF_8); + String[] split = lines.get(0).split("\\s+"); + String hostname = + String.format(Locale.ROOT, "[%s]:%d", sshd.getHost(), sshd.getFirstMappedPort()); + return new HostKey(hostname, Base64.getDecoder().decode(split[1])); + } + + private Session createSession(JSch ssh) throws Exception { + Session session = ssh.getSession("root", sshd.getHost(), sshd.getFirstMappedPort()); + session.setConfig("StrictHostKeyChecking", "yes"); + session.setConfig("PreferredAuthentications", "publickey"); + return session; + } + + private String getResourceFile(String fileName) { + return ResourceUtil.getResourceFile(getClass(), fileName); + } +} From 23745477ab8b9558fe8a44d139d4e60608fc2343 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Mon, 18 Dec 2023 15:01:58 -0600 Subject: [PATCH 148/301] Revert ee39336 since it doesn't seem to work with Github's CI runner. --- .github/workflows/maven.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index b67de70d..382f52d1 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -34,7 +34,7 @@ jobs: java-version: '21' check-latest: true - name: Build with Maven - run: ./mvnw -B -V -e -DskipTests=true verify + run: ./mvnw -B -V -e -DskipTests=true package - uses: actions/upload-artifact@v3 with: name: java-${{ matrix.java }}-jars @@ -48,10 +48,8 @@ jobs: distribution: 'zulu' java-version: ${{ matrix.java }} check-latest: true - - name: Unit Tests with Maven - run: ./mvnw -B -V -e jacoco:prepare-agent surefire:test jacoco:report - - name: Integration Tests with Maven - run: ./mvnw -B -V -e -DskipITs=false jacoco:prepare-agent-integration failsafe:integration-test failsafe:verify jacoco:report-integration + - name: Test with Maven + run: ./mvnw -B -V -e -P coverage verify -Denforcer.skip=true -Dmaven.resources.skip=true -Dmaven.main.skip=true -Dassembly.skipAssembly=true -Dmaven.javadoc.skip=true -DskipITs=false - uses: actions/upload-artifact@v3 with: name: java-${{ matrix.java }}-testresults From 6b6dc312db4c77c1fa27157929ecd96891475050 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Tue, 19 Dec 2023 04:33:25 -0600 Subject: [PATCH 149/301] #457 add integration tests for new strict key exchange extension. --- .../java/com/jcraft/jsch/StrictKexIT.java | 270 ++++++++++++++++++ .../resources/docker/Dockerfile.openssh96 | 23 ++ .../resources/docker/sshd_config.openssh96 | 21 ++ 3 files changed, 314 insertions(+) create mode 100644 src/test/java/com/jcraft/jsch/StrictKexIT.java create mode 100644 src/test/resources/docker/Dockerfile.openssh96 create mode 100644 src/test/resources/docker/sshd_config.openssh96 diff --git a/src/test/java/com/jcraft/jsch/StrictKexIT.java b/src/test/java/com/jcraft/jsch/StrictKexIT.java new file mode 100644 index 00000000..a16f4974 --- /dev/null +++ b/src/test/java/com/jcraft/jsch/StrictKexIT.java @@ -0,0 +1,270 @@ +package com.jcraft.jsch; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import com.github.valfirst.slf4jtest.LoggingEvent; +import com.github.valfirst.slf4jtest.TestLogger; +import com.github.valfirst.slf4jtest.TestLoggerFactory; +import java.io.IOException; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Base64; +import java.util.List; +import java.util.Locale; +import java.util.Optional; +import java.util.Random; +import org.apache.commons.codec.digest.DigestUtils; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.output.Slf4jLogConsumer; +import org.testcontainers.images.builder.ImageFromDockerfile; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; + +@Testcontainers +public class StrictKexIT { + + private static final int timeout = 2000; + private static final DigestUtils sha256sum = new DigestUtils(DigestUtils.getSha256Digest()); + private static final TestLogger jschLogger = TestLoggerFactory.getTestLogger(JSch.class); + private static final TestLogger sshdLogger = + TestLoggerFactory.getTestLogger(ServerSigAlgsIT.class); + + @TempDir + public Path tmpDir; + private Path in; + private Path out; + private String hash; + private Slf4jLogConsumer sshdLogConsumer; + + @Container + public GenericContainer sshd = new GenericContainer<>( + new ImageFromDockerfile().withFileFromClasspath("ssh_host_rsa_key", "docker/ssh_host_rsa_key") + .withFileFromClasspath("ssh_host_rsa_key.pub", "docker/ssh_host_rsa_key.pub") + .withFileFromClasspath("ssh_host_ecdsa256_key", "docker/ssh_host_ecdsa256_key") + .withFileFromClasspath("ssh_host_ecdsa256_key.pub", "docker/ssh_host_ecdsa256_key.pub") + .withFileFromClasspath("ssh_host_ecdsa384_key", "docker/ssh_host_ecdsa384_key") + .withFileFromClasspath("ssh_host_ecdsa384_key.pub", "docker/ssh_host_ecdsa384_key.pub") + .withFileFromClasspath("ssh_host_ecdsa521_key", "docker/ssh_host_ecdsa521_key") + .withFileFromClasspath("ssh_host_ecdsa521_key.pub", "docker/ssh_host_ecdsa521_key.pub") + .withFileFromClasspath("ssh_host_ed25519_key", "docker/ssh_host_ed25519_key") + .withFileFromClasspath("ssh_host_ed25519_key.pub", "docker/ssh_host_ed25519_key.pub") + .withFileFromClasspath("ssh_host_dsa_key", "docker/ssh_host_dsa_key") + .withFileFromClasspath("ssh_host_dsa_key.pub", "docker/ssh_host_dsa_key.pub") + .withFileFromClasspath("sshd_config", "docker/sshd_config.openssh96") + .withFileFromClasspath("authorized_keys", "docker/authorized_keys") + .withFileFromClasspath("Dockerfile", "docker/Dockerfile.openssh96")) + .withExposedPorts(22); + + @BeforeAll + public static void beforeAll() { + JSch.setLogger(new Slf4jLogger()); + } + + @BeforeEach + public void beforeEach() throws IOException { + if (sshdLogConsumer == null) { + sshdLogConsumer = new Slf4jLogConsumer(sshdLogger); + sshd.followOutput(sshdLogConsumer); + } + + in = tmpDir.resolve("in"); + out = tmpDir.resolve("out"); + Files.createFile(in); + try (OutputStream os = Files.newOutputStream(in)) { + byte[] data = new byte[1024]; + for (int i = 0; i < 1024 * 100; i += 1024) { + new Random().nextBytes(data); + os.write(data); + } + } + hash = sha256sum.digestAsHex(in); + + jschLogger.clearAll(); + sshdLogger.clearAll(); + } + + @AfterAll + public static void afterAll() { + JSch.setLogger(null); + jschLogger.clearAll(); + sshdLogger.clearAll(); + } + + @Test + public void testEnableStrictKexNoRequireStrictKex() throws Exception { + JSch ssh = createRSAIdentity(); + Session session = createSession(ssh); + session.setConfig("enable_strict_kex", "yes"); + session.setConfig("require_strict_kex", "no"); + doSftp(session, true); + + String expectedServerKex = "server proposal: KEX algorithms: .*,kex-strict-s-v00@openssh.com"; + String expectedClientKex = "client proposal: KEX algorithms: .*,kex-strict-c-v00@openssh.com"; + String expected1 = "Doing strict KEX"; + String expected2 = + "Reset outgoing sequence number after sending SSH_MSG_NEWKEYS for strict KEX"; + String expected3 = + "Reset incoming sequence number after receiving SSH_MSG_NEWKEYS for strict KEX"; + checkLogs(expectedServerKex); + checkLogs(expectedClientKex); + checkLogs(expected1); + checkLogs(expected2); + checkLogs(expected3); + } + + @Test + public void testEnableStrictKexRequireStrictKex() throws Exception { + JSch ssh = createRSAIdentity(); + Session session = createSession(ssh); + session.setConfig("enable_strict_kex", "yes"); + session.setConfig("require_strict_kex", "yes"); + doSftp(session, true); + + String expectedServerKex = "server proposal: KEX algorithms: .*,kex-strict-s-v00@openssh.com"; + String expectedClientKex = "client proposal: KEX algorithms: .*,kex-strict-c-v00@openssh.com"; + String expected1 = "Doing strict KEX"; + String expected2 = + "Reset outgoing sequence number after sending SSH_MSG_NEWKEYS for strict KEX"; + String expected3 = + "Reset incoming sequence number after receiving SSH_MSG_NEWKEYS for strict KEX"; + checkLogs(expectedServerKex); + checkLogs(expectedClientKex); + checkLogs(expected1); + checkLogs(expected2); + checkLogs(expected3); + } + + @Test + public void testNoEnableStrictKexRequireStrictKex() throws Exception { + JSch ssh = createRSAIdentity(); + Session session = createSession(ssh); + session.setConfig("enable_strict_kex", "no"); + session.setConfig("require_strict_kex", "yes"); + doSftp(session, true); + + String expectedServerKex = "server proposal: KEX algorithms: .*,kex-strict-s-v00@openssh.com"; + String expectedClientKex = "client proposal: KEX algorithms: .*,kex-strict-c-v00@openssh.com"; + String expected1 = "Doing strict KEX"; + String expected2 = + "Reset outgoing sequence number after sending SSH_MSG_NEWKEYS for strict KEX"; + String expected3 = + "Reset incoming sequence number after receiving SSH_MSG_NEWKEYS for strict KEX"; + checkLogs(expectedServerKex); + checkLogs(expectedClientKex); + checkLogs(expected1); + checkLogs(expected2); + checkLogs(expected3); + } + + @Test + public void testNoEnableStrictKexNoRequireStrictKex() throws Exception { + JSch ssh = createRSAIdentity(); + Session session = createSession(ssh); + session.setConfig("enable_strict_kex", "no"); + session.setConfig("require_strict_kex", "no"); + doSftp(session, true); + + String expectedServerKex = "server proposal: KEX algorithms: .*,kex-strict-s-v00@openssh.com"; + String expectedClientKex = "client proposal: KEX algorithms: .*,kex-strict-c-v00@openssh.com"; + String expected1 = "Doing strict KEX"; + String expected2 = + "Reset outgoing sequence number after sending SSH_MSG_NEWKEYS for strict KEX"; + String expected3 = + "Reset incoming sequence number after receiving SSH_MSG_NEWKEYS for strict KEX"; + checkLogs(expectedServerKex); + checkNoLogs(expectedClientKex); + checkNoLogs(expected1); + checkNoLogs(expected2); + checkNoLogs(expected3); + } + + private JSch createRSAIdentity() throws Exception { + HostKey hostKey = readHostKey(getResourceFile("docker/ssh_host_rsa_key.pub")); + JSch ssh = new JSch(); + ssh.addIdentity(getResourceFile("docker/id_rsa"), getResourceFile("docker/id_rsa.pub"), null); + ssh.getHostKeyRepository().add(hostKey, null); + return ssh; + } + + private HostKey readHostKey(String fileName) throws Exception { + List lines = Files.readAllLines(Paths.get(fileName), UTF_8); + String[] split = lines.get(0).split("\\s+"); + String hostname = + String.format(Locale.ROOT, "[%s]:%d", sshd.getHost(), sshd.getFirstMappedPort()); + return new HostKey(hostname, Base64.getDecoder().decode(split[1])); + } + + private Session createSession(JSch ssh) throws Exception { + Session session = ssh.getSession("root", sshd.getHost(), sshd.getFirstMappedPort()); + session.setConfig("StrictHostKeyChecking", "yes"); + session.setConfig("PreferredAuthentications", "publickey"); + return session; + } + + private void doSftp(Session session, boolean debugException) throws Exception { + try { + session.setTimeout(timeout); + session.connect(); + ChannelSftp sftp = (ChannelSftp) session.openChannel("sftp"); + sftp.connect(timeout); + sftp.put(in.toString(), "/root/test"); + sftp.get("/root/test", out.toString()); + sftp.disconnect(); + session.disconnect(); + } catch (Exception e) { + if (debugException) { + printInfo(); + } + throw e; + } + + assertEquals(1024L * 100L, Files.size(out)); + assertEquals(hash, sha256sum.digestAsHex(out)); + } + + private void printInfo() { + jschLogger.getAllLoggingEvents().stream().map(LoggingEvent::getFormattedMessage) + .forEach(System.out::println); + sshdLogger.getAllLoggingEvents().stream().map(LoggingEvent::getFormattedMessage) + .forEach(System.out::println); + System.out.println(""); + System.out.println(""); + System.out.println(""); + } + + private void checkLogs(String expected) { + Optional actualJsch = jschLogger.getAllLoggingEvents().stream() + .map(LoggingEvent::getFormattedMessage).filter(msg -> msg.matches(expected)).findFirst(); + try { + assertTrue(actualJsch.isPresent(), () -> "JSch: " + expected); + } catch (AssertionError e) { + printInfo(); + throw e; + } + } + + private void checkNoLogs(String expected) { + Optional actualJsch = jschLogger.getAllLoggingEvents().stream() + .map(LoggingEvent::getFormattedMessage).filter(msg -> msg.matches(expected)).findFirst(); + try { + assertFalse(actualJsch.isPresent(), () -> "JSch: " + expected); + } catch (AssertionError e) { + printInfo(); + throw e; + } + } + + private String getResourceFile(String fileName) { + return ResourceUtil.getResourceFile(getClass(), fileName); + } +} diff --git a/src/test/resources/docker/Dockerfile.openssh96 b/src/test/resources/docker/Dockerfile.openssh96 new file mode 100644 index 00000000..474c9282 --- /dev/null +++ b/src/test/resources/docker/Dockerfile.openssh96 @@ -0,0 +1,23 @@ +FROM alpine:3.19 +RUN apk update && \ + apk upgrade && \ + apk add openssh && \ + rm /var/cache/apk/* && \ + mkdir /root/.ssh && \ + chmod 700 /root/.ssh +COPY ssh_host_rsa_key /etc/ssh/ +COPY ssh_host_rsa_key.pub /etc/ssh/ +COPY ssh_host_ecdsa256_key /etc/ssh/ +COPY ssh_host_ecdsa256_key.pub /etc/ssh/ +COPY ssh_host_ecdsa384_key /etc/ssh/ +COPY ssh_host_ecdsa384_key.pub /etc/ssh/ +COPY ssh_host_ecdsa521_key /etc/ssh/ +COPY ssh_host_ecdsa521_key.pub /etc/ssh/ +COPY ssh_host_ed25519_key /etc/ssh/ +COPY ssh_host_ed25519_key.pub /etc/ssh/ +COPY ssh_host_dsa_key /etc/ssh/ +COPY ssh_host_dsa_key.pub /etc/ssh/ +COPY sshd_config /etc/ssh/ +COPY authorized_keys /root/.ssh/ +RUN chmod 600 /etc/ssh/ssh_*_key /root/.ssh/authorized_keys +ENTRYPOINT ["/usr/sbin/sshd", "-D", "-e"] diff --git a/src/test/resources/docker/sshd_config.openssh96 b/src/test/resources/docker/sshd_config.openssh96 new file mode 100644 index 00000000..8d7bcba1 --- /dev/null +++ b/src/test/resources/docker/sshd_config.openssh96 @@ -0,0 +1,21 @@ +ChallengeResponseAuthentication no +HostbasedAuthentication no +PasswordAuthentication no +PubkeyAuthentication yes +AuthenticationMethods publickey +PubkeyAcceptedAlgorithms ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss +UseDNS no +PrintMotd no +PermitRootLogin yes +Subsystem sftp internal-sftp +HostKey /etc/ssh/ssh_host_ecdsa256_key +HostKey /etc/ssh/ssh_host_ecdsa384_key +HostKey /etc/ssh/ssh_host_ecdsa521_key +HostKey /etc/ssh/ssh_host_ed25519_key +HostKey /etc/ssh/ssh_host_rsa_key +HostKey /etc/ssh/ssh_host_dsa_key +KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group18-sha512,diffie-hellman-group16-sha512,diffie-hellman-group14-sha256,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 +HostKeyAlgorithms ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss +Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc +MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,hmac-sha1,hmac-sha1-96-etm@openssh.com,hmac-sha1-96,hmac-md5-etm@openssh.com,hmac-md5,hmac-md5-96-etm@openssh.com,hmac-md5-96 +LogLevel DEBUG3 From 646f62277a3caff7752276bccd33b511c8c58837 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Tue, 19 Dec 2023 05:46:26 -0600 Subject: [PATCH 150/301] Add support for `ext-info-in-auth@openssh.com` extension. --- src/main/java/com/jcraft/jsch/JSch.java | 2 + src/main/java/com/jcraft/jsch/Session.java | 91 +++++-- .../java/com/jcraft/jsch/ExtInfoInAuthIT.java | 234 ++++++++++++++++++ .../docker/Dockerfile.ExtInfoInAuthIT | 36 +++ .../docker/sshd_config.ExtInfoInAuthIT | 25 ++ 5 files changed, 368 insertions(+), 20 deletions(-) create mode 100644 src/test/java/com/jcraft/jsch/ExtInfoInAuthIT.java create mode 100644 src/test/resources/docker/Dockerfile.ExtInfoInAuthIT create mode 100644 src/test/resources/docker/sshd_config.ExtInfoInAuthIT diff --git a/src/main/java/com/jcraft/jsch/JSch.java b/src/main/java/com/jcraft/jsch/JSch.java index ae754305..0c86f25c 100644 --- a/src/main/java/com/jcraft/jsch/JSch.java +++ b/src/main/java/com/jcraft/jsch/JSch.java @@ -49,6 +49,8 @@ public class JSch { config.put("require_strict_kex", Util.getSystemProperty("jsch.require_strict_kex", "no")); config.put("enable_server_sig_algs", Util.getSystemProperty("jsch.enable_server_sig_algs", "yes")); + config.put("enable_ext_info_in_auth", + Util.getSystemProperty("jsch.enable_ext_info_in_auth", "yes")); config.put("cipher.s2c", Util.getSystemProperty("jsch.cipher", "aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com")); config.put("cipher.c2s", Util.getSystemProperty("jsch.cipher", diff --git a/src/main/java/com/jcraft/jsch/Session.java b/src/main/java/com/jcraft/jsch/Session.java index ede905e5..57302763 100644 --- a/src/main/java/com/jcraft/jsch/Session.java +++ b/src/main/java/com/jcraft/jsch/Session.java @@ -117,6 +117,10 @@ public class Session { private volatile boolean isConnected = false; + private volatile boolean doExtInfo = false; + private boolean enable_server_sig_algs = true; + private boolean enable_ext_info_in_auth = true; + private volatile boolean initialKex = true; private volatile boolean doStrictKex = false; private boolean enable_strict_kex = true; @@ -314,6 +318,8 @@ public void connect(int connectTimeout) throws JSchException { getLogger().log(Logger.INFO, "Local version string: " + Util.byte2str(V_C)); } + enable_server_sig_algs = getConfig("enable_server_sig_algs").equals("yes"); + enable_ext_info_in_auth = getConfig("enable_ext_info_in_auth").equals("yes"); enable_strict_kex = getConfig("enable_strict_kex").equals("yes"); require_strict_kex = getConfig("require_strict_kex").equals("yes"); send_kexinit(); @@ -376,7 +382,11 @@ public void connect(int connectTimeout) throws JSchException { initialKex = false; } else { in_kex = false; - throw new JSchException("invalid protocol(newkyes): " + buf.getCommand()); + throw new JSchException("invalid protocol(newkeys): " + buf.getCommand()); + } + + if (enable_server_sig_algs && enable_ext_info_in_auth && doExtInfo) { + send_extinfo(); } try { @@ -574,18 +584,27 @@ private KeyExchange receive_kexinit(Buffer buf) throws Exception { } System.arraycopy(buf.buffer, buf.s, I_S, 0, I_S.length); - if ((enable_strict_kex || require_strict_kex) && initialKex) { - doStrictKex = checkServerStrictKex(); - if (doStrictKex) { - if (getLogger().isEnabled(Logger.INFO)) { - getLogger().log(Logger.INFO, "Doing strict KEX"); + if (initialKex) { + if (enable_strict_kex || require_strict_kex) { + doStrictKex = checkServerStrictKex(); + if (doStrictKex) { + if (getLogger().isEnabled(Logger.INFO)) { + getLogger().log(Logger.INFO, "Doing strict KEX"); + } + + if (seqi != 1) { + throw new JSchStrictKexException("KEXINIT not first packet from server"); + } + } else if (require_strict_kex) { + throw new JSchStrictKexException("Strict KEX not supported by server"); } + } - if (seqi != 1) { - throw new JSchStrictKexException("KEXINIT not first packet from server"); + if (enable_server_sig_algs) { + doExtInfo = checkServerExtInfo(); + if (getLogger().isEnabled(Logger.INFO)) { + getLogger().log(Logger.INFO, "ext-info messaging supported by server"); } - } else if (require_strict_kex) { - throw new JSchStrictKexException("Strict KEX not supported by server"); } } @@ -643,6 +662,28 @@ private boolean checkServerStrictKex() { return false; } + private boolean checkServerExtInfo() { + Buffer sb = new Buffer(I_S); + sb.setOffSet(17); + byte[] sp = sb.getString(); // server proposal + + int l = 0; + int m = 0; + while (l < sp.length) { + while (l < sp.length && sp[l] != ',') + l++; + if (m == l) + continue; + if ("ext-info-s".equals(Util.byte2str(sp, m, l - m))) { + return true; + } + l++; + m = l; + } + + return false; + } + private volatile boolean in_kex = false; private volatile boolean in_prompt = false; private volatile String[] not_available_shks = null; @@ -726,8 +767,7 @@ private void send_kexinit() throws Exception { } } - String enable_server_sig_algs = getConfig("enable_server_sig_algs"); - if (enable_server_sig_algs.equals("yes") && !isAuthed) { + if (enable_server_sig_algs && !isAuthed) { kex += ",ext-info-c"; } @@ -862,6 +902,20 @@ private void send_newkeys() throws Exception { } } + private void send_extinfo() throws Exception { + // send SSH_MSG_EXT_INFO(7) + packet.reset(); + buf.putByte((byte) SSH_MSG_EXT_INFO); + buf.putInt(1); + buf.putString(Util.str2byte("ext-info-in-auth@openssh.com")); + buf.putString(Util.str2byte("0")); + write(packet); + + if (getLogger().isEnabled(Logger.INFO)) { + getLogger().log(Logger.INFO, "SSH_MSG_EXT_INFO sent"); + } + } + private void checkHost(String chost, int port, KeyExchange kex) throws JSchException { String shkc = getConfig("StrictHostKeyChecking"); @@ -1298,8 +1352,7 @@ Buffer read(Buffer buf) throws Exception { buf.getInt(); buf.getShort(); boolean ignore = false; - String enable_server_sig_algs = getConfig("enable_server_sig_algs"); - if (!enable_server_sig_algs.equals("yes")) { + if (!enable_server_sig_algs) { ignore = true; if (getLogger().isEnabled(Logger.INFO)) { getLogger().log(Logger.INFO, @@ -2091,6 +2144,8 @@ public void disconnect() { seqo = 0; initialKex = true; doStrictKex = false; + doExtInfo = false; + serverSigAlgs = null; // synchronized(jsch.pool){ // jsch.pool.removeElement(this); @@ -2713,9 +2768,6 @@ public void setConfig(Hashtable newconf) { String key = (newkey.equals("PubkeyAcceptedKeyTypes") ? "PubkeyAcceptedAlgorithms" : newkey); String value = newconf.get(newkey); - if (key.equals("enable_server_sig_algs") && !value.equals("yes")) { - serverSigAlgs = null; - } config.put(key, value); } } @@ -2729,9 +2781,6 @@ public void setConfig(String key, String value) { if (key.equals("PubkeyAcceptedKeyTypes")) { config.put("PubkeyAcceptedAlgorithms", value); } else { - if (key.equals("enable_server_sig_algs") && !value.equals("yes")) { - serverSigAlgs = null; - } config.put(key, value); } } @@ -3148,6 +3197,8 @@ private void applyConfig() throws JSchException { checkConfig(config, "kex"); checkConfig(config, "server_host_key"); checkConfig(config, "prefer_known_host_key_types"); + checkConfig(config, "enable_server_sig_algs"); + checkConfig(config, "enable_ext_info_in_auth"); checkConfig(config, "enable_strict_kex"); checkConfig(config, "require_strict_kex"); checkConfig(config, "enable_pubkey_auth_query"); diff --git a/src/test/java/com/jcraft/jsch/ExtInfoInAuthIT.java b/src/test/java/com/jcraft/jsch/ExtInfoInAuthIT.java new file mode 100644 index 00000000..fb58e2c0 --- /dev/null +++ b/src/test/java/com/jcraft/jsch/ExtInfoInAuthIT.java @@ -0,0 +1,234 @@ +package com.jcraft.jsch; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import com.github.valfirst.slf4jtest.LoggingEvent; +import com.github.valfirst.slf4jtest.TestLogger; +import com.github.valfirst.slf4jtest.TestLoggerFactory; +import java.io.IOException; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Base64; +import java.util.List; +import java.util.Locale; +import java.util.Optional; +import java.util.Random; +import org.apache.commons.codec.digest.DigestUtils; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.output.Slf4jLogConsumer; +import org.testcontainers.images.builder.ImageFromDockerfile; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; + +@Testcontainers +public class ExtInfoInAuthIT { + + private static final int timeout = 2000; + private static final DigestUtils sha256sum = new DigestUtils(DigestUtils.getSha256Digest()); + private static final TestLogger jschLogger = TestLoggerFactory.getTestLogger(JSch.class); + private static final TestLogger sshdLogger = + TestLoggerFactory.getTestLogger(ServerSigAlgsIT.class); + + @TempDir + public Path tmpDir; + private Path in; + private Path out; + private String hash; + private Slf4jLogConsumer sshdLogConsumer; + + @Container + public GenericContainer sshd = new GenericContainer<>( + new ImageFromDockerfile().withFileFromClasspath("ssh_host_rsa_key", "docker/ssh_host_rsa_key") + .withFileFromClasspath("ssh_host_rsa_key.pub", "docker/ssh_host_rsa_key.pub") + .withFileFromClasspath("ssh_host_ecdsa256_key", "docker/ssh_host_ecdsa256_key") + .withFileFromClasspath("ssh_host_ecdsa256_key.pub", "docker/ssh_host_ecdsa256_key.pub") + .withFileFromClasspath("ssh_host_ecdsa384_key", "docker/ssh_host_ecdsa384_key") + .withFileFromClasspath("ssh_host_ecdsa384_key.pub", "docker/ssh_host_ecdsa384_key.pub") + .withFileFromClasspath("ssh_host_ecdsa521_key", "docker/ssh_host_ecdsa521_key") + .withFileFromClasspath("ssh_host_ecdsa521_key.pub", "docker/ssh_host_ecdsa521_key.pub") + .withFileFromClasspath("ssh_host_ed25519_key", "docker/ssh_host_ed25519_key") + .withFileFromClasspath("ssh_host_ed25519_key.pub", "docker/ssh_host_ed25519_key.pub") + .withFileFromClasspath("ssh_host_dsa_key", "docker/ssh_host_dsa_key") + .withFileFromClasspath("ssh_host_dsa_key.pub", "docker/ssh_host_dsa_key.pub") + .withFileFromClasspath("sshd_config", "docker/sshd_config.ExtInfoInAuthIT") + .withFileFromClasspath("authorized_keys", "docker/authorized_keys") + .withFileFromClasspath("Dockerfile", "docker/Dockerfile.ExtInfoInAuthIT")) + .withExposedPorts(22); + + @BeforeAll + public static void beforeAll() { + JSch.setLogger(new Slf4jLogger()); + } + + @BeforeEach + public void beforeEach() throws IOException { + if (sshdLogConsumer == null) { + sshdLogConsumer = new Slf4jLogConsumer(sshdLogger); + sshd.followOutput(sshdLogConsumer); + } + + in = tmpDir.resolve("in"); + out = tmpDir.resolve("out"); + Files.createFile(in); + try (OutputStream os = Files.newOutputStream(in)) { + byte[] data = new byte[1024]; + for (int i = 0; i < 1024 * 100; i += 1024) { + new Random().nextBytes(data); + os.write(data); + } + } + hash = sha256sum.digestAsHex(in); + + jschLogger.clearAll(); + sshdLogger.clearAll(); + } + + @AfterAll + public static void afterAll() { + JSch.setLogger(null); + jschLogger.clearAll(); + sshdLogger.clearAll(); + } + + @Test + public void testExtInfoInAuthYes() throws Exception { + JSch ssh = createRSAIdentity(); + Session session = createSession(ssh, "rsa"); + session.setConfig("enable_ext_info_in_auth", "yes"); + session.setConfig("PubkeyAcceptedAlgorithms", "ssh-rsa"); + doSftp(session, "rsa", true); + + String expectedServerKex = "server proposal: KEX algorithms: .*,ext-info-s,.*"; + String expectedClientKex = "client proposal: KEX algorithms: .*,ext-info-c,.*"; + String expected1 = "ext-info messaging supported by server"; + String expected2 = "SSH_MSG_EXT_INFO sent"; + String expectedServerSigAlgs1 = "server-sig-algs="; + String expectedServerSigAlgs2 = "server-sig-algs=<.*ssh-rsa.*>"; + String expectedServerSigAlgs3 = "server-sig-algs=<.*ecdsa.*>"; + checkLogs(expectedServerKex); + checkLogs(expectedClientKex); + checkLogs(expected1); + checkLogs(expected2); + checkLogs(expectedServerSigAlgs1); + checkLogs(expectedServerSigAlgs2); + checkNoLogs(expectedServerSigAlgs3); + } + + @Test + public void testExtInfoInAuthNo() throws Exception { + JSch ssh = createRSAIdentity(); + Session session = createSession(ssh, "ecdsa"); + session.setConfig("enable_ext_info_in_auth", "no"); + session.setConfig("PubkeyAcceptedAlgorithms", "ssh-rsa"); + session.setTimeout(timeout); + + assertThrows(JSchException.class, session::connect, "Auth fail for methods 'publickey'"); + + String expectedServerKex = "server proposal: KEX algorithms: .*,ext-info-s,.*"; + String expectedClientKex = "client proposal: KEX algorithms: .*,ext-info-c,.*"; + String expected1 = "ext-info messaging supported by server"; + String expected2 = "SSH_MSG_EXT_INFO sent"; + String expectedServerSigAlgs1 = "server-sig-algs="; + String expectedServerSigAlgs2 = "server-sig-algs=<.*ssh-rsa.*>"; + String expectedServerSigAlgs3 = "server-sig-algs=<.*ecdsa.*>"; + checkLogs(expectedServerKex); + checkLogs(expectedClientKex); + checkLogs(expected1); + checkNoLogs(expected2); + checkLogs(expectedServerSigAlgs1); + checkNoLogs(expectedServerSigAlgs2); + checkNoLogs(expectedServerSigAlgs3); + } + + private JSch createRSAIdentity() throws Exception { + HostKey hostKey = readHostKey(getResourceFile("docker/ssh_host_rsa_key.pub")); + JSch ssh = new JSch(); + ssh.addIdentity(getResourceFile("docker/id_rsa"), getResourceFile("docker/id_rsa.pub"), null); + ssh.getHostKeyRepository().add(hostKey, null); + return ssh; + } + + private HostKey readHostKey(String fileName) throws Exception { + List lines = Files.readAllLines(Paths.get(fileName), UTF_8); + String[] split = lines.get(0).split("\\s+"); + String hostname = + String.format(Locale.ROOT, "[%s]:%d", sshd.getHost(), sshd.getFirstMappedPort()); + return new HostKey(hostname, Base64.getDecoder().decode(split[1])); + } + + private Session createSession(JSch ssh, String username) throws Exception { + Session session = ssh.getSession(username, sshd.getHost(), sshd.getFirstMappedPort()); + session.setConfig("StrictHostKeyChecking", "yes"); + session.setConfig("PreferredAuthentications", "publickey"); + return session; + } + + private void doSftp(Session session, String username, boolean debugException) throws Exception { + String testFile = String.format(Locale.ROOT, "/%s/test", username); + try { + session.setTimeout(timeout); + session.connect(); + ChannelSftp sftp = (ChannelSftp) session.openChannel("sftp"); + sftp.connect(timeout); + sftp.put(in.toString(), testFile); + sftp.get(testFile, out.toString()); + sftp.disconnect(); + session.disconnect(); + } catch (Exception e) { + if (debugException) { + printInfo(); + } + throw e; + } + + assertEquals(1024L * 100L, Files.size(out)); + assertEquals(hash, sha256sum.digestAsHex(out)); + } + + private void printInfo() { + jschLogger.getAllLoggingEvents().stream().map(LoggingEvent::getFormattedMessage) + .forEach(System.out::println); + sshdLogger.getAllLoggingEvents().stream().map(LoggingEvent::getFormattedMessage) + .forEach(System.out::println); + System.out.println(""); + System.out.println(""); + System.out.println(""); + } + + private void checkLogs(String expected) { + Optional actualJsch = jschLogger.getAllLoggingEvents().stream() + .map(LoggingEvent::getFormattedMessage).filter(msg -> msg.matches(expected)).findFirst(); + try { + assertTrue(actualJsch.isPresent(), () -> "JSch: " + expected); + } catch (AssertionError e) { + printInfo(); + throw e; + } + } + + private void checkNoLogs(String expected) { + Optional actualJsch = jschLogger.getAllLoggingEvents().stream() + .map(LoggingEvent::getFormattedMessage).filter(msg -> msg.matches(expected)).findFirst(); + try { + assertFalse(actualJsch.isPresent(), () -> "JSch: " + expected); + } catch (AssertionError e) { + printInfo(); + throw e; + } + } + + private String getResourceFile(String fileName) { + return ResourceUtil.getResourceFile(getClass(), fileName); + } +} diff --git a/src/test/resources/docker/Dockerfile.ExtInfoInAuthIT b/src/test/resources/docker/Dockerfile.ExtInfoInAuthIT new file mode 100644 index 00000000..06a3f9bb --- /dev/null +++ b/src/test/resources/docker/Dockerfile.ExtInfoInAuthIT @@ -0,0 +1,36 @@ +FROM alpine:3.19 +RUN apk update && \ + apk upgrade && \ + apk add openssh && \ + rm /var/cache/apk/* && \ + addgroup -g 1000 rsa && \ + adduser -Du 1000 -G rsa -Hh /rsa -s /bin/sh -g rsa rsa && \ + mkdir -p /rsa/.ssh && \ + chown -R rsa:rsa /rsa && \ + chmod 700 /rsa /rsa/.ssh && \ + passwd -u rsa && \ + addgroup -g 1001 ecdsa && \ + adduser -Du 1001 -G ecdsa -Hh /ecdsa -s /bin/sh -g ecdsa ecdsa && \ + mkdir -p /ecdsa/.ssh && \ + chown -R ecdsa:ecdsa /ecdsa && \ + chmod 700 /ecdsa /ecdsa/.ssh && \ + passwd -u ecdsa +COPY ssh_host_rsa_key /etc/ssh/ +COPY ssh_host_rsa_key.pub /etc/ssh/ +COPY ssh_host_ecdsa256_key /etc/ssh/ +COPY ssh_host_ecdsa256_key.pub /etc/ssh/ +COPY ssh_host_ecdsa384_key /etc/ssh/ +COPY ssh_host_ecdsa384_key.pub /etc/ssh/ +COPY ssh_host_ecdsa521_key /etc/ssh/ +COPY ssh_host_ecdsa521_key.pub /etc/ssh/ +COPY ssh_host_ed25519_key /etc/ssh/ +COPY ssh_host_ed25519_key.pub /etc/ssh/ +COPY ssh_host_dsa_key /etc/ssh/ +COPY ssh_host_dsa_key.pub /etc/ssh/ +COPY sshd_config /etc/ssh/ +COPY authorized_keys /rsa/.ssh/ +COPY authorized_keys /ecdsa/.ssh/ +RUN chown rsa:rsa /rsa/.ssh/authorized_keys && \ + chown ecdsa:ecdsa /ecdsa/.ssh/authorized_keys && \ + chmod 600 /etc/ssh/ssh_*_key /rsa/.ssh/authorized_keys /ecdsa/.ssh/authorized_keys +ENTRYPOINT ["/usr/sbin/sshd", "-D", "-e"] diff --git a/src/test/resources/docker/sshd_config.ExtInfoInAuthIT b/src/test/resources/docker/sshd_config.ExtInfoInAuthIT new file mode 100644 index 00000000..d63c7f83 --- /dev/null +++ b/src/test/resources/docker/sshd_config.ExtInfoInAuthIT @@ -0,0 +1,25 @@ +ChallengeResponseAuthentication no +HostbasedAuthentication no +PasswordAuthentication no +PubkeyAuthentication yes +AuthenticationMethods publickey +PubkeyAcceptedAlgorithms ssh-ed25519 +UseDNS no +PrintMotd no +PermitRootLogin yes +Subsystem sftp internal-sftp +HostKey /etc/ssh/ssh_host_ecdsa256_key +HostKey /etc/ssh/ssh_host_ecdsa384_key +HostKey /etc/ssh/ssh_host_ecdsa521_key +HostKey /etc/ssh/ssh_host_ed25519_key +HostKey /etc/ssh/ssh_host_rsa_key +HostKey /etc/ssh/ssh_host_dsa_key +KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group18-sha512,diffie-hellman-group16-sha512,diffie-hellman-group14-sha256,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 +HostKeyAlgorithms ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss +Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc +MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,hmac-sha1,hmac-sha1-96-etm@openssh.com,hmac-sha1-96,hmac-md5-etm@openssh.com,hmac-md5,hmac-md5-96-etm@openssh.com,hmac-md5-96 +LogLevel DEBUG3 +Match User rsa + PubkeyAcceptedAlgorithms rsa-sha2-512,rsa-sha2-256,ssh-rsa +Match User ecdsa + PubkeyAcceptedAlgorithms ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256 From eb5b0c962c74984369fa61bb2fa90b61f9b2ef2c Mon Sep 17 00:00:00 2001 From: release-bot Date: Tue, 19 Dec 2023 16:07:03 +0000 Subject: [PATCH 151/301] [maven-release-plugin] prepare release jsch-0.2.15 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 3dc16283..d348533d 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.mwiede jsch jar - 0.2.15-SNAPSHOT + 0.2.15 JSch https://github.com/mwiede/jsch JSch is a pure Java implementation of SSH2 @@ -12,7 +12,7 @@ scm:git:https://github.com/mwiede/jsch.git scm:git:https://github.com/mwiede/jsch.git https://github.com/mwiede/jsch - HEAD + jsch-0.2.15 @@ -73,7 +73,7 @@ - 2023-12-14T11:54:05Z + 2023-12-19T16:06:04Z UTF-8 UTF-8 true From a97a6f437c77fd84e249c7133ae8d23b39451804 Mon Sep 17 00:00:00 2001 From: release-bot Date: Tue, 19 Dec 2023 16:07:05 +0000 Subject: [PATCH 152/301] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index d348533d..34d69187 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.mwiede jsch jar - 0.2.15 + 0.2.16-SNAPSHOT JSch https://github.com/mwiede/jsch JSch is a pure Java implementation of SSH2 @@ -12,7 +12,7 @@ scm:git:https://github.com/mwiede/jsch.git scm:git:https://github.com/mwiede/jsch.git https://github.com/mwiede/jsch - jsch-0.2.15 + HEAD @@ -73,7 +73,7 @@ - 2023-12-19T16:06:04Z + 2023-12-19T16:07:05Z UTF-8 UTF-8 true From 31966f0e83350bd9012d848c14ddecde1ba6f194 Mon Sep 17 00:00:00 2001 From: Matthias Wiedemann Date: Wed, 20 Dec 2023 07:08:57 +0100 Subject: [PATCH 153/301] Update ChangeLog.md --- ChangeLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 03bf6573..22bb7fc1 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,6 @@ +* [0.2.15](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.15) + * address [CVE-2023-48795](https://nvd.nist.gov/vuln/detail/CVE-2023-48795) by adding support for new strict key exchange extension + * Add support for `ext-info-in-auth@openssh.com` extension * [0.2.14](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.14) * [#450](https://github.com/mwiede/jsch/issues/450) use Socket.connect() with a timeout that has been supported since Java 1.4 instead of using old method of creating a separate thread and joining to that thread with timeout. * [0.2.13](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.13) From 4c6a33a01715a1155495f321fa00bc7af456a07b Mon Sep 17 00:00:00 2001 From: Matthias Wiedemann Date: Wed, 20 Dec 2023 07:09:27 +0100 Subject: [PATCH 154/301] Update Readme.md --- Readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 31de4a53..60d76a7c 100644 --- a/Readme.md +++ b/Readme.md @@ -33,7 +33,7 @@ with com.github.mwiede jsch - 0.2.14 + 0.2.15 ``` @@ -43,7 +43,7 @@ When you have an artifact `foo:bar`, which contains `com.jcraft:jsch` as a trans com.github.mwiede jsch - 0.2.14 + 0.2.15 foo From bee3ea23cd1af205d7485666f17fd09af62443b8 Mon Sep 17 00:00:00 2001 From: Martijn Vegter Date: Wed, 20 Dec 2023 13:36:24 +0100 Subject: [PATCH 155/301] Do not falsely log support for ext-info if the server did not return 'ext-info-s' --- src/main/java/com/jcraft/jsch/Session.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/jcraft/jsch/Session.java b/src/main/java/com/jcraft/jsch/Session.java index 57302763..35042c07 100644 --- a/src/main/java/com/jcraft/jsch/Session.java +++ b/src/main/java/com/jcraft/jsch/Session.java @@ -602,7 +602,7 @@ private KeyExchange receive_kexinit(Buffer buf) throws Exception { if (enable_server_sig_algs) { doExtInfo = checkServerExtInfo(); - if (getLogger().isEnabled(Logger.INFO)) { + if (doExtInfo && getLogger().isEnabled(Logger.INFO)) { getLogger().log(Logger.INFO, "ext-info messaging supported by server"); } } From cc38991d1b297c1c8e3ad54c8a6f7cc31f45337f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Dec 2023 19:52:47 +0000 Subject: [PATCH 156/301] Bump org.apache.maven.plugins:maven-compiler-plugin Bumps [org.apache.maven.plugins:maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.11.0 to 3.12.1. - [Release notes](https://github.com/apache/maven-compiler-plugin/releases) - [Commits](https://github.com/apache/maven-compiler-plugin/compare/maven-compiler-plugin-3.11.0...maven-compiler-plugin-3.12.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-compiler-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 34d69187..79aca348 100644 --- a/pom.xml +++ b/pom.xml @@ -324,7 +324,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.11.0 + 3.12.1 8 true From 5a93123d125d217388b674b83d2b21f703c018a5 Mon Sep 17 00:00:00 2001 From: Martijn Vegter Date: Thu, 28 Dec 2023 22:40:35 +0100 Subject: [PATCH 157/301] Introduce JSchProxyException to replace generic JschException in Proxy implementations --- .../com/jcraft/jsch/JSchProxyException.java | 39 +++++++++++++++++++ src/main/java/com/jcraft/jsch/ProxyHTTP.java | 2 +- .../java/com/jcraft/jsch/ProxySOCKS4.java | 10 ++--- .../java/com/jcraft/jsch/ProxySOCKS5.java | 8 ++-- 4 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 src/main/java/com/jcraft/jsch/JSchProxyException.java diff --git a/src/main/java/com/jcraft/jsch/JSchProxyException.java b/src/main/java/com/jcraft/jsch/JSchProxyException.java new file mode 100644 index 00000000..88f8d99f --- /dev/null +++ b/src/main/java/com/jcraft/jsch/JSchProxyException.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions + * and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided with + * the distribution. + * + * 3. The names of the authors may not be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.jcraft.jsch; + +public class JSchProxyException extends JSchException { + private static final long serialVersionUID = -1L; + + public JSchProxyException(String s) { + super(s); + } + + public JSchProxyException(String s, Throwable e) { + super(s, e); + } +} diff --git a/src/main/java/com/jcraft/jsch/ProxyHTTP.java b/src/main/java/com/jcraft/jsch/ProxyHTTP.java index 028cf830..e69c5b9d 100644 --- a/src/main/java/com/jcraft/jsch/ProxyHTTP.java +++ b/src/main/java/com/jcraft/jsch/ProxyHTTP.java @@ -163,7 +163,7 @@ public void connect(SocketFactory socket_factory, String host, int port, int tim } catch (Exception eee) { } String message = "ProxyHTTP: " + e.toString(); - throw new JSchException(message, e); + throw new JSchProxyException(message, e); } } diff --git a/src/main/java/com/jcraft/jsch/ProxySOCKS4.java b/src/main/java/com/jcraft/jsch/ProxySOCKS4.java index aad0c017..69ab8f42 100644 --- a/src/main/java/com/jcraft/jsch/ProxySOCKS4.java +++ b/src/main/java/com/jcraft/jsch/ProxySOCKS4.java @@ -120,7 +120,7 @@ public void connect(SocketFactory socket_factory, String host, int port, int tim buf[index++] = byteAddress[i]; } } catch (UnknownHostException uhe) { - throw new JSchException("ProxySOCKS4: " + uhe.toString(), uhe); + throw new JSchProxyException("ProxySOCKS4: " + uhe.toString(), uhe); } if (user != null) { @@ -156,12 +156,12 @@ public void connect(SocketFactory socket_factory, String host, int port, int tim while (s < len) { int i = in.read(buf, s, len - s); if (i <= 0) { - throw new JSchException("ProxySOCKS4: stream is closed"); + throw new JSchProxyException("ProxySOCKS4: stream is closed"); } s += i; } if (buf[0] != 0) { - throw new JSchException("ProxySOCKS4: server returns VN " + buf[0]); + throw new JSchProxyException("ProxySOCKS4: server returns VN " + buf[0]); } if (buf[1] != 90) { try { @@ -169,7 +169,7 @@ public void connect(SocketFactory socket_factory, String host, int port, int tim } catch (Exception eee) { } String message = "ProxySOCKS4: server returns CD " + buf[1]; - throw new JSchException(message); + throw new JSchProxyException(message); } } catch (RuntimeException e) { throw e; @@ -179,7 +179,7 @@ public void connect(SocketFactory socket_factory, String host, int port, int tim socket.close(); } catch (Exception eee) { } - throw new JSchException("ProxySOCKS4: " + e.toString(), e); + throw new JSchProxyException("ProxySOCKS4: " + e.toString(), e); } } diff --git a/src/main/java/com/jcraft/jsch/ProxySOCKS5.java b/src/main/java/com/jcraft/jsch/ProxySOCKS5.java index b1b556dc..2160ce50 100644 --- a/src/main/java/com/jcraft/jsch/ProxySOCKS5.java +++ b/src/main/java/com/jcraft/jsch/ProxySOCKS5.java @@ -177,7 +177,7 @@ public void connect(SocketFactory socket_factory, String host, int port, int tim socket.close(); } catch (Exception eee) { } - throw new JSchException("fail in SOCKS5 proxy"); + throw new JSchProxyException("fail in SOCKS5 proxy"); } /* @@ -239,7 +239,7 @@ public void connect(SocketFactory socket_factory, String host, int port, int tim socket.close(); } catch (Exception eee) { } - throw new JSchException("ProxySOCKS5: server returns " + buf[1]); + throw new JSchProxyException("ProxySOCKS5: server returns " + buf[1]); } switch (buf[3] & 0xff) { @@ -268,7 +268,7 @@ public void connect(SocketFactory socket_factory, String host, int port, int tim } catch (Exception eee) { } String message = "ProxySOCKS5: " + e.toString(); - throw new JSchException(message, e); + throw new JSchProxyException(message, e); } } @@ -312,7 +312,7 @@ private void fill(InputStream in, byte[] buf, int len) throws JSchException, IOE while (s < len) { int i = in.read(buf, s, len - s); if (i <= 0) { - throw new JSchException("ProxySOCKS5: stream is closed"); + throw new JSchProxyException("ProxySOCKS5: stream is closed"); } s += i; } From 359768ced151837659f8cd21f37be3e4f87d8a15 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jan 2024 19:53:40 +0000 Subject: [PATCH 158/301] Bump org.slf4j:slf4j-api from 2.0.9 to 2.0.10 Bumps org.slf4j:slf4j-api from 2.0.9 to 2.0.10. --- updated-dependencies: - dependency-name: org.slf4j:slf4j-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 34d69187..dcefc7da 100644 --- a/pom.xml +++ b/pom.xml @@ -130,7 +130,7 @@ org.slf4j slf4j-api - 2.0.9 + 2.0.10 true From b5f901066e285f8bebd67bbd0b0e825805c078ac Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jan 2024 19:53:42 +0000 Subject: [PATCH 159/301] Bump log4j.version from 2.22.0 to 2.22.1 Bumps `log4j.version` from 2.22.0 to 2.22.1. Updates `org.apache.logging.log4j:log4j-api` from 2.22.0 to 2.22.1 Updates `org.apache.logging.log4j:log4j-core-test` from 2.22.0 to 2.22.1 --- updated-dependencies: - dependency-name: org.apache.logging.log4j:log4j-api dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.logging.log4j:log4j-core-test dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 34d69187..f3f5091f 100644 --- a/pom.xml +++ b/pom.xml @@ -79,7 +79,7 @@ true 2.8.3 5.14.0 - 2.22.0 + 2.22.1 2.23.0 3.2.3 From b3bdfcf4eca83cfa8e01adcc46ffdd7ca2d00eb7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jan 2024 20:13:43 +0000 Subject: [PATCH 160/301] Bump errorprone.version from 2.23.0 to 2.24.0 Bumps `errorprone.version` from 2.23.0 to 2.24.0. Updates `com.google.errorprone:error_prone_annotations` from 2.23.0 to 2.24.0 - [Release notes](https://github.com/google/error-prone/releases) - [Commits](https://github.com/google/error-prone/compare/v2.23.0...v2.24.0) Updates `com.google.errorprone:error_prone_core` from 2.23.0 to 2.24.0 - [Release notes](https://github.com/google/error-prone/releases) - [Commits](https://github.com/google/error-prone/compare/v2.23.0...v2.24.0) --- updated-dependencies: - dependency-name: com.google.errorprone:error_prone_annotations dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.google.errorprone:error_prone_core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5da91821..5a474e69 100644 --- a/pom.xml +++ b/pom.xml @@ -80,7 +80,7 @@ 2.8.3 5.14.0 2.22.1 - 2.23.0 + 2.24.0 3.2.3 From db4bf8bbfc593db318553757a9006ae7f03273e2 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Fri, 22 Dec 2023 07:45:32 -0600 Subject: [PATCH 161/301] Add support for `sntrup761x25519-sha512@openssh.com` KEX algorithm. --- pom.xml | 3 + .../com/jcraft/jsch/DH25519SNTRUP761.java | 38 +++ src/main/java/com/jcraft/jsch/DHECN.java | 5 +- src/main/java/com/jcraft/jsch/DHGEX.java | 4 +- src/main/java/com/jcraft/jsch/DHGN.java | 5 +- src/main/java/com/jcraft/jsch/DHXEC.java | 5 +- src/main/java/com/jcraft/jsch/DHXECKEM.java | 229 ++++++++++++++++++ src/main/java/com/jcraft/jsch/JSch.java | 5 +- src/main/java/com/jcraft/jsch/KEM.java | 35 +++ .../java/com/jcraft/jsch/KeyExchange.java | 26 ++ src/main/java/com/jcraft/jsch/Session.java | 8 +- .../annotations/SuppressForbiddenApi.java | 13 + .../java/com/jcraft/jsch/bc/SNTRUP761.java | 73 ++++++ .../java/com/jcraft/jsch/Algorithms4IT.java | 191 +++++++++++++++ .../docker/sshd_config.ExtInfoInAuthIT | 2 +- .../resources/docker/sshd_config.openssh96 | 2 +- 16 files changed, 627 insertions(+), 17 deletions(-) create mode 100644 src/main/java/com/jcraft/jsch/DH25519SNTRUP761.java create mode 100644 src/main/java/com/jcraft/jsch/DHXECKEM.java create mode 100644 src/main/java/com/jcraft/jsch/KEM.java create mode 100644 src/main/java/com/jcraft/jsch/annotations/SuppressForbiddenApi.java create mode 100644 src/main/java/com/jcraft/jsch/bc/SNTRUP761.java create mode 100644 src/test/java/com/jcraft/jsch/Algorithms4IT.java diff --git a/pom.xml b/pom.xml index 5da91821..c479b830 100644 --- a/pom.xml +++ b/pom.xml @@ -661,6 +661,9 @@ jdk-non-portable jdk-reflection + + com.jcraft.jsch.annotations.SuppressForbiddenApi + diff --git a/src/main/java/com/jcraft/jsch/DH25519SNTRUP761.java b/src/main/java/com/jcraft/jsch/DH25519SNTRUP761.java new file mode 100644 index 00000000..1c6732ce --- /dev/null +++ b/src/main/java/com/jcraft/jsch/DH25519SNTRUP761.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions + * and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided with + * the distribution. + * + * 3. The names of the authors may not be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.jcraft.jsch; + +class DH25519SNTRUP761 extends DHXECKEM { + public DH25519SNTRUP761() { + kem_name = "sntrup761"; + sha_name = "sha-512"; + curve_name = "X25519"; + kem_pubkey_len = 1158; + kem_encap_len = 1039; + xec_key_len = 32; + } +} diff --git a/src/main/java/com/jcraft/jsch/DHECN.java b/src/main/java/com/jcraft/jsch/DHECN.java index f28c9ff8..a20abf06 100644 --- a/src/main/java/com/jcraft/jsch/DHECN.java +++ b/src/main/java/com/jcraft/jsch/DHECN.java @@ -133,8 +133,7 @@ public boolean next(Buffer _buf) throws Exception { return false; } - K = ecdh.getSecret(r_s[0], r_s[1]); - K = normalize(K); + K = encodeAsMPInt(normalize(ecdh.getSecret(r_s[0], r_s[1]))); byte[] sig_of_H = _buf.getString(); @@ -159,11 +158,11 @@ public boolean next(Buffer _buf) throws Exception { buf.putString(K_S); buf.putString(Q_C); buf.putString(Q_S); - buf.putMPInt(K); byte[] foo = new byte[buf.getLength()]; buf.getByte(foo); sha.update(foo, 0, foo.length); + sha.update(K, 0, K.length); H = sha.digest(); i = 0; diff --git a/src/main/java/com/jcraft/jsch/DHGEX.java b/src/main/java/com/jcraft/jsch/DHGEX.java index 84aa51d4..15f9bd0f 100644 --- a/src/main/java/com/jcraft/jsch/DHGEX.java +++ b/src/main/java/com/jcraft/jsch/DHGEX.java @@ -175,7 +175,7 @@ public boolean next(Buffer _buf) throws Exception { dh.checkRange(); - K = normalize(dh.getK()); + K = encodeAsMPInt(normalize(dh.getK())); // The hash H is computed as the HASH hash of the concatenation of the // following: @@ -208,11 +208,11 @@ public boolean next(Buffer _buf) throws Exception { buf.putMPInt(g); buf.putMPInt(e); buf.putMPInt(f); - buf.putMPInt(K); byte[] foo = new byte[buf.getLength()]; buf.getByte(foo); sha.update(foo, 0, foo.length); + sha.update(K, 0, K.length); H = sha.digest(); diff --git a/src/main/java/com/jcraft/jsch/DHGN.java b/src/main/java/com/jcraft/jsch/DHGN.java index 44aaadf8..ddb41dfb 100644 --- a/src/main/java/com/jcraft/jsch/DHGN.java +++ b/src/main/java/com/jcraft/jsch/DHGN.java @@ -134,7 +134,7 @@ public boolean next(Buffer _buf) throws Exception { dh.checkRange(); - K = normalize(dh.getK()); + K = encodeAsMPInt(normalize(dh.getK())); // The hash H is computed as the HASH hash of the concatenation of the // following: @@ -156,10 +156,11 @@ public boolean next(Buffer _buf) throws Exception { buf.putString(K_S); buf.putMPInt(e); buf.putMPInt(f); - buf.putMPInt(K); byte[] foo = new byte[buf.getLength()]; buf.getByte(foo); + sha.update(foo, 0, foo.length); + sha.update(K, 0, K.length); H = sha.digest(); // System.err.print("H -> "); //dump(H, 0, H.length); diff --git a/src/main/java/com/jcraft/jsch/DHXEC.java b/src/main/java/com/jcraft/jsch/DHXEC.java index a3576189..b8cf55cc 100644 --- a/src/main/java/com/jcraft/jsch/DHXEC.java +++ b/src/main/java/com/jcraft/jsch/DHXEC.java @@ -131,8 +131,7 @@ public boolean next(Buffer _buf) throws Exception { return false; } - K = xdh.getSecret(Q_S); - K = normalize(K); + K = encodeAsMPInt(normalize(xdh.getSecret(Q_S))); byte[] sig_of_H = _buf.getString(); @@ -171,11 +170,11 @@ public boolean next(Buffer _buf) throws Exception { buf.putString(K_S); buf.putString(Q_C); buf.putString(Q_S); - buf.putMPInt(K); byte[] foo = new byte[buf.getLength()]; buf.getByte(foo); sha.update(foo, 0, foo.length); + sha.update(K, 0, K.length); H = sha.digest(); i = 0; diff --git a/src/main/java/com/jcraft/jsch/DHXECKEM.java b/src/main/java/com/jcraft/jsch/DHXECKEM.java new file mode 100644 index 00000000..1bee11fb --- /dev/null +++ b/src/main/java/com/jcraft/jsch/DHXECKEM.java @@ -0,0 +1,229 @@ +/* + * Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions + * and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided with + * the distribution. + * + * 3. The names of the authors may not be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.jcraft.jsch; + +abstract class DHXECKEM extends KeyExchange { + + private static final int SSH_MSG_KEX_ECDH_INIT = 30; + private static final int SSH_MSG_KEX_ECDH_REPLY = 31; + private int state; + + byte[] Q_C; + + byte[] V_S; + byte[] V_C; + byte[] I_S; + byte[] I_C; + + byte[] e; + + private Buffer buf; + private Packet packet; + + private KEM kem; + private XDH xdh; + + protected String kem_name; + protected String sha_name; + protected String curve_name; + protected int kem_pubkey_len; + protected int kem_encap_len; + protected int xec_key_len; + + @Override + public void init(Session session, byte[] V_S, byte[] V_C, byte[] I_S, byte[] I_C) + throws Exception { + this.V_S = V_S; + this.V_C = V_C; + this.I_S = I_S; + this.I_C = I_C; + + try { + Class c = Class.forName(session.getConfig(sha_name)).asSubclass(HASH.class); + sha = c.getDeclaredConstructor().newInstance(); + sha.init(); + } catch (Exception e) { + throw new JSchException(e.toString(), e); + } + + buf = new Buffer(); + packet = new Packet(buf); + + packet.reset(); + // command + string len + Q_C len + buf.checkFreeSize(1 + 4 + kem_pubkey_len + xec_key_len); + buf.putByte((byte) SSH_MSG_KEX_ECDH_INIT); + + try { + Class k = Class.forName(session.getConfig(kem_name)).asSubclass(KEM.class); + kem = k.getDeclaredConstructor().newInstance(); + kem.init(); + + Class c = Class.forName(session.getConfig("xdh")).asSubclass(XDH.class); + xdh = c.getDeclaredConstructor().newInstance(); + xdh.init(curve_name, xec_key_len); + + byte[] kem_public_key_C = kem.getPublicKey(); + byte[] xec_public_key_C = xdh.getQ(); + Q_C = new byte[kem_pubkey_len + xec_key_len]; + System.arraycopy(kem_public_key_C, 0, Q_C, 0, kem_pubkey_len); + System.arraycopy(xec_public_key_C, 0, Q_C, kem_pubkey_len, xec_key_len); + buf.putString(Q_C); + } catch (Exception | NoClassDefFoundError e) { + throw new JSchException(e.toString(), e); + } + + if (V_S == null) { // This is a really ugly hack for Session.checkKexes ;-( + return; + } + + session.write(packet); + + if (session.getLogger().isEnabled(Logger.INFO)) { + session.getLogger().log(Logger.INFO, "SSH_MSG_KEX_ECDH_INIT sent"); + session.getLogger().log(Logger.INFO, "expecting SSH_MSG_KEX_ECDH_REPLY"); + } + + state = SSH_MSG_KEX_ECDH_REPLY; + } + + @Override + public boolean next(Buffer _buf) throws Exception { + int i, j; + switch (state) { + case SSH_MSG_KEX_ECDH_REPLY: + // The server responds with: + // byte SSH_MSG_KEX_ECDH_REPLY + // string K_S, server's public host key + // string Q_S, server's ephemeral public key octet string + // string the signature on the exchange hash + j = _buf.getInt(); + j = _buf.getByte(); + j = _buf.getByte(); + if (j != SSH_MSG_KEX_ECDH_REPLY) { + if (session.getLogger().isEnabled(Logger.ERROR)) { + session.getLogger().log(Logger.ERROR, "type: must be SSH_MSG_KEX_ECDH_REPLY " + j); + } + return false; + } + + K_S = _buf.getString(); + + byte[] Q_S = _buf.getString(); + if (Q_S.length != kem_encap_len + xec_key_len) { + return false; + } + + byte[] encapsulation = new byte[kem_encap_len]; + byte[] xec_public_key_S = new byte[xec_key_len]; + System.arraycopy(Q_S, 0, encapsulation, 0, kem_encap_len); + System.arraycopy(Q_S, kem_encap_len, xec_public_key_S, 0, xec_key_len); + + // RFC 5656, + // 4. ECDH Key Exchange + // All elliptic curve public keys MUST be validated after they are + // received. An example of a validation algorithm can be found in + // Section 3.2.2 of [SEC1]. If a key fails validation, + // the key exchange MUST fail. + if (!xdh.validate(xec_public_key_S)) { + return false; + } + + byte[] tmp = null; + try { + tmp = kem.decapsulate(encapsulation); + sha.update(tmp, 0, tmp.length); + } finally { + Util.bzero(tmp); + } + try { + tmp = normalize(xdh.getSecret(xec_public_key_S)); + sha.update(tmp, 0, tmp.length); + } finally { + Util.bzero(tmp); + } + K = encodeAsString(sha.digest()); + + byte[] sig_of_H = _buf.getString(); + + // The hash H is computed as the HASH hash of the concatenation of the + // following: + // string V_C, client's identification string (CR and LF excluded) + // string V_S, server's identification string (CR and LF excluded) + // string I_C, payload of the client's SSH_MSG_KEXINIT + // string I_S, payload of the server's SSH_MSG_KEXINIT + // string K_S, server's public host key + // string Q_C, client's ephemeral public key octet string + // string Q_S, server's ephemeral public key octet string + // string K, shared secret + + // draft-josefsson-ntruprime-ssh-02, + // 3. Key Exchange Method: sntrup761x25519-sha512 + // ... + // The SSH_MSG_KEX_ECDH_REPLY's signature value is computed as described + // in [RFC5656] with the following changes. Instead of encoding the + // shared secret K as 'mpint', it MUST be encoded as 'string'. The + // shared secret K value MUST be the 64-byte output octet string of the + // SHA-512 hash computed with the input as the 32-byte octet string key + // output from the key encapsulation mechanism of sntrup761 concatenated + // with the 32-byte octet string of X25519(a, X25519(b, 9)) = X25519(b, + // X25519(a, 9)). + buf.reset(); + buf.putString(V_C); + buf.putString(V_S); + buf.putString(I_C); + buf.putString(I_S); + buf.putString(K_S); + buf.putString(Q_C); + buf.putString(Q_S); + byte[] foo = new byte[buf.getLength()]; + buf.getByte(foo); + + sha.update(foo, 0, foo.length); + sha.update(K, 0, K.length); + H = sha.digest(); + + i = 0; + j = 0; + j = ((K_S[i++] << 24) & 0xff000000) | ((K_S[i++] << 16) & 0x00ff0000) + | ((K_S[i++] << 8) & 0x0000ff00) | ((K_S[i++]) & 0x000000ff); + String alg = Util.byte2str(K_S, i, j); + i += j; + + boolean result = verify(alg, K_S, i, sig_of_H); + + state = STATE_END; + return result; + } + return false; + } + + @Override + public int getState() { + return state; + } +} diff --git a/src/main/java/com/jcraft/jsch/JSch.java b/src/main/java/com/jcraft/jsch/JSch.java index 0c86f25c..a089dd66 100644 --- a/src/main/java/com/jcraft/jsch/JSch.java +++ b/src/main/java/com/jcraft/jsch/JSch.java @@ -103,6 +103,9 @@ public class JSch { config.put("curve25519-sha256", "com.jcraft.jsch.DH25519"); config.put("curve25519-sha256@libssh.org", "com.jcraft.jsch.DH25519"); config.put("curve448-sha512", "com.jcraft.jsch.DH448"); + config.put("sntrup761x25519-sha512@openssh.com", "com.jcraft.jsch.DH25519SNTRUP761"); + + config.put("sntrup761", "com.jcraft.jsch.bc.SNTRUP761"); config.put("dh", "com.jcraft.jsch.jce.DH"); config.put("3des-cbc", "com.jcraft.jsch.jce.TripleDESCBC"); @@ -239,7 +242,7 @@ public class JSch { Util.getSystemProperty("jsch.check_ciphers", "chacha20-poly1305@openssh.com")); config.put("CheckMacs", Util.getSystemProperty("jsch.check_macs", "")); config.put("CheckKexes", Util.getSystemProperty("jsch.check_kexes", - "curve25519-sha256,curve25519-sha256@libssh.org,curve448-sha512")); + "sntrup761x25519-sha512@openssh.com,curve25519-sha256,curve25519-sha256@libssh.org,curve448-sha512")); config.put("CheckSignatures", Util.getSystemProperty("jsch.check_signatures", "ssh-ed25519,ssh-ed448")); config.put("FingerprintHash", Util.getSystemProperty("jsch.fingerprint_hash", "sha256")); diff --git a/src/main/java/com/jcraft/jsch/KEM.java b/src/main/java/com/jcraft/jsch/KEM.java new file mode 100644 index 00000000..90dcaacf --- /dev/null +++ b/src/main/java/com/jcraft/jsch/KEM.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions + * and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided with + * the distribution. + * + * 3. The names of the authors may not be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.jcraft.jsch; + +public interface KEM { + void init() throws Exception; + + byte[] getPublicKey() throws Exception; + + byte[] decapsulate(byte[] encapsulation) throws Exception; +} diff --git a/src/main/java/com/jcraft/jsch/KeyExchange.java b/src/main/java/com/jcraft/jsch/KeyExchange.java index e686be76..f418cb0a 100644 --- a/src/main/java/com/jcraft/jsch/KeyExchange.java +++ b/src/main/java/com/jcraft/jsch/KeyExchange.java @@ -425,4 +425,30 @@ protected boolean verify(String alg, byte[] K_S, int index, byte[] sig_of_H) thr return result; } + protected byte[] encodeAsMPInt(byte[] raw) { + int i = (raw[0] & 0x80) >>> 7; + int len = raw.length + i; + byte[] foo = new byte[len + 4]; + // Try to remain timing safe by performing an extra allocation when i == 0 + byte[] bar = new byte[i ^ 0x1]; + foo[0] = (byte) (len >>> 24); + foo[1] = (byte) (len >>> 16); + foo[2] = (byte) (len >>> 8); + foo[3] = (byte) (len); + System.arraycopy(raw, 0, foo, 4 + i, len - i); + Util.bzero(raw); + return foo; + } + + protected byte[] encodeAsString(byte[] raw) { + int len = raw.length; + byte[] foo = new byte[len + 4]; + foo[0] = (byte) (len >>> 24); + foo[1] = (byte) (len >>> 16); + foo[2] = (byte) (len >>> 8); + foo[3] = (byte) (len); + System.arraycopy(raw, 0, foo, 4, len); + Util.bzero(raw); + return foo; + } } diff --git a/src/main/java/com/jcraft/jsch/Session.java b/src/main/java/com/jcraft/jsch/Session.java index 57302763..3052b951 100644 --- a/src/main/java/com/jcraft/jsch/Session.java +++ b/src/main/java/com/jcraft/jsch/Session.java @@ -1491,7 +1491,7 @@ private void updateKeys(KeyExchange kex) throws Exception { */ buf.reset(); - buf.putMPInt(K); + buf.putByte(K); buf.putByte(H); buf.putByte((byte) 0x41); buf.putByte(session_id); @@ -1530,7 +1530,7 @@ private void updateKeys(KeyExchange kex) throws Exception { s2ccipher = cc.getDeclaredConstructor().newInstance(); while (s2ccipher.getBlockSize() > Es2c.length) { buf.reset(); - buf.putMPInt(K); + buf.putByte(K); buf.putByte(H); buf.putByte(Es2c); hash.update(buf.buffer, 0, buf.index); @@ -1559,7 +1559,7 @@ private void updateKeys(KeyExchange kex) throws Exception { c2scipher = cc.getDeclaredConstructor().newInstance(); while (c2scipher.getBlockSize() > Ec2s.length) { buf.reset(); - buf.putMPInt(K); + buf.putByte(K); buf.putByte(H); buf.putByte(Ec2s); hash.update(buf.buffer, 0, buf.index); @@ -1608,7 +1608,7 @@ private byte[] expandKey(Buffer buf, byte[] K, byte[] H, byte[] key, HASH hash, int size = hash.getBlockSize(); while (result.length < required_length) { buf.reset(); - buf.putMPInt(K); + buf.putByte(K); buf.putByte(H); buf.putByte(result); hash.update(buf.buffer, 0, buf.index); diff --git a/src/main/java/com/jcraft/jsch/annotations/SuppressForbiddenApi.java b/src/main/java/com/jcraft/jsch/annotations/SuppressForbiddenApi.java new file mode 100644 index 00000000..b3494689 --- /dev/null +++ b/src/main/java/com/jcraft/jsch/annotations/SuppressForbiddenApi.java @@ -0,0 +1,13 @@ +package com.jcraft.jsch.annotations; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Retention(RetentionPolicy.CLASS) +@Target({ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.LOCAL_VARIABLE, ElementType.METHOD, + ElementType.PARAMETER, ElementType.TYPE}) +public @interface SuppressForbiddenApi { + String[] value(); +} diff --git a/src/main/java/com/jcraft/jsch/bc/SNTRUP761.java b/src/main/java/com/jcraft/jsch/bc/SNTRUP761.java new file mode 100644 index 00000000..08862a07 --- /dev/null +++ b/src/main/java/com/jcraft/jsch/bc/SNTRUP761.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions + * and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided with + * the distribution. + * + * 3. The names of the authors may not be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.jcraft.jsch.bc; + +import com.jcraft.jsch.KEM; +import com.jcraft.jsch.annotations.SuppressForbiddenApi; +import java.lang.reflect.Constructor; +import java.security.SecureRandom; +import org.bouncycastle.crypto.AsymmetricCipherKeyPair; +import org.bouncycastle.pqc.crypto.ntruprime.*; + +public class SNTRUP761 implements KEM { + SNTRUPrimeKEMExtractor extractor; + SNTRUPrimePublicKeyParameters publicKey; + + @Override + public void init() throws Exception { + SNTRUPrimeKeyPairGenerator kpg = new SNTRUPrimeKeyPairGenerator(); + kpg.init(new SNTRUPrimeKeyGenerationParameters(new SecureRandom(), sntrup761())); + AsymmetricCipherKeyPair kp = kpg.generateKeyPair(); + extractor = new SNTRUPrimeKEMExtractor((SNTRUPrimePrivateKeyParameters) kp.getPrivate()); + publicKey = (SNTRUPrimePublicKeyParameters) kp.getPublic(); + } + + @Override + public byte[] getPublicKey() throws Exception { + return publicKey.getEncoded(); + } + + @Override + public byte[] decapsulate(byte[] encapsulation) throws Exception { + return extractor.extractSecret(encapsulation); + } + + // Bouncy Castle before 1.78 defines sharedKeyBytes differently than OpenSSH (16 instead of 32) + // https://github.com/bcgit/bc-java/issues/1554 + // https://github.com/bcgit/bc-java/commit/db3ae60 + @SuppressForbiddenApi("jdk-reflection") + static SNTRUPrimeParameters sntrup761() throws Exception { + if (SNTRUPrimeParameters.sntrup761.getSessionKeySize() == 32 * 8) { + return SNTRUPrimeParameters.sntrup761; + } + Constructor c = + SNTRUPrimeParameters.class.getDeclaredConstructor(String.class, int.class, int.class, + int.class, int.class, int.class, int.class, int.class, int.class); + c.setAccessible(true); + return c.newInstance("sntrup761", 761, 4591, 286, 1158, 1007, 1158, 1763, 32); + } +} diff --git a/src/test/java/com/jcraft/jsch/Algorithms4IT.java b/src/test/java/com/jcraft/jsch/Algorithms4IT.java new file mode 100644 index 00000000..0d5632f9 --- /dev/null +++ b/src/test/java/com/jcraft/jsch/Algorithms4IT.java @@ -0,0 +1,191 @@ +package com.jcraft.jsch; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static java.util.stream.Collectors.toList; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import com.github.valfirst.slf4jtest.LoggingEvent; +import com.github.valfirst.slf4jtest.TestLogger; +import com.github.valfirst.slf4jtest.TestLoggerFactory; +import java.io.IOException; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Base64; +import java.util.List; +import java.util.Locale; +import java.util.Optional; +import java.util.Random; +import org.apache.commons.codec.digest.DigestUtils; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.io.TempDir; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.output.Slf4jLogConsumer; +import org.testcontainers.images.builder.ImageFromDockerfile; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; + +@Testcontainers +public class Algorithms4IT { + + private static final int timeout = 2000; + private static final DigestUtils sha256sum = new DigestUtils(DigestUtils.getSha256Digest()); + private static final TestLogger jschLogger = TestLoggerFactory.getTestLogger(JSch.class); + private static final TestLogger sshdLogger = TestLoggerFactory.getTestLogger(Algorithms4IT.class); + + @TempDir + public Path tmpDir; + private Path in; + private Path out; + private String hash; + private Slf4jLogConsumer sshdLogConsumer; + + @Container + public GenericContainer sshd = new GenericContainer<>( + new ImageFromDockerfile().withFileFromClasspath("ssh_host_rsa_key", "docker/ssh_host_rsa_key") + .withFileFromClasspath("ssh_host_rsa_key.pub", "docker/ssh_host_rsa_key.pub") + .withFileFromClasspath("ssh_host_ecdsa256_key", "docker/ssh_host_ecdsa256_key") + .withFileFromClasspath("ssh_host_ecdsa256_key.pub", "docker/ssh_host_ecdsa256_key.pub") + .withFileFromClasspath("ssh_host_ecdsa384_key", "docker/ssh_host_ecdsa384_key") + .withFileFromClasspath("ssh_host_ecdsa384_key.pub", "docker/ssh_host_ecdsa384_key.pub") + .withFileFromClasspath("ssh_host_ecdsa521_key", "docker/ssh_host_ecdsa521_key") + .withFileFromClasspath("ssh_host_ecdsa521_key.pub", "docker/ssh_host_ecdsa521_key.pub") + .withFileFromClasspath("ssh_host_ed25519_key", "docker/ssh_host_ed25519_key") + .withFileFromClasspath("ssh_host_ed25519_key.pub", "docker/ssh_host_ed25519_key.pub") + .withFileFromClasspath("ssh_host_dsa_key", "docker/ssh_host_dsa_key") + .withFileFromClasspath("ssh_host_dsa_key.pub", "docker/ssh_host_dsa_key.pub") + .withFileFromClasspath("sshd_config", "docker/sshd_config.openssh96") + .withFileFromClasspath("authorized_keys", "docker/authorized_keys") + .withFileFromClasspath("Dockerfile", "docker/Dockerfile.openssh96")) + .withExposedPorts(22); + + @BeforeAll + public static void beforeAll() { + JSch.setLogger(new Slf4jLogger()); + } + + @BeforeEach + public void beforeEach() throws IOException { + if (sshdLogConsumer == null) { + sshdLogConsumer = new Slf4jLogConsumer(sshdLogger); + sshd.followOutput(sshdLogConsumer); + } + + in = tmpDir.resolve("in"); + out = tmpDir.resolve("out"); + Files.createFile(in); + try (OutputStream os = Files.newOutputStream(in)) { + byte[] data = new byte[1024]; + for (int i = 0; i < 1024 * 100; i += 1024) { + new Random().nextBytes(data); + os.write(data); + } + } + hash = sha256sum.digestAsHex(in); + + jschLogger.clearAll(); + sshdLogger.clearAll(); + } + + @AfterAll + public static void afterAll() { + JSch.setLogger(null); + jschLogger.clearAll(); + sshdLogger.clearAll(); + } + + @ParameterizedTest + @ValueSource(strings = {"sntrup761x25519-sha512@openssh.com"}) + public void testBCKEXs(String kex) throws Exception { + JSch ssh = createRSAIdentity(); + Session session = createSession(ssh); + session.setConfig("kex", kex); + doSftp(session, true); + + String expected = String.format(Locale.ROOT, "kex: algorithm: %s.*", kex); + checkLogs(expected); + } + + private JSch createRSAIdentity() throws Exception { + HostKey hostKey = readHostKey(getResourceFile("docker/ssh_host_rsa_key.pub")); + JSch ssh = new JSch(); + ssh.addIdentity(getResourceFile("docker/id_rsa"), getResourceFile("docker/id_rsa.pub"), null); + ssh.getHostKeyRepository().add(hostKey, null); + return ssh; + } + + private HostKey readHostKey(String fileName) throws Exception { + List lines = Files.readAllLines(Paths.get(fileName), UTF_8); + String[] split = lines.get(0).split("\\s+"); + String hostname = + String.format(Locale.ROOT, "[%s]:%d", sshd.getHost(), sshd.getFirstMappedPort()); + return new HostKey(hostname, Base64.getDecoder().decode(split[1])); + } + + private Session createSession(JSch ssh) throws Exception { + Session session = ssh.getSession("root", sshd.getHost(), sshd.getFirstMappedPort()); + session.setConfig("StrictHostKeyChecking", "yes"); + session.setConfig("PreferredAuthentications", "publickey"); + return session; + } + + private void doSftp(Session session, boolean debugException) throws Exception { + try { + session.setTimeout(timeout); + session.connect(); + ChannelSftp sftp = (ChannelSftp) session.openChannel("sftp"); + sftp.connect(timeout); + sftp.put(in.toString(), "/root/test"); + sftp.get("/root/test", out.toString()); + sftp.disconnect(); + session.disconnect(); + } catch (Exception e) { + if (debugException) { + printInfo(); + } + throw e; + } + + assertEquals(1024L * 100L, Files.size(out)); + assertEquals(hash, sha256sum.digestAsHex(out)); + } + + private void printInfo() { + jschLogger.getAllLoggingEvents().stream().map(LoggingEvent::getFormattedMessage) + .forEach(System.out::println); + sshdLogger.getAllLoggingEvents().stream().map(LoggingEvent::getFormattedMessage) + .forEach(System.out::println); + System.out.println(""); + System.out.println(""); + System.out.println(""); + } + + private void checkLogs(String expected) { + Optional actualJsch = jschLogger.getAllLoggingEvents().stream() + .map(LoggingEvent::getFormattedMessage).filter(msg -> msg.matches(expected)).findFirst(); + // Skip OpenSSH log checks, as log output from Docker falls behind and these assertions + // frequently run before they are output + // Optional actualSshd = + // sshdLogger.getAllLoggingEvents().stream() + // .map(LoggingEvent::getFormattedMessage) + // .filter(msg -> msg.matches("STDERR: debug1: " + expected)) + // .findFirst(); + try { + assertTrue(actualJsch.isPresent(), () -> "JSch: " + expected); + // assertTrue(actualSshd.isPresent(), () -> "sshd: " + expected); + } catch (AssertionError e) { + printInfo(); + throw e; + } + } + + private String getResourceFile(String fileName) { + return ResourceUtil.getResourceFile(getClass(), fileName); + } +} diff --git a/src/test/resources/docker/sshd_config.ExtInfoInAuthIT b/src/test/resources/docker/sshd_config.ExtInfoInAuthIT index d63c7f83..73dd194a 100644 --- a/src/test/resources/docker/sshd_config.ExtInfoInAuthIT +++ b/src/test/resources/docker/sshd_config.ExtInfoInAuthIT @@ -14,7 +14,7 @@ HostKey /etc/ssh/ssh_host_ecdsa521_key HostKey /etc/ssh/ssh_host_ed25519_key HostKey /etc/ssh/ssh_host_rsa_key HostKey /etc/ssh/ssh_host_dsa_key -KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group18-sha512,diffie-hellman-group16-sha512,diffie-hellman-group14-sha256,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 +KexAlgorithms sntrup761x25519-sha512@openssh.com,curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group18-sha512,diffie-hellman-group16-sha512,diffie-hellman-group14-sha256,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 HostKeyAlgorithms ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,hmac-sha1,hmac-sha1-96-etm@openssh.com,hmac-sha1-96,hmac-md5-etm@openssh.com,hmac-md5,hmac-md5-96-etm@openssh.com,hmac-md5-96 diff --git a/src/test/resources/docker/sshd_config.openssh96 b/src/test/resources/docker/sshd_config.openssh96 index 8d7bcba1..12c4064f 100644 --- a/src/test/resources/docker/sshd_config.openssh96 +++ b/src/test/resources/docker/sshd_config.openssh96 @@ -14,7 +14,7 @@ HostKey /etc/ssh/ssh_host_ecdsa521_key HostKey /etc/ssh/ssh_host_ed25519_key HostKey /etc/ssh/ssh_host_rsa_key HostKey /etc/ssh/ssh_host_dsa_key -KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group18-sha512,diffie-hellman-group16-sha512,diffie-hellman-group14-sha256,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 +KexAlgorithms sntrup761x25519-sha512@openssh.com,curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group18-sha512,diffie-hellman-group16-sha512,diffie-hellman-group14-sha256,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 HostKeyAlgorithms ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,hmac-sha1,hmac-sha1-96-etm@openssh.com,hmac-sha1-96,hmac-md5-etm@openssh.com,hmac-md5,hmac-md5-96-etm@openssh.com,hmac-md5-96 From e90b350377ddd7c2ff3733c52d5c30a16f89bd96 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Sun, 24 Dec 2023 10:21:09 -0600 Subject: [PATCH 162/301] Clear intermediate copies of shared secret. --- src/main/java/com/jcraft/jsch/KeyExchange.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/jcraft/jsch/KeyExchange.java b/src/main/java/com/jcraft/jsch/KeyExchange.java index f418cb0a..17e2b144 100644 --- a/src/main/java/com/jcraft/jsch/KeyExchange.java +++ b/src/main/java/com/jcraft/jsch/KeyExchange.java @@ -236,6 +236,7 @@ protected byte[] normalize(byte[] secret) { if (secret.length > 1 && secret[0] == 0 && (secret[1] & 0x80) == 0) { byte[] tmp = new byte[secret.length - 1]; System.arraycopy(secret, 1, tmp, 0, tmp.length); + Util.bzero(secret); return normalize(tmp); } else { return secret; From 0682338741c78653315eb60ba559312f65bb1741 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Sun, 24 Dec 2023 10:21:29 -0600 Subject: [PATCH 163/301] Don't store unnecessary copy of shared secret. --- src/main/java/com/jcraft/jsch/jce/DH.java | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/jcraft/jsch/jce/DH.java b/src/main/java/com/jcraft/jsch/jce/DH.java index 114102ea..c8a7f888 100644 --- a/src/main/java/com/jcraft/jsch/jce/DH.java +++ b/src/main/java/com/jcraft/jsch/jce/DH.java @@ -39,8 +39,6 @@ public class DH implements com.jcraft.jsch.DH { BigInteger e; // my public key byte[] e_array; BigInteger f; // your public key - BigInteger K; // shared secret key - byte[] K_array; private KeyPairGenerator myKpairGen; private KeyAgreement myKeyAgree; @@ -66,17 +64,11 @@ public byte[] getE() throws Exception { @Override public byte[] getK() throws Exception { - if (K == null) { - KeyFactory myKeyFac = KeyFactory.getInstance("DH"); - DHPublicKeySpec keySpec = new DHPublicKeySpec(f, p, g); - PublicKey yourPubKey = myKeyFac.generatePublic(keySpec); - myKeyAgree.doPhase(yourPubKey, true); - byte[] mySharedSecret = myKeyAgree.generateSecret(); - K = new BigInteger(1, mySharedSecret); - K_array = K.toByteArray(); - K_array = mySharedSecret; - } - return K_array; + KeyFactory myKeyFac = KeyFactory.getInstance("DH"); + DHPublicKeySpec keySpec = new DHPublicKeySpec(f, p, g); + PublicKey yourPubKey = myKeyFac.generatePublic(keySpec); + myKeyAgree.doPhase(yourPubKey, true); + return myKeyAgree.generateSecret(); } @Override From 4b62cced47c20b9cc90b2406b12c2d48f1bee676 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Sun, 24 Dec 2023 10:28:58 -0600 Subject: [PATCH 164/301] Clear copy of shared secret. --- src/main/java/com/jcraft/jsch/KeyExchange.java | 5 +++++ src/main/java/com/jcraft/jsch/Session.java | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/jcraft/jsch/KeyExchange.java b/src/main/java/com/jcraft/jsch/KeyExchange.java index 17e2b144..c042d0aa 100644 --- a/src/main/java/com/jcraft/jsch/KeyExchange.java +++ b/src/main/java/com/jcraft/jsch/KeyExchange.java @@ -215,6 +215,11 @@ byte[] getK() { return K; } + void clearK() { + Util.bzero(K); + K = null; + } + byte[] getH() { return H; } diff --git a/src/main/java/com/jcraft/jsch/Session.java b/src/main/java/com/jcraft/jsch/Session.java index 3052b951..b2464fad 100644 --- a/src/main/java/com/jcraft/jsch/Session.java +++ b/src/main/java/com/jcraft/jsch/Session.java @@ -1461,7 +1461,11 @@ byte[] getSessionId() { } private void receive_newkeys(Buffer buf, KeyExchange kex) throws Exception { - updateKeys(kex); + try { + updateKeys(kex); + } finally { + kex.clearK(); + } in_kex = false; if (doStrictKex) { seqi = 0; From 42aace1185f4f672afd7becad69228669e99c658 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Mon, 25 Dec 2023 14:10:09 -0600 Subject: [PATCH 165/301] Change normalize() method to a timing safe implementation. --- .../java/com/jcraft/jsch/KeyExchange.java | 56 ++++++++++++++++--- 1 file changed, 49 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/jcraft/jsch/KeyExchange.java b/src/main/java/com/jcraft/jsch/KeyExchange.java index c042d0aa..3090391e 100644 --- a/src/main/java/com/jcraft/jsch/KeyExchange.java +++ b/src/main/java/com/jcraft/jsch/KeyExchange.java @@ -235,17 +235,59 @@ byte[] getHostKey() { /* * It seems JCE included in Oracle's Java7u6(and later) has suddenly changed its behavior. The * secrete generated by KeyAgreement#generateSecret() may start with 0, even if it is a positive - * value. + * value. See https://bugs.openjdk.org/browse/JDK-7146728. */ protected byte[] normalize(byte[] secret) { - if (secret.length > 1 && secret[0] == 0 && (secret[1] & 0x80) == 0) { - byte[] tmp = new byte[secret.length - 1]; - System.arraycopy(secret, 1, tmp, 0, tmp.length); - Util.bzero(secret); - return normalize(tmp); - } else { + // This should be a timing safe version of the following: + // if (secret.length > 1 && secret[0] == 0 && (secret[1] & 0x80) == 0) { + // byte[] tmp = new byte[secret.length - 1]; + // System.arraycopy(secret, 1, tmp, 0, tmp.length); + // Util.bzero(secret); + // return normalize(tmp); + // } else { + // return secret; + // } + + int len = secret.length; + if (len < 2) { return secret; } + + // secret[0] == 0 + int a = 0; + int s0 = secret[0] & 0xff; + for (int i = 0; i < 8; i++) { + int j = s0 >>> i; + j &= 0x1; + a |= j; + } + a ^= 0x1; + + // (secret[1..n] & 0x80) == 0 && secret[1..n] != 0 + int offset = 0; + for (int i = 1; i < len; i++) { + int j = secret[i] & 0x80; + j >>>= 7; + j ^= 0x1; + a &= j; + offset += a; + j = secret[i] & 0x7f; + for (int k = 0; k < 7; k++) { + int l = j >>> k; + l &= 0x1; + l ^= 0x1; + a &= l; + } + } + + len -= offset; + // Try to remain timing safe by performing an allocation + copy for leading bytes removed + byte[] foo = new byte[len]; + byte[] bar = new byte[offset]; + System.arraycopy(secret, 0, bar, 0, offset); + System.arraycopy(secret, offset, foo, 0, len); + Util.bzero(secret); + return foo; } protected boolean verify(String alg, byte[] K_S, int index, byte[] sig_of_H) throws Exception { From fe26a2c76516553b4fc39a2403fc6d458da5e237 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Mon, 25 Dec 2023 14:11:19 -0600 Subject: [PATCH 166/301] Add unit tests for normalize(), encodeAsMPInt() and encodeAsString() methods. --- .../java/com/jcraft/jsch/KeyExchangeTest.java | 249 ++++++++++++++++++ 1 file changed, 249 insertions(+) create mode 100644 src/test/java/com/jcraft/jsch/KeyExchangeTest.java diff --git a/src/test/java/com/jcraft/jsch/KeyExchangeTest.java b/src/test/java/com/jcraft/jsch/KeyExchangeTest.java new file mode 100644 index 00000000..ef5aae3c --- /dev/null +++ b/src/test/java/com/jcraft/jsch/KeyExchangeTest.java @@ -0,0 +1,249 @@ +package com.jcraft.jsch; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; + +import java.util.Arrays; +import java.util.Random; +import org.junit.jupiter.api.Test; + +public class KeyExchangeTest { + + private final Random random = new Random(); + private final KeyExchange kex = new TestKex(); + + @Test + public void testNormalize0() { + byte[] secret = new byte[0]; + doNormalize(secret); + } + + @Test + public void testNormalize1() { + KeyExchange kex = new TestKex(); + byte[] secret = new byte[1]; + for (int i = 0; i <= 0xff; i++) { + secret[0] = (byte) i; + doNormalize(secret); + } + } + + @Test + public void testNormalize2() { + KeyExchange kex = new TestKex(); + byte[] secret = new byte[2]; + for (int i = 0; i <= 0xff; i++) { + secret[0] = (byte) i; + for (int j = 0; j <= 0xff; j++) { + secret[1] = (byte) j; + doNormalize(secret); + } + } + } + + @Test + public void testNormalize3() { + KeyExchange kex = new TestKex(); + byte[] secret = new byte[3]; + for (int i = 0; i <= 0xff; i++) { + secret[0] = (byte) i; + for (int j = 0; j <= 0xff; j++) { + secret[1] = (byte) j; + for (int k = 0; k <= 0xff; k++) { + secret[2] = (byte) k; + doNormalize(secret); + } + } + } + } + + @Test + public void testNormalizeRandom() { + KeyExchange kex = new TestKex(); + for (int i = 0; i < 1000000; i++) { + byte[] secret = new byte[64]; + random.nextBytes(secret); + doNormalize(secret); + } + } + + @Test + public void testEncodeAsMPInt1() { + KeyExchange kex = new TestKex(); + byte[] secret = new byte[1]; + for (int i = 0; i <= 0xff; i++) { + secret[0] = (byte) i; + doEncodeAsMPInt(secret); + } + } + + @Test + public void testEncodeAsMPInt2() { + KeyExchange kex = new TestKex(); + byte[] secret = new byte[2]; + for (int i = 0; i <= 0xff; i++) { + secret[0] = (byte) i; + for (int j = 0; j <= 0xff; j++) { + secret[1] = (byte) j; + doEncodeAsMPInt(secret); + } + } + } + + @Test + public void testEncodeAsMPInt3() { + KeyExchange kex = new TestKex(); + byte[] secret = new byte[3]; + for (int i = 0; i <= 0xff; i++) { + secret[0] = (byte) i; + for (int j = 0; j <= 0xff; j++) { + secret[1] = (byte) j; + for (int k = 0; k <= 0xff; k++) { + secret[2] = (byte) k; + doEncodeAsMPInt(secret); + } + } + } + } + + @Test + public void testEncodeAsMPIntRandom() { + KeyExchange kex = new TestKex(); + for (int i = 0; i < 1000000; i++) { + byte[] secret = new byte[64]; + random.nextBytes(secret); + doEncodeAsMPInt(secret); + } + } + + @Test + public void testEncodeAsString0() { + KeyExchange kex = new TestKex(); + byte[] secret = new byte[0]; + doEncodeAsString(secret); + } + + @Test + public void testEncodeAsString1() { + KeyExchange kex = new TestKex(); + byte[] secret = new byte[1]; + for (int i = 0; i <= 0xff; i++) { + secret[0] = (byte) i; + doEncodeAsString(secret); + } + } + + @Test + public void testEncodeAsString2() { + KeyExchange kex = new TestKex(); + byte[] secret = new byte[2]; + for (int i = 0; i <= 0xff; i++) { + secret[0] = (byte) i; + for (int j = 0; j <= 0xff; j++) { + secret[1] = (byte) j; + doEncodeAsString(secret); + } + } + } + + @Test + public void testEncodeAsString3() { + KeyExchange kex = new TestKex(); + byte[] secret = new byte[3]; + for (int i = 0; i <= 0xff; i++) { + secret[0] = (byte) i; + for (int j = 0; j <= 0xff; j++) { + secret[1] = (byte) j; + for (int k = 0; k <= 0xff; k++) { + secret[2] = (byte) k; + doEncodeAsString(secret); + } + } + } + } + + @Test + public void testEncodeAsStringRandom() { + KeyExchange kex = new TestKex(); + for (int i = 0; i < 1000000; i++) { + byte[] secret = new byte[64]; + random.nextBytes(secret); + doEncodeAsString(secret); + } + } + + private void doNormalize(byte[] secret) { + byte[] expected = normalize(Arrays.copyOf(secret, secret.length)); + byte[] actual = kex.normalize(Arrays.copyOf(secret, secret.length)); + try { + assertArrayEquals(expected, actual); + } catch (Exception e) { + System.out.println(" secret = " + Arrays.toString(secret)); + System.out.println("expected = " + Arrays.toString(expected)); + System.out.println(" actual = " + Arrays.toString(actual)); + throw e; + } + } + + // Copy of old implementation + private static byte[] normalize(byte[] secret) { + if (secret.length > 1 && secret[0] == 0 && (secret[1] & 0x80) == 0) { + byte[] tmp = new byte[secret.length - 1]; + System.arraycopy(secret, 1, tmp, 0, tmp.length); + Util.bzero(secret); + return normalize(tmp); + } else { + return secret; + } + } + + private void doEncodeAsMPInt(byte[] secret) { + Buffer b = new Buffer(); + b.putMPInt(secret); + byte[] expected = new byte[b.getLength()]; + b.getByte(expected); + byte[] actual = kex.encodeAsMPInt(Arrays.copyOf(secret, secret.length)); + try { + assertArrayEquals(expected, actual); + } catch (Throwable t) { + System.out.println(" secret = " + Arrays.toString(secret)); + System.out.println("expected = " + Arrays.toString(expected)); + System.out.println(" actual = " + Arrays.toString(actual)); + throw t; + } + } + + private void doEncodeAsString(byte[] secret) { + Buffer b = new Buffer(); + b.putString(secret); + byte[] expected = new byte[b.getLength()]; + b.getByte(expected); + byte[] actual = kex.encodeAsString(Arrays.copyOf(secret, secret.length)); + try { + assertArrayEquals(expected, actual); + } catch (Throwable t) { + System.out.println(" secret = " + Arrays.toString(secret)); + System.out.println("expected = " + Arrays.toString(expected)); + System.out.println(" actual = " + Arrays.toString(actual)); + throw t; + } + } + + static class TestKex extends KeyExchange { + + @Override + public void init(Session session, byte[] V_S, byte[] V_C, byte[] I_S, byte[] I_C) + throws Exception { + throw new UnsupportedOperationException("Not supported"); + } + + @Override + public boolean next(Buffer buf) throws Exception { + throw new UnsupportedOperationException("Not supported"); + } + + @Override + public int getState() { + throw new UnsupportedOperationException("Not supported"); + } + } +} From 76f1bdb630682da7d91372c8af3438cfb5ad84b6 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Tue, 2 Jan 2024 21:22:28 -0600 Subject: [PATCH 167/301] Switch to bnd-maven-plugin in order to support Multi-Release OSGi bundle JAR's via supplemental manifest files. --- .github/workflows/maven.yml | 2 +- pom.xml | 72 +++++++++++++++++++++++++------------ 2 files changed, 50 insertions(+), 24 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 55e530ea..22d61ccf 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -49,7 +49,7 @@ jobs: java-version: ${{ matrix.java }} check-latest: true - name: Test with Maven - run: ./mvnw -B -V -e -P coverage verify -Denforcer.skip=true -Dmaven.resources.skip=true -Dmaven.main.skip=true -Dassembly.skipAssembly=true -Dmaven.javadoc.skip=true -DskipITs=false + run: ./mvnw -B -V -e -P coverage verify -Denforcer.skip=true -Dmaven.resources.skip=true -Dmaven.main.skip=true -Dbnd.skip=true -Dassembly.skipAssembly=true -Dmaven.javadoc.skip=true -Dcyclonedx.skip=true -DskipITs=false - uses: actions/upload-artifact@v4 with: name: java-${{ matrix.java }}-testresults diff --git a/pom.xml b/pom.xml index c479b830..4df83993 100644 --- a/pom.xml +++ b/pom.xml @@ -47,12 +47,14 @@ +9 + mwiede Matthias Wiedemann mwiede@gmx.de Community https://github.com/mwiede + norrisjeremy Jeremy Norris Community https://github.com/norrisjeremy @@ -254,7 +256,7 @@ - 16 + 17 @@ -403,31 +405,32 @@ - org.apache.felix - maven-bundle-plugin - 5.1.9 + biz.aQute.bnd + bnd-maven-plugin + 7.0.0 - - com.jcraft.jsch;-noimport:=true - - + ]]> - - - bundle-manifest - process-classes - - manifest - - - org.apache.maven.plugins @@ -862,5 +865,28 @@ + + bnd + + [17,) + + + + + biz.aQute.bnd + bnd-maven-plugin + + + bnd-process + process-classes + + bnd-process + + + + + + + From ee570b5a21737b2e9d895a593734c62ae1deb239 Mon Sep 17 00:00:00 2001 From: release-bot Date: Wed, 3 Jan 2024 09:19:56 +0000 Subject: [PATCH 168/301] [maven-release-plugin] prepare release jsch-0.2.16 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 3db24d7d..c00fa630 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.mwiede jsch jar - 0.2.16-SNAPSHOT + 0.2.16 JSch https://github.com/mwiede/jsch JSch is a pure Java implementation of SSH2 @@ -12,7 +12,7 @@ scm:git:https://github.com/mwiede/jsch.git scm:git:https://github.com/mwiede/jsch.git https://github.com/mwiede/jsch - HEAD + jsch-0.2.16 @@ -75,7 +75,7 @@ - 2023-12-19T16:07:05Z + 2024-01-03T09:18:14Z UTF-8 UTF-8 true From 159e6e967b20ac2fcbf8bb6d851348dcd2f768f5 Mon Sep 17 00:00:00 2001 From: release-bot Date: Wed, 3 Jan 2024 09:19:58 +0000 Subject: [PATCH 169/301] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index c00fa630..2fa1711c 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.mwiede jsch jar - 0.2.16 + 0.2.17-SNAPSHOT JSch https://github.com/mwiede/jsch JSch is a pure Java implementation of SSH2 @@ -12,7 +12,7 @@ scm:git:https://github.com/mwiede/jsch.git scm:git:https://github.com/mwiede/jsch.git https://github.com/mwiede/jsch - jsch-0.2.16 + HEAD @@ -75,7 +75,7 @@ - 2024-01-03T09:18:14Z + 2024-01-03T09:19:58Z UTF-8 UTF-8 true From 87f277ac87f94fd5f210e593d14a17fd0ab421f3 Mon Sep 17 00:00:00 2001 From: Matthias Wiedemann Date: Fri, 5 Jan 2024 19:41:27 +0100 Subject: [PATCH 170/301] Update Readme.md --- Readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 60d76a7c..11d96bb3 100644 --- a/Readme.md +++ b/Readme.md @@ -33,7 +33,7 @@ with com.github.mwiede jsch - 0.2.15 + 0.2.16 ``` @@ -43,7 +43,7 @@ When you have an artifact `foo:bar`, which contains `com.jcraft:jsch` as a trans com.github.mwiede jsch - 0.2.15 + 0.2.16 foo From 0d2ffbf9f52b99e39affdcb32216dd1d45b89387 Mon Sep 17 00:00:00 2001 From: Matthias Wiedemann Date: Fri, 5 Jan 2024 19:43:13 +0100 Subject: [PATCH 171/301] Update ChangeLog.md --- ChangeLog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 22bb7fc1..1fb02217 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,7 @@ +* [0.2.16](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.16) + * Add support for sntrup761x25519-sha512@openssh.com KEX algorithm. + * Switch to bnd-maven-plugin in order to support Multi-Release OSGi bundle JAR's via supplemental manifest files. + * Introduce JSchProxyException to replace generic JschException in Proxy implementations by @mvegter in https://github.com/mwiede/jsch/pull/467 * [0.2.15](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.15) * address [CVE-2023-48795](https://nvd.nist.gov/vuln/detail/CVE-2023-48795) by adding support for new strict key exchange extension * Add support for `ext-info-in-auth@openssh.com` extension From 69db93ab88d3ab3c0d92e6c83054db8e0365e2dd Mon Sep 17 00:00:00 2001 From: Matthias Wiedemann Date: Mon, 8 Jan 2024 18:36:07 +0100 Subject: [PATCH 172/301] Update Readme.md added entry to faq --- Readme.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 11d96bb3..99e09659 100644 --- a/Readme.md +++ b/Readme.md @@ -60,8 +60,10 @@ When you have an artifact `foo:bar`, which contains `com.jcraft:jsch` as a trans *Addition*: You can further exclude any of `com.jcraft:jsch.agentproxy.jsch`, `com.jcraft:jsch.agentproxy.core` or `com.jcraft:jsch.agentproxy.pageant`, because these modules where integrated in this fork (see release notes of [0.1.66](https://github.com/mwiede/jsch/releases/tag/jsch-0.1.66)). ## FAQ +### Which is the minimum Java version required? + * Java 8. For more limitations, see next answer. ### Are ssh-ed25519, ssh-ed448, curve25519-sha256, curve448-sha512 & chacha20-poly1305@openssh.com supported? - * This library is a Multi-Release-jar, which means that you can only use certain features when a more recent Java version is used. + * This library is a [Multi-Release-jar](https://openjdk.org/jeps/238), which means that you can only use certain features when a more recent Java version is used. * In order to use ssh-ed25519 & ssh-ed448, you must use at least Java 15 or add [Bouncy Castle](https://www.bouncycastle.org/java.html) (bcprov-jdk18on) to the classpath. * In order to use curve25519-sha256 & curve448-sha512, you must use at least Java 11 or add [Bouncy Castle](https://www.bouncycastle.org/java.html) (bcprov-jdk18on) to the classpath. * In order to use chacha20-poly1305@openssh.com, you must add [Bouncy Castle](https://www.bouncycastle.org/java.html) (bcprov-jdk18on) to the classpath. From 5f35073bfbcf9a0fe8a5b1a2b9291e557cffe158 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jan 2024 19:47:44 +0000 Subject: [PATCH 173/301] Bump org.slf4j:slf4j-api from 2.0.10 to 2.0.11 Bumps org.slf4j:slf4j-api from 2.0.10 to 2.0.11. --- updated-dependencies: - dependency-name: org.slf4j:slf4j-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2fa1711c..4befcc87 100644 --- a/pom.xml +++ b/pom.xml @@ -132,7 +132,7 @@ org.slf4j slf4j-api - 2.0.10 + 2.0.11 true From c86a28035db488449be4905b1afe15a880e96afb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jan 2024 19:47:45 +0000 Subject: [PATCH 174/301] Bump com.kohlschutter:compiler-annotations from 1.6.6 to 1.6.7 Bumps com.kohlschutter:compiler-annotations from 1.6.6 to 1.6.7. --- updated-dependencies: - dependency-name: com.kohlschutter:compiler-annotations dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2fa1711c..76317d3c 100644 --- a/pom.xml +++ b/pom.xml @@ -101,7 +101,7 @@ com.kohlschutter compiler-annotations - 1.6.6 + 1.6.7 provided true From 1515a61b099236623803d625bb9922f3e11f208a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jan 2024 19:47:54 +0000 Subject: [PATCH 175/301] Bump errorprone.version from 2.24.0 to 2.24.1 Bumps `errorprone.version` from 2.24.0 to 2.24.1. Updates `com.google.errorprone:error_prone_annotations` from 2.24.0 to 2.24.1 - [Release notes](https://github.com/google/error-prone/releases) - [Commits](https://github.com/google/error-prone/compare/v2.24.0...v2.24.1) Updates `com.google.errorprone:error_prone_core` from 2.24.0 to 2.24.1 - [Release notes](https://github.com/google/error-prone/releases) - [Commits](https://github.com/google/error-prone/compare/v2.24.0...v2.24.1) --- updated-dependencies: - dependency-name: com.google.errorprone:error_prone_annotations dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.google.errorprone:error_prone_core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2fa1711c..365d6648 100644 --- a/pom.xml +++ b/pom.xml @@ -82,7 +82,7 @@ 2.8.3 5.14.0 2.22.1 - 2.24.0 + 2.24.1 3.2.3 From 34a071d16c178835a9c25d266596aef63fa800fd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Jan 2024 19:50:34 +0000 Subject: [PATCH 176/301] Bump surefire.version from 3.2.3 to 3.2.5 Bumps `surefire.version` from 3.2.3 to 3.2.5. Updates `org.apache.maven.plugins:maven-surefire-plugin` from 3.2.3 to 3.2.5 - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.3...surefire-3.2.5) Updates `org.apache.maven.plugins:maven-failsafe-plugin` from 3.2.3 to 3.2.5 - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.3...surefire-3.2.5) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.maven.plugins:maven-failsafe-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bf78883c..01dbd403 100644 --- a/pom.xml +++ b/pom.xml @@ -83,7 +83,7 @@ 5.14.0 2.22.1 2.24.1 - 3.2.3 + 3.2.5 From 40447d234c50dc61c149fd61958cfd616f3202a3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Jan 2024 19:50:40 +0000 Subject: [PATCH 177/301] Bump org.codehaus.mojo:flatten-maven-plugin from 1.5.0 to 1.6.0 Bumps [org.codehaus.mojo:flatten-maven-plugin](https://github.com/mojohaus/flatten-maven-plugin) from 1.5.0 to 1.6.0. - [Release notes](https://github.com/mojohaus/flatten-maven-plugin/releases) - [Commits](https://github.com/mojohaus/flatten-maven-plugin/compare/1.5.0...1.6.0) --- updated-dependencies: - dependency-name: org.codehaus.mojo:flatten-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bf78883c..c43740ad 100644 --- a/pom.xml +++ b/pom.xml @@ -270,7 +270,7 @@ org.codehaus.mojo flatten-maven-plugin - 1.5.0 + 1.6.0 ossrh all From 697cbbbd07c89a1f697a038ff2a5b285b16cd703 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jan 2024 19:07:04 +0000 Subject: [PATCH 178/301] Bump org.cyclonedx:cyclonedx-maven-plugin from 2.7.10 to 2.7.11 Bumps [org.cyclonedx:cyclonedx-maven-plugin](https://github.com/CycloneDX/cyclonedx-maven-plugin) from 2.7.10 to 2.7.11. - [Release notes](https://github.com/CycloneDX/cyclonedx-maven-plugin/releases) - [Commits](https://github.com/CycloneDX/cyclonedx-maven-plugin/compare/cyclonedx-maven-plugin-2.7.10...cyclonedx-maven-plugin-2.7.11) --- updated-dependencies: - dependency-name: org.cyclonedx:cyclonedx-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cadb6f19..ea50cd92 100644 --- a/pom.xml +++ b/pom.xml @@ -546,7 +546,7 @@ org.cyclonedx cyclonedx-maven-plugin - 2.7.10 + 2.7.11 false false From 5e62864689ed5a84345d4082ba6d5cb125c8d88e Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Mon, 15 Jan 2024 13:28:13 -0600 Subject: [PATCH 179/301] Organize imports and remove unused imports. --- .../com/jcraft/jsch/ChannelAgentForwarding.java | 1 - src/main/java/com/jcraft/jsch/ChannelExec.java | 1 - src/main/java/com/jcraft/jsch/ChannelShell.java | 2 -- src/main/java/com/jcraft/jsch/IdentityFile.java | 2 -- .../com/jcraft/jsch/JUnixSocketFactory.java | 10 +++------- src/main/java/com/jcraft/jsch/SftpATTRS.java | 1 - src/main/java/com/jcraft/jsch/SftpStatVFS.java | 3 --- .../jcraft/jsch/UnixDomainSocketFactory.java | 3 --- .../java/com/jcraft/jsch/bc/SignatureEdDSA.java | 3 +-- src/main/java/com/jcraft/jsch/bc/XDH.java | 1 - src/main/java/com/jcraft/jsch/jce/ARCFOUR.java | 1 - .../java/com/jcraft/jsch/jce/ARCFOUR128.java | 1 - .../java/com/jcraft/jsch/jce/ARCFOUR256.java | 1 - src/main/java/com/jcraft/jsch/jce/DH.java | 2 +- src/main/java/com/jcraft/jsch/jce/ECDHN.java | 2 +- src/main/java/com/jcraft/jsch/jce/HMACMD5.java | 4 ---- .../java/com/jcraft/jsch/jce/HMACMD5ETM.java | 4 ---- .../com/jcraft/jsch/jce/KeyPairGenECDSA.java | 2 +- src/main/java/com/jcraft/jsch/jce/PBKDF.java | 6 ++---- src/main/java/com/jcraft/jsch/jce/PBKDF2.java | 3 +-- .../java/com/jcraft/jsch/jce/SignatureDSA.java | 2 +- .../com/jcraft/jsch/jce/SignatureECDSAN.java | 2 +- .../java/com/jcraft/jsch/jce/SignatureRSAN.java | 2 +- .../java/com/jcraft/jsch/jzlib/Compression.java | 2 +- .../java/com/jcraft/jsch/jzlib/GZIPHeader.java | 1 - .../com/jcraft/jsch/jce/SignatureEdDSA.java | 2 +- .../jcraft/jsch/UnixDomainSocketFactory.java | 3 --- .../java/com/jcraft/jsch/Algorithms4IT.java | 1 - src/test/java/com/jcraft/jsch/JSchTest.java | 7 +++---- src/test/java/com/jcraft/jsch/KeyPair2IT.java | 9 ++++----- src/test/java/com/jcraft/jsch/KeyPair2Test.java | 11 +++++------ src/test/java/com/jcraft/jsch/KeyPairIT.java | 9 ++++----- src/test/java/com/jcraft/jsch/KeyPairTest.java | 17 ++++++++--------- .../java/com/jcraft/jsch/KnownHostsTest.java | 2 +- .../java/com/jcraft/jsch/OpenSSHConfigTest.java | 9 ++++----- src/test/java/com/jcraft/jsch/SessionTest.java | 10 ++++------ 36 files changed, 48 insertions(+), 94 deletions(-) diff --git a/src/main/java/com/jcraft/jsch/ChannelAgentForwarding.java b/src/main/java/com/jcraft/jsch/ChannelAgentForwarding.java index eab9cbdb..d5d133c9 100644 --- a/src/main/java/com/jcraft/jsch/ChannelAgentForwarding.java +++ b/src/main/java/com/jcraft/jsch/ChannelAgentForwarding.java @@ -27,7 +27,6 @@ package com.jcraft.jsch; import java.io.IOException; -import java.net.*; import java.util.Vector; class ChannelAgentForwarding extends Channel { diff --git a/src/main/java/com/jcraft/jsch/ChannelExec.java b/src/main/java/com/jcraft/jsch/ChannelExec.java index 4f31d480..202b06ce 100644 --- a/src/main/java/com/jcraft/jsch/ChannelExec.java +++ b/src/main/java/com/jcraft/jsch/ChannelExec.java @@ -27,7 +27,6 @@ package com.jcraft.jsch; import java.io.*; -import java.util.*; public class ChannelExec extends ChannelSession { diff --git a/src/main/java/com/jcraft/jsch/ChannelShell.java b/src/main/java/com/jcraft/jsch/ChannelShell.java index 2dc582f0..7fc3d3d3 100644 --- a/src/main/java/com/jcraft/jsch/ChannelShell.java +++ b/src/main/java/com/jcraft/jsch/ChannelShell.java @@ -26,8 +26,6 @@ package com.jcraft.jsch; -import java.util.*; - public class ChannelShell extends ChannelSession { ChannelShell() { diff --git a/src/main/java/com/jcraft/jsch/IdentityFile.java b/src/main/java/com/jcraft/jsch/IdentityFile.java index af55a0b4..f9aead36 100644 --- a/src/main/java/com/jcraft/jsch/IdentityFile.java +++ b/src/main/java/com/jcraft/jsch/IdentityFile.java @@ -26,8 +26,6 @@ package com.jcraft.jsch; -import java.io.*; - class IdentityFile implements Identity { private KeyPair kpair; private String identity; diff --git a/src/main/java/com/jcraft/jsch/JUnixSocketFactory.java b/src/main/java/com/jcraft/jsch/JUnixSocketFactory.java index d3038cdd..af15017f 100644 --- a/src/main/java/com/jcraft/jsch/JUnixSocketFactory.java +++ b/src/main/java/com/jcraft/jsch/JUnixSocketFactory.java @@ -26,17 +26,13 @@ package com.jcraft.jsch; -import com.jcraft.jsch.AgentProxyException; -import com.jcraft.jsch.USocketFactory; - -import org.newsclub.net.unix.AFUNIXServerSocketChannel; -import org.newsclub.net.unix.AFUNIXSocketChannel; -import org.newsclub.net.unix.AFUNIXSocketAddress; - import java.io.IOException; import java.nio.channels.ServerSocketChannel; import java.nio.channels.SocketChannel; import java.nio.file.Path; +import org.newsclub.net.unix.AFUNIXServerSocketChannel; +import org.newsclub.net.unix.AFUNIXSocketChannel; +import org.newsclub.net.unix.AFUNIXSocketAddress; public class JUnixSocketFactory implements USocketFactory { diff --git a/src/main/java/com/jcraft/jsch/SftpATTRS.java b/src/main/java/com/jcraft/jsch/SftpATTRS.java index e7180bde..84151085 100644 --- a/src/main/java/com/jcraft/jsch/SftpATTRS.java +++ b/src/main/java/com/jcraft/jsch/SftpATTRS.java @@ -26,7 +26,6 @@ package com.jcraft.jsch; -import java.text.SimpleDateFormat; import java.util.Date; /* diff --git a/src/main/java/com/jcraft/jsch/SftpStatVFS.java b/src/main/java/com/jcraft/jsch/SftpStatVFS.java index 257b005e..193e97b0 100644 --- a/src/main/java/com/jcraft/jsch/SftpStatVFS.java +++ b/src/main/java/com/jcraft/jsch/SftpStatVFS.java @@ -26,9 +26,6 @@ package com.jcraft.jsch; -import java.text.SimpleDateFormat; -import java.util.Date; - public class SftpStatVFS { /* diff --git a/src/main/java/com/jcraft/jsch/UnixDomainSocketFactory.java b/src/main/java/com/jcraft/jsch/UnixDomainSocketFactory.java index 280cdbcd..f5dcf344 100644 --- a/src/main/java/com/jcraft/jsch/UnixDomainSocketFactory.java +++ b/src/main/java/com/jcraft/jsch/UnixDomainSocketFactory.java @@ -26,9 +26,6 @@ package com.jcraft.jsch; -import com.jcraft.jsch.AgentProxyException; -import com.jcraft.jsch.USocketFactory; - import java.io.IOException; import java.nio.channels.ServerSocketChannel; import java.nio.channels.SocketChannel; diff --git a/src/main/java/com/jcraft/jsch/bc/SignatureEdDSA.java b/src/main/java/com/jcraft/jsch/bc/SignatureEdDSA.java index cdf33e5e..ca9221d6 100644 --- a/src/main/java/com/jcraft/jsch/bc/SignatureEdDSA.java +++ b/src/main/java/com/jcraft/jsch/bc/SignatureEdDSA.java @@ -26,13 +26,12 @@ package com.jcraft.jsch.bc; +import com.jcraft.jsch.Buffer; import java.nio.charset.StandardCharsets; import java.security.*; -import java.util.Arrays; import org.bouncycastle.crypto.Signer; import org.bouncycastle.crypto.params.*; import org.bouncycastle.crypto.signers.*; -import com.jcraft.jsch.Buffer; abstract class SignatureEdDSA implements com.jcraft.jsch.SignatureEdDSA { diff --git a/src/main/java/com/jcraft/jsch/bc/XDH.java b/src/main/java/com/jcraft/jsch/bc/XDH.java index 7f70b9a2..fbaf306f 100644 --- a/src/main/java/com/jcraft/jsch/bc/XDH.java +++ b/src/main/java/com/jcraft/jsch/bc/XDH.java @@ -27,7 +27,6 @@ package com.jcraft.jsch.bc; import java.security.*; -import java.util.Arrays; import org.bouncycastle.crypto.params.*; public class XDH implements com.jcraft.jsch.XDH { diff --git a/src/main/java/com/jcraft/jsch/jce/ARCFOUR.java b/src/main/java/com/jcraft/jsch/jce/ARCFOUR.java index d2a71fd2..ebb99961 100644 --- a/src/main/java/com/jcraft/jsch/jce/ARCFOUR.java +++ b/src/main/java/com/jcraft/jsch/jce/ARCFOUR.java @@ -27,7 +27,6 @@ package com.jcraft.jsch.jce; import com.jcraft.jsch.Cipher; -import javax.crypto.*; import javax.crypto.spec.*; public class ARCFOUR implements Cipher { diff --git a/src/main/java/com/jcraft/jsch/jce/ARCFOUR128.java b/src/main/java/com/jcraft/jsch/jce/ARCFOUR128.java index b0962fea..3db7fda2 100644 --- a/src/main/java/com/jcraft/jsch/jce/ARCFOUR128.java +++ b/src/main/java/com/jcraft/jsch/jce/ARCFOUR128.java @@ -27,7 +27,6 @@ package com.jcraft.jsch.jce; import com.jcraft.jsch.Cipher; -import javax.crypto.*; import javax.crypto.spec.*; public class ARCFOUR128 implements Cipher { diff --git a/src/main/java/com/jcraft/jsch/jce/ARCFOUR256.java b/src/main/java/com/jcraft/jsch/jce/ARCFOUR256.java index 6e160382..c618f16a 100644 --- a/src/main/java/com/jcraft/jsch/jce/ARCFOUR256.java +++ b/src/main/java/com/jcraft/jsch/jce/ARCFOUR256.java @@ -27,7 +27,6 @@ package com.jcraft.jsch.jce; import com.jcraft.jsch.Cipher; -import javax.crypto.*; import javax.crypto.spec.*; public class ARCFOUR256 implements Cipher { diff --git a/src/main/java/com/jcraft/jsch/jce/DH.java b/src/main/java/com/jcraft/jsch/jce/DH.java index c8a7f888..48072e5c 100644 --- a/src/main/java/com/jcraft/jsch/jce/DH.java +++ b/src/main/java/com/jcraft/jsch/jce/DH.java @@ -26,12 +26,12 @@ package com.jcraft.jsch.jce; +import com.jcraft.jsch.JSchException; import java.math.BigInteger; import java.security.*; import javax.crypto.*; import javax.crypto.interfaces.*; import javax.crypto.spec.*; -import com.jcraft.jsch.JSchException; public class DH implements com.jcraft.jsch.DH { BigInteger p; diff --git a/src/main/java/com/jcraft/jsch/jce/ECDHN.java b/src/main/java/com/jcraft/jsch/jce/ECDHN.java index 9cca4b35..9969a070 100644 --- a/src/main/java/com/jcraft/jsch/jce/ECDHN.java +++ b/src/main/java/com/jcraft/jsch/jce/ECDHN.java @@ -28,9 +28,9 @@ import java.math.BigInteger; import java.security.*; -import javax.crypto.*; import java.security.spec.*; import java.security.interfaces.*; +import javax.crypto.*; public class ECDHN implements com.jcraft.jsch.ECDH { byte[] Q_array; diff --git a/src/main/java/com/jcraft/jsch/jce/HMACMD5.java b/src/main/java/com/jcraft/jsch/jce/HMACMD5.java index 00581652..681d3baa 100644 --- a/src/main/java/com/jcraft/jsch/jce/HMACMD5.java +++ b/src/main/java/com/jcraft/jsch/jce/HMACMD5.java @@ -26,10 +26,6 @@ package com.jcraft.jsch.jce; -import com.jcraft.jsch.MAC; -import javax.crypto.*; -import javax.crypto.spec.*; - public class HMACMD5 extends HMAC { public HMACMD5() { name = "hmac-md5"; diff --git a/src/main/java/com/jcraft/jsch/jce/HMACMD5ETM.java b/src/main/java/com/jcraft/jsch/jce/HMACMD5ETM.java index 97b835b9..e490fad4 100644 --- a/src/main/java/com/jcraft/jsch/jce/HMACMD5ETM.java +++ b/src/main/java/com/jcraft/jsch/jce/HMACMD5ETM.java @@ -26,10 +26,6 @@ package com.jcraft.jsch.jce; -import com.jcraft.jsch.MAC; -import javax.crypto.*; -import javax.crypto.spec.*; - public class HMACMD5ETM extends HMACMD5 { public HMACMD5ETM() { name = "hmac-md5-etm@openssh.com"; diff --git a/src/main/java/com/jcraft/jsch/jce/KeyPairGenECDSA.java b/src/main/java/com/jcraft/jsch/jce/KeyPairGenECDSA.java index d0587e1e..b77805c7 100644 --- a/src/main/java/com/jcraft/jsch/jce/KeyPairGenECDSA.java +++ b/src/main/java/com/jcraft/jsch/jce/KeyPairGenECDSA.java @@ -26,10 +26,10 @@ package com.jcraft.jsch.jce; +import com.jcraft.jsch.JSchException; import java.security.*; import java.security.interfaces.*; import java.security.spec.*; -import com.jcraft.jsch.JSchException; public class KeyPairGenECDSA implements com.jcraft.jsch.KeyPairGenECDSA { byte[] d; diff --git a/src/main/java/com/jcraft/jsch/jce/PBKDF.java b/src/main/java/com/jcraft/jsch/jce/PBKDF.java index 8cc6a315..85a031df 100644 --- a/src/main/java/com/jcraft/jsch/jce/PBKDF.java +++ b/src/main/java/com/jcraft/jsch/jce/PBKDF.java @@ -26,12 +26,10 @@ package com.jcraft.jsch.jce; -import com.jcraft.jsch.HASH; - -import javax.crypto.spec.PBEKeySpec; -import javax.crypto.SecretKeyFactory; import java.security.spec.InvalidKeySpecException; import java.security.NoSuchAlgorithmException; +import javax.crypto.spec.PBEKeySpec; +import javax.crypto.SecretKeyFactory; /** * Use PBKDF2 instead. diff --git a/src/main/java/com/jcraft/jsch/jce/PBKDF2.java b/src/main/java/com/jcraft/jsch/jce/PBKDF2.java index ef466e15..527661f4 100644 --- a/src/main/java/com/jcraft/jsch/jce/PBKDF2.java +++ b/src/main/java/com/jcraft/jsch/jce/PBKDF2.java @@ -26,10 +26,9 @@ package com.jcraft.jsch.jce; +import java.security.spec.InvalidKeySpecException; import javax.crypto.spec.PBEKeySpec; import javax.crypto.SecretKeyFactory; -import java.security.spec.InvalidKeySpecException; -import java.security.NoSuchAlgorithmException; abstract class PBKDF2 implements com.jcraft.jsch.PBKDF2 { private SecretKeyFactory skf; diff --git a/src/main/java/com/jcraft/jsch/jce/SignatureDSA.java b/src/main/java/com/jcraft/jsch/jce/SignatureDSA.java index 7a62612a..9462fabb 100644 --- a/src/main/java/com/jcraft/jsch/jce/SignatureDSA.java +++ b/src/main/java/com/jcraft/jsch/jce/SignatureDSA.java @@ -26,11 +26,11 @@ package com.jcraft.jsch.jce; +import com.jcraft.jsch.Buffer; import java.math.BigInteger; import java.nio.charset.StandardCharsets; import java.security.*; import java.security.spec.*; -import com.jcraft.jsch.Buffer; public class SignatureDSA implements com.jcraft.jsch.SignatureDSA { diff --git a/src/main/java/com/jcraft/jsch/jce/SignatureECDSAN.java b/src/main/java/com/jcraft/jsch/jce/SignatureECDSAN.java index b11755bb..79eb93f7 100644 --- a/src/main/java/com/jcraft/jsch/jce/SignatureECDSAN.java +++ b/src/main/java/com/jcraft/jsch/jce/SignatureECDSAN.java @@ -26,10 +26,10 @@ package com.jcraft.jsch.jce; +import com.jcraft.jsch.Buffer; import java.math.BigInteger; import java.security.*; import java.security.spec.*; -import com.jcraft.jsch.Buffer; abstract class SignatureECDSAN implements com.jcraft.jsch.SignatureECDSA { diff --git a/src/main/java/com/jcraft/jsch/jce/SignatureRSAN.java b/src/main/java/com/jcraft/jsch/jce/SignatureRSAN.java index 1a98267f..b0fdd25c 100644 --- a/src/main/java/com/jcraft/jsch/jce/SignatureRSAN.java +++ b/src/main/java/com/jcraft/jsch/jce/SignatureRSAN.java @@ -26,11 +26,11 @@ package com.jcraft.jsch.jce; +import com.jcraft.jsch.Buffer; import java.math.BigInteger; import java.nio.charset.StandardCharsets; import java.security.*; import java.security.spec.*; -import com.jcraft.jsch.Buffer; abstract class SignatureRSAN implements com.jcraft.jsch.SignatureRSA { diff --git a/src/main/java/com/jcraft/jsch/jzlib/Compression.java b/src/main/java/com/jcraft/jsch/jzlib/Compression.java index 809373d8..747b5eca 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/Compression.java +++ b/src/main/java/com/jcraft/jsch/jzlib/Compression.java @@ -26,11 +26,11 @@ package com.jcraft.jsch.jzlib; -import java.util.function.Supplier; import com.jcraft.jsch.JSch; import com.jcraft.jsch.Logger; import com.jcraft.jsch.Session; import java.io.UncheckedIOException; +import java.util.function.Supplier; public class Compression implements com.jcraft.jsch.Compression { static private final int BUF_SIZE = 4096; diff --git a/src/main/java/com/jcraft/jsch/jzlib/GZIPHeader.java b/src/main/java/com/jcraft/jsch/jzlib/GZIPHeader.java index bfa2f245..8c69a1cd 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/GZIPHeader.java +++ b/src/main/java/com/jcraft/jsch/jzlib/GZIPHeader.java @@ -31,7 +31,6 @@ package com.jcraft.jsch.jzlib; import java.nio.charset.StandardCharsets; -import java.util.Arrays; /** * @see http://www.ietf.org/rfc/rfc1952.txt diff --git a/src/main/java15/com/jcraft/jsch/jce/SignatureEdDSA.java b/src/main/java15/com/jcraft/jsch/jce/SignatureEdDSA.java index ee0d8828..7a98724c 100644 --- a/src/main/java15/com/jcraft/jsch/jce/SignatureEdDSA.java +++ b/src/main/java15/com/jcraft/jsch/jce/SignatureEdDSA.java @@ -26,12 +26,12 @@ package com.jcraft.jsch.jce; +import com.jcraft.jsch.Buffer; import java.math.BigInteger; import java.nio.charset.StandardCharsets; import java.security.*; import java.security.spec.*; import java.util.Arrays; -import com.jcraft.jsch.Buffer; abstract class SignatureEdDSA implements com.jcraft.jsch.SignatureEdDSA { diff --git a/src/main/java16/com/jcraft/jsch/UnixDomainSocketFactory.java b/src/main/java16/com/jcraft/jsch/UnixDomainSocketFactory.java index 48995918..cb0f42f5 100644 --- a/src/main/java16/com/jcraft/jsch/UnixDomainSocketFactory.java +++ b/src/main/java16/com/jcraft/jsch/UnixDomainSocketFactory.java @@ -26,9 +26,6 @@ package com.jcraft.jsch; -import com.jcraft.jsch.AgentProxyException; -import com.jcraft.jsch.USocketFactory; - import java.io.IOException; import java.net.StandardProtocolFamily; import java.net.UnixDomainSocketAddress; diff --git a/src/test/java/com/jcraft/jsch/Algorithms4IT.java b/src/test/java/com/jcraft/jsch/Algorithms4IT.java index 0d5632f9..4d01b5b7 100644 --- a/src/test/java/com/jcraft/jsch/Algorithms4IT.java +++ b/src/test/java/com/jcraft/jsch/Algorithms4IT.java @@ -1,7 +1,6 @@ package com.jcraft.jsch; import static java.nio.charset.StandardCharsets.UTF_8; -import static java.util.stream.Collectors.toList; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/src/test/java/com/jcraft/jsch/JSchTest.java b/src/test/java/com/jcraft/jsch/JSchTest.java index f1e00a36..52ce1c9b 100644 --- a/src/test/java/com/jcraft/jsch/JSchTest.java +++ b/src/test/java/com/jcraft/jsch/JSchTest.java @@ -1,11 +1,10 @@ package com.jcraft.jsch; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; import java.util.Hashtable; - -import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; class JSchTest { diff --git a/src/test/java/com/jcraft/jsch/KeyPair2IT.java b/src/test/java/com/jcraft/jsch/KeyPair2IT.java index fc6d7f24..393c66a1 100644 --- a/src/test/java/com/jcraft/jsch/KeyPair2IT.java +++ b/src/test/java/com/jcraft/jsch/KeyPair2IT.java @@ -1,5 +1,9 @@ package com.jcraft.jsch; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.net.URISyntaxException; +import java.nio.file.Paths; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import org.testcontainers.containers.GenericContainer; @@ -7,11 +11,6 @@ import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; -import java.net.URISyntaxException; -import java.nio.file.Paths; - -import static org.junit.jupiter.api.Assertions.assertTrue; - @Testcontainers public class KeyPair2IT { diff --git a/src/test/java/com/jcraft/jsch/KeyPair2Test.java b/src/test/java/com/jcraft/jsch/KeyPair2Test.java index c5dd4782..a588a5f7 100644 --- a/src/test/java/com/jcraft/jsch/KeyPair2Test.java +++ b/src/test/java/com/jcraft/jsch/KeyPair2Test.java @@ -1,17 +1,16 @@ package com.jcraft.jsch; -import org.junit.jupiter.api.io.TempDir; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.*; import java.io.File; import java.net.URISyntaxException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.io.TempDir; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; class KeyPair2Test { diff --git a/src/test/java/com/jcraft/jsch/KeyPairIT.java b/src/test/java/com/jcraft/jsch/KeyPairIT.java index aef8dec1..a0f8c95c 100644 --- a/src/test/java/com/jcraft/jsch/KeyPairIT.java +++ b/src/test/java/com/jcraft/jsch/KeyPairIT.java @@ -1,5 +1,9 @@ package com.jcraft.jsch; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.net.URISyntaxException; +import java.nio.file.Paths; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import org.testcontainers.containers.GenericContainer; @@ -7,11 +11,6 @@ import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; -import java.net.URISyntaxException; -import java.nio.file.Paths; - -import static org.junit.jupiter.api.Assertions.assertTrue; - @Testcontainers public class KeyPairIT { diff --git a/src/test/java/com/jcraft/jsch/KeyPairTest.java b/src/test/java/com/jcraft/jsch/KeyPairTest.java index f8b007e7..147999df 100644 --- a/src/test/java/com/jcraft/jsch/KeyPairTest.java +++ b/src/test/java/com/jcraft/jsch/KeyPairTest.java @@ -1,20 +1,19 @@ package com.jcraft.jsch; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.junit.jupiter.params.provider.ValueSource; +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.jupiter.api.Assertions.*; import java.io.File; import java.net.URISyntaxException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.stream.Stream; - -import static java.nio.charset.StandardCharsets.UTF_8; -import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.params.provider.ValueSource; class KeyPairTest { diff --git a/src/test/java/com/jcraft/jsch/KnownHostsTest.java b/src/test/java/com/jcraft/jsch/KnownHostsTest.java index 527aad56..3ca101d5 100644 --- a/src/test/java/com/jcraft/jsch/KnownHostsTest.java +++ b/src/test/java/com/jcraft/jsch/KnownHostsTest.java @@ -10,6 +10,7 @@ import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -36,7 +37,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import com.jcraft.jsch.KnownHosts.HashedHostKey; -import com.jcraft.jsch.jce.HMACSHA1; import com.jcraft.jsch.jce.HMACSHA256; import com.jcraft.jsch.jce.HMACSHA512; diff --git a/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java b/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java index bb1bb9be..221166dc 100644 --- a/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java +++ b/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java @@ -1,8 +1,6 @@ package com.jcraft.jsch; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; +import static org.junit.jupiter.api.Assertions.*; import java.io.IOException; import java.net.URISyntaxException; @@ -11,8 +9,9 @@ import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; - -import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; class OpenSSHConfigTest { diff --git a/src/test/java/com/jcraft/jsch/SessionTest.java b/src/test/java/com/jcraft/jsch/SessionTest.java index 2969ac8a..116a2f20 100644 --- a/src/test/java/com/jcraft/jsch/SessionTest.java +++ b/src/test/java/com/jcraft/jsch/SessionTest.java @@ -1,16 +1,14 @@ package com.jcraft.jsch; +import static org.junit.jupiter.api.Assertions.*; + +import com.jcraft.jsch.JSchTest.TestLogger; +import java.util.stream.Stream; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import com.jcraft.jsch.JSchTest.TestLogger; - -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.*; - class SessionTest { static JSch jsch = new JSch(); From 449bb0a75f586068d44d125947d454d1905f0f6c Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Mon, 15 Jan 2024 13:31:38 -0600 Subject: [PATCH 180/301] Remove unneeded implements statements. --- src/main/java/com/jcraft/jsch/jce/ECDH256.java | 2 +- src/main/java/com/jcraft/jsch/jce/ECDH384.java | 2 +- src/main/java/com/jcraft/jsch/jce/ECDH521.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/jcraft/jsch/jce/ECDH256.java b/src/main/java/com/jcraft/jsch/jce/ECDH256.java index 7a40ab87..872a8b95 100644 --- a/src/main/java/com/jcraft/jsch/jce/ECDH256.java +++ b/src/main/java/com/jcraft/jsch/jce/ECDH256.java @@ -26,7 +26,7 @@ package com.jcraft.jsch.jce; -public class ECDH256 extends ECDHN implements com.jcraft.jsch.ECDH { +public class ECDH256 extends ECDHN { public void init() throws Exception { super.init(256); } diff --git a/src/main/java/com/jcraft/jsch/jce/ECDH384.java b/src/main/java/com/jcraft/jsch/jce/ECDH384.java index 85b57a0f..8477f040 100644 --- a/src/main/java/com/jcraft/jsch/jce/ECDH384.java +++ b/src/main/java/com/jcraft/jsch/jce/ECDH384.java @@ -26,7 +26,7 @@ package com.jcraft.jsch.jce; -public class ECDH384 extends ECDHN implements com.jcraft.jsch.ECDH { +public class ECDH384 extends ECDHN { public void init() throws Exception { super.init(384); } diff --git a/src/main/java/com/jcraft/jsch/jce/ECDH521.java b/src/main/java/com/jcraft/jsch/jce/ECDH521.java index 42f3a393..77f6237b 100644 --- a/src/main/java/com/jcraft/jsch/jce/ECDH521.java +++ b/src/main/java/com/jcraft/jsch/jce/ECDH521.java @@ -26,7 +26,7 @@ package com.jcraft.jsch.jce; -public class ECDH521 extends ECDHN implements com.jcraft.jsch.ECDH { +public class ECDH521 extends ECDHN { public void init() throws Exception { super.init(521); } From 48423a761965a0404e00e27a49676e9c0c8c5a98 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Mon, 15 Jan 2024 14:21:44 -0600 Subject: [PATCH 181/301] Remove unused local variables. --- src/main/java/com/jcraft/jsch/jce/ARCFOUR.java | 1 - src/test/java/com/jcraft/jsch/KeyExchangeTest.java | 13 ------------- src/test/java/com/jcraft/jsch/ServerSigAlgsIT.java | 4 ++-- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/jcraft/jsch/jce/ARCFOUR.java b/src/main/java/com/jcraft/jsch/jce/ARCFOUR.java index ebb99961..d9e23853 100644 --- a/src/main/java/com/jcraft/jsch/jce/ARCFOUR.java +++ b/src/main/java/com/jcraft/jsch/jce/ARCFOUR.java @@ -46,7 +46,6 @@ public int getBlockSize() { @Override public void init(int mode, byte[] key, byte[] iv) throws Exception { - String pad = "NoPadding"; byte[] tmp; if (key.length > bsize) { tmp = new byte[bsize]; diff --git a/src/test/java/com/jcraft/jsch/KeyExchangeTest.java b/src/test/java/com/jcraft/jsch/KeyExchangeTest.java index ef5aae3c..861013fe 100644 --- a/src/test/java/com/jcraft/jsch/KeyExchangeTest.java +++ b/src/test/java/com/jcraft/jsch/KeyExchangeTest.java @@ -19,7 +19,6 @@ public void testNormalize0() { @Test public void testNormalize1() { - KeyExchange kex = new TestKex(); byte[] secret = new byte[1]; for (int i = 0; i <= 0xff; i++) { secret[0] = (byte) i; @@ -29,7 +28,6 @@ public void testNormalize1() { @Test public void testNormalize2() { - KeyExchange kex = new TestKex(); byte[] secret = new byte[2]; for (int i = 0; i <= 0xff; i++) { secret[0] = (byte) i; @@ -42,7 +40,6 @@ public void testNormalize2() { @Test public void testNormalize3() { - KeyExchange kex = new TestKex(); byte[] secret = new byte[3]; for (int i = 0; i <= 0xff; i++) { secret[0] = (byte) i; @@ -58,7 +55,6 @@ public void testNormalize3() { @Test public void testNormalizeRandom() { - KeyExchange kex = new TestKex(); for (int i = 0; i < 1000000; i++) { byte[] secret = new byte[64]; random.nextBytes(secret); @@ -68,7 +64,6 @@ public void testNormalizeRandom() { @Test public void testEncodeAsMPInt1() { - KeyExchange kex = new TestKex(); byte[] secret = new byte[1]; for (int i = 0; i <= 0xff; i++) { secret[0] = (byte) i; @@ -78,7 +73,6 @@ public void testEncodeAsMPInt1() { @Test public void testEncodeAsMPInt2() { - KeyExchange kex = new TestKex(); byte[] secret = new byte[2]; for (int i = 0; i <= 0xff; i++) { secret[0] = (byte) i; @@ -91,7 +85,6 @@ public void testEncodeAsMPInt2() { @Test public void testEncodeAsMPInt3() { - KeyExchange kex = new TestKex(); byte[] secret = new byte[3]; for (int i = 0; i <= 0xff; i++) { secret[0] = (byte) i; @@ -107,7 +100,6 @@ public void testEncodeAsMPInt3() { @Test public void testEncodeAsMPIntRandom() { - KeyExchange kex = new TestKex(); for (int i = 0; i < 1000000; i++) { byte[] secret = new byte[64]; random.nextBytes(secret); @@ -117,14 +109,12 @@ public void testEncodeAsMPIntRandom() { @Test public void testEncodeAsString0() { - KeyExchange kex = new TestKex(); byte[] secret = new byte[0]; doEncodeAsString(secret); } @Test public void testEncodeAsString1() { - KeyExchange kex = new TestKex(); byte[] secret = new byte[1]; for (int i = 0; i <= 0xff; i++) { secret[0] = (byte) i; @@ -134,7 +124,6 @@ public void testEncodeAsString1() { @Test public void testEncodeAsString2() { - KeyExchange kex = new TestKex(); byte[] secret = new byte[2]; for (int i = 0; i <= 0xff; i++) { secret[0] = (byte) i; @@ -147,7 +136,6 @@ public void testEncodeAsString2() { @Test public void testEncodeAsString3() { - KeyExchange kex = new TestKex(); byte[] secret = new byte[3]; for (int i = 0; i <= 0xff; i++) { secret[0] = (byte) i; @@ -163,7 +151,6 @@ public void testEncodeAsString3() { @Test public void testEncodeAsStringRandom() { - KeyExchange kex = new TestKex(); for (int i = 0; i < 1000000; i++) { byte[] secret = new byte[64]; random.nextBytes(secret); diff --git a/src/test/java/com/jcraft/jsch/ServerSigAlgsIT.java b/src/test/java/com/jcraft/jsch/ServerSigAlgsIT.java index bc1aa0f5..9f7a5df8 100644 --- a/src/test/java/com/jcraft/jsch/ServerSigAlgsIT.java +++ b/src/test/java/com/jcraft/jsch/ServerSigAlgsIT.java @@ -140,8 +140,8 @@ public void testNoServerSigAlgs() throws Exception { doSftp(session, true); String expectedKex = "kex: host key algorithm: rsa-sha2-512"; - String expectedPubkeysNoServerSigs = String.format(Locale.ROOT, - "No server-sig-algs found, using PubkeyAcceptedAlgorithms = %s", algos); + // String expectedPubkeysNoServerSigs = String.format(Locale.ROOT, + // "No server-sig-algs found, using PubkeyAcceptedAlgorithms = %s", algos); String expectedPreauthFail1 = "ssh-rsa-sha512@ssh.com preauth failure"; String expectedPreauthFail2 = "ssh-rsa-sha384@ssh.com preauth failure"; String expectedPreauthFail3 = "ssh-rsa-sha256@ssh.com preauth failure"; From d3e310178d63d2728a16a500af73658362fa9cfa Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Mon, 15 Jan 2024 14:22:06 -0600 Subject: [PATCH 182/301] Skip flatten-maven-plugin during CI tests. --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 22d61ccf..04c05c81 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -49,7 +49,7 @@ jobs: java-version: ${{ matrix.java }} check-latest: true - name: Test with Maven - run: ./mvnw -B -V -e -P coverage verify -Denforcer.skip=true -Dmaven.resources.skip=true -Dmaven.main.skip=true -Dbnd.skip=true -Dassembly.skipAssembly=true -Dmaven.javadoc.skip=true -Dcyclonedx.skip=true -DskipITs=false + run: ./mvnw -B -V -e -P coverage verify -Denforcer.skip=true -Dmaven.resources.skip=true -Dflatten.skip=true -Dmaven.main.skip=true -Dbnd.skip=true -Dassembly.skipAssembly=true -Dmaven.javadoc.skip=true -Dcyclonedx.skip=true -DskipITs=false - uses: actions/upload-artifact@v4 with: name: java-${{ matrix.java }}-testresults From cceda971de258f9cf70e2b95dc19560855b130b3 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Mon, 15 Jan 2024 15:32:33 -0600 Subject: [PATCH 183/301] Expand wildcard imports in order to better adhere to Google Java Style Guide. --- examples/AES.java | 17 ++++++++++--- examples/ChangePassphrase.java | 7 ++++-- examples/Compression.java | 17 ++++++++++--- examples/Daemon.java | 23 ++++++++++++++---- examples/Exec.java | 20 ++++++++++++---- examples/JSchWithAgentProxy.java | 13 +++++++--- examples/JumpHosts.java | 17 ++++++++++--- examples/KeyGen.java | 7 ++++-- examples/KnownHosts.java | 20 +++++++++++++--- examples/Logger.java | 17 ++++++++++--- examples/OpenSSHConfig.java | 10 +++++--- examples/PortForwardingL.java | 16 ++++++++++--- examples/PortForwardingR.java | 16 ++++++++++--- examples/ScpFrom.java | 24 +++++++++++++++---- examples/ScpTo.java | 24 +++++++++++++++---- examples/ScpToNoneCipher.java | 24 +++++++++++++++---- examples/Sftp.java | 23 +++++++++++++++--- examples/Shell.java | 9 ++++--- examples/SocketForwardingL.java | 8 ++++--- examples/StreamForwarding.java | 17 ++++++++++--- examples/Subsystem.java | 18 +++++++++++--- examples/Sudo.java | 21 ++++++++++++---- examples/UserAuthKI.java | 17 ++++++++++--- examples/UserAuthPubKey.java | 18 +++++++++++--- examples/ViaHTTP.java | 18 +++++++++++--- examples/ViaSOCKS5.java | 18 +++++++++++--- examples/X11Forwarding.java | 17 ++++++++++--- src/main/java/com/jcraft/jsch/Channel.java | 6 ++++- .../com/jcraft/jsch/ChannelDirectTCPIP.java | 3 ++- .../java/com/jcraft/jsch/ChannelExec.java | 4 +++- .../jcraft/jsch/ChannelForwardedTCPIP.java | 4 ++-- .../java/com/jcraft/jsch/ChannelSession.java | 3 ++- .../java/com/jcraft/jsch/ChannelSftp.java | 9 ++++++- .../com/jcraft/jsch/ChannelSubsystem.java | 4 +++- src/main/java/com/jcraft/jsch/ChannelX11.java | 2 +- .../com/jcraft/jsch/ForwardedTCPIPDaemon.java | 3 ++- src/main/java/com/jcraft/jsch/IO.java | 4 +++- src/main/java/com/jcraft/jsch/KeyPair.java | 6 ++++- src/main/java/com/jcraft/jsch/Proxy.java | 3 ++- src/main/java/com/jcraft/jsch/ProxyHTTP.java | 6 +++-- .../java/com/jcraft/jsch/ProxySOCKS4.java | 7 ++++-- .../java/com/jcraft/jsch/ProxySOCKS5.java | 6 +++-- .../com/jcraft/jsch/ServerSocketFactory.java | 5 ++-- .../java/com/jcraft/jsch/SocketFactory.java | 7 ++++-- .../com/jcraft/jsch/UserAuthPublicKey.java | 7 +++++- .../com/jcraft/jsch/bc/ChaCha20Poly1305.java | 3 ++- .../com/jcraft/jsch/bc/KeyPairGenEdDSA.java | 6 +++-- .../java/com/jcraft/jsch/bc/SNTRUP761.java | 7 +++++- .../com/jcraft/jsch/bc/SignatureEdDSA.java | 12 +++++++--- src/main/java/com/jcraft/jsch/bc/XDH.java | 9 +++++-- .../java/com/jcraft/jsch/jce/AES128CBC.java | 3 ++- .../java/com/jcraft/jsch/jce/AES128CTR.java | 3 ++- .../java/com/jcraft/jsch/jce/AES192CBC.java | 3 ++- .../java/com/jcraft/jsch/jce/AES192CTR.java | 3 ++- .../java/com/jcraft/jsch/jce/AES256CBC.java | 3 ++- .../java/com/jcraft/jsch/jce/AES256CTR.java | 3 ++- src/main/java/com/jcraft/jsch/jce/AESGCM.java | 3 ++- .../java/com/jcraft/jsch/jce/ARCFOUR.java | 2 +- .../java/com/jcraft/jsch/jce/ARCFOUR128.java | 2 +- .../java/com/jcraft/jsch/jce/ARCFOUR256.java | 2 +- .../java/com/jcraft/jsch/jce/BlowfishCBC.java | 3 ++- .../java/com/jcraft/jsch/jce/BlowfishCTR.java | 3 ++- src/main/java/com/jcraft/jsch/jce/DH.java | 12 ++++++---- src/main/java/com/jcraft/jsch/jce/ECDHN.java | 18 +++++++++----- src/main/java/com/jcraft/jsch/jce/HMAC.java | 5 ++-- .../com/jcraft/jsch/jce/KeyPairGenDSA.java | 11 +++++++-- .../com/jcraft/jsch/jce/KeyPairGenECDSA.java | 10 +++++--- .../com/jcraft/jsch/jce/KeyPairGenRSA.java | 10 ++++++-- src/main/java/com/jcraft/jsch/jce/MD5.java | 3 +-- src/main/java/com/jcraft/jsch/jce/SHA1.java | 3 +-- src/main/java/com/jcraft/jsch/jce/SHA224.java | 3 +-- src/main/java/com/jcraft/jsch/jce/SHA256.java | 3 +-- src/main/java/com/jcraft/jsch/jce/SHA384.java | 5 ++-- src/main/java/com/jcraft/jsch/jce/SHA512.java | 5 ++-- .../com/jcraft/jsch/jce/SignatureDSA.java | 12 ++++++---- .../com/jcraft/jsch/jce/SignatureECDSAN.java | 19 +++++++++++---- .../com/jcraft/jsch/jce/SignatureEd25519.java | 4 +++- .../com/jcraft/jsch/jce/SignatureEd448.java | 4 +++- .../com/jcraft/jsch/jce/SignatureRSAN.java | 15 ++++++++---- .../com/jcraft/jsch/jce/TripleDESCBC.java | 6 +++-- .../com/jcraft/jsch/jce/TripleDESCTR.java | 6 +++-- .../com/jcraft/jsch/jgss/GSSContextKrb5.java | 1 - .../java/com/jcraft/jsch/juz/Compression.java | 7 ++++-- .../jsch/jzlib/DeflaterOutputStream.java | 4 +++- .../jsch/jzlib/InflaterInputStream.java | 5 +++- src/main/java11/com/jcraft/jsch/jce/XDH.java | 12 ++++++---- .../com/jcraft/jsch/jce/KeyPairGenEdDSA.java | 8 ++++--- .../com/jcraft/jsch/jce/SignatureEdDSA.java | 12 +++++++--- src/test/java/com/jcraft/jsch/JSchTest.java | 3 ++- .../java/com/jcraft/jsch/KeyPair2Test.java | 4 +++- .../java/com/jcraft/jsch/KeyPairTest.java | 6 ++++- .../com/jcraft/jsch/OpenSSHConfigTest.java | 3 ++- .../java/com/jcraft/jsch/SessionTest.java | 3 ++- .../com/jcraft/jsch/jbcrypt/BCryptTest.java | 4 +++- .../com/jcraft/jsch/jzlib/Adler32Test.java | 2 +- .../java/com/jcraft/jsch/jzlib/CRC32Test.java | 2 +- .../jcraft/jsch/jzlib/DeflateInflateTest.java | 14 ++++++++++- .../jzlib/DeflaterInflaterStreamTest.java | 5 +++- .../jcraft/jsch/jzlib/WrapperTypeTest.java | 18 ++++++++++++-- 99 files changed, 674 insertions(+), 208 deletions(-) diff --git a/examples/AES.java b/examples/AES.java index 69e43b87..5723ea58 100644 --- a/examples/AES.java +++ b/examples/AES.java @@ -2,9 +2,20 @@ * This program will demonstrate how to use "aes128-cbc". * */ -import com.jcraft.jsch.*; -import java.awt.*; -import javax.swing.*; +import com.jcraft.jsch.Channel; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.UIKeyboardInteractive; +import com.jcraft.jsch.UserInfo; +import java.awt.Container; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPasswordField; +import javax.swing.JTextField; public class AES { public static void main(String[] arg) { diff --git a/examples/ChangePassphrase.java b/examples/ChangePassphrase.java index f720b3b5..193b1718 100644 --- a/examples/ChangePassphrase.java +++ b/examples/ChangePassphrase.java @@ -5,8 +5,11 @@ * and the given private-key will be re-encrypted with that new passphrase. * */ -import com.jcraft.jsch.*; -import javax.swing.*; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.KeyPair; +import javax.swing.JOptionPane; +import javax.swing.JPasswordField; +import javax.swing.JTextField; public class ChangePassphrase { public static void main(String[] arg) { diff --git a/examples/Compression.java b/examples/Compression.java index d11a6853..d5630a96 100644 --- a/examples/Compression.java +++ b/examples/Compression.java @@ -4,9 +4,20 @@ * sshd server to jsch will be compressed. * */ -import com.jcraft.jsch.*; -import java.awt.*; -import javax.swing.*; +import com.jcraft.jsch.Channel; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.UIKeyboardInteractive; +import com.jcraft.jsch.UserInfo; +import java.awt.Container; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPasswordField; +import javax.swing.JTextField; public class Compression { public static void main(String[] arg) { diff --git a/examples/Daemon.java b/examples/Daemon.java index 49de1f6a..197083b5 100644 --- a/examples/Daemon.java +++ b/examples/Daemon.java @@ -3,10 +3,25 @@ * port-forwarding functionality. * */ -import com.jcraft.jsch.*; -import java.io.*; -import java.awt.*; -import javax.swing.*; +import com.jcraft.jsch.ChannelForwardedTCPIP; +import com.jcraft.jsch.ForwardedTCPIPDaemon; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.JSchException; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.UIKeyboardInteractive; +import com.jcraft.jsch.UserInfo; +import java.awt.Container; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPasswordField; +import javax.swing.JTextField; public class Daemon { public static void main(String[] arg) { diff --git a/examples/Exec.java b/examples/Exec.java index c2c0401b..1635d68b 100644 --- a/examples/Exec.java +++ b/examples/Exec.java @@ -4,10 +4,22 @@ * and outputs will be printed out. * */ -import com.jcraft.jsch.*; -import java.awt.*; -import javax.swing.*; -import java.io.*; +import com.jcraft.jsch.Channel; +import com.jcraft.jsch.ChannelExec; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.UIKeyboardInteractive; +import com.jcraft.jsch.UserInfo; +import java.awt.Container; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.io.InputStream; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPasswordField; +import javax.swing.JTextField; public class Exec { public static void main(String[] arg) { diff --git a/examples/JSchWithAgentProxy.java b/examples/JSchWithAgentProxy.java index deb4cc8a..34d5ebef 100644 --- a/examples/JSchWithAgentProxy.java +++ b/examples/JSchWithAgentProxy.java @@ -1,6 +1,13 @@ -import com.jcraft.jsch.*; -import java.io.*; -import javax.swing.*; +import com.jcraft.jsch.AgentIdentityRepository; +import com.jcraft.jsch.Channel; +import com.jcraft.jsch.ChannelShell; +import com.jcraft.jsch.IdentityRepository; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.SSHAgentConnector; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.UIKeyboardInteractive; +import com.jcraft.jsch.UserInfo; +import javax.swing.JOptionPane; public class JSchWithAgentProxy { public static void main(String[] arg) { diff --git a/examples/JumpHosts.java b/examples/JumpHosts.java index bdfcb907..905d8abc 100644 --- a/examples/JumpHosts.java +++ b/examples/JumpHosts.java @@ -5,9 +5,20 @@ * at host3. * */ -import com.jcraft.jsch.*; -import java.awt.*; -import javax.swing.*; +import com.jcraft.jsch.ChannelSftp; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.UIKeyboardInteractive; +import com.jcraft.jsch.UserInfo; +import java.awt.Container; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPasswordField; +import javax.swing.JTextField; public class JumpHosts { public static void main(String[] arg) { diff --git a/examples/KeyGen.java b/examples/KeyGen.java index bb91e4f4..9f1810d0 100644 --- a/examples/KeyGen.java +++ b/examples/KeyGen.java @@ -4,8 +4,11 @@ * output_keyfile+".pub". The private key and public key are in the OpenSSH format. * */ -import com.jcraft.jsch.*; -import javax.swing.*; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.KeyPair; +import javax.swing.JOptionPane; +import javax.swing.JPasswordField; +import javax.swing.JTextField; public class KeyGen { public static void main(String[] arg) { diff --git a/examples/KnownHosts.java b/examples/KnownHosts.java index f3eeea81..bc720710 100644 --- a/examples/KnownHosts.java +++ b/examples/KnownHosts.java @@ -5,9 +5,23 @@ * it. * */ -import com.jcraft.jsch.*; -import java.awt.*; -import javax.swing.*; +import com.jcraft.jsch.Channel; +import com.jcraft.jsch.HostKey; +import com.jcraft.jsch.HostKeyRepository; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.UIKeyboardInteractive; +import com.jcraft.jsch.UserInfo; +import java.awt.Container; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPasswordField; +import javax.swing.JTextField; public class KnownHosts { public static void main(String[] arg) { diff --git a/examples/Logger.java b/examples/Logger.java index 4f76617b..862453c6 100644 --- a/examples/Logger.java +++ b/examples/Logger.java @@ -2,9 +2,20 @@ * This program will demonstrate how to enable logging mechanism and get logging messages. * */ -import com.jcraft.jsch.*; -import java.awt.*; -import javax.swing.*; +import com.jcraft.jsch.Channel; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.UIKeyboardInteractive; +import com.jcraft.jsch.UserInfo; +import java.awt.Container; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPasswordField; +import javax.swing.JTextField; public class Logger { public static void main(String[] arg) { diff --git a/examples/OpenSSHConfig.java b/examples/OpenSSHConfig.java index f7dd22de..c9890eda 100644 --- a/examples/OpenSSHConfig.java +++ b/examples/OpenSSHConfig.java @@ -4,9 +4,13 @@ * lacks of terminal-emulation, but you can issue commands. * */ -import com.jcraft.jsch.*; -import java.awt.*; -import javax.swing.*; +import com.jcraft.jsch.Channel; +import com.jcraft.jsch.ConfigRepository; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.UIKeyboardInteractive; +import com.jcraft.jsch.UserInfo; +import javax.swing.JOptionPane; public class OpenSSHConfig { public static void main(String[] arg) { diff --git a/examples/PortForwardingL.java b/examples/PortForwardingL.java index 1cd7a114..efdeaa96 100644 --- a/examples/PortForwardingL.java +++ b/examples/PortForwardingL.java @@ -5,9 +5,19 @@ * will get the shell prompt. Try the port on localhost. * */ -import com.jcraft.jsch.*; -import java.awt.*; -import javax.swing.*; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.UIKeyboardInteractive; +import com.jcraft.jsch.UserInfo; +import java.awt.Container; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPasswordField; +import javax.swing.JTextField; public class PortForwardingL { public static void main(String[] arg) { diff --git a/examples/PortForwardingR.java b/examples/PortForwardingR.java index cb74ba18..242ca1d7 100644 --- a/examples/PortForwardingR.java +++ b/examples/PortForwardingR.java @@ -5,9 +5,19 @@ * the shell prompt. Try the port on remote host. * */ -import com.jcraft.jsch.*; -import java.awt.*; -import javax.swing.*; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.UIKeyboardInteractive; +import com.jcraft.jsch.UserInfo; +import java.awt.Container; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPasswordField; +import javax.swing.JTextField; public class PortForwardingR { public static void main(String[] arg) { diff --git a/examples/ScpFrom.java b/examples/ScpFrom.java index 756b8e55..bfdd86dd 100644 --- a/examples/ScpFrom.java +++ b/examples/ScpFrom.java @@ -3,10 +3,26 @@ * file 'file1' on 'remotehost' will copied to local 'file1'. * */ -import com.jcraft.jsch.*; -import java.awt.*; -import javax.swing.*; -import java.io.*; +import com.jcraft.jsch.Channel; +import com.jcraft.jsch.ChannelExec; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.UIKeyboardInteractive; +import com.jcraft.jsch.UserInfo; +import java.awt.Container; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPasswordField; +import javax.swing.JTextField; public class ScpFrom { public static void main(String[] arg) { diff --git a/examples/ScpTo.java b/examples/ScpTo.java index 46140172..1184a170 100644 --- a/examples/ScpTo.java +++ b/examples/ScpTo.java @@ -3,10 +3,26 @@ * If everything works fine, a local file 'file1' will copied to 'file2' on 'remotehost'. * */ -import com.jcraft.jsch.*; -import java.awt.*; -import javax.swing.*; -import java.io.*; +import com.jcraft.jsch.Channel; +import com.jcraft.jsch.ChannelExec; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.UIKeyboardInteractive; +import com.jcraft.jsch.UserInfo; +import java.awt.Container; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPasswordField; +import javax.swing.JTextField; public class ScpTo { public static void main(String[] arg) { diff --git a/examples/ScpToNoneCipher.java b/examples/ScpToNoneCipher.java index f1752ca5..b61bdd45 100644 --- a/examples/ScpToNoneCipher.java +++ b/examples/ScpToNoneCipher.java @@ -3,10 +3,26 @@ * works fine, a local file 'file1' will copied to 'file2' on 'remotehost'. * */ -import com.jcraft.jsch.*; -import java.awt.*; -import javax.swing.*; -import java.io.*; +import com.jcraft.jsch.Channel; +import com.jcraft.jsch.ChannelExec; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.UIKeyboardInteractive; +import com.jcraft.jsch.UserInfo; +import java.awt.Container; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPasswordField; +import javax.swing.JTextField; public class ScpToNoneCipher { public static void main(String[] arg) { diff --git a/examples/Sftp.java b/examples/Sftp.java index 1b79b413..5de20143 100644 --- a/examples/Sftp.java +++ b/examples/Sftp.java @@ -4,9 +4,26 @@ * destination path for 'get' and 'put' commands must be a file, not a directory. * */ -import com.jcraft.jsch.*; -import java.awt.*; -import javax.swing.*; +import com.jcraft.jsch.Channel; +import com.jcraft.jsch.ChannelSftp; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.SftpATTRS; +import com.jcraft.jsch.SftpException; +import com.jcraft.jsch.SftpProgressMonitor; +import com.jcraft.jsch.SftpStatVFS; +import com.jcraft.jsch.UIKeyboardInteractive; +import com.jcraft.jsch.UserInfo; +import java.awt.Container; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPasswordField; +import javax.swing.JTextField; +import javax.swing.ProgressMonitor; public class Sftp { public static void main(String[] arg) { diff --git a/examples/Shell.java b/examples/Shell.java index 9db4fe95..090e6148 100644 --- a/examples/Shell.java +++ b/examples/Shell.java @@ -4,9 +4,12 @@ * may be ugly because of lacks of terminal-emulation, but you can issue commands. * */ -import com.jcraft.jsch.*; -import java.awt.*; -import javax.swing.*; +import com.jcraft.jsch.Channel; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.UIKeyboardInteractive; +import com.jcraft.jsch.UserInfo; +import javax.swing.JOptionPane; public class Shell { public static void main(String[] arg) { diff --git a/examples/SocketForwardingL.java b/examples/SocketForwardingL.java index 51b78d38..336d2c39 100644 --- a/examples/SocketForwardingL.java +++ b/examples/SocketForwardingL.java @@ -4,11 +4,13 @@ * the _ping endpoint of the dockerd. * */ -import com.jcraft.jsch.*; - -import javax.swing.*; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.UIKeyboardInteractive; +import com.jcraft.jsch.UserInfo; import java.net.HttpURLConnection; import java.net.URL; +import javax.swing.JOptionPane; public class SocketForwardingL { public static void main(String[] arg) { diff --git a/examples/StreamForwarding.java b/examples/StreamForwarding.java index 47a360bd..89ca3315 100644 --- a/examples/StreamForwarding.java +++ b/examples/StreamForwarding.java @@ -6,9 +6,20 @@ * will be forwared to remote port and you can send messages from command line. * */ -import com.jcraft.jsch.*; -import java.awt.*; -import javax.swing.*; +import com.jcraft.jsch.Channel; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.UIKeyboardInteractive; +import com.jcraft.jsch.UserInfo; +import java.awt.Container; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPasswordField; +import javax.swing.JTextField; public class StreamForwarding { public static void main(String[] arg) { diff --git a/examples/Subsystem.java b/examples/Subsystem.java index fa4065f7..ac5f7f36 100644 --- a/examples/Subsystem.java +++ b/examples/Subsystem.java @@ -2,9 +2,21 @@ * This program will demonstrate how to use the Subsystem channel. * */ -import com.jcraft.jsch.*; -import java.awt.*; -import javax.swing.*; +import com.jcraft.jsch.Channel; +import com.jcraft.jsch.ChannelSubsystem; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.UIKeyboardInteractive; +import com.jcraft.jsch.UserInfo; +import java.awt.Container; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPasswordField; +import javax.swing.JTextField; public class Subsystem { public static void main(String[] arg) { diff --git a/examples/Sudo.java b/examples/Sudo.java index e0b8ec1b..cb42d6f3 100644 --- a/examples/Sudo.java +++ b/examples/Sudo.java @@ -2,10 +2,23 @@ * This program will demonstrate how to exec 'sudo' on the remote. * */ -import com.jcraft.jsch.*; -import java.awt.*; -import javax.swing.*; -import java.io.*; +import com.jcraft.jsch.Channel; +import com.jcraft.jsch.ChannelExec; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.UIKeyboardInteractive; +import com.jcraft.jsch.UserInfo; +import java.awt.Container; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.io.InputStream; +import java.io.OutputStream; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPasswordField; +import javax.swing.JTextField; public class Sudo { public static void main(String[] arg) { diff --git a/examples/UserAuthKI.java b/examples/UserAuthKI.java index 67cfdd06..f2e62870 100644 --- a/examples/UserAuthKI.java +++ b/examples/UserAuthKI.java @@ -3,9 +3,20 @@ * supports keyboard-interactive authentication, you will be prompted. * */ -import com.jcraft.jsch.*; -import java.awt.*; -import javax.swing.*; +import com.jcraft.jsch.Channel; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.UIKeyboardInteractive; +import com.jcraft.jsch.UserInfo; +import java.awt.Container; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPasswordField; +import javax.swing.JTextField; public class UserAuthKI { public static void main(String[] arg) { diff --git a/examples/UserAuthPubKey.java b/examples/UserAuthPubKey.java index 6ed96078..03437280 100644 --- a/examples/UserAuthPubKey.java +++ b/examples/UserAuthPubKey.java @@ -4,9 +4,21 @@ * shell prompt. * */ -import com.jcraft.jsch.*; -import java.awt.*; -import javax.swing.*; +import com.jcraft.jsch.Channel; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.UIKeyboardInteractive; +import com.jcraft.jsch.UserInfo; +import java.awt.Container; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPasswordField; +import javax.swing.JTextField; public class UserAuthPubKey { public static void main(String[] arg) { diff --git a/examples/ViaHTTP.java b/examples/ViaHTTP.java index 5d3ea03d..ca943a96 100644 --- a/examples/ViaHTTP.java +++ b/examples/ViaHTTP.java @@ -3,9 +3,21 @@ * hostname, proxy-server and passwd. If everything works fine, you will get the shell prompt. * */ -import com.jcraft.jsch.*; -import java.awt.*; -import javax.swing.*; +import com.jcraft.jsch.Channel; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.ProxyHTTP; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.UIKeyboardInteractive; +import com.jcraft.jsch.UserInfo; +import java.awt.Container; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPasswordField; +import javax.swing.JTextField; public class ViaHTTP { public static void main(String[] arg) { diff --git a/examples/ViaSOCKS5.java b/examples/ViaSOCKS5.java index 8ee9fdec..06d31811 100644 --- a/examples/ViaSOCKS5.java +++ b/examples/ViaSOCKS5.java @@ -3,9 +3,21 @@ * hostname, proxy-server and passwd. If everything works fine, you will get the shell prompt. * */ -import com.jcraft.jsch.*; -import java.awt.*; -import javax.swing.*; +import com.jcraft.jsch.Channel; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.ProxySOCKS5; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.UIKeyboardInteractive; +import com.jcraft.jsch.UserInfo; +import java.awt.Container; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPasswordField; +import javax.swing.JTextField; public class ViaSOCKS5 { public static void main(String[] arg) { diff --git a/examples/X11Forwarding.java b/examples/X11Forwarding.java index 95d9fa1c..a82438f1 100644 --- a/examples/X11Forwarding.java +++ b/examples/X11Forwarding.java @@ -4,9 +4,20 @@ * everything works fine, you will get the shell prompt. Try X applications; for example, xlogo. * */ -import com.jcraft.jsch.*; -import java.awt.*; -import javax.swing.*; +import com.jcraft.jsch.Channel; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.UIKeyboardInteractive; +import com.jcraft.jsch.UserInfo; +import java.awt.Container; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPasswordField; +import javax.swing.JTextField; public class X11Forwarding { public static void main(String[] arg) { diff --git a/src/main/java/com/jcraft/jsch/Channel.java b/src/main/java/com/jcraft/jsch/Channel.java index 82abe288..f419f33a 100644 --- a/src/main/java/com/jcraft/jsch/Channel.java +++ b/src/main/java/com/jcraft/jsch/Channel.java @@ -26,7 +26,11 @@ package com.jcraft.jsch; -import java.io.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PipedInputStream; +import java.io.PipedOutputStream; import java.util.Vector; public abstract class Channel { diff --git a/src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java b/src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java index a357a773..37a2e94a 100644 --- a/src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java +++ b/src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java @@ -26,7 +26,8 @@ package com.jcraft.jsch; -import java.io.*; +import java.io.InputStream; +import java.io.OutputStream; public class ChannelDirectTCPIP extends Channel { diff --git a/src/main/java/com/jcraft/jsch/ChannelExec.java b/src/main/java/com/jcraft/jsch/ChannelExec.java index 202b06ce..56143bbb 100644 --- a/src/main/java/com/jcraft/jsch/ChannelExec.java +++ b/src/main/java/com/jcraft/jsch/ChannelExec.java @@ -26,7 +26,9 @@ package com.jcraft.jsch; -import java.io.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; public class ChannelExec extends ChannelSession { diff --git a/src/main/java/com/jcraft/jsch/ChannelForwardedTCPIP.java b/src/main/java/com/jcraft/jsch/ChannelForwardedTCPIP.java index dad614b5..d168b976 100644 --- a/src/main/java/com/jcraft/jsch/ChannelForwardedTCPIP.java +++ b/src/main/java/com/jcraft/jsch/ChannelForwardedTCPIP.java @@ -26,8 +26,8 @@ package com.jcraft.jsch; -import java.net.*; -import java.io.*; +import java.io.PipedOutputStream; +import java.net.Socket; import java.util.Vector; public class ChannelForwardedTCPIP extends Channel { diff --git a/src/main/java/com/jcraft/jsch/ChannelSession.java b/src/main/java/com/jcraft/jsch/ChannelSession.java index 0827f04c..dbb8be5d 100644 --- a/src/main/java/com/jcraft/jsch/ChannelSession.java +++ b/src/main/java/com/jcraft/jsch/ChannelSession.java @@ -26,7 +26,8 @@ package com.jcraft.jsch; -import java.util.*; +import java.util.Enumeration; +import java.util.Hashtable; class ChannelSession extends Channel { private static byte[] _session = Util.str2byte("session"); diff --git a/src/main/java/com/jcraft/jsch/ChannelSftp.java b/src/main/java/com/jcraft/jsch/ChannelSftp.java index 4848339e..00a4d167 100644 --- a/src/main/java/com/jcraft/jsch/ChannelSftp.java +++ b/src/main/java/com/jcraft/jsch/ChannelSftp.java @@ -26,7 +26,14 @@ package com.jcraft.jsch; -import java.io.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PipedInputStream; +import java.io.PipedOutputStream; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.Hashtable; diff --git a/src/main/java/com/jcraft/jsch/ChannelSubsystem.java b/src/main/java/com/jcraft/jsch/ChannelSubsystem.java index 8c8ea5af..537ae391 100644 --- a/src/main/java/com/jcraft/jsch/ChannelSubsystem.java +++ b/src/main/java/com/jcraft/jsch/ChannelSubsystem.java @@ -26,7 +26,9 @@ package com.jcraft.jsch; -import java.io.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; public class ChannelSubsystem extends ChannelSession { boolean want_reply = true; diff --git a/src/main/java/com/jcraft/jsch/ChannelX11.java b/src/main/java/com/jcraft/jsch/ChannelX11.java index 7135eece..da6683b6 100644 --- a/src/main/java/com/jcraft/jsch/ChannelX11.java +++ b/src/main/java/com/jcraft/jsch/ChannelX11.java @@ -27,7 +27,7 @@ package com.jcraft.jsch; import java.io.IOException; -import java.net.*; +import java.net.Socket; import java.util.Hashtable; class ChannelX11 extends Channel { diff --git a/src/main/java/com/jcraft/jsch/ForwardedTCPIPDaemon.java b/src/main/java/com/jcraft/jsch/ForwardedTCPIPDaemon.java index d1233943..ef0fedc5 100644 --- a/src/main/java/com/jcraft/jsch/ForwardedTCPIPDaemon.java +++ b/src/main/java/com/jcraft/jsch/ForwardedTCPIPDaemon.java @@ -26,7 +26,8 @@ package com.jcraft.jsch; -import java.io.*; +import java.io.InputStream; +import java.io.OutputStream; public interface ForwardedTCPIPDaemon extends Runnable { void setChannel(ChannelForwardedTCPIP channel, InputStream in, OutputStream out); diff --git a/src/main/java/com/jcraft/jsch/IO.java b/src/main/java/com/jcraft/jsch/IO.java index 9c84488b..d00241af 100644 --- a/src/main/java/com/jcraft/jsch/IO.java +++ b/src/main/java/com/jcraft/jsch/IO.java @@ -26,7 +26,9 @@ package com.jcraft.jsch; -import java.io.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.net.SocketException; class IO { diff --git a/src/main/java/com/jcraft/jsch/KeyPair.java b/src/main/java/com/jcraft/jsch/KeyPair.java index 498b8204..ecdc3516 100644 --- a/src/main/java/com/jcraft/jsch/KeyPair.java +++ b/src/main/java/com/jcraft/jsch/KeyPair.java @@ -26,7 +26,11 @@ package com.jcraft.jsch; -import java.io.*; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; diff --git a/src/main/java/com/jcraft/jsch/Proxy.java b/src/main/java/com/jcraft/jsch/Proxy.java index abc2d280..e214ed8e 100644 --- a/src/main/java/com/jcraft/jsch/Proxy.java +++ b/src/main/java/com/jcraft/jsch/Proxy.java @@ -26,7 +26,8 @@ package com.jcraft.jsch; -import java.io.*; +import java.io.InputStream; +import java.io.OutputStream; import java.net.Socket; public interface Proxy { diff --git a/src/main/java/com/jcraft/jsch/ProxyHTTP.java b/src/main/java/com/jcraft/jsch/ProxyHTTP.java index e69c5b9d..728c25bb 100644 --- a/src/main/java/com/jcraft/jsch/ProxyHTTP.java +++ b/src/main/java/com/jcraft/jsch/ProxyHTTP.java @@ -26,8 +26,10 @@ package com.jcraft.jsch; -import java.io.*; -import java.net.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; public class ProxyHTTP implements Proxy { private static int DEFAULTPORT = 80; diff --git a/src/main/java/com/jcraft/jsch/ProxySOCKS4.java b/src/main/java/com/jcraft/jsch/ProxySOCKS4.java index 69ab8f42..540bfceb 100644 --- a/src/main/java/com/jcraft/jsch/ProxySOCKS4.java +++ b/src/main/java/com/jcraft/jsch/ProxySOCKS4.java @@ -31,8 +31,11 @@ package com.jcraft.jsch; -import java.io.*; -import java.net.*; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.InetAddress; +import java.net.Socket; +import java.net.UnknownHostException; public class ProxySOCKS4 implements Proxy { private static int DEFAULTPORT = 1080; diff --git a/src/main/java/com/jcraft/jsch/ProxySOCKS5.java b/src/main/java/com/jcraft/jsch/ProxySOCKS5.java index 2160ce50..ea6df018 100644 --- a/src/main/java/com/jcraft/jsch/ProxySOCKS5.java +++ b/src/main/java/com/jcraft/jsch/ProxySOCKS5.java @@ -31,8 +31,10 @@ package com.jcraft.jsch; -import java.io.*; -import java.net.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; public class ProxySOCKS5 implements Proxy { private static int DEFAULTPORT = 1080; diff --git a/src/main/java/com/jcraft/jsch/ServerSocketFactory.java b/src/main/java/com/jcraft/jsch/ServerSocketFactory.java index c43d140b..c60f64f4 100644 --- a/src/main/java/com/jcraft/jsch/ServerSocketFactory.java +++ b/src/main/java/com/jcraft/jsch/ServerSocketFactory.java @@ -26,8 +26,9 @@ package com.jcraft.jsch; -import java.net.*; -import java.io.*; +import java.io.IOException; +import java.net.InetAddress; +import java.net.ServerSocket; public interface ServerSocketFactory { public ServerSocket createServerSocket(int port, int backlog, InetAddress bindAddr) diff --git a/src/main/java/com/jcraft/jsch/SocketFactory.java b/src/main/java/com/jcraft/jsch/SocketFactory.java index f0a26c3f..e31f340f 100644 --- a/src/main/java/com/jcraft/jsch/SocketFactory.java +++ b/src/main/java/com/jcraft/jsch/SocketFactory.java @@ -26,8 +26,11 @@ package com.jcraft.jsch; -import java.net.*; -import java.io.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; +import java.net.UnknownHostException; public interface SocketFactory { public Socket createSocket(String host, int port) throws IOException, UnknownHostException; diff --git a/src/main/java/com/jcraft/jsch/UserAuthPublicKey.java b/src/main/java/com/jcraft/jsch/UserAuthPublicKey.java index 5cffe35a..0b5f01b3 100644 --- a/src/main/java/com/jcraft/jsch/UserAuthPublicKey.java +++ b/src/main/java/com/jcraft/jsch/UserAuthPublicKey.java @@ -26,7 +26,12 @@ package com.jcraft.jsch; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Vector; class UserAuthPublicKey extends UserAuth { diff --git a/src/main/java/com/jcraft/jsch/bc/ChaCha20Poly1305.java b/src/main/java/com/jcraft/jsch/bc/ChaCha20Poly1305.java index a088fa84..a0452a72 100644 --- a/src/main/java/com/jcraft/jsch/bc/ChaCha20Poly1305.java +++ b/src/main/java/com/jcraft/jsch/bc/ChaCha20Poly1305.java @@ -31,7 +31,8 @@ import javax.crypto.AEADBadTagException; import org.bouncycastle.crypto.engines.ChaChaEngine; import org.bouncycastle.crypto.macs.Poly1305; -import org.bouncycastle.crypto.params.*; +import org.bouncycastle.crypto.params.KeyParameter; +import org.bouncycastle.crypto.params.ParametersWithIV; public class ChaCha20Poly1305 implements Cipher { // Actually the block size, not IV size diff --git a/src/main/java/com/jcraft/jsch/bc/KeyPairGenEdDSA.java b/src/main/java/com/jcraft/jsch/bc/KeyPairGenEdDSA.java index bf57cc27..8be3d381 100644 --- a/src/main/java/com/jcraft/jsch/bc/KeyPairGenEdDSA.java +++ b/src/main/java/com/jcraft/jsch/bc/KeyPairGenEdDSA.java @@ -26,8 +26,10 @@ package com.jcraft.jsch.bc; -import java.security.*; -import org.bouncycastle.crypto.params.*; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import org.bouncycastle.crypto.params.Ed25519PrivateKeyParameters; +import org.bouncycastle.crypto.params.Ed448PrivateKeyParameters; public class KeyPairGenEdDSA implements com.jcraft.jsch.KeyPairGenEdDSA { byte[] prv; // private diff --git a/src/main/java/com/jcraft/jsch/bc/SNTRUP761.java b/src/main/java/com/jcraft/jsch/bc/SNTRUP761.java index 08862a07..b1f2677b 100644 --- a/src/main/java/com/jcraft/jsch/bc/SNTRUP761.java +++ b/src/main/java/com/jcraft/jsch/bc/SNTRUP761.java @@ -31,7 +31,12 @@ import java.lang.reflect.Constructor; import java.security.SecureRandom; import org.bouncycastle.crypto.AsymmetricCipherKeyPair; -import org.bouncycastle.pqc.crypto.ntruprime.*; +import org.bouncycastle.pqc.crypto.ntruprime.SNTRUPrimeKEMExtractor; +import org.bouncycastle.pqc.crypto.ntruprime.SNTRUPrimeKeyGenerationParameters; +import org.bouncycastle.pqc.crypto.ntruprime.SNTRUPrimeKeyPairGenerator; +import org.bouncycastle.pqc.crypto.ntruprime.SNTRUPrimeParameters; +import org.bouncycastle.pqc.crypto.ntruprime.SNTRUPrimePrivateKeyParameters; +import org.bouncycastle.pqc.crypto.ntruprime.SNTRUPrimePublicKeyParameters; public class SNTRUP761 implements KEM { SNTRUPrimeKEMExtractor extractor; diff --git a/src/main/java/com/jcraft/jsch/bc/SignatureEdDSA.java b/src/main/java/com/jcraft/jsch/bc/SignatureEdDSA.java index ca9221d6..df58207e 100644 --- a/src/main/java/com/jcraft/jsch/bc/SignatureEdDSA.java +++ b/src/main/java/com/jcraft/jsch/bc/SignatureEdDSA.java @@ -28,10 +28,16 @@ import com.jcraft.jsch.Buffer; import java.nio.charset.StandardCharsets; -import java.security.*; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.SignatureException; import org.bouncycastle.crypto.Signer; -import org.bouncycastle.crypto.params.*; -import org.bouncycastle.crypto.signers.*; +import org.bouncycastle.crypto.params.Ed25519PrivateKeyParameters; +import org.bouncycastle.crypto.params.Ed25519PublicKeyParameters; +import org.bouncycastle.crypto.params.Ed448PrivateKeyParameters; +import org.bouncycastle.crypto.params.Ed448PublicKeyParameters; +import org.bouncycastle.crypto.signers.Ed25519Signer; +import org.bouncycastle.crypto.signers.Ed448Signer; abstract class SignatureEdDSA implements com.jcraft.jsch.SignatureEdDSA { diff --git a/src/main/java/com/jcraft/jsch/bc/XDH.java b/src/main/java/com/jcraft/jsch/bc/XDH.java index fbaf306f..89db552c 100644 --- a/src/main/java/com/jcraft/jsch/bc/XDH.java +++ b/src/main/java/com/jcraft/jsch/bc/XDH.java @@ -26,8 +26,13 @@ package com.jcraft.jsch.bc; -import java.security.*; -import org.bouncycastle.crypto.params.*; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import org.bouncycastle.crypto.params.X25519PrivateKeyParameters; +import org.bouncycastle.crypto.params.X25519PublicKeyParameters; +import org.bouncycastle.crypto.params.X448PrivateKeyParameters; +import org.bouncycastle.crypto.params.X448PublicKeyParameters; public class XDH implements com.jcraft.jsch.XDH { byte[] Q_array; diff --git a/src/main/java/com/jcraft/jsch/jce/AES128CBC.java b/src/main/java/com/jcraft/jsch/jce/AES128CBC.java index 62bb4ba4..7e7ad713 100644 --- a/src/main/java/com/jcraft/jsch/jce/AES128CBC.java +++ b/src/main/java/com/jcraft/jsch/jce/AES128CBC.java @@ -27,7 +27,8 @@ package com.jcraft.jsch.jce; import com.jcraft.jsch.Cipher; -import javax.crypto.spec.*; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; public class AES128CBC implements Cipher { private static final int ivsize = 16; diff --git a/src/main/java/com/jcraft/jsch/jce/AES128CTR.java b/src/main/java/com/jcraft/jsch/jce/AES128CTR.java index 38c0c79a..8ab50c84 100644 --- a/src/main/java/com/jcraft/jsch/jce/AES128CTR.java +++ b/src/main/java/com/jcraft/jsch/jce/AES128CTR.java @@ -27,7 +27,8 @@ package com.jcraft.jsch.jce; import com.jcraft.jsch.Cipher; -import javax.crypto.spec.*; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; public class AES128CTR implements Cipher { private static final int ivsize = 16; diff --git a/src/main/java/com/jcraft/jsch/jce/AES192CBC.java b/src/main/java/com/jcraft/jsch/jce/AES192CBC.java index 1dcb8639..e3732572 100644 --- a/src/main/java/com/jcraft/jsch/jce/AES192CBC.java +++ b/src/main/java/com/jcraft/jsch/jce/AES192CBC.java @@ -27,7 +27,8 @@ package com.jcraft.jsch.jce; import com.jcraft.jsch.Cipher; -import javax.crypto.spec.*; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; public class AES192CBC implements Cipher { private static final int ivsize = 16; diff --git a/src/main/java/com/jcraft/jsch/jce/AES192CTR.java b/src/main/java/com/jcraft/jsch/jce/AES192CTR.java index 12b21066..08782261 100644 --- a/src/main/java/com/jcraft/jsch/jce/AES192CTR.java +++ b/src/main/java/com/jcraft/jsch/jce/AES192CTR.java @@ -27,7 +27,8 @@ package com.jcraft.jsch.jce; import com.jcraft.jsch.Cipher; -import javax.crypto.spec.*; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; public class AES192CTR implements Cipher { private static final int ivsize = 16; diff --git a/src/main/java/com/jcraft/jsch/jce/AES256CBC.java b/src/main/java/com/jcraft/jsch/jce/AES256CBC.java index 8fe2028b..fee50337 100644 --- a/src/main/java/com/jcraft/jsch/jce/AES256CBC.java +++ b/src/main/java/com/jcraft/jsch/jce/AES256CBC.java @@ -27,7 +27,8 @@ package com.jcraft.jsch.jce; import com.jcraft.jsch.Cipher; -import javax.crypto.spec.*; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; public class AES256CBC implements Cipher { private static final int ivsize = 16; diff --git a/src/main/java/com/jcraft/jsch/jce/AES256CTR.java b/src/main/java/com/jcraft/jsch/jce/AES256CTR.java index d78b2daa..ae207735 100644 --- a/src/main/java/com/jcraft/jsch/jce/AES256CTR.java +++ b/src/main/java/com/jcraft/jsch/jce/AES256CTR.java @@ -27,7 +27,8 @@ package com.jcraft.jsch.jce; import com.jcraft.jsch.Cipher; -import javax.crypto.spec.*; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; public class AES256CTR implements Cipher { private static final int ivsize = 16; diff --git a/src/main/java/com/jcraft/jsch/jce/AESGCM.java b/src/main/java/com/jcraft/jsch/jce/AESGCM.java index 7a521ceb..89e74475 100644 --- a/src/main/java/com/jcraft/jsch/jce/AESGCM.java +++ b/src/main/java/com/jcraft/jsch/jce/AESGCM.java @@ -28,7 +28,8 @@ import com.jcraft.jsch.Cipher; import java.nio.ByteBuffer; -import javax.crypto.spec.*; +import javax.crypto.spec.GCMParameterSpec; +import javax.crypto.spec.SecretKeySpec; abstract class AESGCM implements Cipher { // Actually the block size, not IV size diff --git a/src/main/java/com/jcraft/jsch/jce/ARCFOUR.java b/src/main/java/com/jcraft/jsch/jce/ARCFOUR.java index d9e23853..316ce26b 100644 --- a/src/main/java/com/jcraft/jsch/jce/ARCFOUR.java +++ b/src/main/java/com/jcraft/jsch/jce/ARCFOUR.java @@ -27,7 +27,7 @@ package com.jcraft.jsch.jce; import com.jcraft.jsch.Cipher; -import javax.crypto.spec.*; +import javax.crypto.spec.SecretKeySpec; public class ARCFOUR implements Cipher { private static final int ivsize = 8; diff --git a/src/main/java/com/jcraft/jsch/jce/ARCFOUR128.java b/src/main/java/com/jcraft/jsch/jce/ARCFOUR128.java index 3db7fda2..e26e8d6f 100644 --- a/src/main/java/com/jcraft/jsch/jce/ARCFOUR128.java +++ b/src/main/java/com/jcraft/jsch/jce/ARCFOUR128.java @@ -27,7 +27,7 @@ package com.jcraft.jsch.jce; import com.jcraft.jsch.Cipher; -import javax.crypto.spec.*; +import javax.crypto.spec.SecretKeySpec; public class ARCFOUR128 implements Cipher { private static final int ivsize = 8; diff --git a/src/main/java/com/jcraft/jsch/jce/ARCFOUR256.java b/src/main/java/com/jcraft/jsch/jce/ARCFOUR256.java index c618f16a..74ac0756 100644 --- a/src/main/java/com/jcraft/jsch/jce/ARCFOUR256.java +++ b/src/main/java/com/jcraft/jsch/jce/ARCFOUR256.java @@ -27,7 +27,7 @@ package com.jcraft.jsch.jce; import com.jcraft.jsch.Cipher; -import javax.crypto.spec.*; +import javax.crypto.spec.SecretKeySpec; public class ARCFOUR256 implements Cipher { private static final int ivsize = 8; diff --git a/src/main/java/com/jcraft/jsch/jce/BlowfishCBC.java b/src/main/java/com/jcraft/jsch/jce/BlowfishCBC.java index d3c048ba..20443766 100644 --- a/src/main/java/com/jcraft/jsch/jce/BlowfishCBC.java +++ b/src/main/java/com/jcraft/jsch/jce/BlowfishCBC.java @@ -27,7 +27,8 @@ package com.jcraft.jsch.jce; import com.jcraft.jsch.Cipher; -import javax.crypto.spec.*; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; public class BlowfishCBC implements Cipher { private static final int ivsize = 8; diff --git a/src/main/java/com/jcraft/jsch/jce/BlowfishCTR.java b/src/main/java/com/jcraft/jsch/jce/BlowfishCTR.java index 04978e8d..d18146cd 100644 --- a/src/main/java/com/jcraft/jsch/jce/BlowfishCTR.java +++ b/src/main/java/com/jcraft/jsch/jce/BlowfishCTR.java @@ -27,7 +27,8 @@ package com.jcraft.jsch.jce; import com.jcraft.jsch.Cipher; -import javax.crypto.spec.*; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; public class BlowfishCTR implements Cipher { private static final int ivsize = 8; diff --git a/src/main/java/com/jcraft/jsch/jce/DH.java b/src/main/java/com/jcraft/jsch/jce/DH.java index 48072e5c..c9673e63 100644 --- a/src/main/java/com/jcraft/jsch/jce/DH.java +++ b/src/main/java/com/jcraft/jsch/jce/DH.java @@ -28,10 +28,14 @@ import com.jcraft.jsch.JSchException; import java.math.BigInteger; -import java.security.*; -import javax.crypto.*; -import javax.crypto.interfaces.*; -import javax.crypto.spec.*; +import java.security.KeyFactory; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.PublicKey; +import javax.crypto.KeyAgreement; +import javax.crypto.interfaces.DHPublicKey; +import javax.crypto.spec.DHParameterSpec; +import javax.crypto.spec.DHPublicKeySpec; public class DH implements com.jcraft.jsch.DH { BigInteger p; diff --git a/src/main/java/com/jcraft/jsch/jce/ECDHN.java b/src/main/java/com/jcraft/jsch/jce/ECDHN.java index 9969a070..84f9e164 100644 --- a/src/main/java/com/jcraft/jsch/jce/ECDHN.java +++ b/src/main/java/com/jcraft/jsch/jce/ECDHN.java @@ -26,13 +26,19 @@ package com.jcraft.jsch.jce; +import com.jcraft.jsch.ECDH; import java.math.BigInteger; -import java.security.*; -import java.security.spec.*; -import java.security.interfaces.*; -import javax.crypto.*; - -public class ECDHN implements com.jcraft.jsch.ECDH { +import java.security.KeyFactory; +import java.security.PublicKey; +import java.security.interfaces.ECPublicKey; +import java.security.spec.ECFieldFp; +import java.security.spec.ECParameterSpec; +import java.security.spec.ECPoint; +import java.security.spec.ECPublicKeySpec; +import java.security.spec.EllipticCurve; +import javax.crypto.KeyAgreement; + +public class ECDHN implements ECDH { byte[] Q_array; ECPublicKey publicKey; diff --git a/src/main/java/com/jcraft/jsch/jce/HMAC.java b/src/main/java/com/jcraft/jsch/jce/HMAC.java index 8321e14b..cf1bca34 100644 --- a/src/main/java/com/jcraft/jsch/jce/HMAC.java +++ b/src/main/java/com/jcraft/jsch/jce/HMAC.java @@ -26,11 +26,12 @@ package com.jcraft.jsch.jce; +import javax.crypto.Mac; +import javax.crypto.ShortBufferException; +import javax.crypto.spec.SecretKeySpec; import com.jcraft.jsch.JSch; import com.jcraft.jsch.Logger; import com.jcraft.jsch.MAC; -import javax.crypto.*; -import javax.crypto.spec.*; abstract class HMAC implements MAC { protected String name; diff --git a/src/main/java/com/jcraft/jsch/jce/KeyPairGenDSA.java b/src/main/java/com/jcraft/jsch/jce/KeyPairGenDSA.java index 56682dea..29c06c96 100644 --- a/src/main/java/com/jcraft/jsch/jce/KeyPairGenDSA.java +++ b/src/main/java/com/jcraft/jsch/jce/KeyPairGenDSA.java @@ -26,8 +26,15 @@ package com.jcraft.jsch.jce; -import java.security.*; -import java.security.interfaces.*; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.security.SecureRandom; +import java.security.interfaces.DSAKey; +import java.security.interfaces.DSAParams; +import java.security.interfaces.DSAPrivateKey; +import java.security.interfaces.DSAPublicKey; public class KeyPairGenDSA implements com.jcraft.jsch.KeyPairGenDSA { byte[] x; // private diff --git a/src/main/java/com/jcraft/jsch/jce/KeyPairGenECDSA.java b/src/main/java/com/jcraft/jsch/jce/KeyPairGenECDSA.java index b77805c7..ac678491 100644 --- a/src/main/java/com/jcraft/jsch/jce/KeyPairGenECDSA.java +++ b/src/main/java/com/jcraft/jsch/jce/KeyPairGenECDSA.java @@ -27,9 +27,13 @@ package com.jcraft.jsch.jce; import com.jcraft.jsch.JSchException; -import java.security.*; -import java.security.interfaces.*; -import java.security.spec.*; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.interfaces.ECPrivateKey; +import java.security.interfaces.ECPublicKey; +import java.security.spec.ECGenParameterSpec; +import java.security.spec.ECParameterSpec; +import java.security.spec.ECPoint; public class KeyPairGenECDSA implements com.jcraft.jsch.KeyPairGenECDSA { byte[] d; diff --git a/src/main/java/com/jcraft/jsch/jce/KeyPairGenRSA.java b/src/main/java/com/jcraft/jsch/jce/KeyPairGenRSA.java index 32c82d5f..5a04940c 100644 --- a/src/main/java/com/jcraft/jsch/jce/KeyPairGenRSA.java +++ b/src/main/java/com/jcraft/jsch/jce/KeyPairGenRSA.java @@ -26,8 +26,14 @@ package com.jcraft.jsch.jce; -import java.security.*; -import java.security.interfaces.*; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.security.SecureRandom; +import java.security.interfaces.RSAPrivateCrtKey; +import java.security.interfaces.RSAPrivateKey; +import java.security.interfaces.RSAPublicKey; public class KeyPairGenRSA implements com.jcraft.jsch.KeyPairGenRSA { byte[] d; // private diff --git a/src/main/java/com/jcraft/jsch/jce/MD5.java b/src/main/java/com/jcraft/jsch/jce/MD5.java index 250b9b2e..21afabb7 100644 --- a/src/main/java/com/jcraft/jsch/jce/MD5.java +++ b/src/main/java/com/jcraft/jsch/jce/MD5.java @@ -27,8 +27,7 @@ package com.jcraft.jsch.jce; import com.jcraft.jsch.HASH; - -import java.security.*; +import java.security.MessageDigest; public class MD5 implements HASH { MessageDigest md; diff --git a/src/main/java/com/jcraft/jsch/jce/SHA1.java b/src/main/java/com/jcraft/jsch/jce/SHA1.java index 102f6178..47967818 100644 --- a/src/main/java/com/jcraft/jsch/jce/SHA1.java +++ b/src/main/java/com/jcraft/jsch/jce/SHA1.java @@ -27,8 +27,7 @@ package com.jcraft.jsch.jce; import com.jcraft.jsch.HASH; - -import java.security.*; +import java.security.MessageDigest; public class SHA1 implements HASH { MessageDigest md; diff --git a/src/main/java/com/jcraft/jsch/jce/SHA224.java b/src/main/java/com/jcraft/jsch/jce/SHA224.java index f8acf879..7eef4fa4 100644 --- a/src/main/java/com/jcraft/jsch/jce/SHA224.java +++ b/src/main/java/com/jcraft/jsch/jce/SHA224.java @@ -27,8 +27,7 @@ package com.jcraft.jsch.jce; import com.jcraft.jsch.HASH; - -import java.security.*; +import java.security.MessageDigest; public class SHA224 implements HASH { MessageDigest md; diff --git a/src/main/java/com/jcraft/jsch/jce/SHA256.java b/src/main/java/com/jcraft/jsch/jce/SHA256.java index 3173ab7b..67288a1a 100644 --- a/src/main/java/com/jcraft/jsch/jce/SHA256.java +++ b/src/main/java/com/jcraft/jsch/jce/SHA256.java @@ -27,8 +27,7 @@ package com.jcraft.jsch.jce; import com.jcraft.jsch.HASH; - -import java.security.*; +import java.security.MessageDigest; public class SHA256 implements HASH { MessageDigest md; diff --git a/src/main/java/com/jcraft/jsch/jce/SHA384.java b/src/main/java/com/jcraft/jsch/jce/SHA384.java index d7505b69..662f3e0b 100644 --- a/src/main/java/com/jcraft/jsch/jce/SHA384.java +++ b/src/main/java/com/jcraft/jsch/jce/SHA384.java @@ -26,9 +26,10 @@ package com.jcraft.jsch.jce; -import java.security.*; +import com.jcraft.jsch.HASH; +import java.security.MessageDigest; -public class SHA384 implements com.jcraft.jsch.HASH { +public class SHA384 implements HASH { MessageDigest md; @Override diff --git a/src/main/java/com/jcraft/jsch/jce/SHA512.java b/src/main/java/com/jcraft/jsch/jce/SHA512.java index 1a8286db..5c2df9c3 100644 --- a/src/main/java/com/jcraft/jsch/jce/SHA512.java +++ b/src/main/java/com/jcraft/jsch/jce/SHA512.java @@ -26,9 +26,10 @@ package com.jcraft.jsch.jce; -import java.security.*; +import com.jcraft.jsch.HASH; +import java.security.MessageDigest; -public class SHA512 implements com.jcraft.jsch.HASH { +public class SHA512 implements HASH { MessageDigest md; @Override diff --git a/src/main/java/com/jcraft/jsch/jce/SignatureDSA.java b/src/main/java/com/jcraft/jsch/jce/SignatureDSA.java index 9462fabb..5f6a687e 100644 --- a/src/main/java/com/jcraft/jsch/jce/SignatureDSA.java +++ b/src/main/java/com/jcraft/jsch/jce/SignatureDSA.java @@ -29,17 +29,21 @@ import com.jcraft.jsch.Buffer; import java.math.BigInteger; import java.nio.charset.StandardCharsets; -import java.security.*; -import java.security.spec.*; +import java.security.KeyFactory; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.security.Signature; +import java.security.spec.DSAPrivateKeySpec; +import java.security.spec.DSAPublicKeySpec; public class SignatureDSA implements com.jcraft.jsch.SignatureDSA { - java.security.Signature signature; + Signature signature; KeyFactory keyFactory; @Override public void init() throws Exception { - signature = java.security.Signature.getInstance("SHA1withDSA"); + signature = Signature.getInstance("SHA1withDSA"); keyFactory = KeyFactory.getInstance("DSA"); } diff --git a/src/main/java/com/jcraft/jsch/jce/SignatureECDSAN.java b/src/main/java/com/jcraft/jsch/jce/SignatureECDSAN.java index 79eb93f7..40c2b6df 100644 --- a/src/main/java/com/jcraft/jsch/jce/SignatureECDSAN.java +++ b/src/main/java/com/jcraft/jsch/jce/SignatureECDSAN.java @@ -27,11 +27,20 @@ package com.jcraft.jsch.jce; import com.jcraft.jsch.Buffer; +import com.jcraft.jsch.SignatureECDSA; import java.math.BigInteger; -import java.security.*; -import java.security.spec.*; - -abstract class SignatureECDSAN implements com.jcraft.jsch.SignatureECDSA { +import java.security.AlgorithmParameters; +import java.security.KeyFactory; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.security.Signature; +import java.security.spec.ECGenParameterSpec; +import java.security.spec.ECParameterSpec; +import java.security.spec.ECPoint; +import java.security.spec.ECPrivateKeySpec; +import java.security.spec.ECPublicKeySpec; + +abstract class SignatureECDSAN implements SignatureECDSA { Signature signature; KeyFactory keyFactory; @@ -46,7 +55,7 @@ public void init() throws Exception { foo = "SHA384withECDSA"; else if (name.equals("ecdsa-sha2-nistp521")) foo = "SHA512withECDSA"; - signature = java.security.Signature.getInstance(foo); + signature = Signature.getInstance(foo); keyFactory = KeyFactory.getInstance("EC"); } diff --git a/src/main/java/com/jcraft/jsch/jce/SignatureEd25519.java b/src/main/java/com/jcraft/jsch/jce/SignatureEd25519.java index 9078c3b2..0c1b604d 100644 --- a/src/main/java/com/jcraft/jsch/jce/SignatureEd25519.java +++ b/src/main/java/com/jcraft/jsch/jce/SignatureEd25519.java @@ -26,7 +26,9 @@ package com.jcraft.jsch.jce; -public class SignatureEd25519 implements com.jcraft.jsch.SignatureEdDSA { +import com.jcraft.jsch.SignatureEdDSA; + +public class SignatureEd25519 implements SignatureEdDSA { public SignatureEd25519() { throw new UnsupportedOperationException("SignatureEd25519 requires Java15+."); diff --git a/src/main/java/com/jcraft/jsch/jce/SignatureEd448.java b/src/main/java/com/jcraft/jsch/jce/SignatureEd448.java index dedeee89..2addd66f 100644 --- a/src/main/java/com/jcraft/jsch/jce/SignatureEd448.java +++ b/src/main/java/com/jcraft/jsch/jce/SignatureEd448.java @@ -26,7 +26,9 @@ package com.jcraft.jsch.jce; -public class SignatureEd448 implements com.jcraft.jsch.SignatureEdDSA { +import com.jcraft.jsch.SignatureEdDSA; + +public class SignatureEd448 implements SignatureEdDSA { public SignatureEd448() { throw new UnsupportedOperationException("SignatureEd448 requires Java15+."); diff --git a/src/main/java/com/jcraft/jsch/jce/SignatureRSAN.java b/src/main/java/com/jcraft/jsch/jce/SignatureRSAN.java index b0fdd25c..e1f5f392 100644 --- a/src/main/java/com/jcraft/jsch/jce/SignatureRSAN.java +++ b/src/main/java/com/jcraft/jsch/jce/SignatureRSAN.java @@ -27,14 +27,19 @@ package com.jcraft.jsch.jce; import com.jcraft.jsch.Buffer; +import com.jcraft.jsch.SignatureRSA; import java.math.BigInteger; import java.nio.charset.StandardCharsets; -import java.security.*; -import java.security.spec.*; +import java.security.KeyFactory; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.security.Signature; +import java.security.spec.RSAPrivateKeySpec; +import java.security.spec.RSAPublicKeySpec; -abstract class SignatureRSAN implements com.jcraft.jsch.SignatureRSA { +abstract class SignatureRSAN implements SignatureRSA { - java.security.Signature signature; + Signature signature; KeyFactory keyFactory; abstract String getName(); @@ -51,7 +56,7 @@ else if (name.equals("ssh-rsa-sha384@ssh.com")) foo = "SHA384withRSA"; else if (name.equals("ssh-rsa-sha224@ssh.com")) foo = "SHA224withRSA"; - signature = java.security.Signature.getInstance(foo); + signature = Signature.getInstance(foo); keyFactory = KeyFactory.getInstance("RSA"); } diff --git a/src/main/java/com/jcraft/jsch/jce/TripleDESCBC.java b/src/main/java/com/jcraft/jsch/jce/TripleDESCBC.java index 93442843..34aab47e 100644 --- a/src/main/java/com/jcraft/jsch/jce/TripleDESCBC.java +++ b/src/main/java/com/jcraft/jsch/jce/TripleDESCBC.java @@ -27,8 +27,10 @@ package com.jcraft.jsch.jce; import com.jcraft.jsch.Cipher; -import javax.crypto.*; -import javax.crypto.spec.*; +import javax.crypto.SecretKey; +import javax.crypto.SecretKeyFactory; +import javax.crypto.spec.DESedeKeySpec; +import javax.crypto.spec.IvParameterSpec; public class TripleDESCBC implements Cipher { private static final int ivsize = 8; diff --git a/src/main/java/com/jcraft/jsch/jce/TripleDESCTR.java b/src/main/java/com/jcraft/jsch/jce/TripleDESCTR.java index c4fd3338..ec7db099 100644 --- a/src/main/java/com/jcraft/jsch/jce/TripleDESCTR.java +++ b/src/main/java/com/jcraft/jsch/jce/TripleDESCTR.java @@ -27,8 +27,10 @@ package com.jcraft.jsch.jce; import com.jcraft.jsch.Cipher; -import javax.crypto.*; -import javax.crypto.spec.*; +import javax.crypto.SecretKey; +import javax.crypto.SecretKeyFactory; +import javax.crypto.spec.DESedeKeySpec; +import javax.crypto.spec.IvParameterSpec; public class TripleDESCTR implements Cipher { private static final int ivsize = 8; diff --git a/src/main/java/com/jcraft/jsch/jgss/GSSContextKrb5.java b/src/main/java/com/jcraft/jsch/jgss/GSSContextKrb5.java index 5a2a1698..689da9c4 100644 --- a/src/main/java/com/jcraft/jsch/jgss/GSSContextKrb5.java +++ b/src/main/java/com/jcraft/jsch/jgss/GSSContextKrb5.java @@ -27,7 +27,6 @@ package com.jcraft.jsch.jgss; import com.jcraft.jsch.JSchException; - import java.net.InetAddress; import java.net.UnknownHostException; import org.ietf.jgss.GSSContext; diff --git a/src/main/java/com/jcraft/jsch/juz/Compression.java b/src/main/java/com/jcraft/jsch/juz/Compression.java index 0fbd5667..ad32869a 100644 --- a/src/main/java/com/jcraft/jsch/juz/Compression.java +++ b/src/main/java/com/jcraft/jsch/juz/Compression.java @@ -1,7 +1,10 @@ package com.jcraft.jsch.juz; -import com.jcraft.jsch.*; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.Logger; +import com.jcraft.jsch.Session; import java.util.function.Supplier; +import java.util.zip.DataFormatException; import java.util.zip.Deflater; import java.util.zip.Inflater; @@ -115,7 +118,7 @@ public byte[] uncompress(byte[] buf, int start, int[] len) { System.arraycopy(tmpbuf, 0, inflated_buf, inflated_end, result); inflated_end += result; } while (inflater.getRemaining() > 0); - } catch (java.util.zip.DataFormatException e) { + } catch (DataFormatException e) { logMessage(Logger.WARN, () -> "an exception during uncompress\n" + e.toString()); } diff --git a/src/main/java/com/jcraft/jsch/jzlib/DeflaterOutputStream.java b/src/main/java/com/jcraft/jsch/jzlib/DeflaterOutputStream.java index b0b252e4..ce4be27f 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/DeflaterOutputStream.java +++ b/src/main/java/com/jcraft/jsch/jzlib/DeflaterOutputStream.java @@ -26,7 +26,9 @@ package com.jcraft.jsch.jzlib; -import java.io.*; +import java.io.FilterOutputStream; +import java.io.IOException; +import java.io.OutputStream; final class DeflaterOutputStream extends FilterOutputStream { diff --git a/src/main/java/com/jcraft/jsch/jzlib/InflaterInputStream.java b/src/main/java/com/jcraft/jsch/jzlib/InflaterInputStream.java index 6d5a90bb..a6f08be2 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/InflaterInputStream.java +++ b/src/main/java/com/jcraft/jsch/jzlib/InflaterInputStream.java @@ -26,7 +26,10 @@ package com.jcraft.jsch.jzlib; -import java.io.*; +import java.io.EOFException; +import java.io.FilterInputStream; +import java.io.IOException; +import java.io.InputStream; import java.nio.charset.StandardCharsets; final class InflaterInputStream extends FilterInputStream { diff --git a/src/main/java11/com/jcraft/jsch/jce/XDH.java b/src/main/java11/com/jcraft/jsch/jce/XDH.java index a8856e7f..4c07a54c 100644 --- a/src/main/java11/com/jcraft/jsch/jce/XDH.java +++ b/src/main/java11/com/jcraft/jsch/jce/XDH.java @@ -27,11 +27,15 @@ package com.jcraft.jsch.jce; import java.math.BigInteger; -import java.security.*; -import java.security.spec.*; -import java.security.interfaces.*; +import java.security.KeyFactory; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.PublicKey; +import java.security.interfaces.XECPublicKey; +import java.security.spec.NamedParameterSpec; +import java.security.spec.XECPublicKeySpec; import java.util.Arrays; -import javax.crypto.*; +import javax.crypto.KeyAgreement; public class XDH implements com.jcraft.jsch.XDH { byte[] Q_array; diff --git a/src/main/java15/com/jcraft/jsch/jce/KeyPairGenEdDSA.java b/src/main/java15/com/jcraft/jsch/jce/KeyPairGenEdDSA.java index 100bd095..fa02abb4 100644 --- a/src/main/java15/com/jcraft/jsch/jce/KeyPairGenEdDSA.java +++ b/src/main/java15/com/jcraft/jsch/jce/KeyPairGenEdDSA.java @@ -26,9 +26,11 @@ package com.jcraft.jsch.jce; -import java.security.*; -import java.security.interfaces.*; -import java.security.spec.*; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.interfaces.EdECPrivateKey; +import java.security.interfaces.EdECPublicKey; +import java.security.spec.EdECPoint; import java.util.Arrays; public class KeyPairGenEdDSA implements com.jcraft.jsch.KeyPairGenEdDSA { diff --git a/src/main/java15/com/jcraft/jsch/jce/SignatureEdDSA.java b/src/main/java15/com/jcraft/jsch/jce/SignatureEdDSA.java index 7a98724c..2386e20f 100644 --- a/src/main/java15/com/jcraft/jsch/jce/SignatureEdDSA.java +++ b/src/main/java15/com/jcraft/jsch/jce/SignatureEdDSA.java @@ -29,8 +29,14 @@ import com.jcraft.jsch.Buffer; import java.math.BigInteger; import java.nio.charset.StandardCharsets; -import java.security.*; -import java.security.spec.*; +import java.security.KeyFactory; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.security.Signature; +import java.security.spec.EdECPoint; +import java.security.spec.EdECPrivateKeySpec; +import java.security.spec.EdECPublicKeySpec; +import java.security.spec.NamedParameterSpec; import java.util.Arrays; abstract class SignatureEdDSA implements com.jcraft.jsch.SignatureEdDSA { @@ -46,7 +52,7 @@ abstract class SignatureEdDSA implements com.jcraft.jsch.SignatureEdDSA { @Override public void init() throws Exception { - signature = java.security.Signature.getInstance("EdDSA"); + signature = Signature.getInstance("EdDSA"); keyFactory = KeyFactory.getInstance("EdDSA"); } diff --git a/src/test/java/com/jcraft/jsch/JSchTest.java b/src/test/java/com/jcraft/jsch/JSchTest.java index 52ce1c9b..04c54422 100644 --- a/src/test/java/com/jcraft/jsch/JSchTest.java +++ b/src/test/java/com/jcraft/jsch/JSchTest.java @@ -1,6 +1,7 @@ package com.jcraft.jsch; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; import java.util.Hashtable; import org.junit.jupiter.api.BeforeEach; diff --git a/src/test/java/com/jcraft/jsch/KeyPair2Test.java b/src/test/java/com/jcraft/jsch/KeyPair2Test.java index a588a5f7..22fad28f 100644 --- a/src/test/java/com/jcraft/jsch/KeyPair2Test.java +++ b/src/test/java/com/jcraft/jsch/KeyPair2Test.java @@ -1,6 +1,8 @@ package com.jcraft.jsch; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; import java.net.URISyntaxException; diff --git a/src/test/java/com/jcraft/jsch/KeyPairTest.java b/src/test/java/com/jcraft/jsch/KeyPairTest.java index 147999df..12a19bef 100644 --- a/src/test/java/com/jcraft/jsch/KeyPairTest.java +++ b/src/test/java/com/jcraft/jsch/KeyPairTest.java @@ -1,7 +1,11 @@ package com.jcraft.jsch; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; import java.net.URISyntaxException; diff --git a/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java b/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java index 221166dc..b357c72e 100644 --- a/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java +++ b/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java @@ -1,6 +1,7 @@ package com.jcraft.jsch; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.io.IOException; import java.net.URISyntaxException; diff --git a/src/test/java/com/jcraft/jsch/SessionTest.java b/src/test/java/com/jcraft/jsch/SessionTest.java index 116a2f20..3bf5987c 100644 --- a/src/test/java/com/jcraft/jsch/SessionTest.java +++ b/src/test/java/com/jcraft/jsch/SessionTest.java @@ -1,6 +1,7 @@ package com.jcraft.jsch; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; import com.jcraft.jsch.JSchTest.TestLogger; import java.util.stream.Stream; diff --git a/src/test/java/com/jcraft/jsch/jbcrypt/BCryptTest.java b/src/test/java/com/jcraft/jsch/jbcrypt/BCryptTest.java index 6f69f4c8..607f4a1e 100644 --- a/src/test/java/com/jcraft/jsch/jbcrypt/BCryptTest.java +++ b/src/test/java/com/jcraft/jsch/jbcrypt/BCryptTest.java @@ -15,7 +15,9 @@ package com.jcraft.jsch.jbcrypt; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Arrays; import org.junit.jupiter.api.Test; diff --git a/src/test/java/com/jcraft/jsch/jzlib/Adler32Test.java b/src/test/java/com/jcraft/jsch/jzlib/Adler32Test.java index b3e09d95..68362eff 100644 --- a/src/test/java/com/jcraft/jsch/jzlib/Adler32Test.java +++ b/src/test/java/com/jcraft/jsch/jzlib/Adler32Test.java @@ -1,6 +1,6 @@ package com.jcraft.jsch.jzlib; -import static com.jcraft.jsch.jzlib.Package.*; +import static com.jcraft.jsch.jzlib.Package.randombuf; import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Arrays; diff --git a/src/test/java/com/jcraft/jsch/jzlib/CRC32Test.java b/src/test/java/com/jcraft/jsch/jzlib/CRC32Test.java index b30acd83..76cc445b 100644 --- a/src/test/java/com/jcraft/jsch/jzlib/CRC32Test.java +++ b/src/test/java/com/jcraft/jsch/jzlib/CRC32Test.java @@ -1,6 +1,6 @@ package com.jcraft.jsch.jzlib; -import static com.jcraft.jsch.jzlib.Package.*; +import static com.jcraft.jsch.jzlib.Package.randombuf; import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Arrays; diff --git a/src/test/java/com/jcraft/jsch/jzlib/DeflateInflateTest.java b/src/test/java/com/jcraft/jsch/jzlib/DeflateInflateTest.java index 3d2489d5..2a9b8988 100644 --- a/src/test/java/com/jcraft/jsch/jzlib/DeflateInflateTest.java +++ b/src/test/java/com/jcraft/jsch/jzlib/DeflateInflateTest.java @@ -1,6 +1,18 @@ package com.jcraft.jsch.jzlib; -import static com.jcraft.jsch.jzlib.JZlib.*; +import static com.jcraft.jsch.jzlib.JZlib.Z_BEST_COMPRESSION; +import static com.jcraft.jsch.jzlib.JZlib.Z_BEST_SPEED; +import static com.jcraft.jsch.jzlib.JZlib.Z_DATA_ERROR; +import static com.jcraft.jsch.jzlib.JZlib.Z_DEFAULT_COMPRESSION; +import static com.jcraft.jsch.jzlib.JZlib.Z_DEFAULT_STRATEGY; +import static com.jcraft.jsch.jzlib.JZlib.Z_FILTERED; +import static com.jcraft.jsch.jzlib.JZlib.Z_FINISH; +import static com.jcraft.jsch.jzlib.JZlib.Z_FULL_FLUSH; +import static com.jcraft.jsch.jzlib.JZlib.Z_NEED_DICT; +import static com.jcraft.jsch.jzlib.JZlib.Z_NO_COMPRESSION; +import static com.jcraft.jsch.jzlib.JZlib.Z_NO_FLUSH; +import static com.jcraft.jsch.jzlib.JZlib.Z_OK; +import static com.jcraft.jsch.jzlib.JZlib.Z_STREAM_END; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/src/test/java/com/jcraft/jsch/jzlib/DeflaterInflaterStreamTest.java b/src/test/java/com/jcraft/jsch/jzlib/DeflaterInflaterStreamTest.java index 1e9b018d..84464f86 100644 --- a/src/test/java/com/jcraft/jsch/jzlib/DeflaterInflaterStreamTest.java +++ b/src/test/java/com/jcraft/jsch/jzlib/DeflaterInflaterStreamTest.java @@ -1,6 +1,9 @@ package com.jcraft.jsch.jzlib; -import static com.jcraft.jsch.jzlib.Package.*; +import static com.jcraft.jsch.jzlib.Package.randombuf; +import static com.jcraft.jsch.jzlib.Package.readArray; +import static com.jcraft.jsch.jzlib.Package.readIS; +import static com.jcraft.jsch.jzlib.Package.uncheckedConsumer; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/src/test/java/com/jcraft/jsch/jzlib/WrapperTypeTest.java b/src/test/java/com/jcraft/jsch/jzlib/WrapperTypeTest.java index 4ec42f9e..f5140b5b 100644 --- a/src/test/java/com/jcraft/jsch/jzlib/WrapperTypeTest.java +++ b/src/test/java/com/jcraft/jsch/jzlib/WrapperTypeTest.java @@ -1,12 +1,26 @@ package com.jcraft.jsch.jzlib; -import static com.jcraft.jsch.jzlib.JZlib.*; -import static com.jcraft.jsch.jzlib.Package.*; +import static com.jcraft.jsch.jzlib.JZlib.DEF_WBITS; +import static com.jcraft.jsch.jzlib.JZlib.W_ANY; +import static com.jcraft.jsch.jzlib.JZlib.W_GZIP; +import static com.jcraft.jsch.jzlib.JZlib.W_NONE; +import static com.jcraft.jsch.jzlib.JZlib.W_ZLIB; +import static com.jcraft.jsch.jzlib.JZlib.Z_BEST_SPEED; +import static com.jcraft.jsch.jzlib.JZlib.Z_DATA_ERROR; +import static com.jcraft.jsch.jzlib.JZlib.Z_DEFAULT_COMPRESSION; +import static com.jcraft.jsch.jzlib.JZlib.Z_NO_FLUSH; +import static com.jcraft.jsch.jzlib.JZlib.Z_OK; +import static com.jcraft.jsch.jzlib.JZlib.Z_STREAM_END; +import static com.jcraft.jsch.jzlib.Package.readArray; +import static com.jcraft.jsch.jzlib.Package.readIS; +import static com.jcraft.jsch.jzlib.Package.uncheckedConsumer; +import static com.jcraft.jsch.jzlib.Package.uncheckedFunction; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; +import com.jcraft.jsch.jzlib.JZlib.WrapperType; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; From 6a3ccfbbc2cf326f776badad3fea10ec4f7e25f1 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Mon, 15 Jan 2024 16:22:27 -0600 Subject: [PATCH 184/301] Add PBKDF2-HMAC-SHA512/256 & PBKDF2-HMAC-SHA512/224, which are both supported as of Java 21. --- src/main/java/com/jcraft/jsch/JSch.java | 2 ++ .../java/com/jcraft/jsch/KeyPairPKCS8.java | 4 +-- .../jcraft/jsch/jce/PBKDF2HMACSHA512224.java | 34 +++++++++++++++++++ .../jcraft/jsch/jce/PBKDF2HMACSHA512256.java | 34 +++++++++++++++++++ 4 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/jcraft/jsch/jce/PBKDF2HMACSHA512224.java create mode 100644 src/main/java/com/jcraft/jsch/jce/PBKDF2HMACSHA512256.java diff --git a/src/main/java/com/jcraft/jsch/JSch.java b/src/main/java/com/jcraft/jsch/JSch.java index a089dd66..14d0f656 100644 --- a/src/main/java/com/jcraft/jsch/JSch.java +++ b/src/main/java/com/jcraft/jsch/JSch.java @@ -202,6 +202,8 @@ public class JSch { config.put("pbkdf2-hmac-sha256", "com.jcraft.jsch.jce.PBKDF2HMACSHA256"); config.put("pbkdf2-hmac-sha384", "com.jcraft.jsch.jce.PBKDF2HMACSHA384"); config.put("pbkdf2-hmac-sha512", "com.jcraft.jsch.jce.PBKDF2HMACSHA512"); + config.put("pbkdf2-hmac-sha512-224", "com.jcraft.jsch.jce.PBKDF2HMACSHA512224"); + config.put("pbkdf2-hmac-sha512-256", "com.jcraft.jsch.jce.PBKDF2HMACSHA512256"); config.put("bcrypt", "com.jcraft.jsch.jbcrypt.JBCrypt"); config.put("argon2", "com.jcraft.jsch.bc.Argon2"); config.put("scrypt", "com.jcraft.jsch.bc.SCrypt"); diff --git a/src/main/java/com/jcraft/jsch/KeyPairPKCS8.java b/src/main/java/com/jcraft/jsch/KeyPairPKCS8.java index e1845cf1..9a2c0fce 100644 --- a/src/main/java/com/jcraft/jsch/KeyPairPKCS8.java +++ b/src/main/java/com/jcraft/jsch/KeyPairPKCS8.java @@ -797,9 +797,9 @@ static String getPBKDF2Name(byte[] id) throws JSchException { } else if (Util.array_equals(id, hmacWithSha512)) { name = "pbkdf2-hmac-sha512"; } else if (Util.array_equals(id, hmacWithSha512224)) { - throw new JSchException("unsupported pbkdf2 function: pbkdf2-hmac-sha512-224"); + name = "pbkdf2-hmac-sha512-224"; } else if (Util.array_equals(id, hmacWithSha512256)) { - throw new JSchException("unsupported pbkdf2 function: pbkdf2-hmac-sha512-256"); + name = "pbkdf2-hmac-sha512-256"; } if (name == null) { diff --git a/src/main/java/com/jcraft/jsch/jce/PBKDF2HMACSHA512224.java b/src/main/java/com/jcraft/jsch/jce/PBKDF2HMACSHA512224.java new file mode 100644 index 00000000..de9a04ba --- /dev/null +++ b/src/main/java/com/jcraft/jsch/jce/PBKDF2HMACSHA512224.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2013-2018 ymnk, JCraft,Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions + * and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided with + * the distribution. + * + * 3. The names of the authors may not be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.jcraft.jsch.jce; + +public class PBKDF2HMACSHA512224 extends PBKDF2 { + @Override + String getName() { + return "PBKDF2WithHmacSHA512/224"; + } +} diff --git a/src/main/java/com/jcraft/jsch/jce/PBKDF2HMACSHA512256.java b/src/main/java/com/jcraft/jsch/jce/PBKDF2HMACSHA512256.java new file mode 100644 index 00000000..cf1db901 --- /dev/null +++ b/src/main/java/com/jcraft/jsch/jce/PBKDF2HMACSHA512256.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2013-2018 ymnk, JCraft,Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions + * and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided with + * the distribution. + * + * 3. The names of the authors may not be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.jcraft.jsch.jce; + +public class PBKDF2HMACSHA512256 extends PBKDF2 { + @Override + String getName() { + return "PBKDF2WithHmacSHA512/256"; + } +} From 061dfcc2b9725e445e6d04fb09e08db2636b2339 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Wed, 17 Jan 2024 07:48:40 -0600 Subject: [PATCH 185/301] Organize imports. --- src/main/java/com/jcraft/jsch/jce/HMAC.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/jcraft/jsch/jce/HMAC.java b/src/main/java/com/jcraft/jsch/jce/HMAC.java index cf1bca34..4b23f18e 100644 --- a/src/main/java/com/jcraft/jsch/jce/HMAC.java +++ b/src/main/java/com/jcraft/jsch/jce/HMAC.java @@ -26,12 +26,12 @@ package com.jcraft.jsch.jce; -import javax.crypto.Mac; -import javax.crypto.ShortBufferException; -import javax.crypto.spec.SecretKeySpec; import com.jcraft.jsch.JSch; import com.jcraft.jsch.Logger; import com.jcraft.jsch.MAC; +import javax.crypto.Mac; +import javax.crypto.ShortBufferException; +import javax.crypto.spec.SecretKeySpec; abstract class HMAC implements MAC { protected String name; From 604203c7865e500665bc2251b4833e6704a59870 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Wed, 17 Jan 2024 08:05:28 -0600 Subject: [PATCH 186/301] Always embed NoPadding into Cipher string. --- src/main/java/com/jcraft/jsch/jce/AES128CBC.java | 3 +-- src/main/java/com/jcraft/jsch/jce/AES128CTR.java | 3 +-- src/main/java/com/jcraft/jsch/jce/AES192CBC.java | 3 +-- src/main/java/com/jcraft/jsch/jce/AES192CTR.java | 3 +-- src/main/java/com/jcraft/jsch/jce/AES256CBC.java | 3 +-- src/main/java/com/jcraft/jsch/jce/AES256CTR.java | 3 +-- src/main/java/com/jcraft/jsch/jce/AESGCM.java | 3 +-- src/main/java/com/jcraft/jsch/jce/BlowfishCBC.java | 4 +--- src/main/java/com/jcraft/jsch/jce/BlowfishCTR.java | 4 +--- src/main/java/com/jcraft/jsch/jce/TripleDESCBC.java | 4 +--- src/main/java/com/jcraft/jsch/jce/TripleDESCTR.java | 4 +--- 11 files changed, 11 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/jcraft/jsch/jce/AES128CBC.java b/src/main/java/com/jcraft/jsch/jce/AES128CBC.java index 7e7ad713..ecf317d1 100644 --- a/src/main/java/com/jcraft/jsch/jce/AES128CBC.java +++ b/src/main/java/com/jcraft/jsch/jce/AES128CBC.java @@ -47,7 +47,6 @@ public int getBlockSize() { @Override public void init(int mode, byte[] key, byte[] iv) throws Exception { - String pad = "NoPadding"; byte[] tmp; if (iv.length > ivsize) { tmp = new byte[ivsize]; @@ -62,7 +61,7 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception { try { SecretKeySpec keyspec = new SecretKeySpec(key, "AES"); - cipher = javax.crypto.Cipher.getInstance("AES/CBC/" + pad); + cipher = javax.crypto.Cipher.getInstance("AES/CBC/NoPadding"); cipher.init((mode == ENCRYPT_MODE ? javax.crypto.Cipher.ENCRYPT_MODE : javax.crypto.Cipher.DECRYPT_MODE), keyspec, new IvParameterSpec(iv)); } catch (Exception e) { diff --git a/src/main/java/com/jcraft/jsch/jce/AES128CTR.java b/src/main/java/com/jcraft/jsch/jce/AES128CTR.java index 8ab50c84..753f7c6c 100644 --- a/src/main/java/com/jcraft/jsch/jce/AES128CTR.java +++ b/src/main/java/com/jcraft/jsch/jce/AES128CTR.java @@ -47,7 +47,6 @@ public int getBlockSize() { @Override public void init(int mode, byte[] key, byte[] iv) throws Exception { - String pad = "NoPadding"; byte[] tmp; if (iv.length > ivsize) { tmp = new byte[ivsize]; @@ -62,7 +61,7 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception { try { SecretKeySpec keyspec = new SecretKeySpec(key, "AES"); - cipher = javax.crypto.Cipher.getInstance("AES/CTR/" + pad); + cipher = javax.crypto.Cipher.getInstance("AES/CTR/NoPadding"); cipher.init((mode == ENCRYPT_MODE ? javax.crypto.Cipher.ENCRYPT_MODE : javax.crypto.Cipher.DECRYPT_MODE), keyspec, new IvParameterSpec(iv)); } catch (Exception e) { diff --git a/src/main/java/com/jcraft/jsch/jce/AES192CBC.java b/src/main/java/com/jcraft/jsch/jce/AES192CBC.java index e3732572..4f6d1352 100644 --- a/src/main/java/com/jcraft/jsch/jce/AES192CBC.java +++ b/src/main/java/com/jcraft/jsch/jce/AES192CBC.java @@ -47,7 +47,6 @@ public int getBlockSize() { @Override public void init(int mode, byte[] key, byte[] iv) throws Exception { - String pad = "NoPadding"; byte[] tmp; if (iv.length > ivsize) { tmp = new byte[ivsize]; @@ -61,7 +60,7 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception { } try { SecretKeySpec keyspec = new SecretKeySpec(key, "AES"); - cipher = javax.crypto.Cipher.getInstance("AES/CBC/" + pad); + cipher = javax.crypto.Cipher.getInstance("AES/CBC/NoPadding"); cipher.init((mode == ENCRYPT_MODE ? javax.crypto.Cipher.ENCRYPT_MODE : javax.crypto.Cipher.DECRYPT_MODE), keyspec, new IvParameterSpec(iv)); } catch (Exception e) { diff --git a/src/main/java/com/jcraft/jsch/jce/AES192CTR.java b/src/main/java/com/jcraft/jsch/jce/AES192CTR.java index 08782261..990d4b91 100644 --- a/src/main/java/com/jcraft/jsch/jce/AES192CTR.java +++ b/src/main/java/com/jcraft/jsch/jce/AES192CTR.java @@ -47,7 +47,6 @@ public int getBlockSize() { @Override public void init(int mode, byte[] key, byte[] iv) throws Exception { - String pad = "NoPadding"; byte[] tmp; if (iv.length > ivsize) { tmp = new byte[ivsize]; @@ -61,7 +60,7 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception { } try { SecretKeySpec keyspec = new SecretKeySpec(key, "AES"); - cipher = javax.crypto.Cipher.getInstance("AES/CTR/" + pad); + cipher = javax.crypto.Cipher.getInstance("AES/CTR/NoPadding"); cipher.init((mode == ENCRYPT_MODE ? javax.crypto.Cipher.ENCRYPT_MODE : javax.crypto.Cipher.DECRYPT_MODE), keyspec, new IvParameterSpec(iv)); } catch (Exception e) { diff --git a/src/main/java/com/jcraft/jsch/jce/AES256CBC.java b/src/main/java/com/jcraft/jsch/jce/AES256CBC.java index fee50337..5e7c3a45 100644 --- a/src/main/java/com/jcraft/jsch/jce/AES256CBC.java +++ b/src/main/java/com/jcraft/jsch/jce/AES256CBC.java @@ -47,7 +47,6 @@ public int getBlockSize() { @Override public void init(int mode, byte[] key, byte[] iv) throws Exception { - String pad = "NoPadding"; byte[] tmp; if (iv.length > ivsize) { tmp = new byte[ivsize]; @@ -61,7 +60,7 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception { } try { SecretKeySpec keyspec = new SecretKeySpec(key, "AES"); - cipher = javax.crypto.Cipher.getInstance("AES/CBC/" + pad); + cipher = javax.crypto.Cipher.getInstance("AES/CBC/NoPadding"); cipher.init((mode == ENCRYPT_MODE ? javax.crypto.Cipher.ENCRYPT_MODE : javax.crypto.Cipher.DECRYPT_MODE), keyspec, new IvParameterSpec(iv)); } catch (Exception e) { diff --git a/src/main/java/com/jcraft/jsch/jce/AES256CTR.java b/src/main/java/com/jcraft/jsch/jce/AES256CTR.java index ae207735..58b5907c 100644 --- a/src/main/java/com/jcraft/jsch/jce/AES256CTR.java +++ b/src/main/java/com/jcraft/jsch/jce/AES256CTR.java @@ -47,7 +47,6 @@ public int getBlockSize() { @Override public void init(int mode, byte[] key, byte[] iv) throws Exception { - String pad = "NoPadding"; byte[] tmp; if (iv.length > ivsize) { tmp = new byte[ivsize]; @@ -61,7 +60,7 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception { } try { SecretKeySpec keyspec = new SecretKeySpec(key, "AES"); - cipher = javax.crypto.Cipher.getInstance("AES/CTR/" + pad); + cipher = javax.crypto.Cipher.getInstance("AES/CTR/NoPadding"); cipher.init((mode == ENCRYPT_MODE ? javax.crypto.Cipher.ENCRYPT_MODE : javax.crypto.Cipher.DECRYPT_MODE), keyspec, new IvParameterSpec(iv)); } catch (Exception e) { diff --git a/src/main/java/com/jcraft/jsch/jce/AESGCM.java b/src/main/java/com/jcraft/jsch/jce/AESGCM.java index 89e74475..44025ccd 100644 --- a/src/main/java/com/jcraft/jsch/jce/AESGCM.java +++ b/src/main/java/com/jcraft/jsch/jce/AESGCM.java @@ -53,7 +53,6 @@ public int getTagSize() { @Override public void init(int mode, byte[] key, byte[] iv) throws Exception { - String pad = "NoPadding"; byte[] tmp; if (iv.length > 12) { tmp = new byte[12]; @@ -72,7 +71,7 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception { this.initcounter = this.iv.getLong(4); try { keyspec = new SecretKeySpec(key, "AES"); - cipher = javax.crypto.Cipher.getInstance("AES/GCM/" + pad); + cipher = javax.crypto.Cipher.getInstance("AES/GCM/NoPadding"); cipher.init(this.mode, keyspec, new GCMParameterSpec(tagsize * 8, iv)); } catch (Exception e) { cipher = null; diff --git a/src/main/java/com/jcraft/jsch/jce/BlowfishCBC.java b/src/main/java/com/jcraft/jsch/jce/BlowfishCBC.java index 20443766..abf1eca1 100644 --- a/src/main/java/com/jcraft/jsch/jce/BlowfishCBC.java +++ b/src/main/java/com/jcraft/jsch/jce/BlowfishCBC.java @@ -47,8 +47,6 @@ public int getBlockSize() { @Override public void init(int mode, byte[] key, byte[] iv) throws Exception { - String pad = "NoPadding"; - // if(padding) pad="PKCS5Padding"; byte[] tmp; if (iv.length > ivsize) { tmp = new byte[ivsize]; @@ -62,7 +60,7 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception { } try { SecretKeySpec skeySpec = new SecretKeySpec(key, "Blowfish"); - cipher = javax.crypto.Cipher.getInstance("Blowfish/CBC/" + pad); + cipher = javax.crypto.Cipher.getInstance("Blowfish/CBC/NoPadding"); cipher.init((mode == ENCRYPT_MODE ? javax.crypto.Cipher.ENCRYPT_MODE : javax.crypto.Cipher.DECRYPT_MODE), skeySpec, new IvParameterSpec(iv)); } catch (Exception e) { diff --git a/src/main/java/com/jcraft/jsch/jce/BlowfishCTR.java b/src/main/java/com/jcraft/jsch/jce/BlowfishCTR.java index d18146cd..16e3e0b0 100644 --- a/src/main/java/com/jcraft/jsch/jce/BlowfishCTR.java +++ b/src/main/java/com/jcraft/jsch/jce/BlowfishCTR.java @@ -47,8 +47,6 @@ public int getBlockSize() { @Override public void init(int mode, byte[] key, byte[] iv) throws Exception { - String pad = "NoPadding"; - // if(padding) pad="PKCS5Padding"; byte[] tmp; if (iv.length > ivsize) { tmp = new byte[ivsize]; @@ -62,7 +60,7 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception { } try { SecretKeySpec skeySpec = new SecretKeySpec(key, "Blowfish"); - cipher = javax.crypto.Cipher.getInstance("Blowfish/CTR/" + pad); + cipher = javax.crypto.Cipher.getInstance("Blowfish/CTR/NoPadding"); cipher.init((mode == ENCRYPT_MODE ? javax.crypto.Cipher.ENCRYPT_MODE : javax.crypto.Cipher.DECRYPT_MODE), skeySpec, new IvParameterSpec(iv)); } catch (Exception e) { diff --git a/src/main/java/com/jcraft/jsch/jce/TripleDESCBC.java b/src/main/java/com/jcraft/jsch/jce/TripleDESCBC.java index 34aab47e..2cabd039 100644 --- a/src/main/java/com/jcraft/jsch/jce/TripleDESCBC.java +++ b/src/main/java/com/jcraft/jsch/jce/TripleDESCBC.java @@ -49,8 +49,6 @@ public int getBlockSize() { @Override public void init(int mode, byte[] key, byte[] iv) throws Exception { - String pad = "NoPadding"; - // if(padding) pad="PKCS5Padding"; byte[] tmp; if (iv.length > ivsize) { tmp = new byte[ivsize]; @@ -64,7 +62,7 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception { } try { - cipher = javax.crypto.Cipher.getInstance("DESede/CBC/" + pad); + cipher = javax.crypto.Cipher.getInstance("DESede/CBC/NoPadding"); /* * // The following code does not work on IBM's JDK 1.4.1 SecretKeySpec skeySpec = new * SecretKeySpec(key, "DESede"); cipher.init((mode==ENCRYPT_MODE? diff --git a/src/main/java/com/jcraft/jsch/jce/TripleDESCTR.java b/src/main/java/com/jcraft/jsch/jce/TripleDESCTR.java index ec7db099..23dbd0b9 100644 --- a/src/main/java/com/jcraft/jsch/jce/TripleDESCTR.java +++ b/src/main/java/com/jcraft/jsch/jce/TripleDESCTR.java @@ -49,8 +49,6 @@ public int getBlockSize() { @Override public void init(int mode, byte[] key, byte[] iv) throws Exception { - String pad = "NoPadding"; - // if(padding) pad="PKCS5Padding"; byte[] tmp; if (iv.length > ivsize) { tmp = new byte[ivsize]; @@ -64,7 +62,7 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception { } try { - cipher = javax.crypto.Cipher.getInstance("DESede/CTR/" + pad); + cipher = javax.crypto.Cipher.getInstance("DESede/CTR/NoPadding"); /* * // The following code does not work on IBM's JDK 1.4.1 SecretKeySpec skeySpec = new * SecretKeySpec(key, "DESede"); cipher.init((mode==ENCRYPT_MODE? From 8455767d2dc5e1766beced5787fc6683a56de8e5 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Wed, 17 Jan 2024 08:30:54 -0600 Subject: [PATCH 187/301] Import javax.crypto.Cipher instead of com.jcraft.jsch.Cipher. --- .../java/com/jcraft/jsch/jce/AES128CBC.java | 13 +++++++------ .../java/com/jcraft/jsch/jce/AES128CTR.java | 13 +++++++------ .../java/com/jcraft/jsch/jce/AES192CBC.java | 13 +++++++------ .../java/com/jcraft/jsch/jce/AES192CTR.java | 13 +++++++------ .../java/com/jcraft/jsch/jce/AES256CBC.java | 13 +++++++------ .../java/com/jcraft/jsch/jce/AES256CTR.java | 13 +++++++------ src/main/java/com/jcraft/jsch/jce/AESGCM.java | 12 ++++++------ src/main/java/com/jcraft/jsch/jce/ARCFOUR.java | 13 +++++++------ .../java/com/jcraft/jsch/jce/ARCFOUR128.java | 13 +++++++------ .../java/com/jcraft/jsch/jce/ARCFOUR256.java | 13 +++++++------ .../java/com/jcraft/jsch/jce/BlowfishCBC.java | 13 +++++++------ .../java/com/jcraft/jsch/jce/BlowfishCTR.java | 13 +++++++------ .../java/com/jcraft/jsch/jce/TripleDESCBC.java | 18 +++++++++--------- .../java/com/jcraft/jsch/jce/TripleDESCTR.java | 18 +++++++++--------- 14 files changed, 101 insertions(+), 90 deletions(-) diff --git a/src/main/java/com/jcraft/jsch/jce/AES128CBC.java b/src/main/java/com/jcraft/jsch/jce/AES128CBC.java index ecf317d1..860f4571 100644 --- a/src/main/java/com/jcraft/jsch/jce/AES128CBC.java +++ b/src/main/java/com/jcraft/jsch/jce/AES128CBC.java @@ -26,14 +26,14 @@ package com.jcraft.jsch.jce; -import com.jcraft.jsch.Cipher; +import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; -public class AES128CBC implements Cipher { +public class AES128CBC implements com.jcraft.jsch.Cipher { private static final int ivsize = 16; private static final int bsize = 16; - private javax.crypto.Cipher cipher; + private Cipher cipher; @Override public int getIVSize() { @@ -61,9 +61,10 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception { try { SecretKeySpec keyspec = new SecretKeySpec(key, "AES"); - cipher = javax.crypto.Cipher.getInstance("AES/CBC/NoPadding"); - cipher.init((mode == ENCRYPT_MODE ? javax.crypto.Cipher.ENCRYPT_MODE - : javax.crypto.Cipher.DECRYPT_MODE), keyspec, new IvParameterSpec(iv)); + cipher = Cipher.getInstance("AES/CBC/NoPadding"); + cipher.init( + (mode == com.jcraft.jsch.Cipher.ENCRYPT_MODE ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE), + keyspec, new IvParameterSpec(iv)); } catch (Exception e) { cipher = null; throw e; diff --git a/src/main/java/com/jcraft/jsch/jce/AES128CTR.java b/src/main/java/com/jcraft/jsch/jce/AES128CTR.java index 753f7c6c..1cd5dd80 100644 --- a/src/main/java/com/jcraft/jsch/jce/AES128CTR.java +++ b/src/main/java/com/jcraft/jsch/jce/AES128CTR.java @@ -26,14 +26,14 @@ package com.jcraft.jsch.jce; -import com.jcraft.jsch.Cipher; +import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; -public class AES128CTR implements Cipher { +public class AES128CTR implements com.jcraft.jsch.Cipher { private static final int ivsize = 16; private static final int bsize = 16; - private javax.crypto.Cipher cipher; + private Cipher cipher; @Override public int getIVSize() { @@ -61,9 +61,10 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception { try { SecretKeySpec keyspec = new SecretKeySpec(key, "AES"); - cipher = javax.crypto.Cipher.getInstance("AES/CTR/NoPadding"); - cipher.init((mode == ENCRYPT_MODE ? javax.crypto.Cipher.ENCRYPT_MODE - : javax.crypto.Cipher.DECRYPT_MODE), keyspec, new IvParameterSpec(iv)); + cipher = Cipher.getInstance("AES/CTR/NoPadding"); + cipher.init( + (mode == com.jcraft.jsch.Cipher.ENCRYPT_MODE ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE), + keyspec, new IvParameterSpec(iv)); } catch (Exception e) { cipher = null; throw e; diff --git a/src/main/java/com/jcraft/jsch/jce/AES192CBC.java b/src/main/java/com/jcraft/jsch/jce/AES192CBC.java index 4f6d1352..1d1e16bb 100644 --- a/src/main/java/com/jcraft/jsch/jce/AES192CBC.java +++ b/src/main/java/com/jcraft/jsch/jce/AES192CBC.java @@ -26,14 +26,14 @@ package com.jcraft.jsch.jce; -import com.jcraft.jsch.Cipher; +import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; -public class AES192CBC implements Cipher { +public class AES192CBC implements com.jcraft.jsch.Cipher { private static final int ivsize = 16; private static final int bsize = 24; - private javax.crypto.Cipher cipher; + private Cipher cipher; @Override public int getIVSize() { @@ -60,9 +60,10 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception { } try { SecretKeySpec keyspec = new SecretKeySpec(key, "AES"); - cipher = javax.crypto.Cipher.getInstance("AES/CBC/NoPadding"); - cipher.init((mode == ENCRYPT_MODE ? javax.crypto.Cipher.ENCRYPT_MODE - : javax.crypto.Cipher.DECRYPT_MODE), keyspec, new IvParameterSpec(iv)); + cipher = Cipher.getInstance("AES/CBC/NoPadding"); + cipher.init( + (mode == com.jcraft.jsch.Cipher.ENCRYPT_MODE ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE), + keyspec, new IvParameterSpec(iv)); } catch (Exception e) { cipher = null; throw e; diff --git a/src/main/java/com/jcraft/jsch/jce/AES192CTR.java b/src/main/java/com/jcraft/jsch/jce/AES192CTR.java index 990d4b91..8d266391 100644 --- a/src/main/java/com/jcraft/jsch/jce/AES192CTR.java +++ b/src/main/java/com/jcraft/jsch/jce/AES192CTR.java @@ -26,14 +26,14 @@ package com.jcraft.jsch.jce; -import com.jcraft.jsch.Cipher; +import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; -public class AES192CTR implements Cipher { +public class AES192CTR implements com.jcraft.jsch.Cipher { private static final int ivsize = 16; private static final int bsize = 24; - private javax.crypto.Cipher cipher; + private Cipher cipher; @Override public int getIVSize() { @@ -60,9 +60,10 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception { } try { SecretKeySpec keyspec = new SecretKeySpec(key, "AES"); - cipher = javax.crypto.Cipher.getInstance("AES/CTR/NoPadding"); - cipher.init((mode == ENCRYPT_MODE ? javax.crypto.Cipher.ENCRYPT_MODE - : javax.crypto.Cipher.DECRYPT_MODE), keyspec, new IvParameterSpec(iv)); + cipher = Cipher.getInstance("AES/CTR/NoPadding"); + cipher.init( + (mode == com.jcraft.jsch.Cipher.ENCRYPT_MODE ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE), + keyspec, new IvParameterSpec(iv)); } catch (Exception e) { cipher = null; throw e; diff --git a/src/main/java/com/jcraft/jsch/jce/AES256CBC.java b/src/main/java/com/jcraft/jsch/jce/AES256CBC.java index 5e7c3a45..9a736c41 100644 --- a/src/main/java/com/jcraft/jsch/jce/AES256CBC.java +++ b/src/main/java/com/jcraft/jsch/jce/AES256CBC.java @@ -26,14 +26,14 @@ package com.jcraft.jsch.jce; -import com.jcraft.jsch.Cipher; +import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; -public class AES256CBC implements Cipher { +public class AES256CBC implements com.jcraft.jsch.Cipher { private static final int ivsize = 16; private static final int bsize = 32; - private javax.crypto.Cipher cipher; + private Cipher cipher; @Override public int getIVSize() { @@ -60,9 +60,10 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception { } try { SecretKeySpec keyspec = new SecretKeySpec(key, "AES"); - cipher = javax.crypto.Cipher.getInstance("AES/CBC/NoPadding"); - cipher.init((mode == ENCRYPT_MODE ? javax.crypto.Cipher.ENCRYPT_MODE - : javax.crypto.Cipher.DECRYPT_MODE), keyspec, new IvParameterSpec(iv)); + cipher = Cipher.getInstance("AES/CBC/NoPadding"); + cipher.init( + (mode == com.jcraft.jsch.Cipher.ENCRYPT_MODE ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE), + keyspec, new IvParameterSpec(iv)); } catch (Exception e) { cipher = null; throw e; diff --git a/src/main/java/com/jcraft/jsch/jce/AES256CTR.java b/src/main/java/com/jcraft/jsch/jce/AES256CTR.java index 58b5907c..c1f72dcc 100644 --- a/src/main/java/com/jcraft/jsch/jce/AES256CTR.java +++ b/src/main/java/com/jcraft/jsch/jce/AES256CTR.java @@ -26,14 +26,14 @@ package com.jcraft.jsch.jce; -import com.jcraft.jsch.Cipher; +import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; -public class AES256CTR implements Cipher { +public class AES256CTR implements com.jcraft.jsch.Cipher { private static final int ivsize = 16; private static final int bsize = 32; - private javax.crypto.Cipher cipher; + private Cipher cipher; @Override public int getIVSize() { @@ -60,9 +60,10 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception { } try { SecretKeySpec keyspec = new SecretKeySpec(key, "AES"); - cipher = javax.crypto.Cipher.getInstance("AES/CTR/NoPadding"); - cipher.init((mode == ENCRYPT_MODE ? javax.crypto.Cipher.ENCRYPT_MODE - : javax.crypto.Cipher.DECRYPT_MODE), keyspec, new IvParameterSpec(iv)); + cipher = Cipher.getInstance("AES/CTR/NoPadding"); + cipher.init( + (mode == com.jcraft.jsch.Cipher.ENCRYPT_MODE ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE), + keyspec, new IvParameterSpec(iv)); } catch (Exception e) { cipher = null; throw e; diff --git a/src/main/java/com/jcraft/jsch/jce/AESGCM.java b/src/main/java/com/jcraft/jsch/jce/AESGCM.java index 44025ccd..ae94e7c3 100644 --- a/src/main/java/com/jcraft/jsch/jce/AESGCM.java +++ b/src/main/java/com/jcraft/jsch/jce/AESGCM.java @@ -26,16 +26,16 @@ package com.jcraft.jsch.jce; -import com.jcraft.jsch.Cipher; import java.nio.ByteBuffer; +import javax.crypto.Cipher; import javax.crypto.spec.GCMParameterSpec; import javax.crypto.spec.SecretKeySpec; -abstract class AESGCM implements Cipher { +abstract class AESGCM implements com.jcraft.jsch.Cipher { // Actually the block size, not IV size private static final int ivsize = 16; private static final int tagsize = 16; - private javax.crypto.Cipher cipher; + private Cipher cipher; private SecretKeySpec keyspec; private int mode; private ByteBuffer iv; @@ -65,13 +65,13 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception { System.arraycopy(key, 0, tmp, 0, tmp.length); key = tmp; } - this.mode = ((mode == ENCRYPT_MODE) ? javax.crypto.Cipher.ENCRYPT_MODE - : javax.crypto.Cipher.DECRYPT_MODE); + this.mode = + ((mode == com.jcraft.jsch.Cipher.ENCRYPT_MODE) ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE); this.iv = ByteBuffer.wrap(iv); this.initcounter = this.iv.getLong(4); try { keyspec = new SecretKeySpec(key, "AES"); - cipher = javax.crypto.Cipher.getInstance("AES/GCM/NoPadding"); + cipher = Cipher.getInstance("AES/GCM/NoPadding"); cipher.init(this.mode, keyspec, new GCMParameterSpec(tagsize * 8, iv)); } catch (Exception e) { cipher = null; diff --git a/src/main/java/com/jcraft/jsch/jce/ARCFOUR.java b/src/main/java/com/jcraft/jsch/jce/ARCFOUR.java index 316ce26b..5b6ea72f 100644 --- a/src/main/java/com/jcraft/jsch/jce/ARCFOUR.java +++ b/src/main/java/com/jcraft/jsch/jce/ARCFOUR.java @@ -26,13 +26,13 @@ package com.jcraft.jsch.jce; -import com.jcraft.jsch.Cipher; +import javax.crypto.Cipher; import javax.crypto.spec.SecretKeySpec; -public class ARCFOUR implements Cipher { +public class ARCFOUR implements com.jcraft.jsch.Cipher { private static final int ivsize = 8; private static final int bsize = 16; - private javax.crypto.Cipher cipher; + private Cipher cipher; @Override public int getIVSize() { @@ -54,10 +54,11 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception { } try { - cipher = javax.crypto.Cipher.getInstance("RC4"); + cipher = Cipher.getInstance("RC4"); SecretKeySpec _key = new SecretKeySpec(key, "RC4"); - cipher.init((mode == ENCRYPT_MODE ? javax.crypto.Cipher.ENCRYPT_MODE - : javax.crypto.Cipher.DECRYPT_MODE), _key); + cipher.init( + (mode == com.jcraft.jsch.Cipher.ENCRYPT_MODE ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE), + _key); } catch (Exception e) { cipher = null; throw e; diff --git a/src/main/java/com/jcraft/jsch/jce/ARCFOUR128.java b/src/main/java/com/jcraft/jsch/jce/ARCFOUR128.java index e26e8d6f..7d10fafe 100644 --- a/src/main/java/com/jcraft/jsch/jce/ARCFOUR128.java +++ b/src/main/java/com/jcraft/jsch/jce/ARCFOUR128.java @@ -26,14 +26,14 @@ package com.jcraft.jsch.jce; -import com.jcraft.jsch.Cipher; +import javax.crypto.Cipher; import javax.crypto.spec.SecretKeySpec; -public class ARCFOUR128 implements Cipher { +public class ARCFOUR128 implements com.jcraft.jsch.Cipher { private static final int ivsize = 8; private static final int bsize = 16; private static final int skip = 1536; - private javax.crypto.Cipher cipher; + private Cipher cipher; @Override public int getIVSize() { @@ -54,10 +54,11 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception { key = tmp; } try { - cipher = javax.crypto.Cipher.getInstance("RC4"); + cipher = Cipher.getInstance("RC4"); SecretKeySpec _key = new SecretKeySpec(key, "RC4"); - cipher.init((mode == ENCRYPT_MODE ? javax.crypto.Cipher.ENCRYPT_MODE - : javax.crypto.Cipher.DECRYPT_MODE), _key); + cipher.init( + (mode == com.jcraft.jsch.Cipher.ENCRYPT_MODE ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE), + _key); byte[] foo = new byte[1]; for (int i = 0; i < skip; i++) { cipher.update(foo, 0, 1, foo, 0); diff --git a/src/main/java/com/jcraft/jsch/jce/ARCFOUR256.java b/src/main/java/com/jcraft/jsch/jce/ARCFOUR256.java index 74ac0756..5f822a1a 100644 --- a/src/main/java/com/jcraft/jsch/jce/ARCFOUR256.java +++ b/src/main/java/com/jcraft/jsch/jce/ARCFOUR256.java @@ -26,14 +26,14 @@ package com.jcraft.jsch.jce; -import com.jcraft.jsch.Cipher; +import javax.crypto.Cipher; import javax.crypto.spec.SecretKeySpec; -public class ARCFOUR256 implements Cipher { +public class ARCFOUR256 implements com.jcraft.jsch.Cipher { private static final int ivsize = 8; private static final int bsize = 32; private static final int skip = 1536; - private javax.crypto.Cipher cipher; + private Cipher cipher; @Override public int getIVSize() { @@ -54,10 +54,11 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception { key = tmp; } try { - cipher = javax.crypto.Cipher.getInstance("RC4"); + cipher = Cipher.getInstance("RC4"); SecretKeySpec _key = new SecretKeySpec(key, "RC4"); - cipher.init((mode == ENCRYPT_MODE ? javax.crypto.Cipher.ENCRYPT_MODE - : javax.crypto.Cipher.DECRYPT_MODE), _key); + cipher.init( + (mode == com.jcraft.jsch.Cipher.ENCRYPT_MODE ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE), + _key); byte[] foo = new byte[1]; for (int i = 0; i < skip; i++) { cipher.update(foo, 0, 1, foo, 0); diff --git a/src/main/java/com/jcraft/jsch/jce/BlowfishCBC.java b/src/main/java/com/jcraft/jsch/jce/BlowfishCBC.java index abf1eca1..443993e3 100644 --- a/src/main/java/com/jcraft/jsch/jce/BlowfishCBC.java +++ b/src/main/java/com/jcraft/jsch/jce/BlowfishCBC.java @@ -26,14 +26,14 @@ package com.jcraft.jsch.jce; -import com.jcraft.jsch.Cipher; +import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; -public class BlowfishCBC implements Cipher { +public class BlowfishCBC implements com.jcraft.jsch.Cipher { private static final int ivsize = 8; private static final int bsize = 16; - private javax.crypto.Cipher cipher; + private Cipher cipher; @Override public int getIVSize() { @@ -60,9 +60,10 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception { } try { SecretKeySpec skeySpec = new SecretKeySpec(key, "Blowfish"); - cipher = javax.crypto.Cipher.getInstance("Blowfish/CBC/NoPadding"); - cipher.init((mode == ENCRYPT_MODE ? javax.crypto.Cipher.ENCRYPT_MODE - : javax.crypto.Cipher.DECRYPT_MODE), skeySpec, new IvParameterSpec(iv)); + cipher = Cipher.getInstance("Blowfish/CBC/NoPadding"); + cipher.init( + (mode == com.jcraft.jsch.Cipher.ENCRYPT_MODE ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE), + skeySpec, new IvParameterSpec(iv)); } catch (Exception e) { throw e; } diff --git a/src/main/java/com/jcraft/jsch/jce/BlowfishCTR.java b/src/main/java/com/jcraft/jsch/jce/BlowfishCTR.java index 16e3e0b0..40b52d1e 100644 --- a/src/main/java/com/jcraft/jsch/jce/BlowfishCTR.java +++ b/src/main/java/com/jcraft/jsch/jce/BlowfishCTR.java @@ -26,14 +26,14 @@ package com.jcraft.jsch.jce; -import com.jcraft.jsch.Cipher; +import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; -public class BlowfishCTR implements Cipher { +public class BlowfishCTR implements com.jcraft.jsch.Cipher { private static final int ivsize = 8; private static final int bsize = 32; - private javax.crypto.Cipher cipher; + private Cipher cipher; @Override public int getIVSize() { @@ -60,9 +60,10 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception { } try { SecretKeySpec skeySpec = new SecretKeySpec(key, "Blowfish"); - cipher = javax.crypto.Cipher.getInstance("Blowfish/CTR/NoPadding"); - cipher.init((mode == ENCRYPT_MODE ? javax.crypto.Cipher.ENCRYPT_MODE - : javax.crypto.Cipher.DECRYPT_MODE), skeySpec, new IvParameterSpec(iv)); + cipher = Cipher.getInstance("Blowfish/CTR/NoPadding"); + cipher.init( + (mode == com.jcraft.jsch.Cipher.ENCRYPT_MODE ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE), + skeySpec, new IvParameterSpec(iv)); } catch (Exception e) { throw e; } diff --git a/src/main/java/com/jcraft/jsch/jce/TripleDESCBC.java b/src/main/java/com/jcraft/jsch/jce/TripleDESCBC.java index 2cabd039..35150857 100644 --- a/src/main/java/com/jcraft/jsch/jce/TripleDESCBC.java +++ b/src/main/java/com/jcraft/jsch/jce/TripleDESCBC.java @@ -26,16 +26,16 @@ package com.jcraft.jsch.jce; -import com.jcraft.jsch.Cipher; +import javax.crypto.Cipher; import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactory; import javax.crypto.spec.DESedeKeySpec; import javax.crypto.spec.IvParameterSpec; -public class TripleDESCBC implements Cipher { +public class TripleDESCBC implements com.jcraft.jsch.Cipher { private static final int ivsize = 8; private static final int bsize = 24; - private javax.crypto.Cipher cipher; + private Cipher cipher; @Override public int getIVSize() { @@ -62,18 +62,18 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception { } try { - cipher = javax.crypto.Cipher.getInstance("DESede/CBC/NoPadding"); + cipher = Cipher.getInstance("DESede/CBC/NoPadding"); /* * // The following code does not work on IBM's JDK 1.4.1 SecretKeySpec skeySpec = new - * SecretKeySpec(key, "DESede"); cipher.init((mode==ENCRYPT_MODE? - * javax.crypto.Cipher.ENCRYPT_MODE: javax.crypto.Cipher.DECRYPT_MODE), skeySpec, new - * IvParameterSpec(iv)); + * SecretKeySpec(key, "DESede"); cipher.init((mode==com.jcraft.jsch.Cipher.ENCRYPT_MODE? + * Cipher.ENCRYPT_MODE: Cipher.DECRYPT_MODE), skeySpec, new IvParameterSpec(iv)); */ DESedeKeySpec keyspec = new DESedeKeySpec(key); SecretKeyFactory keyfactory = SecretKeyFactory.getInstance("DESede"); SecretKey _key = keyfactory.generateSecret(keyspec); - cipher.init((mode == ENCRYPT_MODE ? javax.crypto.Cipher.ENCRYPT_MODE - : javax.crypto.Cipher.DECRYPT_MODE), _key, new IvParameterSpec(iv)); + cipher.init( + (mode == com.jcraft.jsch.Cipher.ENCRYPT_MODE ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE), + _key, new IvParameterSpec(iv)); } catch (Exception e) { cipher = null; throw e; diff --git a/src/main/java/com/jcraft/jsch/jce/TripleDESCTR.java b/src/main/java/com/jcraft/jsch/jce/TripleDESCTR.java index 23dbd0b9..de10ca35 100644 --- a/src/main/java/com/jcraft/jsch/jce/TripleDESCTR.java +++ b/src/main/java/com/jcraft/jsch/jce/TripleDESCTR.java @@ -26,16 +26,16 @@ package com.jcraft.jsch.jce; -import com.jcraft.jsch.Cipher; +import javax.crypto.Cipher; import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactory; import javax.crypto.spec.DESedeKeySpec; import javax.crypto.spec.IvParameterSpec; -public class TripleDESCTR implements Cipher { +public class TripleDESCTR implements com.jcraft.jsch.Cipher { private static final int ivsize = 8; private static final int bsize = 24; - private javax.crypto.Cipher cipher; + private Cipher cipher; @Override public int getIVSize() { @@ -62,18 +62,18 @@ public void init(int mode, byte[] key, byte[] iv) throws Exception { } try { - cipher = javax.crypto.Cipher.getInstance("DESede/CTR/NoPadding"); + cipher = Cipher.getInstance("DESede/CTR/NoPadding"); /* * // The following code does not work on IBM's JDK 1.4.1 SecretKeySpec skeySpec = new - * SecretKeySpec(key, "DESede"); cipher.init((mode==ENCRYPT_MODE? - * javax.crypto.Cipher.ENCRYPT_MODE: javax.crypto.Cipher.DECRYPT_MODE), skeySpec, new - * IvParameterSpec(iv)); + * SecretKeySpec(key, "DESede"); cipher.init((mode==com.jcraft.jsch.Cipher.ENCRYPT_MODE? + * Cipher.ENCRYPT_MODE: Cipher.DECRYPT_MODE), skeySpec, new IvParameterSpec(iv)); */ DESedeKeySpec keyspec = new DESedeKeySpec(key); SecretKeyFactory keyfactory = SecretKeyFactory.getInstance("DESede"); SecretKey _key = keyfactory.generateSecret(keyspec); - cipher.init((mode == ENCRYPT_MODE ? javax.crypto.Cipher.ENCRYPT_MODE - : javax.crypto.Cipher.DECRYPT_MODE), _key, new IvParameterSpec(iv)); + cipher.init( + (mode == com.jcraft.jsch.Cipher.ENCRYPT_MODE ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE), + _key, new IvParameterSpec(iv)); } catch (Exception e) { cipher = null; throw e; From 11b3fe7abae1d1c35ac55f8741df2fb3b89b703c Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Wed, 17 Jan 2024 08:36:52 -0600 Subject: [PATCH 188/301] Organize module-info. --- src/main/java9/module-info.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java9/module-info.java b/src/main/java9/module-info.java index 39da23f7..dadf75b7 100644 --- a/src/main/java9/module-info.java +++ b/src/main/java9/module-info.java @@ -1,12 +1,12 @@ module com.jcraft.jsch { exports com.jcraft.jsch; - requires static java.security.jgss; + requires static com.sun.jna; + requires static com.sun.jna.platform; requires static java.logging; + requires static java.security.jgss; requires static org.apache.logging.log4j; - requires static org.slf4j; requires static org.bouncycastle.provider; requires static org.newsclub.net.unix; - requires static com.sun.jna; - requires static com.sun.jna.platform; + requires static org.slf4j; } From e15238dfbd409bc35e92320249d865739132d4b0 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Fri, 19 Jan 2024 00:36:28 -0600 Subject: [PATCH 189/301] More formatting corrections to better adhere to Google Java Style Guide. --- examples/AES.java | 7 +- examples/ChangePassphrase.java | 1 - examples/Compression.java | 3 - examples/Daemon.java | 1 - examples/Exec.java | 1 - examples/JumpHosts.java | 1 - examples/KeyGen.java | 1 - examples/KnownHosts.java | 3 - examples/Logger.java | 8 +- examples/OpenSSHConfig.java | 3 +- examples/PortForwardingL.java | 1 - examples/PortForwardingR.java | 1 - examples/ScpFrom.java | 1 - examples/ScpTo.java | 1 - examples/ScpToNoneCipher.java | 1 - examples/Sftp.java | 1 - examples/Shell.java | 3 +- examples/SocketForwardingL.java | 4 +- examples/StreamForwarding.java | 3 - examples/Subsystem.java | 5 +- examples/Sudo.java | 6 +- examples/UserAuthKI.java | 1 - examples/UserAuthPubKey.java | 2 - examples/ViaHTTP.java | 4 - examples/ViaSOCKS5.java | 3 - examples/X11Forwarding.java | 3 - src/main/java/com/jcraft/jsch/Buffer.java | 1 - src/main/java/com/jcraft/jsch/Channel.java | 3 +- .../jcraft/jsch/ChannelAgentForwarding.java | 46 +++--- .../jcraft/jsch/ChannelDirectStreamLocal.java | 7 +- .../com/jcraft/jsch/ChannelDirectTCPIP.java | 6 +- .../jcraft/jsch/ChannelForwardedTCPIP.java | 10 +- .../java/com/jcraft/jsch/ChannelSftp.java | 31 ++-- src/main/java/com/jcraft/jsch/ChannelX11.java | 6 +- .../java/com/jcraft/jsch/Compression.java | 4 +- src/main/java/com/jcraft/jsch/Identity.java | 10 +- .../java/com/jcraft/jsch/IdentityFile.java | 4 +- src/main/java/com/jcraft/jsch/JSch.java | 33 +---- .../com/jcraft/jsch/JUnixSocketFactory.java | 2 +- src/main/java/com/jcraft/jsch/KeyPair.java | 5 +- src/main/java/com/jcraft/jsch/KeyPairDSA.java | 1 - .../java/com/jcraft/jsch/KeyPairECDSA.java | 2 - .../java/com/jcraft/jsch/KeyPairPKCS8.java | 1 - .../java/com/jcraft/jsch/OpenSSHConfig.java | 2 + src/main/java/com/jcraft/jsch/PBKDF.java | 4 +- .../java/com/jcraft/jsch/PortWatcher.java | 2 +- src/main/java/com/jcraft/jsch/Session.java | 7 +- .../java/com/jcraft/jsch/SftpStatVFS.java | 4 +- .../java/com/jcraft/jsch/Slf4jLogger.java | 4 +- .../jcraft/jsch/UserAuthGSSAPIWithMIC.java | 2 - .../com/jcraft/jsch/UserAuthPassword.java | 1 - src/main/java/com/jcraft/jsch/Util.java | 6 +- .../annotations/SuppressForbiddenApi.java | 2 +- .../java/com/jcraft/jsch/jbcrypt/BCrypt.java | 26 ++-- src/main/java/com/jcraft/jsch/jce/PBKDF.java | 8 +- src/main/java/com/jcraft/jsch/jce/PBKDF2.java | 2 +- .../com/jcraft/jsch/jce/SignatureECDSAN.java | 2 +- .../java/com/jcraft/jsch/juz/Compression.java | 5 +- .../java/com/jcraft/jsch/jzlib/Adler32.java | 4 +- .../java/com/jcraft/jsch/jzlib/CRC32.java | 1 + .../com/jcraft/jsch/jzlib/Compression.java | 2 +- .../java/com/jcraft/jsch/jzlib/Deflate.java | 133 +++++++++--------- .../java/com/jcraft/jsch/jzlib/Deflater.java | 40 +++--- .../java/com/jcraft/jsch/jzlib/InfBlocks.java | 49 +++---- .../java/com/jcraft/jsch/jzlib/InfCodes.java | 42 +++--- .../java/com/jcraft/jsch/jzlib/InfTree.java | 23 ++- .../java/com/jcraft/jsch/jzlib/Inflate.java | 89 ++++++------ .../java/com/jcraft/jsch/jzlib/Inflater.java | 40 +++--- .../jsch/jzlib/InflaterInputStream.java | 2 +- .../com/jcraft/jsch/jzlib/StaticTree.java | 12 +- src/main/java/com/jcraft/jsch/jzlib/Tree.java | 20 ++- .../java/com/jcraft/jsch/jzlib/ZStream.java | 41 +++--- src/main/java9/module-info.java | 18 +-- src/test/java/com/jcraft/jsch/JSchTest.java | 2 +- src/test/java/com/jcraft/jsch/KeyPair2IT.java | 6 +- src/test/java/com/jcraft/jsch/KeyPairIT.java | 6 +- .../java/com/jcraft/jsch/KeyPairTest.java | 1 - .../java/com/jcraft/jsch/KnownHostsTest.java | 19 ++- .../com/jcraft/jsch/OpenSSHConfigTest.java | 1 - .../java/com/jcraft/jsch/SessionTest.java | 2 +- .../com/jcraft/jsch/jbcrypt/BCryptTest.java | 24 +--- 81 files changed, 371 insertions(+), 524 deletions(-) diff --git a/examples/AES.java b/examples/AES.java index 5723ea58..7a918fc9 100644 --- a/examples/AES.java +++ b/examples/AES.java @@ -1,7 +1,4 @@ -/** - * This program will demonstrate how to use "aes128-cbc". - * - */ +/** This program will demonstrate how to use "aes128-cbc". */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.JSch; import com.jcraft.jsch.Session; @@ -153,5 +150,3 @@ public String[] promptKeyboardInteractive(String destination, String name, Strin } } } - - diff --git a/examples/ChangePassphrase.java b/examples/ChangePassphrase.java index 193b1718..c1dd39ac 100644 --- a/examples/ChangePassphrase.java +++ b/examples/ChangePassphrase.java @@ -3,7 +3,6 @@ * a new private key. A passphrase will be prompted if the given private-key has been encrypted. * After successfully loading the content of the private-key, the new passphrase will be prompted * and the given private-key will be re-encrypted with that new passphrase. - * */ import com.jcraft.jsch.JSch; import com.jcraft.jsch.KeyPair; diff --git a/examples/Compression.java b/examples/Compression.java index d5630a96..81b1814b 100644 --- a/examples/Compression.java +++ b/examples/Compression.java @@ -2,7 +2,6 @@ * This program will demonstrate the packet compression. You will be asked username, hostname and * passwd. If everything works fine, you will get the shell prompt. In this program, all data from * sshd server to jsch will be compressed. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.JSch; @@ -152,5 +151,3 @@ public String[] promptKeyboardInteractive(String destination, String name, Strin } } } - - diff --git a/examples/Daemon.java b/examples/Daemon.java index 197083b5..58f4c996 100644 --- a/examples/Daemon.java +++ b/examples/Daemon.java @@ -1,7 +1,6 @@ /** * This program will demonstrate how to provide a network service like inetd by using remote * port-forwarding functionality. - * */ import com.jcraft.jsch.ChannelForwardedTCPIP; import com.jcraft.jsch.ForwardedTCPIPDaemon; diff --git a/examples/Exec.java b/examples/Exec.java index 1635d68b..dc8348de 100644 --- a/examples/Exec.java +++ b/examples/Exec.java @@ -2,7 +2,6 @@ * This program will demonstrate remote exec. You will be asked username, hostname, displayname, * passwd and command. If everything works fine, given command will be invoked on the remote side * and outputs will be printed out. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.ChannelExec; diff --git a/examples/JumpHosts.java b/examples/JumpHosts.java index 905d8abc..e2bd0aaf 100644 --- a/examples/JumpHosts.java +++ b/examples/JumpHosts.java @@ -3,7 +3,6 @@ * to host2 and host3. java JumpHosts usr1@host1 usr2@host2 usr3@host3. You will be asked passwords * for those destinations. If everything works fine, you will get file lists of your home-directory * at host3. - * */ import com.jcraft.jsch.ChannelSftp; import com.jcraft.jsch.JSch; diff --git a/examples/KeyGen.java b/examples/KeyGen.java index 9f1810d0..3a2cde3d 100644 --- a/examples/KeyGen.java +++ b/examples/KeyGen.java @@ -2,7 +2,6 @@ * This progam will demonstrate the keypair generation. You will be asked a passphrase for * output_keyfile. If everything works fine, you will get the keypair, output_keyfile and * output_keyfile+".pub". The private key and public key are in the OpenSSH format. - * */ import com.jcraft.jsch.JSch; import com.jcraft.jsch.KeyPair; diff --git a/examples/KnownHosts.java b/examples/KnownHosts.java index bc720710..7de50ce8 100644 --- a/examples/KnownHosts.java +++ b/examples/KnownHosts.java @@ -3,7 +3,6 @@ * hostname, a path for 'known_hosts' and passwd. If everything works fine, you will get the shell * prompt. In current implementation, jsch only reads 'known_hosts' for checking and does not modify * it. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.HostKey; @@ -173,5 +172,3 @@ public String[] promptKeyboardInteractive(String destination, String name, Strin } } } - - diff --git a/examples/Logger.java b/examples/Logger.java index 862453c6..5c391004 100644 --- a/examples/Logger.java +++ b/examples/Logger.java @@ -1,7 +1,4 @@ -/** - * This program will demonstrate how to enable logging mechanism and get logging messages. - * - */ +/** This program will demonstrate how to enable logging mechanism and get logging messages. */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.JSch; import com.jcraft.jsch.Session; @@ -55,6 +52,7 @@ public static void main(String[] arg) { public static class MyLogger implements com.jcraft.jsch.Logger { static java.util.Map name = new java.util.HashMap<>(); + static { name.put(DEBUG, "DEBUG: "); name.put(INFO, "INFO: "); @@ -169,5 +167,3 @@ public String[] promptKeyboardInteractive(String destination, String name, Strin } } } - - diff --git a/examples/OpenSSHConfig.java b/examples/OpenSSHConfig.java index c9890eda..e5c7db45 100644 --- a/examples/OpenSSHConfig.java +++ b/examples/OpenSSHConfig.java @@ -2,7 +2,6 @@ * This program demonsrates how to use OpenSSHConfig class. You will be asked username, hostname and * passwd. If everything works fine, you will get the shell prompt. Output may be ugly because of * lacks of terminal-emulation, but you can issue commands. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.ConfigRepository; @@ -100,7 +99,7 @@ public boolean promptYesNo(String message) { } } - public static abstract class MyUserInfo implements UserInfo, UIKeyboardInteractive { + public abstract static class MyUserInfo implements UserInfo, UIKeyboardInteractive { @Override public String getPassword() { return null; diff --git a/examples/PortForwardingL.java b/examples/PortForwardingL.java index efdeaa96..c217bd99 100644 --- a/examples/PortForwardingL.java +++ b/examples/PortForwardingL.java @@ -3,7 +3,6 @@ * on the local host will be forwarded to the given remote host and port on the remote side. You * will be asked username, hostname, port:host:hostport and passwd. If everything works fine, you * will get the shell prompt. Try the port on localhost. - * */ import com.jcraft.jsch.JSch; import com.jcraft.jsch.Session; diff --git a/examples/PortForwardingR.java b/examples/PortForwardingR.java index 242ca1d7..7eba1e6c 100644 --- a/examples/PortForwardingR.java +++ b/examples/PortForwardingR.java @@ -3,7 +3,6 @@ * on the remote host will be forwarded to the given host and port on the local side. You will be * asked username, hostname, port:host:hostport and passwd. If everything works fine, you will get * the shell prompt. Try the port on remote host. - * */ import com.jcraft.jsch.JSch; import com.jcraft.jsch.Session; diff --git a/examples/ScpFrom.java b/examples/ScpFrom.java index bfdd86dd..611ecc5a 100644 --- a/examples/ScpFrom.java +++ b/examples/ScpFrom.java @@ -1,7 +1,6 @@ /** * This program will demonstrate the file transfer from remote to local. If everything works fine, a * file 'file1' on 'remotehost' will copied to local 'file1'. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.ChannelExec; diff --git a/examples/ScpTo.java b/examples/ScpTo.java index 1184a170..79d09a44 100644 --- a/examples/ScpTo.java +++ b/examples/ScpTo.java @@ -1,7 +1,6 @@ /** * This program will demonstrate the file transfer from local to remote. You will be asked passwd. * If everything works fine, a local file 'file1' will copied to 'file2' on 'remotehost'. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.ChannelExec; diff --git a/examples/ScpToNoneCipher.java b/examples/ScpToNoneCipher.java index b61bdd45..4a102b0b 100644 --- a/examples/ScpToNoneCipher.java +++ b/examples/ScpToNoneCipher.java @@ -1,7 +1,6 @@ /** * This program will demonstrate how to enable none cipher. You will be asked passwd. If everything * works fine, a local file 'file1' will copied to 'file2' on 'remotehost'. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.ChannelExec; diff --git a/examples/Sftp.java b/examples/Sftp.java index 5de20143..8084bcdd 100644 --- a/examples/Sftp.java +++ b/examples/Sftp.java @@ -2,7 +2,6 @@ * This program will demonstrate the sftp protocol support. If everything works fine, you will get a * prompt 'sftp>'. 'help' command will show available command. In current implementation, the * destination path for 'get' and 'put' commands must be a file, not a directory. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.ChannelSftp; diff --git a/examples/Shell.java b/examples/Shell.java index 090e6148..6ba9f730 100644 --- a/examples/Shell.java +++ b/examples/Shell.java @@ -2,7 +2,6 @@ * This program enables you to connect to sshd server and get the shell prompt. You will be asked * username, hostname and passwd. If everything works fine, you will get the shell prompt. Output * may be ugly because of lacks of terminal-emulation, but you can issue commands. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.JSch; @@ -94,7 +93,7 @@ public boolean promptYesNo(String message) { } } - public static abstract class MyUserInfo implements UserInfo, UIKeyboardInteractive { + public abstract static class MyUserInfo implements UserInfo, UIKeyboardInteractive { @Override public String getPassword() { return null; diff --git a/examples/SocketForwardingL.java b/examples/SocketForwardingL.java index 336d2c39..a1071a47 100644 --- a/examples/SocketForwardingL.java +++ b/examples/SocketForwardingL.java @@ -2,7 +2,6 @@ * This program enables you to connect to sshd server and forward the docker socket. You will be * asked username, hostname and passwd. If everything works fine, you will get the response code to * the _ping endpoint of the dockerd. - * */ import com.jcraft.jsch.JSch; import com.jcraft.jsch.Session; @@ -77,13 +76,12 @@ public boolean promptYesNo(String message) { HttpURLConnection myURLConnection2 = (HttpURLConnection) myURL.openConnection(); System.out.println("Docker Ping http response code: " + myURLConnection2.getResponseCode()); - } catch (Exception e) { System.out.println(e); } } - public static abstract class MyUserInfo implements UserInfo, UIKeyboardInteractive { + public abstract static class MyUserInfo implements UserInfo, UIKeyboardInteractive { @Override public String getPassword() { return null; diff --git a/examples/StreamForwarding.java b/examples/StreamForwarding.java index 89ca3315..7fdd4842 100644 --- a/examples/StreamForwarding.java +++ b/examples/StreamForwarding.java @@ -4,7 +4,6 @@ * command, but you don't have to assign and open a local tcp port. You will be asked username, * hostname, host:hostport and passwd. If everything works fine, System.in and System.out streams * will be forwared to remote port and you can send messages from command line. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.JSch; @@ -155,5 +154,3 @@ public String[] promptKeyboardInteractive(String destination, String name, Strin } } } - - diff --git a/examples/Subsystem.java b/examples/Subsystem.java index ac5f7f36..2f3e85e9 100644 --- a/examples/Subsystem.java +++ b/examples/Subsystem.java @@ -1,7 +1,4 @@ -/** - * This program will demonstrate how to use the Subsystem channel. - * - */ +/** This program will demonstrate how to use the Subsystem channel. */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.ChannelSubsystem; import com.jcraft.jsch.JSch; diff --git a/examples/Sudo.java b/examples/Sudo.java index cb42d6f3..cb3da7c8 100644 --- a/examples/Sudo.java +++ b/examples/Sudo.java @@ -1,7 +1,4 @@ -/** - * This program will demonstrate how to exec 'sudo' on the remote. - * - */ +/** This program will demonstrate how to exec 'sudo' on the remote. */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.ChannelExec; import com.jcraft.jsch.JSch; @@ -65,7 +62,6 @@ public static void main(String[] arg) { // password prompt and use a custom one. ((ChannelExec) channel).setCommand("sudo -S -p '' " + command); - InputStream in = channel.getInputStream(); OutputStream out = channel.getOutputStream(); ((ChannelExec) channel).setErrStream(System.err); diff --git a/examples/UserAuthKI.java b/examples/UserAuthKI.java index f2e62870..81699dbf 100644 --- a/examples/UserAuthKI.java +++ b/examples/UserAuthKI.java @@ -1,7 +1,6 @@ /** * This program will demonstrate the keyboard-interactive authentication. If the remote sshd * supports keyboard-interactive authentication, you will be prompted. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.JSch; diff --git a/examples/UserAuthPubKey.java b/examples/UserAuthPubKey.java index 03437280..adc6a3c0 100644 --- a/examples/UserAuthPubKey.java +++ b/examples/UserAuthPubKey.java @@ -2,7 +2,6 @@ * This program will demonstrate the user authentification by public key. You will be asked * username, hostname, privatekey(id_dsa) and passphrase. If everything works fine, you will get the * shell prompt. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.JSch; @@ -65,7 +64,6 @@ public static void main(String[] arg) { } } - public static class MyUserInfo implements UserInfo, UIKeyboardInteractive { @Override public String getPassword() { diff --git a/examples/ViaHTTP.java b/examples/ViaHTTP.java index ca943a96..ab4e8759 100644 --- a/examples/ViaHTTP.java +++ b/examples/ViaHTTP.java @@ -1,7 +1,6 @@ /** * This program will demonstrate the ssh session via HTTP proxy. You will be asked username, * hostname, proxy-server and passwd. If everything works fine, you will get the shell prompt. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.JSch; @@ -156,7 +155,4 @@ public String[] promptKeyboardInteractive(String destination, String name, Strin } } } - } - - diff --git a/examples/ViaSOCKS5.java b/examples/ViaSOCKS5.java index 06d31811..d232c97b 100644 --- a/examples/ViaSOCKS5.java +++ b/examples/ViaSOCKS5.java @@ -1,7 +1,6 @@ /** * This program will demonstrate the ssh session via SOCKS proxy. You will be asked username, * hostname, proxy-server and passwd. If everything works fine, you will get the shell prompt. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.JSch; @@ -157,5 +156,3 @@ public String[] promptKeyboardInteractive(String destination, String name, Strin } } } - - diff --git a/examples/X11Forwarding.java b/examples/X11Forwarding.java index a82438f1..5a819fe5 100644 --- a/examples/X11Forwarding.java +++ b/examples/X11Forwarding.java @@ -2,7 +2,6 @@ * This program will demonstrate X11 forwarding. You will be asked username, hostname, displayname * and passwd. If your X server does not run at 127.0.0.1, please enter correct displayname. If * everything works fine, you will get the shell prompt. Try X applications; for example, xlogo. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.JSch; @@ -160,5 +159,3 @@ public String[] promptKeyboardInteractive(String destination, String name, Strin } } } - - diff --git a/src/main/java/com/jcraft/jsch/Buffer.java b/src/main/java/com/jcraft/jsch/Buffer.java index e19b8000..e57fef60 100644 --- a/src/main/java/com/jcraft/jsch/Buffer.java +++ b/src/main/java/com/jcraft/jsch/Buffer.java @@ -290,7 +290,6 @@ static Buffer fromBytes(byte[][] args) { return buf; } - /* * static String[] chars={ "0","1","2","3","4","5","6","7","8","9", "a","b","c","d","e","f" }; * static void dump_buffer(){ int foo; for(int i=0; i * https://raw.githubusercontent.com/openssh/openssh-portable/master/PROTOCOL */ public class ChannelDirectStreamLocal extends ChannelDirectTCPIP { - static private final int LOCAL_WINDOW_SIZE_MAX = 0x20000; - static private final int LOCAL_MAXIMUM_PACKET_SIZE = 0x4000; - static private final byte[] _type = Util.str2byte("direct-streamlocal@openssh.com"); + private static final int LOCAL_WINDOW_SIZE_MAX = 0x20000; + private static final int LOCAL_MAXIMUM_PACKET_SIZE = 0x4000; + private static final byte[] _type = Util.str2byte("direct-streamlocal@openssh.com"); private String socketPath; diff --git a/src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java b/src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java index 37a2e94a..c1522efb 100644 --- a/src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java +++ b/src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java @@ -31,9 +31,9 @@ public class ChannelDirectTCPIP extends Channel { - static private final int LOCAL_WINDOW_SIZE_MAX = 0x20000; - static private final int LOCAL_MAXIMUM_PACKET_SIZE = 0x4000; - static private final byte[] _type = Util.str2byte("direct-tcpip"); + private static final int LOCAL_WINDOW_SIZE_MAX = 0x20000; + private static final int LOCAL_MAXIMUM_PACKET_SIZE = 0x4000; + private static final byte[] _type = Util.str2byte("direct-tcpip"); String host; int port; diff --git a/src/main/java/com/jcraft/jsch/ChannelForwardedTCPIP.java b/src/main/java/com/jcraft/jsch/ChannelForwardedTCPIP.java index d168b976..15de3829 100644 --- a/src/main/java/com/jcraft/jsch/ChannelForwardedTCPIP.java +++ b/src/main/java/com/jcraft/jsch/ChannelForwardedTCPIP.java @@ -34,11 +34,11 @@ public class ChannelForwardedTCPIP extends Channel { private static Vector pool = new Vector<>(); - static private final int LOCAL_WINDOW_SIZE_MAX = 0x20000; + private static final int LOCAL_WINDOW_SIZE_MAX = 0x20000; // static private final int LOCAL_WINDOW_SIZE_MAX=0x100000; - static private final int LOCAL_MAXIMUM_PACKET_SIZE = 0x4000; + private static final int LOCAL_MAXIMUM_PACKET_SIZE = 0x4000; - static private final int TIMEOUT = 10 * 1000; + private static final int TIMEOUT = 10 * 1000; private Socket socket = null; private ForwardedTCPIPDaemon daemon = null; @@ -278,7 +278,7 @@ static void delPort(Session session, String address_to_bind, int rport) { // string address_to_bind (e.g. "127.0.0.1") // uint32 port number to bind packet.reset(); - buf.putByte((byte) 80/* SSH_MSG_GLOBAL_REQUEST */); + buf.putByte((byte) 80 /* SSH_MSG_GLOBAL_REQUEST */); buf.putString(Util.str2byte("cancel-tcpip-forward")); buf.putByte((byte) 0); buf.putString(Util.str2byte(address_to_bind)); @@ -315,7 +315,7 @@ private void setSocketFactory(SocketFactory factory) { ((ConfigLHost) config).factory = factory; } - static abstract class Config { + abstract static class Config { Session session; int rport; int allocated_rport; diff --git a/src/main/java/com/jcraft/jsch/ChannelSftp.java b/src/main/java/com/jcraft/jsch/ChannelSftp.java index 00a4d167..6c7b6e3b 100644 --- a/src/main/java/com/jcraft/jsch/ChannelSftp.java +++ b/src/main/java/com/jcraft/jsch/ChannelSftp.java @@ -41,8 +41,8 @@ public class ChannelSftp extends ChannelSession { - static private final int LOCAL_MAXIMUM_PACKET_SIZE = 32 * 1024; - static private final int LOCAL_WINDOW_SIZE_MAX = (64 * LOCAL_MAXIMUM_PACKET_SIZE); + private static final int LOCAL_MAXIMUM_PACKET_SIZE = 32 * 1024; + private static final int LOCAL_WINDOW_SIZE_MAX = (64 * LOCAL_MAXIMUM_PACKET_SIZE); private static final byte SSH_FXP_INIT = 1; private static final byte SSH_FXP_VERSION = 2; @@ -1076,12 +1076,10 @@ private void _get(String src, OutputStream dst, SftpProgressMonitor monitor, int length -= 4; int length_of_data = buf.getInt(); // length of data - /** - * Since sftp protocol version 6, "end-of-file" has been defined, - * - * byte SSH_FXP_DATA uint32 request-id string data bool end-of-file [optional] - * - * but some sftpd server will send such a field in the sftp protocol 3 ;-( + /* + * Since sftp protocol version 6, "end-of-file" has been defined, byte SSH_FXP_DATA uint32 + * request-id string data bool end-of-file [optional] but some sftpd server will send such a + * field in the sftp protocol 3 ;-( */ int optional_data = length - length_of_data; @@ -1110,7 +1108,6 @@ private void _get(String src, OutputStream dst, SftpProgressMonitor monitor, int break loop; } } - } // System.err.println("length: "+length); // length should be 0 @@ -1143,7 +1140,6 @@ private void _get(String src, OutputStream dst, SftpProgressMonitor monitor, int } } - private class RequestQueue { class OutOfOrderException extends Exception { private static final long serialVersionUID = -1L; @@ -1153,6 +1149,7 @@ class OutOfOrderException extends Exception { this.offset = offset; } } + class Request { int id; long offset; @@ -1435,12 +1432,10 @@ public int read(byte[] d, int s, int len) throws IOException { int length_of_data = buf.getInt(); rest_length -= 4; - /** - * Since sftp protocol version 6, "end-of-file" has been defined, - * - * byte SSH_FXP_DATA uint32 request-id string data bool end-of-file [optional] - * - * but some sftpd server will send such a field in the sftp protocol 3 ;-( + /* + * Since sftp protocol version 6, "end-of-file" has been defined, byte SSH_FXP_DATA uint32 + * request-id string data bool end-of-file [optional] but some sftpd server will send such + * a field in the sftp protocol 3 ;-( */ int optional_data = rest_length - length_of_data; @@ -1593,7 +1588,6 @@ public void ls(String path, LsEntrySelector selector) throws SftpException { _pattern = Util.unquote(_pattern); pattern = Util.str2byte(_pattern, fEncoding); } - } } @@ -2522,7 +2516,7 @@ private void sendOPENW(byte[] path) throws Exception { } private void sendOPENA(byte[] path) throws Exception { - sendOPEN(path, SSH_FXF_WRITE | /* SSH_FXF_APPEND| */SSH_FXF_CREAT); + sendOPEN(path, SSH_FXF_WRITE | /* SSH_FXF_APPEND | */ SSH_FXF_CREAT); } private void sendOPEN(byte[] path, int mode) throws Exception { @@ -3034,7 +3028,6 @@ public interface LsEntrySelector { public final int BREAK = 1; /** - *

* The select method will be invoked in ls method for each file entry. * If this method returns BREAK, ls will be canceled. * diff --git a/src/main/java/com/jcraft/jsch/ChannelX11.java b/src/main/java/com/jcraft/jsch/ChannelX11.java index da6683b6..92e29d26 100644 --- a/src/main/java/com/jcraft/jsch/ChannelX11.java +++ b/src/main/java/com/jcraft/jsch/ChannelX11.java @@ -32,10 +32,10 @@ class ChannelX11 extends Channel { - static private final int LOCAL_WINDOW_SIZE_MAX = 0x20000; - static private final int LOCAL_MAXIMUM_PACKET_SIZE = 0x4000; + private static final int LOCAL_WINDOW_SIZE_MAX = 0x20000; + private static final int LOCAL_MAXIMUM_PACKET_SIZE = 0x4000; - static private final int TIMEOUT = 10 * 1000; + private static final int TIMEOUT = 10 * 1000; private static String host = "127.0.0.1"; private static int port = 6000; diff --git a/src/main/java/com/jcraft/jsch/Compression.java b/src/main/java/com/jcraft/jsch/Compression.java index a961efd6..0c084409 100644 --- a/src/main/java/com/jcraft/jsch/Compression.java +++ b/src/main/java/com/jcraft/jsch/Compression.java @@ -27,8 +27,8 @@ package com.jcraft.jsch; public interface Compression { - static public final int INFLATER = 0; - static public final int DEFLATER = 1; + public static final int INFLATER = 0; + public static final int DEFLATER = 1; default void init(int type, int level, Session session) { init(type, level); diff --git a/src/main/java/com/jcraft/jsch/Identity.java b/src/main/java/com/jcraft/jsch/Identity.java index f27c36bb..2520cd2c 100644 --- a/src/main/java/com/jcraft/jsch/Identity.java +++ b/src/main/java/com/jcraft/jsch/Identity.java @@ -45,12 +45,12 @@ public interface Identity { /** * Signs on data with this identity, and returns the result. + * *

* IMPORTANT NOTE:
* The {@link #getSignature(byte[], String)} method should be overridden to ensure {@code ssh-rsa} * type public keys function with the {@code rsa-sha2-256} or {@code rsa-sha2-512} signature * algorithms. - *

* * @param data data to be signed * @return the signature @@ -60,17 +60,17 @@ public interface Identity { /** * Signs on data with this identity, and returns the result. + * *

* IMPORTANT NOTE:
* The default implementation of this method simply calls {@link #getSignature(byte[])}, which * will fail with {@code ssh-rsa} type public keys when utilized with the {@code rsa-sha2-256} or * {@code rsa-sha2-512} signature algorithms:
* it exists only to maintain backwards compatibility of this interface. - *

+ * *

* This default method should be overridden by implementations to ensure the {@code rsa-sha2-256} * and {@code rsa-sha2-512} signature algorithms function correctly. - *

* * @param data data to be signed * @param alg signature algorithm to use @@ -117,8 +117,6 @@ public default boolean decrypt() { */ public boolean isEncrypted(); - /** - * Disposes internally allocated data, like byte array for the private key. - */ + /** Disposes internally allocated data, like byte array for the private key. */ public void clear(); } diff --git a/src/main/java/com/jcraft/jsch/IdentityFile.java b/src/main/java/com/jcraft/jsch/IdentityFile.java index f9aead36..caf40135 100644 --- a/src/main/java/com/jcraft/jsch/IdentityFile.java +++ b/src/main/java/com/jcraft/jsch/IdentityFile.java @@ -123,9 +123,7 @@ public boolean isEncrypted() { return kpair.isEncrypted(); } - /** - * Disposes internally allocated data, like byte array for the private key. - */ + /** Disposes internally allocated data, like byte array for the private key. */ @Override public void clear() { kpair.dispose(); diff --git a/src/main/java/com/jcraft/jsch/JSch.java b/src/main/java/com/jcraft/jsch/JSch.java index 14d0f656..b5d642d3 100644 --- a/src/main/java/com/jcraft/jsch/JSch.java +++ b/src/main/java/com/jcraft/jsch/JSch.java @@ -32,12 +32,11 @@ import java.util.Vector; public class JSch { - /** - * The version number. - */ + /** The version number. */ public static final String VERSION = Version.getVersion(); static Hashtable config = new Hashtable<>(); + static { config.put("kex", Util.getSystemProperty("jsch.kex", "curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256")); @@ -269,7 +268,6 @@ public class JSch { * * @param identityRepository if null is given, the default repository, which usually * refers to ~/.ssh/, will be used. - * * @see #getIdentityRepository() */ public synchronized void setIdentityRepository(IdentityRepository identityRepository) { @@ -313,11 +311,8 @@ public JSch() {} * "user.name" will be referred. * * @param host hostname - * * @throws JSchException if username or host are invalid. - * * @return the instance of Session class. - * * @see #getSession(String username, String host, int port) * @see com.jcraft.jsch.Session * @see com.jcraft.jsch.ConfigRepository @@ -333,11 +328,8 @@ public Session getSession(String host) throws JSchException { * * @param username user name * @param host hostname - * * @throws JSchException if username or host are invalid. - * * @return the instance of Session class. - * * @see #getSession(String username, String host, int port) * @see com.jcraft.jsch.Session */ @@ -353,11 +345,8 @@ public Session getSession(String username, String host) throws JSchException { * @param username user name * @param host hostname * @param port port number - * * @throws JSchException if username or host are invalid. - * * @return the instance of Session class. - * * @see #getSession(String username, String host, int port) * @see com.jcraft.jsch.Session */ @@ -385,7 +374,6 @@ protected boolean removeSession(Session session) { * Sets the hostkey repository. * * @param hkrepo - * * @see com.jcraft.jsch.HostKeyRepository * @see com.jcraft.jsch.KnownHosts */ @@ -397,9 +385,7 @@ public void setHostKeyRepository(HostKeyRepository hkrepo) { * Sets the instance of KnownHosts, which refers to filename. * * @param filename filename of known_hosts file. - * * @throws JSchException if the given filename is invalid. - * * @see com.jcraft.jsch.KnownHosts */ public void setKnownHosts(String filename) throws JSchException { @@ -416,9 +402,7 @@ public void setKnownHosts(String filename) throws JSchException { * Sets the instance of KnownHosts generated with stream. * * @param stream the instance of InputStream from known_hosts file. - * * @throws JSchException if an I/O error occurs. - * * @see com.jcraft.jsch.KnownHosts */ public void setKnownHosts(InputStream stream) throws JSchException { @@ -436,7 +420,6 @@ public void setKnownHosts(InputStream stream) throws JSchException { * KnownHosts. * * @return current hostkey repository. - * * @see com.jcraft.jsch.HostKeyRepository * @see com.jcraft.jsch.KnownHosts */ @@ -450,9 +433,7 @@ public HostKeyRepository getHostKeyRepository() { * Sets the private key, which will be referred in the public key authentication. * * @param prvkey filename of the private key. - * * @throws JSchException if prvkey is invalid. - * * @see #addIdentity(String prvkey, String passphrase) */ public void addIdentity(String prvkey) throws JSchException { @@ -465,9 +446,7 @@ public void addIdentity(String prvkey) throws JSchException { * * @param prvkey filename of the private key. * @param passphrase passphrase for prvkey. - * * @throws JSchException if passphrase is not right. - * * @see #addIdentity(String prvkey, byte[] passphrase) */ public void addIdentity(String prvkey, String passphrase) throws JSchException { @@ -486,9 +465,7 @@ public void addIdentity(String prvkey, String passphrase) throws JSchException { * * @param prvkey filename of the private key. * @param passphrase passphrase for prvkey. - * * @throws JSchException if passphrase is not right. - * * @see #addIdentity(String prvkey, String pubkey, byte[] passphrase) */ public void addIdentity(String prvkey, byte[] passphrase) throws JSchException { @@ -503,7 +480,6 @@ public void addIdentity(String prvkey, byte[] passphrase) throws JSchException { * @param prvkey filename of the private key. * @param pubkey filename of the public key. * @param passphrase passphrase for prvkey. - * * @throws JSchException if passphrase is not right. */ public void addIdentity(String prvkey, String pubkey, byte[] passphrase) throws JSchException { @@ -519,7 +495,6 @@ public void addIdentity(String prvkey, String pubkey, byte[] passphrase) throws * @param prvkey private key in byte array. * @param pubkey public key in byte array. * @param passphrase passphrase for prvkey. - * */ public void addIdentity(String name, byte[] prvkey, byte[] pubkey, byte[] passphrase) throws JSchException { @@ -533,7 +508,6 @@ public void addIdentity(String name, byte[] prvkey, byte[] pubkey, byte[] passph * * @param identity private key. * @param passphrase passphrase for identity. - * * @throws JSchException if passphrase is not right. */ public void addIdentity(Identity identity, byte[] passphrase) throws JSchException { @@ -583,7 +557,6 @@ public void removeIdentity(String name) throws JSchException { * Removes the identity from identityRepository. * * @param identity the indentity to be removed. - * * @throws JSchException if identity is invalid. */ public void removeIdentity(Identity identity) throws JSchException { @@ -594,7 +567,6 @@ public void removeIdentity(Identity identity) throws JSchException { * Lists names of identities included in the identityRepository. * * @return names of identities - * * @throws JSchException if identityReposory has problems. */ public Vector getIdentityNames() throws JSchException { @@ -665,7 +637,6 @@ public static void setConfig(String key, String value) { * Sets the logger * * @param logger logger or null if no logging should take place - * * @see com.jcraft.jsch.Logger */ public static void setLogger(Logger logger) { diff --git a/src/main/java/com/jcraft/jsch/JUnixSocketFactory.java b/src/main/java/com/jcraft/jsch/JUnixSocketFactory.java index af15017f..053e4947 100644 --- a/src/main/java/com/jcraft/jsch/JUnixSocketFactory.java +++ b/src/main/java/com/jcraft/jsch/JUnixSocketFactory.java @@ -31,8 +31,8 @@ import java.nio.channels.SocketChannel; import java.nio.file.Path; import org.newsclub.net.unix.AFUNIXServerSocketChannel; -import org.newsclub.net.unix.AFUNIXSocketChannel; import org.newsclub.net.unix.AFUNIXSocketAddress; +import org.newsclub.net.unix.AFUNIXSocketChannel; public class JUnixSocketFactory implements USocketFactory { diff --git a/src/main/java/com/jcraft/jsch/KeyPair.java b/src/main/java/com/jcraft/jsch/KeyPair.java index ecdc3516..5492b469 100644 --- a/src/main/java/com/jcraft/jsch/KeyPair.java +++ b/src/main/java/com/jcraft/jsch/KeyPair.java @@ -41,6 +41,7 @@ public abstract class KeyPair { /** DEFERRED should not be be used. */ public static final int DEFERRED = -1; + public static final int ERROR = 0; public static final int DSA = 1; public static final int RSA = 2; @@ -1221,13 +1222,13 @@ private static boolean isOpenSSHPrivateKey(byte[] buf, int i, int len) { && ident.equals(Util.byte2str(Arrays.copyOfRange(buf, i, i + ident.length()))); } - static private byte a2b(byte c) { + private static byte a2b(byte c) { if ('0' <= c && c <= '9') return (byte) (c - '0'); return (byte) (c - 'a' + 10); } - static private byte b2a(byte c) { + private static byte b2a(byte c) { if (0 <= c && c <= 9) return (byte) (c + '0'); return (byte) (c - 10 + 'A'); diff --git a/src/main/java/com/jcraft/jsch/KeyPairDSA.java b/src/main/java/com/jcraft/jsch/KeyPairDSA.java index e7400f15..d030525c 100644 --- a/src/main/java/com/jcraft/jsch/KeyPairDSA.java +++ b/src/main/java/com/jcraft/jsch/KeyPairDSA.java @@ -165,7 +165,6 @@ else if (vendor == VENDOR_OPENSSH_V1) { publicKeyComment = Util.byte2str(prvKEyBuffer.getString()); // if(P_array!=null) key_size = (new BigInteger(P_array)).bitLength(); return true; - } int index = 0; diff --git a/src/main/java/com/jcraft/jsch/KeyPairECDSA.java b/src/main/java/com/jcraft/jsch/KeyPairECDSA.java index 1d315856..c3221353 100644 --- a/src/main/java/com/jcraft/jsch/KeyPairECDSA.java +++ b/src/main/java/com/jcraft/jsch/KeyPairECDSA.java @@ -201,7 +201,6 @@ boolean parse(byte[] plain) { prvKeyBuffer.getByte(x); prvKeyBuffer.getByte(y); - prv_array = prvKeyBuffer.getString(); publicKeyComment = Util.byte2str(prvKeyBuffer.getString()); r_array = x; @@ -209,7 +208,6 @@ boolean parse(byte[] plain) { key_size = x.length >= 64 ? 521 : (x.length >= 48 ? 384 : 256); return true; - } int index = 0; diff --git a/src/main/java/com/jcraft/jsch/KeyPairPKCS8.java b/src/main/java/com/jcraft/jsch/KeyPairPKCS8.java index 9a2c0fce..131dd6db 100644 --- a/src/main/java/com/jcraft/jsch/KeyPairPKCS8.java +++ b/src/main/java/com/jcraft/jsch/KeyPairPKCS8.java @@ -122,7 +122,6 @@ class KeyPairPKCS8 extends KeyPair { private static final byte[] pbeWithSHA1AndRC2CBC = {(byte) 0x2a, (byte) 0x86, (byte) 0x48, (byte) 0x86, (byte) 0xf7, (byte) 0x0d, (byte) 0x01, (byte) 0x05, (byte) 0x0b}; - private KeyPair kpair = null; KeyPairPKCS8(JSch.InstanceLogger instLogger) { diff --git a/src/main/java/com/jcraft/jsch/OpenSSHConfig.java b/src/main/java/com/jcraft/jsch/OpenSSHConfig.java index c56f63a8..aab20e09 100644 --- a/src/main/java/com/jcraft/jsch/OpenSSHConfig.java +++ b/src/main/java/com/jcraft/jsch/OpenSSHConfig.java @@ -45,6 +45,7 @@ /** * This class implements ConfigRepository interface, and parses OpenSSH's configuration file. The * following keywords will be recognized, + * *
    *
  • Host
  • *
  • User
  • @@ -160,6 +161,7 @@ static Hashtable getKeymap() { } private static final Hashtable keymap = new Hashtable<>(); + static { keymap.put("kex", "KexAlgorithms"); keymap.put("server_host_key", "HostKeyAlgorithms"); diff --git a/src/main/java/com/jcraft/jsch/PBKDF.java b/src/main/java/com/jcraft/jsch/PBKDF.java index abd09ce6..67e6c9cf 100644 --- a/src/main/java/com/jcraft/jsch/PBKDF.java +++ b/src/main/java/com/jcraft/jsch/PBKDF.java @@ -26,9 +26,7 @@ package com.jcraft.jsch; -/** - * Use PBKDF2 instead. - */ +/** Use PBKDF2 instead. */ @Deprecated public interface PBKDF { byte[] getKey(byte[] pass, byte[] salt, int iteration, int size); diff --git a/src/main/java/com/jcraft/jsch/PortWatcher.java b/src/main/java/com/jcraft/jsch/PortWatcher.java index 4616fc52..0508f5d5 100644 --- a/src/main/java/com/jcraft/jsch/PortWatcher.java +++ b/src/main/java/com/jcraft/jsch/PortWatcher.java @@ -37,6 +37,7 @@ class PortWatcher { private static Vector pool = new Vector<>(); private static InetAddress anyLocalAddress = null; + static { // 0.0.0.0 /* @@ -49,7 +50,6 @@ class PortWatcher { } } - Session session; int lport; int rport; diff --git a/src/main/java/com/jcraft/jsch/Session.java b/src/main/java/com/jcraft/jsch/Session.java index 4ac75dbe..8c348b44 100644 --- a/src/main/java/com/jcraft/jsch/Session.java +++ b/src/main/java/com/jcraft/jsch/Session.java @@ -40,7 +40,6 @@ import java.util.Locale; import java.util.Properties; import java.util.Vector; - import javax.crypto.AEADBadTagException; public class Session { @@ -1597,7 +1596,6 @@ private void updateKeys(KeyExchange kex) throws Exception { } } - /* * RFC 4253 7.2. Output from Key Exchange If the key length needed is longer than the output of * the HASH, the key is extended by computing HASH of the concatenation of K and H and the entire @@ -1639,7 +1637,6 @@ private byte[] expandKey(Buffer buf, byte[] K, byte[] H, byte[] key, HASH hash, continue; } synchronized (c) { - if (c.rwsize < length) { try { c.notifyme++; @@ -1658,7 +1655,6 @@ private byte[] expandKey(Buffer buf, byte[] K, byte[] H, byte[] key, HASH hash, c.rwsize -= length; break; } - } if (c.close || !c.isConnected()) { throw new IOException("channel is broken"); @@ -1786,7 +1782,7 @@ void run() { try { buf = read(buf); stimeout = 0; - } catch (InterruptedIOException/* SocketTimeoutException */ ee) { + } catch (InterruptedIOException /* SocketTimeoutException */ ee) { if (!in_kex && stimeout < serverAliveCountMax) { sendKeepAliveMsg(); stimeout++; @@ -3292,7 +3288,6 @@ private void applyConfig() throws JSchException { if (value != null) { setConfig("ClearAllForwardings", value); } - } private void applyConfigChannel(ChannelSession channel) throws JSchException { diff --git a/src/main/java/com/jcraft/jsch/SftpStatVFS.java b/src/main/java/com/jcraft/jsch/SftpStatVFS.java index 193e97b0..3054d6d3 100644 --- a/src/main/java/com/jcraft/jsch/SftpStatVFS.java +++ b/src/main/java/com/jcraft/jsch/SftpStatVFS.java @@ -71,8 +71,8 @@ static SftpStatVFS getStatVFS(Buffer buf) { int flag = (int) buf.getLong(); statvfs.namemax = buf.getLong(); - statvfs.flag = (flag & 1/* SSH2_FXE_STATVFS_ST_RDONLY */) != 0 ? 1/* ST_RDONLY */ : 0; - statvfs.flag |= (flag & 2/* SSH2_FXE_STATVFS_ST_NOSUID */) != 0 ? 2/* ST_NOSUID */ : 0; + statvfs.flag = (flag & 1 /* SSH2_FXE_STATVFS_ST_RDONLY */) != 0 ? 1 /* ST_RDONLY */ : 0; + statvfs.flag |= (flag & 2 /* SSH2_FXE_STATVFS_ST_NOSUID */) != 0 ? 2 /* ST_NOSUID */ : 0; return statvfs; } diff --git a/src/main/java/com/jcraft/jsch/Slf4jLogger.java b/src/main/java/com/jcraft/jsch/Slf4jLogger.java index c24c1563..0fccd2c9 100644 --- a/src/main/java/com/jcraft/jsch/Slf4jLogger.java +++ b/src/main/java/com/jcraft/jsch/Slf4jLogger.java @@ -3,9 +3,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** - * JSch logger to log entries using the SLF4J framework - */ +/** JSch logger to log entries using the SLF4J framework */ public class Slf4jLogger implements com.jcraft.jsch.Logger { private static final Logger logger = LoggerFactory.getLogger(JSch.class); diff --git a/src/main/java/com/jcraft/jsch/UserAuthGSSAPIWithMIC.java b/src/main/java/com/jcraft/jsch/UserAuthGSSAPIWithMIC.java index 7a10780e..92e9cd76 100644 --- a/src/main/java/com/jcraft/jsch/UserAuthGSSAPIWithMIC.java +++ b/src/main/java/com/jcraft/jsch/UserAuthGSSAPIWithMIC.java @@ -221,5 +221,3 @@ public boolean start(Session session) throws Exception { return false; } } - - diff --git a/src/main/java/com/jcraft/jsch/UserAuthPassword.java b/src/main/java/com/jcraft/jsch/UserAuthPassword.java index 111e0def..375f11e4 100644 --- a/src/main/java/com/jcraft/jsch/UserAuthPassword.java +++ b/src/main/java/com/jcraft/jsch/UserAuthPassword.java @@ -174,7 +174,6 @@ public boolean start(Session session) throws Exception { Util.bzero(password); password = null; } - } } finally { diff --git a/src/main/java/com/jcraft/jsch/Util.java b/src/main/java/com/jcraft/jsch/Util.java index dde331e7..b7ef747d 100644 --- a/src/main/java/com/jcraft/jsch/Util.java +++ b/src/main/java/com/jcraft/jsch/Util.java @@ -28,8 +28,8 @@ import java.io.File; import java.io.FileInputStream; -import java.io.InputStream; import java.io.IOException; +import java.io.InputStream; import java.net.InetSocketAddress; import java.net.Socket; import java.net.SocketTimeoutException; @@ -152,7 +152,7 @@ static boolean glob(byte[] pattern, byte[] name) { return glob0(pattern, 0, name, 0); } - static private boolean glob0(byte[] pattern, int pattern_index, byte[] name, int name_index) { + private static boolean glob0(byte[] pattern, int pattern_index, byte[] name, int name_index) { if (name.length > 0 && name[0] == '.') { if (pattern.length > 0 && pattern[0] == '.') { if (pattern.length == 2 && pattern[1] == '*') @@ -164,7 +164,7 @@ static private boolean glob0(byte[] pattern, int pattern_index, byte[] name, int return glob(pattern, pattern_index, name, name_index); } - static private boolean glob(byte[] pattern, int pattern_index, byte[] name, int name_index) { + private static boolean glob(byte[] pattern, int pattern_index, byte[] name, int name_index) { // System.err.println("glob: "+new String(pattern)+", "+pattern_index+" "+new String(name)+", // "+name_index); diff --git a/src/main/java/com/jcraft/jsch/annotations/SuppressForbiddenApi.java b/src/main/java/com/jcraft/jsch/annotations/SuppressForbiddenApi.java index b3494689..fb9a3569 100644 --- a/src/main/java/com/jcraft/jsch/annotations/SuppressForbiddenApi.java +++ b/src/main/java/com/jcraft/jsch/annotations/SuppressForbiddenApi.java @@ -1,9 +1,9 @@ package com.jcraft.jsch.annotations; +import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import java.lang.annotation.ElementType; @Retention(RetentionPolicy.CLASS) @Target({ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.LOCAL_VARIABLE, ElementType.METHOD, diff --git a/src/main/java/com/jcraft/jsch/jbcrypt/BCrypt.java b/src/main/java/com/jcraft/jsch/jbcrypt/BCrypt.java index 4f4dab88..332f879b 100644 --- a/src/main/java/com/jcraft/jsch/jbcrypt/BCrypt.java +++ b/src/main/java/com/jcraft/jsch/jbcrypt/BCrypt.java @@ -23,20 +23,25 @@ /** * BCrypt implements OpenBSD-style Blowfish password hashing using the scheme described in "A * Future-Adaptable Password Scheme" by Niels Provos and David Mazieres. + * *

    * This password hashing system tries to thwart off-line password cracking using a * computationally-intensive hashing algorithm, based on Bruce Schneier's Blowfish cipher. The work * factor of the algorithm is parameterised, so it can be increased as computers get faster. + * *

    * Usage is really simple. To hash a password for the first time, call the hashpw method with a * random salt, like this: + * *

    * * String pw_hash = BCrypt.hashpw(plain_password, BCrypt.gensalt());
    *
    + * *

    * To check whether a plaintext password matches one that has been hashed previously, use the * checkpw method: + * *

    * * if (BCrypt.checkpw(candidate_password, stored_hash))
    @@ -44,14 +49,17 @@ * else
    *     System.out.println("It does not match");
    *
    + * *

    * The gensalt() method takes an optional parameter (log_rounds) that determines the computational * complexity of the hashing: + * *

    * * String strong_salt = BCrypt.gensalt(10)
    * String stronger_salt = BCrypt.gensalt(12)
    *
    + * *

    * The amount of work increases exponentially (2**log_rounds), so each increment is twice as much * work. The default log_rounds is 10, and the valid range is 4 to 30. @@ -226,17 +234,17 @@ public class BCrypt { // bcrypt IV: "OrpheanBeholderScryDoubt". The C implementation calls // this "ciphertext", but it is really plaintext or an IV. We keep // the name to make code comparison easier. - static private final int bf_crypt_ciphertext[] = + private static final int bf_crypt_ciphertext[] = {0x4f727068, 0x65616e42, 0x65686f6c, 0x64657253, 0x63727944, 0x6f756274}; // Table for Base64 encoding - static private final char base64_code[] = {'.', '/', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', + private static final char base64_code[] = {'.', '/', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; // Table for Base64 decoding - static private final byte index_64[] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + private static final byte index_64[] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, -1, -1, -1, -1, -1, -1, -1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, @@ -400,9 +408,7 @@ private static int streamtoword(byte data[], int offp[]) { return word; } - /** - * Initialise the Blowfish key schedule - */ + /** Initialise the Blowfish key schedule */ private void init_key() { P = P_orig.clone(); S = S_orig.clone(); @@ -468,9 +474,7 @@ private void ekskey(byte data[], byte key[]) { } } - /** - * Compatibility with new OpenBSD function. - */ + /** Compatibility with new OpenBSD function. */ public void hash(byte[] hpass, byte[] hsalt, byte[] output) { init_key(); ekskey(hsalt, hpass); @@ -496,9 +500,7 @@ public void hash(byte[] hpass, byte[] hsalt, byte[] output) { } } - /** - * Compatibility with new OpenBSD function. - */ + /** Compatibility with new OpenBSD function. */ public void pbkdf(byte[] password, byte[] salt, int rounds, byte[] output) { try { MessageDigest sha512 = MessageDigest.getInstance("SHA-512"); diff --git a/src/main/java/com/jcraft/jsch/jce/PBKDF.java b/src/main/java/com/jcraft/jsch/jce/PBKDF.java index 85a031df..2cfb574b 100644 --- a/src/main/java/com/jcraft/jsch/jce/PBKDF.java +++ b/src/main/java/com/jcraft/jsch/jce/PBKDF.java @@ -26,14 +26,12 @@ package com.jcraft.jsch.jce; -import java.security.spec.InvalidKeySpecException; import java.security.NoSuchAlgorithmException; -import javax.crypto.spec.PBEKeySpec; +import java.security.spec.InvalidKeySpecException; import javax.crypto.SecretKeyFactory; +import javax.crypto.spec.PBEKeySpec; -/** - * Use PBKDF2 instead. - */ +/** Use PBKDF2 instead. */ @Deprecated public class PBKDF implements com.jcraft.jsch.PBKDF { @Override diff --git a/src/main/java/com/jcraft/jsch/jce/PBKDF2.java b/src/main/java/com/jcraft/jsch/jce/PBKDF2.java index 527661f4..8279d69a 100644 --- a/src/main/java/com/jcraft/jsch/jce/PBKDF2.java +++ b/src/main/java/com/jcraft/jsch/jce/PBKDF2.java @@ -27,8 +27,8 @@ package com.jcraft.jsch.jce; import java.security.spec.InvalidKeySpecException; -import javax.crypto.spec.PBEKeySpec; import javax.crypto.SecretKeyFactory; +import javax.crypto.spec.PBEKeySpec; abstract class PBKDF2 implements com.jcraft.jsch.PBKDF2 { private SecretKeyFactory skf; diff --git a/src/main/java/com/jcraft/jsch/jce/SignatureECDSAN.java b/src/main/java/com/jcraft/jsch/jce/SignatureECDSAN.java index 40c2b6df..307a043f 100644 --- a/src/main/java/com/jcraft/jsch/jce/SignatureECDSAN.java +++ b/src/main/java/com/jcraft/jsch/jce/SignatureECDSAN.java @@ -108,7 +108,7 @@ public byte[] sign() throws Exception { // so we have to convert it. if (sig[0] == 0x30 && // in ASN.1 ((sig[1] + 2 == sig.length) - || ((sig[1] & 0x80) != 0 && (sig[2] & 0xff) + 3 == sig.length))) {// 2bytes for len + || ((sig[1] & 0x80) != 0 && (sig[2] & 0xff) + 3 == sig.length))) { // 2bytes for len int index = 3; if ((sig[1] & 0x80) != 0 && (sig[2] & 0xff) + 3 == sig.length) diff --git a/src/main/java/com/jcraft/jsch/juz/Compression.java b/src/main/java/com/jcraft/jsch/juz/Compression.java index ad32869a..990c40e3 100644 --- a/src/main/java/com/jcraft/jsch/juz/Compression.java +++ b/src/main/java/com/jcraft/jsch/juz/Compression.java @@ -11,6 +11,7 @@ /** * This example demonstrates the packet compression without using jzlib[1]. * + *

    * The ssh protocol adopts zlib[2] for the packet compression. Fortunately, JDK has provided wrapper * classes for zlib(j.u.z.{Deflater, Inflater}), but it does not expose enough functionality of * zlib, unfortunately; it must not allow to compress data with SYNC_FLUSH. So, JSch has been using @@ -18,12 +19,12 @@ * j.u.z.Deflater, and SYNC_FLUSH has been supported at last. This example shows how to enable the * packet compression by using JDK's java.util.zip package. * - * + *

    * [1] http://www.jcraft.com/jzlib/ [2] http://www.zlib.net/ [3] * https://bugs.openjdk.java.net/browse/JDK-4206909 */ public class Compression implements com.jcraft.jsch.Compression { - static private final int BUF_SIZE = 4096; + private static final int BUF_SIZE = 4096; private final int buffer_margin = 32 + 20; // AES256 + HMACSHA1 private Deflater deflater; private Inflater inflater; diff --git a/src/main/java/com/jcraft/jsch/jzlib/Adler32.java b/src/main/java/com/jcraft/jsch/jzlib/Adler32.java index 6fbfad83..a20b8907 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/Adler32.java +++ b/src/main/java/com/jcraft/jsch/jzlib/Adler32.java @@ -33,9 +33,9 @@ final class Adler32 implements Checksum { // largest prime smaller than 65536 - static final private int BASE = 65521; + private static final int BASE = 65521; // NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 - static final private int NMAX = 5552; + private static final int NMAX = 5552; private long s1 = 1L; private long s2 = 0L; diff --git a/src/main/java/com/jcraft/jsch/jzlib/CRC32.java b/src/main/java/com/jcraft/jsch/jzlib/CRC32.java index 7c311a8d..6e9591ec 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/CRC32.java +++ b/src/main/java/com/jcraft/jsch/jzlib/CRC32.java @@ -37,6 +37,7 @@ final class CRC32 implements Checksum { */ private int v = 0; private static int[] crc_table = null; + static { crc_table = new int[256]; for (int n = 0; n < 256; n++) { diff --git a/src/main/java/com/jcraft/jsch/jzlib/Compression.java b/src/main/java/com/jcraft/jsch/jzlib/Compression.java index 747b5eca..279ee189 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/Compression.java +++ b/src/main/java/com/jcraft/jsch/jzlib/Compression.java @@ -33,7 +33,7 @@ import java.util.function.Supplier; public class Compression implements com.jcraft.jsch.Compression { - static private final int BUF_SIZE = 4096; + private static final int BUF_SIZE = 4096; private final int buffer_margin = 32 + 20; // AES256 + HMACSHA1 private Deflater deflater; private Inflater inflater; diff --git a/src/main/java/com/jcraft/jsch/jzlib/Deflate.java b/src/main/java/com/jcraft/jsch/jzlib/Deflate.java index b79b22cc..4e15b04c 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/Deflate.java +++ b/src/main/java/com/jcraft/jsch/jzlib/Deflate.java @@ -32,12 +32,12 @@ final class Deflate implements Cloneable { - static final private int MAX_MEM_LEVEL = 9; + private static final int MAX_MEM_LEVEL = 9; - static final private int Z_DEFAULT_COMPRESSION = -1; + private static final int Z_DEFAULT_COMPRESSION = -1; - static final private int MAX_WBITS = 15; // 32K LZ77 window - static final private int DEF_MEM_LEVEL = 8; + private static final int MAX_WBITS = 15; // 32K LZ77 window + private static final int DEF_MEM_LEVEL = 8; static class Config { int good_length; // reduce lazy search above this match length @@ -55,10 +55,11 @@ static class Config { } } - static final private int STORED = 0; - static final private int FAST = 1; - static final private int SLOW = 2; - static final private Config[] config_table; + private static final int STORED = 0; + private static final int FAST = 1; + private static final int SLOW = 2; + private static final Config[] config_table; + static { config_table = new Config[10]; // good lazy nice chain @@ -75,7 +76,7 @@ static class Config { config_table[9] = new Config(32, 258, 258, 4096, SLOW); } - static final private String[] z_errmsg = {"need dictionary", // Z_NEED_DICT 2 + private static final String[] z_errmsg = {"need dictionary", // Z_NEED_DICT 2 "stream end", // Z_STREAM_END 1 "", // Z_OK 0 "file error", // Z_ERRNO (-1) @@ -87,80 +88,80 @@ static class Config { ""}; // block not completed, need more input or more output - static final private int NeedMore = 0; + private static final int NeedMore = 0; // block flush performed - static final private int BlockDone = 1; + private static final int BlockDone = 1; // finish started, need only more output at next deflate - static final private int FinishStarted = 2; + private static final int FinishStarted = 2; // finish done, accept no more input or output - static final private int FinishDone = 3; + private static final int FinishDone = 3; // preset dictionary flag in zlib header - static final private int PRESET_DICT = 0x20; - - static final private int Z_FILTERED = 1; - static final private int Z_HUFFMAN_ONLY = 2; - static final private int Z_DEFAULT_STRATEGY = 0; - - static final private int Z_NO_FLUSH = 0; - static final private int Z_PARTIAL_FLUSH = 1; - static final private int Z_SYNC_FLUSH = 2; - static final private int Z_FULL_FLUSH = 3; - static final private int Z_FINISH = 4; - - static final private int Z_OK = 0; - static final private int Z_STREAM_END = 1; - static final private int Z_NEED_DICT = 2; - static final private int Z_ERRNO = -1; - static final private int Z_STREAM_ERROR = -2; - static final private int Z_DATA_ERROR = -3; - static final private int Z_MEM_ERROR = -4; - static final private int Z_BUF_ERROR = -5; - static final private int Z_VERSION_ERROR = -6; - - static final private int INIT_STATE = 42; - static final private int BUSY_STATE = 113; - static final private int FINISH_STATE = 666; + private static final int PRESET_DICT = 0x20; + + private static final int Z_FILTERED = 1; + private static final int Z_HUFFMAN_ONLY = 2; + private static final int Z_DEFAULT_STRATEGY = 0; + + private static final int Z_NO_FLUSH = 0; + private static final int Z_PARTIAL_FLUSH = 1; + private static final int Z_SYNC_FLUSH = 2; + private static final int Z_FULL_FLUSH = 3; + private static final int Z_FINISH = 4; + + private static final int Z_OK = 0; + private static final int Z_STREAM_END = 1; + private static final int Z_NEED_DICT = 2; + private static final int Z_ERRNO = -1; + private static final int Z_STREAM_ERROR = -2; + private static final int Z_DATA_ERROR = -3; + private static final int Z_MEM_ERROR = -4; + private static final int Z_BUF_ERROR = -5; + private static final int Z_VERSION_ERROR = -6; + + private static final int INIT_STATE = 42; + private static final int BUSY_STATE = 113; + private static final int FINISH_STATE = 666; // The deflate compression method - static final private int Z_DEFLATED = 8; + private static final int Z_DEFLATED = 8; - static final private int STORED_BLOCK = 0; - static final private int STATIC_TREES = 1; - static final private int DYN_TREES = 2; + private static final int STORED_BLOCK = 0; + private static final int STATIC_TREES = 1; + private static final int DYN_TREES = 2; // The three kinds of block type - static final private int Z_BINARY = 0; - static final private int Z_ASCII = 1; - static final private int Z_UNKNOWN = 2; + private static final int Z_BINARY = 0; + private static final int Z_ASCII = 1; + private static final int Z_UNKNOWN = 2; - static final private int Buf_size = 8 * 2; + private static final int Buf_size = 8 * 2; // repeat previous bit length 3-6 times (2 bits of repeat count) - static final private int REP_3_6 = 16; + private static final int REP_3_6 = 16; // repeat a zero length 3-10 times (3 bits of repeat count) - static final private int REPZ_3_10 = 17; + private static final int REPZ_3_10 = 17; // repeat a zero length 11-138 times (7 bits of repeat count) - static final private int REPZ_11_138 = 18; + private static final int REPZ_11_138 = 18; - static final private int MIN_MATCH = 3; - static final private int MAX_MATCH = 258; - static final private int MIN_LOOKAHEAD = (MAX_MATCH + MIN_MATCH + 1); + private static final int MIN_MATCH = 3; + private static final int MAX_MATCH = 258; + private static final int MIN_LOOKAHEAD = (MAX_MATCH + MIN_MATCH + 1); - static final private int MAX_BITS = 15; - static final private int D_CODES = 30; - static final private int BL_CODES = 19; - static final private int LENGTH_CODES = 29; - static final private int LITERALS = 256; - static final private int L_CODES = (LITERALS + 1 + LENGTH_CODES); - static final private int HEAP_SIZE = (2 * L_CODES + 1); + private static final int MAX_BITS = 15; + private static final int D_CODES = 30; + private static final int BL_CODES = 19; + private static final int LENGTH_CODES = 29; + private static final int LITERALS = 256; + private static final int L_CODES = (LITERALS + 1 + LENGTH_CODES); + private static final int HEAP_SIZE = (2 * L_CODES + 1); - static final private int END_BLOCK = 256; + private static final int END_BLOCK = 256; ZStream strm; // pointer back to this zlib stream int status; // as the name implies @@ -487,7 +488,6 @@ int build_bl_tree() { return max_blindex; } - // Send the header for a block using dynamic Huffman trees: the counts, the // lengths of the bit length codes, the literal tree and the distance tree. // IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. @@ -572,13 +572,13 @@ final void put_byte(byte c) { } final void put_short(int w) { - put_byte((byte) (w/* &0xff */)); + put_byte((byte) (w /* &0xff */)); put_byte((byte) (w >>> 8)); } final void putShortMSB(int b) { put_byte((byte) (b >> 8)); - put_byte((byte) (b/* &0xff */)); + put_byte((byte) (b /* &0xff */)); } final void send_code(int c, short[] tree) { @@ -629,7 +629,6 @@ void _tr_align() { last_eob_len = 7; } - // Save the match info and tally the frequency counts. Return true if // the current block must be flushed. boolean _tr_tally(int dist, // distance of matched string @@ -835,7 +834,6 @@ int deflate_stored(int flush) { flush_block_only(false); if (strm.avail_out == 0) return NeedMore; - } // Flush if we may have to slide, otherwise block_start may become @@ -869,7 +867,7 @@ void _tr_flush_block(int buf, // input block, or NULL if too old int stored_len, // length of input block boolean eof // true if this is the last block for a file ) { - int opt_lenb, static_lenb;// opt_len and static_len in bytes + int opt_lenb, static_lenb; // opt_len and static_len in bytes int max_blindex = 0; // index of last bit length code of non zero freq // Build the Huffman trees unless a stored block is forced @@ -1541,7 +1539,6 @@ int deflate(int flush) { status = BUSY_STATE; putShortMSB(header); - // Save the adler32 of the preset dictionary: if (strstart != 0) { long adler = strm.adler.getValue(); @@ -1620,7 +1617,7 @@ int deflate(int flush) { // as a special marker by inflate_sync(). if (flush == Z_FULL_FLUSH) { // state.head[s.hash_size-1]=0; - for (int i = 0; i < hash_size/*-1*/; i++) // forget history + for (int i = 0; i < hash_size /*-1*/; i++) // forget history head[i] = 0; } } diff --git a/src/main/java/com/jcraft/jsch/jzlib/Deflater.java b/src/main/java/com/jcraft/jsch/jzlib/Deflater.java index af2a74da..0941a214 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/Deflater.java +++ b/src/main/java/com/jcraft/jsch/jzlib/Deflater.java @@ -32,26 +32,26 @@ final class Deflater extends ZStream { - static final private int MAX_WBITS = 15; // 32K LZ77 window - static final private int DEF_WBITS = MAX_WBITS; - - static final private int Z_NO_FLUSH = 0; - static final private int Z_PARTIAL_FLUSH = 1; - static final private int Z_SYNC_FLUSH = 2; - static final private int Z_FULL_FLUSH = 3; - static final private int Z_FINISH = 4; - - static final private int MAX_MEM_LEVEL = 9; - - static final private int Z_OK = 0; - static final private int Z_STREAM_END = 1; - static final private int Z_NEED_DICT = 2; - static final private int Z_ERRNO = -1; - static final private int Z_STREAM_ERROR = -2; - static final private int Z_DATA_ERROR = -3; - static final private int Z_MEM_ERROR = -4; - static final private int Z_BUF_ERROR = -5; - static final private int Z_VERSION_ERROR = -6; + private static final int MAX_WBITS = 15; // 32K LZ77 window + private static final int DEF_WBITS = MAX_WBITS; + + private static final int Z_NO_FLUSH = 0; + private static final int Z_PARTIAL_FLUSH = 1; + private static final int Z_SYNC_FLUSH = 2; + private static final int Z_FULL_FLUSH = 3; + private static final int Z_FINISH = 4; + + private static final int MAX_MEM_LEVEL = 9; + + private static final int Z_OK = 0; + private static final int Z_STREAM_END = 1; + private static final int Z_NEED_DICT = 2; + private static final int Z_ERRNO = -1; + private static final int Z_STREAM_ERROR = -2; + private static final int Z_DATA_ERROR = -3; + private static final int Z_MEM_ERROR = -4; + private static final int Z_BUF_ERROR = -5; + private static final int Z_VERSION_ERROR = -6; private boolean finished = false; diff --git a/src/main/java/com/jcraft/jsch/jzlib/InfBlocks.java b/src/main/java/com/jcraft/jsch/jzlib/InfBlocks.java index 02a8aba6..458ff5d2 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/InfBlocks.java +++ b/src/main/java/com/jcraft/jsch/jzlib/InfBlocks.java @@ -31,10 +31,10 @@ package com.jcraft.jsch.jzlib; final class InfBlocks { - static final private int MANY = 1440; + private static final int MANY = 1440; // And'ing with mask[n] masks the lower n bits - static final private int[] inflate_mask = {0x00000000, 0x00000001, 0x00000003, 0x00000007, + private static final int[] inflate_mask = {0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff}; @@ -42,26 +42,26 @@ final class InfBlocks { static final int[] border = { // Order of the bit length code lengths 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - static final private int Z_OK = 0; - static final private int Z_STREAM_END = 1; - static final private int Z_NEED_DICT = 2; - static final private int Z_ERRNO = -1; - static final private int Z_STREAM_ERROR = -2; - static final private int Z_DATA_ERROR = -3; - static final private int Z_MEM_ERROR = -4; - static final private int Z_BUF_ERROR = -5; - static final private int Z_VERSION_ERROR = -6; - - static final private int TYPE = 0; // get type bits (3, including end bit) - static final private int LENS = 1; // get lengths for stored - static final private int STORED = 2;// processing stored block - static final private int TABLE = 3; // get table lengths - static final private int BTREE = 4; // get bit lengths tree for a dynamic block - static final private int DTREE = 5; // get length, distance trees for a dynamic block - static final private int CODES = 6; // processing fixed or dynamic block - static final private int DRY = 7; // output remaining window bytes - static final private int DONE = 8; // finished last block, done - static final private int BAD = 9; // ot a data error--stuck here + private static final int Z_OK = 0; + private static final int Z_STREAM_END = 1; + private static final int Z_NEED_DICT = 2; + private static final int Z_ERRNO = -1; + private static final int Z_STREAM_ERROR = -2; + private static final int Z_DATA_ERROR = -3; + private static final int Z_MEM_ERROR = -4; + private static final int Z_BUF_ERROR = -5; + private static final int Z_VERSION_ERROR = -6; + + private static final int TYPE = 0; // get type bits (3, including end bit) + private static final int LENS = 1; // get lengths for stored + private static final int STORED = 2; // processing stored block + private static final int TABLE = 3; // get table lengths + private static final int BTREE = 4; // get bit lengths tree for a dynamic block + private static final int DTREE = 5; // get length, distance trees for a dynamic block + private static final int CODES = 6; // processing fixed or dynamic block + private static final int DRY = 7; // output remaining window bytes + private static final int DONE = 8; // finished last block, done + private static final int BAD = 9; // ot a data error--stuck here int mode; // current inflate_block mode @@ -151,7 +151,6 @@ int proc(int r) { while (true) { switch (mode) { case TYPE: - while (k < (3)) { if (n != 0) { r = Z_OK; @@ -197,7 +196,6 @@ int proc(int r) { mode = CODES; break; case 2: // dynamic - { b >>>= (3); k -= (3); @@ -206,7 +204,6 @@ int proc(int r) { mode = TABLE; break; case 3: // illegal - { b >>>= (3); k -= (3); @@ -225,7 +222,6 @@ int proc(int r) { } break; case LENS: - while (k < (32)) { if (n != 0) { r = Z_OK; @@ -313,7 +309,6 @@ int proc(int r) { mode = last != 0 ? DRY : TYPE; break; case TABLE: - while (k < (14)) { if (n != 0) { r = Z_OK; diff --git a/src/main/java/com/jcraft/jsch/jzlib/InfCodes.java b/src/main/java/com/jcraft/jsch/jzlib/InfCodes.java index 028b222e..edfd0891 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/InfCodes.java +++ b/src/main/java/com/jcraft/jsch/jzlib/InfCodes.java @@ -32,33 +32,33 @@ final class InfCodes { - static final private int[] inflate_mask = {0x00000000, 0x00000001, 0x00000003, 0x00000007, + private static final int[] inflate_mask = {0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff}; - static final private int Z_OK = 0; - static final private int Z_STREAM_END = 1; - static final private int Z_NEED_DICT = 2; - static final private int Z_ERRNO = -1; - static final private int Z_STREAM_ERROR = -2; - static final private int Z_DATA_ERROR = -3; - static final private int Z_MEM_ERROR = -4; - static final private int Z_BUF_ERROR = -5; - static final private int Z_VERSION_ERROR = -6; + private static final int Z_OK = 0; + private static final int Z_STREAM_END = 1; + private static final int Z_NEED_DICT = 2; + private static final int Z_ERRNO = -1; + private static final int Z_STREAM_ERROR = -2; + private static final int Z_DATA_ERROR = -3; + private static final int Z_MEM_ERROR = -4; + private static final int Z_BUF_ERROR = -5; + private static final int Z_VERSION_ERROR = -6; // waiting for "i:"=input, // "o:"=output, // "x:"=nothing - static final private int START = 0; // x: set up for LEN - static final private int LEN = 1; // i: get length/literal/eob next - static final private int LENEXT = 2; // i: getting length extra (have base) - static final private int DIST = 3; // i: get distance next - static final private int DISTEXT = 4;// i: getting distance extra - static final private int COPY = 5; // o: copying bytes in window, waiting for space - static final private int LIT = 6; // o: got literal, waiting for output space - static final private int WASH = 7; // o: got eob, possibly still output waiting - static final private int END = 8; // x: got eob and all data flushed - static final private int BADCODE = 9;// x: got error + private static final int START = 0; // x: set up for LEN + private static final int LEN = 1; // i: get length/literal/eob next + private static final int LENEXT = 2; // i: getting length extra (have base) + private static final int DIST = 3; // i: get distance next + private static final int DISTEXT = 4; // i: getting distance extra + private static final int COPY = 5; // o: copying bytes in window, waiting for space + private static final int LIT = 6; // o: got literal, waiting for output space + private static final int WASH = 7; // o: got eob, possibly still output waiting + private static final int END = 8; // x: got eob and all data flushed + private static final int BADCODE = 9; // x: got error int mode; // current inflate_codes mode @@ -433,7 +433,6 @@ int proc(int r) { return s.inflate_flush(r); case BADCODE: // x: got error - r = Z_DATA_ERROR; s.bitb = b; @@ -599,7 +598,6 @@ int inflate_fast(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index, } r = 0; // copy rest from start of window } - } // copy all or what's left diff --git a/src/main/java/com/jcraft/jsch/jzlib/InfTree.java b/src/main/java/com/jcraft/jsch/jzlib/InfTree.java index 0c8f0ba0..26b6fa6d 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/InfTree.java +++ b/src/main/java/com/jcraft/jsch/jzlib/InfTree.java @@ -32,17 +32,17 @@ final class InfTree { - static final private int MANY = 1440; - - static final private int Z_OK = 0; - static final private int Z_STREAM_END = 1; - static final private int Z_NEED_DICT = 2; - static final private int Z_ERRNO = -1; - static final private int Z_STREAM_ERROR = -2; - static final private int Z_DATA_ERROR = -3; - static final private int Z_MEM_ERROR = -4; - static final private int Z_BUF_ERROR = -5; - static final private int Z_VERSION_ERROR = -6; + private static final int MANY = 1440; + + private static final int Z_OK = 0; + private static final int Z_STREAM_END = 1; + private static final int Z_NEED_DICT = 2; + private static final int Z_ERRNO = -1; + private static final int Z_STREAM_ERROR = -2; + private static final int Z_DATA_ERROR = -3; + private static final int Z_MEM_ERROR = -4; + private static final int Z_BUF_ERROR = -5; + private static final int Z_VERSION_ERROR = -6; static final int fixed_bl = 9; static final int fixed_bd = 5; @@ -77,7 +77,6 @@ final class InfTree { 8, 135, 0, 8, 71, 0, 9, 238, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 158, 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, 9, 222, 82, 7, 27, 0, 8, 111, 0, 8, 47, 0, 9, 190, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 254, 96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, 193, - 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 161, 0, 8, 0, 0, 8, 128, 0, 8, 64, 0, 9, 225, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 145, 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, 9, 209, 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, 9, 177, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 241, 80, 7, 4, 0, 8, 84, 0, 8, diff --git a/src/main/java/com/jcraft/jsch/jzlib/Inflate.java b/src/main/java/com/jcraft/jsch/jzlib/Inflate.java index b6f487fc..c937d6a9 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/Inflate.java +++ b/src/main/java/com/jcraft/jsch/jzlib/Inflate.java @@ -34,10 +34,10 @@ final class Inflate { - static final private int MAX_WBITS = 15; // 32K LZ77 window + private static final int MAX_WBITS = 15; // 32K LZ77 window // preset dictionary flag in zlib header - static final private int PRESET_DICT = 0x20; + private static final int PRESET_DICT = 0x20; static final int Z_NO_FLUSH = 0; static final int Z_PARTIAL_FLUSH = 1; @@ -45,43 +45,43 @@ final class Inflate { static final int Z_FULL_FLUSH = 3; static final int Z_FINISH = 4; - static final private int Z_DEFLATED = 8; - - static final private int Z_OK = 0; - static final private int Z_STREAM_END = 1; - static final private int Z_NEED_DICT = 2; - static final private int Z_ERRNO = -1; - static final private int Z_STREAM_ERROR = -2; - static final private int Z_DATA_ERROR = -3; - static final private int Z_MEM_ERROR = -4; - static final private int Z_BUF_ERROR = -5; - static final private int Z_VERSION_ERROR = -6; - - static final private int METHOD = 0; // waiting for method byte - static final private int FLAG = 1; // waiting for flag byte - static final private int DICT4 = 2; // four dictionary check bytes to go - static final private int DICT3 = 3; // three dictionary check bytes to go - static final private int DICT2 = 4; // two dictionary check bytes to go - static final private int DICT1 = 5; // one dictionary check byte to go - static final private int DICT0 = 6; // waiting for inflateSetDictionary - static final private int BLOCKS = 7; // decompressing blocks - static final private int CHECK4 = 8; // four check bytes to go - static final private int CHECK3 = 9; // three check bytes to go - static final private int CHECK2 = 10; // two check bytes to go - static final private int CHECK1 = 11; // one check byte to go - static final private int DONE = 12; // finished check, done - static final private int BAD = 13; // got an error--stay here - - static final private int HEAD = 14; - static final private int LENGTH = 15; - static final private int TIME = 16; - static final private int OS = 17; - static final private int EXLEN = 18; - static final private int EXTRA = 19; - static final private int NAME = 20; - static final private int COMMENT = 21; - static final private int HCRC = 22; - static final private int FLAGS = 23; + private static final int Z_DEFLATED = 8; + + private static final int Z_OK = 0; + private static final int Z_STREAM_END = 1; + private static final int Z_NEED_DICT = 2; + private static final int Z_ERRNO = -1; + private static final int Z_STREAM_ERROR = -2; + private static final int Z_DATA_ERROR = -3; + private static final int Z_MEM_ERROR = -4; + private static final int Z_BUF_ERROR = -5; + private static final int Z_VERSION_ERROR = -6; + + private static final int METHOD = 0; // waiting for method byte + private static final int FLAG = 1; // waiting for flag byte + private static final int DICT4 = 2; // four dictionary check bytes to go + private static final int DICT3 = 3; // three dictionary check bytes to go + private static final int DICT2 = 4; // two dictionary check bytes to go + private static final int DICT1 = 5; // one dictionary check byte to go + private static final int DICT0 = 6; // waiting for inflateSetDictionary + private static final int BLOCKS = 7; // decompressing blocks + private static final int CHECK4 = 8; // four check bytes to go + private static final int CHECK3 = 9; // three check bytes to go + private static final int CHECK2 = 10; // two check bytes to go + private static final int CHECK1 = 11; // one check byte to go + private static final int DONE = 12; // finished check, done + private static final int BAD = 13; // got an error--stay here + + private static final int HEAD = 14; + private static final int LENGTH = 15; + private static final int TIME = 16; + private static final int OS = 17; + private static final int EXLEN = 18; + private static final int EXTRA = 19; + private static final int NAME = 20; + private static final int COMMENT = 21; + private static final int HCRC = 22; + private static final int FLAGS = 23; static final int INFLATE_ANY = 0x40000000; @@ -288,7 +288,6 @@ int inflate(int f) { } this.mode = DICT4; case DICT4: - if (z.avail_in == 0) return r; r = f; @@ -298,7 +297,6 @@ int inflate(int f) { this.need = ((z.next_in[z.next_in_index++] & 0xff) << 24) & 0xff000000L; this.mode = DICT3; case DICT3: - if (z.avail_in == 0) return r; r = f; @@ -308,7 +306,6 @@ int inflate(int f) { this.need += ((z.next_in[z.next_in_index++] & 0xff) << 16) & 0xff0000L; this.mode = DICT2; case DICT2: - if (z.avail_in == 0) return r; r = f; @@ -318,7 +315,6 @@ int inflate(int f) { this.need += ((z.next_in[z.next_in_index++] & 0xff) << 8) & 0xff00L; this.mode = DICT1; case DICT1: - if (z.avail_in == 0) return r; r = f; @@ -356,7 +352,6 @@ int inflate(int f) { } this.mode = CHECK4; case CHECK4: - if (z.avail_in == 0) return r; r = f; @@ -366,7 +361,6 @@ int inflate(int f) { this.need = ((z.next_in[z.next_in_index++] & 0xff) << 24) & 0xff000000L; this.mode = CHECK3; case CHECK3: - if (z.avail_in == 0) return r; r = f; @@ -376,7 +370,6 @@ int inflate(int f) { this.need += ((z.next_in[z.next_in_index++] & 0xff) << 16) & 0xff0000L; this.mode = CHECK2; case CHECK2: - if (z.avail_in == 0) return r; r = f; @@ -386,7 +379,6 @@ int inflate(int f) { this.need += ((z.next_in[z.next_in_index++] & 0xff) << 8) & 0xff00L; this.mode = CHECK1; case CHECK1: - if (z.avail_in == 0) return r; r = f; @@ -447,7 +439,6 @@ int inflate(int f) { return Z_DATA_ERROR; case FLAGS: - try { r = readBytes(2, r, f); } catch (Return e) { @@ -625,7 +616,7 @@ int inflateSetDictionary(byte[] dictionary, int dictLength) { return Z_OK; } - static private byte[] mark = {(byte) 0, (byte) 0, (byte) 0xff, (byte) 0xff}; + private static byte[] mark = {(byte) 0, (byte) 0, (byte) 0xff, (byte) 0xff}; int inflateSync() { int n; // number of bytes to look at diff --git a/src/main/java/com/jcraft/jsch/jzlib/Inflater.java b/src/main/java/com/jcraft/jsch/jzlib/Inflater.java index 6e8d97d7..d4aede85 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/Inflater.java +++ b/src/main/java/com/jcraft/jsch/jzlib/Inflater.java @@ -32,26 +32,26 @@ final class Inflater extends ZStream { - static final private int MAX_WBITS = 15; // 32K LZ77 window - static final private int DEF_WBITS = MAX_WBITS; - - static final private int Z_NO_FLUSH = 0; - static final private int Z_PARTIAL_FLUSH = 1; - static final private int Z_SYNC_FLUSH = 2; - static final private int Z_FULL_FLUSH = 3; - static final private int Z_FINISH = 4; - - static final private int MAX_MEM_LEVEL = 9; - - static final private int Z_OK = 0; - static final private int Z_STREAM_END = 1; - static final private int Z_NEED_DICT = 2; - static final private int Z_ERRNO = -1; - static final private int Z_STREAM_ERROR = -2; - static final private int Z_DATA_ERROR = -3; - static final private int Z_MEM_ERROR = -4; - static final private int Z_BUF_ERROR = -5; - static final private int Z_VERSION_ERROR = -6; + private static final int MAX_WBITS = 15; // 32K LZ77 window + private static final int DEF_WBITS = MAX_WBITS; + + private static final int Z_NO_FLUSH = 0; + private static final int Z_PARTIAL_FLUSH = 1; + private static final int Z_SYNC_FLUSH = 2; + private static final int Z_FULL_FLUSH = 3; + private static final int Z_FINISH = 4; + + private static final int MAX_MEM_LEVEL = 9; + + private static final int Z_OK = 0; + private static final int Z_STREAM_END = 1; + private static final int Z_NEED_DICT = 2; + private static final int Z_ERRNO = -1; + private static final int Z_STREAM_ERROR = -2; + private static final int Z_DATA_ERROR = -3; + private static final int Z_MEM_ERROR = -4; + private static final int Z_BUF_ERROR = -5; + private static final int Z_VERSION_ERROR = -6; private int param_w = -1; private JZlib.WrapperType param_wrapperType = null; diff --git a/src/main/java/com/jcraft/jsch/jzlib/InflaterInputStream.java b/src/main/java/com/jcraft/jsch/jzlib/InflaterInputStream.java index a6f08be2..28e92360 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/InflaterInputStream.java +++ b/src/main/java/com/jcraft/jsch/jzlib/InflaterInputStream.java @@ -243,7 +243,7 @@ void readHeader() throws IOException { throw new IOException("no input"); inflater.setInput(b1); err = inflater.inflate(JZlib.Z_NO_FLUSH); - if (err != 0/* Z_OK */) + if (err != 0 /* Z_OK */) throw new IOException(inflater.msg); } while (inflater.istate.inParsingHeader()); } diff --git a/src/main/java/com/jcraft/jsch/jzlib/StaticTree.java b/src/main/java/com/jcraft/jsch/jzlib/StaticTree.java index 41f8fcc7..12a1f863 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/StaticTree.java +++ b/src/main/java/com/jcraft/jsch/jzlib/StaticTree.java @@ -31,13 +31,13 @@ package com.jcraft.jsch.jzlib; final class StaticTree { - static final private int MAX_BITS = 15; + private static final int MAX_BITS = 15; - static final private int BL_CODES = 19; - static final private int D_CODES = 30; - static final private int LITERALS = 256; - static final private int LENGTH_CODES = 29; - static final private int L_CODES = (LITERALS + 1 + LENGTH_CODES); + private static final int BL_CODES = 19; + private static final int D_CODES = 30; + private static final int LITERALS = 256; + private static final int LENGTH_CODES = 29; + private static final int L_CODES = (LITERALS + 1 + LENGTH_CODES); // Bit length codes must not exceed MAX_BL_BITS bits static final int MAX_BL_BITS = 7; diff --git a/src/main/java/com/jcraft/jsch/jzlib/Tree.java b/src/main/java/com/jcraft/jsch/jzlib/Tree.java index abb55a4e..9668bdf2 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/Tree.java +++ b/src/main/java/com/jcraft/jsch/jzlib/Tree.java @@ -31,13 +31,13 @@ package com.jcraft.jsch.jzlib; final class Tree { - static final private int MAX_BITS = 15; - static final private int BL_CODES = 19; - static final private int D_CODES = 30; - static final private int LITERALS = 256; - static final private int LENGTH_CODES = 29; - static final private int L_CODES = (LITERALS + 1 + LENGTH_CODES); - static final private int HEAP_SIZE = (2 * L_CODES + 1); + private static final int MAX_BITS = 15; + private static final int BL_CODES = 19; + private static final int D_CODES = 30; + private static final int LITERALS = 256; + private static final int LENGTH_CODES = 29; + private static final int L_CODES = (LITERALS + 1 + LENGTH_CODES); + private static final int HEAP_SIZE = (2 * L_CODES + 1); // Bit length codes must not exceed MAX_BL_BITS bits static final int MAX_BL_BITS = 7; @@ -67,7 +67,6 @@ final class Tree { static final byte[] bl_order = {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - // The lengths of the bit length codes are sent in order of decreasing // probability, to avoid transmitting the lengths for unused bit // length codes. @@ -304,7 +303,7 @@ void build_tree(Deflate s) { // the given tree and the field len is set for all tree elements. // OUT assertion: the field code is set for all tree elements of non // zero code length. - private final static void gen_codes(short[] tree, // the tree to decorate + private static final void gen_codes(short[] tree, // the tree to decorate int max_code, // largest code with non zero frequency short[] bl_count, // number of codes at each bit length short[] next_code) { @@ -337,7 +336,7 @@ private final static void gen_codes(short[] tree, // the tree to decorate // Reverse the first len bits of a code, using straightforward code (a faster // method would use a table) // IN assertion: 1 <= len <= 15 - private final static int bi_reverse(int code, // the value to invert + private static final int bi_reverse(int code, // the value to invert int len // its bit length ) { int res = 0; @@ -349,4 +348,3 @@ private final static int bi_reverse(int code, // the value to invert return res >>> 1; } } - diff --git a/src/main/java/com/jcraft/jsch/jzlib/ZStream.java b/src/main/java/com/jcraft/jsch/jzlib/ZStream.java index 5064ca3e..bffc0938 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/ZStream.java +++ b/src/main/java/com/jcraft/jsch/jzlib/ZStream.java @@ -32,26 +32,26 @@ class ZStream { - static final private int MAX_WBITS = 15; // 32K LZ77 window - static final private int DEF_WBITS = MAX_WBITS; - - static final private int Z_NO_FLUSH = 0; - static final private int Z_PARTIAL_FLUSH = 1; - static final private int Z_SYNC_FLUSH = 2; - static final private int Z_FULL_FLUSH = 3; - static final private int Z_FINISH = 4; - - static final private int MAX_MEM_LEVEL = 9; - - static final private int Z_OK = 0; - static final private int Z_STREAM_END = 1; - static final private int Z_NEED_DICT = 2; - static final private int Z_ERRNO = -1; - static final private int Z_STREAM_ERROR = -2; - static final private int Z_DATA_ERROR = -3; - static final private int Z_MEM_ERROR = -4; - static final private int Z_BUF_ERROR = -5; - static final private int Z_VERSION_ERROR = -6; + private static final int MAX_WBITS = 15; // 32K LZ77 window + private static final int DEF_WBITS = MAX_WBITS; + + private static final int Z_NO_FLUSH = 0; + private static final int Z_PARTIAL_FLUSH = 1; + private static final int Z_SYNC_FLUSH = 2; + private static final int Z_FULL_FLUSH = 3; + private static final int Z_FINISH = 4; + + private static final int MAX_MEM_LEVEL = 9; + + private static final int Z_OK = 0; + private static final int Z_STREAM_END = 1; + private static final int Z_NEED_DICT = 2; + private static final int Z_ERRNO = -1; + private static final int Z_STREAM_ERROR = -2; + private static final int Z_DATA_ERROR = -3; + private static final int Z_MEM_ERROR = -4; + private static final int Z_BUF_ERROR = -5; + private static final int Z_VERSION_ERROR = -6; byte[] next_in; // next input byte int next_in_index; @@ -358,7 +358,6 @@ void setNextOutIndex(int next_out_index) { int getAvailOut() { return avail_out; - } void setAvailOut(int avail_out) { diff --git a/src/main/java9/module-info.java b/src/main/java9/module-info.java index dadf75b7..10139cc9 100644 --- a/src/main/java9/module-info.java +++ b/src/main/java9/module-info.java @@ -1,12 +1,12 @@ module com.jcraft.jsch { - exports com.jcraft.jsch; + exports com.jcraft.jsch; - requires static com.sun.jna; - requires static com.sun.jna.platform; - requires static java.logging; - requires static java.security.jgss; - requires static org.apache.logging.log4j; - requires static org.bouncycastle.provider; - requires static org.newsclub.net.unix; - requires static org.slf4j; + requires static com.sun.jna; + requires static com.sun.jna.platform; + requires static java.logging; + requires static java.security.jgss; + requires static org.apache.logging.log4j; + requires static org.bouncycastle.provider; + requires static org.newsclub.net.unix; + requires static org.slf4j; } diff --git a/src/test/java/com/jcraft/jsch/JSchTest.java b/src/test/java/com/jcraft/jsch/JSchTest.java index 04c54422..e2735a7a 100644 --- a/src/test/java/com/jcraft/jsch/JSchTest.java +++ b/src/test/java/com/jcraft/jsch/JSchTest.java @@ -64,7 +64,7 @@ void checkLoggerBehavior() throws Exception { assertSame(JSch.DEVNULL, jsch.getInstanceLogger(), "instance logger should be DEVNULL"); } - final static class TestLogger implements Logger { + static final class TestLogger implements Logger { @Override public boolean isEnabled(int level) { return true; diff --git a/src/test/java/com/jcraft/jsch/KeyPair2IT.java b/src/test/java/com/jcraft/jsch/KeyPair2IT.java index 393c66a1..f2b66b9a 100644 --- a/src/test/java/com/jcraft/jsch/KeyPair2IT.java +++ b/src/test/java/com/jcraft/jsch/KeyPair2IT.java @@ -55,7 +55,6 @@ void connectWithPublicKey(String path, String password, String keyType) throws E } finally { session.disconnect(); } - } @ParameterizedTest @@ -96,9 +95,7 @@ public boolean promptYesNo(String message) { } @Override - public void showMessage(String message) { - - } + public void showMessage(String message) {} }); if (keyType != null) { @@ -110,7 +107,6 @@ public void showMessage(String message) { } finally { session.disconnect(); } - } private JSch createIdentity(String path, String password) diff --git a/src/test/java/com/jcraft/jsch/KeyPairIT.java b/src/test/java/com/jcraft/jsch/KeyPairIT.java index a0f8c95c..a356dd49 100644 --- a/src/test/java/com/jcraft/jsch/KeyPairIT.java +++ b/src/test/java/com/jcraft/jsch/KeyPairIT.java @@ -38,7 +38,6 @@ void connectWithPublicKey(String path, String password, String keyType) throws E } finally { session.disconnect(); } - } @ParameterizedTest @@ -79,9 +78,7 @@ public boolean promptYesNo(String message) { } @Override - public void showMessage(String message) { - - } + public void showMessage(String message) {} }); if (keyType != null) { @@ -93,7 +90,6 @@ public void showMessage(String message) { } finally { session.disconnect(); } - } private JSch createIdentity(String path, String password) diff --git a/src/test/java/com/jcraft/jsch/KeyPairTest.java b/src/test/java/com/jcraft/jsch/KeyPairTest.java index 12a19bef..46823322 100644 --- a/src/test/java/com/jcraft/jsch/KeyPairTest.java +++ b/src/test/java/com/jcraft/jsch/KeyPairTest.java @@ -178,5 +178,4 @@ void decryptEncryptedOpensshKey(String keyFile) throws URISyntaxException, JSchE assertTrue(identity.getKeyPair().decrypt((byte[]) null)); assertTrue(identity.getKeyPair().decrypt((String) null)); } - } diff --git a/src/test/java/com/jcraft/jsch/KnownHostsTest.java b/src/test/java/com/jcraft/jsch/KnownHostsTest.java index 3ca101d5..c74df310 100644 --- a/src/test/java/com/jcraft/jsch/KnownHostsTest.java +++ b/src/test/java/com/jcraft/jsch/KnownHostsTest.java @@ -11,6 +11,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; +import com.jcraft.jsch.KnownHosts.HashedHostKey; +import com.jcraft.jsch.jce.HMACSHA256; +import com.jcraft.jsch.jce.HMACSHA512; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -36,22 +39,19 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.jcraft.jsch.KnownHosts.HashedHostKey; -import com.jcraft.jsch.jce.HMACSHA256; -import com.jcraft.jsch.jce.HMACSHA512; class KnownHostsTest { - private final static String rsaKey = + private static final String rsaKey = "AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkc" + "cKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81e" + "FzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpI" + "oaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G" + "3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=="; - private final static String hashValue = + private static final String hashValue = "|1|F1E1KeoE/eEWhi10WpGv4OdiO6Y=|3988QV0VE8wmZL7suNrYQLITLCg="; - private final static String hostLine = "ssh.example.com,192.168.1.61"; - private final static byte[] dsaKeyBytes = Util.str2byte(" ssh-dsa"); - private final static byte[] rsaKeyBytes = Util.str2byte(" ssh-rsa"); + private static final String hostLine = "ssh.example.com,192.168.1.61"; + private static final byte[] dsaKeyBytes = Util.str2byte(" ssh-dsa"); + private static final byte[] rsaKeyBytes = Util.str2byte(" ssh-rsa"); private LinkedList messages; private JSch jsch; private Hashtable orgConfig; @@ -201,7 +201,6 @@ MAC createHMAC(String hmacClassname) { assertEquals(HMACSHA512.class.getName(), kh.hmacsha1.getClass().getName(), "hmac class mismatch"); assertEquals("", messages.stream().collect(Collectors.joining("\r\n"))); - } @Test @@ -977,7 +976,6 @@ void sync() throws IOException { assertEquals(1, hosts.length, "unexpected number of host keys: " + getHostKeysString(hosts)); assertEquals("[192.277.325.5]:123: key type ssh-rsa", getHostKeysString(hosts), "unexpected hosts"); - } private String getMessagesAsString() { @@ -1142,5 +1140,4 @@ public boolean isEnabled(int level) { return true; } } - } diff --git a/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java b/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java index b357c72e..99567500 100644 --- a/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java +++ b/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java @@ -88,5 +88,4 @@ void replaceKexAlgorithms() throws IOException { ConfigRepository.Config kex = parse.getConfig(""); assertEquals("diffie-hellman-group1-sha1", kex.getValue("kex")); } - } diff --git a/src/test/java/com/jcraft/jsch/SessionTest.java b/src/test/java/com/jcraft/jsch/SessionTest.java index 3bf5987c..ebc12d98 100644 --- a/src/test/java/com/jcraft/jsch/SessionTest.java +++ b/src/test/java/com/jcraft/jsch/SessionTest.java @@ -36,7 +36,7 @@ private static Stream sshConfigs() { Arguments.of(":42 host:99", "0.0.0.0", "host", 99, null), // bind is empty Arguments.of("*:42 host:99", "0.0.0.0", "host", 99, null), // bind is asterisk Arguments.of("bind_adress:42 socket", "bind_adress", null, -1, "socket"), // socket - Arguments.of("42 socket", "127.0.0.1", null, -1, "socket")// socket wo bind + Arguments.of("42 socket", "127.0.0.1", null, -1, "socket") // socket wo bind ); } diff --git a/src/test/java/com/jcraft/jsch/jbcrypt/BCryptTest.java b/src/test/java/com/jcraft/jsch/jbcrypt/BCryptTest.java index 607f4a1e..2c34f3ff 100644 --- a/src/test/java/com/jcraft/jsch/jbcrypt/BCryptTest.java +++ b/src/test/java/com/jcraft/jsch/jbcrypt/BCryptTest.java @@ -71,9 +71,7 @@ public class BCryptTest { {"~!@#$%^&*() ~!@#$%^&*()PNBFRD", "$2a$12$WApznUOJfkEGSmYRfnkrPO", "$2a$12$WApznUOJfkEGSmYRfnkrPOr466oFDCaj4b6HY3EXGvfxm43seyhgC"},}; - /** - * Test method for 'BCrypt.hashpw(String, String)' - */ + /** Test method for 'BCrypt.hashpw(String, String)' */ @Test public void testHashpw() { // System.out.print("BCrypt.hashpw(): "); @@ -88,9 +86,7 @@ public void testHashpw() { // System.out.println(""); } - /** - * Test method for 'BCrypt.gensalt(int)' - */ + /** Test method for 'BCrypt.gensalt(int)' */ @Test public void testGensaltInt() { // System.out.print("BCrypt.gensalt(log_rounds):"); @@ -108,9 +104,7 @@ public void testGensaltInt() { // System.out.println(""); } - /** - * Test method for 'BCrypt.gensalt()' - */ + /** Test method for 'BCrypt.gensalt()' */ @Test public void testGensalt() { // System.out.print("BCrypt.gensalt(): "); @@ -125,9 +119,7 @@ public void testGensalt() { // System.out.println(""); } - /** - * Test method for 'BCrypt.checkpw(String, String)' expecting success - */ + /** Test method for 'BCrypt.checkpw(String, String)' expecting success */ @Test public void testCheckpw_success() { // System.out.print("BCrypt.checkpw w/ good passwords: "); @@ -140,9 +132,7 @@ public void testCheckpw_success() { // System.out.println(""); } - /** - * Test method for 'BCrypt.checkpw(String, String)' expecting failure - */ + /** Test method for 'BCrypt.checkpw(String, String)' expecting failure */ @Test public void testCheckpw_failure() { // System.out.print("BCrypt.checkpw w/ bad passwords: "); @@ -156,9 +146,7 @@ public void testCheckpw_failure() { // System.out.println(""); } - /** - * Test for correct hashing of non-US-ASCII passwords - */ + /** Test for correct hashing of non-US-ASCII passwords */ @Test public void testInternationalChars() { // System.out.print("BCrypt.hashpw w/ international chars: "); From 5927085a91ad7cee28e5e4c439b72485047cd398 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Thu, 18 Jan 2024 05:58:56 -0600 Subject: [PATCH 190/301] Switch to using java.time classes & make work for dates past 2038. --- src/main/java/com/jcraft/jsch/SftpATTRS.java | 21 +++++++--- .../java/com/jcraft/jsch/SftpATTRSTest.java | 38 +++++++++++++++++++ 2 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 src/test/java/com/jcraft/jsch/SftpATTRSTest.java diff --git a/src/main/java/com/jcraft/jsch/SftpATTRS.java b/src/main/java/com/jcraft/jsch/SftpATTRS.java index 84151085..cff4c660 100644 --- a/src/main/java/com/jcraft/jsch/SftpATTRS.java +++ b/src/main/java/com/jcraft/jsch/SftpATTRS.java @@ -26,7 +26,11 @@ package com.jcraft.jsch; -import java.util.Date; +import java.time.Instant; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Locale; /* * uint32 flags uint64 size present only if flag SSH_FILEXFER_ATTR_SIZE uint32 uid present only if @@ -122,13 +126,20 @@ else if ((permissions & S_IXGRP) != 0) } public String getAtimeString() { - Date date = new Date(((long) atime) * 1000L); - return (date.toString()); + return toDateString(Integer.toUnsignedLong(atime)); } public String getMtimeString() { - Date date = new Date(((long) mtime) * 1000L); - return (date.toString()); + return toDateString(Integer.toUnsignedLong(mtime)); + } + + private static DateTimeFormatter DTF = + DateTimeFormatter.ofPattern("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ROOT); + + static String toDateString(long epochSeconds) { + Instant instant = Instant.ofEpochSecond(epochSeconds); + ZonedDateTime zdt = ZonedDateTime.ofInstant(instant, ZoneId.systemDefault()); + return DTF.format(zdt); } public static final int SSH_FILEXFER_ATTR_SIZE = 0x00000001; diff --git a/src/test/java/com/jcraft/jsch/SftpATTRSTest.java b/src/test/java/com/jcraft/jsch/SftpATTRSTest.java new file mode 100644 index 00000000..d8359204 --- /dev/null +++ b/src/test/java/com/jcraft/jsch/SftpATTRSTest.java @@ -0,0 +1,38 @@ +package com.jcraft.jsch; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.Date; +import java.util.Random; +import org.junit.jupiter.api.Test; + +public class SftpATTRSTest { + + private final Random random = new Random(); + + @Test + public void testToDateString0() { + String expected = new Date(0L).toString(); + String actual = SftpATTRS.toDateString(0L); + assertEquals(expected, actual); + } + + @Test + public void testToDateStringNow() { + long now = System.currentTimeMillis() / 1000L; + String expected = new Date(now * 1000L).toString(); + String actual = SftpATTRS.toDateString(now); + assertEquals(expected, actual); + } + + @Test + public void testToDateStringRandom() { + for (int i = 0; i < 1000000; i++) { + int j = random.ints(Integer.MIN_VALUE, Integer.MAX_VALUE).findFirst().getAsInt(); + long l = Integer.toUnsignedLong(j); + String expected = new Date(l * 1000L).toString(); + String actual = SftpATTRS.toDateString(l); + assertEquals(expected, actual); + } + } +} From 623f0eb82088288c57a43fcadd8c883670c9b922 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jan 2024 19:55:48 +0000 Subject: [PATCH 191/301] Bump actions/cache from 3 to 4 Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 22d61ccf..4f0ff237 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -21,7 +21,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Cache local Maven repository - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.m2/repository key: ${{ runner.os }}-${{ matrix.java }}-maven-${{ hashFiles('**/pom.xml') }} From 723f95491f6851c2d3c7aa1c05cd23d80dbb119a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 19:53:30 +0000 Subject: [PATCH 192/301] Bump org.testcontainers:junit-jupiter from 1.19.3 to 1.19.4 Bumps [org.testcontainers:junit-jupiter](https://github.com/testcontainers/testcontainers-java) from 1.19.3 to 1.19.4. - [Release notes](https://github.com/testcontainers/testcontainers-java/releases) - [Changelog](https://github.com/testcontainers/testcontainers-java/blob/main/CHANGELOG.md) - [Commits](https://github.com/testcontainers/testcontainers-java/compare/1.19.3...1.19.4) --- updated-dependencies: - dependency-name: org.testcontainers:junit-jupiter dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ea50cd92..cf42ca2b 100644 --- a/pom.xml +++ b/pom.xml @@ -144,7 +144,7 @@ org.testcontainers junit-jupiter - 1.19.3 + 1.19.4 test From b3520090e00d7dae7fe7af5a3604cbfc2dd12dc9 Mon Sep 17 00:00:00 2001 From: Matthias Wiedemann Date: Fri, 2 Feb 2024 10:00:25 +0000 Subject: [PATCH 193/301] suppress deprecation error from forbiddenapis check --- src/main/java9/com/jcraft/jsch/JavaVersion.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java9/com/jcraft/jsch/JavaVersion.java b/src/main/java9/com/jcraft/jsch/JavaVersion.java index c3f8afb3..6d9fd0d9 100644 --- a/src/main/java9/com/jcraft/jsch/JavaVersion.java +++ b/src/main/java9/com/jcraft/jsch/JavaVersion.java @@ -1,7 +1,10 @@ package com.jcraft.jsch; +import com.jcraft.jsch.annotations.SuppressForbiddenApi; + final class JavaVersion { + @SuppressForbiddenApi("jdk-deprecated") static int getVersion() { return Runtime.version().major(); } From 6167635e38298e43e49d345119d7c3db66bf8aa9 Mon Sep 17 00:00:00 2001 From: Matthias Wiedemann Date: Fri, 2 Feb 2024 10:22:45 +0000 Subject: [PATCH 194/301] added sdkman config file --- .sdkmanrc | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .sdkmanrc diff --git a/.sdkmanrc b/.sdkmanrc new file mode 100644 index 00000000..9b281c73 --- /dev/null +++ b/.sdkmanrc @@ -0,0 +1,4 @@ +# Enable auto-env through the sdkman_auto_env config +# Add key=value pairs of SDKs to use below +java=21.0.2-tem +maven=3.9.6 From 9cd2b00ca34b545b289edddf04def5a077ed2c62 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 19:16:55 +0000 Subject: [PATCH 195/301] Bump org.junit.jupiter:junit-jupiter from 5.10.1 to 5.10.2 Bumps [org.junit.jupiter:junit-jupiter](https://github.com/junit-team/junit5) from 5.10.1 to 5.10.2. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.10.1...r5.10.2) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cf42ca2b..ab92bbc5 100644 --- a/pom.xml +++ b/pom.xml @@ -138,7 +138,7 @@ org.junit.jupiter junit-jupiter - 5.10.1 + 5.10.2 test From 4a1ba155d4bce7d5f5b1bb3900b93ef830b71696 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 19:36:08 +0000 Subject: [PATCH 196/301] Bump commons-codec:commons-codec from 1.16.0 to 1.16.1 Bumps [commons-codec:commons-codec](https://github.com/apache/commons-codec) from 1.16.0 to 1.16.1. - [Changelog](https://github.com/apache/commons-codec/blob/master/RELEASE-NOTES.txt) - [Commits](https://github.com/apache/commons-codec/compare/rel/commons-codec-1.16.0...rel/commons-codec-1.16.1) --- updated-dependencies: - dependency-name: commons-codec:commons-codec dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ab92bbc5..ac0cf5c0 100644 --- a/pom.xml +++ b/pom.xml @@ -161,7 +161,7 @@ commons-codec commons-codec - 1.16.0 + 1.16.1 test From ff18aceb331147faabde91fbaace393c63d225f4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 19:36:16 +0000 Subject: [PATCH 197/301] Bump org.testcontainers:junit-jupiter from 1.19.4 to 1.19.5 Bumps [org.testcontainers:junit-jupiter](https://github.com/testcontainers/testcontainers-java) from 1.19.4 to 1.19.5. - [Release notes](https://github.com/testcontainers/testcontainers-java/releases) - [Changelog](https://github.com/testcontainers/testcontainers-java/blob/main/CHANGELOG.md) - [Commits](https://github.com/testcontainers/testcontainers-java/compare/1.19.4...1.19.5) --- updated-dependencies: - dependency-name: org.testcontainers:junit-jupiter dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ab92bbc5..2f555258 100644 --- a/pom.xml +++ b/pom.xml @@ -144,7 +144,7 @@ org.testcontainers junit-jupiter - 1.19.4 + 1.19.5 test From 04fa578fff0d7c765f7b383fe92127779424b981 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 19:36:19 +0000 Subject: [PATCH 198/301] Bump org.slf4j:slf4j-api from 2.0.11 to 2.0.12 Bumps org.slf4j:slf4j-api from 2.0.11 to 2.0.12. --- updated-dependencies: - dependency-name: org.slf4j:slf4j-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ab92bbc5..2bf8f7cb 100644 --- a/pom.xml +++ b/pom.xml @@ -132,7 +132,7 @@ org.slf4j slf4j-api - 2.0.11 + 2.0.12 true From fa2b4d562ee02fa384f5136ec850f65a457ff7c7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 19:18:40 +0000 Subject: [PATCH 199/301] Bump junixsocket.version from 2.8.3 to 2.9.0 Bumps `junixsocket.version` from 2.8.3 to 2.9.0. Updates `com.kohlschutter.junixsocket:junixsocket-common` from 2.8.3 to 2.9.0 - [Release notes](https://github.com/kohlschutter/junixsocket/releases) - [Commits](https://github.com/kohlschutter/junixsocket/compare/junixsocket-2.8.3...junixsocket-2.9.0) Updates `com.kohlschutter.junixsocket:junixsocket-native-common` from 2.8.3 to 2.9.0 - [Release notes](https://github.com/kohlschutter/junixsocket/releases) - [Commits](https://github.com/kohlschutter/junixsocket/compare/junixsocket-2.8.3...junixsocket-2.9.0) --- updated-dependencies: - dependency-name: com.kohlschutter.junixsocket:junixsocket-common dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.kohlschutter.junixsocket:junixsocket-native-common dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 71c2a780..df75d274 100644 --- a/pom.xml +++ b/pom.xml @@ -79,7 +79,7 @@ UTF-8 UTF-8 true - 2.8.3 + 2.9.0 5.14.0 2.22.1 2.24.1 From 36116975bb4297e25a6e8c9ee954f62e2d76a1ed Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 19:18:51 +0000 Subject: [PATCH 200/301] Bump errorprone.version from 2.24.1 to 2.25.0 Bumps `errorprone.version` from 2.24.1 to 2.25.0. Updates `com.google.errorprone:error_prone_annotations` from 2.24.1 to 2.25.0 - [Release notes](https://github.com/google/error-prone/releases) - [Commits](https://github.com/google/error-prone/compare/v2.24.1...v2.25.0) Updates `com.google.errorprone:error_prone_core` from 2.24.1 to 2.25.0 - [Release notes](https://github.com/google/error-prone/releases) - [Commits](https://github.com/google/error-prone/compare/v2.24.1...v2.25.0) --- updated-dependencies: - dependency-name: com.google.errorprone:error_prone_annotations dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.google.errorprone:error_prone_core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 71c2a780..6ff2bd75 100644 --- a/pom.xml +++ b/pom.xml @@ -82,7 +82,7 @@ 2.8.3 5.14.0 2.22.1 - 2.24.1 + 2.25.0 3.2.5 From e790d37af9764720811ef4713c3f900ac2d9449b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Feb 2024 19:29:15 +0000 Subject: [PATCH 201/301] Bump org.testcontainers:junit-jupiter from 1.19.5 to 1.19.6 Bumps [org.testcontainers:junit-jupiter](https://github.com/testcontainers/testcontainers-java) from 1.19.5 to 1.19.6. - [Release notes](https://github.com/testcontainers/testcontainers-java/releases) - [Changelog](https://github.com/testcontainers/testcontainers-java/blob/main/CHANGELOG.md) - [Commits](https://github.com/testcontainers/testcontainers-java/compare/1.19.5...1.19.6) --- updated-dependencies: - dependency-name: org.testcontainers:junit-jupiter dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fd1a257d..4ee0b5ec 100644 --- a/pom.xml +++ b/pom.xml @@ -144,7 +144,7 @@ org.testcontainers junit-jupiter - 1.19.5 + 1.19.6 test From f8796f10db1e956a57c0135be90a7ee421881c08 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Feb 2024 19:29:20 +0000 Subject: [PATCH 202/301] Bump log4j.version from 2.22.1 to 2.23.0 Bumps `log4j.version` from 2.22.1 to 2.23.0. Updates `org.apache.logging.log4j:log4j-api` from 2.22.1 to 2.23.0 Updates `org.apache.logging.log4j:log4j-core-test` from 2.22.1 to 2.23.0 --- updated-dependencies: - dependency-name: org.apache.logging.log4j:log4j-api dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.apache.logging.log4j:log4j-core-test dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fd1a257d..61626568 100644 --- a/pom.xml +++ b/pom.xml @@ -81,7 +81,7 @@ true 2.9.0 5.14.0 - 2.22.1 + 2.23.0 2.25.0 3.2.5 From 1d214a4a013b6a480e0a2ea01072b38828cadebe Mon Sep 17 00:00:00 2001 From: release-bot Date: Tue, 27 Feb 2024 11:36:16 +0000 Subject: [PATCH 203/301] [maven-release-plugin] prepare release jsch-0.2.17 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 4714c682..10a87ddd 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.mwiede jsch jar - 0.2.17-SNAPSHOT + 0.2.17 JSch https://github.com/mwiede/jsch JSch is a pure Java implementation of SSH2 @@ -12,7 +12,7 @@ scm:git:https://github.com/mwiede/jsch.git scm:git:https://github.com/mwiede/jsch.git https://github.com/mwiede/jsch - HEAD + jsch-0.2.17 @@ -75,7 +75,7 @@ - 2024-01-03T09:19:58Z + 2024-02-27T11:34:35Z UTF-8 UTF-8 true From 624d8b7f4f82823cb3c1d1cb13fd192cf61f267d Mon Sep 17 00:00:00 2001 From: release-bot Date: Tue, 27 Feb 2024 11:36:17 +0000 Subject: [PATCH 204/301] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 10a87ddd..fc537bd9 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.mwiede jsch jar - 0.2.17 + 0.2.18-SNAPSHOT JSch https://github.com/mwiede/jsch JSch is a pure Java implementation of SSH2 @@ -12,7 +12,7 @@ scm:git:https://github.com/mwiede/jsch.git scm:git:https://github.com/mwiede/jsch.git https://github.com/mwiede/jsch - jsch-0.2.17 + HEAD @@ -75,7 +75,7 @@ - 2024-02-27T11:34:35Z + 2024-02-27T11:36:17Z UTF-8 UTF-8 true From c157a0bf556b19774ed05ce03c20e73c06589e84 Mon Sep 17 00:00:00 2001 From: Matthias Wiedemann Date: Thu, 29 Feb 2024 07:54:16 +0100 Subject: [PATCH 205/301] Update Readme.md --- Readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 99e09659..2aac622f 100644 --- a/Readme.md +++ b/Readme.md @@ -33,7 +33,7 @@ with com.github.mwiede jsch - 0.2.16 + 0.2.17 ``` @@ -43,7 +43,7 @@ When you have an artifact `foo:bar`, which contains `com.jcraft:jsch` as a trans com.github.mwiede jsch - 0.2.16 + 0.2.17 foo From 617ae9499651dcfed780d7e4b760da3a80fe8565 Mon Sep 17 00:00:00 2001 From: Matthias Wiedemann Date: Thu, 29 Feb 2024 07:56:40 +0100 Subject: [PATCH 206/301] Update ChangeLog.md --- ChangeLog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 1fb02217..1649e8f7 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,5 @@ +* [0.2.17](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.17) + * Add PBKDF2-HMAC-SHA512/256 & PBKDF2-HMAC-SHA512/224, which are both supported as of Java 21. * [0.2.16](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.16) * Add support for sntrup761x25519-sha512@openssh.com KEX algorithm. * Switch to bnd-maven-plugin in order to support Multi-Release OSGi bundle JAR's via supplemental manifest files. From 76af6411578ad35682acb8e0bcfc12e921b1d0dc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 19:30:25 +0000 Subject: [PATCH 207/301] Bump org.testcontainers:junit-jupiter from 1.19.6 to 1.19.7 Bumps [org.testcontainers:junit-jupiter](https://github.com/testcontainers/testcontainers-java) from 1.19.6 to 1.19.7. - [Release notes](https://github.com/testcontainers/testcontainers-java/releases) - [Changelog](https://github.com/testcontainers/testcontainers-java/blob/main/CHANGELOG.md) - [Commits](https://github.com/testcontainers/testcontainers-java/compare/1.19.6...1.19.7) --- updated-dependencies: - dependency-name: org.testcontainers:junit-jupiter dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fc537bd9..fc9f2078 100644 --- a/pom.xml +++ b/pom.xml @@ -144,7 +144,7 @@ org.testcontainers junit-jupiter - 1.19.6 + 1.19.7 test From eab84f4fcff10861c8f03c0e3402a6db24b204a3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 19:30:41 +0000 Subject: [PATCH 208/301] Bump org.apache.maven.plugins:maven-gpg-plugin from 3.1.0 to 3.2.0 Bumps [org.apache.maven.plugins:maven-gpg-plugin](https://github.com/apache/maven-gpg-plugin) from 3.1.0 to 3.2.0. - [Release notes](https://github.com/apache/maven-gpg-plugin/releases) - [Commits](https://github.com/apache/maven-gpg-plugin/compare/maven-gpg-plugin-3.1.0...maven-gpg-plugin-3.2.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-gpg-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fc537bd9..be146714 100644 --- a/pom.xml +++ b/pom.xml @@ -571,7 +571,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.1.0 + 3.2.0 org.apache.maven.plugins From 2420d8bf06749487639cfdc87fe7c71e9588b1b0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 19:30:46 +0000 Subject: [PATCH 209/301] Bump log4j.version from 2.23.0 to 2.23.1 Bumps `log4j.version` from 2.23.0 to 2.23.1. Updates `org.apache.logging.log4j:log4j-api` from 2.23.0 to 2.23.1 Updates `org.apache.logging.log4j:log4j-core-test` from 2.23.0 to 2.23.1 --- updated-dependencies: - dependency-name: org.apache.logging.log4j:log4j-api dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.logging.log4j:log4j-core-test dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fc537bd9..042313e0 100644 --- a/pom.xml +++ b/pom.xml @@ -81,7 +81,7 @@ true 2.9.0 5.14.0 - 2.23.0 + 2.23.1 2.25.0 3.2.5 From 1de098eda81d21cac25af6ba9f14cdad8d01ccd5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 19:30:54 +0000 Subject: [PATCH 210/301] Bump org.apache.maven.plugins:maven-assembly-plugin from 3.6.0 to 3.7.0 Bumps [org.apache.maven.plugins:maven-assembly-plugin](https://github.com/apache/maven-assembly-plugin) from 3.6.0 to 3.7.0. - [Commits](https://github.com/apache/maven-assembly-plugin/compare/maven-assembly-plugin-3.6.0...maven-assembly-plugin-3.7.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-assembly-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fc537bd9..04c0e7c3 100644 --- a/pom.xml +++ b/pom.xml @@ -507,7 +507,7 @@ org.apache.maven.plugins maven-assembly-plugin - 3.6.0 + 3.7.0 attach-sources From 4b1d0518661256c66ffc8e9a02c2fff65d41701b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 19:52:16 +0000 Subject: [PATCH 211/301] Bump errorprone.version from 2.25.0 to 2.26.0 Bumps `errorprone.version` from 2.25.0 to 2.26.0. Updates `com.google.errorprone:error_prone_annotations` from 2.25.0 to 2.26.0 - [Release notes](https://github.com/google/error-prone/releases) - [Commits](https://github.com/google/error-prone/compare/v2.25.0...v2.26.0) Updates `com.google.errorprone:error_prone_core` from 2.25.0 to 2.26.0 - [Release notes](https://github.com/google/error-prone/releases) - [Commits](https://github.com/google/error-prone/compare/v2.25.0...v2.26.0) --- updated-dependencies: - dependency-name: com.google.errorprone:error_prone_annotations dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.google.errorprone:error_prone_core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 552c5c34..1117ce56 100644 --- a/pom.xml +++ b/pom.xml @@ -82,7 +82,7 @@ 2.9.0 5.14.0 2.23.1 - 2.25.0 + 2.26.0 3.2.5 From 27fa9ceb0e3e089c902b164de5eb29b81c25285c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 19:30:25 +0000 Subject: [PATCH 212/301] Bump errorprone.version from 2.26.0 to 2.26.1 Bumps `errorprone.version` from 2.26.0 to 2.26.1. Updates `com.google.errorprone:error_prone_annotations` from 2.26.0 to 2.26.1 - [Release notes](https://github.com/google/error-prone/releases) - [Commits](https://github.com/google/error-prone/compare/v2.26.0...v2.26.1) Updates `com.google.errorprone:error_prone_core` from 2.26.0 to 2.26.1 - [Release notes](https://github.com/google/error-prone/releases) - [Commits](https://github.com/google/error-prone/compare/v2.26.0...v2.26.1) --- updated-dependencies: - dependency-name: com.google.errorprone:error_prone_annotations dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.google.errorprone:error_prone_core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5f64b2ba..0b4059d7 100644 --- a/pom.xml +++ b/pom.xml @@ -82,7 +82,7 @@ 2.9.0 5.14.0 2.23.1 - 2.26.0 + 2.26.1 3.2.5 From 53162c114b1eab6e9f09c8c9867fbf4d74ac93dd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 19:30:30 +0000 Subject: [PATCH 213/301] Bump org.apache.maven.plugins:maven-gpg-plugin from 3.2.0 to 3.2.1 Bumps [org.apache.maven.plugins:maven-gpg-plugin](https://github.com/apache/maven-gpg-plugin) from 3.2.0 to 3.2.1. - [Release notes](https://github.com/apache/maven-gpg-plugin/releases) - [Commits](https://github.com/apache/maven-gpg-plugin/compare/maven-gpg-plugin-3.2.0...maven-gpg-plugin-3.2.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-gpg-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5f64b2ba..feaa603d 100644 --- a/pom.xml +++ b/pom.xml @@ -571,7 +571,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.2.0 + 3.2.1 org.apache.maven.plugins From ffa3b9d486d7852e4c0ec65e70edeacf7be13f03 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 19:30:35 +0000 Subject: [PATCH 214/301] Bump org.apache.maven.plugins:maven-assembly-plugin from 3.7.0 to 3.7.1 Bumps [org.apache.maven.plugins:maven-assembly-plugin](https://github.com/apache/maven-assembly-plugin) from 3.7.0 to 3.7.1. - [Release notes](https://github.com/apache/maven-assembly-plugin/releases) - [Commits](https://github.com/apache/maven-assembly-plugin/compare/maven-assembly-plugin-3.7.0...maven-assembly-plugin-3.7.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-assembly-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5f64b2ba..a036310a 100644 --- a/pom.xml +++ b/pom.xml @@ -507,7 +507,7 @@ org.apache.maven.plugins maven-assembly-plugin - 3.7.0 + 3.7.1 attach-sources From 86970fb23874ee6c8d968c90a8db99be5bb604f1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 19:30:41 +0000 Subject: [PATCH 215/301] Bump org.apache.maven.plugins:maven-compiler-plugin Bumps [org.apache.maven.plugins:maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.12.1 to 3.13.0. - [Release notes](https://github.com/apache/maven-compiler-plugin/releases) - [Commits](https://github.com/apache/maven-compiler-plugin/compare/maven-compiler-plugin-3.12.1...maven-compiler-plugin-3.13.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-compiler-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5f64b2ba..358f331e 100644 --- a/pom.xml +++ b/pom.xml @@ -326,7 +326,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.12.1 + 3.13.0 8 true From 3c0a67ecda4b0e94024b7298e59e4b47bf590ab1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 19:35:55 +0000 Subject: [PATCH 216/301] Bump dependabot/fetch-metadata from 1 to 2 Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 1 to 2. - [Release notes](https://github.com/dependabot/fetch-metadata/releases) - [Commits](https://github.com/dependabot/fetch-metadata/compare/v1...v2) --- updated-dependencies: - dependency-name: dependabot/fetch-metadata dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/automerge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index e8995433..aeb47bf5 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Dependabot metadata id: metadata - uses: dependabot/fetch-metadata@v1 + uses: dependabot/fetch-metadata@v2 with: github-token: "${{ secrets.GITHUB_TOKEN }}" - name: Enable auto-merge for Dependabot PRs From cb0a35a61ed2cadf3d78ea8576d74016aefb260a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 19:37:10 +0000 Subject: [PATCH 217/301] Bump de.thetaphi:forbiddenapis from 3.6 to 3.7 Bumps [de.thetaphi:forbiddenapis](https://github.com/policeman-tools/forbidden-apis) from 3.6 to 3.7. - [Commits](https://github.com/policeman-tools/forbidden-apis/compare/3.6...3.7) --- updated-dependencies: - dependency-name: de.thetaphi:forbiddenapis dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9447a610..f646d0ff 100644 --- a/pom.xml +++ b/pom.xml @@ -656,7 +656,7 @@ de.thetaphi forbiddenapis - 3.6 + 3.7 jdk-unsafe From 81de26f90d98c1a1ef85462c100a158810b21290 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 19:37:22 +0000 Subject: [PATCH 218/301] Bump org.cyclonedx:cyclonedx-maven-plugin from 2.7.11 to 2.8.0 Bumps [org.cyclonedx:cyclonedx-maven-plugin](https://github.com/CycloneDX/cyclonedx-maven-plugin) from 2.7.11 to 2.8.0. - [Release notes](https://github.com/CycloneDX/cyclonedx-maven-plugin/releases) - [Commits](https://github.com/CycloneDX/cyclonedx-maven-plugin/compare/cyclonedx-maven-plugin-2.7.11...cyclonedx-maven-plugin-2.8.0) --- updated-dependencies: - dependency-name: org.cyclonedx:cyclonedx-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9447a610..15dd8ef3 100644 --- a/pom.xml +++ b/pom.xml @@ -546,7 +546,7 @@ org.cyclonedx cyclonedx-maven-plugin - 2.7.11 + 2.8.0 false false From 02cf35c9a8958e3c2597ed6ff8b7ca2aa7f40302 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 19:45:41 +0000 Subject: [PATCH 219/301] Bump org.apache.maven.plugins:maven-gpg-plugin from 3.2.1 to 3.2.2 Bumps [org.apache.maven.plugins:maven-gpg-plugin](https://github.com/apache/maven-gpg-plugin) from 3.2.1 to 3.2.2. - [Release notes](https://github.com/apache/maven-gpg-plugin/releases) - [Commits](https://github.com/apache/maven-gpg-plugin/compare/maven-gpg-plugin-3.2.1...maven-gpg-plugin-3.2.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-gpg-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 77c21a5d..8d0eb80c 100644 --- a/pom.xml +++ b/pom.xml @@ -571,7 +571,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.2.1 + 3.2.2 org.apache.maven.plugins From 046ed9fe861344612a626c2344916eb5328b0c39 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 19:45:45 +0000 Subject: [PATCH 220/301] Bump com.kohlschutter:compiler-annotations from 1.6.7 to 1.7.0 Bumps com.kohlschutter:compiler-annotations from 1.6.7 to 1.7.0. --- updated-dependencies: - dependency-name: com.kohlschutter:compiler-annotations dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 77c21a5d..40798353 100644 --- a/pom.xml +++ b/pom.xml @@ -101,7 +101,7 @@ com.kohlschutter compiler-annotations - 1.6.7 + 1.7.0 provided true From 45e0206b71b021e0a538b8eebbd48ae2bd5c4f09 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Apr 2024 19:33:05 +0000 Subject: [PATCH 221/301] Bump junixsocket.version from 2.9.0 to 2.9.1 Bumps `junixsocket.version` from 2.9.0 to 2.9.1. Updates `com.kohlschutter.junixsocket:junixsocket-common` from 2.9.0 to 2.9.1 - [Release notes](https://github.com/kohlschutter/junixsocket/releases) - [Commits](https://github.com/kohlschutter/junixsocket/compare/junixsocket-2.9.0...junixsocket-2.9.1) Updates `com.kohlschutter.junixsocket:junixsocket-native-common` from 2.9.0 to 2.9.1 - [Release notes](https://github.com/kohlschutter/junixsocket/releases) - [Commits](https://github.com/kohlschutter/junixsocket/compare/junixsocket-2.9.0...junixsocket-2.9.1) --- updated-dependencies: - dependency-name: com.kohlschutter.junixsocket:junixsocket-common dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.kohlschutter.junixsocket:junixsocket-native-common dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8d0eb80c..9b6fbf2c 100644 --- a/pom.xml +++ b/pom.xml @@ -79,7 +79,7 @@ UTF-8 UTF-8 true - 2.9.0 + 2.9.1 5.14.0 2.23.1 2.26.1 From 22037f6924476ad60e86ef542dac0f666fd7b0b3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Apr 2024 19:33:07 +0000 Subject: [PATCH 222/301] Bump org.bouncycastle:bcprov-jdk18on from 1.77 to 1.78 Bumps [org.bouncycastle:bcprov-jdk18on](https://github.com/bcgit/bc-java) from 1.77 to 1.78. - [Changelog](https://github.com/bcgit/bc-java/blob/main/docs/releasenotes.html) - [Commits](https://github.com/bcgit/bc-java/commits) --- updated-dependencies: - dependency-name: org.bouncycastle:bcprov-jdk18on dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8d0eb80c..06484dba 100644 --- a/pom.xml +++ b/pom.xml @@ -89,7 +89,7 @@ org.bouncycastle bcprov-jdk18on - 1.77 + 1.78 true From 8f25e959020a4bdfa6d1f20ba2b00974bb4d4318 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Apr 2024 19:33:11 +0000 Subject: [PATCH 223/301] Bump commons-io:commons-io from 2.15.1 to 2.16.1 Bumps commons-io:commons-io from 2.15.1 to 2.16.1. --- updated-dependencies: - dependency-name: commons-io:commons-io dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8d0eb80c..f9bb0afe 100644 --- a/pom.xml +++ b/pom.xml @@ -167,7 +167,7 @@ commons-io commons-io - 2.15.1 + 2.16.1 test From 49a08959f347e3bf9284f84fb97f0c997eca144e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Apr 2024 19:33:15 +0000 Subject: [PATCH 224/301] Bump org.jacoco:jacoco-maven-plugin from 0.8.11 to 0.8.12 Bumps [org.jacoco:jacoco-maven-plugin](https://github.com/jacoco/jacoco) from 0.8.11 to 0.8.12. - [Release notes](https://github.com/jacoco/jacoco/releases) - [Commits](https://github.com/jacoco/jacoco/compare/v0.8.11...v0.8.12) --- updated-dependencies: - dependency-name: org.jacoco:jacoco-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8d0eb80c..fb0a547e 100644 --- a/pom.xml +++ b/pom.xml @@ -638,7 +638,7 @@ org.jacoco jacoco-maven-plugin - 0.8.11 + 0.8.12 com/jcraft/jsch/JavaVersion.class From 66cf28e5c34dc69d295215b0bae45385d8e322c6 Mon Sep 17 00:00:00 2001 From: Matthias Wiedemann Date: Thu, 11 Apr 2024 13:03:15 +0000 Subject: [PATCH 225/301] use BoundedInputStream.builder --- src/test/java/com/jcraft/jsch/AbstractBufferMargin.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/jcraft/jsch/AbstractBufferMargin.java b/src/test/java/com/jcraft/jsch/AbstractBufferMargin.java index 8b152b88..3d85fa53 100644 --- a/src/test/java/com/jcraft/jsch/AbstractBufferMargin.java +++ b/src/test/java/com/jcraft/jsch/AbstractBufferMargin.java @@ -211,7 +211,9 @@ private void doScp(Session session, boolean debugException) throws Exception { byte[] buf = new byte[17]; is.read(buf, 0, 17); sendAck(os); - Files.copy(new BoundedInputStream(is, 100L * 1024L), out); + Files.copy( + BoundedInputStream.builder().setMaxCount(100L * 1024L).setInputStream(is).get(), + out); checkAck(is); sendAck(os); } From 20ecd5f4fdda75492dd11e7760a01876662d79d3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 19:48:14 +0000 Subject: [PATCH 226/301] Bump com.kohlschutter:compiler-annotations from 1.7.0 to 1.7.1 Bumps com.kohlschutter:compiler-annotations from 1.7.0 to 1.7.1. --- updated-dependencies: - dependency-name: com.kohlschutter:compiler-annotations dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a6a2ee7d..58ca04b6 100644 --- a/pom.xml +++ b/pom.xml @@ -101,7 +101,7 @@ com.kohlschutter compiler-annotations - 1.7.0 + 1.7.1 provided true From d83a357dda3c8aa3974a77bf43a5c94d3ccb385b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 19:48:14 +0000 Subject: [PATCH 227/301] Bump org.apache.maven.plugins:maven-gpg-plugin from 3.2.2 to 3.2.3 Bumps [org.apache.maven.plugins:maven-gpg-plugin](https://github.com/apache/maven-gpg-plugin) from 3.2.2 to 3.2.3. - [Release notes](https://github.com/apache/maven-gpg-plugin/releases) - [Commits](https://github.com/apache/maven-gpg-plugin/compare/maven-gpg-plugin-3.2.2...maven-gpg-plugin-3.2.3) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-gpg-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a6a2ee7d..366d0af6 100644 --- a/pom.xml +++ b/pom.xml @@ -571,7 +571,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.2.2 + 3.2.3 org.apache.maven.plugins From 1509aab6a5c4f6b38ad9f62ac7be3129e941fa96 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 19:48:20 +0000 Subject: [PATCH 228/301] Bump org.slf4j:slf4j-api from 2.0.12 to 2.0.13 Bumps org.slf4j:slf4j-api from 2.0.12 to 2.0.13. --- updated-dependencies: - dependency-name: org.slf4j:slf4j-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a6a2ee7d..6ffacc17 100644 --- a/pom.xml +++ b/pom.xml @@ -132,7 +132,7 @@ org.slf4j slf4j-api - 2.0.12 + 2.0.13 true From 1d0c42c21d85b4365c0b7ecfcf878c2c60fd55d3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Apr 2024 19:10:59 +0000 Subject: [PATCH 229/301] Bump org.apache.maven.plugins:maven-gpg-plugin from 3.2.3 to 3.2.4 Bumps [org.apache.maven.plugins:maven-gpg-plugin](https://github.com/apache/maven-gpg-plugin) from 3.2.3 to 3.2.4. - [Release notes](https://github.com/apache/maven-gpg-plugin/releases) - [Commits](https://github.com/apache/maven-gpg-plugin/compare/maven-gpg-plugin-3.2.3...maven-gpg-plugin-3.2.4) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-gpg-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f6f26bb0..c09016f3 100644 --- a/pom.xml +++ b/pom.xml @@ -571,7 +571,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.2.3 + 3.2.4 org.apache.maven.plugins From 3bfdaad4d0b5b0a1427a66434c08fcbf2b15ca7e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Apr 2024 19:11:02 +0000 Subject: [PATCH 230/301] Bump org.apache.maven.plugins:maven-jar-plugin from 3.3.0 to 3.4.1 Bumps [org.apache.maven.plugins:maven-jar-plugin](https://github.com/apache/maven-jar-plugin) from 3.3.0 to 3.4.1. - [Release notes](https://github.com/apache/maven-jar-plugin/releases) - [Commits](https://github.com/apache/maven-jar-plugin/compare/maven-jar-plugin-3.3.0...maven-jar-plugin-3.4.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-jar-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f6f26bb0..11d8c5ed 100644 --- a/pom.xml +++ b/pom.xml @@ -490,7 +490,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.3.0 + 3.4.1 From 56875777427f527296a31bf08f2822249bc66612 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Apr 2024 19:11:06 +0000 Subject: [PATCH 231/301] Bump org.bouncycastle:bcprov-jdk18on from 1.78 to 1.78.1 Bumps [org.bouncycastle:bcprov-jdk18on](https://github.com/bcgit/bc-java) from 1.78 to 1.78.1. - [Changelog](https://github.com/bcgit/bc-java/blob/main/docs/releasenotes.html) - [Commits](https://github.com/bcgit/bc-java/commits) --- updated-dependencies: - dependency-name: org.bouncycastle:bcprov-jdk18on dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f6f26bb0..57153086 100644 --- a/pom.xml +++ b/pom.xml @@ -89,7 +89,7 @@ org.bouncycastle bcprov-jdk18on - 1.78 + 1.78.1 true From d2bb48b56789a98d594303c2c31f1c9219357bb9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Apr 2024 19:11:08 +0000 Subject: [PATCH 232/301] Bump com.kohlschutter:compiler-annotations from 1.7.1 to 1.7.2 Bumps com.kohlschutter:compiler-annotations from 1.7.1 to 1.7.2. --- updated-dependencies: - dependency-name: com.kohlschutter:compiler-annotations dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f6f26bb0..998bf99a 100644 --- a/pom.xml +++ b/pom.xml @@ -101,7 +101,7 @@ com.kohlschutter compiler-annotations - 1.7.1 + 1.7.2 provided true From 951dfc79d7b46c8ed14775200759a5c3a7a39b5d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 19:06:12 +0000 Subject: [PATCH 233/301] Bump commons-codec:commons-codec from 1.16.1 to 1.17.0 Bumps [commons-codec:commons-codec](https://github.com/apache/commons-codec) from 1.16.1 to 1.17.0. - [Changelog](https://github.com/apache/commons-codec/blob/master/RELEASE-NOTES.txt) - [Commits](https://github.com/apache/commons-codec/compare/rel/commons-codec-1.16.1...rel/commons-codec-1.17.0) --- updated-dependencies: - dependency-name: commons-codec:commons-codec dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 86fa4ef9..ce74b910 100644 --- a/pom.xml +++ b/pom.xml @@ -161,7 +161,7 @@ commons-codec commons-codec - 1.16.1 + 1.17.0 test From 801016a986defdd5562204f63d58d93c75bd5691 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 19:06:23 +0000 Subject: [PATCH 234/301] Bump org.apache.maven.plugins:maven-deploy-plugin from 3.1.1 to 3.1.2 Bumps [org.apache.maven.plugins:maven-deploy-plugin](https://github.com/apache/maven-deploy-plugin) from 3.1.1 to 3.1.2. - [Release notes](https://github.com/apache/maven-deploy-plugin/releases) - [Commits](https://github.com/apache/maven-deploy-plugin/compare/maven-deploy-plugin-3.1.1...maven-deploy-plugin-3.1.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-deploy-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 86fa4ef9..fb133ffc 100644 --- a/pom.xml +++ b/pom.xml @@ -576,7 +576,7 @@ org.apache.maven.plugins maven-deploy-plugin - 3.1.1 + 3.1.2 org.apache.maven.plugins From 5d4b58b41409e556e0d5bb154dd029a03716ff12 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 19:06:28 +0000 Subject: [PATCH 235/301] Bump org.apache.maven.plugins:maven-install-plugin from 3.1.1 to 3.1.2 Bumps [org.apache.maven.plugins:maven-install-plugin](https://github.com/apache/maven-install-plugin) from 3.1.1 to 3.1.2. - [Release notes](https://github.com/apache/maven-install-plugin/releases) - [Commits](https://github.com/apache/maven-install-plugin/compare/maven-install-plugin-3.1.1...maven-install-plugin-3.1.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-install-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 86fa4ef9..080f1f7e 100644 --- a/pom.xml +++ b/pom.xml @@ -581,7 +581,7 @@ org.apache.maven.plugins maven-install-plugin - 3.1.1 + 3.1.2 org.apache.maven.plugins From bb675dd230707923c6b31c33852f594b2ee154d8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 May 2024 19:25:36 +0000 Subject: [PATCH 236/301] Bump errorprone.version from 2.26.1 to 2.27.1 Bumps `errorprone.version` from 2.26.1 to 2.27.1. Updates `com.google.errorprone:error_prone_annotations` from 2.26.1 to 2.27.1 - [Release notes](https://github.com/google/error-prone/releases) - [Commits](https://github.com/google/error-prone/compare/v2.26.1...v2.27.1) Updates `com.google.errorprone:error_prone_core` from 2.26.1 to 2.27.1 - [Release notes](https://github.com/google/error-prone/releases) - [Commits](https://github.com/google/error-prone/compare/v2.26.1...v2.27.1) --- updated-dependencies: - dependency-name: com.google.errorprone:error_prone_annotations dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.google.errorprone:error_prone_core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 862d1ea0..6b7159c7 100644 --- a/pom.xml +++ b/pom.xml @@ -82,7 +82,7 @@ 2.9.1 5.14.0 2.23.1 - 2.26.1 + 2.27.1 3.2.5 From 6cf7172a0ace2d38a529c6b7924a0a68a9b634f5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 19:10:50 +0000 Subject: [PATCH 237/301] Bump org.testcontainers:junit-jupiter from 1.19.7 to 1.19.8 Bumps [org.testcontainers:junit-jupiter](https://github.com/testcontainers/testcontainers-java) from 1.19.7 to 1.19.8. - [Release notes](https://github.com/testcontainers/testcontainers-java/releases) - [Changelog](https://github.com/testcontainers/testcontainers-java/blob/main/CHANGELOG.md) - [Commits](https://github.com/testcontainers/testcontainers-java/compare/1.19.7...1.19.8) --- updated-dependencies: - dependency-name: org.testcontainers:junit-jupiter dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 862d1ea0..5d5e70be 100644 --- a/pom.xml +++ b/pom.xml @@ -144,7 +144,7 @@ org.testcontainers junit-jupiter - 1.19.7 + 1.19.8 test From cace7e5f7bf43a0b2b3194bf2034291fc050b34a Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Fri, 3 May 2024 14:28:08 -0500 Subject: [PATCH 238/301] Update Maven Wrapper to 3.3.1. --- .mvn/wrapper/maven-wrapper.properties | 2 +- mvnw | 95 +++++++++++++++------------ mvnw.cmd | 3 +- 3 files changed, 56 insertions(+), 44 deletions(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 346d645f..fe378a15 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -14,5 +14,5 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +wrapperVersion=3.3.1 distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar diff --git a/mvnw b/mvnw index 633bbb74..ac8e247e 100755 --- a/mvnw +++ b/mvnw @@ -19,7 +19,7 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Apache Maven Wrapper startup batch script, version 3.2.0 +# Apache Maven Wrapper startup batch script, version 3.3.1 # # Optional ENV vars # ----------------- @@ -35,15 +35,17 @@ set -euf # OS specific support. native_path() { printf %s\\n "$1"; } case "$(uname)" in -(CYGWIN*|MINGW*) [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" - native_path() { cygpath --path --windows "$1"; } ;; +CYGWIN* | MINGW*) + [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" + native_path() { cygpath --path --windows "$1"; } + ;; esac # set JAVACMD and JAVACCMD set_java_home() { # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched - if [ -n "${JAVA_HOME-}" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + if [ -n "${JAVA_HOME-}" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then # IBM's JDK on AIX uses strange locations for the executables JAVACMD="$JAVA_HOME/jre/sh/java" JAVACCMD="$JAVA_HOME/jre/sh/javac" @@ -51,17 +53,25 @@ set_java_home() { JAVACMD="$JAVA_HOME/bin/java" JAVACCMD="$JAVA_HOME/bin/javac" - if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ] ; then + if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 return 1 fi fi else - JAVACMD="$('set' +e; 'unset' -f command 2>/dev/null; 'command' -v java)" || : - JAVACCMD="$('set' +e; 'unset' -f command 2>/dev/null; 'command' -v javac)" || : - - if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ] ; then + JAVACMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v java + )" || : + JAVACCMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v javac + )" || : + + if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 return 1 fi @@ -72,7 +82,8 @@ set_java_home() { hash_string() { str="${1:-}" h=0 while [ -n "$str" ]; do - h=$(( ( h * 31 + $(LC_CTYPE=C printf %d "'$str") ) % 4294967296 )) + char="${str%"${str#?}"}" + h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) str="${str#?}" done printf %x\\n $h @@ -89,29 +100,29 @@ die() { # parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties while IFS="=" read -r key value; do case "${key-}" in - distributionUrl) distributionUrl="${value-}" ;; - distributionSha256Sum) distributionSha256Sum="${value-}" ;; + distributionUrl) distributionUrl="${value-}" ;; + distributionSha256Sum) distributionSha256Sum="${value-}" ;; esac -done < "${0%/*}/.mvn/wrapper/maven-wrapper.properties" +done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties" [ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties" - case "${distributionUrl##*/}" in -(maven-mvnd-*bin.*) +maven-mvnd-*bin.*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in - (*AMD64:CYGWIN*|*AMD64:MINGW*) distributionPlatform=windows-amd64 ;; - (:Darwin*x86_64) distributionPlatform=darwin-amd64 ;; - (:Darwin*arm64) distributionPlatform=darwin-aarch64 ;; - (:Linux*x86_64*) distributionPlatform=linux-amd64 ;; - (*) echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 - distributionPlatform=linux-amd64 - ;; + *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; + :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; + :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; + :Linux*x86_64*) distributionPlatform=linux-amd64 ;; + *) + echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 + distributionPlatform=linux-amd64 + ;; esac distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" ;; -(maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; -(*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; +maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; +*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; esac # apply MVNW_REPOURL and calculate MAVEN_HOME @@ -133,8 +144,8 @@ if [ -d "$MAVEN_HOME" ]; then fi case "${distributionUrl-}" in -(*?-bin.zip|*?maven-mvnd-?*-?*.zip) ;; -(*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; +*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; +*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; esac # prepare tmp dir @@ -168,17 +179,17 @@ case "${MVNW_PASSWORD:+has-password}" in has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; esac -if [ -z "${MVNW_USERNAME-}" ] && command -v wget > /dev/null; then +if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then verbose "Found wget ... using wget" - wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" -elif [ -z "${MVNW_USERNAME-}" ] && command -v curl > /dev/null; then + wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" +elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then verbose "Found curl ... using curl" - curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" + curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" elif set_java_home; then verbose "Falling back to use Java to download" javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" - cat > "$javaSource" <<-END + cat >"$javaSource" <<-END public class Downloader extends java.net.Authenticator { protected java.net.PasswordAuthentication getPasswordAuthentication() @@ -188,13 +199,13 @@ elif set_java_home; then public static void main( String[] args ) throws Exception { setDefault( new Downloader() ); - java.nio.file.Files.copy( new java.net.URL( args[0] ).openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); + java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); } } END # For Cygwin/MinGW, switch paths to Windows format before running javac and java verbose " - Compiling Downloader.java ..." - "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" + "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" verbose " - Running Downloader.java ..." "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" fi @@ -206,12 +217,12 @@ if [ -n "${distributionSha256Sum-}" ]; then echo "Checksum validation is not supported for maven-mvnd." >&2 echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 exit 1 - elif command -v sha256sum > /dev/null; then - if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c > /dev/null 2>&1; then + elif command -v sha256sum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then distributionSha256Result=true fi - elif command -v shasum > /dev/null; then - if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c > /dev/null 2>&1; then + elif command -v shasum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then distributionSha256Result=true fi else @@ -227,12 +238,12 @@ if [ -n "${distributionSha256Sum-}" ]; then fi # unzip and move -if command -v unzip > /dev/null; then - unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" +if command -v unzip >/dev/null; then + unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" else - tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" + tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" fi -printf %s\\n "$distributionUrl" > "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url" +printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url" mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" clean || : diff --git a/mvnw.cmd b/mvnw.cmd index dd02e16f..1ff8c9dd 100644 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -19,7 +19,7 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Apache Maven Wrapper startup batch script, version 3.2.0 +@REM Apache Maven Wrapper startup batch script, version 3.3.1 @REM @REM Optional ENV vars @REM MVNW_REPOURL - repo url base for downloading maven distribution @@ -123,6 +123,7 @@ if ($distributionSha256Sum) { if ($USE_MVND) { Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." } From 86cae73e48360302038e36256a5e1849d20d464f Mon Sep 17 00:00:00 2001 From: Matthias Wiedemann Date: Sat, 18 May 2024 09:08:12 +0000 Subject: [PATCH 239/301] removing obsolete config --- pom.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/pom.xml b/pom.xml index 11d8c5ed..d6e1f960 100644 --- a/pom.xml +++ b/pom.xml @@ -497,9 +497,6 @@ true true - - true - ${project.build.outputDirectory}/META-INF/MANIFEST.MF From b0c8434c3a66fe01ddb9653936e5fc65e27e2173 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 19:11:27 +0000 Subject: [PATCH 240/301] --- updated-dependencies: - dependency-name: org.codehaus.mojo:build-helper-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e295cdb8..ea423666 100644 --- a/pom.xml +++ b/pom.xml @@ -295,7 +295,7 @@ org.codehaus.mojo build-helper-maven-plugin - 3.5.0 + 3.6.0 From 4ba2dacf9df651a3d460e996b714b4b0511d1f62 Mon Sep 17 00:00:00 2001 From: Brian Middaugh <3270756+bmiddaugh@users.noreply.github.com> Date: Tue, 28 May 2024 12:29:25 -0700 Subject: [PATCH 241/301] Handle negated patterns according to ssh_config(5) Fixes #564 --- .../java/com/jcraft/jsch/OpenSSHConfig.java | 14 ++++++++++---- .../com/jcraft/jsch/OpenSSHConfigTest.java | 19 +++++++++++++++++++ src/test/resources/config_with_negations | 11 +++++++++++ 3 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 src/test/resources/config_with_negations diff --git a/src/main/java/com/jcraft/jsch/OpenSSHConfig.java b/src/main/java/com/jcraft/jsch/OpenSSHConfig.java index aab20e09..76328a2e 100644 --- a/src/main/java/com/jcraft/jsch/OpenSSHConfig.java +++ b/src/main/java/com/jcraft/jsch/OpenSSHConfig.java @@ -188,6 +188,8 @@ class MyConfig implements Config { byte[] _host = Util.str2byte(host); if (hosts.size() > 1) { for (int i = 1; i < hosts.size(); i++) { + boolean anyPositivePatternMatches = false; + boolean anyNegativePatternMatches = false; String patterns[] = hosts.elementAt(i).split("[ \t]"); for (int j = 0; j < patterns.length; j++) { boolean negate = false; @@ -197,13 +199,17 @@ class MyConfig implements Config { foo = foo.substring(1).trim(); } if (Util.glob(Util.str2byte(foo), _host)) { - if (!negate) { - _configs.addElement(config.get(hosts.elementAt(i))); + if (negate) { + anyNegativePatternMatches = true; + } else { + anyPositivePatternMatches = true; } - } else if (negate) { - _configs.addElement(config.get(hosts.elementAt(i))); } } + + if (anyPositivePatternMatches && !anyNegativePatternMatches) { + _configs.addElement(config.get(hosts.elementAt(i))); + } } } } diff --git a/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java b/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java index 99567500..ba9a7477 100644 --- a/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java +++ b/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java @@ -88,4 +88,23 @@ void replaceKexAlgorithms() throws IOException { ConfigRepository.Config kex = parse.getConfig(""); assertEquals("diffie-hellman-group1-sha1", kex.getValue("kex")); } + + @Test + void parseFileWithNegations() throws IOException, URISyntaxException { + final String configFile = + Paths.get(ClassLoader.getSystemResource("config_with_negations").toURI()).toFile().getAbsolutePath(); + final OpenSSHConfig openSSHConfig = OpenSSHConfig.parseFile(configFile); + + assertUserEquals(openSSHConfig, "my.example.com", "u1"); + assertUserEquals(openSSHConfig, "my-jump.example.com", "jump-u1"); + assertUserEquals(openSSHConfig, "my-proxy.example.com", "proxy-u1"); + assertUserEquals(openSSHConfig, "my.example.org", "u2"); + } + + private void assertUserEquals(OpenSSHConfig openSSHConfig, String host, String expected) { + final ConfigRepository.Config config = openSSHConfig.getConfig(host); + assertNotNull(config); + String actual = config.getUser(); + assertEquals(expected, actual, String.format("Expected user for host %s to be %s, but was %s", host, expected, actual)); + } } diff --git a/src/test/resources/config_with_negations b/src/test/resources/config_with_negations new file mode 100644 index 00000000..ff8ed382 --- /dev/null +++ b/src/test/resources/config_with_negations @@ -0,0 +1,11 @@ +Host *.example.com !*-jump.example.com !*-proxy.example.com + User u1 + +Host *-jump.example.com + User jump-u1 + +Host *-proxy.example.com + User proxy-u1 + +Host *.example.org + User u2 From 9b361e5ef3c187f3010bc8179f7a95262ed323bd Mon Sep 17 00:00:00 2001 From: Brian Middaugh <3270756+bmiddaugh@users.noreply.github.com> Date: Tue, 28 May 2024 14:22:28 -0700 Subject: [PATCH 242/301] Run maven formatter --- src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java b/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java index ba9a7477..d9b51619 100644 --- a/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java +++ b/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java @@ -92,7 +92,8 @@ void replaceKexAlgorithms() throws IOException { @Test void parseFileWithNegations() throws IOException, URISyntaxException { final String configFile = - Paths.get(ClassLoader.getSystemResource("config_with_negations").toURI()).toFile().getAbsolutePath(); + Paths.get(ClassLoader.getSystemResource("config_with_negations").toURI()).toFile() + .getAbsolutePath(); final OpenSSHConfig openSSHConfig = OpenSSHConfig.parseFile(configFile); assertUserEquals(openSSHConfig, "my.example.com", "u1"); @@ -105,6 +106,7 @@ private void assertUserEquals(OpenSSHConfig openSSHConfig, String host, String e final ConfigRepository.Config config = openSSHConfig.getConfig(host); assertNotNull(config); String actual = config.getUser(); - assertEquals(expected, actual, String.format("Expected user for host %s to be %s, but was %s", host, expected, actual)); + assertEquals(expected, actual, + String.format("Expected user for host %s to be %s, but was %s", host, expected, actual)); } } From 9a25dd59c422c21cfd6f313408922854f523c66b Mon Sep 17 00:00:00 2001 From: Brian Middaugh <3270756+bmiddaugh@users.noreply.github.com> Date: Tue, 28 May 2024 15:02:15 -0700 Subject: [PATCH 243/301] Don't use default locale for String.format call --- src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java b/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java index d9b51619..439d712b 100644 --- a/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java +++ b/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java @@ -107,6 +107,6 @@ private void assertUserEquals(OpenSSHConfig openSSHConfig, String host, String e assertNotNull(config); String actual = config.getUser(); assertEquals(expected, actual, - String.format("Expected user for host %s to be %s, but was %s", host, expected, actual)); + String.format(Locale.ROOT, "Expected user for host %s to be %s, but was %s", host, expected, actual)); } } From 955d64199437ef8065ce7fb6d743ff06e23acdf3 Mon Sep 17 00:00:00 2001 From: Brian Middaugh <3270756+bmiddaugh@users.noreply.github.com> Date: Wed, 29 May 2024 09:35:23 -0700 Subject: [PATCH 244/301] Run formatter --- src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java b/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java index 439d712b..f40df771 100644 --- a/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java +++ b/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java @@ -106,7 +106,7 @@ private void assertUserEquals(OpenSSHConfig openSSHConfig, String host, String e final ConfigRepository.Config config = openSSHConfig.getConfig(host); assertNotNull(config); String actual = config.getUser(); - assertEquals(expected, actual, - String.format(Locale.ROOT, "Expected user for host %s to be %s, but was %s", host, expected, actual)); + assertEquals(expected, actual, String.format(Locale.ROOT, + "Expected user for host %s to be %s, but was %s", host, expected, actual)); } } From bde81d8e586ec2ea2fb30dddb47c67cfe8de61ee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 19:05:05 +0000 Subject: [PATCH 245/301] Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.6.3 to 3.7.0 Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.6.3 to 3.7.0. - [Release notes](https://github.com/apache/maven-javadoc-plugin/releases) - [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.6.3...maven-javadoc-plugin-3.7.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-javadoc-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e295cdb8..4aa71ea3 100644 --- a/pom.xml +++ b/pom.xml @@ -523,7 +523,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.6.3 + 3.7.0 true none From fb78b4b7a38168e20aca87d92e20e228106f42f9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 19:05:17 +0000 Subject: [PATCH 246/301] Bump errorprone.version from 2.27.1 to 2.28.0 Bumps `errorprone.version` from 2.27.1 to 2.28.0. Updates `com.google.errorprone:error_prone_annotations` from 2.27.1 to 2.28.0 - [Release notes](https://github.com/google/error-prone/releases) - [Commits](https://github.com/google/error-prone/compare/v2.27.1...v2.28.0) Updates `com.google.errorprone:error_prone_core` from 2.27.1 to 2.28.0 - [Release notes](https://github.com/google/error-prone/releases) - [Commits](https://github.com/google/error-prone/compare/v2.27.1...v2.28.0) --- updated-dependencies: - dependency-name: com.google.errorprone:error_prone_annotations dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.google.errorprone:error_prone_core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e295cdb8..1cbad7c0 100644 --- a/pom.xml +++ b/pom.xml @@ -82,7 +82,7 @@ 2.9.1 5.14.0 2.23.1 - 2.27.1 + 2.28.0 3.2.5 From cfd4f60c59e89a7c1ef7847e4fc5877dc619da06 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 19:05:23 +0000 Subject: [PATCH 247/301] Bump org.apache.maven.plugins:maven-enforcer-plugin from 3.4.1 to 3.5.0 Bumps [org.apache.maven.plugins:maven-enforcer-plugin](https://github.com/apache/maven-enforcer) from 3.4.1 to 3.5.0. - [Release notes](https://github.com/apache/maven-enforcer/releases) - [Commits](https://github.com/apache/maven-enforcer/compare/enforcer-3.4.1...enforcer-3.5.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-enforcer-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e295cdb8..7f55cc50 100644 --- a/pom.xml +++ b/pom.xml @@ -246,7 +246,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 3.4.1 + 3.5.0 enforce-java From 71a6e115772a5344662fe3108dd7fa0decc5d6c1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 19:05:25 +0000 Subject: [PATCH 248/301] Bump net.revelc.code.formatter:formatter-maven-plugin Bumps net.revelc.code.formatter:formatter-maven-plugin from 2.23.0 to 2.24.0. --- updated-dependencies: - dependency-name: net.revelc.code.formatter:formatter-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e295cdb8..4fc03760 100644 --- a/pom.xml +++ b/pom.xml @@ -615,7 +615,7 @@ net.revelc.code.formatter formatter-maven-plugin - 2.23.0 + 2.24.0 ${project.basedir}/eclipse-java-google-style.xml UTF-8 From 55e78f678e4337c0aa9cc8ce7d4a1276d6179b5e Mon Sep 17 00:00:00 2001 From: Matthias Wiedemann Date: Fri, 7 Jun 2024 12:55:26 +0000 Subject: [PATCH 249/301] adopt formatvalidation requirements --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4fc03760..a8083dd5 100644 --- a/pom.xml +++ b/pom.xml @@ -782,7 +782,7 @@ formatvalidation - [11,) + [17,) From 4727e7e9d90602657fbcac74202a03a5569abea4 Mon Sep 17 00:00:00 2001 From: release-bot Date: Fri, 7 Jun 2024 22:13:32 +0000 Subject: [PATCH 250/301] [maven-release-plugin] prepare release jsch-0.2.18 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 2e930152..af84ab22 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.mwiede jsch jar - 0.2.18-SNAPSHOT + 0.2.18 JSch https://github.com/mwiede/jsch JSch is a pure Java implementation of SSH2 @@ -12,7 +12,7 @@ scm:git:https://github.com/mwiede/jsch.git scm:git:https://github.com/mwiede/jsch.git https://github.com/mwiede/jsch - HEAD + jsch-0.2.18 @@ -75,7 +75,7 @@ - 2024-02-27T11:36:17Z + 2024-06-07T22:11:52Z UTF-8 UTF-8 true From 46e72af34049915ed234e522c8cb2bf43cdb301c Mon Sep 17 00:00:00 2001 From: release-bot Date: Fri, 7 Jun 2024 22:13:34 +0000 Subject: [PATCH 251/301] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index af84ab22..cf21175a 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.mwiede jsch jar - 0.2.18 + 0.2.19-SNAPSHOT JSch https://github.com/mwiede/jsch JSch is a pure Java implementation of SSH2 @@ -12,7 +12,7 @@ scm:git:https://github.com/mwiede/jsch.git scm:git:https://github.com/mwiede/jsch.git https://github.com/mwiede/jsch - jsch-0.2.18 + HEAD @@ -75,7 +75,7 @@ - 2024-06-07T22:11:52Z + 2024-06-07T22:13:34Z UTF-8 UTF-8 true From 7168752a0056519f2c1e38866147be8fdc5c3a96 Mon Sep 17 00:00:00 2001 From: Matthias Wiedemann Date: Sun, 9 Jun 2024 15:28:46 +0200 Subject: [PATCH 252/301] Update ChangeLog.md --- ChangeLog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 1649e8f7..15569361 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,5 @@ +* [0.2.18](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.18) + * Handle negated patterns according to ssh_config(5) by @bmiddaugh in https://github.com/mwiede/jsch/pull/565 * [0.2.17](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.17) * Add PBKDF2-HMAC-SHA512/256 & PBKDF2-HMAC-SHA512/224, which are both supported as of Java 21. * [0.2.16](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.16) From 26c833966eb5e07b72fb8e9dc8ad661e5d4baba3 Mon Sep 17 00:00:00 2001 From: Matthias Wiedemann Date: Sun, 9 Jun 2024 15:29:26 +0200 Subject: [PATCH 253/301] Update Readme.md --- Readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 2aac622f..cb1daf22 100644 --- a/Readme.md +++ b/Readme.md @@ -33,7 +33,7 @@ with com.github.mwiede jsch - 0.2.17 + 0.2.18 ``` @@ -43,7 +43,7 @@ When you have an artifact `foo:bar`, which contains `com.jcraft:jsch` as a trans com.github.mwiede jsch - 0.2.17 + 0.2.18 foo From e2dd9f8a50edbe23cf126ae2e3b6accb33acde08 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 19:07:29 +0000 Subject: [PATCH 254/301] Bump org.apache.maven.plugins:maven-checkstyle-plugin Bumps [org.apache.maven.plugins:maven-checkstyle-plugin](https://github.com/apache/maven-checkstyle-plugin) from 3.3.1 to 3.4.0. - [Commits](https://github.com/apache/maven-checkstyle-plugin/compare/maven-checkstyle-plugin-3.3.1...maven-checkstyle-plugin-3.4.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-checkstyle-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cf21175a..28f3f199 100644 --- a/pom.xml +++ b/pom.xml @@ -593,7 +593,7 @@ org.apache.maven.plugins maven-checkstyle-plugin - 3.3.1 + 3.4.0 true true From fc447ce3e698ecd506d4af067da995e5206c46ec Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 19:07:31 +0000 Subject: [PATCH 255/301] Bump net.revelc.code.formatter:formatter-maven-plugin Bumps net.revelc.code.formatter:formatter-maven-plugin from 2.24.0 to 2.24.1. --- updated-dependencies: - dependency-name: net.revelc.code.formatter:formatter-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cf21175a..2155decd 100644 --- a/pom.xml +++ b/pom.xml @@ -615,7 +615,7 @@ net.revelc.code.formatter formatter-maven-plugin - 2.24.0 + 2.24.1 ${project.basedir}/eclipse-java-google-style.xml UTF-8 From 96a02c48556a3179744573abbd93f10d7d632f76 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 19:49:48 +0000 Subject: [PATCH 256/301] Bump surefire.version from 3.2.5 to 3.3.0 Bumps `surefire.version` from 3.2.5 to 3.3.0. Updates `org.apache.maven.plugins:maven-surefire-plugin` from 3.2.5 to 3.3.0 - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.5...surefire-3.3.0) Updates `org.apache.maven.plugins:maven-failsafe-plugin` from 3.2.5 to 3.3.0 - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.5...surefire-3.3.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.apache.maven.plugins:maven-failsafe-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4e803d62..cac763f5 100644 --- a/pom.xml +++ b/pom.xml @@ -83,7 +83,7 @@ 5.14.0 2.23.1 2.28.0 - 3.2.5 + 3.3.0 From 0216aaf9b4ba79c10eacd6ef954f001271a170c6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 19:49:56 +0000 Subject: [PATCH 257/301] Bump org.apache.maven.plugins:maven-dependency-plugin Bumps [org.apache.maven.plugins:maven-dependency-plugin](https://github.com/apache/maven-dependency-plugin) from 3.6.1 to 3.7.0. - [Release notes](https://github.com/apache/maven-dependency-plugin/releases) - [Commits](https://github.com/apache/maven-dependency-plugin/compare/maven-dependency-plugin-3.6.1...maven-dependency-plugin-3.7.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-dependency-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4e803d62..8b20889d 100644 --- a/pom.xml +++ b/pom.xml @@ -588,7 +588,7 @@ org.apache.maven.plugins maven-dependency-plugin - 3.6.1 + 3.7.0 org.apache.maven.plugins From 2351f2cc49b7def4a505b47ef0fd508eea025d8e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 19:50:00 +0000 Subject: [PATCH 258/301] Bump org.apache.maven.plugins:maven-release-plugin from 3.0.1 to 3.1.0 Bumps [org.apache.maven.plugins:maven-release-plugin](https://github.com/apache/maven-release) from 3.0.1 to 3.1.0. - [Release notes](https://github.com/apache/maven-release/releases) - [Commits](https://github.com/apache/maven-release/compare/maven-release-3.0.1...maven-release-3.1.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-release-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4e803d62..d4401129 100644 --- a/pom.xml +++ b/pom.xml @@ -559,7 +559,7 @@ org.apache.maven.plugins maven-release-plugin - 3.0.1 + 3.1.0 false release From 57acba3975ad4bdab5e68c1408fe9ce990088695 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2024 19:20:29 +0000 Subject: [PATCH 259/301] Bump org.apache.maven.plugins:maven-clean-plugin from 3.3.2 to 3.4.0 Bumps [org.apache.maven.plugins:maven-clean-plugin](https://github.com/apache/maven-clean-plugin) from 3.3.2 to 3.4.0. - [Release notes](https://github.com/apache/maven-clean-plugin/releases) - [Commits](https://github.com/apache/maven-clean-plugin/compare/maven-clean-plugin-3.3.2...maven-clean-plugin-3.4.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-clean-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c178bc36..23f0ab2f 100644 --- a/pom.xml +++ b/pom.xml @@ -459,7 +459,7 @@ org.apache.maven.plugins maven-clean-plugin - 3.3.2 + 3.4.0 org.apache.maven.plugins From c7608c708cf71d57eb3cd25a96dc550628627f5b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2024 19:20:36 +0000 Subject: [PATCH 260/301] Bump org.apache.maven.plugins:maven-dependency-plugin Bumps [org.apache.maven.plugins:maven-dependency-plugin](https://github.com/apache/maven-dependency-plugin) from 3.7.0 to 3.7.1. - [Release notes](https://github.com/apache/maven-dependency-plugin/releases) - [Commits](https://github.com/apache/maven-dependency-plugin/compare/maven-dependency-plugin-3.7.0...maven-dependency-plugin-3.7.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-dependency-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c178bc36..49db7feb 100644 --- a/pom.xml +++ b/pom.xml @@ -588,7 +588,7 @@ org.apache.maven.plugins maven-dependency-plugin - 3.7.0 + 3.7.1 org.apache.maven.plugins From 85ed6d3355295ead3c72bd9a213b289054461d6e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2024 19:20:42 +0000 Subject: [PATCH 261/301] Bump org.apache.maven.plugins:maven-jar-plugin from 3.4.1 to 3.4.2 Bumps [org.apache.maven.plugins:maven-jar-plugin](https://github.com/apache/maven-jar-plugin) from 3.4.1 to 3.4.2. - [Release notes](https://github.com/apache/maven-jar-plugin/releases) - [Commits](https://github.com/apache/maven-jar-plugin/compare/maven-jar-plugin-3.4.1...maven-jar-plugin-3.4.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-jar-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c178bc36..bdc0233a 100644 --- a/pom.xml +++ b/pom.xml @@ -490,7 +490,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.4.1 + 3.4.2 From 246920bd09909aafc5a3c7983ffca3ec9d40b7d0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 19:51:41 +0000 Subject: [PATCH 262/301] Bump org.junit.jupiter:junit-jupiter from 5.10.2 to 5.10.3 Bumps [org.junit.jupiter:junit-jupiter](https://github.com/junit-team/junit5) from 5.10.2 to 5.10.3. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.10.2...r5.10.3) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cfdc2546..9179ca20 100644 --- a/pom.xml +++ b/pom.xml @@ -138,7 +138,7 @@ org.junit.jupiter junit-jupiter - 5.10.2 + 5.10.3 test From 4db02d466999c0d96091157cb80cb6e2e18fb3e7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 19:51:43 +0000 Subject: [PATCH 263/301] Bump com.kohlschutter:compiler-annotations from 1.7.2 to 1.7.3 Bumps com.kohlschutter:compiler-annotations from 1.7.2 to 1.7.3. --- updated-dependencies: - dependency-name: com.kohlschutter:compiler-annotations dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cfdc2546..0a0430b0 100644 --- a/pom.xml +++ b/pom.xml @@ -101,7 +101,7 @@ com.kohlschutter compiler-annotations - 1.7.2 + 1.7.3 provided true From a7ef4a0e3e7ec3ab465587b48efd865f2b2b5329 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Mon, 24 Jun 2024 15:17:25 -0500 Subject: [PATCH 264/301] Update to latest Maven (3.9.8), Maven Wrapper (3.3.2) & Java (21.0.3) releases. --- .mvn/wrapper/maven-wrapper.properties | 5 +++-- .sdkmanrc | 4 ++-- mvnw | 17 +++++++++++++---- mvnw.cmd | 5 ++++- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index fe378a15..f95f1ee8 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -14,5 +14,6 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -wrapperVersion=3.3.1 -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip +wrapperVersion=3.3.2 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.8/apache-maven-3.9.8-bin.zip diff --git a/.sdkmanrc b/.sdkmanrc index 9b281c73..7d27f296 100644 --- a/.sdkmanrc +++ b/.sdkmanrc @@ -1,4 +1,4 @@ # Enable auto-env through the sdkman_auto_env config # Add key=value pairs of SDKs to use below -java=21.0.2-tem -maven=3.9.6 +java=21.0.3-tem +maven=3.9.8 diff --git a/mvnw b/mvnw index ac8e247e..19529ddf 100755 --- a/mvnw +++ b/mvnw @@ -19,7 +19,7 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Apache Maven Wrapper startup batch script, version 3.3.1 +# Apache Maven Wrapper startup batch script, version 3.3.2 # # Optional ENV vars # ----------------- @@ -97,11 +97,19 @@ die() { exit 1 } +trim() { + # MWRAPPER-139: + # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. + # Needed for removing poorly interpreted newline sequences when running in more + # exotic environments such as mingw bash on Windows. + printf "%s" "${1}" | tr -d '[:space:]' +} + # parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties while IFS="=" read -r key value; do case "${key-}" in - distributionUrl) distributionUrl="${value-}" ;; - distributionSha256Sum) distributionSha256Sum="${value-}" ;; + distributionUrl) distributionUrl=$(trim "${value-}") ;; + distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; esac done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties" [ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties" @@ -131,7 +139,8 @@ esac distributionUrlName="${distributionUrl##*/}" distributionUrlNameMain="${distributionUrlName%.*}" distributionUrlNameMain="${distributionUrlNameMain%-bin}" -MAVEN_HOME="$HOME/.m2/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" +MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" +MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" exec_maven() { unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : diff --git a/mvnw.cmd b/mvnw.cmd index 1ff8c9dd..b150b91e 100644 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -19,7 +19,7 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Apache Maven Wrapper startup batch script, version 3.3.1 +@REM Apache Maven Wrapper startup batch script, version 3.3.2 @REM @REM Optional ENV vars @REM MVNW_REPOURL - repo url base for downloading maven distribution @@ -79,6 +79,9 @@ if ($env:MVNW_REPOURL) { $distributionUrlName = $distributionUrl -replace '^.*/','' $distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' $MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" +if ($env:MAVEN_USER_HOME) { + $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" +} $MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' $MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" From b13277aaa40da4edfe8be5a490a1e28d6cc2741e Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Thu, 11 Jul 2024 07:19:04 -0500 Subject: [PATCH 265/301] Only execute build once during CI and then run distinct jobs to run tests for each Java version. --- .github/workflows/maven.yml | 59 ++++++++++++++++++++++++++----------- .gitignore | 1 + 2 files changed, 43 insertions(+), 17 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index bcdd71c7..476ebabc 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -15,42 +15,67 @@ on: jobs: build: runs-on: ubuntu-latest - strategy: - matrix: - java: ['8', '11', '17', '21'] steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 - name: Cache local Maven repository uses: actions/cache@v4 with: - path: ~/.m2/repository - key: ${{ runner.os }}-${{ matrix.java }}-maven-${{ hashFiles('**/pom.xml') }} + path: | + ~/.m2/repository + ~/.m2/wrapper + key: ${{ runner.os }}-build-maven-${{ hashFiles('**/pom.xml', '**/maven-wrapper.properties') }} restore-keys: | - ${{ runner.os }}-${{ matrix.java }}-maven- - - name: Set up build JDK + ${{ runner.os }}-build-maven- + - name: Set up JDK uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: '21' check-latest: true - name: Build with Maven - run: ./mvnw -B -V -e -DskipTests=true package - - uses: actions/upload-artifact@v4 + run: ./mvnw -B -V -e verify -DskipTests=true -DskipITs=true + - name: Archive target directory + run: tar -cf target.tar target + - name: Upload target directory archive + uses: actions/upload-artifact@v4 + with: + name: build_target + path: target.tar + test: + needs: build + runs-on: ubuntu-latest + strategy: + matrix: + java: ['8', '11', '17', '21'] + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Cache local Maven repository + uses: actions/cache@v4 with: - name: java-${{ matrix.java }}-jars path: | - **/target/*.jar - **/target/bom.* - if: always() - - name: Set up test JDK ${{ matrix.java }} + ~/.m2/repository + ~/.m2/wrapper + key: ${{ runner.os }}-test-${{ matrix.java }}-maven-${{ hashFiles('**/pom.xml', '**/maven-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-test-${{ matrix.java }}-maven- + - name: Set up JDK uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: ${{ matrix.java }} check-latest: true + - name: Download target directory archive + uses: actions/download-artifact@v4 + with: + name: build_target + - name: Extract target directory archive + run: tar -xf target.tar - name: Test with Maven - run: ./mvnw -B -V -e -P coverage verify -Denforcer.skip=true -Dmaven.resources.skip=true -Dflatten.skip=true -Dmaven.main.skip=true -Dbnd.skip=true -Dassembly.skipAssembly=true -Dmaven.javadoc.skip=true -Dcyclonedx.skip=true -DskipITs=false - - uses: actions/upload-artifact@v4 + run: ./mvnw -B -V -e -Pcoverage verify -Denforcer.skip=true -Dmaven.resources.skip=true -Dflatten.skip=true -Dmaven.main.skip=true -Dbnd.skip=true -Dassembly.skipAssembly=true -Dmaven.javadoc.skip=true -Dcyclonedx.skip=true -Dformatter.skip=true -Dforbiddenapis.skip=true -DskipTests=false -DskipITs=false + - name: Upload test results + uses: actions/upload-artifact@v4 with: name: java-${{ matrix.java }}-testresults path: | diff --git a/.gitignore b/.gitignore index 606ae2fb..389ad015 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.geany nb-configuration.xml .flattened-pom.xml +target.tar # Created by https://www.toptal.com/developers/gitignore/api/intellij+all,netbeans,eclipse,visualstudiocode,vim,emacs,macos,windows,linux,java,maven # Edit at https://www.toptal.com/developers/gitignore?templates=intellij+all,netbeans,eclipse,visualstudiocode,vim,emacs,macos,windows,linux,java,maven From 9766a56fdc16f4315a6686caa7b224be33aea259 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Thu, 11 Jul 2024 07:24:47 -0500 Subject: [PATCH 266/301] Run tests on Java 22. --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 476ebabc..79c99c61 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -47,7 +47,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - java: ['8', '11', '17', '21'] + java: ['8', '11', '17', '21', '22'] steps: - name: Checkout repository uses: actions/checkout@v4 From 6b9669f20b28e5ebc66b1e4d787961c34cb0a9b4 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Thu, 11 Jul 2024 07:50:33 -0500 Subject: [PATCH 267/301] Harden CI workflows by pinning action versions to specific commit hashes. --- .github/workflows/automerge.yml | 2 +- .github/workflows/codeql-analysis.yml | 12 ++++++------ .github/workflows/coverity.yml | 8 ++++---- .github/workflows/javadoc.yml | 6 +++--- .github/workflows/maven.yml | 18 +++++++++--------- .github/workflows/release.yml | 2 +- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index aeb47bf5..729c50a2 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Dependabot metadata id: metadata - uses: dependabot/fetch-metadata@v2 + uses: dependabot/fetch-metadata@dbb049abf0d677abbd7f7eee0375145b417fdd34 # v2.2.0 with: github-token: "${{ secrets.GITHUB_TOKEN }}" - name: Enable auto-merge for Dependabot PRs diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 2adf1043..60d891a8 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -31,18 +31,18 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup JDK - uses: actions/setup-java@v4 + uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 with: distribution: 'zulu' java-version: '21' - check-latest: true + check-latest: true cache: 'maven' # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v3 + uses: github/codeql-action/init@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -56,7 +56,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v3 + uses: github/codeql-action/autobuild@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 # ℹī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -69,4 +69,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 + uses: github/codeql-action/analyze@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index e8bc0126..f12fd994 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -7,15 +7,15 @@ jobs: coverity: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up build JDK - uses: actions/setup-java@v4 + uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 with: distribution: 'zulu' java-version: '21' - check-latest: true + check-latest: true cache: 'maven' - - uses: vapier/coverity-scan-action@v1 + - uses: vapier/coverity-scan-action@2068473c7bdf8c2fb984a6a40ae76ee7facd7a85 # v1.8.0 with: email: ${{ secrets.COVERITY_SCAN_EMAIL }} token: ${{ secrets.COVERITY_SCAN_TOKEN }} diff --git a/.github/workflows/javadoc.yml b/.github/workflows/javadoc.yml index 2dbd1d0c..38731767 100644 --- a/.github/workflows/javadoc.yml +++ b/.github/workflows/javadoc.yml @@ -11,9 +11,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout 🛎ī¸ - uses: actions/checkout@v4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up build JDK - uses: actions/setup-java@v4 + uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 with: distribution: 'zulu' java-version: '21' @@ -21,7 +21,7 @@ jobs: - name: Build Javadoc run: ./mvnw -B -V -e javadoc:javadoc - name: Deploy 🚀 - uses: JamesIves/github-pages-deploy-action@v4 + uses: JamesIves/github-pages-deploy-action@94f3c658273cf92fb48ef99e5fbc02bd2dc642b2 # v4.6.3 with: folder: target/site/apidocs target-folder: ${{github.ref_name}} diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 79c99c61..25224ad3 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -17,9 +17,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Cache local Maven repository - uses: actions/cache@v4 + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 with: path: | ~/.m2/repository @@ -28,7 +28,7 @@ jobs: restore-keys: | ${{ runner.os }}-build-maven- - name: Set up JDK - uses: actions/setup-java@v4 + uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 with: distribution: 'zulu' java-version: '21' @@ -38,7 +38,7 @@ jobs: - name: Archive target directory run: tar -cf target.tar target - name: Upload target directory archive - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4 with: name: build_target path: target.tar @@ -50,9 +50,9 @@ jobs: java: ['8', '11', '17', '21', '22'] steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Cache local Maven repository - uses: actions/cache@v4 + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 with: path: | ~/.m2/repository @@ -61,13 +61,13 @@ jobs: restore-keys: | ${{ runner.os }}-test-${{ matrix.java }}-maven- - name: Set up JDK - uses: actions/setup-java@v4 + uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 with: distribution: 'zulu' java-version: ${{ matrix.java }} check-latest: true - name: Download target directory archive - uses: actions/download-artifact@v4 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: build_target - name: Extract target directory archive @@ -75,7 +75,7 @@ jobs: - name: Test with Maven run: ./mvnw -B -V -e -Pcoverage verify -Denforcer.skip=true -Dmaven.resources.skip=true -Dflatten.skip=true -Dmaven.main.skip=true -Dbnd.skip=true -Dassembly.skipAssembly=true -Dmaven.javadoc.skip=true -Dcyclonedx.skip=true -Dformatter.skip=true -Dforbiddenapis.skip=true -DskipTests=false -DskipITs=false - name: Upload test results - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4 with: name: java-${{ matrix.java }}-testresults path: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 95c9036f..7a354aea 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,7 +17,7 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v4 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 # Runs a set of commands using the runners shell - name: Release From ff9f2348b95a548a4b16b46f1a8ad2b8770e51f8 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Thu, 11 Jul 2024 07:52:22 -0500 Subject: [PATCH 268/301] Increase Dependabot open PR limit. --- .github/dependabot.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index ca2841c3..7e7a78a1 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,9 +9,11 @@ updates: directory: "/" # Location of package manifests schedule: interval: "weekly" + open-pull-requests-limit: 25 - package-ecosystem: "github-actions" # Workflow files stored in the # default location of `.github/workflows` directory: "/" schedule: - interval: "weekly" + interval: "weekly" + open-pull-requests-limit: 25 From 39413bce043d3c4d52d8e255b9a34afcb4be5441 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Thu, 11 Jul 2024 10:18:44 -0500 Subject: [PATCH 269/301] Enforce DHGEX prime modulus bit length meets configured constraints. --- ChangeLog.md | 2 ++ src/main/java/com/jcraft/jsch/DHGEX.java | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 15569361..c9ca552e 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,5 @@ +* [0.2.19](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.19) + * Enforce DHGEX prime modulus bit length meets configured constraints. * [0.2.18](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.18) * Handle negated patterns according to ssh_config(5) by @bmiddaugh in https://github.com/mwiede/jsch/pull/565 * [0.2.17](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.17) diff --git a/src/main/java/com/jcraft/jsch/DHGEX.java b/src/main/java/com/jcraft/jsch/DHGEX.java index 15f9bd0f..393b0ba2 100644 --- a/src/main/java/com/jcraft/jsch/DHGEX.java +++ b/src/main/java/com/jcraft/jsch/DHGEX.java @@ -26,6 +26,8 @@ package com.jcraft.jsch; +import java.math.BigInteger; + abstract class DHGEX extends KeyExchange { private static final int SSH_MSG_KEX_DH_GEX_GROUP = 31; @@ -79,8 +81,7 @@ public void init(Session session, byte[] V_S, byte[] V_C, byte[] I_S, byte[] I_C min = Integer.parseInt(session.getConfig("dhgex_min")); max = Integer.parseInt(session.getConfig("dhgex_max")); preferred = Integer.parseInt(session.getConfig("dhgex_preferred")); - if (checkInvalidSize(min) || checkInvalidSize(max) || checkInvalidSize(preferred) - || preferred < min || max < preferred) { + if (min <= 0 || max <= 0 || preferred <= 0 || preferred < min || preferred > max) { throw new JSchException( "Invalid DHGEX sizes: min=" + min + " max=" + max + " preferred=" + preferred); } @@ -127,6 +128,11 @@ public boolean next(Buffer _buf) throws Exception { p = _buf.getMPInt(); g = _buf.getMPInt(); + int bits = new BigInteger(1, p).bitLength(); + if (bits < min || bits > max) { + return false; + } + dh.setP(p); dh.setG(g); // The client responds with: @@ -237,8 +243,4 @@ public boolean next(Buffer _buf) throws Exception { public int getState() { return state; } - - static boolean checkInvalidSize(int size) { - return (size < 1024 || size > 8192 || size % 1024 != 0); - } } From 30ee53936f9561892f6f4d59e4f6ee30515e7ef7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Jul 2024 11:23:47 +0000 Subject: [PATCH 270/301] Bump surefire.version from 3.3.0 to 3.3.1 Bumps `surefire.version` from 3.3.0 to 3.3.1. Updates `org.apache.maven.plugins:maven-surefire-plugin` from 3.3.0 to 3.3.1 - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.3.0...surefire-3.3.1) Updates `org.apache.maven.plugins:maven-failsafe-plugin` from 3.3.0 to 3.3.1 - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.3.0...surefire-3.3.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.maven.plugins:maven-failsafe-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 10e8ff7b..afbc7115 100644 --- a/pom.xml +++ b/pom.xml @@ -83,7 +83,7 @@ 5.14.0 2.23.1 2.28.0 - 3.3.0 + 3.3.1 From a444570df570d5c0704f5972cbeb46c79812da5d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Jul 2024 11:23:54 +0000 Subject: [PATCH 271/301] Bump junixsocket.version from 2.9.1 to 2.10.0 Bumps `junixsocket.version` from 2.9.1 to 2.10.0. Updates `com.kohlschutter.junixsocket:junixsocket-common` from 2.9.1 to 2.10.0 - [Release notes](https://github.com/kohlschutter/junixsocket/releases) - [Commits](https://github.com/kohlschutter/junixsocket/compare/junixsocket-2.9.1...junixsocket-2.10.0) Updates `com.kohlschutter.junixsocket:junixsocket-native-common` from 2.9.1 to 2.10.0 - [Release notes](https://github.com/kohlschutter/junixsocket/releases) - [Commits](https://github.com/kohlschutter/junixsocket/compare/junixsocket-2.9.1...junixsocket-2.10.0) --- updated-dependencies: - dependency-name: com.kohlschutter.junixsocket:junixsocket-common dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.kohlschutter.junixsocket:junixsocket-native-common dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 10e8ff7b..b53ce62d 100644 --- a/pom.xml +++ b/pom.xml @@ -79,7 +79,7 @@ UTF-8 UTF-8 true - 2.9.1 + 2.10.0 5.14.0 2.23.1 2.28.0 From 6dfa15a9b8fc4926cbb3d0f992cdde1e9460ac36 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Jul 2024 11:23:57 +0000 Subject: [PATCH 272/301] Bump org.apache.maven.plugins:maven-release-plugin from 3.1.0 to 3.1.1 Bumps [org.apache.maven.plugins:maven-release-plugin](https://github.com/apache/maven-release) from 3.1.0 to 3.1.1. - [Release notes](https://github.com/apache/maven-release/releases) - [Commits](https://github.com/apache/maven-release/compare/maven-release-3.1.0...maven-release-3.1.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-release-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 10e8ff7b..daca8a95 100644 --- a/pom.xml +++ b/pom.xml @@ -559,7 +559,7 @@ org.apache.maven.plugins maven-release-plugin - 3.1.0 + 3.1.1 false release From 7e9f7db98cc3d897a0b51c5867b1718effc817b9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Jul 2024 11:23:58 +0000 Subject: [PATCH 273/301] Bump github/codeql-action from 3.25.11 to 3.25.12 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.11 to 3.25.12. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/b611370bb5703a7efb587f9d136a52ea24c5c38c...4fa2a7953630fd2f3fb380f21be14ede0169dd4f) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql-analysis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 60d891a8..e2caae59 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -42,7 +42,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 + uses: github/codeql-action/init@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -56,7 +56,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 + uses: github/codeql-action/autobuild@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12 # ℹī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -69,4 +69,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 + uses: github/codeql-action/analyze@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12 From 841b23e45b94c46959300567b1fa30e2e6e05764 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 19:12:27 +0000 Subject: [PATCH 274/301] Bump github/codeql-action from 3.25.12 to 3.25.13 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.12 to 3.25.13. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/4fa2a7953630fd2f3fb380f21be14ede0169dd4f...2d790406f505036ef40ecba973cc774a50395aac) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql-analysis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index e2caae59..e1c37517 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -42,7 +42,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12 + uses: github/codeql-action/init@2d790406f505036ef40ecba973cc774a50395aac # v3.25.13 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -56,7 +56,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12 + uses: github/codeql-action/autobuild@2d790406f505036ef40ecba973cc774a50395aac # v3.25.13 # ℹī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -69,4 +69,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12 + uses: github/codeql-action/analyze@2d790406f505036ef40ecba973cc774a50395aac # v3.25.13 From 23f9b85ee00cbddb0c35ef401f49db04f2e14543 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 19:52:31 +0000 Subject: [PATCH 275/301] Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.7.0 to 3.8.0 Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.7.0 to 3.8.0. - [Release notes](https://github.com/apache/maven-javadoc-plugin/releases) - [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.7.0...maven-javadoc-plugin-3.8.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-javadoc-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 82eff425..36a120c0 100644 --- a/pom.xml +++ b/pom.xml @@ -523,7 +523,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.7.0 + 3.8.0 true none From c116be6d66aef7f6309fac25f8c8c619a6e596d5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 19:52:41 +0000 Subject: [PATCH 276/301] Bump commons-codec:commons-codec from 1.17.0 to 1.17.1 Bumps [commons-codec:commons-codec](https://github.com/apache/commons-codec) from 1.17.0 to 1.17.1. - [Changelog](https://github.com/apache/commons-codec/blob/master/RELEASE-NOTES.txt) - [Commits](https://github.com/apache/commons-codec/compare/rel/commons-codec-1.17.0...rel/commons-codec-1.17.1) --- updated-dependencies: - dependency-name: commons-codec:commons-codec dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 82eff425..0d681786 100644 --- a/pom.xml +++ b/pom.xml @@ -161,7 +161,7 @@ commons-codec commons-codec - 1.17.0 + 1.17.1 test From 6463c26ed6805458fdf311aaf0c8d4c9f91113b9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 19:52:49 +0000 Subject: [PATCH 277/301] Bump errorprone.version from 2.28.0 to 2.29.2 Bumps `errorprone.version` from 2.28.0 to 2.29.2. Updates `com.google.errorprone:error_prone_annotations` from 2.28.0 to 2.29.2 - [Release notes](https://github.com/google/error-prone/releases) - [Commits](https://github.com/google/error-prone/compare/v2.28.0...v2.29.2) Updates `com.google.errorprone:error_prone_core` from 2.28.0 to 2.29.2 - [Release notes](https://github.com/google/error-prone/releases) - [Commits](https://github.com/google/error-prone/compare/v2.28.0...v2.29.2) --- updated-dependencies: - dependency-name: com.google.errorprone:error_prone_annotations dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.google.errorprone:error_prone_core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 82eff425..054d5ea9 100644 --- a/pom.xml +++ b/pom.xml @@ -82,7 +82,7 @@ 2.10.0 5.14.0 2.23.1 - 2.28.0 + 2.29.2 3.3.1 From a1f8b0993fb8385c46e7b1644159d05c8dbda5ae Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Tue, 23 Jul 2024 10:33:39 -0500 Subject: [PATCH 278/301] #604 Fix possible rekeying timeouts. --- ChangeLog.md | 1 + src/main/java/com/jcraft/jsch/Session.java | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index c9ca552e..27adf487 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,6 @@ * [0.2.19](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.19) * Enforce DHGEX prime modulus bit length meets configured constraints. + * #604 Fix possible rekeying timeouts. * [0.2.18](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.18) * Handle negated patterns according to ssh_config(5) by @bmiddaugh in https://github.com/mwiede/jsch/pull/565 * [0.2.17](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.17) diff --git a/src/main/java/com/jcraft/jsch/Session.java b/src/main/java/com/jcraft/jsch/Session.java index 8c348b44..22a0c103 100644 --- a/src/main/java/com/jcraft/jsch/Session.java +++ b/src/main/java/com/jcraft/jsch/Session.java @@ -159,7 +159,7 @@ public class Session { protected boolean daemon_thread = false; - private long kex_start_time = 0L; + private volatile long kex_start_time = 0L; int max_auth_tries = 6; int auth_failures = 0; @@ -843,8 +843,8 @@ private void send_kexinit() throws Exception { } } - in_kex = true; kex_start_time = System.currentTimeMillis(); + in_kex = true; // byte SSH_MSG_KEXINIT(20) // byte[16] cookie (random bytes) From d90b297d1df75383ab57102f8d78afadb116b473 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Tue, 23 Jul 2024 10:37:26 -0500 Subject: [PATCH 279/301] Fix ChangeLog formatting. --- ChangeLog.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 27adf487..10a242e0 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,10 +1,10 @@ * [0.2.19](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.19) - * Enforce DHGEX prime modulus bit length meets configured constraints. - * #604 Fix possible rekeying timeouts. + * Enforce DHGEX prime modulus bit length meets configured constraints. + * #604 Fix possible rekeying timeouts. * [0.2.18](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.18) - * Handle negated patterns according to ssh_config(5) by @bmiddaugh in https://github.com/mwiede/jsch/pull/565 + * Handle negated patterns according to ssh_config(5) by @bmiddaugh in https://github.com/mwiede/jsch/pull/565 * [0.2.17](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.17) - * Add PBKDF2-HMAC-SHA512/256 & PBKDF2-HMAC-SHA512/224, which are both supported as of Java 21. + * Add PBKDF2-HMAC-SHA512/256 & PBKDF2-HMAC-SHA512/224, which are both supported as of Java 21. * [0.2.16](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.16) * Add support for sntrup761x25519-sha512@openssh.com KEX algorithm. * Switch to bnd-maven-plugin in order to support Multi-Release OSGi bundle JAR's via supplemental manifest files. From 47204fd33bf206914df04c8021737f9f847a6ba2 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Wed, 24 Jul 2024 10:44:30 -0500 Subject: [PATCH 280/301] Update to latest Java (21.0.4) release. --- .sdkmanrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.sdkmanrc b/.sdkmanrc index 7d27f296..2b547b6f 100644 --- a/.sdkmanrc +++ b/.sdkmanrc @@ -1,4 +1,4 @@ # Enable auto-env through the sdkman_auto_env config # Add key=value pairs of SDKs to use below -java=21.0.3-tem +java=21.0.4-tem maven=3.9.8 From 8352675ad12300a4b489da00074397815f16b8e2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jul 2024 19:28:23 +0000 Subject: [PATCH 281/301] Bump github/codeql-action from 3.25.13 to 3.25.15 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.13 to 3.25.15. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/2d790406f505036ef40ecba973cc774a50395aac...afb54ba388a7dca6ecae48f608c4ff05ff4cc77a) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql-analysis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index e1c37517..eed9a14f 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -42,7 +42,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@2d790406f505036ef40ecba973cc774a50395aac # v3.25.13 + uses: github/codeql-action/init@afb54ba388a7dca6ecae48f608c4ff05ff4cc77a # v3.25.15 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -56,7 +56,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@2d790406f505036ef40ecba973cc774a50395aac # v3.25.13 + uses: github/codeql-action/autobuild@afb54ba388a7dca6ecae48f608c4ff05ff4cc77a # v3.25.15 # ℹī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -69,4 +69,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@2d790406f505036ef40ecba973cc774a50395aac # v3.25.13 + uses: github/codeql-action/analyze@afb54ba388a7dca6ecae48f608c4ff05ff4cc77a # v3.25.15 From 487582831dce732ea65c156f21badc59a742e5dc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 19:27:40 +0000 Subject: [PATCH 282/301] Bump actions/setup-java from 4.2.1 to 4.2.2 Bumps [actions/setup-java](https://github.com/actions/setup-java) from 4.2.1 to 4.2.2. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](https://github.com/actions/setup-java/compare/99b8673ff64fbf99d8d325f52d9a5bdedb8483e9...6a0805fcefea3d4657a47ac4c165951e33482018) --- updated-dependencies: - dependency-name: actions/setup-java dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/coverity.yml | 2 +- .github/workflows/javadoc.yml | 2 +- .github/workflows/maven.yml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index eed9a14f..6d16968d 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -33,7 +33,7 @@ jobs: - name: Checkout repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup JDK - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 + uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2 with: distribution: 'zulu' java-version: '21' diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index f12fd994..420557da 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -9,7 +9,7 @@ jobs: steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up build JDK - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 + uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2 with: distribution: 'zulu' java-version: '21' diff --git a/.github/workflows/javadoc.yml b/.github/workflows/javadoc.yml index 38731767..8d74e9de 100644 --- a/.github/workflows/javadoc.yml +++ b/.github/workflows/javadoc.yml @@ -13,7 +13,7 @@ jobs: - name: Checkout 🛎ī¸ uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up build JDK - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 + uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2 with: distribution: 'zulu' java-version: '21' diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 25224ad3..aa52c476 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -28,7 +28,7 @@ jobs: restore-keys: | ${{ runner.os }}-build-maven- - name: Set up JDK - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 + uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2 with: distribution: 'zulu' java-version: '21' @@ -61,7 +61,7 @@ jobs: restore-keys: | ${{ runner.os }}-test-${{ matrix.java }}-maven- - name: Set up JDK - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 + uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2 with: distribution: 'zulu' java-version: ${{ matrix.java }} From dded39d2b9b09b4a39f6a2d229d3391273ff209b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 19:31:18 +0000 Subject: [PATCH 283/301] Bump org.testcontainers:junit-jupiter from 1.19.8 to 1.20.1 Bumps [org.testcontainers:junit-jupiter](https://github.com/testcontainers/testcontainers-java) from 1.19.8 to 1.20.1. - [Release notes](https://github.com/testcontainers/testcontainers-java/releases) - [Changelog](https://github.com/testcontainers/testcontainers-java/blob/main/CHANGELOG.md) - [Commits](https://github.com/testcontainers/testcontainers-java/compare/1.19.8...1.20.1) --- updated-dependencies: - dependency-name: org.testcontainers:junit-jupiter dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0d681786..9c67bb9a 100644 --- a/pom.xml +++ b/pom.xml @@ -144,7 +144,7 @@ org.testcontainers junit-jupiter - 1.19.8 + 1.20.1 test From dc63c6fd59d52b635e1df1a32ad7b3106afdde59 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 19:31:22 +0000 Subject: [PATCH 284/301] Bump org.cyclonedx:cyclonedx-maven-plugin from 2.8.0 to 2.8.1 Bumps [org.cyclonedx:cyclonedx-maven-plugin](https://github.com/CycloneDX/cyclonedx-maven-plugin) from 2.8.0 to 2.8.1. - [Release notes](https://github.com/CycloneDX/cyclonedx-maven-plugin/releases) - [Commits](https://github.com/CycloneDX/cyclonedx-maven-plugin/compare/cyclonedx-maven-plugin-2.8.0...cyclonedx-maven-plugin-2.8.1) --- updated-dependencies: - dependency-name: org.cyclonedx:cyclonedx-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0d681786..95d1b339 100644 --- a/pom.xml +++ b/pom.xml @@ -543,7 +543,7 @@ org.cyclonedx cyclonedx-maven-plugin - 2.8.0 + 2.8.1 false false From 600ffb3aae7052c3a8b56bc2fa03546c2fca1354 Mon Sep 17 00:00:00 2001 From: release-bot Date: Tue, 6 Aug 2024 09:07:29 +0000 Subject: [PATCH 285/301] [maven-release-plugin] prepare release jsch-0.2.19 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 297d4762..6cda0db3 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.mwiede jsch jar - 0.2.19-SNAPSHOT + 0.2.19 JSch https://github.com/mwiede/jsch JSch is a pure Java implementation of SSH2 @@ -12,7 +12,7 @@ scm:git:https://github.com/mwiede/jsch.git scm:git:https://github.com/mwiede/jsch.git https://github.com/mwiede/jsch - HEAD + jsch-0.2.19 @@ -75,7 +75,7 @@ - 2024-06-07T22:13:34Z + 2024-08-06T09:05:46Z UTF-8 UTF-8 true From 98558b104346a2dcd8eccc2e22b28e2572dba458 Mon Sep 17 00:00:00 2001 From: release-bot Date: Tue, 6 Aug 2024 09:07:30 +0000 Subject: [PATCH 286/301] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 6cda0db3..bc0e3b85 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.mwiede jsch jar - 0.2.19 + 0.2.20-SNAPSHOT JSch https://github.com/mwiede/jsch JSch is a pure Java implementation of SSH2 @@ -12,7 +12,7 @@ scm:git:https://github.com/mwiede/jsch.git scm:git:https://github.com/mwiede/jsch.git https://github.com/mwiede/jsch - jsch-0.2.19 + HEAD @@ -75,7 +75,7 @@ - 2024-08-06T09:05:46Z + 2024-08-06T09:07:30Z UTF-8 UTF-8 true From cc6b7a6db6c9f6ee700502d5bbb743c353c432a7 Mon Sep 17 00:00:00 2001 From: Matthias Wiedemann Date: Tue, 6 Aug 2024 11:57:34 +0200 Subject: [PATCH 287/301] Update version in Readme.md --- Readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index cb1daf22..94dfc8d0 100644 --- a/Readme.md +++ b/Readme.md @@ -33,7 +33,7 @@ with com.github.mwiede jsch - 0.2.18 + 0.2.19 ``` @@ -43,7 +43,7 @@ When you have an artifact `foo:bar`, which contains `com.jcraft:jsch` as a trans com.github.mwiede jsch - 0.2.18 + 0.2.19 foo From 8a390ee2282aea7c68114d4b0ac595514756d7eb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:21:25 +0000 Subject: [PATCH 288/301] Bump actions/upload-artifact from 4.3.4 to 4.3.6 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.3.4 to 4.3.6. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/0b2256b8c012f0828dc542b3febcab082c67f72b...834a144ee995460fba8ed112a2fc961b36a5ec5a) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/maven.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index aa52c476..9cdd4cb7 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -38,7 +38,7 @@ jobs: - name: Archive target directory run: tar -cf target.tar target - name: Upload target directory archive - uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: build_target path: target.tar @@ -75,7 +75,7 @@ jobs: - name: Test with Maven run: ./mvnw -B -V -e -Pcoverage verify -Denforcer.skip=true -Dmaven.resources.skip=true -Dflatten.skip=true -Dmaven.main.skip=true -Dbnd.skip=true -Dassembly.skipAssembly=true -Dmaven.javadoc.skip=true -Dcyclonedx.skip=true -Dformatter.skip=true -Dforbiddenapis.skip=true -DskipTests=false -DskipITs=false - name: Upload test results - uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: java-${{ matrix.java }}-testresults path: | From cda76aa1f823f06dbfcf6db2f645eb72b5271543 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:39:06 +0000 Subject: [PATCH 289/301] Bump org.apache.maven.plugins:maven-gpg-plugin from 3.2.4 to 3.2.5 Bumps [org.apache.maven.plugins:maven-gpg-plugin](https://github.com/apache/maven-gpg-plugin) from 3.2.4 to 3.2.5. - [Release notes](https://github.com/apache/maven-gpg-plugin/releases) - [Commits](https://github.com/apache/maven-gpg-plugin/compare/maven-gpg-plugin-3.2.4...maven-gpg-plugin-3.2.5) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-gpg-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bc0e3b85..c3e9220a 100644 --- a/pom.xml +++ b/pom.xml @@ -568,7 +568,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.2.4 + 3.2.5 org.apache.maven.plugins From 9e30e4bb1a7dc2161fd83998db6632625774b567 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:39:07 +0000 Subject: [PATCH 290/301] Bump org.slf4j:slf4j-api from 2.0.13 to 2.0.16 Bumps org.slf4j:slf4j-api from 2.0.13 to 2.0.16. --- updated-dependencies: - dependency-name: org.slf4j:slf4j-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bc0e3b85..e0777ad4 100644 --- a/pom.xml +++ b/pom.xml @@ -132,7 +132,7 @@ org.slf4j slf4j-api - 2.0.13 + 2.0.16 true From 5b2bd7f1588acd9daad7200affd683a3441d96ee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 19:18:28 +0000 Subject: [PATCH 291/301] Bump github/codeql-action from 3.25.15 to 3.26.3 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.15 to 3.26.3. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/afb54ba388a7dca6ecae48f608c4ff05ff4cc77a...883d8588e56d1753a8a58c1c86e88976f0c23449) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql-analysis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 6d16968d..4d3e2fe4 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -42,7 +42,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@afb54ba388a7dca6ecae48f608c4ff05ff4cc77a # v3.25.15 + uses: github/codeql-action/init@883d8588e56d1753a8a58c1c86e88976f0c23449 # v3.26.3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -56,7 +56,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@afb54ba388a7dca6ecae48f608c4ff05ff4cc77a # v3.25.15 + uses: github/codeql-action/autobuild@883d8588e56d1753a8a58c1c86e88976f0c23449 # v3.26.3 # ℹī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -69,4 +69,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@afb54ba388a7dca6ecae48f608c4ff05ff4cc77a # v3.25.15 + uses: github/codeql-action/analyze@883d8588e56d1753a8a58c1c86e88976f0c23449 # v3.26.3 From 4e195c94faba3f0b30f633a61e9c352fad219747 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 20:00:04 +0000 Subject: [PATCH 292/301] Bump org.apache.maven.plugins:maven-deploy-plugin from 3.1.2 to 3.1.3 Bumps [org.apache.maven.plugins:maven-deploy-plugin](https://github.com/apache/maven-deploy-plugin) from 3.1.2 to 3.1.3. - [Release notes](https://github.com/apache/maven-deploy-plugin/releases) - [Commits](https://github.com/apache/maven-deploy-plugin/compare/maven-deploy-plugin-3.1.2...maven-deploy-plugin-3.1.3) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-deploy-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a92809fc..77dd1de0 100644 --- a/pom.xml +++ b/pom.xml @@ -573,7 +573,7 @@ org.apache.maven.plugins maven-deploy-plugin - 3.1.2 + 3.1.3 org.apache.maven.plugins From 40ed8e24de3b0be8c82bfdc27e5488735068deb5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 20:00:07 +0000 Subject: [PATCH 293/301] Bump org.apache.maven.plugins:maven-install-plugin from 3.1.2 to 3.1.3 Bumps [org.apache.maven.plugins:maven-install-plugin](https://github.com/apache/maven-install-plugin) from 3.1.2 to 3.1.3. - [Release notes](https://github.com/apache/maven-install-plugin/releases) - [Commits](https://github.com/apache/maven-install-plugin/compare/maven-install-plugin-3.1.2...maven-install-plugin-3.1.3) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-install-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a92809fc..adca4ee6 100644 --- a/pom.xml +++ b/pom.xml @@ -578,7 +578,7 @@ org.apache.maven.plugins maven-install-plugin - 3.1.2 + 3.1.3 org.apache.maven.plugins From ea73d53f1c43e382e4134dbb5f30da18a37e11f5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 20:00:10 +0000 Subject: [PATCH 294/301] Bump org.junit.jupiter:junit-jupiter from 5.10.3 to 5.11.0 Bumps [org.junit.jupiter:junit-jupiter](https://github.com/junit-team/junit5) from 5.10.3 to 5.11.0. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.10.3...r5.11.0) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a92809fc..d7d09e96 100644 --- a/pom.xml +++ b/pom.xml @@ -138,7 +138,7 @@ org.junit.jupiter junit-jupiter - 5.10.3 + 5.11.0 test From b92dee6d7a26c01f5be9d7e5272745e5a9268aae Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 20:00:17 +0000 Subject: [PATCH 295/301] Bump surefire.version from 3.3.1 to 3.4.0 Bumps `surefire.version` from 3.3.1 to 3.4.0. Updates `org.apache.maven.plugins:maven-surefire-plugin` from 3.3.1 to 3.4.0 - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.3.1...surefire-3.4.0) Updates `org.apache.maven.plugins:maven-failsafe-plugin` from 3.3.1 to 3.4.0 - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.3.1...surefire-3.4.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.apache.maven.plugins:maven-failsafe-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a92809fc..e72fe841 100644 --- a/pom.xml +++ b/pom.xml @@ -83,7 +83,7 @@ 5.14.0 2.23.1 2.29.2 - 3.3.1 + 3.4.0 From 216f9a079279c171cd05f86097695724adf90cf6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 20:00:19 +0000 Subject: [PATCH 296/301] Bump com.kohlschutter:compiler-annotations from 1.7.3 to 1.7.4 Bumps com.kohlschutter:compiler-annotations from 1.7.3 to 1.7.4. --- updated-dependencies: - dependency-name: com.kohlschutter:compiler-annotations dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a92809fc..697c7007 100644 --- a/pom.xml +++ b/pom.xml @@ -101,7 +101,7 @@ com.kohlschutter compiler-annotations - 1.7.3 + 1.7.4 provided true From 864df9821250281e9857efece3a807f3604bc28d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 20:00:23 +0000 Subject: [PATCH 297/301] Bump org.apache.maven.plugins:maven-site-plugin from 3.12.1 to 3.20.0 Bumps [org.apache.maven.plugins:maven-site-plugin](https://github.com/apache/maven-site-plugin) from 3.12.1 to 3.20.0. - [Commits](https://github.com/apache/maven-site-plugin/compare/maven-site-plugin-3.12.1...maven-site-plugin-3.20.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-site-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a92809fc..9f1a1673 100644 --- a/pom.xml +++ b/pom.xml @@ -583,7 +583,7 @@ org.apache.maven.plugins maven-site-plugin - 3.12.1 + 3.20.0 org.apache.maven.plugins From 9667ec324e6f3dc45bb9e1d303ffa12c666cfb8c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Aug 2024 19:44:03 +0000 Subject: [PATCH 298/301] Bump github/codeql-action from 3.26.3 to 3.26.5 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.26.3 to 3.26.5. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/883d8588e56d1753a8a58c1c86e88976f0c23449...2c779ab0d087cd7fe7b826087247c2c81f27bfa6) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql-analysis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 4d3e2fe4..a70d2437 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -42,7 +42,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@883d8588e56d1753a8a58c1c86e88976f0c23449 # v3.26.3 + uses: github/codeql-action/init@2c779ab0d087cd7fe7b826087247c2c81f27bfa6 # v3.26.5 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -56,7 +56,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@883d8588e56d1753a8a58c1c86e88976f0c23449 # v3.26.3 + uses: github/codeql-action/autobuild@2c779ab0d087cd7fe7b826087247c2c81f27bfa6 # v3.26.5 # ℹī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -69,4 +69,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@883d8588e56d1753a8a58c1c86e88976f0c23449 # v3.26.3 + uses: github/codeql-action/analyze@2c779ab0d087cd7fe7b826087247c2c81f27bfa6 # v3.26.5 From 9cffc2749c790085fdff6322a4aaa1fa7a8e1550 Mon Sep 17 00:00:00 2001 From: ShadelessFox Date: Thu, 29 Aug 2024 18:41:57 +0200 Subject: [PATCH 299/301] Compatibility with com.jcraft.jsch --- pom.xml | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 4c70f58e..5e684931 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ 4.0.0 - com.github.mwiede + com.jcraft jsch jar 0.2.20-SNAPSHOT @@ -96,7 +96,6 @@ com.kohlschutter.junixsocket junixsocket-common ${junixsocket.version} - true com.kohlschutter @@ -174,7 +173,6 @@ com.kohlschutter.junixsocket junixsocket-native-common ${junixsocket.version} - test org.apache.logging.log4j @@ -420,6 +418,7 @@ Private-Package Bundle-SymbolicName: ${project.groupId}.${project.artifactId} Export-Package: com.jcraft.jsch;-noimport:=true + Require-Bundle: com.sun.jna,com.sun.jna.platform Import-Package: \ com.sun.jna*;version="${range;[=0,+)}";resolution:=optional,\ org.apache.logging.log4j*;version="${range;[=0,4)}";resolution:=optional,\ @@ -666,6 +665,36 @@ + + org.apache.maven.plugins + maven-shade-plugin + 3.4.1 + + + package + + shade + + + + + com.kohlschutter.junixsocket:junixsocket-common + com.kohlschutter.junixsocket:junixsocket-native-common + + + + + com.kohlschutter.junixsocket:* + + lib/**/*.dll + lib/**/*.nodeps.so + + + + + + + From 7049461a996061335227c6c5ad5f77097aaf49c4 Mon Sep 17 00:00:00 2001 From: ShadelessFox Date: Thu, 29 Aug 2024 18:50:47 +0200 Subject: [PATCH 300/301] Exclude checkstyle/formatter plugins --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 5e684931..ea94c96d 100644 --- a/pom.xml +++ b/pom.xml @@ -589,7 +589,7 @@ maven-dependency-plugin 3.7.1 - + org.jacoco jacoco-maven-plugin From 697e417e98cd8ea5b60cc5b82eb9ab48d42df92d Mon Sep 17 00:00:00 2001 From: ShadelessFox Date: Thu, 29 Aug 2024 18:58:53 +0200 Subject: [PATCH 301/301] Exclude checkstyle/formatter plugins --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index ea94c96d..7f075059 100644 --- a/pom.xml +++ b/pom.xml @@ -789,7 +789,7 @@ - + forbiddenapis