Skip to content

Commit

Permalink
compatibility updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dghgit committed Jun 10, 2023
1 parent 1ad9fad commit d87bb35
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 17 deletions.
34 changes: 26 additions & 8 deletions build1-1
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ find $jdk11src -name "*.java" -exec scripts/useseccert.sh \{\} \;
rm -rf org/bouncycastle/cert/test/ConverterTest*
rm -rf org/bouncycastle/cert/test/CertPathLoopTest.java
rm -rf org/bouncycastle/cert/test/Bc*
rm -rf org/bouncycastle/cert/test/DeltaCertTest*
rm -rf org/bouncycastle/cert/test/GOST3410_2012CMSTest.java
rm -rf org/bouncycastle/cert/ocsp/test/PKIXRevocationTest.java
rm -rf org/bouncycastle/tsp/GenTimeAccuracyUnit*
Expand Down Expand Up @@ -259,6 +260,11 @@ find $jdk11src -name "*.java" -exec scripts/useseccert.sh \{\} \;
rm -rf org/bouncycastle/pkix/jcajce/X509*
rm -rf org/bouncycastle/pkix/jcajce/RFC3280*
rm -rf org/bouncycastle/pkix/jcajce/Revocation*
rm org/bouncycastle/pkix/jcajce/CertPath*.java
rm org/bouncycastle/pkix/jcajce/PKIXCert*.java
rm org/bouncycastle/pkix/jcajce/PKIXPolicyN*.java
rm org/bouncycastle/pkix/jcajce/PKIXCRLUtil.java
rm -r org/bouncycastle/pkix/util
rm -rf org/bouncycastle/pkix/test/Revocation*
rm -rf org/bouncycastle/pkix/test/TestUtil*
rm org/bouncycastle/pkix/test/CheckerTest.java
Expand All @@ -284,6 +290,9 @@ find $jdk11src -name "*.java" -exec scripts/useseccert.sh \{\} \;
rm -rf org/bouncycastle/jce/provider/test/SM2SignatureTest.java
rm -f org/bouncycastle/jcajce/provider/drbg/EntropyGatherer.java
rm -f org/bouncycastle/jcajce/provider/drbg/EntropyDaemon.java
rm -f org/bouncycastle/jcajce/provider/asymmetric/Dilithium.java
rm -f org/bouncycastle/jcajce/provider/asymmetric/NTRU.java
rm -f org/bouncycastle/jcajce/provider/asymmetric/Falcon.java
rm -f org/bouncycastle/test/PrintTestResult.java

sh ../../scripts/jdk1.2ed.sh > /dev/null 2>&1
Expand Down Expand Up @@ -670,6 +679,7 @@ then
rm -f src/org/bouncycastle/openpgp/test/BcPGPEd25519JcaKeyPairConversionTest.java
rm src/org/bouncycastle/openpgp/test/ArmoredOutputStreamUTF8Test.java
rm -f src/org/bouncycastle/openpgp/examples/DSAElGamalKeyRingGenerator.java
rm -f src/org/bouncycastle/openpgp/examples/EllipticCurveKeyPairGenerator.java

find src -name AllTests.java -exec rm {} \;

Expand All @@ -688,18 +698,26 @@ then

echo "compiling"

(
cd src
sh ../../../../../scripts/jdk1.2ed.sh > /dev/null 2>&1
sh ../../../../../scripts/jdk1.1ed.sh > /dev/null 2>&1
)

