Changeset 30829 in osm for applications/editors/josm


Ignore:
Timestamp:
2014-11-29T20:52:09+01:00 (10 years ago)
Author:
donvip
Message:

[josm_trustosm] update to Bouncy Castle 1.51

Location:
applications/editors/josm/plugins/trustosm
Files:
6 added
6 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/trustosm/.classpath

    r30750 r30829  
    22<classpath>
    33        <classpathentry kind="src" path="src"/>
    4         <classpathentry kind="lib" path="lib/bcpg-jdk15on-1.50.jar" sourcepath="bcpg-jdk15on-1.50-sources.jar">
     4        <classpathentry kind="lib" path="lib/jcalendar-1.4.jar"/>
     5        <classpathentry kind="lib" path="lib/swingx-core-1.6.5-1.jar"/>
     6        <classpathentry kind="lib" path="lib/bcpg-jdk15on-151.jar" sourcepath="lib/bcpg-jdk15on-1.51-sources.jar">
    57                <attributes>
    6                         <attribute name="javadoc_location" value="jar:platform:/resource/JOSM-trustosm/bcpg-jdk15on-1.50-javadoc.jar!/"/>
     8                        <attribute name="javadoc_location" value="jar:platform:/resource/JOSM-trustosm/lib/bcpg-jdk15on-1.51-javadoc.jar!/"/>
    79                </attributes>
    810        </classpathentry>
    9         <classpathentry kind="lib" path="lib/bcprov-jdk15on-1.50.jar" sourcepath="bcprov-jdk15on-1.50-sources.jar">
     11        <classpathentry kind="lib" path="lib/bcprov-jdk15on-151.jar" sourcepath="lib/bcprov-jdk15on-1.51-sources.jar">
    1012                <attributes>
    11                         <attribute name="javadoc_location" value="jar:platform:/resource/JOSM-trustosm/bcprov-jdk15on-1.50-javadoc.jar!/"/>
     13                        <attribute name="javadoc_location" value="jar:platform:/resource/JOSM-trustosm/lib/bcprov-jdk15on-1.51-javadoc.jar!/"/>
    1214                </attributes>
    1315        </classpathentry>
    14         <classpathentry kind="lib" path="lib/jcalendar-1.4.jar"/>
    15         <classpathentry kind="lib" path="lib/swingx-core-1.6.5-1.jar"/>
    1616        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
    1717        <classpathentry combineaccessrules="false" kind="src" path="/JOSM"/>
  • applications/editors/josm/plugins/trustosm/build.xml

    r30750 r30829  
    66    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    77    <property name="plugin.main.version" value="7001" />
    8 
    9     <!-- Configure these properties (replace "..." accordingly).
    10          See http://josm.openstreetmap.de/wiki/DevelopersGuide/DevelopingPlugins
    11     -->
    128    <property name="plugin.author" value="Christoph Wagner" />
    139    <property name="plugin.class" value="org.openstreetmap.josm.plugins.trustosm.TrustOSMplugin" />
     
    4036            <fileset dir="${plugin.lib.dir}">
    4137                <include name="**/*.jar"/>
     38                <exclude name="**/*-sources.jar"/>
     39                <exclude name="**/*-javadoc.jar"/>
    4240            </fileset>
    4341        </path>
  • applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/util/TrustGPG.java

    r30744 r30829  
    1919import java.security.NoSuchAlgorithmException;
    2020import java.security.NoSuchProviderException;
     21import java.security.Provider;
    2122import java.security.SecureRandom;
    2223import java.security.Security;
     
    4748import javax.swing.SpringLayout;
    4849
     50import org.bouncycastle.bcpg.HashAlgorithmTags;
    4951import org.bouncycastle.bcpg.sig.NotationData;
    5052import org.bouncycastle.jce.provider.BouncyCastleProvider;
     
    6567import org.bouncycastle.openpgp.PGPSignatureSubpacketVector;
    6668import org.bouncycastle.openpgp.PGPUtil;
     69import org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor;
     70import org.bouncycastle.openpgp.operator.PBESecretKeyEncryptor;
     71import org.bouncycastle.openpgp.operator.PGPContentSignerBuilder;
     72import org.bouncycastle.openpgp.operator.PGPContentVerifierBuilderProvider;
     73import org.bouncycastle.openpgp.operator.PGPDigestCalculator;
     74import org.bouncycastle.openpgp.operator.PGPDigestCalculatorProvider;
     75import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentSignerBuilder;
     76import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentVerifierBuilderProvider;
     77import org.bouncycastle.openpgp.operator.jcajce.JcaPGPDigestCalculatorProviderBuilder;
     78import org.bouncycastle.openpgp.operator.jcajce.JcaPGPKeyPair;
     79import org.bouncycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder;
     80import org.bouncycastle.openpgp.operator.jcajce.JcePBESecretKeyEncryptorBuilder;
    6781import org.bouncycastle.util.encoders.Hex;
    6882import org.openstreetmap.josm.Main;
     
    534548            }
    535549
    536             PGPPrivateKey pgpPrivKey = pgpSecKey.extractPrivateKey(password, "BC");
    537             PGPSignatureGenerator sGen = new PGPSignatureGenerator(pgpSecKey.getPublicKey().getAlgorithm(), digest, "BC");
    538             sGen.initSign(PGPSignature.CANONICAL_TEXT_DOCUMENT, pgpPrivKey);
     550            Provider provider = Security.getProvider("BC");
     551            PGPDigestCalculatorProvider digestCalculatorProvider = new JcaPGPDigestCalculatorProviderBuilder().setProvider(provider).build();
     552            PBESecretKeyDecryptor secretKeyDecryptor = new JcePBESecretKeyDecryptorBuilder(digestCalculatorProvider).setProvider(provider).build(password);
     553            PGPPrivateKey pgpPrivKey = pgpSecKey.extractPrivateKey(secretKeyDecryptor);
     554            int keyAlgorithm = pgpSecKey.getPublicKey().getAlgorithm();
     555            PGPContentSignerBuilder contentSignerBuilder = new JcaPGPContentSignerBuilder(keyAlgorithm, digest).setProvider(provider).setDigestProvider(provider);
     556            PGPSignatureGenerator sGen = new PGPSignatureGenerator(contentSignerBuilder);
     557            sGen.init(PGPSignature.CANONICAL_TEXT_DOCUMENT, pgpPrivKey);
    539558
    540559            Iterator<?> it = pgpSecKey.getPublicKey().getUserIDs();
     
    575594    }*/
    576595        try {
    577             sig.initVerify(pgpPub.getPublicKey(sig.getKeyID()), "BC");
     596            Provider provider = Security.getProvider("BC");
     597            PGPContentVerifierBuilderProvider contentVerifierBuilderProvider = new JcaPGPContentVerifierBuilderProvider().setProvider(provider);
     598            sig.init(contentVerifierBuilderProvider, pgpPub.getPublicKey(sig.getKeyID()));
    578599            sig.update(sigtext.getBytes(Charset.forName("UTF-8")));
    579600            return sig.verify();
     
    812833
    813834        Date now = new Date();
    814         PGPKeyPair pgpKp = new PGPKeyPair(al, kp, now);
     835        PGPKeyPair pgpKp = new JcaPGPKeyPair(al, kp, now);
    815836
    816837        getPasswordfromUser();
     
    825846        }
    826847
    827         PGPKeyRingGenerator keyRingGen = new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION, pgpKp,
    828                 userId.getText(), protAl[protectBox.getSelectedIndex()], password, true, subPck, null, new SecureRandom(), "BC");
     848        Provider provider = Security.getProvider("BC");
     849        int encAlgorithm = protAl[protectBox.getSelectedIndex()];
     850        PGPDigestCalculator checksumCalculator = new JcaPGPDigestCalculatorProviderBuilder().build().get(HashAlgorithmTags.SHA1);
     851        PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder(pgpKp.getPublicKey().getAlgorithm(), HashAlgorithmTags.SHA1);
     852        PBESecretKeyEncryptor encryptor = new JcePBESecretKeyEncryptorBuilder(encAlgorithm).setProvider(provider).
     853                setSecureRandom(new SecureRandom()).build(password);
     854       
     855        PGPKeyRingGenerator keyRingGen = new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION, pgpKp, userId.getText(),
     856                checksumCalculator, subPck, null, signerBuilder, encryptor);
    829857
    830858        if (pgpPub == null) {
Note: See TracChangeset for help on using the changeset viewer.