Hi, I have attached a small patch that fixes PR28212: SecretKeySpec equals method does not check the object type (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28212)
The equal method now checks the object type passed to the equals method to make sure it is an instance of SecretKeySpec. Thanks, Matt Wringe Changelog: 2006-06-30 Matt Wringe <[EMAIL PROTECTED]> * javax/crypto/spec/SecretKeySpec.java (equals): Check object type
Index: SecretKeySpec.java =================================================================== RCS file: /sources/classpath/classpath/javax/crypto/spec/SecretKeySpec.java,v retrieving revision 1.3 diff -u -r1.3 SecretKeySpec.java --- SecretKeySpec.java 2 Jul 2005 20:32:45 -0000 1.3 +++ SecretKeySpec.java 30 Jun 2006 19:11:01 -0000 @@ -133,14 +133,22 @@ public boolean equals(Object o) { - byte[] okey = ((SecretKeySpec) o).getEncoded(); - if (key.length != okey.length) return false; - for (int i = 0; i < key.length; i++) + if (o instanceof SecretKeySpec) { - if (key[i] != okey[i]) + byte[] okey = ((SecretKeySpec) o).getEncoded(); + if (key.length != okey.length) return false; + for (int i = 0; i < key.length; i++) + { + if (key[i] != okey[i]) + return false; + } + return algorithm.equals(((SecretKeySpec) o).getAlgorithm()); + } + else + { + return false; } - return algorithm.equals(((SecretKeySpec) o).getAlgorithm()); } public int hashCode()