for i in src/org/bouncycastle/pqc/jcajce/provider/*/*.java src/org/bouncycastle/pqc/crypto/*/*.java src/org/bouncycastle/bcpg/*.java src/org/bouncycastle/openpgp/*.java src/org/bouncycastle/openpgp/test/*.java
do
ed $i <<%%
g/.Override/d
ed src/org/bouncycastle/gpg/SExpression.java <<%
g/\.\.\. /s//[]/
w
q
%%
done
%

ed src/org/bouncycastle/gpg/SExpression.java <<%
g/\.\.\. /s//[]/
ed src/org/bouncycastle/openpgp/PGPSignature.java <<%
g/private.*final.*;/s/final//
w
q
%

ed src/org/bouncycastle/openpgp/operator/jcajce/JceAEADUtil.java <<%
g/private.*final.*;/s/final//
w
q
%
Expand Down
9 changes: 9 additions & 0 deletions build1-2
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ find $jdk12src -name "*.java" -exec scripts/usejcecert.sh \{\} \;
rm org/bouncycastle/pkix/jcajce/Revocation*.java
rm org/bouncycastle/pkix/jcajce/X509RevocationChecker.java
rm org/bouncycastle/pkix/jcajce/RFC3280*.java
rm org/bouncycastle/pkix/jcajce/CertPath*.java
rm org/bouncycastle/pkix/jcajce/X509CertSel*.java
rm org/bouncycastle/pkix/jcajce/X509CertStoreSel*.java
rm org/bouncycastle/pkix/jcajce/X509CRLStoreSel*.java
rm org/bouncycastle/pkix/jcajce/PKIXCRL*.java
rm org/bouncycastle/pkix/jcajce/PKIXCert*.java
rm org/bouncycastle/pkix/jcajce/PKIXPolicyN*.java
rm -r org/bouncycastle/pkix/util
rm org/bouncycastle/cms/jcajce/JceKeyTransAuthEnvelopedRecipient.java
rm org/bouncycastle/cms/jcajce/JceAADStream.java
rm org/bouncycastle/jcajce/provider/keystore/util/ParameterUtil.java
Expand Down Expand Up @@ -224,6 +232,7 @@ find $jdk12src -name "*.java" -exec scripts/usejcecert.sh \{\} \;
rm -rf org/bouncycastle/cert/test/ConverterTest*
rm -rf org/bouncycastle/cert/test/CertPathLoopTest.java
rm -rf org/bouncycastle/cert/test/Bc*
rm -rf org/bouncycastle/cert/test/Delta*
rm -rf org/bouncycastle/tsp/GenTimeAccuracyUnit*
rm -rf org/bouncycastle/tsp/TimeStampTokenInfoUnit*
rm org/bouncycastle/openpgp/test/BcPGPEd25519JcaKeyPairConversionTest.java
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.bouncycastle.pqc.crypto.picnic;


import org.bouncycastle.util.Arrays;
import org.bouncycastle.util.Pack;

Expand Down
5 changes: 2 additions & 3 deletions core/src/test/java/org/bouncycastle/crypto/test/GCMTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.security.SecureRandom;

import junit.framework.TestCase;
import org.bouncycastle.crypto.BlockCipher;
import org.bouncycastle.crypto.InvalidCipherTextException;
import org.bouncycastle.crypto.engines.AESEngine;
Expand Down Expand Up @@ -358,8 +357,8 @@ private void testResetBehavior() throws Exception
l = gcm.processBytes(ct, 0, ct.length, outPostReset, 0);
gcm.doFinal(outPostReset, l);

TestCase.assertTrue("before / after reset decryptions not the same", Arrays.areEqual(outPreReset, outPostReset));
TestCase.assertTrue("decryption not same as message", Arrays.areEqual(msg, outPostReset));
isTrue("before / after reset decryptions not the same", Arrays.areEqual(outPreReset, outPostReset));
isTrue("decryption not same as message", Arrays.areEqual(msg, outPostReset));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.cert.selector.X509CertificateHolderSelector;
import org.bouncycastle.util.Exceptions;

public class JcaX509CertSelectorConverter
{
Expand All @@ -26,7 +27,7 @@ protected X509CertSelector doConversion(X500Name issuer, BigInteger serialNumber
}
catch (IOException e)
{
throw new IllegalArgumentException("unable to convert issuer: " + e.getMessage(), e);
throw Exceptions.illegalArgumentException("unable to convert issuer: " + e.getMessage(), e);
}
}

Expand All @@ -43,7 +44,7 @@ protected X509CertSelector doConversion(X500Name issuer, BigInteger serialNumber
}
catch (IOException e)
{
throw new IllegalArgumentException("unable to convert subjectKeyIdentifier: " + e.getMessage(), e);
throw Exceptions.illegalArgumentException("unable to convert subjectKeyIdentifier: " + e.getMessage(), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.math.BigInteger;
import java.security.InvalidKeyException;
import java.security.PublicKey;
import java.security.PrivateKey;

import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.DERNull;
Expand All @@ -18,6 +19,14 @@

class ECUtils
{
static AsymmetricKeyParameter generatePrivateKeyParameter(
PrivateKey key)
throws InvalidKeyException
{
return (key instanceof BCECPrivateKey) ? ((BCECPrivateKey)key).engineGetKeyParameters() : ECUtil.generatePrivateKeyParameter(key);
}


static AsymmetricKeyParameter generatePublicKeyParameter(
PublicKey key)
throws InvalidKeyException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ public TestResult v0Test()
X509Certificate endCert = TestUtils.generateEndEntityCert(endPair.getPublic(), interPair.getPrivate(), interCert);

BigInteger revokedSerialNumber = BigInteger.valueOf(2);
X509CRL rootCRL = TestUtils.createCRL(rootCert, rootPair.getPrivate(), revokedSerialNumber);
X509CRL interCRL = TestUtils.createCRL(interCert, interPair.getPrivate(), revokedSerialNumber);
X509CRL rootCRL = TestCertificateGen.createCRL(rootCert, rootPair.getPrivate(), revokedSerialNumber);
X509CRL interCRL = TestCertificateGen.createCRL(interCert, interPair.getPrivate(), revokedSerialNumber);

// create CertStore to support path building
List list = new ArrayList();
Expand Down
17 changes: 15 additions & 2 deletions scripts/jdk1.2ed.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#
# JDK 1.2 edits

for i in org/bouncycastle/pqc/jcajce/provider/*/*.java org/bouncycastle/pqc/*/*/*.java org/bouncycastle/pqc/*/*/*/*.java org/bouncycastle/crypto/digests/*.java org/bouncycastle/cert/cmp/*.java org/bouncycastle/crypto/engines/*.java org/bouncycastle/openpgp/*.java org/bouncycastle/bcpg/*.java org/bouncycastle/openpgp/test/*.java
for i in org/bouncycastle/pqc/jcajce/provider/*/*.java org/bouncycastle/pqc/*/*/*.java org/bouncycastle/pqc/*/*/*/*.java org/bouncycastle/crypto/digests/*.java org/bouncycastle/cert/cmp/*.java org/bouncycastle/crypto/engines/*.java org/bouncycastle/openpgp/operator/*.java org/bouncycastle/openpgp/operator/jcajce/*.java org/bouncycastle/openpgp/operator/bc/*.java org/bouncycastle/openpgp/*.java org/bouncycastle/bcpg/*.java org/bouncycastle/openpgp/test/*.java
do
ed $i <<%%
g/.Override/d
g/ .Override/d
g/ .Override/d
w
q
%%
Expand Down Expand Up @@ -194,6 +195,18 @@ w
q
%

ed org/bouncycastle/openpgp/operator/jcajce/JcePGPDataEncryptorBuilder.java <<%
g/private final/s//private/g
w
q
%

ed org/bouncycastle/openpgp/operator/bc/BcPGPDataEncryptorBuilder.java <<%
g/private final/s//private/g
w
q
%

ed org/bouncycastle/openpgp/PGPCanonicalizedDataGenerator.java <<%
g/FileNotFoundException/s//IOException/
w
Expand Down

0 comments on commit d87bb35

Please sign in to comment.