나는 탄력성을 사용하여 해독하고 DataLengthException이 발생하는 것을 잡으려고합니다. 그러나 어떤 이유로 인해 JVM은 Exception을 DataLengthException으로 인식하지 못합니다. 다른 사람이이 문제를 겪었습니까?Bouncy Castle DataLengthException이 (가) catch되지 않았습니다.
코드 : 당신이 코멘트에서 볼 수 있듯이
for (int i = 0; i < transformations.length; i++) {
try {
cipher = Cipher.getInstance(transformations[i], "BC");
cipher.init(Cipher.DECRYPT_MODE, certificate);
return cipher.doFinal(bytesTimestampEncrypted);
}
catch (ArrayIndexOutOfBoundsException e1) {
// try the next transformation
}
catch (BadPaddingException e1) {
// try the next transformation
}
catch (IllegalBlockSizeException e1) {
// try the next transformation
}
catch (NoSuchPaddingException e) {
// try the next transformation
}
catch (NoSuchAlgorithmException e) {
// try the next transformation
}
catch (InvalidKeyException e) {
// try the next transformation
}
catch (NoSuchProviderException e) {
// try the next transformation
}
catch (DataLengthException e) {
// This is the one I am trying to catch
Log.debug("Input too large for RSA cipher, trans=" + transformations[i], e);
}
catch (RuntimeException e) {
// This is the one that actually ends up catching it.
throw e;
}
}
예외 내가 테스트 이유로 단순히 추가 catch(RuntimeException)
까지 잡았되지 않습니다. 예외를 디버깅하고 RuntimeException에 중단 점을 설정했습니다. 예외는 : org.bouncycastle.crypto.DataLengthException: input too large for RSA cipher
그러나, 내가 e instance of org.bouncastle.crypto.DataLengthException
을 테스트 할 때 나는 틀리게된다.
여기에 어떤 아이디어라도 도움이 될 것입니다.
제쳐두고, 여기서 뭔가 이상한 행동을하는 것처럼 보입니다. 실제 응용 프로그램을위한 것입니까, 아니면 Java 암호화를 사용하는 방법을 알아 내려고하고 있습니까? – erickson