Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/security/KeyPairGeneratorSpi.java
38829 views
/*1* Copyright (c) 1997, 2013, 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 java.security;2627import java.security.spec.AlgorithmParameterSpec;2829/**30* <p> This class defines the <i>Service Provider Interface</i> (<b>SPI</b>)31* for the {@code KeyPairGenerator} class, which is used to generate32* pairs of public and private keys.33*34* <p> All the abstract methods in this class must be implemented by each35* cryptographic service provider who wishes to supply the implementation36* of a key pair generator for a particular algorithm.37*38* <p> In case the client does not explicitly initialize the KeyPairGenerator39* (via a call to an {@code initialize} method), each provider must40* supply (and document) a default initialization.41* For example, the <i>Sun</i> provider uses a default modulus size (keysize)42* of 1024 bits.43*44* @author Benjamin Renaud45*46*47* @see KeyPairGenerator48* @see java.security.spec.AlgorithmParameterSpec49*/5051public abstract class KeyPairGeneratorSpi {5253/**54* Initializes the key pair generator for a certain keysize, using55* the default parameter set.56*57* @param keysize the keysize. This is an58* algorithm-specific metric, such as modulus length, specified in59* number of bits.60*61* @param random the source of randomness for this generator.62*63* @exception InvalidParameterException if the {@code keysize} is not64* supported by this KeyPairGeneratorSpi object.65*/66public abstract void initialize(int keysize, SecureRandom random);6768/**69* Initializes the key pair generator using the specified parameter70* set and user-provided source of randomness.71*72* <p>This concrete method has been added to this previously-defined73* abstract class. (For backwards compatibility, it cannot be abstract.)74* It may be overridden by a provider to initialize the key pair75* generator. Such an override76* is expected to throw an InvalidAlgorithmParameterException if77* a parameter is inappropriate for this key pair generator.78* If this method is not overridden, it always throws an79* UnsupportedOperationException.80*81* @param params the parameter set used to generate the keys.82*83* @param random the source of randomness for this generator.84*85* @exception InvalidAlgorithmParameterException if the given parameters86* are inappropriate for this key pair generator.87*88* @since 1.289*/90public void initialize(AlgorithmParameterSpec params,91SecureRandom random)92throws InvalidAlgorithmParameterException {93throw new UnsupportedOperationException();94}9596/**97* Generates a key pair. Unless an initialization method is called98* using a KeyPairGenerator interface, algorithm-specific defaults99* will be used. This will generate a new key pair every time it100* is called.101*102* @return the newly generated {@code KeyPair}103*/104public abstract KeyPair generateKeyPair();105}106107108