Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow skip in SignatureValidatingInputStream #42

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
59fcd28
SignatureValidatingInputStream: use default InputStream implementatio…
Feb 25, 2020
edaded5
Add (failing) unit test encryptAndSignArmored_thenDecryptAndVerifyWit…
Mar 7, 2020
84f2e64
fixes #46 by reverting 012c3f9; that commit did not make sense, as we…
ispringer Apr 2, 2020
b1c5ca8
fix so KeyFlag#extractPublicKeyFlags does not throw a NullPointerExce…
ispringer Apr 2, 2020
6c394ce
Bouncy Castle to 1.65
Neustradamus Apr 14, 2020
b899853
Fix for issue https://github.com/neuhalje/bouncy-gpg/issues/50, where…
mdesmons Apr 28, 2020
70d6146
added comment to extractPublicKeyFlags
mdesmons Apr 28, 2020
986d436
Added the MDC verification if present
Jun 15, 2020
813d35a
Removed unneccessary comments
Sauhardstark Jun 16, 2020
a2f9447
Updated minor comments
Sauhardstark Jun 16, 2020
7cb1ed0
Added accidentally removed NOMPD tag
Jun 18, 2020
563ce4c
Added comments regarding the bit changed (595th)
Sauhardstark Jun 22, 2020
75b484f
Bump gradle & jaCoCo for JDK 14
neuhalje Jul 12, 2020
0eb5fca
Check JDK 13 & 14 in Travis
neuhalje Jul 12, 2020
0eb437c
Run tests from Travis
neuhalje Jul 12, 2020
0941564
Merge branch 'Sauhardstark-master'
neuhalje Jul 12, 2020
26b957f
Merge branch 'bouncycastle' of https://github.com/Neustradamus/bouncy…
neuhalje Jul 12, 2020
64a6602
Some tests used algorithm identifiers from wrong class
neuhalje Jul 12, 2020
50cabd8
Merge branch 'Neustradamus-bouncycastle'
neuhalje Jul 12, 2020
550d5b2
Merge branch 'master' of https://github.com/mdesmons/bouncy-gpg into …
neuhalje Jul 12, 2020
7d92b1d
Merge branch 'mdesmons-master'
neuhalje Jul 12, 2020
887b149
Merge branch 'issue-48' of https://github.com/ispringer/bouncy-gpg in…
neuhalje Jul 12, 2020
1ab3b17
Merge branch 'ispringer-issue-48'
neuhalje Jul 12, 2020
59dcae1
Merge branch 'issue-46' of https://github.com/ispringer/bouncy-gpg in…
neuhalje Jul 12, 2020
08fcb12
Merge branch 'ispringer-issue-46'
neuhalje Jul 12, 2020
11b3704
Pass timestamp within key validity into test
neuhalje Nov 18, 2020
5f05193
Bump Bouncy Castle to 1.67
neuhalje Nov 18, 2020
500dd89
Minor code and documentation changes.
neuhalje Nov 19, 2020
3523ca7
Bump to 2.3.0
neuhalje Nov 18, 2020
16e3e53
Merge branch 'master' of github.com:unverbraucht/bouncy-gpg
unverbraucht Feb 21, 2022
0aa8dc5
Incorporate fixed skip() implementation from @ispringer - thanks.
unverbraucht Feb 21, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ build/
out/
gradle.properties
*.iml
bin/
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ cache:
jdk:
- openjdk8
- oraclejdk8
# - openjdk10
- openjdk11
- oraclejdk11
- openjdk13
- oraclejdk13
- openjdk14
- oraclejdk14

script:
- sudo apt-get update
Expand All @@ -24,7 +25,7 @@ script:
- # sudo snap install hugo
- # export PATH
- # /snap/bin/hugo version
- ./gradlew -PHUGO_EXEC="/snap/bin/hugo" --info --stacktrace check jacocoTestReport # generateWebsite
- ./gradlew -PHUGO_EXEC="/snap/bin/hugo" -info --stacktrace clean check test integrationTest jacocoTestReport

