Skip to content

Commit 30c6cc6

Browse files
committed
Java 1.1 Updates
1 parent 5b13608 commit 30c6cc6

File tree

7 files changed

+604
-3
lines changed

7 files changed

+604
-3
lines changed

build1-1

+32-3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ mkdir -p $jdk11src
4545
((cd pkix/src/main/java && tar cf - * ) | (cd $jdk11src && tar xf -))
4646
((cd pkix/src/main/javadoc && tar cf - * ) | (cd $jdk11src && tar xf -))
4747
((cd pkix/src/test/java && tar cf - * ) | (cd $jdk11src && tar xf -))
48+
((cd pg/src/main/jdk1.5 && tar cf - * ) | (cd $jdk11src && tar xf -))
49+
((cd pg/src/main/jdk1.4 && tar cf - * ) | (cd $jdk11src && tar xf -))
50+
((cd pg/src/main/jdk1.3 && tar cf - * ) | (cd $jdk11src && tar xf -))
51+
((cd pg/src/main/jdk1.1 && tar cf - * ) | (cd $jdk11src && tar xf -))
4852
((cd pkix/src/main/jdk1.4 && tar cf - * ) | (cd $jdk11src && tar xf -))
4953
((cd pkix/src/test/jdk1.4 && tar cf - * ) | (cd $jdk11src && tar xf -))
5054
((cd pkix/src/main/jdk1.3 && tar cf - * ) | (cd $jdk11src && tar xf -))
@@ -234,6 +238,12 @@ find $jdk11src -name "*.java" -exec scripts/useseccert.sh \{\} \;
234238
rm -rf org/bouncycastle/pkcs/test
235239
rm -rf org/bouncycastle/eac/test
236240
rm -rf org/bouncycastle/cms/test
241+
rm -r org/bouncycastle/jcajce/provider/asymmetric/compositesignatures
242+
rm -r org/bouncycastle/jcajce/provider/asymmetric/CompositeSignatures.java
243+
rm org/bouncycastle/pqc/crypto/test/XWingTest.java
244+
rm org/bouncycastle/cert/test/GOSTR3410_2012_256GenerateCertificate.java
245+
rm org/bouncycastle/cert/cmp/test/InvalidMessagesTest.java
246+
rm org/bouncycastle/test/JVMVersionTest.java
237247
rm org/bouncycastle/cms/jcajce/JceAADStream.java
238248
rm org/bouncycastle/cms/jcajce/JceCMSKEM*.java
239249
rm org/bouncycastle/cms/jcajce/JceKEM*.java
@@ -295,7 +305,11 @@ find $jdk11src -name "*.java" -exec scripts/useseccert.sh \{\} \;
295305
rm -f org/bouncycastle/jcajce/provider/asymmetric/NTRU.java
296306
rm -f org/bouncycastle/jcajce/provider/asymmetric/Falcon.java
297307
rm -f org/bouncycastle/test/PrintTestResult.java
298-
rm org/bouncycastle/openpgp/test/PGPAeadTest.java
308+
rm -f org/bouncycastle/openpgp/test/PGPAeadTest.java
309+
rm -f org/bouncycastle/openpgp/test/BytesBooleansTest.java
310+
rm -f org/bouncycastle/openpgp/test/BcImplProviderTest.java
311+
rm -f org/bouncycastle/openpgp/test/BcpgGeneralTest.java
312+
rm -f org/bouncycastle/openpgp/test/OpenPGPTest.java
299313

