libcommons-openpgp-java/0000755000175000017500000000000010620447146014275 5ustar paulpaullibcommons-openpgp-java/pom.xml0000755000175000017500000000525210550005561015612 0ustar paulpaul 4.0.0 org.apache.commons commons-sandbox 1-SNAPSHOT commons-openpgp 1.0-SNAPSHOT Commons OpenPGP http://jakarta.apache.org/commons/sandbox/openpgp/ 2005 org.bouncycastle bcpg-jdk12 130 junit junit 3.8.1 test ant ant 1.6.5 compile ant ant-launcher 1.6.5 runtime src/main/resources true brett Brett Porter brett AT apache DOT org Apache +10 bodewig Stefan Bodewig bodewig AT apache DOT org Apache +1 scm:svn:http://svn.apache.org/repos/asf/jakarta/commons/sandbox/openpgp/trunk/ scm:svn:https://svn.apache.org/repos/asf/jakarta/commons/sandbox/openpgp/trunk/ http://svn.apache.org/repos/asf/jakarta/commons/sandbox/openpgp/trunk/ website Apache Website scp://people.apache.org/www/jakarta.apache.org/commons/sandbox/openpgp/ 1.3 1.3 libcommons-openpgp-java/src/0000755000175000017500000000000010620447145015063 5ustar paulpaullibcommons-openpgp-java/src/site/0000755000175000017500000000000010620447146016030 5ustar paulpaullibcommons-openpgp-java/src/site/apt/0000755000175000017500000000000010620447146016614 5ustar paulpaullibcommons-openpgp-java/src/site/apt/index.apt0000755000175000017500000000127010550006311020417 0ustar paulpaul ----- Home ----- Brett Porter ----- 10 December 2005 ----- Jakarta Commons OpenPGP Commons OpenPGP was started to produce a common and simple interface for generating and verifying OpenPGP signatures. Currently implemented using {{{http://www.bouncycastle.org} BouncyCastle}}, it is intended to allow pluggable providers so that alternate open source and commercial providers can be used. * History The library was started by Maven and Ant committers to enable the use of OpenPGP from these tools. Currently, Maven uses it in its development version to sign libraries released to the repository. * Using the Library * {{{usage.html} Usage Instructions}} libcommons-openpgp-java/src/site/apt/signer.apt0000644000175000017500000000761610552023307020614 0ustar paulpaul ----- Signer Ant Task ----- Antoine Levy-Lambert ----- 12 October 2006 ----- Signer Ant Task This task will be packaged in the commons-openpgp.jar. It will use the bouncy castle jars at runtime. It has been tested with bcpg-jdk12-134.jar and bcprov-jdk12-134.jar. The generated signatures can be verified with gpg. <<>> can sign one or several files at once. * <<>> *------------------+--------------------------------------------------------------------------+-------------------------------------------------+ | Attribute | Description | Required | *------------------+--------------------------------------------------------------------------+-------------------------------------------------+ | <<>> | Secret key ring file. | Yes | *------------------+--------------------------------------------------------------------------+-------------------------------------------------+ | <<>> | Public key ring file. | Yes | *------------------+--------------------------------------------------------------------------+-------------------------------------------------+ | <<>> | Password of the secret key ring. | Yes | *------------------+--------------------------------------------------------------------------+-------------------------------------------------+ | <<>> | Id of the key used to sign. | Yes | *------------------+--------------------------------------------------------------------------+-------------------------------------------------+ | <<>> | Boolean, defaults to true. | No | *------------------+--------------------------------------------------------------------------+-------------------------------------------------+ | <<>> | The file that you want to sign. | No, if fileset nested element present. | *------------------+--------------------------------------------------------------------------+-------------------------------------------------+ The task must also take either one or several nested <<>> element, or an <<>> attribute. ** <<>> nested element The task can take one or several fileset nested elements. See the {{{http://ant.apache.org/manual/CoreTypes/fileset.html} ant manual}} for an explanation. If you want to sign just one file, the <<>> attribute can be used instead. ** <<>> nested element The task may take a {{{http://ant.apache.org/manual/CoreTypes/mapper.html} mapper}} nested element. This nested element tells the task how the signature files should be called. If you do not supply this element, the signature files will be located in the same directory as the files that you sign. An ending of <<<.asc>>> will be appended to the file name for ascii armored output (the default). If you set <<>> to false, the ending will be <<<.sig>>> * example ----- ----- libcommons-openpgp-java/src/site/apt/usage.apt0000755000175000017500000000543210550006311020420 0ustar paulpaul ----- Usage ----- Brett Porter ----- 10 December 2005 ----- Usage Instructions Currently only creation and verification of detached signatures is supported. This can be done in streaming and non-streaming mode. Both modes require that you have created a key ring. * Creating a Key Ring A key ring object needs to be created, containing an input stream for both the public and secret key rings. The password for the secret key ring also needs to be passed in for creating signatures. For example, to create the Bouncy Castle key ring, the constructor is used: ----- BouncyCastleKeyRing( InputStream secretKeyRing, InputStream publicKeyRing, char[] password ); ----- * Non-streaming Mode ~~TODO: link to Javadoc To sign data with a detached signature, create a <<>>. ----- signer = new BouncyCastleOpenPgpSigner(); signer.detachedSign( getClass().getResourceAsStream( "/test-input" ), // binary input file signature, // outputstream for the signature keyId, // key ID keyRing, true ); // ascii armor ----- Verifying the signature is similar. ----- verifier = new BouncyCastleOpenPgpSignatureVerifier(); verifier.verifyDetachedSignature( getClass().getResourceAsStream( "/test-input" ), // binary input file signature, // inputstream for the signature keyRing, true ); // ascii armor ----- * Streaming Mode ~~TODO: link to Javadoc To sign data in streaming mode, create an instance of <<>>. The <<>> method is called on blocks of data to update the signautre. Finally, <<>> is called to receive the detached signature as a byte array. ----- signer = new BouncyCastleOpenPgpStreamingSigner( new FileOutputStream( "file.asc" ), // detached signature "ABC123D", // key ID keyRing, true ); // ascii armor? int len; do { len = read( buf ); if ( len > 0 ) { signer.update( buf ); } } while ( len >= 0 ); byte[] signature = signer.finish(); ----- To verify a signature in streaming mode is similar. ----- verifier = new BouncyCastleOpenPgpStreamingSignatureVerifier( new FileInputStream( "file.asc" ), // detached signature keyRing, true ); // ascii armor? int len; do { len = read( buf ); if ( len > 0 ) { verifier.update( buf ); } } while ( len >= 0 ); SignatureStatus status = verifier.finish(); ----- The <<>> returned indicates whether the signature was valid and whether it was trusted. libcommons-openpgp-java/src/site/site.xml0000755000175000017500000000074610550005521017515 0ustar paulpaul libcommons-openpgp-java/src/main/0000755000175000017500000000000010620447145016007 5ustar paulpaullibcommons-openpgp-java/src/main/resources/0000755000175000017500000000000010620447145020021 5ustar paulpaullibcommons-openpgp-java/src/main/resources/org/0000755000175000017500000000000010620447145020610 5ustar paulpaullibcommons-openpgp-java/src/main/resources/org/apache/0000755000175000017500000000000010620447145022031 5ustar paulpaullibcommons-openpgp-java/src/main/resources/org/apache/commons/0000755000175000017500000000000010620447145023504 5ustar paulpaullibcommons-openpgp-java/src/main/resources/org/apache/commons/openpgp/0000755000175000017500000000000010620447145025154 5ustar paulpaullibcommons-openpgp-java/src/main/resources/org/apache/commons/openpgp/ant/0000755000175000017500000000000010620447145025736 5ustar paulpaullibcommons-openpgp-java/src/main/resources/org/apache/commons/openpgp/ant/antlib.xml0000644000175000017500000000023210550004071027713 0ustar paulpaul libcommons-openpgp-java/src/main/java/0000755000175000017500000000000010620447143016726 5ustar paulpaullibcommons-openpgp-java/src/main/java/org/0000755000175000017500000000000010620447143017515 5ustar paulpaullibcommons-openpgp-java/src/main/java/org/apache/0000755000175000017500000000000010620447143020736 5ustar paulpaullibcommons-openpgp-java/src/main/java/org/apache/commons/0000755000175000017500000000000010620447143022411 5ustar paulpaullibcommons-openpgp-java/src/main/java/org/apache/commons/openpgp/0000755000175000017500000000000010620447145024063 5ustar paulpaullibcommons-openpgp-java/src/main/java/org/apache/commons/openpgp/BouncyCastleOpenPgpSigner.java0000644000175000017500000000370510533243442031764 0ustar paulpaulpackage org.apache.commons.openpgp; /* * 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. */ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** * Bouncy Castle implementation of the OpenPGP signer. * * @author Brett Porter */ public class BouncyCastleOpenPgpSigner implements OpenPgpSigner { private static final int BUFFER_SIZE = 1024; public void sign( InputStream data, OutputStream signedOutput, String keyId, KeyRing keyRing, boolean asciiArmor ) throws OpenPgpException { // TODO } public void detachedSign( InputStream data, OutputStream signature, String keyId, KeyRing keyRing, boolean asciiArmor ) throws OpenPgpException, IOException { OpenPgpStreamingSigner updater = new BouncyCastleOpenPgpStreamingSigner( signature, keyId, keyRing, asciiArmor ); byte[] buf = new byte[BUFFER_SIZE]; int len; do { len = data.read( buf ); if ( len > 0 ) { updater.update( buf, 0, len ); } } while ( len >= 0 ); updater.finish(); } } libcommons-openpgp-java/src/main/java/org/apache/commons/openpgp/BouncyCastleKeyRing.java0000644000175000017500000000743510533243442030620 0ustar paulpaulpackage org.apache.commons.openpgp; /* * 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. */ import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPPublicKey; import org.bouncycastle.openpgp.PGPPublicKeyRing; import org.bouncycastle.openpgp.PGPPublicKeyRingCollection; import org.bouncycastle.openpgp.PGPSecretKey; import org.bouncycastle.openpgp.PGPSecretKeyRing; import org.bouncycastle.openpgp.PGPSecretKeyRingCollection; import org.bouncycastle.openpgp.PGPUtil; import java.io.IOException; import java.io.InputStream; import java.util.Iterator; /** * Bouncy Castle implementation of the OpenPGP key ring. * * @author Brett Porter * @todo password is not secure */ public class BouncyCastleKeyRing implements KeyRing { private final PGPSecretKeyRingCollection pgpSec; private final char[] password; private final PGPPublicKeyRingCollection pgpPub; private static final long MASK = 0xFFFFFFFFL; public BouncyCastleKeyRing( InputStream secretKeyRingStream, InputStream publicKeyRingStream, char[] password ) throws IOException, PGPException { pgpSec = new PGPSecretKeyRingCollection( PGPUtil.getDecoderStream( secretKeyRingStream ) ); pgpPub = new PGPPublicKeyRingCollection( PGPUtil.getDecoderStream( publicKeyRingStream ) ); this.password = password; } public char[] getPassword() { return password; } public PGPSecretKey getSecretKey( String keyId ) { Iterator rIt = pgpSec.getKeyRings(); while ( rIt.hasNext() ) { PGPSecretKeyRing kRing = (PGPSecretKeyRing) rIt.next(); Iterator kIt = kRing.getSecretKeys(); while ( kIt.hasNext() ) { PGPSecretKey k = (PGPSecretKey) kIt.next(); // TODO: do long conversion in other direction if ( k.isSigningKey() && Long.toHexString( k.getKeyID() & MASK ).equals( keyId.toLowerCase() ) ) { return k; } } } return null; } public PGPPublicKey getPublicKey( String keyId ) { Iterator rIt = pgpPub.getKeyRings(); while ( rIt.hasNext() ) { PGPPublicKeyRing kRing = (PGPPublicKeyRing) rIt.next(); Iterator kIt = kRing.getPublicKeys(); while ( kIt.hasNext() ) { PGPPublicKey k = (PGPPublicKey) kIt.next(); // TODO: do long conversion in other direction if ( Long.toHexString( k.getKeyID() & MASK ).equals( keyId.toLowerCase() ) ) { return k; } } } return null; } public PGPSecretKey getSecretKey( long keyId ) { // TODO: switch with above return getSecretKey( Long.toHexString( keyId & MASK ) ); } public PGPPublicKey getPublicKey( long keyId ) { // TODO: switch with above return getPublicKey( Long.toHexString( keyId & MASK ) ); } } libcommons-openpgp-java/src/main/java/org/apache/commons/openpgp/ant/0000755000175000017500000000000010620447144024644 5ustar paulpaullibcommons-openpgp-java/src/main/java/org/apache/commons/openpgp/ant/OpenPgpSignerTask.java0000644000175000017500000001612510550004071031045 0ustar paulpaul/* * 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. */ package org.apache.commons.openpgp.ant; import org.apache.tools.ant.Task; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.util.FileNameMapper; import org.apache.tools.ant.util.GlobPatternMapper; import org.apache.tools.ant.util.FileUtils; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.Mapper; import org.apache.commons.openpgp.*; import org.bouncycastle.openpgp.PGPException; import java.io.*; import java.util.Collection; import java.util.ArrayList; import java.util.Iterator; /** */ public class OpenPgpSignerTask extends Task { private File secring; private File pubring; private String password; private String keyId; private Collection tosign = new ArrayList(); private File artefact; private boolean asciiarmor = true; private Mapper mapperElement; /** * set the secret keyring * @param secring secret keyring file */ public void setSecring(File secring) { this.secring = secring; } /** * set the public keyring * @param pubring public keyring file */ public void setPubring(File pubring) { this.pubring = pubring; } /** * set the key id * @param keyId */ public void setKeyId(String keyId) { this.keyId = keyId; } /** * asciiarmor the signature ? * @param asciiarmor ascii armored signature ? */ public void setAsciiarmor(boolean asciiarmor) { this.asciiarmor = asciiarmor; } /** * set the value of the password * @param password value of the password */ public void setPassword(String password) { this.password = password; } /** * artefact to be signed * @param artefact artefact to be signed */ public void setArtefact(File artefact) { this.artefact = artefact; } public void add(FileSet fs) { tosign.add(fs); } /** * Define the mapper to map source to destination files. * @return a mapper to be configured. * @exception org.apache.tools.ant.BuildException if more than one mapper is defined. */ public Mapper createMapper() throws BuildException { if (mapperElement != null) { throw new BuildException("Cannot define more than one mapper", getLocation()); } mapperElement = new Mapper(getProject()); return mapperElement; } public void execute() { if (secring == null) { throw new BuildException("secring attribute compulsory"); } if (pubring == null) { throw new BuildException("pubring attribute compulsory"); } if (password == null) { throw new BuildException("password attribute compulsory"); } if (tosign.size() == 0 && artefact == null) { throw new BuildException("supply the attribute tosign or one nested fileset"); } if (!secring.exists() || !secring.canRead()) { throw new BuildException("secret keyring file does not exist or is not readable"); } if (!pubring.exists() || !pubring.canRead()) { throw new BuildException("public keyring file does not exist or is not readable"); } FileInputStream secStream; FileInputStream pubStream; KeyRing keyRing = null; try { secStream = new FileInputStream(secring); pubStream = new FileInputStream(pubring); keyRing = new BouncyCastleKeyRing(secStream, pubStream, password.toCharArray() ); } catch (IOException ioe) { throw new BuildException(ioe); } catch (PGPException pgpe) { throw new BuildException(pgpe); } if (artefact != null) { dosign(keyRing, artefact); } if (tosign.size() != 0) { for (Iterator it = tosign.iterator(); it.hasNext(); ) { FileSet fs = (FileSet) it.next(); dosign(keyRing, fs); } } FileUtils.close(secStream); FileUtils.close(pubStream); } private void dosign(KeyRing keyRing, FileSet fs) { DirectoryScanner ds = fs.getDirectoryScanner(getProject()); String[] artefacts = ds.getIncludedFiles(); for (int counter = 0; counter < artefacts.length; counter++) { dosign(keyRing, new File(fs.getDir(getProject()), artefacts[counter]), fs.getDir(getProject()), artefacts[counter]); } } private void dosign(KeyRing keyRing, File oneartefact) { dosign(keyRing, oneartefact, oneartefact.getParentFile(), oneartefact.getName()); } private void dosign(KeyRing keyRing, File oneartefact, File basedir, String relpath) { FileInputStream fis = null; FileOutputStream fos = null; File signature; try { fis = new FileInputStream(oneartefact); FileNameMapper mapper = getMapper(); String [] mappedFiles = mapper.mapFileName(relpath); if (mappedFiles == null || mappedFiles.length != 1) { throw new BuildException("mapper returned more or less than one output"); } signature = new File(basedir, mappedFiles[0]); fos = new FileOutputStream(signature); OpenPgpSigner signer = new BouncyCastleOpenPgpSigner(); signer.detachedSign(fis, fos, keyId, keyRing, asciiarmor); } catch (FileNotFoundException fnfe) { throw new BuildException(fnfe); } catch (IOException ioe) { throw new BuildException(ioe); } catch (OpenPgpException opgpe) { throw new BuildException(opgpe); } FileUtils.close(fos); FileUtils.close(fis); } /** * returns the mapper to use based on nested elements or the */ private FileNameMapper getMapper() { FileNameMapper mapper = null; if (mapperElement != null) { mapper = mapperElement.getImplementation(); } else { mapper = new GlobPatternMapper(); mapper.setFrom("*"); if (asciiarmor) { mapper.setTo("*.asc"); } else { mapper.setTo("*.sig"); } } return mapper; } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibcommons-openpgp-java/src/main/java/org/apache/commons/openpgp/BouncyCastleOpenPgpStreamingSignatureVerifier.javalibcommons-openpgp-java/src/main/java/org/apache/commons/openpgp/BouncyCastleOpenPgpStreamingSignatu0000644000175000017500000001173310533243442033101 0ustar paulpaulpackage org.apache.commons.openpgp; /* * 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. */ import org.bouncycastle.bcpg.BCPGOutputStream; import org.bouncycastle.bcpg.ArmoredInputStream; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPSignature; import org.bouncycastle.openpgp.PGPSignatureGenerator; import org.bouncycastle.openpgp.PGPUtil; import org.bouncycastle.openpgp.PGPObjectFactory; import org.bouncycastle.openpgp.PGPSignatureList; import org.bouncycastle.openpgp.PGPCompressedData; import org.bouncycastle.openpgp.PGPPublicKey; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.InputStream; import java.security.NoSuchProviderException; import java.security.Security; import java.security.SignatureException; /** * Bouncy Castle implementation of the OpenPGP signer. * * @author Brett Porter */ public class BouncyCastleOpenPgpStreamingSignatureVerifier implements OpenPgpStreamingSignatureVerifier { private static final String PROVIDER = "BC"; private PGPSignature sig; public BouncyCastleOpenPgpStreamingSignatureVerifier( InputStream signature, KeyRing keyRing, boolean asciiArmor ) throws OpenPgpException, IOException { init( asciiArmor, signature, keyRing ); } private void init( boolean asciiArmor, InputStream signature, KeyRing keyRing ) throws OpenPgpException, IOException { // TODO: better location for this? Security.addProvider( new BouncyCastleProvider() ); try { signature = PGPUtil.getDecoderStream( signature ); if ( asciiArmor ) { signature = new ArmoredInputStream( signature ); } PGPObjectFactory pgpFact = new PGPObjectFactory( signature ); PGPSignatureList p3; Object o = pgpFact.nextObject(); if ( o instanceof PGPCompressedData ) { PGPCompressedData c1 = (PGPCompressedData) o; pgpFact = new PGPObjectFactory( c1.getDataStream() ); p3 = (PGPSignatureList) pgpFact.nextObject(); } else { p3 = (PGPSignatureList) o; } sig = p3.get( 0 ); PGPPublicKey key = keyRing.getPublicKey( sig.getKeyID() ); sig.initVerify( key, "BC" ); } catch ( NoSuchProviderException e ) { throw new OpenPgpException( "Unable to find the correct provider for PGP - check that the Bouncy Castle provider is correctly installed", e ); } catch ( PGPException e ) { // TODO: more details throw new OpenPgpException( "Error calculating detached signature", e ); } } public void update( byte[] buf ) throws OpenPgpException { update( buf, 0, buf.length ); } public void update( byte[] buf, int offset, int length ) throws OpenPgpException { try { sig.update( buf, offset, length ); } catch ( SignatureException e ) { // TODO: more details throw new OpenPgpException( "Error calculating detached signature", e ); } } public SignatureStatus finish() throws OpenPgpException, IOException { try { if ( sig.verify() ) { // TODO: how do we assess trust? return SignatureStatus.VALID_UNTRUSTED; } else { return SignatureStatus.INVALID; } } catch ( PGPException e ) { // TODO: more details throw new OpenPgpException( "Error calculating detached signature", e ); } catch ( SignatureException e ) { // TODO: more details throw new OpenPgpException( "Error calculating detached signature", e ); } } public SignatureStatus verify() { return null; //To change body of implemented methods use File | Settings | File Templates. } } libcommons-openpgp-java/src/main/java/org/apache/commons/openpgp/OpenPgpSigner.java0000644000175000017500000000444310533243442027450 0ustar paulpaulpackage org.apache.commons.openpgp; /* * 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. */ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** * Interface for signing data with OpenPGP. * * @author Brett Porter * @todo perhaps should have different interface methods for the default key * @todo should the exception be a signature exception instead of a common one? */ public interface OpenPgpSigner { String ROLE = OpenPgpSigner.class.getName(); /** * Sign a piece of data with the given key. * * @param data the data to sign * @param signedOutput the signed output data * @param keyId the key ID of the key used to sign it * @param keyRing the keyring containing the key above * @param asciiArmor whether to ascii armor the output */ void sign( InputStream data, OutputStream signedOutput, String keyId, KeyRing keyRing, boolean asciiArmor ) throws OpenPgpException; /** * Sign a piece of data with the given key, storing the signature in a detached output. * * @param data the data to sign * @param signature the detached signature * @param keyId the key ID of the key used to sign it * @param keyRing the keyring containing the key above * @param asciiArmor whether to ascii armor the output */ void detachedSign( InputStream data, OutputStream signature, String keyId, KeyRing keyRing, boolean asciiArmor ) throws OpenPgpException, IOException; } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibcommons-openpgp-java/src/main/java/org/apache/commons/openpgp/OpenPgpStreamingSignatureVerifier.javalibcommons-openpgp-java/src/main/java/org/apache/commons/openpgp/OpenPgpStreamingSignatureVerifier.j0000644000175000017500000000425410533243442033040 0ustar paulpaulpackage org.apache.commons.openpgp; /* * 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. */ import java.io.IOException; /** * An interface for updating an OpenPGP signature on the fly with streaming data. * * @author Brett Porter */ public interface OpenPgpStreamingSignatureVerifier { String ROLE = OpenPgpStreamingSignatureVerifier.class.getName(); /** * Update the signature with the next block from the data buffer. * * @param buf the buffer * @throws org.apache.commons.openpgp.OpenPgpException if the buffer is not valid for updating the signature */ void update( byte[] buf ) throws OpenPgpException; /** * Update the signature with the next block from the data buffer. * * @param buf the buffer * @param offset offset within the buffer to start from * @param length number of bytes in the buffer to read from * @throws org.apache.commons.openpgp.OpenPgpException if the buffer is not valid for updating the signature */ void update( byte[] buf, int offset, int length ) throws OpenPgpException; /** * Finish and verify the signature that has been obtained. * * @return the status of the signature * @throws org.apache.commons.openpgp.OpenPgpException if the signature is not in a consistent or complete state */ SignatureStatus finish() throws OpenPgpException, IOException; } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibcommons-openpgp-java/src/main/java/org/apache/commons/openpgp/BouncyCastleOpenPgpStreamingSigner.javalibcommons-openpgp-java/src/main/java/org/apache/commons/openpgp/BouncyCastleOpenPgpStreamingSigner.0000644000175000017500000001201310533243442032764 0ustar paulpaulpackage org.apache.commons.openpgp; /* * 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. */ import org.bouncycastle.bcpg.ArmoredOutputStream; import org.bouncycastle.bcpg.BCPGOutputStream; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPPrivateKey; import org.bouncycastle.openpgp.PGPSecretKey; import org.bouncycastle.openpgp.PGPSignature; import org.bouncycastle.openpgp.PGPSignatureGenerator; import org.bouncycastle.openpgp.PGPUtil; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import java.security.Security; import java.security.SignatureException; /** * Bouncy Castle implementation of the OpenPGP signer. * * @author Brett Porter */ public class BouncyCastleOpenPgpStreamingSigner implements OpenPgpStreamingSigner { private static final String PROVIDER = "BC"; private PGPSignatureGenerator sGen; private final ByteArrayOutputStream signatureBytes; private BCPGOutputStream bOut; public BouncyCastleOpenPgpStreamingSigner( String keyId, KeyRing keyRing, boolean asciiArmor ) throws OpenPgpException { signatureBytes = new ByteArrayOutputStream(); init( asciiArmor, signatureBytes, keyRing, keyId ); } public BouncyCastleOpenPgpStreamingSigner( OutputStream signature, String keyId, KeyRing keyRing, boolean asciiArmor ) throws OpenPgpException { signatureBytes = null; init( asciiArmor, signature, keyRing, keyId ); } private void init( boolean asciiArmor, OutputStream signature, KeyRing keyRing, String keyId ) throws OpenPgpException { // TODO: better location for this? Security.addProvider( new BouncyCastleProvider() ); OutputStream out; if ( asciiArmor ) { out = new ArmoredOutputStream( signature ); } else { out = signature; } bOut = new BCPGOutputStream( out ); try { PGPSecretKey pgpSec = keyRing.getSecretKey( keyId ); PGPPrivateKey pgpPrivKey = pgpSec.extractPrivateKey( keyRing.getPassword(), PROVIDER ); sGen = new PGPSignatureGenerator( pgpSec.getPublicKey().getAlgorithm(), PGPUtil.SHA1, PROVIDER ); sGen.initSign( PGPSignature.BINARY_DOCUMENT, pgpPrivKey ); } catch ( NoSuchAlgorithmException e ) { throw new OpenPgpException( "Unable to find the correct algorithm for PGP - check that the Bouncy Castle provider is correctly installed", e ); } catch ( NoSuchProviderException e ) { throw new OpenPgpException( "Unable to find the correct provider for PGP - check that the Bouncy Castle provider is correctly installed", e ); } catch ( PGPException e ) { // TODO: more details throw new OpenPgpException( "Error calculating detached signature", e ); } } public void update( byte[] buf ) throws OpenPgpException { update( buf, 0, buf.length ); } public void update( byte[] buf, int offset, int length ) throws OpenPgpException { try { sGen.update( buf, offset, length ); } catch ( SignatureException e ) { // TODO: more details throw new OpenPgpException( "Error calculating detached signature", e ); } } public byte[] finish() throws OpenPgpException, IOException { try { sGen.generate().encode( bOut ); } catch ( PGPException e ) { // TODO: more details throw new OpenPgpException( "Error calculating detached signature", e ); } catch ( SignatureException e ) { // TODO: more details throw new OpenPgpException( "Error calculating detached signature", e ); } bOut.close(); return signatureBytes != null ? signatureBytes.toByteArray() : null; } } libcommons-openpgp-java/src/main/java/org/apache/commons/openpgp/SignatureStatus.java0000644000175000017500000000420510533243442030071 0ustar paulpaulpackage org.apache.commons.openpgp; /* * 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. */ /** * Enumerated type indicating the status of data that was signed. *