after_success:
- bash <(curl -s https://codecov.io/bash)
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
## V 2.x.x (NEXT)

## V 2.3.0 Bugfix Release

This releases fixes a security issue (#50) where encrypted, but not signed archives could be modified.
Some background on MDC and why it's important security-wise: https://gpgtools.tenderapp.com/kb/faq/modification-detection-code-mdc-errors

* Fix: Do not expose logback as compile-time dependency (#41)
* Fix: java.io.EOFException: Unexpected end of ZIP input stream using 2.2.0 version for PGP file (#46)
* Fix: KeyFlag#extractPublicKeyFlags throws NullPointerException if called on an older public key with no hashed subpackets (#48)
* Fix: Encrypting with keys that don't have a KeyFlags subpacket (#50)
* Fix: MDC (integrity checksum) is not verified when decrypting (#45)
* Enh: Bump Bouncy Castle to 1.67


## V 2.2.0 Key generation

* new: Add key generation (initial version by Paul Schaub [@vanitasvitae])
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ repositories {

// ...
dependencies {
compile 'org.bouncycastle:bcprov-jdk15on:1.64'
compile 'org.bouncycastle:bcpg-jdk15on:1.64'
compile 'org.bouncycastle:bcprov-jdk15on:1.67'
compile 'org.bouncycastle:bcpg-jdk15on:1.67'
// ...
compile 'name.neuhalfen.projects.crypto.bouncycastle.openpgp:bouncy-gpg:2.+'
// ...
Expand All @@ -215,10 +215,10 @@ dependencies {
<dependency>
<groupId>name.neuhalfen.projects.crypto.bouncycastle.openpgp</groupId>
<artifactId>bouncy-gpg</artifactId>
<version>2.2.0</version>
   </dependency>
<version>2.3.0</version>
</dependency>
```
 

### Install Provider

```java
Expand Down
12 changes: 10 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ Open TODOs
Version 3.0
--------------

Version 2.2
Version 2.4
-------------

- [ ] Key generation
- [ ] Key generation key expiration
- [ ] Key generation documentation
- [ ] Add decryptor.getResult() for decryption result
Expand All @@ -16,6 +15,15 @@ Version 2.2
- [ ] Unit tests: iterate different DefaultPGPAlgorithmSuites.secureSuiteForGnuPG() (incl. compression & no signature!)
- [ ] Extend documentation of key derivation

Version 2.3
-------------
- [x] Bugfixes


Version 2.2
-------------
- [x] Key generation


Version 2.1
-------------
Expand Down
13 changes: 7 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ tasks.withType(Checkstyle) {
}

jacoco {
toolVersion = "0.8.2"
toolVersion = "0.8.5"
reportsDir = file("${buildDir}/jacocoHtml")
}

Expand Down Expand Up @@ -87,7 +87,7 @@ sourceCompatibility = 8
targetCompatibility = 8

group = 'name.neuhalfen.projects.crypto.bouncycastle.openpgp'
version = '2.2.0'
version = '2.3.0'

repositories {
jcenter()
Expand Down Expand Up @@ -123,11 +123,10 @@ check.dependsOn integrationTest


dependencies {
compile 'org.bouncycastle:bcprov-jdk15on:1.64'
compile 'org.bouncycastle:bcpg-jdk15on:1.64'
compile 'org.bouncycastle:bcprov-jdk15on:1.67'
compile 'org.bouncycastle:bcpg-jdk15on:1.67'

compile 'org.slf4j:slf4j-api:1.7.30'
compile 'ch.qos.logback:logback-classic:1.2.3'

// @Nullable and friends are not needed at runtime
compile 'com.google.code.findbugs:jsr305:3.0.2'
Expand All @@ -136,6 +135,8 @@ dependencies {
testCompile 'org.hamcrest:hamcrest-all:1.3'
testCompile 'org.mockito:mockito-core:3.2.4'
testCompile 'org.concordion:concordion-api-documentation-extension:0.0.4'
testCompile 'ch.qos.logback:logback-classic:1.2.3'

}


Expand Down Expand Up @@ -163,7 +164,7 @@ if (hasProperty('bintray_Username')) {
apply from: 'website.gradle'

wrapper {
gradleVersion = '6.1'
gradleVersion = '6.5'
}

// Generate OSGI bundle metadata
Expand Down
6 changes: 3 additions & 3 deletions examples/decrypt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ repositories {
}

dependencies {
compile 'org.bouncycastle:bcprov-jdk15on:1.60'
compile 'org.bouncycastle:bcpg-jdk15on:1.60'
compile 'org.bouncycastle:bcprov-jdk15on:1.67'
compile 'org.bouncycastle:bcpg-jdk15on:1.67'

compile 'name.neuhalfen.projects.crypto.bouncycastle.openpgp:bouncy-gpg:2.2.0'
compile 'name.neuhalfen.projects.crypto.bouncycastle.openpgp:bouncy-gpg:2.3.0'

compile 'org.slf4j:slf4j-api:1.7.25'
compile 'ch.qos.logback:logback-classic:1.2.3'
Expand Down
4 changes: 2 additions & 2 deletions examples/encrypt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ repositories {
}

dependencies {
compile 'org.bouncycastle:bcprov-jdk15on:1.60'
compile 'org.bouncycastle:bcpg-jdk15on:1.60'
compile 'org.bouncycastle:bcprov-jdk15on:1.67'
compile 'org.bouncycastle:bcpg-jdk15on:1.67'

compile 'name.neuhalfen.projects.crypto.bouncycastle.openpgp:bouncy-gpg:2.+'

Expand Down
7 changes: 4 additions & 3 deletions examples/maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,24 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<bouncycastle.version>1.67</bouncycastle.version>
</properties>

<dependencies>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.64</version>
<version>${bouncycastle.version}</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpg-jdk15on</artifactId>
<version>1.64</version>
<version>${bouncycastle.version}</version>
</dependency>
<dependency>
<groupId>name.neuhalfen.projects.crypto.bouncycastle.openpgp</groupId>
<artifactId>bouncy-gpg</artifactId>
<version>2.2.0</version>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
Expand Down
6 changes: 3 additions & 3 deletions examples/reencrypt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ repositories {
}

dependencies {
compile 'org.bouncycastle:bcprov-jdk15on:1.60'
compile 'org.bouncycastle:bcpg-jdk15on:1.60'
compile 'org.bouncycastle:bcprov-jdk15on:1.67'
compile 'org.bouncycastle:bcpg-jdk15on:1.67'

compile 'name.neuhalfen.projects.crypto.bouncycastle.openpgp:bouncy-gpg:2.2.0'
compile 'name.neuhalfen.projects.crypto.bouncycastle.openpgp:bouncy-gpg:2.3.0'

compile 'org.slf4j:slf4j-api:1.7.22'
compile 'ch.qos.logback:logback-classic:1.2.1'
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#Sun Jan 19 11:34:50 CET 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import java.security.Security;

import name.neuhalfen.projects.crypto.bouncycastle.openpgp.keys.generation.KeyRingBuilder;
import name.neuhalfen.projects.crypto.bouncycastle.openpgp.keys.generation.KeyRingBuilderImpl;
import name.neuhalfen.projects.crypto.bouncycastle.openpgp.keys.generation.SimpleKeyRingBuilder;
Expand Down Expand Up @@ -82,7 +83,7 @@ public static SimpleKeyRingBuilder createSimpleKeyring() {
* implementation.
* </p>
*/
public synchronized static void registerProvider() {
public static synchronized void registerProvider() {
Security.removeProvider(BouncyCastleProvider.PROVIDER_NAME);
Security.insertProviderAt(new BouncyCastleProvider(), 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,13 @@ public interface Validation {
Build andRequireSignatureFromAllKeys(Long... publicKeyIds);

/**
* <p>
* Decryption will enforce that the ciphertext has been signed by ALL of the public key ids
* passed.
*
* </p>
*<p>
* Given the following keyring:
*
*</p>
* <pre>{@code
* $ gpg -k --keyid-format=0xlong
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@ public final class DefaultPGPAlgorithmSuites {
/**
* GPG default algorithms.
*/
private final static PGPAlgorithmSuite DEFAULT_GPG = new PGPAlgorithmSuite(
private static final PGPAlgorithmSuite DEFAULT_GPG = new PGPAlgorithmSuite(
PGPHashAlgorithms.SHA1,
PGPSymmetricEncryptionAlgorithms.CAST5,
PGPCompressionAlgorithms.ZLIB);

/**
* GPG strong crypto algorithms.
*/
private final static PGPAlgorithmSuite STRONG_GPG = new PGPAlgorithmSuite(
private static final PGPAlgorithmSuite STRONG_GPG = new PGPAlgorithmSuite(
PGPHashAlgorithms.SHA_256,
PGPSymmetricEncryptionAlgorithms.AES_128,
PGPCompressionAlgorithms.ZLIB);

/**
* Algorithm suite for XEP-0373: OpenPGP for XMPP.
*/
private final static PGPAlgorithmSuite DEFAULT_OX = new PGPAlgorithmSuite(
private static final PGPAlgorithmSuite DEFAULT_OX = new PGPAlgorithmSuite(
PGPHashAlgorithms.SHA_256,
PGPSymmetricEncryptionAlgorithms.AES_128,
PGPCompressionAlgorithms.UNCOMPRESSED);
Expand All @@ -48,6 +49,9 @@ public static PGPAlgorithmSuite strongSuite() {
return STRONG_GPG;
}

/**
* Algorithm suite for XEP-0373: OpenPGP for XMPP.
*/
public static PGPAlgorithmSuite oxSuite() {
return DEFAULT_OX;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package name.neuhalfen.projects.crypto.bouncycastle.openpgp.algorithms;

import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public enum PGPCompressionAlgorithms {
*/
BZIP2(CompressionAlgorithmTags.BZIP2);

private final static Set<PGPCompressionAlgorithms> RECOMMENDED_ALGORITHMS = SetUtils
private static final Set<PGPCompressionAlgorithms> RECOMMENDED_ALGORITHMS = SetUtils
.unmodifiableSet(BZIP2, ZLIB, ZIP, UNCOMPRESSED);
private final static int[] RECOMMENDED_ALGORITHM_IDS =
private static final int[] RECOMMENDED_ALGORITHM_IDS =
RECOMMENDED_ALGORITHMS.stream().mapToInt(algorithm -> algorithm.algorithmId).toArray();
private final int algorithmId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ public enum PGPHashAlgorithms {
*/
HAVAL_5_160(HashAlgorithmTags.HAVAL_5_160, true,true);

private final static Set<PGPHashAlgorithms> RECOMMENDED_ALGORITHMS = Collections
private static final Set<PGPHashAlgorithms> RECOMMENDED_ALGORITHMS = Collections
.unmodifiableSet(
Arrays.stream(
PGPHashAlgorithms.values()).filter(alg -> !alg.insecure && alg.supportedInGPG )
PGPHashAlgorithms.values()).filter(alg -> !alg.insecure && alg.supportedInGPG)
.collect(Collectors.toSet()));
private final static int[] RECOMMENDED_ALGORITHM_IDS =
private static final int[] RECOMMENDED_ALGORITHM_IDS =
RECOMMENDED_ALGORITHMS.stream().mapToInt(algorithm -> algorithm.algorithmId).toArray();
private final int algorithmId;
private final boolean insecure;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public enum PGPSymmetricEncryptionAlgorithms {
BLOWFISH(SymmetricKeyAlgorithmTags.BLOWFISH, true),

/**
* SAFER-SK128 (13 rounds) [SAFER] <p> Insecure: 64 bit blocksize.
* SAFER-SK128 (13 rounds) [SAFER] [INSECURE]: 64 bit blocksize.
*/
SAFER(SymmetricKeyAlgorithmTags.SAFER, true),

Expand Down Expand Up @@ -85,13 +85,13 @@ public enum PGPSymmetricEncryptionAlgorithms {
CAMELLIA_256(SymmetricKeyAlgorithmTags.CAMELLIA_256, false);


private final static Set<PGPSymmetricEncryptionAlgorithms> RECOMMENDED_ALGORITHMS = Collections
private static final Set<PGPSymmetricEncryptionAlgorithms> RECOMMENDED_ALGORITHMS = Collections
.unmodifiableSet(
Arrays.stream(
PGPSymmetricEncryptionAlgorithms.values())
.filter(alg -> !alg.insecure)
.collect(Collectors.toSet()));
private final static int[] RECOMMENDED_ALGORITHM_IDS =
private static final int[] RECOMMENDED_ALGORITHM_IDS =
RECOMMENDED_ALGORITHMS.stream().mapToInt(algorithm -> algorithm.algorithmId).toArray();
private final int algorithmId;
private final boolean insecure;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package name.neuhalfen.projects.crypto.bouncycastle.openpgp.algorithms;

import java.util.HashMap;
Expand Down