JDK-7185471 : Avoid key expansion when AES cipher is re-init w/ the same key
  • Type: Enhancement
  • Component: security-libs
  • Sub-Component: javax.crypto
  • Affected Version: 8
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2012-07-20
  • Updated: 2014-08-15
  • Resolved: 2012-09-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 JDK 8
7u10Fixed 8 b55Fixed
Related Reports
Relates :  
Description
Consider an application which holds on to a Cipher object for AES and keeps the same key but calls Cipher.init to change the Cipher between encryption and decryption.  The current code in AESCrypt.java recomputes the expanded key (which is an expensive operation) with each call to init.

One possible optimization is to save the key and, if it has not changed, skip recomputation on subsequent calls to Cipher.init. It'd also benefit the performance if the key expansion which currently is done in the method setSubKey() is moved to the same time when the keys are recomputed.

Comments
Changeset: http://hg.openjdk.java.net/jdk8/jdk8/jdk/rev/9e97dacbfd35
15-08-2014

EVALUATION Do as the description has said, i.e. save the cipher key and, if it has not changed, skip recomputation of sub keys on subsequent calls to Cipher.init.
27-07-2012