Path: blob/master/src/java.base/share/classes/javax/crypto/spec/PBEParameterSpec.java
41159 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 javax.crypto.spec;2627import java.security.spec.AlgorithmParameterSpec;2829/**30* This class specifies the set of parameters used with password-based31* encryption (PBE), as defined in the32* <a href="http://www.ietf.org/rfc/rfc2898.txt">PKCS #5</a>33* standard.34*35* @author Jan Luehe36*37* @since 1.438*/39public class PBEParameterSpec implements AlgorithmParameterSpec {4041private byte[] salt;42private int iterationCount;43private AlgorithmParameterSpec paramSpec = null;4445/**46* Constructs a parameter set for password-based encryption as defined in47* the PKCS #5 standard.48*49* @param salt the salt. The contents of <code>salt</code> are copied50* to protect against subsequent modification.51* @param iterationCount the iteration count.52* @exception NullPointerException if <code>salt</code> is null.53*/54public PBEParameterSpec(byte[] salt, int iterationCount) {55this.salt = salt.clone();56this.iterationCount = iterationCount;57}5859/**60* Constructs a parameter set for password-based encryption as defined in61* the PKCS #5 standard.62*63* @param salt the salt. The contents of <code>salt</code> are copied64* to protect against subsequent modification.65* @param iterationCount the iteration count.66* @param paramSpec the cipher algorithm parameter specification, which67* may be null.68* @exception NullPointerException if <code>salt</code> is null.69*70* @since 1.871*/72public PBEParameterSpec(byte[] salt, int iterationCount,73AlgorithmParameterSpec paramSpec) {74this.salt = salt.clone();75this.iterationCount = iterationCount;76this.paramSpec = paramSpec;77}7879/**80* Returns the salt.81*82* @return the salt. Returns a new array83* each time this method is called.84*/85public byte[] getSalt() {86return this.salt.clone();87}8889/**90* Returns the iteration count.91*92* @return the iteration count93*/94public int getIterationCount() {95return this.iterationCount;96}9798/**99* Returns the cipher algorithm parameter specification.100*101* @return the parameter specification, or null if none was set.102*103* @since 1.8104*/105public AlgorithmParameterSpec getParameterSpec() {106return this.paramSpec;107}108}109110111