jdk/src/share/classes/java/security/spec/EllipticCurve.java
changeset 9556 79c47f5e241b
parent 5506 202f599c92aa
child 18156 edb590d448c5
equal deleted inserted replaced
9366:a230e69f7bc8 9556:79c47f5e241b
     1 /*
     1 /*
     2  * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   163     /**
   163     /**
   164      * Compares this elliptic curve for equality with the
   164      * Compares this elliptic curve for equality with the
   165      * specified object.
   165      * specified object.
   166      * @param obj the object to be compared.
   166      * @param obj the object to be compared.
   167      * @return true if <code>obj</code> is an instance of
   167      * @return true if <code>obj</code> is an instance of
   168      * EllipticCurve and the field, A, B, and seeding bytes
   168      * EllipticCurve and the field, A, and B match, false otherwise.
   169      * match, false otherwise.
       
   170      */
   169      */
   171     public boolean equals(Object obj) {
   170     public boolean equals(Object obj) {
   172         if (this == obj) return true;
   171         if (this == obj) return true;
   173         if (obj instanceof EllipticCurve) {
   172         if (obj instanceof EllipticCurve) {
   174             EllipticCurve curve = (EllipticCurve) obj;
   173             EllipticCurve curve = (EllipticCurve) obj;
   175             if ((field.equals(curve.field)) &&
   174             if ((field.equals(curve.field)) &&
   176                 (a.equals(curve.a)) &&
   175                 (a.equals(curve.a)) &&
   177                 (b.equals(curve.b)) &&
   176                 (b.equals(curve.b))) {
   178                 (Arrays.equals(seed, curve.seed))) {
   177                     return true;
   179                 return true;
       
   180             }
   178             }
   181         }
   179         }
   182         return false;
   180         return false;
   183     }
   181     }
   184 
   182 
   185     /**
   183     /**
   186      * Returns a hash code value for this elliptic curve.
   184      * Returns a hash code value for this elliptic curve.
   187      * @return a hash code value.
   185      * @return a hash code value computed from the hash codes of the field, A,
       
   186      * and B, as follows:
       
   187      * <code>
       
   188      *     (field.hashCode() << 6) + (a.hashCode() << 4) + (b.hashCode() << 2)
       
   189      * </code>
   188      */
   190      */
   189     public int hashCode() {
   191     public int hashCode() {
   190         return (field.hashCode() << 6 +
   192         return (field.hashCode() << 6 +
   191             (a.hashCode() << 4) +
   193             (a.hashCode() << 4) +
   192             (b.hashCode() << 2) +
   194             (b.hashCode() << 2));
   193             (seed==null? 0:seed.length));
       
   194     }
   195     }
   195 }
   196 }