Skip to content

Commit 81da673

Browse files
committed
Java 5 compatibility updates.
1 parent dd276b2 commit 81da673

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

prov/src/main/java/org/bouncycastle/jcajce/provider/keystore/pkcs12/PKCS12KeyStoreSpi.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
import org.bouncycastle.jce.provider.BouncyCastleProvider;
116116
import org.bouncycastle.jce.provider.JDKPKCS12StoreParameter;
117117
import org.bouncycastle.util.Arrays;
118+
import org.bouncycastle.util.BigIntegers;
118119
import org.bouncycastle.util.Integers;
119120
import org.bouncycastle.util.Properties;
120121
import org.bouncycastle.util.Strings;
@@ -686,7 +687,7 @@ protected byte[] wrapKey(
686687
SecretKeyFactory keyFact = helper.createSecretKeyFactory(algorithm);
687688
PBEParameterSpec defParams = new PBEParameterSpec(
688689
pbeParams.getIV(),
689-
pbeParams.getIterations().intValue());
690+
BigIntegers.intValueExact(pbeParams.getIterations()));
690691

691692
Cipher cipher = helper.createCipher(algorithm);
692693

@@ -710,7 +711,8 @@ protected byte[] wrapKey(
710711
throws IOException
711712
{
712713
PBEKeySpec pbeSpec = new PBEKeySpec(password, pbeParams.getSalt(),
713-
pbeParams.getIterationCount().intValueExact(), pbeParams.getKeyLength().intValueExact() * 8);
714+
BigIntegers.intValueExact(pbeParams.getIterationCount()),
715+
BigIntegers.intValueExact(pbeParams.getKeyLength()) * 8);
714716
byte[] out;
715717

716718
try
@@ -752,7 +754,7 @@ protected byte[] cryptData(
752754
{
753755
PBEParameterSpec defParams = new PBEParameterSpec(
754756
pbeParams.getIV(),
755-
pbeParams.getIterations().intValue());
757+
BigIntegers.intValueExact(pbeParams.getIterations()));
756758
PKCS12Key key = new PKCS12Key(password, wrongPKCS12Zero);
757759

758760
Cipher cipher = helper.createCipher(algorithm.getId());
@@ -1319,7 +1321,7 @@ else if (aOid.equals(pkcs_9_at_localKeyId))
13191321

13201322
private int validateIterationCount(BigInteger i)
13211323
{
1322-
int count = i.intValue();
1324+
int count = BigIntegers.intValueExact(i);
13231325

13241326
if (count < 0)
13251327
{
@@ -1329,9 +1331,10 @@ private int validateIterationCount(BigInteger i)
13291331
BigInteger maxValue = Properties.asBigInteger(PKCS12_MAX_IT_COUNT_PROPERTY);
13301332
if (maxValue != null)
13311333
{
1332-
if (maxValue.intValue() < count)
1334+
if (BigIntegers.intValueExact(maxValue) < count)
13331335
{
1334-
throw new IllegalStateException("iteration count " + count + " greater than " + maxValue.intValue());
1336+
throw new IllegalStateException("iteration count " + count + " greater than "
1337+
+ BigIntegers.intValueExact(maxValue));
13351338
}
13361339
}
13371340

0 commit comments

Comments
 (0)