Skip to content

Commit c2da3a2

Browse files
committed
#771 Avoid NoClassDefFoundError: net/i2p/crypto/eddsa/EdDSAPublicKey using PuttyKeyUtils
1 parent b7843c3 commit c2da3a2

5 files changed

Lines changed: 12 additions & 23 deletions

File tree

sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/EdDSASecurityProviderUtils.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,6 @@ private EdDSASecurityProviderUtils() {
5555
throw new UnsupportedOperationException("No instance");
5656
}
5757

58-
public static Class<? extends PublicKey> getEDDSAPublicKeyType() {
59-
return EdDSAPublicKey.class;
60-
}
61-
62-
public static Class<? extends PrivateKey> getEDDSAPrivateKeyType() {
63-
return EdDSAPrivateKey.class;
64-
}
65-
6658
public static boolean isEDDSAKey(Key key) {
6759
return getEDDSAKeySize(key) == KEY_SIZE;
6860
}

sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/NetI2pCryptoEdDSASupport.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ public int getEDDSAKeySize(Key key) {
6464
}
6565

6666
@Override
67-
public Class<? extends PublicKey> getEDDSAPublicKeyType() {
68-
return EdDSASecurityProviderUtils.getEDDSAPublicKeyType();
67+
public Class<EdDSAPublicKey> getEDDSAPublicKeyType() {
68+
return EdDSAPublicKey.class;
6969
}
7070

7171
@Override
72-
public Class<? extends PrivateKey> getEDDSAPrivateKeyType() {
73-
return EdDSASecurityProviderUtils.getEDDSAPrivateKeyType();
72+
public Class<EdDSAPrivateKey> getEDDSAPrivateKeyType() {
73+
return EdDSAPrivateKey.class;
7474
}
7575

7676
@Override

sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/bouncycastle/BouncyCastleEdDSASupport.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ public int getEDDSAKeySize(Key key) {
7575
}
7676

7777
@Override
78-
public Class<? extends PublicKey> getEDDSAPublicKeyType() {
78+
public Class<EdDSAPublicKey> getEDDSAPublicKeyType() {
7979
return EdDSAPublicKey.class;
8080
}
8181

8282
@Override
83-
public Class<? extends PrivateKey> getEDDSAPrivateKeyType() {
83+
public Class<EdDSAPrivateKey> getEDDSAPrivateKeyType() {
8484
return EdDSAPrivateKey.class;
8585
}
8686

sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/generic/EdDSASupport.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ static PrivateKey decodeEdDSAPrivateKey(byte[] keyData) throws IOException, Gene
108108
/**
109109
* @return the public key class type associated with the security provider.
110110
*/
111-
Class<? extends PublicKey> getEDDSAPublicKeyType();
111+
Class<PUB> getEDDSAPublicKeyType();
112112

113113
/**
114114
* @return the private key class type associated with the security provider.
115115
*/
116-
Class<? extends PrivateKey> getEDDSAPrivateKeyType();
116+
Class<PRV> getEDDSAPrivateKeyType();
117117

118118
/**
119119
* @param k1 the first key

sshd-putty/src/main/java/org/apache/sshd/putty/EdDSAPuttyKeyDecoder.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,20 @@
2929
import java.util.Collections;
3030
import java.util.Map;
3131

32-
import net.i2p.crypto.eddsa.EdDSAPrivateKey;
33-
import net.i2p.crypto.eddsa.EdDSAPublicKey;
3432
import org.apache.sshd.common.NamedResource;
3533
import org.apache.sshd.common.keyprovider.KeyPairProvider;
3634
import org.apache.sshd.common.util.security.SecurityUtils;
37-
import org.apache.sshd.common.util.security.eddsa.EdDSASecurityProviderUtils;
3835

3936
/**
4037
* TODO Add javadoc
4138
*
4239
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
4340
*/
44-
public class EdDSAPuttyKeyDecoder extends AbstractPuttyKeyDecoder<EdDSAPublicKey, EdDSAPrivateKey> {
41+
public class EdDSAPuttyKeyDecoder<PUB extends PublicKey, PRIV extends PrivateKey> extends AbstractPuttyKeyDecoder<PUB, PRIV> {
4542
public static final EdDSAPuttyKeyDecoder INSTANCE = new EdDSAPuttyKeyDecoder();
4643

4744
public EdDSAPuttyKeyDecoder() {
48-
super(EdDSAPublicKey.class, EdDSAPrivateKey.class, Collections.singletonList(KeyPairProvider.SSH_ED25519));
45+
super((Class<PUB>) SecurityUtils.getEdDSASupport().get().getEDDSAPublicKeyType(), (Class<PRIV>) SecurityUtils.getEdDSASupport().get().getEDDSAPrivateKeyType(), Collections.singletonList(KeyPairProvider.SSH_ED25519));
4946
}
5047

5148
@Override
@@ -63,9 +60,9 @@ public Collection<KeyPair> loadKeyPairs(
6360
}
6461

6562
byte[] seed = pubReader.read(Short.MAX_VALUE); // reasonable max. allowed size
66-
PublicKey pubKey = EdDSASecurityProviderUtils.generateEDDSAPublicKey(seed);
63+
PublicKey pubKey = SecurityUtils.getEdDSASupport().get().generateEDDSAPublicKey(seed);
6764
seed = prvReader.read(Short.MAX_VALUE); // reasonable max. allowed size
68-
PrivateKey prvKey = EdDSASecurityProviderUtils.generateEDDSAPrivateKey(seed);
65+
PrivateKey prvKey = SecurityUtils.getEdDSASupport().get().generateEDDSAPrivateKey(seed);
6966
return Collections.singletonList(new KeyPair(pubKey, prvKey));
7067
}
7168
}

0 commit comments

Comments
 (0)