Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/crypto/KeyGeneratorSpi.java
38829 views
/*1* Copyright (c) 1997, 2007, 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 javax.crypto;2627import java.security.*;28import java.security.spec.*;2930/**31* This class defines the <i>Service Provider Interface</i> (<b>SPI</b>)32* for the <code>KeyGenerator</code> class.33* All the abstract methods in this class must be implemented by each34* cryptographic service provider who wishes to supply the implementation35* of a key generator for a particular algorithm.36*37* @author Jan Luehe38*39* @see SecretKey40* @since 1.441*/4243public abstract class KeyGeneratorSpi {4445/**46* Initializes the key generator.47*48* @param random the source of randomness for this generator49*/50protected abstract void engineInit(SecureRandom random);5152/**53* Initializes the key generator with the specified parameter54* set and a user-provided source of randomness.55*56* @param params the key generation parameters57* @param random the source of randomness for this key generator58*59* @exception InvalidAlgorithmParameterException if <code>params</code> is60* inappropriate for this key generator61*/62protected abstract void engineInit(AlgorithmParameterSpec params,63SecureRandom random)64throws InvalidAlgorithmParameterException;6566/**67* Initializes this key generator for a certain keysize, using the given68* source of randomness.69*70* @param keysize the keysize. This is an algorithm-specific metric,71* specified in number of bits.72* @param random the source of randomness for this key generator73*74* @exception InvalidParameterException if the keysize is wrong or not75* supported.76*/77protected abstract void engineInit(int keysize, SecureRandom random);7879/**80* Generates a secret key.81*82* @return the new key83*/84protected abstract SecretKey engineGenerateKey();85}868788