diff --git a/team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/Messages.java b/team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/Messages.java index 0453c56f0a5..fde33f86be1 100644 --- a/team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/Messages.java +++ b/team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/Messages.java @@ -99,6 +99,7 @@ public class Messages extends NLS{ public static String CVSSSH2PreferencePage_145; public static String CVSSSH2PreferencePage_146; public static String CVSSSH2PreferencePage_147; + public static String CVSSSH2PreferencePage_148; public static String KeyboardInteractiveDialog_0; public static String KeyboardInteractiveDialog_1; public static String KeyboardInteractiveDialog_2; diff --git a/team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/messages.properties b/team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/messages.properties index aa6a976f406..345694464a8 100644 --- a/team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/messages.properties +++ b/team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/messages.properties @@ -89,6 +89,7 @@ CVSSSH2PreferencePage_144=Key Exchange &Methods CVSSSH2PreferencePage_145=MA&C Methods CVSSSH2PreferencePage_146=&SSH Agent CVSSSH2PreferencePage_147=Select preferred SSH Agent +CVSSSH2PreferencePage_148=Key Size to Generate: UserInfoPrompter_0=SSH2 Message UserInfoPrompter_1=SSH2 Message KeyboardInteractiveDialog_0=Keyboard Interactive authentication for {0}: {1} diff --git a/team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PreferencePage.java b/team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PreferencePage.java index f536bec2f4a..623fad21874 100644 --- a/team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PreferencePage.java +++ b/team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PreferencePage.java @@ -53,6 +53,8 @@ import org.eclipse.swt.custom.TableEditor; import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.FocusListener; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Image; @@ -66,6 +68,7 @@ import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Spinner; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableItem; @@ -91,6 +94,10 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage 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 static final int MIN_KEY_SIZE = 2048; + private static final int MAX_KEY_SIZE = RSA_KEY_SIZE; + private static final int MAX_KEY_SIZE_DIGIT_COUNT = 0; + private static final int KEY_SIZE_INCREMENT = 1024; private Label ssh2HomeLabel; private Label privateKeyLabel; @@ -101,6 +108,7 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage private Button ssh2HomeBrowse; Button keyGenerateDSA; Button keyGenerateRSA; + private Spinner keyGenerateSize; private Button keyLoad; private Button keyExport; Button saveKeyPair; @@ -305,6 +313,19 @@ private Control createKeyManagementPage(Composite parent){ gd.horizontalSpan=1; keyLoad.setLayoutData(gd); + final Label keyGenerateSizeLabel=new Label(group, SWT.NONE); + keyGenerateSizeLabel.setText(Messages.CVSSSH2PreferencePage_148); + keyGenerateSize=new Spinner(group, SWT.BORDER); + keyGenerateSize.setValues(MIN_KEY_SIZE, MIN_KEY_SIZE, MAX_KEY_SIZE, MAX_KEY_SIZE_DIGIT_COUNT, + KEY_SIZE_INCREMENT, KEY_SIZE_INCREMENT); + + keyGenerateSize.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + e.doit = false; + } + }); + publicKeylabel=new Label(group, SWT.NONE); publicKeylabel.setText(Messages.CVSSSH2PreferencePage_39); gd=new GridData(); @@ -485,6 +506,8 @@ public void widgetSelected(SelectionEvent e){ if(e.widget==keyGenerateDSA){ type=KeyPair.DSA; _type=IConstants.DSA; + if (keyGenerateSize.getSelection()>DSA_KEY_SIZE) + keyGenerateSize.setSelection(DSA_KEY_SIZE); } else if(e.widget==keyGenerateRSA){ type=KeyPair.RSA; @@ -496,7 +519,7 @@ 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; + int keySize=keyGenerateSize.getSelection(); final JSchException[] _e=new JSchException[1]; BusyIndicator.showWhile(getShell().getDisplay(), () -> { try {