Skip to content

Commit

Permalink
[SSH] Increase bit-size of generated RSA and DSA keys
Browse files Browse the repository at this point in the history
This implementation allows to generate RSA keys with 4096 bits and DSA keys with 3072 bits. (DSA does not support 4096 bits or higher within the key algorithm)
Originally generates 1024 bits for RSA and DSA keys.

Fixes #1464
  • Loading branch information
axmanalad committed Nov 3, 2024
1 parent a982bd3 commit 28c0896
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage
implements IWorkbenchPreferencePage{

private static final String SSH2_PREFERENCE_PAGE_CONTEXT="org.eclipse.jsch.ui.ssh2_preference_page_context"; //$NON-NLS-1$
private static final int RSA_KEY_SIZE = 4096;
private static final int DSA_KEY_SIZE = 3072;

private Label ssh2HomeLabel;
private Label privateKeyLabel;
Expand Down Expand Up @@ -494,10 +496,11 @@ else if(e.widget==keyGenerateRSA){

final KeyPair[] _kpair=new KeyPair[1];
final int __type=type;
int keySize = type == KeyPair.RSA ? RSA_KEY_SIZE : DSA_KEY_SIZE;
final JSchException[] _e=new JSchException[1];
BusyIndicator.showWhile(getShell().getDisplay(), () -> {
try {
_kpair[0] = KeyPair.genKeyPair(getJSch(), __type);
_kpair[0] = KeyPair.genKeyPair(getJSch(), __type, keySize);
} catch (JSchException e1) {
_e[0] = e1;
}
Expand All @@ -508,7 +511,7 @@ else if(e.widget==keyGenerateRSA){
kpair=_kpair[0];

ByteArrayOutputStream out=new ByteArrayOutputStream();
kpairComment=_type+"-1024"; //$NON-NLS-1$
kpairComment = _type + "-" + keySize; //$NON-NLS-1$
kpair.writePublicKey(out, kpairComment);
out.close();
publicKeyText.setText(out.toString());
Expand Down

0 comments on commit 28c0896

Please sign in to comment.