RFR: 8368984: Extra slashes in Cipher transformation leads to NSPE instead of NSAE

Weijun Wang weijun at openjdk.org
Mon Oct 6 19:51:46 UTC 2025


On Mon, 6 Oct 2025 17:56:59 GMT, Valerie Peng <valeriep at openjdk.org> wrote:

>> src/java.base/share/classes/javax/crypto/Cipher.java line 329:
>> 
>>> 327:                     SHA512TRUNCATED.length());
>>> 328:             sha512SlashIdx = (sha512Idx != -1 ? sha512Idx + 3 : -2);
>>> 329:         }
>> 
>> The logic is quite complex. Can you create a dedicated method for it like `indexOfRealSlashIn(String s)`?
>> 
>> We can even call it on the mode part.
>
> There are quite a few values being updated here, that's why I didn't make it into a method initially. Let me think about it more...

Both `sha512Idx` and `sha512SlashIdx` locally assigned, `SHA512TRUNCATED` is a constant, `transformation` is not mutated.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27615#discussion_r2408217227


More information about the security-dev mailing list