Skip to content

Commit cf1879f

Browse files
author
Federico Fissore
committed
Introducing GPG signature verification when loading main package_index file
1 parent 804480c commit cf1879f

31 files changed

+1039
-286
lines changed

.classpath

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
<classpathentry kind="lib" path="app/lib/jmdns-3.4.1.jar"/>
2121
<classpathentry kind="lib" path="app/lib/jsch-0.1.50.jar"/>
2222
<classpathentry kind="lib" path="app/lib/jssc-2.8.0.jar"/>
23-
<classpathentry kind="lib" path="app/lib/bcpg-jdk15on-149.jar"/>
24-
<classpathentry kind="lib" path="app/lib/bcprov-jdk15on-149.jar"/>
23+
<classpathentry kind="lib" path="app/lib/bcpg-jdk15on-152.jar"/>
24+
<classpathentry kind="lib" path="app/lib/bcprov-jdk15on-152.jar"/>
2525
<classpathentry kind="lib" path="app/lib/jackson-core-2.2.3.jar"/>
2626
<classpathentry kind="lib" path="app/lib/jackson-databind-2.2.3.jar"/>
2727
<classpathentry kind="lib" path="app/lib/jackson-module-mrbean-2.2.3.jar"/>

app/.classpath

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<classpathentry kind="lib" path="lib/jna.jar"/>
88
<classpathentry kind="lib" path="lib/ecj.jar"/>
99
<classpathentry kind="lib" path="lib/apple.jar"/>
10-
<classpathentry kind="lib" path="lib/bcpg-jdk15on-149.jar"/>
11-
<classpathentry kind="lib" path="lib/bcprov-jdk15on-149.jar"/>
10+
<classpathentry kind="lib" path="lib/bcpg-jdk15on-152.jar"/>
11+
<classpathentry kind="lib" path="lib/bcprov-jdk15on-152.jar"/>
1212
<classpathentry kind="lib" path="lib/commons-codec-1.7.jar"/>
1313
<classpathentry kind="lib" path="lib/commons-compress-1.8.jar"/>
1414
<classpathentry kind="lib" path="lib/commons-exec-1.1.jar"/>

app/build.xml

+2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@
9999
<fileset dir="test" includes="**/*.txt" />
100100
<fileset dir="test" includes="**/*.properties" />
101101
<fileset dir="test" includes="**/*.ino" />
102+
<fileset dir="test" includes="**/*.json*" />
103+
<fileset dir="test" includes="**/*.key" />
102104
</copy>
103105

104106
<junit printsummary="yes" dir="${work.dir}" fork="true">

app/lib/bcpg-jdk15on-149.jar

-243 KB
Binary file not shown.

app/lib/bcpg-jdk15on-152.jar

268 KB
Binary file not shown.

app/lib/bcprov-jdk15on-149.jar

-2.36 MB
Binary file not shown.

app/lib/bcprov-jdk15on-152.jar

2.77 MB
Binary file not shown.

