diff options
14 files changed, 28 insertions, 20 deletions
diff --git a/src/main/java/org/bouncycastle/asn1/cms/SCVPReqRes.java b/src/main/java/org/bouncycastle/asn1/cms/SCVPReqRes.java index c8413636..e9b91eb5 100644 --- a/src/main/java/org/bouncycastle/asn1/cms/SCVPReqRes.java +++ b/src/main/java/org/bouncycastle/asn1/cms/SCVPReqRes.java @@ -46,7 +46,8 @@ public class SCVPReqRes public SCVPReqRes(ContentInfo response) { - this(null, response); + this.request = null; // use of this confuses earlier JDKs + this.response = response; } public SCVPReqRes(ContentInfo request, ContentInfo response) diff --git a/src/main/java/org/bouncycastle/asn1/x500/style/IETFUtils.java b/src/main/java/org/bouncycastle/asn1/x500/style/IETFUtils.java index 91a4ec9e..0cbad08e 100644 --- a/src/main/java/org/bouncycastle/asn1/x500/style/IETFUtils.java +++ b/src/main/java/org/bouncycastle/asn1/x500/style/IETFUtils.java @@ -100,7 +100,7 @@ public class IETFUtils { while (buf.charAt(buf.length() - 1) == ' ' && lastEscaped != (buf.length() - 1)) { - buf.deleteCharAt(buf.length() - 1); + buf.setLength(buf.length() - 1); } } diff --git a/src/main/java/org/bouncycastle/asn1/x509/X509Name.java b/src/main/java/org/bouncycastle/asn1/x509/X509Name.java index ee4f7fe9..af2c9a93 100644 --- a/src/main/java/org/bouncycastle/asn1/x509/X509Name.java +++ b/src/main/java/org/bouncycastle/asn1/x509/X509Name.java @@ -751,7 +751,7 @@ public class X509Name { while (buf.charAt(buf.length() - 1) == ' ' && lastEscaped != (buf.length() - 1)) { - buf.deleteCharAt(buf.length() - 1); + buf.setLength(buf.length() - 1); } } diff --git a/src/main/java/org/bouncycastle/crypto/kems/RSAKeyEncapsulation.java b/src/main/java/org/bouncycastle/crypto/kems/RSAKeyEncapsulation.java index 5ffd356a..ae76881e 100755 --- a/src/main/java/org/bouncycastle/crypto/kems/RSAKeyEncapsulation.java +++ b/src/main/java/org/bouncycastle/crypto/kems/RSAKeyEncapsulation.java @@ -17,6 +17,9 @@ import org.bouncycastle.util.BigIntegers; public class RSAKeyEncapsulation implements KeyEncapsulation { + private static final BigInteger ZERO = BigInteger.valueOf(0); + private static final BigInteger ONE = BigInteger.valueOf(1); + private DerivationFunction kdf; private SecureRandom rnd; private RSAKeyParameters key; @@ -75,7 +78,7 @@ public class RSAKeyEncapsulation BigInteger e = key.getExponent(); // Generate the ephemeral random and encode it - BigInteger r = BigIntegers.createRandomInRange(BigInteger.ZERO, n.subtract(BigInteger.ONE), rnd); + BigInteger r = BigIntegers.createRandomInRange(ZERO, n.subtract(ONE), rnd); byte[] R = BigIntegers.asUnsignedByteArray((n.bitLength()+7)/8, r); // Encrypt the random and encode it diff --git a/src/main/java/org/bouncycastle/crypto/macs/GMac.java b/src/main/java/org/bouncycastle/crypto/macs/GMac.java index ce29f8f7..8aae1e26 100644 --- a/src/main/java/org/bouncycastle/crypto/macs/GMac.java +++ b/src/main/java/org/bouncycastle/crypto/macs/GMac.java @@ -31,7 +31,9 @@ public class GMac implements Mac */ public GMac(final GCMBlockCipher cipher) { - this(cipher, 128); + // use of this confused flow analyser in some earlier JDKs + this.cipher = cipher; + this.macSizeBits = 128; } /** diff --git a/src/main/java/org/bouncycastle/crypto/macs/SipHash.java b/src/main/java/org/bouncycastle/crypto/macs/SipHash.java index a8f693e9..01f159b4 100644 --- a/src/main/java/org/bouncycastle/crypto/macs/SipHash.java +++ b/src/main/java/org/bouncycastle/crypto/macs/SipHash.java @@ -1,12 +1,11 @@ package org.bouncycastle.crypto.macs;
-import java.util.Arrays;
-
import org.bouncycastle.crypto.CipherParameters;
import org.bouncycastle.crypto.DataLengthException;
import org.bouncycastle.crypto.Mac;
import org.bouncycastle.crypto.params.KeyParameter;
import org.bouncycastle.crypto.util.Pack;
+import org.bouncycastle.util.Arrays;
/**
* Implementation of SipHash as specified in "SipHash: a fast short-input PRF", by Jean-Philippe
@@ -35,7 +34,9 @@ public class SipHash */
public SipHash()
{
- this(2, 4);
+ // use of this confuses flow analyser on earlier JDKs.
+ this.c = 2;
+ this.d = 4;
}
/**
diff --git a/src/main/java/org/bouncycastle/crypto/tls/CertificateRequest.java b/src/main/java/org/bouncycastle/crypto/tls/CertificateRequest.java index 7b6f9a01..00bf9508 100644 --- a/src/main/java/org/bouncycastle/crypto/tls/CertificateRequest.java +++ b/src/main/java/org/bouncycastle/crypto/tls/CertificateRequest.java @@ -91,7 +91,7 @@ public class CertificateRequest int totalLength = 0; for (int i = 0; i < certificateAuthorities.size(); ++i) { - X500Name authorityDN = (X500Name)certificateAuthorities.get(i); + X500Name authorityDN = (X500Name)certificateAuthorities.elementAt(i); byte[] encDN = authorityDN.getEncoded(ASN1Encoding.DER); encDNs.addElement(encDN); totalLength += encDN.length; diff --git a/src/main/java/org/bouncycastle/crypto/tls/DTLSReassembler.java b/src/main/java/org/bouncycastle/crypto/tls/DTLSReassembler.java index 99111b2c..93d1038a 100644 --- a/src/main/java/org/bouncycastle/crypto/tls/DTLSReassembler.java +++ b/src/main/java/org/bouncycastle/crypto/tls/DTLSReassembler.java @@ -54,7 +54,7 @@ class DTLSReassembler for (int i = 0; i < missing.size(); ++i)
{
- Range range = (Range)missing.get(i);
+ Range range = (Range)missing.elementAt(i);
if (range.getStart() >= fragment_end)
{
break;
@@ -98,7 +98,7 @@ class DTLSReassembler void reset()
{
- this.missing.clear();
+ this.missing.removeAllElements();
this.missing.addElement(new Range(0, body.length));
}
diff --git a/src/main/java/org/bouncycastle/crypto/tls/DTLSReliableHandshake.java b/src/main/java/org/bouncycastle/crypto/tls/DTLSReliableHandshake.java index 7e3e3c6a..40b2c74f 100644 --- a/src/main/java/org/bouncycastle/crypto/tls/DTLSReliableHandshake.java +++ b/src/main/java/org/bouncycastle/crypto/tls/DTLSReliableHandshake.java @@ -51,7 +51,7 @@ class DTLSReliableHandshake {
checkInboundFlight();
sending = true;
- outboundFlight.clear();
+ outboundFlight.removeAllElements();
}
Message message = new Message(message_seq++, msg_type, body);
diff --git a/src/main/java/org/bouncycastle/crypto/tls/DTLSReplayWindow.java b/src/main/java/org/bouncycastle/crypto/tls/DTLSReplayWindow.java index 98e050ce..05ccea5e 100644 --- a/src/main/java/org/bouncycastle/crypto/tls/DTLSReplayWindow.java +++ b/src/main/java/org/bouncycastle/crypto/tls/DTLSReplayWindow.java @@ -73,7 +73,7 @@ class DTLSReplayWindow }
else
{
- bitmap <<= diff;
+ bitmap <<= (int)diff; // for earlier JDKs
bitmap |= 1;
}
latestConfirmedSeq = seq;
diff --git a/src/main/java/org/bouncycastle/jcajce/provider/digest/SHA1.java b/src/main/java/org/bouncycastle/jcajce/provider/digest/SHA1.java index 0101190a..8033e590 100644 --- a/src/main/java/org/bouncycastle/jcajce/provider/digest/SHA1.java +++ b/src/main/java/org/bouncycastle/jcajce/provider/digest/SHA1.java @@ -18,6 +18,7 @@ import org.bouncycastle.jcajce.provider.symmetric.util.BCPBEKey; import org.bouncycastle.jcajce.provider.symmetric.util.BaseKeyGenerator; import org.bouncycastle.jcajce.provider.symmetric.util.BaseMac; import org.bouncycastle.jcajce.provider.symmetric.util.BaseSecretKeyFactory; +import org.bouncycastle.jcajce.provider.symmetric.util.PBE; import org.bouncycastle.jcajce.provider.symmetric.util.PBESecretKeyFactory; public class SHA1 @@ -133,8 +134,8 @@ public class SHA1 int scheme = PKCS5S2; int digest = SHA1; int keySize = pbeSpec.getKeyLength(); - int ivSize = -1; - CipherParameters param = Util.makePBEMacParameters(pbeSpec, scheme, digest, keySize); + int ivSize = -1; // JDK 1,2 and earlier does not understand simplified version. + CipherParameters param = PBE.Util.makePBEMacParameters(pbeSpec, scheme, digest, keySize); return new BCPBEKey(this.algName, this.algOid, scheme, digest, keySize, ivSize, pbeSpec, param); } diff --git a/src/main/java/org/bouncycastle/openpgp/PGPPublicKey.java b/src/main/java/org/bouncycastle/openpgp/PGPPublicKey.java index 3f845a6d..bbe7f1c9 100644 --- a/src/main/java/org/bouncycastle/openpgp/PGPPublicKey.java +++ b/src/main/java/org/bouncycastle/openpgp/PGPPublicKey.java @@ -434,7 +434,6 @@ public class PGPPublicKey * @param provider provider to construct the key for. * @return a JCE/JCA public key. * @throws PGPException if the key algorithm is not recognised. - * @throws NoSuchProviderException if the provider cannot be found. * @deprecated use a JcaPGPKeyConverter */ public PublicKey getKey( diff --git a/src/main/java/org/bouncycastle/openssl/MiscPEMGenerator.java b/src/main/java/org/bouncycastle/openssl/MiscPEMGenerator.java index 5741993f..488b9282 100644 --- a/src/main/java/org/bouncycastle/openssl/MiscPEMGenerator.java +++ b/src/main/java/org/bouncycastle/openssl/MiscPEMGenerator.java @@ -51,7 +51,8 @@ public class MiscPEMGenerator public MiscPEMGenerator(Object o) { - this(o, null); + this.obj = o; // use of this confuses some earlier JDKs. + this.encryptor = null; } public MiscPEMGenerator(Object o, PEMEncryptor encryptor) diff --git a/src/main/java/org/bouncycastle/operator/bc/BcDefaultDigestProvider.java b/src/main/java/org/bouncycastle/operator/bc/BcDefaultDigestProvider.java index 47bcab3d..655b695b 100644 --- a/src/main/java/org/bouncycastle/operator/bc/BcDefaultDigestProvider.java +++ b/src/main/java/org/bouncycastle/operator/bc/BcDefaultDigestProvider.java @@ -28,9 +28,9 @@ import org.bouncycastle.operator.OperatorCreationException; public class BcDefaultDigestProvider implements BcDigestProvider { - private static final Map lookup; + private static final Map lookup = createTable(); - static + private static Map createTable() { Map table = new HashMap(); @@ -119,7 +119,7 @@ public class BcDefaultDigestProvider } }); - lookup = Collections.unmodifiableMap(table); + return Collections.unmodifiableMap(table); } public static final BcDigestProvider INSTANCE = new BcDefaultDigestProvider(); |