RFR: 8297878: KEM: Implementation [v7]
Weijun Wang
weijun at openjdk.org
Mon Apr 24 19:40:43 UTC 2023
On Fri, 21 Apr 2023 22:50:00 GMT, Anthony Scarpino <ascarpino at openjdk.org> wrote:
>> Weijun Wang has updated the pull request incrementally with one additional commit since the last revision:
>>
>> fine tuning spec
>
> src/java.base/share/classes/com/sun/crypto/provider/DHKEM.java line 202:
>
>> 200: } else {
>> 201: byte[] uArray = ((XECPublicKey) k).getU().toByteArray();
>> 202: return Arrays.copyOf(reverse(uArray), Npk);
>
> You could just return the reversed array. It is already a copy of the BigInteger 'u'.
Is the size always `Npk`? It could be less (if small) or bigger (if MSB is 1).
> src/java.base/share/classes/com/sun/crypto/provider/DHKEM.java line 206:
>
>> 204: }
>> 205:
>> 206: private static byte[] reverse(byte[] arr) {
>
> It would be better to swap the bytes than allocating another array.
> DeserializePublicKey() may need to copy 'data' or have two different reverse methods
Yes, I can.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13256#discussion_r1175706882
PR Review Comment: https://git.openjdk.org/jdk/pull/13256#discussion_r1175707757
More information about the security-dev
mailing list