The application code needs to call Cipher.init again to reset cipher object to re-use its cipher object when doFinal gets exception.
The specification for doFinal in Cipher of Java 7 and Java 8 both indicate: "if any exception is thrown, this cipher object may need to be reset before it can be used again.".
https://www.ibm.com/docs/en/sdk-java-technology/8?topic=jce-cipher
https://www.ibm.com/docs/en/sdk-java-technology/7?topic=jce-cipher
> Note: if any exception is thrown, this cipher object may need to be reset before it can be used again.
There are different implementations for IBM Java 7 and IBM Java 8. But, both IBM Java 7 and IBM Java 8 are following the same specification for doFinal in Cipher. Therefore, the application code should be calling Cipher.init to reset cipher object like below when doFinal gets any exception for any Java or JCE version.
```
try{
cipher.doFinal(...);
} catch (Exception e) {
cipher.init(Cipher.DECRYPT_MODE, ...);
}
```
#Support#SupportMigration#WebSphereApplicationServer(WAS)