RFR: 8326609: New AES implementation with updates specified in FIPS 197 [v5]

Shawn M Emery duke at openjdk.org
Thu Oct 16 04:04:27 UTC 2025


On Thu, 16 Oct 2025 00:42:20 GMT, Valerie Peng <valeriep at openjdk.org> wrote:

>> src/java.base/share/classes/com/sun/crypto/provider/AES_Crypt.java line 954:
>> 
>>> 952:             }
>>> 953:             w[i] = w[i - nk] ^ tmp;
>>> 954:         }
>> 
>> Looks like most of these local variables can be removed? Since you are not changing the value of `len`, you can just use `WB`. `rW` is only used inside the if-block from line 944-948, so it can be declared on line 945.  Line 946-948 can be merged on one line, e.g. `tmp = subByte(rW, SBOX) ^ RCON[(i / nk) - 1];` and no need for `subWord` and `g`. Same goes for line 950 and 951.
>> Also, the value of `WB * (rounds + 1)` is used twice, this can be stored in a local variable say `wLen`, so it's only calculated once.
>> Same goes for the `i * WB` value from line 937-940
>
> On the second thought, instead of calculating `i * WB` value, You can use another local variable to store this index and increment it by 4 for each iteration.

I've made these changes and used the 2nd approach for indexing key.  Fixed.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/27807#discussion_r2434497439


More information about the security-dev mailing list