Skip to content

Commit

Permalink
#392 replace call to BigInteger.intValueExact to remain comptaible wi…
Browse files Browse the repository at this point in the history
…th android api 30
  • Loading branch information
mwiede committed Sep 26, 2023
1 parent 5f092c8 commit d43dc81
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/java/com/jcraft/jsch/KeyPairPKCS8.java
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,13 @@ static Cipher getCipher(byte[] id, ASN1 encryptparams, byte[][] ivp) throws Exce
}

static int parseASN1IntegerAsInt(byte[] content) {
return new BigInteger(content).intValueExact();
BigInteger b = new BigInteger(content);
// https://github.com/mwiede/jsch/issues/392 not using intValueExact() because of Android
// incompatibility.
if (b.bitLength() <= 31) {
return b.intValue();
} else {
throw new ArithmeticException("BigInteger out of int range");
}
}
}

0 comments on commit d43dc81

Please sign in to comment.