On Fri, 12 Sep 2025 23:39:37 GMT, Weijun Wang <[email protected]> wrote:

>> src/java.base/share/classes/javax/crypto/spec/HPKEParameterSpec.java line 
>> 317:
>> 
>>> 315:             throw new IllegalArgumentException("psk_id is empty");
>>> 316:         }
>>> 317:         if ("RAW".equalsIgnoreCase(psk.getFormat())) {
>> 
>> What happens if the format is not RAW?  Is that allowed or should it be an 
>> IAE?
>> If `psk` is an  16 byte AES Secret key is that checked somewhere or at all 
>> relevant?
>
> I just meant if it's not "RAW" (maybe `null`?) then I have no way to check 
> its length. A 16 byte AES will be rejected if it has an encoding which is 
> almost always of "RAW" format.
> 
> Or, did you confuse `getAlgorithm` and `getFormat`?

I know it's `getFormat`.  Since there is a length check for "RAW", I was 
wondering why "PKCS#8", didn't use `psk.getEncoded().length` to checked.  If 
you are handling the "RAW" case in this method and later on a short key is 
checked, that is fine.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18411#discussion_r2350270555

Reply via email to