jdk/src/java.base/share/classes/sun/security/ssl/MAC.java
author martin
Tue, 15 Sep 2015 21:56:04 -0700
changeset 32649 2ee9017c7597
parent 31538 0981099a3e54
permissions -rw-r--r--
8136583: Core libraries should use blessed modifier order Summary: Run blessed-modifier-order script (see bug) Reviewed-by: psandoz, chegar, alanb, plevart
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
29488
1f25b971e59a 6996366: convert MacAlg to an enum
jnimeh
parents: 28059
diff changeset
     2
 * Copyright (c) 1996, 2015, 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.ssl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.security.InvalidKeyException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.security.NoSuchAlgorithmException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.nio.ByteBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import javax.crypto.Mac;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import javax.crypto.SecretKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import sun.security.ssl.CipherSuite.MacAlg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import static sun.security.ssl.CipherSuite.*;
29488
1f25b971e59a 6996366: convert MacAlg to an enum
jnimeh
parents: 28059
diff changeset
    38
import static sun.security.ssl.CipherSuite.MacAlg.*;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * This class computes the "Message Authentication Code" (MAC) for each
16913
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16126
diff changeset
    42
 * SSL stream and block cipher message.  This is essentially a shared-secret
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16126
diff changeset
    43
 * signature, used to provide integrity protection for SSL messages.  The
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16126
diff changeset
    44
 * MAC is actually one of several keyed hashes, as associated with the cipher
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16126
diff changeset
    45
 * suite and protocol version. (SSL v3.0 uses one construct, TLS uses another.)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * @author David Brownell
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * @author Andreas Sterbenz
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 */
16913
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16126
diff changeset
    50
