RFR: 8185127: Add tests to cover hashCode() method for java supported crypto key types [v6]

Sibabrata Sahoo ssahoo at openjdk.java.net
Wed Apr 28 06:56:22 UTC 2021


On Wed, 21 Apr 2021 00:16:59 GMT, Valerie Peng <valeriep at openjdk.org> wrote:

>> Sibabrata Sahoo has updated the pull request incrementally with two additional commits since the last revision:
>> 
>>  - Update CompareKeys.java
>>  - Update CompareKeys.java
>
> test/jdk/javax/crypto/KeyGenerator/CompareKeys.java line 85:
> 
>> 83:                 || origKey.hashCode() == copyKey.hashCode())
>> 84:                 && !Arrays.equals(origKey.getEncoded(), copyKey.getEncoded())
>> 85:                 && !origKey.getFormat().equals(copyKey.getFormat())) {
> 
> So, all of these 3 checks have to fail in order to be considered key inequality? Could you spell out clearly what is expected here? I am not sure if this compound condition is correct. As it is now, the copy must have different format(2nd condition) AND different encoding(3rd condition) AND (not equals AND not same hash code)(1st condition), in order to trigger the RuntimeException.

I have updated the condition to check for equality, hashCode, Format, Encoded bytes of original key against another copy of same. As the keys are same and the copy of key is a replica of original key, i am expecting all condition to match in same time. If there is any condition check fails then it will be treated as a mismatch. Please correct me if i am wrong here.

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

PR: https://git.openjdk.java.net/jdk/pull/3490



More information about the security-dev mailing list