Path: blob/master/src/java.base/share/classes/javax/crypto/SecretKey.java
41152 views
/*1* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.crypto;2627/**28* A secret (symmetric) key.29* The purpose of this interface is to group (and provide type safety30* for) all secret key interfaces.31* <p>32* Provider implementations of this interface must overwrite the33* {@code equals} and {@code hashCode} methods inherited from34* {@link java.lang.Object}, so that secret keys are compared based on35* their underlying key material and not based on reference.36* Implementations should override the default {@code destroy} and37* {@code isDestroyed} methods from the38* {@link javax.security.auth.Destroyable} interface to enable39* sensitive key information to be destroyed, cleared, or in the case40* where such information is immutable, unreferenced.41* Finally, since {@code SecretKey} is {@code Serializable}, implementations42* should also override43* {@link java.io.ObjectOutputStream#writeObject(java.lang.Object)}44* to prevent keys that have been destroyed from being serialized.45*46* <p>Keys that implement this interface return the string {@code RAW}47* as their encoding format (see {@code getFormat}), and return the48* raw key bytes as the result of a {@code getEncoded} method call. (The49* {@code getFormat} and {@code getEncoded} methods are inherited50* from the {@link java.security.Key} parent interface.)51*52* @author Jan Luehe53*54* @see SecretKeyFactory55* @see Cipher56* @since 1.457*/5859public interface SecretKey extends60java.security.Key, javax.security.auth.Destroyable {6162/**63* The class fingerprint that is set to indicate serialization64* compatibility since J2SE 1.4.65*66* @deprecated A {@code serialVersionUID} field in an interface is67* ineffectual. Do not use; no replacement.68*/69@Deprecated70@SuppressWarnings("serial")71static final long serialVersionUID = -4795878709595146952L;72}737475