final class MAC extends Authenticator {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 31538
diff changeset
    52
    static final MAC TLS_NULL = new MAC(false);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    // Value of the null MAC is fixed
31538
0981099a3e54 8130022: Use Java-style array declarations consistently
igerasim
parents: 30904
diff changeset
    55
    private static final byte[] nullMAC = new byte[0];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
16113
946ec9b22004 8006777: Improve TLS handling of invalid messages
xuelei
parents: 14675
diff changeset
    57
    // internal identifier for the MAC algorithm
30904
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
    58
    private final MacAlg macAlg;
16113
946ec9b22004 8006777: Improve TLS handling of invalid messages
xuelei
parents: 14675
diff changeset
    59
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    // JCE Mac object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    private final Mac mac;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
30904
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
    63
    MAC(boolean isDTLS) {
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
    64
        super(isDTLS);
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
    65
16113
946ec9b22004 8006777: Improve TLS handling of invalid messages
xuelei
parents: 14675
diff changeset
    66
        macAlg = M_NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        mac = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    /**
30904
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
    71
     * Set up, configured for the given MAC type and version.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    MAC(MacAlg macAlg, ProtocolVersion protocolVersion, SecretKey key)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
            throws NoSuchAlgorithmException, InvalidKeyException {
16913
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16126
diff changeset
    75
        super(protocolVersion);
16113
946ec9b22004 8006777: Improve TLS handling of invalid messages
xuelei
parents: 14675
diff changeset
    76
        this.macAlg = macAlg;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        String algorithm;
30904
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
    79
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
    80
        // using SSL MAC computation?
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
    81
        boolean useSSLMac = (protocolVersion.v < ProtocolVersion.TLS10.v);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        if (macAlg == M_MD5) {
30904
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
    84
            algorithm = useSSLMac ? "SslMacMD5" : "HmacMD5";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        } else if (macAlg == M_SHA) {
30904
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
    86
            algorithm = useSSLMac ? "SslMacSHA1" : "HmacSHA1";
7043
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
    87
        } else if (macAlg == M_SHA256) {
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
    88
            algorithm = "HmacSHA256";    // TLS 1.2+
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
    89
        } else if (macAlg == M_SHA384) {
5e2d1edeb2c7 6916074: Add support for TLS 1.2
xuelei
parents: 7039
diff changeset
    90
            algorithm = "HmacSHA384";    // TLS 1.2+
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            throw new RuntimeException("Unknown Mac " + macAlg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        mac = JsseJce.getMac(algorithm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        mac.init(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * Returns the length of the MAC.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    int MAClen() {
16913
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16126
diff changeset
   103
        return macAlg.size;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    /**
16113
946ec9b22004 8006777: Improve TLS handling of invalid messages
xuelei
parents: 14675
diff changeset
   107
     * Returns the hash function block length of the MAC alorithm.
946ec9b22004 8006777: Improve TLS handling of invalid messages
xuelei
parents: 14675
diff changeset
   108
     */
946ec9b22004 8006777: Improve TLS handling of invalid messages
xuelei
parents: 14675
diff changeset
   109
    int hashBlockLen() {
946ec9b22004 8006777: Improve TLS handling of invalid messages
xuelei
parents: 14675
diff changeset
   110
        return macAlg.hashBlockSize;
946ec9b22004 8006777: Improve TLS handling of invalid messages
xuelei
parents: 14675
diff changeset
   111
    }
946ec9b22004 8006777: Improve TLS handling of invalid messages
xuelei
parents: 14675
diff changeset
   112
946ec9b22004 8006777: Improve TLS handling of invalid messages
xuelei
parents: 14675
diff changeset
   113
    /**
946ec9b22004 8006777: Improve TLS handling of invalid messages
xuelei
parents: 14675
diff changeset
   114
     * Returns the hash function minimal padding length of the MAC alorithm.
946ec9b22004 8006777: Improve TLS handling of invalid messages
xuelei
parents: 14675
diff changeset
   115
     */
946ec9b22004 8006777: Improve TLS handling of invalid messages
xuelei
parents: 14675
diff changeset
   116
    int minimalPaddingLen() {
946ec9b22004 8006777: Improve TLS handling of invalid messages
xuelei
parents: 14675
diff changeset
   117
        return macAlg.minimalPaddingSize;
946ec9b22004 8006777: Improve TLS handling of invalid messages
xuelei
parents: 14675
diff changeset
   118
    }
946ec9b22004 8006777: Improve TLS handling of invalid messages
xuelei
parents: 14675
diff changeset
   119
946ec9b22004 8006777: Improve TLS handling of invalid messages
xuelei
parents: 14675
diff changeset
   120
    /**
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * Computes and returns the MAC for the data in this byte array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * @param type record type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * @param buf compressed record on which the MAC is computed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * @param offset start of compressed record data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * @param len the size of the compressed record
28059
e576535359cc 8067377: My hobby: caning, then then canning, the the can-can
martin
parents: 25859
diff changeset
   127
     * @param isSimulated if true, simulate the MAC computation
30904
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   128
     *
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   129
     * @return the MAC result
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     */
16113
946ec9b22004 8006777: Improve TLS handling of invalid messages
xuelei
parents: 14675
diff changeset
   131
    final byte[] compute(byte type, byte buf[],
946ec9b22004 8006777: Improve TLS handling of invalid messages
xuelei
parents: 14675
diff changeset
   132
            int offset, int len, boolean isSimulated) {
16913
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16126
diff changeset
   133
        if (macAlg.size == 0) {
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16126
diff changeset
   134
            return nullMAC;
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16126
diff changeset
   135
        }
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16126
diff changeset
   136
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16126
diff changeset
   137
        if (!isSimulated) {
30904
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   138
            // Uses the implicit sequence number for the computation.
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   139
            byte[] additional = acquireAuthenticationBytes(type, len, null);
16913
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16126
diff changeset
   140
            mac.update(additional);
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16126
diff changeset
   141
        }
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16126
diff changeset
   142
        mac.update(buf, offset, len);
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16126
diff changeset
   143
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16126
diff changeset
   144
        return mac.doFinal();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * Compute and returns the MAC for the remaining data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * in this ByteBuffer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * On return, the bb position == limit, and limit will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * have not changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * @param type record type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * @param bb a ByteBuffer in which the position and limit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     *          demarcate the data to be MAC'd.
28059
e576535359cc 8067377: My hobby: caning, then then canning, the the can-can
martin
parents: 25859
diff changeset
   157
     * @param isSimulated if true, simulate the MAC computation
30904
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   158
     * @param sequence the explicit sequence number, or null if using
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   159
     *        the implicit sequence number for the computation
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   160
     *
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   161
     * @return the MAC result
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     */
30904
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   163
    final byte[] compute(byte type, ByteBuffer bb,
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   164
            byte[] sequence, boolean isSimulated) {
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   165
16913
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16126
diff changeset
   166
        if (macAlg.size == 0) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            return nullMAC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
16113
946ec9b22004 8006777: Improve TLS handling of invalid messages
xuelei
parents: 14675
diff changeset
   170
        if (!isSimulated) {
30904
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   171
            // Uses the explicit sequence number for the computation.
16913
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16126
diff changeset
   172
            byte[] additional =
30904
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   173
                    acquireAuthenticationBytes(type, bb.remaining(), sequence);
16913
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16126
diff changeset
   174
            mac.update(additional);
16113
946ec9b22004 8006777: Improve TLS handling of invalid messages
xuelei
parents: 14675
diff changeset
   175
        }
16913
a6f4d1626ad9 8011680: Re-integrate AEAD implementation of JSSE
xuelei
parents: 16126
diff changeset
   176
        mac.update(bb);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        return mac.doFinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
30904
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   181
    /**
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   182
     * Compute and returns the MAC for the remaining data
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   183
     * in this ByteBuffer.
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   184
     *
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   185
     * On return, the bb position == limit, and limit will
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   186
     * have not changed.
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   187
     *
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   188
     * @param type record type
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   189
     * @param bb a ByteBuffer in which the position and limit
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   190
     *        demarcate the data to be MAC'd.
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   191
     * @param isSimulated if true, simulate the the MAC computation
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   192
     *
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   193
     * @return the MAC result
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   194
     */
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   195
    final byte[] compute(byte type, ByteBuffer bb, boolean isSimulated) {
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   196
        // Uses the implicit sequence number for the computation.
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   197
        return compute(type, bb, null, isSimulated);
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 29488
diff changeset
   198
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
}