300314
sh ../../scripts/jdk1.2ed.sh > /dev/null 2>&1
301315
sh ../../scripts/jdk1.1ed.sh > /dev/null 2>&1
@@ -640,6 +654,7 @@ then
640654
mkdir $artifacts/bcpg-jdk11-$base/src
641655
tar cf - index.html LICENSE.html CONTRIBUTORS.html docs | (cd $artifacts/bcpg-jdk11-$base; tar xf -)
642656
((cd pg/src/main/java && tar cf - * ) | (cd $artifacts/bcpg-jdk11-$base/src && tar xf -))
657+
((cd pg/src/main/jdk1.5 && tar cf - * ) | (cd $artifacts/bcpg-jdk11-$base/src && tar xf -))
643658
((cd pg/src/main/jdk1.4 && tar cf - * ) | (cd $artifacts/bcpg-jdk11-$base/src && tar xf -))
644659
((cd pg/src/main/jdk1.3 && tar cf - * ) | (cd $artifacts/bcpg-jdk11-$base/src && tar xf -))
645660
((cd pg/src/main/jdk1.1 && tar cf - * ) | (cd $artifacts/bcpg-jdk11-$base/src && tar xf -))
@@ -683,6 +698,12 @@ then
683698
rm -f src/org/bouncycastle/openpgp/examples/DSAElGamalKeyRingGenerator.java
684699
rm -f src/org/bouncycastle/openpgp/examples/EllipticCurveKeyPairGenerator.java
685700
rm src/org/bouncycastle/openpgp/test/PGPAeadTest.java
701+
rm -f src/org/bouncycastle/openpgp/test/BytesBooleansTest.java
702+
rm -f src/org/bouncycastle/openpgp/test/BcImplProviderTest.java
703+
rm -f src/org/bouncycastle/openpgp/test/BcpgGeneralTest.java
704+
rm -f src/org/bouncycastle/openpgp/test/OpenPGPTest.java
705+
rm -f src/org/bouncycastle/openpgp/test/OperatorBcTest.java
706+
rm -f src/org/bouncycastle/openpgp/test/PGPGeneralTest.java
686707

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

@@ -797,8 +818,16 @@ w
797818
q
798819
%
799820

800-
(cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:../../../../jce-jdk11-$base/classes:$JDK11PATH/lib/classes.zip bcpg/*.java bcpg/*/*.java openpgp/*.java )
801-
(cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:../../../../jce-jdk11-$base/classes:$JDK11PATH/lib/classes.zip openpgp/*/*.java openpgp/*/*/*.java )
821+
ed src/org/bouncycastle/openpgp/operator/bc/BcPublicKeyDataDecryptorFactory.java <<%
822+
g/private.*final.*;/s/final//
823+
w
824+
q
825+
%
826+
827+
(cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:../../../../jce-jdk11-$base/classes:$JDK11PATH/lib/classes.zip bcpg/*.java )
828+
(cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:../../../../jce-jdk11-$base/classes:$JDK11PATH/lib/classes.zip bcpg/*/*.java openpgp/*.java )
829+
(cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:../../../../jce-jdk11-$base/classes:$JDK11PATH/lib/classes.zip openpgp/*/*.java )
830+
(cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:../../../../jce-jdk11-$base/classes:$JDK11PATH/lib/classes.zip openpgp/*/*/*.java )
802831
(cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:../../../../jce-jdk11-$base/classes:$JDK11PATH/lib/classes.zip openpgp/test/RegressionTest.java )
803832

804833
cp ../../../../pg/src/test/resources/org/bouncycastle/openpgp/test/bigpub.asc classes/org/bouncycastle/openpgp/test/bigpub.asc

core/src/main/jdk1.1/org/bouncycastle/util/BigIntegers.java

+45
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,51 @@ private static byte[] createRandom(int bitLength, SecureRandom random)
368368
return rv;
369369
}
370370

