5408N/A * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 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 * 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 * 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. 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 0N/A * InputStream for handshake data, used internally only. Contains the 0N/A * handshake message buffer and methods to parse them. 0N/A * Once a new handshake record arrives, it is buffered in this class until 0N/A * processed by the Handshaker. The buffer may also contain incomplete 0N/A * handshake messages in case the message is split across multiple records. 0N/A * Handshaker.process_record deals with all that. It may also contain 0N/A * handshake messages larger than the default buffer size (e.g. large 0N/A * certificate messages). The buffer is grown dynamically to handle that 0N/A * (see InputRecord.queueHandshake()). 0N/A * Note that the InputRecord used as a buffer here is separate from the 0N/A * AppInStream.r, which is where data from the socket is initially read 0N/A * into. This is because once the initial handshake has been completed, 0N/A * handshake and application data messages may be interleaved arbitrarily 0N/A * and must be processed independently. 0N/A * @author David Brownell 0N/A * Construct the stream; we'll be accumulating hashes of the 0N/A * input records using two sets of digests. 0N/A // overridden InputStream methods 0N/A * Return the number of bytes available for read(). 0N/A * Note that this returns the bytes remaining in the buffer, not 0N/A * the bytes remaining in the current handshake message. 0N/A * Get a byte of handshake data. 0N/A * Get a bunch of bytes of handshake data. 0N/A // we read from a ByteArrayInputStream, it always returns the 0N/A // data in a single read if enough is available 0N/A * Skip some handshake data. 0N/A * Mark/ reset code, implemented using InputRecord mark/ reset. 0N/A * Note that it currently provides only a limited mark functionality 0N/A * and should be used with care (once a new handshake record has been 0N/A * read, data that has already been consumed is lost even if marked). 0N/A // handshake management functions 0N/A * Here's an incoming record with handshake data. Queue the contents; 0N/A * it might be one or more entire messages, complete a message that's 0N/A * partly queued, or both. 0N/A * Hash any data we've consumed but not yet hashed. Useful mostly 0N/A * for processing client certificate messages (so we can check the 0N/A * immediately following cert verify message) and finished messages 0N/A * (so we can compute our own finished message). 0N/A * Do more than skip that handshake data ... totally ignore it. 0N/A * The difference is that the data does not get hashed. 0N/A // Message parsing methods 0N/A * Read 8, 16, 24, and 32 bit SSL integer data types, encoded 0N/A * in standard big-endian form. 0N/A * Read byte vectors with 8, 16, and 24 bit length encodings. 5408N/A // Is a length greater than available bytes in the record? 5408N/A "Not enough data to fill declared vector size");