jdk/src/share/classes/sun/security/internal/spec/TlsKeyMaterialParameterSpec.java
author wetmore
Tue, 12 Mar 2013 15:31:49 -0700
changeset 16067 36055e4b5305
parent 16045 9d08c3b9a6a0
child 16913 a6f4d1626ad9
permissions -rw-r--r--
8009925: Back out AEAD CipherSuites temporarily Reviewed-by: valeriep
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
16067
36055e4b5305 8009925: Back out AEAD CipherSuites temporarily
wetmore
parents: 16045
diff changeset
     2
 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.security.internal.spec;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.security.spec.AlgorithmParameterSpec;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import javax.crypto.SecretKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * Parameters for SSL/TLS key material generation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * This class is used to initialize KeyGenerator of the type
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * "TlsKeyMaterial". The keys returned by such KeyGenerators will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * instances of {@link TlsKeyMaterialSpec}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * <p>Instances of this class are immutable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * @since   1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * @author  Andreas Sterbenz
7043
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
    42
 * @deprecated Sun JDK internal use only --- WILL BE REMOVED in a future
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
    43
 * release.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
@Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
public class TlsKeyMaterialParameterSpec implements AlgorithmParameterSpec {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    private final SecretKey masterSecret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    private final int majorVersion, minorVersion;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    private final byte[] clientRandom, serverRandom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private final String cipherAlgorithm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    private final int cipherKeyLength, ivLength, macKeyLength;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    private final int expandedCipherKeyLength; // == 0 for domestic ciphersuites
7043
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
    54
    private final String prfHashAlg;
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
    55
    private final int prfHashLength;
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
    56
    private final int prfBlockSize;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * Constructs a new TlsKeyMaterialParameterSpec.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * @param masterSecret the master secret
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * @param majorVersion the major number of the protocol version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * @param minorVersion the minor number of the protocol version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * @param clientRandom the client's random value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * @param serverRandom the server's random value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * @param cipherAlgorithm the algorithm name of the cipher keys to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     *    be generated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * @param cipherKeyLength if 0, no cipher keys will be generated;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     *    otherwise, the length in bytes of cipher keys to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     *    generated for domestic cipher suites; for cipher suites defined as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     *    exportable, the number of key material bytes to be generated;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * @param expandedCipherKeyLength 0 for domestic cipher suites; for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     *    exportable cipher suites the length in bytes of the key to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     *    generated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * @param ivLength the length in bytes of the initialization vector
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     *    to be generated, or 0 if no initialization vector is required
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * @param macKeyLength the length in bytes of the MAC key to be generated
7043
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
    78
     * @param prfHashAlg the name of the TLS PRF hash algorithm to use.
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
    79
     *        Used only for TLS 1.2+.  TLS1.1 and earlier use a fixed PRF.
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
    80
     * @param prfHashLength the output length of the TLS PRF hash algorithm.
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
    81
     *        Used only for TLS 1.2+.
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
    82
     * @param prfBlockSize the input block size of the TLS PRF hash algorithm.
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
    83
     *        Used only for TLS 1.2+.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * @throws NullPointerException if masterSecret, clientRandom,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     *   serverRandom, or cipherAlgorithm are null
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * @throws IllegalArgumentException if the algorithm of masterSecret is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     *   not TlsMasterSecret, or if majorVersion or minorVersion are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     *   negative or larger than 255; or if cipherKeyLength, expandedKeyLength,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     *   ivLength, or macKeyLength are negative
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    public TlsKeyMaterialParameterSpec(SecretKey masterSecret,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            int majorVersion, int minorVersion, byte[] clientRandom,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            byte[] serverRandom, String cipherAlgorithm, int cipherKeyLength,
7043
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
    95
            int expandedCipherKeyLength, int ivLength, int macKeyLength,
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
    96
            String prfHashAlg, int prfHashLength, int prfBlockSize) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        if (masterSecret.getAlgorithm().equals("TlsMasterSecret") == false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            throw new IllegalArgumentException("Not a TLS master secret");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        if (cipherAlgorithm == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        this.masterSecret = masterSecret;
7039
6464c8e62a18 4873188: Support TLS 1.1
xuelei
parents: 5506
diff changeset
   104
        this.majorVersion =
6464c8e62a18 4873188: Support TLS 1.1
xuelei
parents: 5506
diff changeset
   105
            TlsMasterSecretParameterSpec.checkVersion(majorVersion);
6464c8e62a18 4873188: Support TLS 1.1
xuelei
parents: 5506
diff changeset
   106
        this.minorVersion =
6464c8e62a18 4873188: Support TLS 1.1
xuelei
parents: 5506
diff changeset
   107
            TlsMasterSecretParameterSpec.checkVersion(minorVersion);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        this.clientRandom = clientRandom.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        this.serverRandom = serverRandom.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        this.cipherAlgorithm = cipherAlgorithm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        this.cipherKeyLength = checkSign(cipherKeyLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        this.expandedCipherKeyLength = checkSign(expandedCipherKeyLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        this.ivLength = checkSign(ivLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        this.macKeyLength = checkSign(macKeyLength);
7043
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   115
        this.prfHashAlg = prfHashAlg;
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   116
        this.prfHashLength = prfHashLength;
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   117
        this.prfBlockSize = prfBlockSize;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    private static int checkSign(int k) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        if (k < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            throw new IllegalArgumentException("Value must not be negative");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        return k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * Returns the master secret.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @return the master secret.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    public SecretKey getMasterSecret() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        return masterSecret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * Returns the major version number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * @return the major version number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    public int getMajorVersion() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        return majorVersion;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * Returns the minor version number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * @return the minor version number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    public int getMinorVersion() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        return minorVersion;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * Returns a copy of the client's random value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * @return a copy of the client's random value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    public byte[] getClientRandom() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        return clientRandom.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * Returns a copy of the server's random value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * @return a copy of the server's random value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    public byte[] getServerRandom() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        return serverRandom.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * Returns the cipher algorithm.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * @return the cipher algorithm.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    public String getCipherAlgorithm() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        return cipherAlgorithm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * Returns the length in bytes of the encryption key to be generated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * @return the length in bytes of the encryption key to be generated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    public int getCipherKeyLength() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        return cipherKeyLength;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    /**
7039
6464c8e62a18 4873188: Support TLS 1.1
xuelei
parents: 5506
diff changeset
   191
     * Returns the length in bytes of the expanded encryption key to be
6464c8e62a18 4873188: Support TLS 1.1
xuelei
parents: 5506
diff changeset
   192
     * generated. Returns zero if the expanded encryption key is not
6464c8e62a18 4873188: Support TLS 1.1
xuelei
parents: 5506
diff changeset
   193
     * supposed to be generated.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     *
7039
6464c8e62a18 4873188: Support TLS 1.1
xuelei
parents: 5506
diff changeset
   195
     * @return the length in bytes of the expanded encryption key to be
6464c8e62a18 4873188: Support TLS 1.1
xuelei
parents: 5506
diff changeset
   196
     *     generated.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    public int getExpandedCipherKeyLength() {
7039
6464c8e62a18 4873188: Support TLS 1.1
xuelei
parents: 5506
diff changeset
   199
        // TLS v1.1 disables the exportable weak cipher suites.
6464c8e62a18 4873188: Support TLS 1.1
xuelei
parents: 5506
diff changeset
   200
        if (majorVersion >= 0x03 && minorVersion >= 0x02) {
6464c8e62a18 4873188: Support TLS 1.1
xuelei
parents: 5506
diff changeset
   201
            return 0;
6464c8e62a18 4873188: Support TLS 1.1
xuelei
parents: 5506
diff changeset
   202
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        return expandedCipherKeyLength;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    /**
7039
6464c8e62a18 4873188: Support TLS 1.1
xuelei
parents: 5506
diff changeset
   207
     * Returns the length in bytes of the initialization vector to be
6464c8e62a18 4873188: Support TLS 1.1
xuelei
parents: 5506
diff changeset
   208
     * generated. Returns zero if the initialization vector is not
6464c8e62a18 4873188: Support TLS 1.1
xuelei
parents: 5506
diff changeset
   209
     * supposed to be generated.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     *
7039
6464c8e62a18 4873188: Support TLS 1.1
xuelei
parents: 5506
diff changeset
   211
     * @return the length in bytes of the initialization vector to be
6464c8e62a18 4873188: Support TLS 1.1
xuelei
parents: 5506
diff changeset
   212
     *     generated.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    public int getIvLength() {
16067
36055e4b5305 8009925: Back out AEAD CipherSuites temporarily
wetmore
parents: 16045
diff changeset
   215
        // TLS v1.1 or later uses an explicit IV to protect against
36055e4b5305 8009925: Back out AEAD CipherSuites temporarily
wetmore
parents: 16045
diff changeset
   216
        // the CBC attacks.
36055e4b5305 8009925: Back out AEAD CipherSuites temporarily
wetmore
parents: 16045
diff changeset
   217
        if (majorVersion >= 0x03 && minorVersion >= 0x02) {
36055e4b5305 8009925: Back out AEAD CipherSuites temporarily
wetmore
parents: 16045
diff changeset
   218
            return 0;
36055e4b5305 8009925: Back out AEAD CipherSuites temporarily
wetmore
parents: 16045
diff changeset
   219
        }
36055e4b5305 8009925: Back out AEAD CipherSuites temporarily
wetmore
parents: 16045
diff changeset
   220
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        return ivLength;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * Returns the length in bytes of the MAC key to be generated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * @return the length in bytes of the MAC key to be generated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    public int getMacKeyLength() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        return macKeyLength;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
7043
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   233
    /**
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   234
     * Obtains the PRF hash algorithm to use in the PRF calculation.
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   235
     *
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   236
     * @return the hash algorithm.
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   237
     */
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   238
    public String getPRFHashAlg() {
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   239
        return prfHashAlg;
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   240
    }
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   241
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   242
    /**
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   243
     * Obtains the length of the PRF hash algorithm.
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   244
     *
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   245
     * @return the hash algorithm length.
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   246
     */
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   247
    public int getPRFHashLength() {
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   248
        return prfHashLength;
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   249
    }
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   250
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   251
    /**
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   252
     * Obtains the block size of the PRF hash algorithm.
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   253
     *
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   254
     * @return the hash algorithm block size
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   255
     */
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   256
    public int getPRFBlockSize() {
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   257
        return prfBlockSize;
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
   258
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
}