371+
public static boolean modOddIsCoprime(BigInteger M, BigInteger X)
372+
{
373+
if (!M.testBit(0))
374+
{
375+
throw new IllegalArgumentException("'M' must be odd");
376+
}
377+
if (M.signum() != 1)
378+
{
379+
throw new ArithmeticException("BigInteger: modulus not positive");
380+
}
381+
if (X.signum() < 0 || X.bitLength() > M.bitLength())
382+
{
383+
X = X.mod(M);
384+
}
385+
386+
int bits = M.bitLength();
387+
int[] m = Nat.fromBigInteger(bits, M);
388+
int[] x = Nat.fromBigInteger(bits, X);
389+
return 0 != Mod.modOddIsCoprime(m, x);
390+
}
391+
392+
public static boolean modOddIsCoprimeVar(BigInteger M, BigInteger X)
393+
{
394+
if (!M.testBit(0))
395+
{
396+
throw new IllegalArgumentException("'M' must be odd");
397+
}
398+
if (M.signum() != 1)
399+
{
400+
throw new ArithmeticException("BigInteger: modulus not positive");
401+
}
402+
if (X.signum() < 0 || X.bitLength() > M.bitLength())
403+
{
404+
X = X.mod(M);
405+
}
406+
if (X.equals(ONE))
407+
{
408+
return true;
409+
}
410+
411+
int bits = M.bitLength();
412+
int[] m = Nat.fromBigInteger(bits, M);
413+
int[] x = Nat.fromBigInteger(bits, X);
414+
return Mod.modOddIsCoprimeVar(m, x);
415+
}
371416
public static class Cache
372417
{
373418
private final Map values = new HashMap();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
package org.bouncycastle.openpgp.operator.jcajce;
2+
3+
import java.io.IOException;
4+
import java.math.BigInteger;
5+
import java.security.GeneralSecurityException;
6+
import java.security.InvalidKeyException;
7+
import java.security.NoSuchAlgorithmException;
8+
import java.security.Key;
9+
import java.security.PublicKey;
10+
import java.security.spec.AlgorithmParameterSpec;
11+
12+
import javax.crypto.KeyAgreement;
13+
import javax.crypto.SecretKey;
14+
import javax.crypto.spec.SecretKeySpec;
15+
16+
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
17+
import org.bouncycastle.asn1.x9.ECNamedCurveTable;
18+
import org.bouncycastle.asn1.x9.X9ECParameters;
19+
import org.bouncycastle.bcpg.PublicKeyPacket;
20+
import org.bouncycastle.crypto.ec.CustomNamedCurves;
21+
import org.bouncycastle.jcajce.spec.HybridValueParameterSpec;
22+
import org.bouncycastle.jcajce.spec.UserKeyingMaterialSpec;
23+
import org.bouncycastle.math.ec.ECCurve;
24+
import org.bouncycastle.math.ec.ECPoint;
25+
import org.bouncycastle.openpgp.PGPException;
26+
import org.bouncycastle.util.Arrays;
27+
import org.bouncycastle.util.BigIntegers;
28+
import org.bouncycastle.util.Strings;
29+
30+
/**
31+
* Basic utility class
32+
*/
33+
class JcaJcePGPUtil
34+
{
35+
public static SecretKey makeSymmetricKey(
36+
int algorithm,
37+
byte[] keyBytes)
38+
throws PGPException
39+
{
40+
String algName = org.bouncycastle.openpgp.PGPUtil.getSymmetricCipherName(algorithm);
41+
42+
if (algName == null)
43+
{
44+
throw new PGPException("unknown symmetric algorithm: " + algorithm);
45+
}
46+
47+
return new SecretKeySpec(keyBytes, algName);
48+
}
49+
50+
static ECPoint decodePoint(
51+
BigInteger encodedPoint,
52+
ECCurve curve)
53+
throws IOException
54+
{
55+
return curve.decodePoint(BigIntegers.asUnsignedByteArray(encodedPoint));
56+
}
57+
58+
static X9ECParameters getX9Parameters(ASN1ObjectIdentifier curveOID)
59+
{
60+
X9ECParameters x9Params = CustomNamedCurves.getByOID(curveOID);
61+
62+
if (x9Params == null)
63+
{
64+
return ECNamedCurveTable.getByOID(curveOID);
65+
}
66+
67+
return x9Params;
68+
}
69+
70+
static HybridValueParameterSpec getHybridValueParameterSpecWithPrepend(byte[] ephmeralPublicKey, PublicKeyPacket pkp, String algorithmName)
71+
throws IOException
72+
{
73+
return new HybridValueParameterSpec(Arrays.concatenate(ephmeralPublicKey, pkp.getEncoded()), true, new UserKeyingMaterialSpec(Strings.toByteArray("OpenPGP " + algorithmName)));
74+
}
75+
76+
static Key getSecret(OperatorHelper helper, PublicKey cryptoPublicKey, String keyEncryptionOID, String agreementName, AlgorithmParameterSpec ukmSpec, Key privKey)
77+
throws GeneralSecurityException
78+
{
79+
try
80+
{
81+
KeyAgreement agreement = helper.createKeyAgreement(agreementName);
82+
agreement.init(privKey, ukmSpec);
83+
agreement.doPhase(cryptoPublicKey, true);
84+
return agreement.generateSecret(keyEncryptionOID);
85+
}
86+
catch (InvalidKeyException e)
87+
{
88+
throw new GeneralSecurityException(e.toString());
89+
}
90+
catch (NoSuchAlgorithmException e)
91+
{
92+
throw new GeneralSecurityException(e.toString());
93+
}
94+
}
95+
}

0 commit comments

Comments
 (0)