I am trying to decrypt some data from a DB and have run into some AEADBadTagExceptions, but not always.
While searching for the error, I have taken the cipher initialization and put a loop around the decryption. I.e.
GCMParameterSpec parameterSpec = new GCMParameterSpec(authenticationTagLength, ivByte);
cipher = Cipher.getInstance(AES_MODE_GCM);
cipher.init(Cipher.DECRYPT_MODE, secretKey, parameterSpec);
if (additionalDataText.length()>0) {
cipher.updateAAD(additionalDataText.getBytes("UTF-8"));
} }
for(int i = 0; i < 500; i++) {
cipher.doFinal(cypherBytes);
}
Running this code several times, I get 17/500 successes on the first try, then Zero for the next several tries. Changing the code and letting Eclipse rebuild may yield 17 or 18 successes followed by failures.
The exception is as follows
[err] javax.crypto.AEADBadTagException
[err] at com.ibm.crypto.provider.GCTRInHardware.gcm_ad(Unknown Source)
[err] at com.ibm.crypto.provider.aA.c(Unknown Source)
[err] at com.ibm.crypto.provider.AESGCMCipher.engineDoFinal(Unknown Source)
[err] at com.ibm.crypto.provider.AESGCMCipher.engineDoFinal(Unknown Source)
[err] at javax.crypto.Cipher.doFinal(Unknown Source)
Oh yeah, I'm using Java 1.8 on the "IBM J9 VM" if that helps.
Does anyone have any idea what might prompt this behaviour? Kind regards
Edit: in additional news, this seems to be caused by something on the server this is running on - I can successfully decrypt the same data on another server, and in a JUnit test. I'll have a look to see if I can find the difference in the configurations.
Solution In my jvm.options I had specified a YourKit profiler under the option -agentpath By removing this line from the options, I got it to work.
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)