Skip to content

Commit 8e9e644

Browse files
committed
Merge branch 'master' into pr/uttamgupta/976
Signed-off-by: Jeroen van Erp <[email protected]>
2 parents c3236a7 + 857d56a commit 8e9e644

File tree

72 files changed

+1340
-821
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1340
-821
lines changed

build.gradle

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,13 @@ compileJava {
4747
configurations.implementation.transitive = false
4848

4949
def bouncycastleVersion = "1.80"
50-
def sshdVersion = "2.14.0"
50+
def sshdVersion = "2.15.0"
5151

5252
dependencies {
53-
implementation "org.slf4j:slf4j-api:2.0.16"
53+
implementation "org.slf4j:slf4j-api:2.0.17"
5454
implementation "org.bouncycastle:bcprov-jdk18on:$bouncycastleVersion"
5555
implementation "org.bouncycastle:bcpkix-jdk18on:$bouncycastleVersion"
5656
implementation "com.hierynomus:asn-one:0.6.0"
57-
implementation "net.i2p.crypto:eddsa:0.3.0"
5857
}
5958

6059
license {
@@ -90,16 +89,15 @@ testing {
9089
configureEach {
9190
useJUnitJupiter()
9291
dependencies {
93-
implementation "org.slf4j:slf4j-api:2.0.16"
94-
implementation "org.spockframework:spock-core:2.4-M5-groovy-4.0"
95-
implementation "org.mockito:mockito-core:5.15.2"
96-
implementation "org.assertj:assertj-core:3.24.2"
92+
implementation "org.slf4j:slf4j-api:2.0.17"
93+
implementation 'org.spockframework:spock-core:2.3-groovy-3.0'
94+
implementation "org.mockito:mockito-core:5.16.1"
95+
implementation "org.assertj:assertj-core:3.27.3"
9796
implementation "ru.vyarus:spock-junit5:1.2.0"
9897
implementation "org.apache.sshd:sshd-core:$sshdVersion"
9998
implementation "org.apache.sshd:sshd-sftp:$sshdVersion"
10099
implementation "org.apache.sshd:sshd-scp:$sshdVersion"
101-
implementation "ch.qos.logback:logback-classic:1.3.15"
102-
implementation 'org.glassfish.grizzly:grizzly-http-server:3.0.1'
100+
implementation "ch.qos.logback:logback-classic:1.5.18"
103101
}
104102

105103
targets {
@@ -134,8 +132,8 @@ testing {
134132
integrationTest(JvmTestSuite) {
135133
dependencies {
136134
implementation project()
137-
implementation 'org.testcontainers:testcontainers:1.20.4'
138-
implementation 'org.testcontainers:junit-jupiter:1.20.4'
135+
implementation platform('org.testcontainers:testcontainers-bom:1.20.6')
136+
implementation 'org.testcontainers:junit-jupiter'
139137
}
140138

141139
sources {
@@ -182,8 +180,6 @@ jar {
182180
instruction "Import-Package", "!net.schmizz.*"
183181
instruction "Import-Package", "!com.hierynomus.sshj.*"
184182
instruction "Import-Package", "javax.crypto*"
185-
instruction "Import-Package", "!net.i2p.crypto.eddsa.math"
186-
instruction "Import-Package", "net.i2p*"
187183
instruction "Import-Package", "com.jcraft.jzlib*;version=\"[1.1,2)\";resolution:=optional"
188184
instruction "Import-Package", "org.slf4j*;version=\"[1.7,5)\""
189185
instruction "Import-Package", "org.bouncycastle*;resolution:=optional"

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

src/itest/java/com/hierynomus/sshj/sftp/FileWriteTest.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import org.junit.jupiter.api.Test;
2222
import org.testcontainers.junit.jupiter.Container;
2323
import org.testcontainers.junit.jupiter.Testcontainers;
24-
import org.testcontainers.shaded.org.bouncycastle.util.Arrays;
2524

2625
import com.hierynomus.sshj.SshdContainer;
2726

@@ -31,11 +30,12 @@
3130
import net.schmizz.sshj.sftp.SFTPClient;
3231

3332
import static org.assertj.core.api.Assertions.assertThat;
33+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
3434

3535
@Testcontainers
3636
public class FileWriteTest {
3737
@Container
38-
private static SshdContainer sshd = new SshdContainer();
38+
private static final SshdContainer sshd = new SshdContainer();
3939

4040
@Test
4141
public void shouldAppendToFile_GH390() throws Throwable {
@@ -63,8 +63,14 @@ public void shouldAppendToFile_GH390() throws Throwable {
6363
try (RemoteFile read = sftp.open(file, EnumSet.of(OpenMode.READ))) {
6464
byte[] readBytes = new byte[initialText.length + appendText.length];
6565
read.read(0, readBytes, 0, readBytes.length);
66-
assertThat(Arrays.copyOfRange(readBytes, 0, initialText.length)).isEqualTo(initialText);
67-
assertThat(Arrays.copyOfRange(readBytes, initialText.length, initialText.length + appendText.length)).isEqualTo(appendText);
66+
67+
final byte[] expectedInitialText = new byte[initialText.length];
68+
System.arraycopy(readBytes, 0, expectedInitialText, 0, expectedInitialText.length);
69+
assertArrayEquals(expectedInitialText, initialText);
70+
71+
final byte[] expectedAppendText = new byte[appendText.length];
72+
System.arraycopy(readBytes, initialText.length, expectedAppendText, 0, expectedAppendText.length);
73+
assertArrayEquals(expectedAppendText, appendText);
6874
}
6975
}
7076

src/itest/java/com/hierynomus/sshj/transport/kex/StrictKeyExchangeTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public boolean isEnabled() {
145145

146146
@Override
147147
protected void doKeepAlive() throws TransportException {
148-
conn.getTransport().write(new SSHPacket(Message.IGNORE));
148+
conn.getTransport().write(new SSHPacket(Message.IGNORE).putString(""));
149149
}
150150

151151
}

src/main/java/com/hierynomus/sshj/common/KeyDecryptionFailedException.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ public class KeyDecryptionFailedException extends IOException {
2626

2727
public static final String MESSAGE = "Decryption of the key failed. A supplied passphrase may be incorrect.";
2828

29-
public KeyDecryptionFailedException() {
30-
super(MESSAGE);
29+
public KeyDecryptionFailedException(final String message) {
30+
super(message);
31+
}
32+
33+
public KeyDecryptionFailedException(final String message, final Throwable cause) {
34+
super(message, cause);
3135
}
3236

3337
public KeyDecryptionFailedException(IOException cause) {

src/main/java/com/hierynomus/sshj/signature/Ed25519PublicKey.java

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/main/java/com/hierynomus/sshj/signature/SignatureEdDSA.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
*/
1616
package com.hierynomus.sshj.signature;
1717

18-
import net.i2p.crypto.eddsa.EdDSAEngine;
1918
import net.schmizz.sshj.common.KeyType;
2019
import net.schmizz.sshj.common.SSHRuntimeException;
20+
import net.schmizz.sshj.common.SecurityUtils;
2121
import net.schmizz.sshj.signature.AbstractSignature;
2222
import net.schmizz.sshj.signature.Signature;
2323

24-
import java.security.MessageDigest;
2524
import java.security.NoSuchAlgorithmException;
25+
import java.security.NoSuchProviderException;
2626
import java.security.SignatureException;
2727

2828
public class SignatureEdDSA extends AbstractSignature {
@@ -43,11 +43,11 @@ public Signature create() {
4343
super(getEngine(), KeyType.ED25519.toString());
4444
}
4545

46-
private static EdDSAEngine getEngine() {
46+
private static java.security.Signature getEngine() {
4747
try {
48-
return new EdDSAEngine(MessageDigest.getInstance("SHA-512"));
49-
} catch (NoSuchAlgorithmException e) {
50-
throw new SSHRuntimeException(e);
48+
return SecurityUtils.getSignature("Ed25519");
49+
} catch (NoSuchAlgorithmException | NoSuchProviderException e) {
50+
throw new SSHRuntimeException("Ed25519 Signatures not supported", e);
5151
}
5252
}
5353

src/main/java/com/hierynomus/sshj/transport/IdentificationStringParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class IdentificationStringParser {
2828
private final Logger log;
2929
private final Buffer.PlainBuffer buffer;
3030

31-
private byte[] EXPECTED_START_BYTES = new byte[] {'S', 'S', 'H', '-'};
31+
private final byte[] EXPECTED_START_BYTES = new byte[] {'S', 'S', 'H', '-'};
3232

3333
public IdentificationStringParser(Buffer.PlainBuffer buffer) {
3434
this(buffer, LoggerFactory.DEFAULT);

src/main/java/com/hierynomus/sshj/transport/cipher/BlockCiphers.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@ public static Factory TripleDESCBC() {
121121
public static class Factory
122122
implements net.schmizz.sshj.common.Factory.Named<Cipher> {
123123

124-
private int keysize;
125-
private String cipher;
126-
private String mode;
127-
private String name;
128-
private int ivsize;
124+
private final int keysize;
125+
private final String cipher;
126+
private final String mode;
127+
private final String name;
128+
private final int ivsize;
129129

130130
/**
131131
* @param ivsize

src/main/java/com/hierynomus/sshj/transport/cipher/GcmCiphers.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ public static Factory AES256GCM() {
3333
public static class Factory
3434
implements net.schmizz.sshj.common.Factory.Named<Cipher> {
3535

36-
private int keysize;
37-
private int authSize;
38-
private String cipher;
39-
private String mode;
40-
private String name;
41-
private int ivsize;
36+
private final int keysize;
37+
private final int authSize;
38+
private final String cipher;
39+
private final String mode;
40+
private final String name;
41+
private final int ivsize;
4242

4343
/**
4444
* @param ivsize

0 commit comments

Comments
 (0)