5353import org .eclipse .swt .custom .TableEditor ;
5454import org .eclipse .swt .events .FocusEvent ;
5555import org .eclipse .swt .events .FocusListener ;
56+ import org .eclipse .swt .events .KeyListener ;
5657import org .eclipse .swt .events .SelectionAdapter ;
5758import org .eclipse .swt .events .SelectionEvent ;
5859import org .eclipse .swt .graphics .Image ;
6667import org .eclipse .swt .widgets .FileDialog ;
6768import org .eclipse .swt .widgets .Label ;
6869import org .eclipse .swt .widgets .Shell ;
70+ import org .eclipse .swt .widgets .Spinner ;
6971import org .eclipse .swt .widgets .Table ;
7072import org .eclipse .swt .widgets .TableColumn ;
7173import org .eclipse .swt .widgets .TableItem ;
@@ -89,8 +91,13 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage
8991 implements IWorkbenchPreferencePage {
9092
9193 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 ;
94+ private static final int RSA_KEY_SIZE = 15360 ;
9395 private static final int DSA_KEY_SIZE = 3072 ;
96+ private static final int INITIAL_KEY_SIZE = 4096 ;
97+ private static final int MIN_KEY_SIZE = 2048 ;
98+ private static final int MAX_KEY_SIZE = RSA_KEY_SIZE ;
99+ private static final int MAX_KEY_SIZE_DIGIT_COUNT = 0 ;
100+ private static final int KEY_SIZE_INCREMENT = 1024 ;
94101
95102 private Label ssh2HomeLabel ;
96103 private Label privateKeyLabel ;
@@ -101,6 +108,7 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage
101108 private Button ssh2HomeBrowse ;
102109 Button keyGenerateDSA ;
103110 Button keyGenerateRSA ;
111+ private Spinner keySizeValue ;
104112 private Button keyLoad ;
105113 private Button keyExport ;
106114 Button saveKeyPair ;
@@ -305,6 +313,13 @@ private Control createKeyManagementPage(Composite parent){
305313 gd .horizontalSpan =1 ;
306314 keyLoad .setLayoutData (gd );
307315
316+ final Label keyGenerateSizeLabel = new Label (group , SWT .NONE );
317+ keyGenerateSizeLabel .setText (Messages .CVSSSH2PreferencePage_148 );
318+ keySizeValue = new Spinner (group , SWT .BORDER );
319+ keySizeValue .setValues (INITIAL_KEY_SIZE , MIN_KEY_SIZE , MAX_KEY_SIZE , MAX_KEY_SIZE_DIGIT_COUNT ,
320+ KEY_SIZE_INCREMENT , KEY_SIZE_INCREMENT );
321+ keySizeValue .addKeyListener (KeyListener .keyPressedAdapter (e -> e .doit = false ));
322+
308323 publicKeylabel =new Label (group , SWT .NONE );
309324 publicKeylabel .setText (Messages .CVSSSH2PreferencePage_39 );
310325 gd =new GridData ();
@@ -485,6 +500,9 @@ public void widgetSelected(SelectionEvent e){
485500 if (e .widget ==keyGenerateDSA ){
486501 type =KeyPair .DSA ;
487502 _type =IConstants .DSA ;
503+ if (keySizeValue .getSelection () > DSA_KEY_SIZE ) {
504+ keySizeValue .setSelection (DSA_KEY_SIZE );
505+ }
488506 }
489507 else if (e .widget ==keyGenerateRSA ){
490508 type =KeyPair .RSA ;
@@ -496,7 +514,7 @@ else if(e.widget==keyGenerateRSA){
496514
497515 final KeyPair [] _kpair =new KeyPair [1 ];
498516 final int __type =type ;
499- int keySize = type == KeyPair . RSA ? RSA_KEY_SIZE : DSA_KEY_SIZE ;
517+ int keySize = keySizeValue . getSelection () ;
500518 final JSchException [] _e =new JSchException [1 ];
501519 BusyIndicator .showWhile (getShell ().getDisplay (), () -> {
502520 try {
0 commit comments