On Wed, 5 Jun 2024 03:27:51 GMT, Martin Balao <mba...@openjdk.org> wrote:

>> I understand the meaning of `k`. It seems that the code here assumes `outOfs 
>> = 0`, but this may not always be the case when operating on user-supplied 
>> output byte array, right?
>
> The code does not assume that `outOfs = 0` but that the content of `out` 
> (between 0 and `outOfs`) is previously generated output of a multi-part 
> operation (not the whole output but one that is multiple of the block size). 
> `outOfs + k` is an offset that we need to know and pass to 
> `convertCTSVariant` for the `out` slicing. @franferrax , do you see possible 
> to determine the penultimate block size from `k` only? (i.e. `int pad = k % 
> blockSize;`) This would be more resilient for handling a user-supplied value.

I am not sure that we can make the assumption `the content of out (between 0 
and outOfs) is previously generated output of a multi-part operation`. It's 
possible that the output buffer starts at a non-zero offset for storing the 
encrypt/decrypted data.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18898#discussion_r1628244076

Reply via email to