Path: blob/master/src/java.base/share/classes/java/security/AlgorithmParameterGeneratorSpi.java
41152 views
/*1* Copyright (c) 1997, 2020, 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* This class defines the <i>Service Provider Interface</i> (<b>SPI</b>)31* for the {@code AlgorithmParameterGenerator} class, which32* is used to generate a set of parameters to be used with a certain algorithm.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 parameter generator for a particular algorithm.37*38* <p> In case the client does not explicitly initialize the39* AlgorithmParameterGenerator (via a call to an {@code engineInit}40* method), each provider must supply (and document) a default initialization.41* See the Keysize Restriction sections of the42* {@extLink security_guide_jdk_providers JDK Providers}43* document for information on the AlgorithmParameterGenerator defaults44* used by JDK providers.45* However, note that defaults may vary across different providers.46* Additionally, the default value for a provider may change in a future47* version. Therefore, it is recommended to explicitly initialize the48* AlgorithmParameterGenerator instead of relying on provider-specific defaults.49*50* @author Jan Luehe51*52*53* @see AlgorithmParameterGenerator54* @see AlgorithmParameters55* @see java.security.spec.AlgorithmParameterSpec56*57* @since 1.258*/5960public abstract class AlgorithmParameterGeneratorSpi {6162/**63* Constructor for subclasses to call.64*/65public AlgorithmParameterGeneratorSpi() {}6667/**68* Initializes this parameter generator for a certain size69* and source of randomness.70*71* @param size the size (number of bits).72* @param random the source of randomness.73*/74protected abstract void engineInit(int size, SecureRandom random);7576/**77* Initializes this parameter generator with a set of78* algorithm-specific parameter generation values.79*80* @param genParamSpec the set of algorithm-specific parameter generation values.81* @param random the source of randomness.82*83* @throws InvalidAlgorithmParameterException if the given parameter84* generation values are inappropriate for this parameter generator.85*/86protected abstract void engineInit(AlgorithmParameterSpec genParamSpec,87SecureRandom random)88throws InvalidAlgorithmParameterException;8990/**91* Generates the parameters.92*93* @return the new AlgorithmParameters object.94*/95protected abstract AlgorithmParameters engineGenerateParameters();96}979899