From 28c0896001a95e1dc7833f027d60bccb85dac28d Mon Sep 17 00:00:00 2001 From: Alexander Manalad Date: Tue, 22 Oct 2024 18:22:38 -0700 Subject: [PATCH] [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 https://github.com/eclipse-platform/eclipse.platform/issues/1464 --- .../jsch/internal/ui/preference/PreferencePage.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 71ad68b3ee5..f536bec2f4a 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 @@ -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; @@ -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; } @@ -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());