Skip to content

Commit 183ca0f

Browse files
author
Thorben Groos
authored
Merge pull request #188 from grthor/develop
Kleptography Refers to #40
2 parents c04b304 + 49bf09f commit 183ca0f

6 files changed

Lines changed: 175 additions & 87 deletions

File tree

org.jcryptool.visual.kleptography/META-INF/MANIFEST.MF

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Bundle-ActivationPolicy: lazy
1010
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
1111
Bundle-Vendor: %Bundle-Vendor
1212
Import-Package: org.jcryptool.core.logging.utils,
13+
org.jcryptool.core.util.colors,
1314
org.jcryptool.core.util.fonts
1415
Export-Package: org.jcryptool.visual.kleptography,
1516
org.jcryptool.visual.kleptography.algorithm,

org.jcryptool.visual.kleptography/src/org/jcryptool/visual/kleptography/handlers/RestartHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
* @version 0.9.5
2323
*/
2424
public class RestartHandler extends AbstractHandler {
25-
public Object execute(ExecutionEvent event) throws ExecutionException {
25+
@Override
26+
public Object execute(ExecutionEvent event) throws ExecutionException {
2627
if (HandlerUtil.getActivePart(event) instanceof KleptoView) {
2728
KleptoView view = ((KleptoView) HandlerUtil.getActivePart(event));
2829

org.jcryptool.visual.kleptography/src/org/jcryptool/visual/kleptography/ui/KleptoView.java

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
import org.eclipse.swt.graphics.Color;
1515
import org.eclipse.swt.widgets.Composite;
1616
import org.eclipse.swt.widgets.Control;
17-
import org.eclipse.swt.widgets.Display;
1817
import org.eclipse.swt.widgets.TabFolder;
1918
import org.eclipse.swt.widgets.TabItem;
2019
import org.eclipse.ui.PlatformUI;
2120
import org.eclipse.ui.part.ViewPart;
21+
import org.jcryptool.core.util.colors.ColorService;
2222
import org.jcryptool.visual.kleptography.KleptographyPlugin;
2323
import org.jcryptool.visual.kleptography.algorithm.Kleptography;
2424

@@ -69,19 +69,11 @@ public enum PrimeGenSetting {
6969
private Composite parent;
7070

7171
// Define all the colors at once.
72-
public static final Color WHITE;
73-
public static final Color BACKGROUND_GRAY;
74-
public static final Color FOREGROUND_GRAY;
75-
public static final Color BLACK;
76-
public static final Color YELLOW;
77-
static {
78-
final Display d = Display.getDefault();
79-
WHITE = d.getSystemColor(SWT.COLOR_WHITE);
80-
BACKGROUND_GRAY = d.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
81-
FOREGROUND_GRAY = d.getSystemColor(SWT.COLOR_GRAY);
82-
BLACK = d.getSystemColor(SWT.COLOR_BLACK);
83-
YELLOW = d.getSystemColor(SWT.COLOR_YELLOW);
84-
}
72+
public static final Color WHITE = ColorService.WHITE;
73+
public static final Color BACKGROUND_GRAY = ColorService.LIGHTGRAY;
74+
public static final Color FOREGROUND_GRAY = ColorService.GRAY;
75+
public static final Color BLACK = ColorService.BLACK;
76+
public static final Color YELLOW = ColorService.YELLOW;
8577

8678
@Override
8779
public void createPartControl(final Composite parent) {

org.jcryptool.visual.kleptography/src/org/jcryptool/visual/kleptography/ui/OverwriteDialog.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ private void createContents(final Shell shell) {
9090
bFirst.setLayoutData(data);
9191

9292
bFirst.addSelectionListener(new SelectionAdapter() {
93+
@Override
9394
public void widgetSelected(SelectionEvent event) {
9495
setSelection(1);
9596
shell.close();
@@ -102,6 +103,7 @@ public void widgetSelected(SelectionEvent event) {
102103
bSecond.setLayoutData(data);
103104

104105
bSecond.addSelectionListener(new SelectionAdapter() {
106+
@Override
105107
public void widgetSelected(SelectionEvent event) {
106108
setSelection(2);
107109
shell.close();
@@ -114,6 +116,7 @@ public void widgetSelected(SelectionEvent event) {
114116
bCancel.setLayoutData(data);
115117

116118
bCancel.addSelectionListener(new SelectionAdapter() {
119+
@Override
117120
public void widgetSelected(SelectionEvent event) {
118121
setSelection(-1);
119122
shell.close();

org.jcryptool.visual.kleptography/src/org/jcryptool/visual/kleptography/ui/RSAAttackView.java

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class RSAAttackView extends Composite {
3434

3535
private Composite cAttackFixed;
3636
private Composite cFieldsFixed;
37-
private Composite cButtonsFixed;
37+
private Group cButtonsFixed;
3838
private Group gPublicKeysFixed;
3939
private Group gCalculationsFixed;
4040
private Group gCipherTextFixed;
@@ -91,7 +91,7 @@ public class RSAAttackView extends Composite {
9191
private Text tTextSETUP1;
9292
private Text tTextSETUP2;
9393
private Composite cAttackSETUP;
94-
private Composite cButtonsSETUP;
94+
private Group cButtonsSETUP;
9595
private Button bCalcPrivateKeysSETUP;
9696
private Button bDecryptTextsSETUP;
9797
private Label lQSETUP1;
@@ -106,10 +106,12 @@ public class RSAAttackView extends Composite {
106106
private Label lCalculationsFixed;
107107
private Label lCipherTextFixed;
108108
private Label lDecryptionsFixed;
109+
private Label lhorizontalSeparatorFixed;
109110
private Label lPublicKeysSETUP;
110111
private Label lCalculationsSETUP;
111112
private Label lCipherTextSETUP;
112113
private Label lDecryptionsSETUP;
114+
private Label lhorizontalSeparatorSETUP;
113115
private Composite cDescriptionFixed;
114116
private Label lDescTitleFixed;
115117
private StyledText stSpecDescFixed;
@@ -209,17 +211,21 @@ private void setUpAttackStack(Composite localParent) {
209211
* @param localParent The Fixed P composite contained in the StackLayout.
210212
*/
211213
private void setUpAttackFixed(Composite localParent) {
212-
cButtonsFixed = new Composite(localParent, SWT.BORDER);
213-
cButtonsFixed.setLayout(new GridLayout(1, false));
214-
cButtonsFixed.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
215-
216-
setUpButtonsFixed(cButtonsFixed);
217214

218-
cFieldsFixed = new Composite(localParent, SWT.BORDER);
219-
cFieldsFixed.setLayout(new GridLayout(1, false));
215+
cFieldsFixed = new Composite(localParent, SWT.NONE);
216+
GridLayout gl_cFieldsFixed = new GridLayout(1, false);
217+
gl_cFieldsFixed.marginWidth = 0;
218+
gl_cFieldsFixed.marginHeight = 0;
219+
cFieldsFixed.setLayout(gl_cFieldsFixed);
220220
cFieldsFixed.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
221221

222222
setUpFieldsFixed(cFieldsFixed);
223+
224+
cButtonsFixed = new Group(localParent, SWT.NONE);
225+
cButtonsFixed.setLayout(new GridLayout(1, false));
226+
cButtonsFixed.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
227+
228+
setUpButtonsFixed(cButtonsFixed);
223229
}
224230

225231
/**
@@ -238,6 +244,11 @@ private void setUpButtonsFixed(Composite localParent) {
238244
bDecryptTextsFixed = new Button(localParent, SWT.PUSH);
239245
bDecryptTextsFixed.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
240246
bDecryptTextsFixed.setText(Messages.RSAAttackView_Fixed_Decrypt_Cipher);
247+
248+
lhorizontalSeparatorFixed = new Label(localParent, SWT.HORIZONTAL | SWT.SEPARATOR);
249+
GridData gd_lhorizontalSeparatorFixed = new GridData(SWT.FILL, SWT.CENTER, false, false);
250+
gd_lhorizontalSeparatorFixed.verticalIndent = 15;
251+
lhorizontalSeparatorFixed.setLayoutData(gd_lhorizontalSeparatorFixed);
241252

242253
bBackFixed = new Button(localParent, SWT.PUSH);
243254
bBackFixed.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
@@ -524,17 +535,21 @@ private void setUpDecryptionsFixed(Composite localParent) {
524535
* @param localParent The parent control of the SETUP fields.
525536
*/
526537
private void setUpAttackSETUP(Composite localParent) {
527-
cButtonsSETUP = new Composite(localParent, SWT.BORDER);
528-
cButtonsSETUP.setLayout(new GridLayout(1, false));
529-
cButtonsSETUP.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
530-
531-
setUpButtonsSETUP(cButtonsSETUP);
532538

533-
cFieldsSETUP = new Composite(localParent, SWT.BORDER);
534-
cFieldsSETUP.setLayout(new GridLayout(1, false));
539+
cFieldsSETUP = new Composite(localParent, SWT.NONE);
540+
GridLayout gl_cFieldsSETUP = new GridLayout(1, false);
541+
gl_cFieldsSETUP.marginWidth = 0;
542+
gl_cFieldsSETUP.marginHeight = 0;
543+
cFieldsSETUP.setLayout(gl_cFieldsSETUP);
535544
cFieldsSETUP.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
536545

537546
setUpFieldsSETUP(cFieldsSETUP);
547+
548+
cButtonsSETUP = new Group(localParent, SWT.NONE);
549+
cButtonsSETUP.setLayout(new GridLayout(1, false));
550+
cButtonsSETUP.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
551+
552+
setUpButtonsSETUP(cButtonsSETUP);
538553
}
539554

540555
/**
@@ -553,6 +568,11 @@ private void setUpButtonsSETUP(Composite localParent) {
553568
bDecryptTextsSETUP = new Button(localParent, SWT.PUSH);
554569
bDecryptTextsSETUP.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
555570
bDecryptTextsSETUP.setText(Messages.RSAAttackView_SETUP_Decrypt_Cipher);
571+
572+
lhorizontalSeparatorSETUP = new Label(localParent, SWT.HORIZONTAL | SWT.SEPARATOR);
573+
GridData gd_lhorizontalSeparatorSETUP = new GridData(SWT.FILL, SWT.CENTER, false, false);
574+
gd_lhorizontalSeparatorSETUP.verticalIndent = 15;
575+
lhorizontalSeparatorSETUP.setLayoutData(gd_lhorizontalSeparatorSETUP);
556576

557577
bBackSETUP = new Button(localParent, SWT.PUSH);
558578
bBackSETUP.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
@@ -948,9 +968,11 @@ public void saveCipherTextSETUP() {
948968
*/
949969
private void setUpAttackListeners() {
950970
bCalcGCD.addSelectionListener(new SelectionListener() {
971+
@Override
951972
public void widgetDefaultSelected(SelectionEvent e) {
952973
widgetSelected(e);
953974
}
975+
@Override
954976
public void widgetSelected(SelectionEvent e) {
955977
// If the user used the same N to generate both saved ciphertexts,
956978
// the attack won't work. Let the user know and don't bother trying.
@@ -972,9 +994,11 @@ public void widgetSelected(SelectionEvent e) {
972994
});
973995

974996
bCalcPrivateKeysFixed.addSelectionListener(new SelectionListener() {
997+
@Override
975998
public void widgetDefaultSelected(SelectionEvent e) {
976999
widgetSelected(e);
9771000
}
1001+
@Override
9781002
public void widgetSelected(SelectionEvent e) {
9791003
kleptoView.currentStep = 18;
9801004
kleptoView.klepto.attack.calculatePrivateKeysFixed();
@@ -992,9 +1016,11 @@ public void widgetSelected(SelectionEvent e) {
9921016
});
9931017

9941018
bDecryptTextsFixed.addSelectionListener(new SelectionListener() {
1019+
@Override
9951020
public void widgetDefaultSelected(SelectionEvent e) {
9961021
widgetSelected(e);
9971022
}
1023+
@Override
9981024
public void widgetSelected(SelectionEvent e) {
9991025
kleptoView.currentStep = 19;
10001026
kleptoView.klepto.attack.decryptFixed();
@@ -1005,9 +1031,11 @@ public void widgetSelected(SelectionEvent e) {
10051031
});
10061032

10071033
bDecryptP.addSelectionListener(new SelectionListener() {
1034+
@Override
10081035
public void widgetDefaultSelected(SelectionEvent e) {
10091036
widgetSelected(e);
10101037
}
1038+
@Override
10111039
public void widgetSelected(SelectionEvent e) {
10121040
kleptoView.currentStep = 10;
10131041
kleptoView.klepto.attack.getPFromN(
@@ -1022,9 +1050,11 @@ public void widgetSelected(SelectionEvent e) {
10221050
});
10231051

10241052
bCalcPrivateKeysSETUP.addSelectionListener(new SelectionListener() {
1053+
@Override
10251054
public void widgetDefaultSelected(SelectionEvent e) {
10261055
widgetSelected(e);
10271056
}
1057+
@Override
10281058
public void widgetSelected(SelectionEvent e) {
10291059
kleptoView.currentStep = 11;
10301060
kleptoView.klepto.attack.calculatePrivateKeysSETUP();
@@ -1042,9 +1072,11 @@ public void widgetSelected(SelectionEvent e) {
10421072
});
10431073

10441074
bDecryptTextsSETUP.addSelectionListener(new SelectionListener() {
1075+
@Override
10451076
public void widgetDefaultSelected(SelectionEvent e) {
10461077
widgetSelected(e);
10471078
}
1079+
@Override
10481080
public void widgetSelected(SelectionEvent e) {
10491081
kleptoView.currentStep = 12;
10501082
kleptoView.klepto.attack.decryptSETUP();
@@ -1055,18 +1087,22 @@ public void widgetSelected(SelectionEvent e) {
10551087
});
10561088

10571089
bBackFixed.addSelectionListener(new SelectionListener() {
1090+
@Override
10581091
public void widgetDefaultSelected(SelectionEvent e) {
10591092
widgetSelected(e);
10601093
}
1094+
@Override
10611095
public void widgetSelected(SelectionEvent e) {
10621096
kleptoView.setTabSelection(0);
10631097
}
10641098
});
10651099

10661100
bBackSETUP.addSelectionListener(new SelectionListener() {
1101+
@Override
10671102
public void widgetDefaultSelected(SelectionEvent e) {
10681103
widgetSelected(e);
10691104
}
1105+
@Override
10701106
public void widgetSelected(SelectionEvent e) {
10711107
kleptoView.setTabSelection(0);
10721108
}

0 commit comments

Comments
 (0)