jdk/src/share/classes/javax/crypto/spec/SecretKeySpec.java
author jjg
Mon, 15 Aug 2011 11:48:20 -0700
changeset 10336 0bb1999251f8
parent 5506 202f599c92aa
child 18156 edb590d448c5
permissions -rw-r--r--
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror Reviewed-by: xuelei, mullan Contributed-by: alexandre.boulgakov@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
     2
 * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.crypto.spec;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.security.spec.KeySpec;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.crypto.SecretKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * This class specifies a secret key in a provider-independent fashion.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * <p>It can be used to construct a <code>SecretKey</code> from a byte array,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * without having to go through a (provider-based)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * <code>SecretKeyFactory</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * <p>This class is only useful for raw secret keys that can be represented as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * a byte array and have no key parameters associated with them, e.g., DES or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * Triple DES keys.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * @author Jan Luehe
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * @see javax.crypto.SecretKey
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * @see javax.crypto.SecretKeyFactory
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
public class SecretKeySpec implements KeySpec, SecretKey {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    private static final long serialVersionUID = 6577238317307289933L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * The secret key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    private byte[] key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * The name of the algorithm associated with this key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    private String algorithm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * Constructs a secret key from the given byte array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * <p>This constructor does not check if the given bytes indeed specify a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * secret key of the specified algorithm. For example, if the algorithm is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * DES, this constructor does not check if <code>key</code> is 8 bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * long, and also does not check for weak or semi-weak keys.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * In order for those checks to be performed, an algorithm-specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * <i>key specification</i> class (in this case:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * {@link DESKeySpec DESKeySpec})
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * should be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * @param key the key material of the secret key. The contents of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * the array are copied to protect against subsequent modification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * @param algorithm the name of the secret-key algorithm to be associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * with the given key material.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * See Appendix A in the <a href=
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     *   "{@docRoot}/../technotes/guides/security/crypto/CryptoSpec.html#AppA">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * Java Cryptography Architecture Reference Guide</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * for information about standard algorithm names.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * @exception IllegalArgumentException if <code>algorithm</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * is null or <code>key</code> is null or empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    public SecretKeySpec(byte[] key, String algorithm) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        if (key == null || algorithm == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
            throw new IllegalArgumentException("Missing argument");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        if (key.length == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            throw new IllegalArgumentException("Empty key");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        }
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
    96
        this.key = key.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        this.algorithm = algorithm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * Constructs a secret key from the given byte array, using the first
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * <code>len</code> bytes of <code>key</code>, starting at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * <code>offset</code> inclusive.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * <p> The bytes that constitute the secret key are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * those between <code>key[offset]</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * <code>key[offset+len-1]</code> inclusive.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * <p>This constructor does not check if the given bytes indeed specify a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * secret key of the specified algorithm. For example, if the algorithm is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * DES, this constructor does not check if <code>key</code> is 8 bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * long, and also does not check for weak or semi-weak keys.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * In order for those checks to be performed, an algorithm-specific key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * specification class (in this case:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * {@link DESKeySpec DESKeySpec})
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * must be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * @param key the key material of the secret key. The first
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * <code>len</code> bytes of the array beginning at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * <code>offset</code> inclusive are copied to protect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * against subsequent modification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * @param offset the offset in <code>key</code> where the key material
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * starts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * @param len the length of the key material.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * @param algorithm the name of the secret-key algorithm to be associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * with the given key material.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * See Appendix A in the <a href=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     *   "{@docRoot}/../technotes/guides/security/crypto/CryptoSpec.html#AppA">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * Java Cryptography Architecture Reference Guide</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * for information about standard algorithm names.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @exception IllegalArgumentException if <code>algorithm</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * is null or <code>key</code> is null, empty, or too short,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * i.e. <code>key.length-offset<len</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * @exception ArrayIndexOutOfBoundsException is thrown if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * <code>offset</code> or <code>len</code> index bytes outside the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * <code>key</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    public SecretKeySpec(byte[] key, int offset, int len, String algorithm) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        if (key == null || algorithm == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            throw new IllegalArgumentException("Missing argument");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        if (key.length == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            throw new IllegalArgumentException("Empty key");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        if (key.length-offset < len) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            throw new IllegalArgumentException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                ("Invalid offset/length combination");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        if (len < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            throw new ArrayIndexOutOfBoundsException("len is negative");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        this.key = new byte[len];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        System.arraycopy(key, offset, this.key, 0, len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        this.algorithm = algorithm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * Returns the name of the algorithm associated with this secret key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @return the secret key algorithm.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    public String getAlgorithm() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        return this.algorithm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * Returns the name of the encoding format for this secret key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * @return the string "RAW".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    public String getFormat() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        return "RAW";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * Returns the key material of this secret key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * @return the key material. Returns a new array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * each time this method is called.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    public byte[] getEncoded() {
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   182
        return this.key.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * Calculates a hash code value for the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * Objects that are equal will also have the same hashcode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        int retval = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        for (int i = 1; i < this.key.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            retval += this.key[i] * i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        if (this.algorithm.equalsIgnoreCase("TripleDES"))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            return (retval ^= "desede".hashCode());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            return (retval ^= this.algorithm.toLowerCase().hashCode());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * Tests for equality between the specified object and this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * object. Two SecretKeySpec objects are considered equal if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * they are both SecretKey instances which have the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * same case-insensitive algorithm name and key encoding.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * @param obj the object to test for equality with this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * @return true if the objects are considered equal, false if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * <code>obj</code> is null or otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    public boolean equals(Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        if (this == obj)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        if (!(obj instanceof SecretKey))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        String thatAlg = ((SecretKey)obj).getAlgorithm();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        if (!(thatAlg.equalsIgnoreCase(this.algorithm))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            if ((!(thatAlg.equalsIgnoreCase("DESede"))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                 || !(this.algorithm.equalsIgnoreCase("TripleDES")))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                && (!(thatAlg.equalsIgnoreCase("TripleDES"))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                    || !(this.algorithm.equalsIgnoreCase("DESede"))))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        byte[] thatKey = ((SecretKey)obj).getEncoded();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        return java.util.Arrays.equals(this.key, thatKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
}