2362N/A * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * This class specifies a secret key in a provider-independent fashion. 0N/A * <p>It can be used to construct a <code>SecretKey</code> from a byte array, 0N/A * without having to go through a (provider-based) 0N/A * <code>SecretKeyFactory</code>. 0N/A * <p>This class is only useful for raw secret keys that can be represented as 0N/A * a byte array and have no key parameters associated with them, e.g., DES or 0N/A * @see javax.crypto.SecretKey 0N/A * @see javax.crypto.SecretKeyFactory 0N/A * The name of the algorithm associated with this key. 0N/A * Constructs a secret key from the given byte array. 0N/A * <p>This constructor does not check if the given bytes indeed specify a 0N/A * secret key of the specified algorithm. For example, if the algorithm is 0N/A * DES, this constructor does not check if <code>key</code> is 8 bytes 0N/A * long, and also does not check for weak or semi-weak keys. 0N/A * In order for those checks to be performed, an algorithm-specific 0N/A * <i>key specification</i> class (in this case: 0N/A * {@link DESKeySpec DESKeySpec}) 0N/A * @param key the key material of the secret key. The contents of 0N/A * the array are copied to protect against subsequent modification. 0N/A * @param algorithm the name of the secret-key algorithm to be associated 0N/A * with the given key material. 0N/A * See Appendix A in the <a href= 0N/A * Java Cryptography Architecture Reference Guide</a> 0N/A * for information about standard algorithm names. 0N/A * @exception IllegalArgumentException if <code>algorithm</code> 0N/A * is null or <code>key</code> is null or empty. 0N/A * Constructs a secret key from the given byte array, using the first 0N/A * <code>len</code> bytes of <code>key</code>, starting at 0N/A * <code>offset</code> inclusive. 0N/A * <p> The bytes that constitute the secret key are 0N/A * those between <code>key[offset]</code> and 0N/A * <code>key[offset+len-1]</code> inclusive. 0N/A * <p>This constructor does not check if the given bytes indeed specify a 0N/A * secret key of the specified algorithm. For example, if the algorithm is 0N/A * DES, this constructor does not check if <code>key</code> is 8 bytes 0N/A * long, and also does not check for weak or semi-weak keys. 0N/A * In order for those checks to be performed, an algorithm-specific key 0N/A * specification class (in this case: 0N/A * {@link DESKeySpec DESKeySpec}) 0N/A * @param key the key material of the secret key. The first 0N/A * <code>len</code> bytes of the array beginning at 0N/A * <code>offset</code> inclusive are copied to protect 0N/A * against subsequent modification. 0N/A * @param offset the offset in <code>key</code> where the key material 0N/A * @param len the length of the key material. 0N/A * @param algorithm the name of the secret-key algorithm to be associated 0N/A * with the given key material. 0N/A * See Appendix A in the <a href= 0N/A * Java Cryptography Architecture Reference Guide</a> 0N/A * for information about standard algorithm names. 0N/A * @exception IllegalArgumentException if <code>algorithm</code> 0N/A * is null or <code>key</code> is null, empty, or too short, 0N/A * i.e. <code>key.length-offset<len</code>. 0N/A * @exception ArrayIndexOutOfBoundsException is thrown if 0N/A * <code>offset</code> or <code>len</code> index bytes outside the 0N/A * Returns the name of the algorithm associated with this secret key. 0N/A * @return the secret key algorithm. 0N/A * Returns the name of the encoding format for this secret key. 0N/A * @return the string "RAW". 0N/A * Returns the key material of this secret key. 0N/A * @return the key material. Returns a new array 0N/A * each time this method is called. 0N/A * Calculates a hash code value for the object. 0N/A * Objects that are equal will also have the same hashcode. 0N/A * Tests for equality between the specified object and this 0N/A * object. Two SecretKeySpec objects are considered equal if 0N/A * they are both SecretKey instances which have the 0N/A * same case-insensitive algorithm name and key encoding. 0N/A * @param obj the object to test for equality with this object. 0N/A * @return true if the objects are considered equal, false if 0N/A * <code>obj</code> is null or otherwise.