Skip to content

Commit aaf3e40

Browse files
committed
Java 4 updates
1 parent 76f342e commit aaf3e40

9 files changed

Lines changed: 141 additions & 63 deletions

File tree

ant/jdk14.xml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@
4141
<fileset dir="pg/src/main/java">
4242
<exclude name="**/keybox/**/*.java"/>
4343
</fileset>
44-
<fileset dir="pg/src/main/jdk1.5">
45-
<exclude name="**/keybox/**/*.java"/>
46-
<include name="**/*.java"/>
47-
</fileset>
4844
<fileset dir="pkix/src/main/java">
4945
<exclude name="**/JceAADStream.java"/>
5046
<exclude name="**/JceKeyTransAuthEnvelopedRecipient.java"/>
@@ -134,17 +130,21 @@
134130
<fileset dir="pg/src/test/java">
135131
<exclude name="**/keybox/**/*.java"/>
136132
<exclude name="**/gpg/test/*.java"/>
133+
<exclude name="**/BcImplProviderTest.java"/>
137134
</fileset>
138135
<fileset dir="pkix/src/test/java">
139136
<exclude name="**/est/**/*.java"/>
140137
<exclude name="**/pkix/test/RevocationTest.java"/>
141138
<exclude name="**/TimeStampTokenInfoUnitTest.java"/>
142139
<exclude name="**/cms/test/AnnotatedKeyTest.java"/>
143-
<exclude name="**/bouncycastle/cms/test/AuthEnvelopedDataTest.java"/>
140+
<exclude name="**/cms/test/GOSTR3410_2012_256CmsSignVerifyDetached.java"/>
141+
<exclude name="**/cert/test/GOSTR3410_2012_256GenerateCertificate.java"/>
142+
<exclude name="**/bouncycastle/cms/test/*AuthEnvelopedData*Test.java"/>
144143
<exclude name="**/PKIXRevocationTest.java"/>
145144
<exclude name="**/its/**/*.java"/>
146145
</fileset>
147146
<fileset dir="mail/src/test/java">
147+
<exclude name="**/MailGeneralTest.java"/>
148148
<exclude name="**/SignedMailValidatorTest.java"/>
149149
<exclude name="**/DummyCertPathReviewer.java"/>
150150
</fileset>
@@ -205,6 +205,9 @@
205205
<fileset dir="pkix/src/main/javadoc"/>
206206
<fileset dir="pg/src/main/javadoc"/>
207207
</copy>
208+
<copy todir="${src.dir}" overwrite="true">
209+
<fileset dir="pg/src/main/jdk1.5" includes="**/*.java"/>
210+
</copy>
208211
<copy todir="${src.dir}" overwrite="true">
209212
<fileset dir="core/src/main/jdk1.4" includes="**/*.java"/>
210213
<fileset dir="prov/src/main/jdk1.4" includes="**/*.java"/>

pg/src/main/jdk1.5/org/bouncycastle/gpg/SExprParser.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import org.bouncycastle.openpgp.operator.PGPSecretKeyDecryptorWithAAD;
4848
import org.bouncycastle.util.Arrays;
4949
import org.bouncycastle.util.BigIntegers;
50+
import org.bouncycastle.util.Integers;
5051
import org.bouncycastle.util.Strings;
5152

