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

refactor: use pgpainless #78

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@

<maven.version>3.3.9</maven.version>

<org.bouncycastle.bcpg.version>1.72.2</org.bouncycastle.bcpg.version>
<org.bouncycastle.bcprov.version>1.72</org.bouncycastle.bcprov.version>
<org.bouncycastle.bcpg.version>1.73</org.bouncycastle.bcpg.version>
<org.bouncycastle.bcprov.version>1.73</org.bouncycastle.bcprov.version>

<packager.version>0.19.0</packager.version>
<packager.version>0.19.1-SNAPSHOT</packager.version>
</properties>

<prerequisites>
Expand Down
1 change: 0 additions & 1 deletion src/it/rpm12-disable/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/test1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/test10-defaultname/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/test10-legacyname/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/test11-prefixes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/test13-skipentry/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/test14-forcerelease/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>
</configuration>
Expand Down
1 change: 0 additions & 1 deletion src/it/test14-primaryname/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/test14-snapshotname/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/test15-default/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/test15-md5-only/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/test15-not-found/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/test16-ghost/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/test17-reproducible-date/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/test17-reproducible-epoch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/test18-file-digest-default/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/test18-file-digest-md5/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/test2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/test3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/test4-lowercase/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/test4-uppercase/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/test5-outname/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/test6-scanner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/test7-nosrcpkg/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/test7-srcpkg/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/test7-srcpkg2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/test8-newflags/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/test9-maxversion/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/yum1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA256</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
1 change: 0 additions & 1 deletion src/it/yum2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA256</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

Expand Down
17 changes: 8 additions & 9 deletions src/main/java/de/dentrassi/rpm/builder/RpmMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectHelper;
import org.bouncycastle.openpgp.PGPPrivateKey;
import org.bouncycastle.openpgp.PGPSecretKeyRing;
import org.codehaus.plexus.util.DirectoryScanner;
import org.eclipse.packager.rpm.Architecture;
import org.eclipse.packager.rpm.HashAlgorithm;
import org.eclipse.packager.rpm.OperatingSystem;
import org.eclipse.packager.rpm.RpmLead;
import org.eclipse.packager.rpm.RpmTag;
Expand All @@ -66,16 +65,15 @@
import org.eclipse.packager.rpm.build.RpmBuilder.PackageInformation;
import org.eclipse.packager.rpm.build.RpmBuilder.Version;
import org.eclipse.packager.rpm.deps.RpmDependencyFlags;
import org.eclipse.packager.rpm.signature.RsaHeaderSignatureProcessor;
import org.eclipse.packager.rpm.signature.RsaSignatureProcessor;
import org.eclipse.packager.rpm.signature.SignatureProcessor;
import org.eclipse.packager.rpm.signature.*;

import com.google.common.base.Strings;
import com.google.common.io.CharSource;

import de.dentrassi.rpm.builder.Naming.Case;
import de.dentrassi.rpm.builder.PackageEntry.Collector;
import de.dentrassi.rpm.builder.signatures.SignatureConfiguration;
import org.pgpainless.key.protection.SecretKeyRingProtector;

/**
* Build an RPM file
Expand Down Expand Up @@ -959,13 +957,14 @@ private void testLeadFlags() {
}

private SignatureProcessor[] makeRsaSigners(final Signature signature) throws MojoExecutionException, MojoFailureException {
final PGPPrivateKey privateKey = SigningHelper.loadKey(signature, this.logger);
if (privateKey == null) {
final PGPSecretKeyRing secretKey = SigningHelper.loadKey(signature, this.logger);
if (secretKey == null) {
return null;
}
final SecretKeyRingProtector protector = SigningHelper.createProtector(secretKey, signature.getPassphrase());
return new SignatureProcessor[]{
new RsaHeaderSignatureProcessor(privateKey, HashAlgorithm.from(signature.getHashAlgorithm())),
new RsaSignatureProcessor(privateKey, HashAlgorithm.from(signature.getHashAlgorithm()))
new PgpHeaderSignatureProcessor(secretKey, protector ),
new PgpSignatureProcessor(secretKey, protector)
};
}

Expand Down
14 changes: 3 additions & 11 deletions src/main/java/de/dentrassi/rpm/builder/Signature.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
/*******************************************************************************
* Copyright (c) 2016 IBH SYSTEMS GmbH and others.
* Copyright (c) 2016, 2023 IBH SYSTEMS GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0
*
* Contributors:
* IBH SYSTEMS GmbH - initial API and implementation
* Red Hat, Inc - use pgpainless
*******************************************************************************/
package de.dentrassi.rpm.builder;

import java.io.File;
import java.nio.file.Path;

public class Signature {
private String keyId;
Expand All @@ -19,8 +21,6 @@ public class Signature {

private String passphrase;

private String hashAlgorithm = "SHA512";

private boolean skip;

public void setKeyId(final String keyId) {
Expand All @@ -47,14 +47,6 @@ public String getPassphrase() {
return this.passphrase;
}

public void setHashAlgorithm(final String hashAlgorithm) {
this.hashAlgorithm = hashAlgorithm;
}

public String getHashAlgorithm() {
return this.hashAlgorithm;
}

public void setSkip(final boolean skip) {
this.skip = skip;
}
Expand Down
Loading