app/src/cc/arduino/contributions/packages/ui/ContributionIndexTableModel.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import cc.arduino.contributions.filters.InstalledPredicate;
3333
import cc.arduino.contributions.packages.ContributedPackage;
3434
import cc.arduino.contributions.packages.ContributedPlatform;
35-
import cc.arduino.contributions.packages.ContributionsIndex;
35+
import cc.arduino.contributions.packages.ContributionsIndexer;
3636
import cc.arduino.contributions.ui.FilteredAbstractTableModel;
3737
import com.google.common.base.Predicate;
3838
import com.google.common.base.Predicates;
@@ -113,16 +113,16 @@ public void select(ContributedPlatform value) {
113113

114114
private Class<?>[] columnTypes = {ContributedPlatform.class};
115115

116-
private ContributionsIndex index;
116+
private ContributionsIndexer indexer;
117117

118-
public void setIndex(ContributionsIndex _index) {
119-
index = _index;
118+
public void setIndexer(ContributionsIndexer indexer) {
119+
this.indexer = indexer;
120120
}
121121

122122
public void updateIndexFilter(String filters[], Predicate<ContributedPlatform>... additionalFilters) {
123123
contributions.clear();
124124
Predicate<ContributedPlatform> filter = Predicates.and(additionalFilters);
125-
for (ContributedPackage pack : index.getPackages()) {
125+
for (ContributedPackage pack : indexer.getPackages()) {
126126
for (ContributedPlatform platform : pack.getPlatforms()) {
127127
if (!filter.apply(platform)) {
128128
continue;

app/src/cc/arduino/contributions/packages/ui/ContributionManagerUI.java

+3-7
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,11 @@
2828
*/
2929
package cc.arduino.contributions.packages.ui;
3030

31-
import cc.arduino.contributions.ui.InstallerJDialogUncaughtExceptionHandler;
3231
import cc.arduino.contributions.packages.ContributedPlatform;
3332
import cc.arduino.contributions.packages.ContributionInstaller;
3433
import cc.arduino.contributions.packages.ContributionsIndexer;
3534
import cc.arduino.contributions.packages.DownloadableContribution;
36-
import cc.arduino.contributions.ui.DropdownItem;
37-
import cc.arduino.contributions.ui.FilteredAbstractTableModel;
38-
import cc.arduino.contributions.ui.InstallerJDialog;
39-
import cc.arduino.contributions.ui.InstallerTableCell;
35+
import cc.arduino.contributions.ui.*;
4036
import cc.arduino.utils.Progress;
4137
import processing.app.I18n;
4238

@@ -95,7 +91,7 @@ public void setIndexer(ContributionsIndexer indexer) {
9591

9692
categoryChooser.removeActionListener(categoryChooserActionListener);
9793

98-
getContribModel().setIndex(indexer.getIndex());
94+
getContribModel().setIndexer(indexer);
9995

10096
categoryFilter = null;
10197
categoryChooser.removeAllItems();
@@ -106,7 +102,7 @@ public void setIndexer(ContributionsIndexer indexer) {
106102

107103
// Enable categories combo only if there are two or more choices
108104
categoryChooser.addItem(new DropdownAllCoresItem());
109-
Collection<String> categories = indexer.getIndex().getCategories();
105+
Collection<String> categories = indexer.getCategories();
110106
for (String s : categories) {
111107
categoryChooser.addItem(new DropdownCoreOfCategoryItem(s));
112108
}

app/src/processing/app/Base.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
package processing.app;
2424

25+
import cc.arduino.DefaultUncaughtExceptionHandler;
2526
import cc.arduino.contributions.DownloadableContributionVersionComparator;
2627
import cc.arduino.contributions.VersionHelper;
2728
import cc.arduino.contributions.libraries.ContributedLibrary;
@@ -342,7 +343,7 @@ protected void onProgress(Progress progress) {
342343
System.exit(1);
343344
}
344345

345-
ContributedPlatform installed = indexer.getIndex().getInstalled(boardToInstallParts[0], boardToInstallParts[1]);
346+
ContributedPlatform installed = indexer.getInstalled(boardToInstallParts[0], boardToInstallParts[1]);
346347

347348
if (!selected.isReadOnly()) {
348349
installer.install(selected);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* This file is part of Arduino.
3+
*
4+
* Copyright 2015 Arduino LLC (http://www.arduino.cc/)
5+
*
6+
* Arduino is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program; if not, write to the Free Software
18+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
*
20+
* As a special exception, you may use this file as part of a free software
21+
* library without restriction. Specifically, if other files instantiate
22+
* templates or use macros or inline functions from this file, or you compile
23+
* this file and link it with other files to produce an executable, this
24+
* file does not by itself cause the resulting executable to be covered by
25+
* the GNU General Public License. This exception does not however
26+
* invalidate any other reasons why the executable file might be covered by
27+
* the GNU General Public License.
28+
*/
29+
30+
package cc.arduino.packages.contributions;
31+
32+
import cc.arduino.contributions.GPGDetachedSignatureVerifier;
33+
import org.junit.Before;
34+
import org.junit.Test;
35+
36+
import java.io.File;
37+
38+
import static org.junit.Assert.assertFalse;
39+
import static org.junit.Assert.assertTrue;
40+
41+
public class GPGDetachedSignatureVerifierTest {
42+
43+
private GPGDetachedSignatureVerifier GPGDetachedSignatureVerifier;
44+
45+
@Before
46+
public void setUp() throws Exception {
47+
GPGDetachedSignatureVerifier = new GPGDetachedSignatureVerifier();
48+
}
49+
50+
@Test
51+
public void testSignatureSuccessfulVerification() throws Exception {
52+
File signedFile = new File(GPGDetachedSignatureVerifierTest.class.getResource("./package_index.json").getFile());
53+
File sign = new File(GPGDetachedSignatureVerifierTest.class.getResource("./package_index.json.sig").getFile());
54+
File publickKey = new File(GPGDetachedSignatureVerifierTest.class.getResource("./public.gpg.key").getFile());
55+
assertTrue(GPGDetachedSignatureVerifier.verify(signedFile, sign, publickKey));
56+
}
57+
58+
@Test
59+
public void testSignatureFailingVerification() throws Exception {
60+
File fakeSignedFile = File.createTempFile("fakeSigned", "txt");
61+
fakeSignedFile.deleteOnExit();
62+
File sign = new File(GPGDetachedSignatureVerifierTest.class.getResource("./package_index.json.sig").getFile());
63+
File publickKey = new File(GPGDetachedSignatureVerifierTest.class.getResource("./public.gpg.key").getFile());
64+
assertFalse(GPGDetachedSignatureVerifier.verify(fakeSignedFile, sign, publickKey));
65+
}
66+
}

0 commit comments

Comments
 (0)