0N/A/*
2362N/A * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
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 *
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 *
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.
0N/A *
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
2362N/A * questions.
0N/A */
0N/A
0N/Apackage java.security;
0N/A
0N/A/**
0N/A * The Key interface is the top-level interface for all keys. It
0N/A * defines the functionality shared by all key objects. All keys
0N/A * have three characteristics:
0N/A *
0N/A * <UL>
0N/A *
0N/A * <LI>An Algorithm
0N/A *
0N/A * <P>This is the key algorithm for that key. The key algorithm is usually
0N/A * an encryption or asymmetric operation algorithm (such as DSA or
0N/A * RSA), which will work with those algorithms and with related
0N/A * algorithms (such as MD5 with RSA, SHA-1 with RSA, Raw DSA, etc.)
0N/A * The name of the algorithm of a key is obtained using the
0N/A * {@link #getAlgorithm() getAlgorithm} method.<P>
0N/A *
0N/A * <LI>An Encoded Form
0N/A *
0N/A * <P>This is an external encoded form for the key used when a standard
0N/A * representation of the key is needed outside the Java Virtual Machine,
0N/A * as when transmitting the key to some other party. The key
0N/A * is encoded according to a standard format (such as
0N/A * X.509 <code>SubjectPublicKeyInfo</code> or PKCS#8), and
0N/A * is returned using the {@link #getEncoded() getEncoded} method.
0N/A * Note: The syntax of the ASN.1 type <code>SubjectPublicKeyInfo</code>
0N/A * is defined as follows:
0N/A *
0N/A * <pre>
0N/A * SubjectPublicKeyInfo ::= SEQUENCE {
0N/A * algorithm AlgorithmIdentifier,
0N/A * subjectPublicKey BIT STRING }
0N/A *
0N/A * AlgorithmIdentifier ::= SEQUENCE {
0N/A * algorithm OBJECT IDENTIFIER,
0N/A * parameters ANY DEFINED BY algorithm OPTIONAL }
0N/A * </pre>
0N/A *
0N/A * For more information, see
0N/A * <a href="http://www.ietf.org/rfc/rfc3280.txt">RFC 3280:
0N/A * Internet X.509 Public Key Infrastructure Certificate and CRL Profile</a>.
0N/A * <P>
0N/A *
0N/A * <LI>A Format
0N/A *
0N/A * <P>This is the name of the format of the encoded key. It is returned
0N/A * by the {@link #getFormat() getFormat} method.<P>
0N/A *
0N/A * </UL>
0N/A *
0N/A * Keys are generally obtained through key generators, certificates,
0N/A * or various Identity classes used to manage keys.
0N/A * Keys may also be obtained from key specifications (transparent
0N/A * representations of the underlying key material) through the use of a key
0N/A * factory (see {@link KeyFactory}).
0N/A *
0N/A * <p> A Key should use KeyRep as its serialized representation.
0N/A * Note that a serialized Key may contain sensitive information
0N/A * which should not be exposed in untrusted environments. See the
0N/A * <a href="../../../platform/serialization/spec/security.html">
0N/A * Security Appendix</a>
0N/A * of the Serialization Specification for more information.
0N/A *
0N/A * @see PublicKey
0N/A * @see PrivateKey
0N/A * @see KeyPair
0N/A * @see KeyPairGenerator
0N/A * @see KeyFactory
0N/A * @see KeyRep
0N/A * @see java.security.spec.KeySpec
0N/A * @see Identity
0N/A * @see Signer
0N/A *
0N/A * @author Benjamin Renaud
0N/A */
0N/A
0N/Apublic interface Key extends java.io.Serializable {
0N/A
0N/A // Declare serialVersionUID to be compatible with JDK1.1
0N/A
0N/A /**
0N/A * The class fingerprint that is set to indicate
0N/A * serialization compatibility with a previous
0N/A * version of the class.
0N/A */
0N/A static final long serialVersionUID = 6603384152749567654L;
0N/A
0N/A /**
0N/A * Returns the standard algorithm name for this key. For
0N/A * example, "DSA" would indicate that this key is a DSA key.
0N/A * See Appendix A in the <a href=
0N/A * "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA">
0N/A * Java Cryptography Architecture API Specification &amp; Reference </a>
0N/A * for information about standard algorithm names.
0N/A *
0N/A * @return the name of the algorithm associated with this key.
0N/A */
0N/A public String getAlgorithm();
0N/A
0N/A /**
0N/A * Returns the name of the primary encoding format of this key,
0N/A * or null if this key does not support encoding.
0N/A * The primary encoding format is
0N/A * named in terms of the appropriate ASN.1 data format, if an
0N/A * ASN.1 specification for this key exists.
0N/A * For example, the name of the ASN.1 data format for public
0N/A * keys is <I>SubjectPublicKeyInfo</I>, as
0N/A * defined by the X.509 standard; in this case, the returned format is
0N/A * <code>"X.509"</code>. Similarly,
0N/A * the name of the ASN.1 data format for private keys is
0N/A * <I>PrivateKeyInfo</I>,
0N/A * as defined by the PKCS #8 standard; in this case, the returned format is
0N/A * <code>"PKCS#8"</code>.
0N/A *
0N/A * @return the primary encoding format of the key.
0N/A */
0N/A public String getFormat();
0N/A
0N/A /**
0N/A * Returns the key in its primary encoding format, or null
0N/A * if this key does not support encoding.
0N/A *
0N/A * @return the encoded key, or null if the key does not support
0N/A * encoding.
0N/A */
0N/A public byte[] getEncoded();
0N/A}