01: /*
02: *
03: *
04: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: */
26:
27: package com.sun.midp.crypto;
28:
29: /**
30: * Implements an abstract class that represents all keys (both
31: * symmetric and asymmetric).
32: */
33: public abstract interface Key {
34: /**
35: * Returns the name of the algorithm associated with this secret key.
36: *
37: * @return the secret key algorithm.
38: */
39: String getAlgorithm();
40:
41: /**
42: * Returns the name of the primary encoding format of this key, or null
43: * if this key does not support encoding. The primary encoding format is
44: * named in terms of the appropriate ASN.1 data format, if an ASN.1
45: * specification for this key exists. For example, the name of the ASN.1
46: * data format for public keys is <I>SubjectPublicKeyInfo</I>, as defined
47: * by
48: * the X.509 standard; in this case, the returned format is
49: * <code>"X.509"</code>.
50: * Similarly, the name of the ASN.1 data format for private keys is
51: * <I>PrivateKeyInfo</I>, as defined by the PKCS #8 standard; in this
52: * case,
53: * the returned format is <code>"PKCS#8"</code>.
54: *
55: * @return the primary encoding format of the key.
56: */
57: String getFormat();
58:
59: /**
60: * Returns the key in its primary encoding format, or null
61: * if this key does not support encoding.
62: *
63: * @return the encoded key, or null if the key does not support encoding.
64: */
65: byte[] getEncoded();
66: }
|