Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.2.7 changes #264

Merged
merged 48 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
a24c57e
Use slfj4-test instead of logback for unit & integration tests.
norrisjeremy Jan 5, 2023
4f96242
Fix exception logging in Log4j2Logger.
norrisjeremy Jan 7, 2023
c9f5a9f
Add unit tests for Log4j2Logger.
norrisjeremy Jan 7, 2023
50f8a6e
Tweak JulLogger & JulLoggerTest to better match other loggers & tests.
norrisjeremy Jan 7, 2023
ea3ec4c
Add unit tests for Log4j2Logger's getLevel method.
norrisjeremy Jan 7, 2023
c6110a1
Misc cleanup of logger tests.
norrisjeremy Jan 7, 2023
555b203
Misc cleanup of LoggerTest.
norrisjeremy Jan 7, 2023
a8a45cd
Remove unneeded logging.
norrisjeremy Jan 8, 2023
27442a8
Update dependencies.
norrisjeremy Jan 9, 2023
b90b045
#265 change buffer_margin computation to be dynamic based upon the MA…
norrisjeremy Jan 11, 2023
44f2385
#266 fix PuTTY key parsing to work with unix line endings.
norrisjeremy Jan 11, 2023
353fd69
Convert from Hashtable & Vector to HashMap & ArrayList.
norrisjeremy Jan 12, 2023
bb8b9e9
Add support for ECDSA & EdDSA type PuTTY keys.
norrisjeremy Jan 12, 2023
9416859
#71 add support for PuTTY version 3 format keys.
norrisjeremy Jan 13, 2023
37606c9
Update ChangeLog.
norrisjeremy Jan 13, 2023
0ea9520
Add coverage reports for integration tests.
norrisjeremy Jan 13, 2023
cac9f94
Archive jars.
norrisjeremy Jan 13, 2023
737e614
Unroll passphrase key derivation for PuTTY version 2 keys.
norrisjeremy Jan 13, 2023
99cacc7
Add logging when exceptions are swallowed.
norrisjeremy Jan 13, 2023
426e023
Test against char representation instead of int to improve readability.
norrisjeremy Jan 14, 2023
dec14d0
Eliminate KeyPairDeferred and instead change handling of OpenSSH V1 t…
norrisjeremy Jan 16, 2023
ccf5a92
Be more vigilant about clearing private key data.
norrisjeremy Jan 16, 2023
d8b4a4b
Update ChangeLog.
norrisjeremy Jan 16, 2023
d3eb280
Improve PKCS8 key handling and add support for PKCS5 2.1 encryption.
norrisjeremy Jan 18, 2023
d3bef4f
Add support for ECDSA type PKCS8 keys.
norrisjeremy Jan 18, 2023
4206975
Remove unneeded null checks.
norrisjeremy Jan 18, 2023
4c00ed0
Update ChangeLog.
norrisjeremy Jan 18, 2023
8d78003
Add support for SCrypt type KDF for PKCS8 keys.
norrisjeremy Jan 19, 2023
62d9ef7
Minor tweaks of PKCS8 handling.
norrisjeremy Jan 19, 2023
47da8ad
Update ChangeLog.
norrisjeremy Jan 19, 2023
b84998e
Make some internal methods static.
norrisjeremy Jan 19, 2023
ff55eb9
Mark Argon2 type and versions as final.
norrisjeremy Jan 19, 2023
3c270d3
Wrap NoClassDefFoundErrors when Bouncy Castle is unavailable.
norrisjeremy Jan 19, 2023
addf6aa
Add a common bzero routine.
norrisjeremy Jan 20, 2023
df2c4ec
Mark PBKDF interface and implementation as deprecated: PBKDF2 should …
norrisjeremy Jan 20, 2023
eba50dd
Add support for EdDSA type PKCS8 keys.
norrisjeremy Jan 21, 2023
0d26fde
Update ChangeLog.
norrisjeremy Jan 21, 2023
76f751e
Add a parent KDF type for all the various KDF implementations.
norrisjeremy Jan 21, 2023
170ca02
Update dependencies.
norrisjeremy Jan 21, 2023
4d065dc
Minor syntax cleanup to scala sources.
norrisjeremy Jan 21, 2023
011d3c0
Misc cleanup to ASN1 parsing.
norrisjeremy Jan 22, 2023
ddd254d
Fix warnings in scala sources.
norrisjeremy Jan 22, 2023
4dce1f9
Convert JZlib tests from Scala to Java.
norrisjeremy Jan 23, 2023
e1fc360
Attempt to authenticate using other signature algorithms supported by…
norrisjeremy Jan 24, 2023
75f3031
Update ChangeLog.
norrisjeremy Jan 24, 2023
a83b248
Use standard Base64 instead of commons-codec version.
norrisjeremy Jan 25, 2023
c6bf01d
Add an `enable_auth_none` config option.
norrisjeremy Jan 25, 2023
7d0e6e2
Update ChangeLog.
norrisjeremy Jan 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ jobs:
check-latest: true
- name: Build with Maven
run: mvn -B -DskipTests=true package --file pom.xml
- uses: actions/upload-artifact@v3
with:
name: java-${{ matrix.java }}-jars
path: |
**/target/*.jar
if: always()
- name: Set up test JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
Expand All @@ -49,4 +55,5 @@ jobs:
**/target/surefire-reports/
**/target/failsafe-reports/
**/target/site/jacoco/
**/target/site/jacoco-it/
if: always()
2 changes: 1 addition & 1 deletion .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.8.6/apache-maven-3.8.6-bin.zip
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
20 changes: 20 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
* [0.2.7](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.7)
* Fix exception logging in Log4j2Logger.
* [#265](https://github.com/mwiede/jsch/issues/265) change buffer_margin computation to be dynamic based upon the MAC to allow connections that advertise small maximum packet sizes.
* [#266](https://github.com/mwiede/jsch/issues/266) fix PuTTY key parsing to work with unix line endings.
* Add support for ECDSA & EdDSA type PuTTY keys.
* [#71](https://github.com/mwiede/jsch/issues/71) add support for PuTTY version 3 format keys.
* Encrypted PuTTY version 3 format keys requires [Bouncy Castle](https://www.bouncycastle.org/java.html) (bcprov-jdk18on).
* Eliminate KeyPairDeferred and instead change handling of OpenSSH V1 type keys to be more like other KeyPair types.
* Be more vigilant about clearing private key data.
* Improve PKCS8 key handling and add support for PKCS5 2.1 encryption.
* Add support for ECDSA type PKCS8 keys.
* Add support for SCrypt type KDF for PKCS8 keys.
* PKCS8 keys using SCrypt requires [Bouncy Castle](https://www.bouncycastle.org/java.html) (bcprov-jdk18on).
* Add support for EdDSA type PKCS8 keys.
* EdDSA type PKCS8 keys requires [Bouncy Castle](https://www.bouncycastle.org/java.html) (bcprov-jdk18on).
* Attempt to authenticate using other signature algorithms supported by the same public key.
* Allow this behavior to be disabled via `try_additional_pubkey_algorithms` config option.
* Some servers incorrectly respond with `SSH_MSG_USERAUTH_PK_OK` to an initial auth query that they don't actually support for RSA keys.
* Add a new config option `enable_pubkey_auth_query` to allow skipping auth queries and proceed directly to attempting full `SSH_MSG_USERAUTH_REQUEST`'s.
* Add a new config option `enable_auth_none` to control whether an initial auth request for the method `none` is sent to detect all supported auth methods available on the server.
* [0.2.6](https://github.com/mwiede/jsch/releases/tag/jsch-0.2.6)
* Include host alias instead of the real host in messages and exceptions by @ShadelessFox in https://github.com/mwiede/jsch/pull/257
* Fix missing keySize set when loading V1 RSA keys by @Alex-Vol-Amz in https://github.com/mwiede/jsch/pull/258
Expand Down
86 changes: 30 additions & 56 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<skipITs>true</skipITs>
<junixsocket.version>2.6.1</junixsocket.version>
<jna.version>5.12.1</jna.version>
<log4j.version>2.19.0</log4j.version>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -118,7 +119,7 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.19.0</version>
<version>${log4j.version}</version>
<optional>true</optional>
<exclusions>
<exclusion>
Expand Down Expand Up @@ -163,33 +164,28 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.3.4</version>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.1-jre</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.13.6</version>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.13</artifactId>
<version>3.2.13</version>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
<type>test-jar</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>co.helmethair</groupId>
<artifactId>scalatest-junit-runner</artifactId>
<version>0.2.0</version>
<groupId>com.github.valfirst</groupId>
<artifactId>slf4j-test</artifactId>
<version>2.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -282,7 +278,7 @@
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<compilerArgs>
<arg>-Xlint:all</arg>
<arg>-Xlint:all,-processing</arg>
<arg>-Werror</arg>
</compilerArgs>
</configuration>
Expand Down Expand Up @@ -373,40 +369,12 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>4.8.0</version>
<configuration>
<recompileMode>all</recompileMode>
<sendJavaToScalac>false</sendJavaToScalac>
<args>
<arg>-deprecation</arg>
<arg>-feature</arg>
<arg>-unchecked</arg>
<arg>-Xfatal-warnings</arg>
</args>
</configuration>
<executions>
<execution>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<trimStackTrace>false</trimStackTrace>
<systemProperties>
<property>
<name>java.util.logging.config.file</name>
<value>${project.basedir}/src/test/resources/logging.properties</value>
</property>
</systemProperties>
</configuration>
</plugin>
<plugin>
Expand All @@ -415,12 +383,6 @@
<version>2.22.2</version>
<configuration>
<trimStackTrace>false</trimStackTrace>
<systemProperties>
<property>
<name>java.util.logging.config.file</name>
<value>${project.basedir}/src/test/resources/logging.properties</value>
</property>
</systemProperties>
</configuration>
<executions>
<execution>
Expand Down Expand Up @@ -594,12 +556,24 @@
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-prepare-agent-integration</id>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>default-report-integration</id>
<goals>
<goal>report-integration</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
Expand Down Expand Up @@ -630,7 +604,7 @@
<path>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>2.15.0</version>
<version>2.17.0</version>
</path>
</annotationProcessorPaths>
</configuration>
Expand All @@ -639,4 +613,4 @@
</build>
</profile>
</profiles>
</project>
</project>
40 changes: 40 additions & 0 deletions src/main/java/com/jcraft/jsch/Argon2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
/*
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;

public interface Argon2 extends KDF{
public static final int ARGON2D = 0;
public static final int ARGON2I = 1;
public static final int ARGON2ID = 2;
public static final int V10 = 0x10;
public static final int V13 = 0x13;

void init(byte[] salt, int iteration, int type, byte[] additional, byte[] secret, int memory, int parallelism, int version) throws Exception;
}
34 changes: 34 additions & 0 deletions src/main/java/com/jcraft/jsch/BCrypt.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
/*
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;

public interface BCrypt extends KDF{
void init(byte[] salt, int iteration) throws Exception;
}
7 changes: 6 additions & 1 deletion src/main/java/com/jcraft/jsch/Buffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,13 @@ byte getCommand(){
return buffer[5];
}

// Hardcode this since we can't use dynamic Session value
private static final int buffer_margin = 32 + // maximum padding length
64 + // maximum mac length
32; // margin for deflater; deflater may inflate data

void checkFreeSize(int n){
int size = index+n+Session.buffer_margin;
int size = index+n+buffer_margin;
if(buffer.length<size){
int i = buffer.length*2;
if(i<size) i = size;
Expand Down
47 changes: 29 additions & 18 deletions src/main/java/com/jcraft/jsch/Channel.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,15 @@ private synchronized void init() throws IOException{
packet=new Packet(buffer);

byte[] _buf=buffer.buffer;
if(_buf.length-(14+0)-Session.buffer_margin<=0){
buffer=null;
packet=null;
throw new IOException("failed to initialize the channel.");
try{
if(_buf.length-(14+0)-getSession().getBufferMargin()<=0){
buffer=null;
packet=null;
throw new IOException("failed to initialize the channel.");
}
}
catch(JSchException e){
throw new IOException("failed to initialize the channel.", e);
}

}
Expand All @@ -265,21 +270,27 @@ public void write(byte[] buf, int s, int l) throws IOException{

byte[] _buf=buffer.buffer;
int _bufl=_buf.length;
while(l>0){
int _l=l;
if(l>_bufl-(14+dataLen)-Session.buffer_margin){
_l=_bufl-(14+dataLen)-Session.buffer_margin;
}

if(_l<=0){
flush();
continue;
try{
while(l>0){
int _l=l;
int buffer_margin=getSession().getBufferMargin();
if(l>_bufl-(14+dataLen)-buffer_margin){
_l=_bufl-(14+dataLen)-buffer_margin;
}

if(_l<=0){
flush();
continue;
}

System.arraycopy(buf, s, _buf, 14+dataLen, _l);
dataLen+=_l;
s+=_l;
l-=_l;
}

System.arraycopy(buf, s, _buf, 14+dataLen, _l);
dataLen+=_l;
s+=_l;
l-=_l;
}
catch(JSchException e){
throw new IOException(e.toString(), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected Packet genChannelOpenPacket() {

Buffer buf = new Buffer(50 +
socketPath.length() +
Session.buffer_margin);
session.getBufferMargin());
Packet packet = new Packet(buf);
packet.reset();
buf.putByte((byte) SSH_MSG_CHANNEL_OPEN);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void run(){
i=io.in.read(buf.buffer,
14,
buf.buffer.length-14
-Session.buffer_margin
-_session.getBufferMargin()
);
if(i<=0){
eof();
Expand Down Expand Up @@ -154,7 +154,7 @@ public void setOutputStream(OutputStream out){
protected Packet genChannelOpenPacket(){
Buffer buf = new Buffer(50 + // 6 + 4*8 + 12
host.length() + originator_IP_address.length() +
Session.buffer_margin);
session.getBufferMargin());
Packet packet = new Packet(buf);
// byte SSH_MSG_CHANNEL_OPEN(90)
// string channel type //
Expand Down
Loading