On Fri, 7 Nov 2025 10:39:37 GMT, Ferenc Rakoczi <[email protected]> wrote:
>> This fix improves performance in the AES key schedule generation by >> eliminating an unnecessary object and unnecessary mask in the inverse key >> schedule. >> >> The micro:org.openjdk.bench.javax.crypto.AESReinit benchmark results are >> improved by 6.96% for arm64 and 7.79% for x86_64. >> >> Thank you @jnimeh for catching the unnecessary byte mask! > > src/java.base/share/classes/com/sun/crypto/provider/AES_Crypt.java line 1017: > >> 1015: | ((SBOX[(b1 & 0xF0) >> 4][b1 & 0x0F] & 0xFF) << 16) >> 1016: | ((SBOX[(b2 & 0xF0) >> 4][b2 & 0x0F] & 0xFF) << 8) >> 1017: | (SBOX[(word & 0xF0) >> 4][word & 0x0F] & 0xFF); > > I think there is no need for any of these bytes. Every index can be computed > as "(word >> offset) & 0x0F". Actually, if you define SBOX as a 1-dim array, > you can index into it with "(word >> offset) & 0xFF". Thank you for your review. The byte assignments were to avoid three redundant shift operations. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/28188#discussion_r2505772947
