0N/A/*
3002N/A * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage sun.security.internal.spec;
0N/A
0N/Aimport java.security.spec.AlgorithmParameterSpec;
0N/A
0N/Aimport javax.crypto.SecretKey;
0N/A
0N/A/**
0N/A * Parameters for the TLS PRF (pseudo-random function). The PRF function
0N/A * is defined in RFC 2246.
0N/A * This class is used to initialize KeyGenerators of the type "TlsPrf".
0N/A *
0N/A * <p>Instances of this class are immutable.
0N/A *
0N/A * @since 1.6
0N/A * @author Andreas Sterbenz
3002N/A * @deprecated Sun JDK internal use only --- WILL BE REMOVED in a future
3002N/A * release.
0N/A */
0N/A@Deprecated
0N/Apublic class TlsPrfParameterSpec implements AlgorithmParameterSpec {
0N/A
0N/A private final SecretKey secret;
0N/A private final String label;
0N/A private final byte[] seed;
0N/A private final int outputLength;
3002N/A private final String prfHashAlg;
3002N/A private final int prfHashLength;
3002N/A private final int prfBlockSize;
0N/A
0N/A /**
0N/A * Constructs a new TlsPrfParameterSpec.
0N/A *
0N/A * @param secret the secret to use in the calculation (or null)
0N/A * @param label the label to use in the calculation
0N/A * @param seed the random seed to use in the calculation
0N/A * @param outputLength the length in bytes of the output key to be produced
3002N/A * @param prfHashAlg the name of the TLS PRF hash algorithm to use.
3002N/A * Used only for TLS 1.2+. TLS1.1 and earlier use a fixed PRF.
3002N/A * @param prfHashLength the output length of the TLS PRF hash algorithm.
3002N/A * Used only for TLS 1.2+.
3002N/A * @param prfBlockSize the input block size of the TLS PRF hash algorithm.
3002N/A * Used only for TLS 1.2+.
0N/A *
0N/A * @throws NullPointerException if label or seed is null
0N/A * @throws IllegalArgumentException if outputLength is negative
0N/A */
3002N/A public TlsPrfParameterSpec(SecretKey secret, String label,
3002N/A byte[] seed, int outputLength,
3002N/A String prfHashAlg, int prfHashLength, int prfBlockSize) {
0N/A if ((label == null) || (seed == null)) {
0N/A throw new NullPointerException("label and seed must not be null");
0N/A }
0N/A if (outputLength <= 0) {
0N/A throw new IllegalArgumentException("outputLength must be positive");
0N/A }
0N/A this.secret = secret;
0N/A this.label = label;
0N/A this.seed = seed.clone();
0N/A this.outputLength = outputLength;
3002N/A this.prfHashAlg = prfHashAlg;
3002N/A this.prfHashLength = prfHashLength;
3002N/A this.prfBlockSize = prfBlockSize;
0N/A }
0N/A
0N/A /**
0N/A * Returns the secret to use in the PRF calculation, or null if there is no
0N/A * secret.
0N/A *
0N/A * @return the secret to use in the PRF calculation, or null if there is no
0N/A * secret.
0N/A */
0N/A public SecretKey getSecret() {
0N/A return secret;
0N/A }
0N/A
0N/A /**
0N/A * Returns the label to use in the PRF calcuation.
0N/A *
0N/A * @return the label to use in the PRF calcuation.
0N/A */
0N/A public String getLabel() {
0N/A return label;
0N/A }
0N/A
0N/A /**
0N/A * Returns a copy of the seed to use in the PRF calcuation.
0N/A *
0N/A * @return a copy of the seed to use in the PRF calcuation.
0N/A */
0N/A public byte[] getSeed() {
0N/A return seed.clone();
0N/A }
0N/A
0N/A /**
0N/A * Returns the length in bytes of the output key to be produced.
0N/A *
0N/A * @return the length in bytes of the output key to be produced.
0N/A */
0N/A public int getOutputLength() {
0N/A return outputLength;
0N/A }
0N/A
3002N/A /**
3002N/A * Obtains the PRF hash algorithm to use in the PRF calculation.
3002N/A *
3002N/A * @return the hash algorithm, or null if no algorithm was specified.
3002N/A */
3002N/A public String getPRFHashAlg() {
3002N/A return prfHashAlg;
3002N/A }
3002N/A
3002N/A /**
3002N/A * Obtains the length of PRF hash algorithm.
3002N/A *
3002N/A * It would have been preferred to use MessageDigest.getDigestLength(),
3002N/A * but the API does not require implementations to support the method.
3002N/A *
3002N/A * @return the hash algorithm length.
3002N/A */
3002N/A public int getPRFHashLength() {
3002N/A return prfHashLength;
3002N/A }
3002N/A
3002N/A /**
3002N/A * Obtains the length of PRF hash algorithm.
3002N/A *
3002N/A * @return the hash algorithm length.
3002N/A */
3002N/A public int getPRFBlockSize() {
3002N/A return prfBlockSize;
3002N/A }
0N/A}