Skip to content
Permalink
Browse files
IVY-1521: Update bouncycastle to 1.52
Thanks to Michal Srb
  • Loading branch information
hibnico committed Sep 6, 2015
1 parent 12e1aaf commit bb3ddfe426cf4ff5390f742d35bdba02a4ce7624
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 72 deletions.
@@ -1,45 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<classpath>
<classpathentry kind="src" path="src/java"/>
<classpathentry kind="src" path="test/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/ant.jar"/>
<classpathentry kind="lib" path="lib/ant-testutil.jar"/>
<classpathentry kind="lib" path="lib/commons-codec.jar"/>
<classpathentry kind="lib" path="lib/commons-httpclient.jar"/>
<classpathentry kind="lib" path="lib/commons-lang.jar"/>
<classpathentry kind="lib" path="lib/commons-logging.jar"/>
<classpathentry kind="lib" path="lib/commons-vfs.jar"/>
<classpathentry kind="lib" path="lib/jsch.jar"/>
<classpathentry kind="lib" path="lib/junit.jar"/>
<classpathentry kind="lib" path="lib/xmlunit.jar"/>
<classpathentry kind="lib" path="lib/oro.jar"/>
<classpathentry kind="lib" path="lib/bcpg-jdk14.jar"/>
<classpathentry kind="lib" path="lib/bcprov-jdk14.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.connector-factory.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.core.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.jsch.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.pageant.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.sshagent.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.usocket-jna.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.usocket-nc.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<classpath>
<classpathentry kind="src" path="src/java"/>
<classpathentry kind="src" path="test/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/ant.jar"/>
<classpathentry kind="lib" path="lib/ant-testutil.jar"/>
<classpathentry kind="lib" path="lib/commons-codec.jar"/>
<classpathentry kind="lib" path="lib/commons-httpclient.jar"/>
<classpathentry kind="lib" path="lib/commons-lang.jar"/>
<classpathentry kind="lib" path="lib/commons-logging.jar"/>
<classpathentry kind="lib" path="lib/commons-vfs.jar"/>
<classpathentry kind="lib" path="lib/jsch.jar"/>
<classpathentry kind="lib" path="lib/junit.jar"/>
<classpathentry kind="lib" path="lib/xmlunit.jar"/>
<classpathentry kind="lib" path="lib/oro.jar"/>
<classpathentry kind="lib" path="lib/bcpg-jdk15on.jar"/>
<classpathentry kind="lib" path="lib/bcprov-jdk15on.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.connector-factory.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.core.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.jsch.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.pageant.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.sshagent.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.usocket-jna.jar"/>
<classpathentry kind="lib" path="lib/jsch.agentproxy.usocket-nc.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
@@ -36,6 +36,7 @@ <h2>Announcement</h2>
configurability, and tight integration with Apache Ant.

Key features of this 2.5.0 release are
* Ivy nows uses BoucyCastle 1.52. Due to the non backward compatibility of that library, earlier versions are not supported.
* TODO
* TODO
* TODO
@@ -65,6 +66,7 @@ <h2>List of Changes in this Release</h2>
- FIX: useCacheOnly should allow lookup of changing dependencies in cache (IVY-1515) (Thanks to Ilya)

- IMPROVEMENT: Optimization: limit the revision numbers scanned if revision prefix is specified (Thanks to Ernestas Vaiciukevi&#269;ius)
- IMPROVEMENT: Update bouncycastle to 1.52 (IVY-1521) (Thanks to Michal Srb)

- NEW: Lets ssh-based resolvers use an ~/.ssh/config file to find username/hostname/keyfile options (Thanks to Colin Stanfill)
- NEW: Add ivy.maven.sources.lookup and ivy.maven.javadoc.lookup variables to control the lookup of the additional artifacts. Defaults to true, for backward compatibility (IVY-1529)
@@ -202,6 +204,7 @@ <h2>Committers and Contributors</h2>
<li>John Shields</li>
<li>Nihal Sinha</li>
<li>Gene Smith</li>
<li>Michal Srb</li>
<li>Colin Stanfill</li>
<li>Simon Steiner</li>
<li>Johan Stuyts</li>
@@ -53,8 +53,8 @@
<dependency org="com.jcraft" name="jsch.agentproxy" rev="0.0.6" conf="default,sftp->default" />
<dependency org="com.jcraft" name="jsch.agentproxy.connector-factory" rev="0.0.6" conf="default,sftp->default" />
<dependency org="com.jcraft" name="jsch.agentproxy.jsch" rev="0.0.6" conf="default,sftp->default" />
<dependency org="org.bouncycastle" name="bcpg-jdk14" rev="1.45" conf="default" />
<dependency org="org.bouncycastle" name="bcprov-jdk14" rev="1.45" conf="default" />
<dependency org="org.bouncycastle" name="bcpg-jdk15on" rev="1.52" conf="default" />
<dependency org="org.bouncycastle" name="bcprov-jdk15on" rev="1.52" conf="default" />

<!-- Test dependencies -->
<dependency org="junit" name="junit" rev="3.8.2" conf="test->default" />
@@ -23,10 +23,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Security;
import java.security.SignatureException;
import java.util.Iterator;

import org.apache.ivy.plugins.signer.SignatureGenerator;
@@ -41,6 +38,11 @@
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.BcKeyFingerprintCalculator;
import org.bouncycastle.openpgp.operator.bc.BcPBESecretKeyDecryptorBuilder;
import org.bouncycastle.openpgp.operator.bc.BcPGPContentSignerBuilder;
import org.bouncycastle.openpgp.operator.bc.BcPGPDigestCalculatorProvider;

public class OpenPGPSignatureGenerator implements SignatureGenerator {

@@ -101,11 +103,12 @@ public void sign(File src, File dest) throws IOException {
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);
PGPSignatureGenerator sGen = new PGPSignatureGenerator(new BcPGPContentSignerBuilder(
pgpSec.getPublicKey().getAlgorithm(), PGPUtil.SHA1));
sGen.init(PGPSignature.BINARY_DOCUMENT, pgpPrivKey);

in = new FileInputStream(src);
out = new BCPGOutputStream(new ArmoredOutputStream(new FileOutputStream(dest)));
@@ -116,22 +119,10 @@ public void sign(File src, File dest) throws IOException {
}

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,14 +147,16 @@ public void sign(File src, File dest) throws IOException {

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();) {
PGPSecretKeyRing kRing = (PGPSecretKeyRing) it.next();
for (Iterator<PGPSecretKeyRing> it = pgpSec.getKeyRings(); key == null && it.hasNext();) {
PGPSecretKeyRing kRing = it.next();

for (Iterator it2 = kRing.getSecretKeys(); key == null && it2.hasNext();) {
PGPSecretKey k = (PGPSecretKey) it2.next();
for (Iterator<PGPSecretKey> it2 = kRing.getSecretKeys(); key == null
&& it2.hasNext();) {
PGPSecretKey k = it2.next();
if ((keyId == null) && k.isSigningKey()) {
key = k;
}

0 comments on commit bb3ddfe

Please sign in to comment.