Skip to content

Commit

Permalink
1.1 J2ME compatibility updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dghgit committed Jun 5, 2021
1 parent 1cebe95 commit d46b4be
Show file tree
Hide file tree
Showing 16 changed files with 285 additions and 56 deletions.
7 changes: 7 additions & 0 deletions CONTRIBUTORS.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@
The following organisations and people have contributed to the Bouncy Castle Cryptography Package.
<p>
Thanks, may your castles never deflate!
</p>
<p>
Donors
</p>
<p>
The following people and organisations donated financially to help with the release of 1.69:
<br />
Miguel, Rodolfo Hansen, and iterate GmbH.
</p>
<p>
The following organisations donated financially to help with the release of 1.67:
<br />
Expand Down
11 changes: 8 additions & 3 deletions build1-1
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ mkdir -p $jdk11src
((cd pkix/src/test/jdk1.1 && tar cf - * ) | (cd $jdk11src && tar xf -))
((cd util/src/main/java && tar cf - * ) | (cd $jdk11src && tar xf -))
((cd util/src/test/java && tar cf - * ) | (cd $jdk11src && tar xf -))
((cd util/src/test/jdk1.1 && tar cf - * ) | (cd $jdk11src && tar xf -))

find $jdk11src -name "*.java" -exec scripts/trim.sh \{\} \;
find $jdk11src -name "*.java" -exec scripts/useseccert.sh \{\} \;
Expand Down Expand Up @@ -162,7 +163,6 @@ find $jdk11src -name "*.java" -exec scripts/useseccert.sh \{\} \;
rm org/bouncycastle/asn1/test/ASN1SequenceParserTest.java
rm org/bouncycastle/asn1/cms/test/OctetStringTest.java
rm org/bouncycastle/asn1/cms/test/ParseTest.java
rm org/bouncycastle/asn1/esf/test/CMCStatusTest.java
rm org/bouncycastle/asn1/cmc/test/CMCFailInfoTest.java
rm org/bouncycastle/asn1/cmc/test/CMCStatusTest.java
rm org/bouncycastle/asn1/test/ASN1IntegerTest.java
Expand Down Expand Up @@ -553,8 +553,12 @@ then

echo "compiling"

(cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:../../../../jce-jdk11-$base/classes:$JDK11PATH/lib/classes.zip */*.java )
(cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:../../../../jce-jdk11-$base/classes:$JDK11PATH/lib/classes.zip */*/*.java )
(cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:../../../../jce-jdk11-$base/classes:$JDK11PATH/lib/classes.zip c*/*.java )
(cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:../../../../jce-jdk11-$base/classes:$JDK11PATH/lib/classes.zip [imo]*/*.java )
(cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:../../../../jce-jdk11-$base/classes:$JDK11PATH/lib/classes.zip [deptv]*/*.java )
(cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:../../../../jce-jdk11-$base/classes:$JDK11PATH/lib/classes.zip t*/*/*.java )
(cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:../../../../jce-jdk11-$base/classes:$JDK11PATH/lib/classes.zip p*/*/*.java )
(cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:../../../../jce-jdk11-$base/classes:$JDK11PATH/lib/classes.zip c*/*/*.java )
(cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:../../../../jce-jdk11-$base/classes:$JDK11PATH/lib/classes.zip */*/*/*.java )
java -mx512m -classpath ../jce-jdk11-$base/classes:classes:$JDK11PATH/lib/classes.zip org.bouncycastle.cert.test.CertTest
java -mx512m -classpath ../jce-jdk11-$base/classes:classes:$JDK11PATH/lib/classes.zip org.bouncycastle.cert.test.AttrCertTest
Expand All @@ -579,6 +583,7 @@ then
((cd pg/src/test/java && tar cf - * ) | (cd $artifacts/bcpg-jdk11-$base/src && tar xf -))
((cd pg/src/test/jdk1.4 && tar cf - * ) | (cd $artifacts/bcpg-jdk11-$base/src && tar xf -))
((cd pg/src/test/jdk1.3 && tar cf - * ) | (cd $artifacts/bcpg-jdk11-$base/src && tar xf -))
((cd pg/src/test/jdk1.2 && tar cf - * ) | (cd $artifacts/bcpg-jdk11-$base/src && tar xf -))
((cd pg/src/test/jdk1.1 && tar cf - * ) | (cd $artifacts/bcpg-jdk11-$base/src && tar xf -))
((cd pg/src/main/javadoc && tar cf - * ) | (cd $artifacts/bcpg-jdk11-$base/src && tar xf -))
find $artifacts/bcpg-jdk11-$base -name "*.java" -exec scripts/trim.sh \{\} \;
Expand Down
19 changes: 19 additions & 0 deletions buildj2me
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ then
((cd core/src/main/j2me; tar cf - * ) | (cd $target/src && tar xf -))
((cd core/src/test/java; tar cf - * ) | (cd $target/src && tar xf -))
((cd core/src/test/j2me; tar cf - * ) | (cd $target/src && tar xf -))
((cd util/src/main/java; tar cf - * ) | (cd $target/src && tar xf -))
((cd util/src/main/j2me; tar cf - * ) | (cd $target/src && tar xf -))
((cd pkix/src/main/java; tar cf - * ) | (cd $target/src && tar xf -))
((cd pkix/src/main/javadoc; tar cf - * ) | (cd $target/src && tar xf -))
((cd pkix/src/main/j2me; tar cf - * ) | (cd $target/src && tar xf -))
Expand All @@ -40,6 +42,7 @@ then
((cd pg/src/main/java; tar cf - * ) | (cd $target/src && tar xf -))
((cd pg/src/main/javadoc; tar cf - * ) | (cd $target/src && tar xf -))
((cd pg/src/main/j2me; tar cf - * ) | (cd $target/src && tar xf -))
((cd pg/src/test/j2me; tar cf - * ) | (cd $target/src && tar xf -))

(cd $target;
rm src/org/bouncycastle/crypto/test/AllTests.java
Expand Down Expand Up @@ -73,7 +76,9 @@ then
rm src/org/bouncycastle/asn1/test/RevokeRequestTest.java
rm src/org/bouncycastle/asn1/test/LocaleTest.java
rm src/org/bouncycastle/tsp/DataGroup.java
rm -rf src/org/bouncycastle/tsp/ers
rm src/org/bouncycastle/crypto/util/JournaledAlgorithm.java
rm -rf src/org/bouncycastle/crypto/fpe/
rm -rf src/org/bouncycastle/math/ec/rfc7748/test
rm -rf src/org/bouncycastle/math/ec/rfc8032/test
rm -rf src/org/bouncycastle/math/raw/test
Expand Down Expand Up @@ -113,6 +118,10 @@ then
rm src/org/bouncycastle/crypto/test/GCMReorderTest.java
rm src/org/bouncycastle/crypto/test/HCFamilyVecTest.java
rm src/org/bouncycastle/crypto/test/RSABlindedTest.java
rm src/org/bouncycastle/crypto/test/SP80038GTest.java
rm src/org/bouncycastle/crypto/digests/Blake3Digest.java
rm src/org/bouncycastle/crypto/macs/Blake3Mac.java
rm src/org/bouncycastle/crypto/test/Blake3*.java
find src -name AllTests.java -exec rm {} \;
find src -name jcajce -exec rm -r {} \;
rm src/org/bouncycastle/asn1/test/GetInstanceTest.java
Expand Down Expand Up @@ -158,6 +167,16 @@ then
rm -r src/org/bouncycastle/voms
rm -r src/org/bouncycastle/math/ec/tools
rm src/org/bouncycastle/mozilla/SignedPublicKeyAndChallenge.java
ed src/org/bouncycastle/cms/CMSSignedDataGenerator.java <<%
g/LinkedHashSet/s//HashSet/g
w
q
%
ed src/org/bouncycastle/openpgp/operator/bc/BcPGPDataEncryptorBuilder.java <<%
g/public BcPGPDataEncryptorBuilder setWi/s//public PGPDataEncryptorBuilder setWi/g
w
q
%
)

find $target/src -name "*.java" -exec scripts/trim.sh \{\} \;
Expand Down
15 changes: 15 additions & 0 deletions core/src/main/j2me/org/bouncycastle/util/Arrays.java
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,21 @@ public static boolean constantTimeAreEqual(int len, byte[] a, int aOff, byte[] b
return 0 == d;
}

public static boolean isNullOrEmpty(byte[] array)
{
return null == array || array.length < 1;
}

public static boolean isNullOrEmpty(int[] array)
{
return null == array || array.length < 1;
}

public static boolean isNullOrEmpty(Object[] array)
{
return null == array || array.length < 1;
}

/**
* Iterator backed by a specific array.
*/
Expand Down
16 changes: 0 additions & 16 deletions core/src/test/j2me/org/bouncycastle/asn1/test/RegressionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ public class RegressionTest
{
public static Test[] tests = {
new CertificateTest(),
new CMSTest(),
new OCSPTest(),
new OIDTest(),
new PKCS10Test(),
Expand All @@ -20,25 +19,10 @@ public class RegressionTest
new X9Test(),
new EncryptedPrivateKeyInfoTest(),
new StringTest(),
new RequestedCertificateUnitTest(),
new OtherCertIDUnitTest(),
new OtherSigningCertificateUnitTest(),
new ContentHintsUnitTest(),
new CertHashUnitTest(),
new AdditionalInformationSyntaxUnitTest(),
new AdmissionSyntaxUnitTest(),
new AdmissionsUnitTest(),
new DeclarationOfMajorityUnitTest(),
new ProcurationSyntaxUnitTest(),
new ProfessionInfoUnitTest(),
new RestrictionUnitTest(),
new NamingAuthorityUnitTest(),
new MonetaryLimitUnitTest(),
new DERApplicationSpecificTest(),
new IssuingDistributionPointUnitTest(),
new TargetInformationTest(),
new SubjectKeyIdentifierTest(),
new ESSCertIDv2UnitTest(),
new ParsingTest(),
new GeneralNameTest(),
new RFC4519Test()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public void performTest()
// with integrity packet
//
cbOut = new ByteArrayOutputStream();
cPk = new PGPEncryptedDataGenerator(new BcPGPDataEncryptorBuilder(PGPEncryptedData.CAST5).setWithIntegrityPacket(true).setSecureRandom(rand));
cPk = new PGPEncryptedDataGenerator(new BcPGPDataEncryptorBuilder(PGPEncryptedData.CAST5).setSecureRandom(rand).setWithIntegrityPacket(true));

cPk.addMethod(new BcPBEKeyEncryptionMethodGenerator(pass));

Expand Down Expand Up @@ -345,7 +345,7 @@ public void performTest()
comOut.close();

cbOut = new ByteArrayOutputStream();
cPk = new PGPEncryptedDataGenerator(new BcPGPDataEncryptorBuilder(PGPEncryptedData.CAST5).setWithIntegrityPacket(true).setSecureRandom(rand));
cPk = new PGPEncryptedDataGenerator(new BcPGPDataEncryptorBuilder(PGPEncryptedData.CAST5).setSecureRandom(rand).setWithIntegrityPacket(true));

cPk.addMethod(new BcPBEKeyEncryptionMethodGenerator(pass));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ private void mixedTest(PGPPrivateKey pgpPrivKey, PGPPublicKey pgpPubKey)

ByteArrayOutputStream bcOut = new ByteArrayOutputStream();

PGPEncryptedDataGenerator encGen = new PGPEncryptedDataGenerator(new BcPGPDataEncryptorBuilder(SymmetricKeyAlgorithmTags.AES_128).setWithIntegrityPacket(true).setSecureRandom(new SecureRandom()));
PGPEncryptedDataGenerator encGen = new PGPEncryptedDataGenerator(new BcPGPDataEncryptorBuilder(SymmetricKeyAlgorithmTags.AES_128).setSecureRandom(new SecureRandom()).setWithIntegrityPacket(true));

encGen.addMethod(new BcPublicKeyKeyEncryptionMethodGenerator(pgpPubKey));

Expand Down
Loading

0 comments on commit d46b4be

Please sign in to comment.