author | valeriep |
Thu, 01 Jun 2017 03:26:30 +0000 | |
changeset 45435 | 7a91c865edd4 |
parent 25859 | 3317bb8137f4 |
child 45665 | 6f21cd7ec80e |
permissions | -rw-r--r-- |
2 | 1 |
/* |
45435
7a91c865edd4
8180635: (doc) Clarify the compatibility and interoperability issue when using provider default values
valeriep
parents:
25859
diff
changeset
|
2 |
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package javax.crypto; |
|
27 |
||
28 |
import java.security.*; |
|
29 |
import java.security.spec.*; |
|
30 |
||
31 |
/** |
|
32 |
* This class defines the <i>Service Provider Interface</i> (<b>SPI</b>) |
|
33 |
* for the <code>KeyGenerator</code> class. |
|
34 |
* All the abstract methods in this class must be implemented by each |
|
35 |
* cryptographic service provider who wishes to supply the implementation |
|
36 |
* of a key generator for a particular algorithm. |
|
37 |
* |
|
45435
7a91c865edd4
8180635: (doc) Clarify the compatibility and interoperability issue when using provider default values
valeriep
parents:
25859
diff
changeset
|
38 |
* <p>In case the client does not explicitly initialize the KeyGenerator |
7a91c865edd4
8180635: (doc) Clarify the compatibility and interoperability issue when using provider default values
valeriep
parents:
25859
diff
changeset
|
39 |
* (via a call to an {@code init} method), each provider must |
7a91c865edd4
8180635: (doc) Clarify the compatibility and interoperability issue when using provider default values
valeriep
parents:
25859
diff
changeset
|
40 |
* supply (and document) a default initialization. |
7a91c865edd4
8180635: (doc) Clarify the compatibility and interoperability issue when using provider default values
valeriep
parents:
25859
diff
changeset
|
41 |
* See the Keysize Restriction sections of the |
7a91c865edd4
8180635: (doc) Clarify the compatibility and interoperability issue when using provider default values
valeriep
parents:
25859
diff
changeset
|
42 |
* <a href="{@docRoot}/../technotes/guides/security/SunProviders.html"> |
7a91c865edd4
8180635: (doc) Clarify the compatibility and interoperability issue when using provider default values
valeriep
parents:
25859
diff
changeset
|
43 |
* JDK Providers</a> |
7a91c865edd4
8180635: (doc) Clarify the compatibility and interoperability issue when using provider default values
valeriep
parents:
25859
diff
changeset
|
44 |
* document for information on the KeyGenerator defaults used by |
7a91c865edd4
8180635: (doc) Clarify the compatibility and interoperability issue when using provider default values
valeriep
parents:
25859
diff
changeset
|
45 |
* JDK providers. |
7a91c865edd4
8180635: (doc) Clarify the compatibility and interoperability issue when using provider default values
valeriep
parents:
25859
diff
changeset
|
46 |
* However, note that defaults may vary across different providers. |
7a91c865edd4
8180635: (doc) Clarify the compatibility and interoperability issue when using provider default values
valeriep
parents:
25859
diff
changeset
|
47 |
* Additionally, the default value for a provider may change in a future |
7a91c865edd4
8180635: (doc) Clarify the compatibility and interoperability issue when using provider default values
valeriep
parents:
25859
diff
changeset
|
48 |
* version. Therefore, it is recommended to explicitly initialize the |
7a91c865edd4
8180635: (doc) Clarify the compatibility and interoperability issue when using provider default values
valeriep
parents:
25859
diff
changeset
|
49 |
* KeyGenerator instead of relying on provider-specific defaults. |
7a91c865edd4
8180635: (doc) Clarify the compatibility and interoperability issue when using provider default values
valeriep
parents:
25859
diff
changeset
|
50 |
* |
2 | 51 |
* @author Jan Luehe |
52 |
* |
|
53 |
* @see SecretKey |
|
54 |
* @since 1.4 |
|
55 |
*/ |
|
56 |
||
57 |
public abstract class KeyGeneratorSpi { |
|
58 |
||
59 |
/** |
|
60 |
* Initializes the key generator. |
|
61 |
* |
|
62 |
* @param random the source of randomness for this generator |
|
63 |
*/ |
|
64 |
protected abstract void engineInit(SecureRandom random); |
|
65 |
||
66 |
/** |
|
67 |
* Initializes the key generator with the specified parameter |
|
68 |
* set and a user-provided source of randomness. |
|
69 |
* |
|
70 |
* @param params the key generation parameters |
|
71 |
* @param random the source of randomness for this key generator |
|
72 |
* |
|
73 |
* @exception InvalidAlgorithmParameterException if <code>params</code> is |
|
74 |
* inappropriate for this key generator |
|
75 |
*/ |
|
76 |
protected abstract void engineInit(AlgorithmParameterSpec params, |
|
77 |
SecureRandom random) |
|
78 |
throws InvalidAlgorithmParameterException; |
|
79 |
||
80 |
/** |
|
81 |
* Initializes this key generator for a certain keysize, using the given |
|
82 |
* source of randomness. |
|
83 |
* |
|
84 |
* @param keysize the keysize. This is an algorithm-specific metric, |
|
85 |
* specified in number of bits. |
|
86 |
* @param random the source of randomness for this key generator |
|
87 |
* |
|
88 |
* @exception InvalidParameterException if the keysize is wrong or not |
|
89 |
* supported. |
|
90 |
*/ |
|
91 |
protected abstract void engineInit(int keysize, SecureRandom random); |
|
92 |
||
93 |
/** |
|
94 |
* Generates a secret key. |
|
95 |
* |
|
96 |
* @return the new key |
|
97 |
*/ |
|
98 |
protected abstract SecretKey engineGenerateKey(); |
|
99 |
} |