Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/security/AlgorithmParametersSpi.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.io.*;28import java.security.spec.AlgorithmParameterSpec;29import java.security.spec.InvalidParameterSpecException;3031/**32* This class defines the <i>Service Provider Interface</i> (<b>SPI</b>)33* for the {@code AlgorithmParameters} class, which is used to manage34* algorithm parameters.35*36* <p> All the abstract methods in this class must be implemented by each37* cryptographic service provider who wishes to supply parameter management38* for a particular algorithm.39*40* @author Jan Luehe41*42*43* @see AlgorithmParameters44* @see java.security.spec.AlgorithmParameterSpec45* @see java.security.spec.DSAParameterSpec46*47* @since 1.248*/4950public abstract class AlgorithmParametersSpi {5152/**53* Initializes this parameters object using the parameters54* specified in {@code paramSpec}.55*56* @param paramSpec the parameter specification.57*58* @exception InvalidParameterSpecException if the given parameter59* specification is inappropriate for the initialization of this parameter60* object.61*/62protected abstract void engineInit(AlgorithmParameterSpec paramSpec)63throws InvalidParameterSpecException;6465/**66* Imports the specified parameters and decodes them67* according to the primary decoding format for parameters.68* The primary decoding format for parameters is ASN.1, if an ASN.169* specification for this type of parameters exists.70*71* @param params the encoded parameters.72*73* @exception IOException on decoding errors74*/75protected abstract void engineInit(byte[] params)76throws IOException;7778/**79* Imports the parameters from {@code params} and80* decodes them according to the specified decoding format.81* If {@code format} is null, the82* primary decoding format for parameters is used. The primary decoding83* format is ASN.1, if an ASN.1 specification for these parameters84* exists.85*86* @param params the encoded parameters.87*88* @param format the name of the decoding format.89*90* @exception IOException on decoding errors91*/92protected abstract void engineInit(byte[] params, String format)93throws IOException;9495/**96* Returns a (transparent) specification of this parameters97* object.98* {@code paramSpec} identifies the specification class in which99* the parameters should be returned. It could, for example, be100* {@code DSAParameterSpec.class}, to indicate that the101* parameters should be returned in an instance of the102* {@code DSAParameterSpec} class.103*104* @param <T> the type of the parameter specification to be returned105*106* @param paramSpec the specification class in which107* the parameters should be returned.108*109* @return the parameter specification.110*111* @exception InvalidParameterSpecException if the requested parameter112* specification is inappropriate for this parameter object.113*/114protected abstract115<T extends AlgorithmParameterSpec>116T engineGetParameterSpec(Class<T> paramSpec)117throws InvalidParameterSpecException;118119/**120* Returns the parameters in their primary encoding format.121* The primary encoding format for parameters is ASN.1, if an ASN.1122* specification for this type of parameters exists.123*124* @return the parameters encoded using their primary encoding format.125*126* @exception IOException on encoding errors.127*/128protected abstract byte[] engineGetEncoded() throws IOException;129130/**131* Returns the parameters encoded in the specified format.132* If {@code format} is null, the133* primary encoding format for parameters is used. The primary encoding134* format is ASN.1, if an ASN.1 specification for these parameters135* exists.136*137* @param format the name of the encoding format.138*139* @return the parameters encoded using the specified encoding scheme.140*141* @exception IOException on encoding errors.142*/143protected abstract byte[] engineGetEncoded(String format)144throws IOException;145146/**147* Returns a formatted string describing the parameters.148*149* @return a formatted string describing the parameters.150*/151protected abstract String engineToString();152}153154155