Skip to content

Commit 4712d12

Browse files
axmanaladHannesWell
authored andcommitted
[SSH] Increase bit-size of generated RSA and DSA keys
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
1 parent a982bd3 commit 4712d12

File tree

1 file changed

+5
-2
lines changed
  • team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference

1 file changed

+5
-2
lines changed

team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PreferencePage.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage
8989
implements IWorkbenchPreferencePage{
9090

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

9395
private Label ssh2HomeLabel;
9496
private Label privateKeyLabel;
@@ -494,10 +496,11 @@ else if(e.widget==keyGenerateRSA){
494496

495497
final KeyPair[] _kpair=new KeyPair[1];
496498
final int __type=type;
499+
int keySize = type == KeyPair.RSA ? RSA_KEY_SIZE : DSA_KEY_SIZE;
497500
final JSchException[] _e=new JSchException[1];
498501
BusyIndicator.showWhile(getShell().getDisplay(), () -> {
499502
try {
500-
_kpair[0] = KeyPair.genKeyPair(getJSch(), __type);
503+
_kpair[0] = KeyPair.genKeyPair(getJSch(), __type, keySize);
501504
} catch (JSchException e1) {
502505
_e[0] = e1;
503506
}
@@ -508,7 +511,7 @@ else if(e.widget==keyGenerateRSA){
508511
kpair=_kpair[0];
509512

510513
ByteArrayOutputStream out=new ByteArrayOutputStream();
511-
kpairComment=_type+"-1024"; //$NON-NLS-1$
514+
kpairComment = _type + "-" + keySize; //$NON-NLS-1$
512515
kpair.writePublicKey(out, kpairComment);
513516
out.close();
514517
publicKeyText.setText(out.toString());

0 commit comments

Comments
 (0)