All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javax.crypto.spec.OAEPParameterSpec Maven / Gradle / Ivy

There is a newer version: 1.2.9
Show newest version
/*
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 *  (the "License"); you may not use this file except in compliance with
 *  the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package javax.crypto.spec;

import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.MGF1ParameterSpec;

/**
 * The algorithm parameter specification for the OAEP Padding algorithm.
 * 

* This padding algorithm is defined in the PKCS #1 standard. */ public class OAEPParameterSpec implements AlgorithmParameterSpec { private final String mdName; private final String mgfName; private final AlgorithmParameterSpec mgfSpec; private final PSource pSrc; /** * The algorithm parameter instance with default values. *

* It uses the following parameters: *

  • message digest : "SHA-1"
  • *
  • mask generation function (mgf) : "MGF1"
  • *
  • parameters for the mgf : "SHA-1" {@link MGF1ParameterSpec#SHA1}
  • *
  • the source of the label L: {@link PSource.PSpecified#DEFAULT}
  • *
*/ public static final OAEPParameterSpec DEFAULT = new OAEPParameterSpec(); private OAEPParameterSpec() { this.mdName = "SHA-1"; this.mgfName = "MGF1"; this.mgfSpec = MGF1ParameterSpec.SHA1; this.pSrc = PSource.PSpecified.DEFAULT; } /** * Creates a new OAEPParameterSpec instance with the specified * message digest algorithm name, mask generation function * (mgf) algorithm name, parameters for the mgf * algorithm and the source of the label L. * * @param mdName * the message digest algorithm name. * @param mgfName * the mask generation function algorithm name. * @param mgfSpec * the algorithm parameter specification for the mask generation * function algorithm. * @param pSrc * the source of the label L. * @throws NullPointerException * if one of mdName, mgfName or * pSrc is null. */ public OAEPParameterSpec(String mdName, String mgfName, AlgorithmParameterSpec mgfSpec, PSource pSrc) { if (mdName == null) { throw new NullPointerException("mdName == null"); } else if (mgfName == null) { throw new NullPointerException("mgfName == null"); } else if (pSrc == null) { throw new NullPointerException("pSrc == null"); } this.mdName = mdName; this.mgfName = mgfName; this.mgfSpec = mgfSpec; this.pSrc = pSrc; } /** * Returns the algorithm name of the message digest. * * @return the algorithm name of the message digest. */ public String getDigestAlgorithm() { return mdName; } /** * Returns the algorithm name of the mask generation function. * * @return the algorithm name of the mask generation function. */ public String getMGFAlgorithm() { return mgfName; } /** * Returns the algorithm parameter specification for the mask generation * function algorithm. * * @return the algorithm parameter specification for the mask generation * function algorithm. */ public AlgorithmParameterSpec getMGFParameters() { return mgfSpec; } /** * Returns the source of the label L. * * @return the source of the label L. */ public PSource getPSource() { return pSrc; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy