From 29055a825af5405e44ffcd59a776f8952bdc7203 Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Fri, 15 Dec 2017 16:03:23 +0100 Subject: [PATCH] Port to latest bouncycastle. --- .../bouncycastle/OpenPGPSignatureGenerator.java | 34 ++++++++++------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/java/org/apache/ivy/plugins/signer/bouncycastle/OpenPGPSignatureGenerator.java b/src/java/org/apache/ivy/plugins/signer/bouncycastle/OpenPGPSignatureGenerator.java index af7beae..34c204f 100644 --- a/src/java/org/apache/ivy/plugins/signer/bouncycastle/OpenPGPSignatureGenerator.java +++ b/src/java/org/apache/ivy/plugins/signer/bouncycastle/OpenPGPSignatureGenerator.java @@ -41,6 +41,11 @@ import org.bouncycastle.openpgp.PGPSecretKeyRingCollection; import org.bouncycastle.openpgp.PGPSignature; import org.bouncycastle.openpgp.PGPSignatureGenerator; import org.bouncycastle.openpgp.PGPUtil; +import org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor; +import org.bouncycastle.openpgp.operator.bc.BcPBESecretKeyDecryptorBuilder; +import org.bouncycastle.openpgp.operator.bc.BcPGPDigestCalculatorProvider; +import org.bouncycastle.openpgp.operator.bc.BcPGPContentSignerBuilder; +import org.bouncycastle.openpgp.operator.bc.BcKeyFingerprintCalculator; public class OpenPGPSignatureGenerator implements SignatureGenerator { @@ -101,11 +106,15 @@ public class OpenPGPSignatureGenerator implements SignatureGenerator { pgpSec = readSecretKey(keyIn); } - PGPPrivateKey pgpPrivKey = pgpSec.extractPrivateKey(password.toCharArray(), - BouncyCastleProvider.PROVIDER_NAME); - PGPSignatureGenerator sGen = new PGPSignatureGenerator(pgpSec.getPublicKey() - .getAlgorithm(), PGPUtil.SHA1, BouncyCastleProvider.PROVIDER_NAME); - sGen.initSign(PGPSignature.BINARY_DOCUMENT, pgpPrivKey); + PBESecretKeyDecryptor decryptor = + new BcPBESecretKeyDecryptorBuilder(new BcPGPDigestCalculatorProvider()) + .build(password.toCharArray()); + PGPPrivateKey pgpPrivKey = pgpSec.extractPrivateKey(decryptor); + BcPGPContentSignerBuilder builder = new BcPGPContentSignerBuilder( + pgpSec.getPublicKey().getAlgorithm(), PGPUtil.SHA1); + + PGPSignatureGenerator sGen = new PGPSignatureGenerator(builder); + sGen.init(PGPSignature.BINARY_DOCUMENT, pgpPrivKey); in = new FileInputStream(src); out = new BCPGOutputStream(new ArmoredOutputStream(new FileOutputStream(dest))); @@ -116,22 +125,10 @@ public class OpenPGPSignatureGenerator implements SignatureGenerator { } sGen.generate().encode(out); - } catch (SignatureException e) { - IOException ioexc = new IOException(); - ioexc.initCause(e); - throw ioexc; } catch (PGPException e) { IOException ioexc = new IOException(); ioexc.initCause(e); throw ioexc; - } catch (NoSuchAlgorithmException e) { - IOException ioexc = new IOException(); - ioexc.initCause(e); - throw ioexc; - } catch (NoSuchProviderException e) { - IOException ioexc = new IOException(); - ioexc.initCause(e); - throw ioexc; } finally { if (out != null) { try { @@ -156,7 +153,8 @@ public class OpenPGPSignatureGenerator implements SignatureGenerator { private PGPSecretKey readSecretKey(InputStream in) throws IOException, PGPException { in = PGPUtil.getDecoderStream(in); - PGPSecretKeyRingCollection pgpSec = new PGPSecretKeyRingCollection(in); + PGPSecretKeyRingCollection pgpSec = new PGPSecretKeyRingCollection(in, + new BcKeyFingerprintCalculator()); PGPSecretKey key = null; for (Iterator it = pgpSec.getKeyRings(); key == null && it.hasNext();) { -- 2.15.1 scm (mingw-w64): Update to 6.0.0. * gnu/packages/patches/mingw-w64-6.0.0-gcc.patch: New file. * gnu/packages/patches/mingw-w64-5.0rc2-gcc-4.9.3.patch: Delete it. * gnu/local.mk (dist_patch_DATA): Add new patch. Delete old patch. * gnu/build/cross-toolchain.scm (set-cross-path/mingw): Add additional autoconf-like substitutions. David Thompson 2019-08-22Merge branch 'master' into core-updatesMark H Weaver 2019-08-14gnu: mingw: Add x86_64 support....This patch parameterizes previously hard-coded instances of i686-w64-mingw32, adding support for x86_64-w64-mingw32. * gnu/packages/mingw.scm (make-mingw-w64): New procedure. (mingw-w64-i686, mingw-w64-x86_64): New variables. (%mingw-triplet): Remove. (mingw-w64): Update to point to 'mingw-w64-i686'. * gnu/packages/cross-base.scm (cross-gcc): Use 'libc' keyword argument if specified, instead of treating it as a boolean. (native-libc): Return the correct mingw-w64 depending on machine specified in target. * gnu/packages/bootstrap.scm (glibc-dynamic-linker): Add "x86_64-mingw". * gnu/build/cross-toolchain.scm (set-cross-path/mingw): Replace hardcoded 'i686-w64-mingw32' instances with 'target' keyword argument. (cross-gcc-build-phases): Update accordingly; use 'target-mingw?' implementation of target checking and add commentary. * gnu/ci.scm (%cross-targets): Add "x86_64-w64-mingw32". Carl Dong 2019-02-28gnu: GCC: Move cross-toolchain build fix to (gnu packages cross-base)....This makes sure it is inherited by packages using (cross-gcc ...). This commit is a followup to 01e8263febb9634564b4b73af49b81a36567a11b. * gnu/build/cross-toolchain.scm (cross-gcc-build-phases): Move 'treat-glibc-as-system-header' phase ... * gnu/packages/cross-base.scm (cross-gcc-arguments): ... here. Marius Bakke