* Values: *

    *
  • VALID_TRUSTED
  • *
  • VALID_UNTRUSTED
  • *
  • INVALID
  • *
* * @author Brett Porter * @todo incorporate levels of trust */ public class SignatureStatus { /** * Status that indicates the signature is valid, and from a trusted source. */ public static SignatureStatus VALID_TRUSTED = new SignatureStatus( true, true ); /** * Status that indicates the signature is valid, but from an unknown or untrusted source. */ public static SignatureStatus VALID_UNTRUSTED = new SignatureStatus( true, false ); /** * Status that indicates the signature is invalid. */ public static SignatureStatus INVALID = new SignatureStatus( false, false ); /** * Whether the signature is valid. */ private final boolean valid; /** * Whether the signature is trusted. */ private final boolean trusted; private SignatureStatus( boolean valid, boolean trusted ) { this.valid = valid; this.trusted = trusted; } public boolean isValid() { return valid; } public boolean isTrusted() { return trusted; } } libcommons-openpgp-java/src/main/java/org/apache/commons/openpgp/UnknownKeyException.java0000644000175000017500000000240710533243442030715 0ustar paulpaulpackage org.apache.commons.openpgp; /* * 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. */ /** * An exception occurring during the verification of a signature, when the key is not found in the keyring. * * @author Brett Porter */ public class UnknownKeyException extends OpenPgpException { public UnknownKeyException( String message ) { super( message ); } public UnknownKeyException( String message, Throwable cause ) { super( message, cause ); } } libcommons-openpgp-java/src/main/java/org/apache/commons/openpgp/OpenPgpException.java0000644000175000017500000000250210533243442030151 0ustar paulpaulpackage org.apache.commons.openpgp; /* * 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. */ /** * An exception occurring during the use of the OpenPGP library. * * @author Brett Porter */ public class OpenPgpException extends Exception { private Throwable cause; public OpenPgpException( String message ) { super( message ); } public OpenPgpException( String message, Throwable cause ) { super( message ); this.cause = cause; } public Throwable getCause() { return cause; } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibcommons-openpgp-java/src/main/java/org/apache/commons/openpgp/BouncyCastleOpenPgpSignatureVerifier.javalibcommons-openpgp-java/src/main/java/org/apache/commons/openpgp/BouncyCastleOpenPgpSignatureVerifie0000644000175000017500000000416210533243442033066 0ustar paulpaulpackage org.apache.commons.openpgp; /* * 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. */ import java.io.IOException; import java.io.InputStream; /** * Verify signatures using the Bouncy Castle OpenPGP provider. * * @author Brett Porter */ public class BouncyCastleOpenPgpSignatureVerifier implements OpenPgpSignatureVerifier { private static final int BUFFER_SIZE = 1024; public SignatureStatus verifySignature( InputStream data, KeyRing keyRing ) throws OpenPgpException, UnknownKeyException { // TODO: implement return null; //To change body of implemented methods use File | Settings | File Templates. } public SignatureStatus verifyDetachedSignature( InputStream data, InputStream signature, KeyRing keyRing, boolean asciiArmored ) throws OpenPgpException, UnknownKeyException, IOException { OpenPgpStreamingSignatureVerifier verifier = new BouncyCastleOpenPgpStreamingSignatureVerifier( signature, keyRing, asciiArmored ); byte[] buf = new byte[BUFFER_SIZE]; int len; do { len = data.read( buf ); if ( len > 0 ) { verifier.update( buf, 0, len ); } } while ( len >= 0 ); return verifier.finish(); } } libcommons-openpgp-java/src/main/java/org/apache/commons/openpgp/KeyRing.java0000644000175000017500000000335610533243442026302 0ustar paulpaulpackage org.apache.commons.openpgp; /* * 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. */ import org.bouncycastle.openpgp.PGPPublicKey; import org.bouncycastle.openpgp.PGPSecretKey; /** * Interface describing a key ring for use in signing or verifying data. * * @author Brett Porter */ public interface KeyRing { String ROLE = KeyRing.class.getName(); /** * @return * @todo seems like the wrong place */ char[] getPassword(); /** * @param keyId * @return * @todo remove BC specifics */ PGPSecretKey getSecretKey( String keyId ); /** * @param keyId * @return * @todo remove BC specifics */ PGPPublicKey getPublicKey( String keyId ); /** * @param keyId * @return * @todo remove BC specifics */ PGPSecretKey getSecretKey( long keyId ); /** * @param keyId * @return * @todo remove BC specifics */ PGPPublicKey getPublicKey( long keyId ); } libcommons-openpgp-java/src/main/java/org/apache/commons/openpgp/OpenPgpSignatureVerifier.java0000644000175000017500000000425710533243442031661 0ustar paulpaulpackage org.apache.commons.openpgp; /* * 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. */ import java.io.IOException; import java.io.InputStream; /** * Interface for verifying data signed with OpenPGP. * * @author Brett Porter * @todo perhaps should have different interface methods for the default key * @todo should the exception be a verification exception instead of a common one? */ public interface OpenPgpSignatureVerifier { String ROLE = OpenPgpSignatureVerifier.class.getName(); /** * Verify a piece of data that was signed with OpenPGP. * * @param data the data that was signed * @param keyRing the keyring containing the key used to sign the data */ SignatureStatus verifySignature( InputStream data, KeyRing keyRing ) throws OpenPgpException, UnknownKeyException; /** * Verify a piece of data against a detached signature. * * @param data the data to that was signed * @param signature the detached signature to verify against the data * @param keyRing the keyring containing the key used to sign the data * @param asciiArmored whether the signature is ascii armored */ SignatureStatus verifyDetachedSignature( InputStream data, InputStream signature, KeyRing keyRing, boolean asciiArmored ) throws OpenPgpException, UnknownKeyException, IOException; } libcommons-openpgp-java/src/main/java/org/apache/commons/openpgp/OpenPgpStreamingSigner.java0000644000175000017500000000403710533243442031321 0ustar paulpaulpackage org.apache.commons.openpgp; /* * 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. */ import java.io.IOException; /** * An interface for updating an OpenPGP signature on the fly with streaming data. * * @author Brett Porter */ public interface OpenPgpStreamingSigner { String ROLE = OpenPgpStreamingSigner.class.getName(); /** * Update the signature with the next block from the data buffer. * * @param buf the buffer * @throws OpenPgpException if the buffer is not valid for updating the signature */ void update( byte[] buf ) throws OpenPgpException; /** * Update the signature with the next block from the data buffer. * * @param buf the buffer * @param offset offset within the buffer to start from * @param length number of bytes in the buffer to read from * @throws OpenPgpException if the buffer is not valid for updating the signature */ void update( byte[] buf, int offset, int length ) throws OpenPgpException; /** * Finish creating the signature. * * @return the completed signature * @throws OpenPgpException if the signature is not in a consistent or complete state */ byte[] finish() throws OpenPgpException, IOException; } libcommons-openpgp-java/src/test/0000755000175000017500000000000010620447143016040 5ustar paulpaullibcommons-openpgp-java/src/test/resources/0000755000175000017500000000000010620447143020052 5ustar paulpaullibcommons-openpgp-java/src/test/resources/test-input0000644000175000017500000000062710345740566022127 0ustar paulpaulThe quick brown fox jumps over the lazy dog quick brown fox jumps over the lazy dog The brown fox jumps over the lazy dog The quick fox jumps over the lazy dog The quick brown jumps over the lazy dog The quick brown fox over the lazy dog The quick brown fox jumps the lazy dog The quick brown fox jumps over lazy dog The quick brown fox jumps over the dog The quick brown fox jumps over the lazy libcommons-openpgp-java/src/test/resources/pubring.gpg0000644000175000017500000000165510345414027022225 0ustar paulpaulCQA? sgN١.֔]fsIl6K?5}(CM *9 ˩HAfȲ[𦲇̈́%bI*sU'K*)On_Vp>!n!p> 933'WMG6@OO\/"g|18 XYAîPr 7~[NyYUlV&&IK;NslL<˹8Kcommons-openpgp (Commons OpenPGP Test Key) ^CQA  N2k$=~1.ZtIe@ L.4#F CQBllJ{9nV/Qдwulj(y ԪA<1`?+3Tu^|_MF@tdKF84nfOPi*b`[zh/!& jC&s-F#Ӑ^ft e5v)r˂k28nG4y|-޴K%8FšJ15^RwgsW50lDy. 0|J=۹u%GψI CQB N2kz{T@\Jw16mN1ScXpzspalibcommons-openpgp-java/src/test/resources/test-signature.bpg0000644000175000017500000000010110345510012023500 0ustar paulpaul?CN2k9!n!p> 933'WMG6@OO\/"g|18 XYAîPr 7~[NyYUlV&&IK;NslL<˹89N@`K̯qmJS+.Hy!/`9J-z}>nKcommons-openpgp (Commons OpenPGP Test Key) ^CQA  N2k$RMl +pJMV_tÙsMXCQBllJ{9nV/Qдwulj(y ԪA<1`?+3Tu^|_MF@tdKF84nfOPi*b`[zh/!& jC&s-F#Ӑ^ft e5v)r˂k28nG4y|-޴K%8FšJ15^RwgsW50lDy. 0|J=۹u%G9N@`4Ͷ=EsQ:iqFNH pj/S /'y-?Q5I CQB N2kzl5/P ?_v S2qV libcommons-openpgp-java/src/test/resources/test-signature.asc0000644000175000017500000000027210345414027023520 0ustar paulpaul-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Cygwin) iD8DBQBDlVJdTusOMqfRa9QRAuxXAJ9k0G+f2tbO6eTuBQS1uim44aADVwCgxS3i MH8RP0v17V5sM1WN8ih97n8= =gPJ5 -----END PGP SIGNATURE----- libcommons-openpgp-java/src/test/java/0000755000175000017500000000000010620447142016760 5ustar paulpaullibcommons-openpgp-java/src/test/java/org/0000755000175000017500000000000010620447142017547 5ustar paulpaullibcommons-openpgp-java/src/test/java/org/apache/0000755000175000017500000000000010620447142020770 5ustar paulpaullibcommons-openpgp-java/src/test/java/org/apache/commons/0000755000175000017500000000000010620447142022443 5ustar paulpaullibcommons-openpgp-java/src/test/java/org/apache/commons/openpgp/0000755000175000017500000000000010620447143024114 5ustar paulpaullibcommons-openpgp-java/src/test/java/org/apache/commons/openpgp/BouncyCastleOpenPgpSignerTest.java0000644000175000017500000000624610533243442032662 0ustar paulpaulpackage org.apache.commons.openpgp; /* * 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. */ import junit.framework.TestCase; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; /** * Test the open pgp signer. * * @author Brett Porter * @todo test text input as well as binary - apparently it fails cross platform */ public class BouncyCastleOpenPgpSignerTest extends TestCase { private OpenPgpSigner signer = new BouncyCastleOpenPgpSigner(); private OpenPgpSignatureVerifier verifier = new BouncyCastleOpenPgpSignatureVerifier(); private String keyId = "A7D16BD4"; private KeyRing keyRing; private static final String PASSWORD = "cop"; protected void setUp() throws Exception { super.setUp(); keyRing = new BouncyCastleKeyRing( getClass().getResourceAsStream( "/secring.gpg" ), getClass().getResourceAsStream( "/pubring.gpg" ), PASSWORD.toCharArray() ); } public void testSignDataDetachedBinary() throws OpenPgpException, IOException { ByteArrayOutputStream signature = new ByteArrayOutputStream(); signer.detachedSign( getClass().getResourceAsStream( "/test-input" ), signature, keyId, keyRing, false ); // TODO: can we get it to verify an ascii armored one? SignatureStatus status = verifier.verifyDetachedSignature( getClass().getResourceAsStream( "/test-input" ), new ByteArrayInputStream( signature.toByteArray() ), keyRing, false ); assertNotNull( "check we got a status", status ); assertTrue( "check it was successful", status.isValid() ); } public void testVerifySignatureDetachedBinary() throws IOException, OpenPgpException { // TODO: can we get it to verify an ascii armored one? SignatureStatus status = verifier.verifyDetachedSignature( getClass().getResourceAsStream( "/test-input" ), getClass().getResourceAsStream( "/test-signature.bpg" ), keyRing, false ); assertNotNull( "check we got a status", status ); assertTrue( "check it was successful", status.isValid() ); } } libcommons-openpgp-java/NOTICE.txt0000644000175000017500000000027010533243563016016 0ustar paulpaulApache Jakarta Commons OpenPGP Copyright 2005-2006 The Apache Software Foundation This product includes software developed by The Apache Software Foundation (http://www.apache.org/). libcommons-openpgp-java/LICENSE.txt0000644000175000017500000002676610250074051016127 0ustar paulpaul/* * Apache License * Version 2.0, January 2004 * http://www.apache.org/licenses/ * * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION * * 1. Definitions. * * "License" shall mean the terms and conditions for use, reproduction, * and distribution as defined by Sections 1 through 9 of this document. * * "Licensor" shall mean the copyright owner or entity authorized by * the copyright owner that is granting the License. * * "Legal Entity" shall mean the union of the acting entity and all * other entities that control, are controlled by, or are under common * control with that entity. For the purposes of this definition, * "control" means (i) the power, direct or indirect, to cause the * direction or management of such entity, whether by contract or * otherwise, or (ii) ownership of fifty percent (50%) or more of the * outstanding shares, or (iii) beneficial ownership of such entity. * * "You" (or "Your") shall mean an individual or Legal Entity * exercising permissions granted by this License. * * "Source" form shall mean the preferred form for making modifications, * including but not limited to software source code, documentation * source, and configuration files. * * "Object" form shall mean any form resulting from mechanical * transformation or translation of a Source form, including but * not limited to compiled object code, generated documentation, * and conversions to other media types. * * "Work" shall mean the work of authorship, whether in Source or * Object form, made available under the License, as indicated by a * copyright notice that is included in or attached to the work * (an example is provided in the Appendix below). * * "Derivative Works" shall mean any work, whether in Source or Object * form, that is based on (or derived from) the Work and for which the * editorial revisions, annotations, elaborations, or other modifications * represent, as a whole, an original work of authorship. For the purposes * of this License, Derivative Works shall not include works that remain * separable from, or merely link (or bind by name) to the interfaces of, * the Work and Derivative Works thereof. * * "Contribution" shall mean any work of authorship, including * the original version of the Work and any modifications or additions * to that Work or Derivative Works thereof, that is intentionally * submitted to Licensor for inclusion in the Work by the copyright owner * or by an individual or Legal Entity authorized to submit on behalf of * the copyright owner. For the purposes of this definition, "submitted" * means any form of electronic, verbal, or written communication sent * to the Licensor or its representatives, including but not limited to * communication on electronic mailing lists, source code control systems, * and issue tracking systems that are managed by, or on behalf of, the * Licensor for the purpose of discussing and improving the Work, but * excluding communication that is conspicuously marked or otherwise * designated in writing by the copyright owner as "Not a Contribution." * * "Contributor" shall mean Licensor and any individual or Legal Entity * on behalf of whom a Contribution has been received by Licensor and * subsequently incorporated within the Work. * * 2. Grant of Copyright License. Subject to the terms and conditions of * this License, each Contributor hereby grants to You a perpetual, * worldwide, non-exclusive, no-charge, royalty-free, irrevocable * copyright license to reproduce, prepare Derivative Works of, * publicly display, publicly perform, sublicense, and distribute the * Work and such Derivative Works in Source or Object form. * * 3. Grant of Patent License. Subject to the terms and conditions of * this License, each Contributor hereby grants to You a perpetual, * worldwide, non-exclusive, no-charge, royalty-free, irrevocable * (except as stated in this section) patent license to make, have made, * use, offer to sell, sell, import, and otherwise transfer the Work, * where such license applies only to those patent claims licensable * by such Contributor that are necessarily infringed by their * Contribution(s) alone or by combination of their Contribution(s) * with the Work to which such Contribution(s) was submitted. If You * institute patent litigation against any entity (including a * cross-claim or counterclaim in a lawsuit) alleging that the Work * or a Contribution incorporated within the Work constitutes direct * or contributory patent infringement, then any patent licenses * granted to You under this License for that Work shall terminate * as of the date such litigation is filed. * * 4. Redistribution. You may reproduce and distribute copies of the * Work or Derivative Works thereof in any medium, with or without * modifications, and in Source or Object form, provided that You * meet the following conditions: * * (a) You must give any other recipients of the Work or * Derivative Works a copy of this License; and * * (b) You must cause any modified files to carry prominent notices * stating that You changed the files; and * * (c) You must retain, in the Source form of any Derivative Works * that You distribute, all copyright, patent, trademark, and * attribution notices from the Source form of the Work, * excluding those notices that do not pertain to any part of * the Derivative Works; and * * (d) If the Work includes a "NOTICE" text file as part of its * distribution, then any Derivative Works that You distribute must * include a readable copy of the attribution notices contained * within such NOTICE file, excluding those notices that do not * pertain to any part of the Derivative Works, in at least one * of the following places: within a NOTICE text file distributed * as part of the Derivative Works; within the Source form or * documentation, if provided along with the Derivative Works; or, * within a display generated by the Derivative Works, if and * wherever such third-party notices normally appear. The contents * of the NOTICE file are for informational purposes only and * do not modify the License. You may add Your own attribution * notices within Derivative Works that You distribute, alongside * or as an addendum to the NOTICE text from the Work, provided * that such additional attribution notices cannot be construed * as modifying the License. * * You may add Your own copyright statement to Your modifications and * may provide additional or different license terms and conditions * for use, reproduction, or distribution of Your modifications, or * for any such Derivative Works as a whole, provided Your use, * reproduction, and distribution of the Work otherwise complies with * the conditions stated in this License. * * 5. Submission of Contributions. Unless You explicitly state otherwise, * any Contribution intentionally submitted for inclusion in the Work * by You to the Licensor shall be under the terms and conditions of * this License, without any additional terms or conditions. * Notwithstanding the above, nothing herein shall supersede or modify * the terms of any separate license agreement you may have executed * with Licensor regarding such Contributions. * * 6. Trademarks. This License does not grant permission to use the trade * names, trademarks, service marks, or product names of the Licensor, * except as required for reasonable and customary use in describing the * origin of the Work and reproducing the content of the NOTICE file. * * 7. Disclaimer of Warranty. Unless required by applicable law or * agreed to in writing, Licensor provides the Work (and each * Contributor provides its Contributions) on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied, including, without limitation, any warranties or conditions * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A * PARTICULAR PURPOSE. You are solely responsible for determining the * appropriateness of using or redistributing the Work and assume any * risks associated with Your exercise of permissions under this License. * * 8. Limitation of Liability. In no event and under no legal theory, * whether in tort (including negligence), contract, or otherwise, * unless required by applicable law (such as deliberate and grossly * negligent acts) or agreed to in writing, shall any Contributor be * liable to You for damages, including any direct, indirect, special, * incidental, or consequential damages of any character arising as a * result of this License or out of the use or inability to use the * Work (including but not limited to damages for loss of goodwill, * work stoppage, computer failure or malfunction, or any and all * other commercial damages or losses), even if such Contributor * has been advised of the possibility of such damages. * * 9. Accepting Warranty or Additional Liability. While redistributing * the Work or Derivative Works thereof, You may choose to offer, * and charge a fee for, acceptance of support, warranty, indemnity, * or other liability obligations and/or rights consistent with this * License. However, in accepting such obligations, You may act only * on Your own behalf and on Your sole responsibility, not on behalf * of any other Contributor, and only if You agree to indemnify, * defend, and hold each Contributor harmless for any liability * incurred by, or claims asserted against, such Contributor by reason * of your accepting any such warranty or additional liability. * * END OF TERMS AND CONDITIONS * * APPENDIX: How to apply the Apache License to your work. * * To apply the Apache License to your work, attach the following * boilerplate notice, with the fields enclosed by brackets "[]" * replaced with your own identifying information. (Don't include * the brackets!) The text should be enclosed in the appropriate * comment syntax for the file format. We also recommend that a * file or class name and description of purpose be included on the * same "printed page" as the copyright notice for easier * identification within third-party archives. * * Copyright [yyyy] [name of copyright owner] * * Licensed 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. */ libcommons-openpgp-java/README0000644000175000017500000000072110447044607015157 0ustar paulpaulThis component is supposed to provide a small library to support PGP signing, verifying of PGP signatures and maybe even PGP key management and encryption/decryption. Interested parties right now are the Ant and Maven projects (for signing tasks, mainly), Maven Wagon and the Repository team. The idea is to start with an implementation based on BouncyCastle's library, but provide an interface that may allow to plug in different providers like cryptix as well. libcommons-openpgp-java/build.xml0000644000175000017500000000546010345645123016122 0ustar paulpaul At least one test has failed.