5253
/**
@@ -68,26 +69,26 @@ public SExprParser(PGPDigestCalculatorProvider digestProvider)
6869

6970
private static final Map<Integer, String[]> rsaLabels = new HashMap<Integer, String[]>()
7071
{{
71-
put(ProtectionModeTags.OPENPGP_S2K3_OCB_AES, new String[]{"rsa", "n", "e", "protected-at"});
72-
put(ProtectionModeTags.OPENPGP_S2K3_SHA1_AES_CBC, new String[]{"rsa", "n", "e", "d", "p", "q", "u", "protected-at"});
72+
put(Integers.valueOf(ProtectionModeTags.OPENPGP_S2K3_OCB_AES), new String[]{"rsa", "n", "e", "protected-at"});
73+
put(Integers.valueOf(ProtectionModeTags.OPENPGP_S2K3_SHA1_AES_CBC), new String[]{"rsa", "n", "e", "d", "p", "q", "u", "protected-at"});
7374
}};
7475
private static final Map<Integer, String[]> eccLabels = new HashMap<Integer, String[]>()
7576
{{
76-
put(ProtectionModeTags.OPENPGP_S2K3_OCB_AES, new String[]{"ecc", "curve", "flags", "q", "protected-at"});
77-
put(ProtectionModeTags.OPENPGP_S2K3_SHA1_AES_CBC, new String[]{"ecc", "curve", "q", "d", "protected-at"});
77+
put(Integers.valueOf(ProtectionModeTags.OPENPGP_S2K3_OCB_AES), new String[]{"ecc", "curve", "flags", "q", "protected-at"});
78+
put(Integers.valueOf(ProtectionModeTags.OPENPGP_S2K3_SHA1_AES_CBC), new String[]{"ecc", "curve", "q", "d", "protected-at"});
7879
}};
7980

8081
private static final Map<Integer, String[]> dsaLabels = new HashMap<Integer, String[]>()
8182
{{
82-
put(ProtectionModeTags.OPENPGP_S2K3_OCB_AES, new String[]{"dsa", "p", "q", "g", "y", "protected-at"});
83-
put(ProtectionModeTags.OPENPGP_S2K3_SHA1_AES_CBC, new String[]{"dsa", "p", "q", "g", "y", "x", "protected-at"});
83+
put(Integers.valueOf(ProtectionModeTags.OPENPGP_S2K3_OCB_AES), new String[]{"dsa", "p", "q", "g", "y", "protected-at"});
84+
put(Integers.valueOf(ProtectionModeTags.OPENPGP_S2K3_SHA1_AES_CBC), new String[]{"dsa", "p", "q", "g", "y", "x", "protected-at"});
8485
}};
8586

8687
private static final Map<Integer, String[]> elgLabels = new HashMap<Integer, String[]>()
8788
{{
8889
//https://github.com/gpg/gnupg/blob/40227e42ea0f2f1cf9c9f506375446648df17e8d/agent/cvt-openpgp.c#L217
89-
put(ProtectionModeTags.OPENPGP_S2K3_OCB_AES, new String[]{"elg", "p", "q", "g", "y", "protected-at"});
90-
put(ProtectionModeTags.OPENPGP_S2K3_SHA1_AES_CBC, new String[]{"elg", "p", "q", "g", "y", "x", "protected-at"});
90+
put(Integers.valueOf(ProtectionModeTags.OPENPGP_S2K3_OCB_AES), new String[]{"elg", "p", "q", "g", "y", "protected-at"});
91+
put(Integers.valueOf(ProtectionModeTags.OPENPGP_S2K3_SHA1_AES_CBC), new String[]{"elg", "p", "q", "g", "y", "x", "protected-at"});
9192
}};
9293

9394
private static final String[] rsaBigIntegers = new String[]{"n", "e"};
@@ -402,7 +403,7 @@ private static SecretKeyPacket getSecKeyPacket(PGPPublicKey pubKey, PBEProtectio
402403
{
403404
PGPDigestCalculator digestCalculator = digestProvider.get(HashAlgorithmTags.SHA1);
404405
OutputStream dOut = digestCalculator.getOutputStream();
405-
byte[] aad = SExpression.buildExpression(expression, keyIn.getExpression(0), labels.get(protection)).toCanonicalForm();
406+
byte[] aad = SExpression.buildExpression(expression, keyIn.getExpression(0), (String[])labels.get(Integers.valueOf(protection))).toCanonicalForm();
406407
dOut.write(aad);
407408
byte[] check = digestCalculator.getDigest();
408409
byte[] hashBytes = keyIn.getExpression(1).getBytes(2);
@@ -415,7 +416,7 @@ private static SecretKeyPacket getSecKeyPacket(PGPPublicKey pubKey, PBEProtectio
415416
}
416417
else //ProtectionModeTags.OPENPGP_S2K3_OCB_AES
417418
{
418-
String[] filter = labels.get(protection);
419+
String[] filter = (String[])labels.get(Integers.valueOf(protection));
419420
if (filter == null)
420421
{
421422
// TODO could not get client to generate protected elgamal keys

pg/src/test/java/org/bouncycastle/openpgp/test/BcPGPDSAElGamalTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public void performTest()
223223
isTrue(!p1.isEmpty());
224224
isTrue(p1.size() == 1);
225225

226-
PGPOnePassSignature ops = new PGPOnePassSignature(new BCPGInputStream(new ByteArrayInputStream(p1.iterator().next().getEncoded())));
226+
PGPOnePassSignature ops = new PGPOnePassSignature(new BCPGInputStream(new ByteArrayInputStream(((PGPOnePassSignature)p1.iterator().next()).getEncoded())));
227227
isTrue(PGPSignature.BINARY_DOCUMENT == ops.getSignatureType());
228228
isTrue(ops.isContaining());
229229

pg/src/test/java/org/bouncycastle/openpgp/test/BcPGPDSATest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ public void performTest()
443443

444444
PGPSignatureList p3 = (PGPSignatureList)pgpFact.nextObject();
445445
isTrue(!p3.isEmpty());
446-
if (!ops.verify(p3.iterator().next()))
446+
if (!ops.verify((PGPSignature)p3.iterator().next()))
447447
{
448448
fail("Failed signature check");
449449
}

pg/src/test/java/org/bouncycastle/openpgp/test/OpenPGPTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ public void operation()
723723
}
724724
}
725725

726-
sig = new PGPSignatureList(sKey.getSignatures().next()).get(0);
726+
sig = new PGPSignatureList((PGPSignature)sKey.getSignatures().next()).get(0);
727727

728728
if (sig.getKeyID() == vKey.getKeyID())
729729
{

pg/src/test/java/org/bouncycastle/openpgp/test/OperatorBcTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import java.security.PublicKey;
1111
import java.security.SecureRandom;
1212
import java.security.Security;
13-
import java.security.spec.ECGenParameterSpec;
1413
import java.util.Date;
1514
import java.util.Iterator;
1615

@@ -315,7 +314,7 @@ private void testCreateKeyPairEC(int algorithm, String name, final String curveN
315314
public void initialize(KeyPairGenerator gen)
316315
throws Exception
317316
{
318-
gen.initialize(new ECGenParameterSpec(curveName));
317+
gen.initialize(new ECNamedCurveGenParameterSpec(curveName));
319318
}
320319
});
321320
}

0 commit comments

Comments
 (0)