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

Valerie Peng valeriep at openjdk.java.net
Wed Apr 21 00:22:16 UTC 2021


On Sat, 17 Apr 2021 09:36:55 GMT, Sibabrata Sahoo <ssahoo at openjdk.org> wrote:

>> This is a simple Test to add few additional API coverage for all java supported key types. The objective of this Test is to cover equals() and hashcode() methods for each key types.
>
> 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.

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

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


More information about the security-dev mailing list