Skip to content

Commit

Permalink
mwiede#289 wrap NoClassDefFoundError's for invalid private keys.
Browse files Browse the repository at this point in the history
  • Loading branch information
norrisjeremy committed Mar 13, 2023
1 parent 3aeecba commit ede6b78
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
* [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.
* [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.
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/jcraft/jsch/KeyPair.java
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ public static KeyPair load(JSch jsch, byte[] prvkey, byte[] pubkey) throws JSchE
}

return kpair;
} catch (Exception e) {
} catch (Exception | NoClassDefFoundError e) {
Util.bzero(data);
if (e instanceof JSchException)
throw (JSchException) e;
Expand Down Expand Up @@ -1170,7 +1170,7 @@ static KeyPair loadOpenSSHKeyv1(JSch jsch, byte[] data) throws JSchException {
Class.forName(JSch.getConfig(cipherName)).asSubclass(Cipher.class);
kpair.cipher = c.getDeclaredConstructor().newInstance();
kpair.iv = new byte[kpair.cipher.getIVSize()];
} catch (Exception e) {
} catch (Exception | NoClassDefFoundError e) {
throw new JSchException("cipher " + cipherName + " is not available", e);
}
} else {
Expand All @@ -1186,7 +1186,7 @@ static KeyPair loadOpenSSHKeyv1(JSch jsch, byte[] data) throws JSchException {
BCrypt bcrypt = c.getDeclaredConstructor().newInstance();
bcrypt.init(salt, rounds);
kpair.kdf = bcrypt;
} catch (Exception e) {
} catch (Exception | NoClassDefFoundError e) {
throw new JSchException("kdf " + kdfName + " is not available", e);
}
}
Expand Down Expand Up @@ -1285,7 +1285,7 @@ static KeyPair loadPPK(JSch jsch, byte[] buf) throws JSchException {
Class.forName(JSch.getConfig("aes256-cbc")).asSubclass(Cipher.class);
kpair.cipher = c.getDeclaredConstructor().newInstance();
kpair.iv = new byte[kpair.cipher.getIVSize()];
} catch (Exception e) {
} catch (Exception | NoClassDefFoundError e) {
throw new JSchException("The cipher 'aes256-cbc' is required, but it is not available.",
e);
}
Expand All @@ -1299,7 +1299,7 @@ static KeyPair loadPPK(JSch jsch, byte[] buf) throws JSchException {
HASH sha1 = c.getDeclaredConstructor().newInstance();
sha1.init();
kpair.sha1 = sha1;
} catch (Exception e) {
} catch (Exception | NoClassDefFoundError e) {
throw new JSchException("'sha-1' is required, but it is not available.", e);
}
} else {
Expand Down Expand Up @@ -1344,7 +1344,7 @@ static KeyPair loadPPK(JSch jsch, byte[] buf) throws JSchException {
kpair.kdf = argon2;
} catch (NumberFormatException e) {
throw new JSchException("Invalid argon2 params.", e);
} catch (Exception e) {
} catch (Exception | NoClassDefFoundError e) {
throw new JSchException("'argon2' is required, but it is not available.", e);
}
}
Expand Down

0 comments on commit ede6b78

Please sign in to comment.