< prev index next >

src/java.base/share/classes/sun/security/ssl/SSLSocketInputRecord.java

Print this page


   1 /*
   2  * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 296                 int remaining = handshakeFrag.remaining();
 297                 if (remaining < handshakeHeaderSize) {
 298                     handshakeBuffer = ByteBuffer.wrap(new byte[remaining]);
 299                     handshakeBuffer.put(handshakeFrag);
 300                     handshakeBuffer.rewind();
 301                     break;
 302                 }
 303 
 304                 handshakeFrag.mark();
 305                 // skip the first byte: handshake type
 306                 byte handshakeType = handshakeFrag.get();
 307                 int handshakeBodyLen = Record.getInt24(handshakeFrag);
 308                 handshakeFrag.reset();
 309                 int handshakeMessageLen =
 310                         handshakeHeaderSize + handshakeBodyLen;
 311                 if (remaining < handshakeMessageLen) {
 312                     handshakeBuffer = ByteBuffer.wrap(new byte[remaining]);
 313                     handshakeBuffer.put(handshakeFrag);
 314                     handshakeBuffer.rewind();
 315                     break;
 316                 }
 317 
 318                 if (remaining == handshakeMessageLen) {
 319                     if (handshakeHash.isHashable(handshakeType)) {
 320                         handshakeHash.receive(handshakeFrag);
 321                     }
 322 
 323                     plaintexts.add(
 324                         new Plaintext(contentType,
 325                             majorVersion, minorVersion, -1, -1L, handshakeFrag)
 326                     );
 327                     break;
 328                 } else {
 329                     int fragPos = handshakeFrag.position();
 330                     int fragLim = handshakeFrag.limit();
 331                     int nextPos = fragPos + handshakeMessageLen;
 332                     handshakeFrag.limit(nextPos);
 333 
 334                     if (handshakeHash.isHashable(handshakeType)) {
 335                         handshakeHash.receive(handshakeFrag);
 336                     }
 337 
 338                     plaintexts.add(


   1 /*
   2  * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 296                 int remaining = handshakeFrag.remaining();
 297                 if (remaining < handshakeHeaderSize) {
 298                     handshakeBuffer = ByteBuffer.wrap(new byte[remaining]);
 299                     handshakeBuffer.put(handshakeFrag);
 300                     handshakeBuffer.rewind();
 301                     break;
 302                 }
 303 
 304                 handshakeFrag.mark();
 305                 // skip the first byte: handshake type
 306                 byte handshakeType = handshakeFrag.get();
 307                 int handshakeBodyLen = Record.getInt24(handshakeFrag);
 308                 handshakeFrag.reset();
 309                 int handshakeMessageLen =
 310                         handshakeHeaderSize + handshakeBodyLen;
 311                 if (remaining < handshakeMessageLen) {
 312                     handshakeBuffer = ByteBuffer.wrap(new byte[remaining]);
 313                     handshakeBuffer.put(handshakeFrag);
 314                     handshakeBuffer.rewind();
 315                     break;
 316                 } if (remaining == handshakeMessageLen) {


 317                     if (handshakeHash.isHashable(handshakeType)) {
 318                         handshakeHash.receive(handshakeFrag);
 319                     }
 320 
 321                     plaintexts.add(
 322                         new Plaintext(contentType,
 323                             majorVersion, minorVersion, -1, -1L, handshakeFrag)
 324                     );
 325                     break;
 326                 } else {
 327                     int fragPos = handshakeFrag.position();
 328                     int fragLim = handshakeFrag.limit();
 329                     int nextPos = fragPos + handshakeMessageLen;
 330                     handshakeFrag.limit(nextPos);
 331 
 332                     if (handshakeHash.isHashable(handshakeType)) {
 333                         handshakeHash.receive(handshakeFrag);
 334                     }
 335 
 336                     plaintexts.add(


< prev index next >