Skip to content

Commit c3236a7

Browse files
committed
Merge branch 'master' into pr/uttamgupta/976
2 parents bfa82b4 + 7f8f43c commit c3236a7

File tree

12 files changed

+227
-100
lines changed

12 files changed

+227
-100
lines changed

build.gradle

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
id 'pl.allegro.tech.build.axion-release' version '1.15.3'
1010
id "com.github.hierynomus.license" version "0.16.1"
1111
id "com.bmuschko.docker-remote-api" version "9.2.1"
12-
id 'ru.vyarus.github-info' version '1.5.0'
12+
id 'ru.vyarus.github-info' version '2.0.0'
1313
id "io.github.gradle-nexus.publish-plugin" version "1.3.0"
1414
}
1515

@@ -22,6 +22,11 @@ repositories {
2222
mavenCentral()
2323
}
2424

25+
github {
26+
user 'hierynomus'
27+
license 'Apache'
28+
}
29+
2530
scmVersion {
2631
tag {
2732
prefix = 'v'
@@ -41,11 +46,11 @@ compileJava {
4146

4247
configurations.implementation.transitive = false
4348

44-
def bouncycastleVersion = "1.78.1"
45-
def sshdVersion = "2.12.1"
49+
def bouncycastleVersion = "1.80"
50+
def sshdVersion = "2.14.0"
4651

4752
dependencies {
48-
implementation "org.slf4j:slf4j-api:2.0.13"
53+
implementation "org.slf4j:slf4j-api:2.0.16"
4954
implementation "org.bouncycastle:bcprov-jdk18on:$bouncycastleVersion"
5055
implementation "org.bouncycastle:bcpkix-jdk18on:$bouncycastleVersion"
5156
implementation "com.hierynomus:asn-one:0.6.0"
@@ -85,15 +90,15 @@ testing {
8590
configureEach {
8691
useJUnitJupiter()
8792
dependencies {
88-
implementation "org.slf4j:slf4j-api:2.0.13"
93+
implementation "org.slf4j:slf4j-api:2.0.16"
8994
implementation "org.spockframework:spock-core:2.4-M5-groovy-4.0"
9095
implementation "org.mockito:mockito-core:5.15.2"
9196
implementation "org.assertj:assertj-core:3.24.2"
9297
implementation "ru.vyarus:spock-junit5:1.2.0"
9398
implementation "org.apache.sshd:sshd-core:$sshdVersion"
9499
implementation "org.apache.sshd:sshd-sftp:$sshdVersion"
95100
implementation "org.apache.sshd:sshd-scp:$sshdVersion"
96-
implementation "ch.qos.logback:logback-classic:1.3.14"
101+
implementation "ch.qos.logback:logback-classic:1.3.15"
97102
implementation 'org.glassfish.grizzly:grizzly-http-server:3.0.1'
98103
}
99104

@@ -129,8 +134,8 @@ testing {
129134
integrationTest(JvmTestSuite) {
130135
dependencies {
131136
implementation project()
132-
implementation 'org.testcontainers:testcontainers:1.19.8'
133-
implementation 'org.testcontainers:junit-jupiter:1.19.8'
137+
implementation 'org.testcontainers:testcontainers:1.20.4'
138+
implementation 'org.testcontainers:junit-jupiter:1.20.4'
134139
}
135140

136141
sources {
@@ -202,11 +207,6 @@ sourcesJar {
202207
}
203208
}
204209

205-
github {
206-
user 'hierynomus'
207-
license 'Apache'
208-
}
209-
210210
publishing {
211211
publications {
212212
maven(MavenPublication) {

gradle/wrapper/gradle-wrapper.jar

-15.9 KB
Binary file not shown.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
46
zipStoreBase=GRADLE_USER_HOME
57
zipStorePath=wrapper/dists

gradlew

Lines changed: 30 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gradlew.bat

Lines changed: 21 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
*/
1616
package com.hierynomus.sshj.common;
1717

18-
import org.bouncycastle.openssl.EncryptionException;
19-
2018
import java.io.IOException;
2119

2220
/**
@@ -32,7 +30,7 @@ public KeyDecryptionFailedException() {
3230
super(MESSAGE);
3331
}
3432

35-
public KeyDecryptionFailedException(EncryptionException cause) {
33+
public KeyDecryptionFailedException(IOException cause) {
3634
super(MESSAGE, cause);
3735
}
3836

src/main/java/com/hierynomus/sshj/userauth/keyprovider/OpenSSHKeyV1KeyFile.java

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@
3131
import net.schmizz.sshj.userauth.keyprovider.FileKeyProvider;
3232
import net.schmizz.sshj.userauth.keyprovider.KeyFormat;
3333
import net.schmizz.sshj.userauth.password.PasswordFinder;
34-
import org.bouncycastle.asn1.nist.NISTNamedCurves;
35-
import org.bouncycastle.asn1.x9.X9ECParameters;
36-
import org.bouncycastle.jce.spec.ECNamedCurveSpec;
37-
import org.bouncycastle.openssl.EncryptionException;
3834
import org.slf4j.Logger;
3935
import org.slf4j.LoggerFactory;
4036

@@ -47,15 +43,14 @@
4743
import java.security.KeyPair;
4844
import java.security.PrivateKey;
4945
import java.security.PublicKey;
50-
import java.security.spec.ECPrivateKeySpec;
5146
import java.security.spec.RSAPrivateCrtKeySpec;
5247
import java.util.Arrays;
5348
import java.util.HashMap;
5449
import java.util.Map;
5550

5651
/**
5752
* Reads a key file in the new OpenSSH format.
58-
* The format is described in the following document: https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key
53+
* The format is described in the following document: <a href="https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key">Key Protocol</a>
5954
*/
6055
public class OpenSSHKeyV1KeyFile extends BaseFileKeyProvider {
6156
private static final String BEGIN = "-----BEGIN ";
@@ -244,7 +239,7 @@ private PlainBuffer decryptPrivateKey(final byte[] privateKey, final int private
244239
cipher.update(privateKey, 0, privateKeyLength);
245240
} catch (final SSHRuntimeException e) {
246241
final String message = String.format("OpenSSH Private Key decryption failed with cipher [%s]", cipherName);
247-
throw new KeyDecryptionFailedException(new EncryptionException(message, e));
242+
throw new KeyDecryptionFailedException(new IOException(message, e));
248243
}
249244
final PlainBuffer decryptedPrivateKey = new PlainBuffer(privateKeyLength);
250245
decryptedPrivateKey.putRawBytes(privateKey, 0, privateKeyLength);
@@ -343,7 +338,7 @@ private KeyPair readUnencrypted(final PlainBuffer keyBuffer, final PublicKey pub
343338
int checkInt1 = keyBuffer.readUInt32AsInt(); // uint32 checkint1
344339
int checkInt2 = keyBuffer.readUInt32AsInt(); // uint32 checkint2
345340
if (checkInt1 != checkInt2) {
346-
throw new KeyDecryptionFailedException(new EncryptionException("OpenSSH Private Key integer comparison failed"));
341+
throw new KeyDecryptionFailedException(new IOException("OpenSSH Private Key integer comparison failed"));
347342
}
348343
// The private key section contains both the public key and the private key
349344
String keyType = keyBuffer.readString(); // string keytype
@@ -365,13 +360,13 @@ private KeyPair readUnencrypted(final PlainBuffer keyBuffer, final PublicKey pub
365360
kp = new KeyPair(publicKey, privateKey);
366361
break;
367362
case ECDSA256:
368-
kp = new KeyPair(publicKey, createECDSAPrivateKey(kt, keyBuffer, "P-256"));
363+
kp = new KeyPair(publicKey, createECDSAPrivateKey(kt, keyBuffer, ECDSACurve.SECP256R1));
369364
break;
370365
case ECDSA384:
371-
kp = new KeyPair(publicKey, createECDSAPrivateKey(kt, keyBuffer, "P-384"));
366+
kp = new KeyPair(publicKey, createECDSAPrivateKey(kt, keyBuffer, ECDSACurve.SECP384R1));
372367
break;
373368
case ECDSA521:
374-
kp = new KeyPair(publicKey, createECDSAPrivateKey(kt, keyBuffer, "P-521"));
369+
kp = new KeyPair(publicKey, createECDSAPrivateKey(kt, keyBuffer, ECDSACurve.SECP521R1));
375370
break;
376371

377372
default:
@@ -388,13 +383,10 @@ private KeyPair readUnencrypted(final PlainBuffer keyBuffer, final PublicKey pub
388383
return kp;
389384
}
390385

391-
private PrivateKey createECDSAPrivateKey(KeyType kt, PlainBuffer buffer, String name) throws GeneralSecurityException, Buffer.BufferException {
386+
private PrivateKey createECDSAPrivateKey(KeyType kt, PlainBuffer buffer, ECDSACurve ecdsaCurve) throws GeneralSecurityException, Buffer.BufferException {
392387
kt.readPubKeyFromBuffer(buffer); // Public key
393-
BigInteger s = new BigInteger(1, buffer.readBytes());
394-
X9ECParameters ecParams = NISTNamedCurves.getByName(name);
395-
ECNamedCurveSpec ecCurveSpec = new ECNamedCurveSpec(name, ecParams.getCurve(), ecParams.getG(), ecParams.getN());
396-
ECPrivateKeySpec pks = new ECPrivateKeySpec(s, ecCurveSpec);
397-
return SecurityUtils.getKeyFactory(KeyAlgorithm.ECDSA).generatePrivate(pks);
388+
final BigInteger s = new BigInteger(1, buffer.readBytes());
389+
return ECDSAKeyFactory.getPrivateKey(s, ecdsaCurve);
398390
}
399391

400392
/**

0 commit comments

Comments
 (0)