53
53
import org .eclipse .swt .custom .TableEditor ;
54
54
import org .eclipse .swt .events .FocusEvent ;
55
55
import org .eclipse .swt .events .FocusListener ;
56
+ import org .eclipse .swt .events .KeyListener ;
56
57
import org .eclipse .swt .events .SelectionAdapter ;
57
58
import org .eclipse .swt .events .SelectionEvent ;
58
59
import org .eclipse .swt .graphics .Image ;
66
67
import org .eclipse .swt .widgets .FileDialog ;
67
68
import org .eclipse .swt .widgets .Label ;
68
69
import org .eclipse .swt .widgets .Shell ;
70
+ import org .eclipse .swt .widgets .Spinner ;
69
71
import org .eclipse .swt .widgets .Table ;
70
72
import org .eclipse .swt .widgets .TableColumn ;
71
73
import org .eclipse .swt .widgets .TableItem ;
@@ -89,8 +91,11 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage
89
91
implements IWorkbenchPreferencePage {
90
92
91
93
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 ;
94
+ private static final int RSA_MAX_KEY_SIZE = 15360 ;
95
+ private static final int DSA_MAX_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 KEY_SIZE_INCREMENT = 1024 ;
94
99
95
100
private Label ssh2HomeLabel ;
96
101
private Label privateKeyLabel ;
@@ -101,6 +106,7 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage
101
106
private Button ssh2HomeBrowse ;
102
107
Button keyGenerateDSA ;
103
108
Button keyGenerateRSA ;
109
+ private Spinner keySizeValue ;
104
110
private Button keyLoad ;
105
111
private Button keyExport ;
106
112
Button saveKeyPair ;
@@ -305,6 +311,13 @@ private Control createKeyManagementPage(Composite parent){
305
311
gd .horizontalSpan =1 ;
306
312
keyLoad .setLayoutData (gd );
307
313
314
+ final Label keySizeValueLabel = new Label (group , SWT .NONE );
315
+ keySizeValueLabel .setText (Messages .CVSSSH2PreferencePage_148 );
316
+ keySizeValue = new Spinner (group , SWT .BORDER );
317
+ int maxKeySize = Math .max (DSA_MAX_KEY_SIZE , RSA_MAX_KEY_SIZE );
318
+ keySizeValue .setValues (INITIAL_KEY_SIZE , MIN_KEY_SIZE , maxKeySize , 0 , KEY_SIZE_INCREMENT , KEY_SIZE_INCREMENT );
319
+ keySizeValue .addKeyListener (KeyListener .keyPressedAdapter (e -> e .doit = false ));
320
+
308
321
publicKeylabel =new Label (group , SWT .NONE );
309
322
publicKeylabel .setText (Messages .CVSSSH2PreferencePage_39 );
310
323
gd =new GridData ();
@@ -485,6 +498,9 @@ public void widgetSelected(SelectionEvent e){
485
498
if (e .widget ==keyGenerateDSA ){
486
499
type =KeyPair .DSA ;
487
500
_type =IConstants .DSA ;
501
+ if (keySizeValue .getSelection () > DSA_MAX_KEY_SIZE ) {
502
+ keySizeValue .setSelection (DSA_MAX_KEY_SIZE );
503
+ }
488
504
}
489
505
else if (e .widget ==keyGenerateRSA ){
490
506
type =KeyPair .RSA ;
@@ -496,7 +512,7 @@ else if(e.widget==keyGenerateRSA){
496
512
497
513
final KeyPair [] _kpair =new KeyPair [1 ];
498
514
final int __type =type ;
499
- int keySize = type == KeyPair . RSA ? RSA_KEY_SIZE : DSA_KEY_SIZE ;
515
+ int keySize = keySizeValue . getSelection () ;
500
516
final JSchException [] _e =new JSchException [1 ];
501
517
BusyIndicator .showWhile (getShell ().getDisplay (), () -> {
502
518
try {
0 commit comments