jdk/src/java.base/share/classes/sun/security/ssl/HandshakeOutStream.java
author chegar
Sun, 17 Aug 2014 15:54:13 +0100
changeset 25859 3317bb8137f4
parent 23010 jdk/src/share/classes/sun/security/ssl/HandshakeOutStream.java@6dadb192ad81
child 30904 ec0224270f90
permissions -rw-r--r--
8054834: Modular Source Code Reviewed-by: alanb, chegar, ihse, mduigou Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, chris.hegarty@oracle.com, erik.joelsson@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, magnus.ihse.bursie@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, paul.sandoz@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 21278
diff changeset
     2
 * Copyright (c) 1996, 2013, 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: 4236
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: 4236
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: 4236
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4236
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4236
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
package sun.security.ssl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.io.OutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * Output stream for handshake data.  This is used only internally
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * to the SSL classes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * MT note:  one thread at a time is presumed be writing handshake
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * messages, but (after initial connection setup) it's possible to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * have other threads reading/writing application data.  It's the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * SSLSocketImpl class that synchronizes record writes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * @author  David Brownell
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 */
4236
02f52c723b79 6894643: Separate out dependency on Kerberos
vinnie
parents: 2
diff changeset
    43
public class HandshakeOutStream extends OutputStream {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    private SSLSocketImpl socket;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    private SSLEngineImpl engine;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    OutputRecord r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    HandshakeOutStream(ProtocolVersion protocolVersion,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
            ProtocolVersion helloVersion, HandshakeHash handshakeHash,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
            SSLSocketImpl socket) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        this.socket = socket;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        r = new OutputRecord(Record.ct_handshake);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        init(protocolVersion, helloVersion, handshakeHash);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    HandshakeOutStream(ProtocolVersion protocolVersion,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
            ProtocolVersion helloVersion, HandshakeHash handshakeHash,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
            SSLEngineImpl engine) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        this.engine = engine;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        r = new EngineOutputRecord(Record.ct_handshake, engine);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        init(protocolVersion, helloVersion, handshakeHash);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    private void init(ProtocolVersion protocolVersion,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
            ProtocolVersion helloVersion, HandshakeHash handshakeHash) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        r.setVersion(protocolVersion);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        r.setHelloVersion(helloVersion);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        r.setHandshakeHash(handshakeHash);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * Update the handshake data hashes ... mostly for use after a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * client cert has been sent, so the cert verify message can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * constructed correctly yet without forcing extra I/O.  In all
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * other cases, automatic hash calculation suffices.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    void doHashes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        r.doHashes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * Write some data out onto the stream ... buffers as much as possible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * Hashes are updated automatically if something gets flushed to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * network (e.g. a big cert message etc).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     */
14664
e71aa0962e70 8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents: 14004
diff changeset
    89
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    public void write(byte buf[], int off, int len) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        while (len > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            int howmuch = Math.min(len, r.availableDataBytes());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            if (howmuch == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                r.write(buf, off, howmuch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                off += howmuch;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                len -= howmuch;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * write-a-byte
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     */
14664
e71aa0962e70 8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents: 14004
diff changeset
   107
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    public void write(int i) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        if (r.availableDataBytes() < 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        r.write(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
14664
e71aa0962e70 8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents: 14004
diff changeset
   115
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    public void flush() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        if (socket != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                socket.writeRecord(r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                // Had problems writing; check if there was an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                // alert from peer. If alert received, waitForClose
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                // will throw an exception for the alert
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                socket.waitForClose(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                // No alert was received, just rethrow exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        } else {  // engine != null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
             * Even if record might be empty, flush anyway in case
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
             * there is a finished handshake message that we need
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
             * to queue.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            engine.writeRecord((EngineOutputRecord)r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * Tell the OutputRecord that a finished message was
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * contained either in this record or the one immeiately
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 14664
diff changeset
   142
     * preceding it.  We need to reliably pass back notifications
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 14664
diff changeset
   143
     * that a finish message occurred.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    void setFinishedMsg() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        assert(socket == null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        ((EngineOutputRecord)r).setFinishedMsg();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * Put integers encoded in standard 8, 16, 24, and 32 bit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * big endian formats. Note that OutputStream.write(int) only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * writes the least significant 8 bits and ignores the rest.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    void putInt8(int i) throws IOException {
14004
611031f93e76 7200295: CertificateRequest message is wrapping when using large numbers of Certs
xuelei
parents: 5506
diff changeset
   158
        checkOverflow(i, Record.OVERFLOW_OF_INT08);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        r.write(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    void putInt16(int i) throws IOException {
14004
611031f93e76 7200295: CertificateRequest message is wrapping when using large numbers of Certs
xuelei
parents: 5506
diff changeset
   163
        checkOverflow(i, Record.OVERFLOW_OF_INT16);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        if (r.availableDataBytes() < 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        r.write(i >> 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        r.write(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    void putInt24(int i) throws IOException {
14004
611031f93e76 7200295: CertificateRequest message is wrapping when using large numbers of Certs
xuelei
parents: 5506
diff changeset
   172
        checkOverflow(i, Record.OVERFLOW_OF_INT24);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        if (r.availableDataBytes() < 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        r.write(i >> 16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        r.write(i >> 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        r.write(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    void putInt32(int i) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        if (r.availableDataBytes() < 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        r.write(i >> 24);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        r.write(i >> 16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        r.write(i >> 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        r.write(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * Put byte arrays with length encoded as 8, 16, 24 bit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * integers in big-endian format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    void putBytes8(byte b[]) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        if (b == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            putInt8(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            return;
14004
611031f93e76 7200295: CertificateRequest message is wrapping when using large numbers of Certs
xuelei
parents: 5506
diff changeset
   199
        } else {
611031f93e76 7200295: CertificateRequest message is wrapping when using large numbers of Certs
xuelei
parents: 5506
diff changeset
   200
            checkOverflow(b.length, Record.OVERFLOW_OF_INT08);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        putInt8(b.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        write(b, 0, b.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
4236
02f52c723b79 6894643: Separate out dependency on Kerberos
vinnie
parents: 2
diff changeset
   206
    public void putBytes16(byte b[]) throws IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        if (b == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            putInt16(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            return;
14004
611031f93e76 7200295: CertificateRequest message is wrapping when using large numbers of Certs
xuelei
parents: 5506
diff changeset
   210
        } else {
611031f93e76 7200295: CertificateRequest message is wrapping when using large numbers of Certs
xuelei
parents: 5506
diff changeset
   211
            checkOverflow(b.length, Record.OVERFLOW_OF_INT16);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        putInt16(b.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        write(b, 0, b.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    void putBytes24(byte b[]) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        if (b == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            putInt24(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            return;
14004
611031f93e76 7200295: CertificateRequest message is wrapping when using large numbers of Certs
xuelei
parents: 5506
diff changeset
   221
        } else {
611031f93e76 7200295: CertificateRequest message is wrapping when using large numbers of Certs
xuelei
parents: 5506
diff changeset
   222
            checkOverflow(b.length, Record.OVERFLOW_OF_INT24);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        putInt24(b.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        write(b, 0, b.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    }
14004
611031f93e76 7200295: CertificateRequest message is wrapping when using large numbers of Certs
xuelei
parents: 5506
diff changeset
   227
611031f93e76 7200295: CertificateRequest message is wrapping when using large numbers of Certs
xuelei
parents: 5506
diff changeset
   228
    private void checkOverflow(int length, int overflow) {
611031f93e76 7200295: CertificateRequest message is wrapping when using large numbers of Certs
xuelei
parents: 5506
diff changeset
   229
        if (length >= overflow) {
611031f93e76 7200295: CertificateRequest message is wrapping when using large numbers of Certs
xuelei
parents: 5506
diff changeset
   230
            // internal_error alert will be triggered
611031f93e76 7200295: CertificateRequest message is wrapping when using large numbers of Certs
xuelei
parents: 5506
diff changeset
   231
            throw new RuntimeException(
611031f93e76 7200295: CertificateRequest message is wrapping when using large numbers of Certs
xuelei
parents: 5506
diff changeset
   232
                    "Field length overflow, the field length (" +
611031f93e76 7200295: CertificateRequest message is wrapping when using large numbers of Certs
xuelei
parents: 5506
diff changeset
   233
                    length + ") should be less than " + overflow);
611031f93e76 7200295: CertificateRequest message is wrapping when using large numbers of Certs
xuelei
parents: 5506
diff changeset
   234
        }
611031f93e76 7200295: CertificateRequest message is wrapping when using large numbers of Certs
xuelei
parents: 5506
diff changeset
   235
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
}