KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > crypto > SecretKeyFactorySpi


1 /*
2  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
3  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
4  */

5
6 /*
7  * @(#)SecretKeyFactorySpi.java 1.4 03/12/19
8  */

9   
10 /*
11  * NOTE:
12  * Because of various external restrictions (i.e. US export
13  * regulations, etc.), the actual source code can not be provided
14  * at this time. This file represents the skeleton of the source
15  * file, so that javadocs of the API can be created.
16  */

17
18 package javax.crypto;
19
20 import java.security.*;
21 import java.security.spec.*;
22
23 /**
24  * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>)
25  * for the <code>SecretKeyFactory</code> class.
26  * All the abstract methods in this class must be implemented by each
27  * cryptographic service provider who wishes to supply the implementation
28  * of a secret-key factory for a particular algorithm.
29  *
30  * <P> A provider should document all the key specifications supported by its
31  * secret key factory.
32  * For example, the DES secret-key factory supplied by the "SunJCE" provider
33  * supports <code>DESKeySpec</code> as a transparent representation of DES
34  * keys, and that provider's secret-key factory for Triple DES keys supports
35  * <code>DESedeKeySpec</code> as a transparent representation of Triple DES
36  * keys.
37  *
38  * @author Jan Luehe
39  *
40  * @version 1.4, 12/19/03
41  *
42  * @see SecretKey
43  * @see javax.crypto.spec.DESKeySpec
44  * @see javax.crypto.spec.DESedeKeySpec
45  * @since 1.4
46  */

47 public abstract class SecretKeyFactorySpi
48 {
49
50     public SecretKeyFactorySpi() { }
51
52     /**
53      * Generates a <code>SecretKey</code> object from the
54      * provided key specification (key material).
55      *
56      * @param keySpec the specification (key material) of the secret key
57      *
58      * @return the secret key
59      *
60      * @exception InvalidKeySpecException if the given key specification
61      * is inappropriate for this secret-key factory to produce a secret key.
62      */

63     protected abstract SecretKey engineGenerateSecret(KeySpec keySpec)
64         throws InvalidKeySpecException;
65
66     /**
67      * Returns a specification (key material) of the given key
68      * object in the requested format.
69      *
70      * @param key the key
71      *
72      * @param keySpec the requested format in which the key material shall be
73      * returned
74      *
75      * @return the underlying key specification (key material) in the
76      * requested format
77      *
78      * @exception InvalidKeySpecException if the requested key specification is
79      * inappropriate for the given key (e.g., the algorithms associated with
80      * <code>key</code> and <code>keySpec</code> do not match, or
81      * <code>key</code> references a key on a cryptographic hardware device
82      * whereas <code>keySpec</code> is the specification of a software-based
83      * key), or the given key cannot be dealt with
84      * (e.g., the given key has an algorithm or format not supported by this
85      * secret-key factory).
86      */

87     protected abstract KeySpec engineGetKeySpec(SecretKey key, Class keySpec)
88         throws InvalidKeySpecException;
89
90     /**
91      * Translates a key object, whose provider may be unknown or
92      * potentially untrusted, into a corresponding key object of this
93      * secret-key factory.
94      *
95      * @param key the key whose provider is unknown or untrusted
96      *
97      * @return the translated key
98      *
99      * @exception InvalidKeyException if the given key cannot be processed
100      * by this secret-key factory.
101      */

102     protected abstract SecretKey engineTranslateKey(SecretKey key)
103         throws InvalidKeyException;
104 }
105
Popular Tags