Showing the changes to java/pkg/sun/security/ssl/Record.java (1 of 18352 files). Show all
Unified · Split
| @@ -0,0 +1,96 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1996, 2010, 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 | ||
| 23 | * questions. | ||
| 24 | */ | ||
| 25 | |||
| 26 | |||
| 27 | package sun.security.ssl; | ||
| 28 | |||
| 29 | |||
| 30 | /** | ||
| 31 | * SSL/TLS records, as pulled off (and put onto) a TCP stream. This is | ||
| 32 | * the base interface, which defines common information and interfaces | ||
| 33 | * used by both Input and Output records. | ||
| 34 | * | ||
| 35 | * @author David Brownell | ||
| 36 | */ | ||
| 37 | interface Record { | ||
| 38 | /* | ||
| 39 | * There are four SSL record types, which are part of the interface | ||
| 40 | * to this level (along with the maximum record size) | ||
| 41 | * | ||
| 42 | * enum { change_cipher_spec(20), alert(21), handshake(22), | ||
| 43 | * application_data(23), (255) } ContentType; | ||
| 44 | */ | ||
| 45 | static final byte ct_change_cipher_spec = 20; | ||
| 46 | static final byte ct_alert = 21; | ||
| 47 | static final byte ct_handshake = 22; | ||
| 48 | static final byte ct_application_data = 23; | ||
| 49 | |||
| 50 | static final int headerSize = 5; // SSLv3 record header | ||
| 51 | static final int maxExpansion = 1024; // for bad compression | ||
| 52 | static final int trailerSize = 20; // SHA1 hash size | ||
| 53 | static final int maxDataSize = 16384; // 2^14 bytes of data | ||
| 54 | static final int maxPadding = 256; // block cipher padding | ||
| 55 | static final int maxIVLength = 256; // block length | ||
| 56 | |||
| 57 | /* | ||
| 58 | * SSL has a maximum record size. It's header, (compressed) data, | ||
| 59 | * padding, and a trailer for the MAC. | ||
| 60 | * Some compression algorithms have rare cases where they expand the data. | ||
| 61 | * As we don't support compression at this time, leave that out. | ||
| 62 | */ | ||
| 63 | static final int maxRecordSize = | ||
| 64 | headerSize // header | ||
| 65 | + maxIVLength // iv | ||
| 66 | + maxDataSize // data | ||
| 67 | + maxPadding // padding | ||
| 68 | + trailerSize; // MAC | ||
| 69 | |||
| 70 | /* | ||
| 71 | * The maximum large record size. | ||
| 72 | * | ||
| 73 | * Some SSL/TLS implementations support large fragment upto 2^15 bytes, | ||
| 74 | * such as Microsoft. We support large incoming fragments. | ||
| 75 | * | ||
| 76 | * The maximum large record size is defined as maxRecordSize plus 2^14, | ||
| 77 | * this is the amount OpenSSL is using. | ||
| 78 | */ | ||
| 79 | static final int maxLargeRecordSize = | ||
| 80 | maxRecordSize // Max size with a conforming implemenation | ||
| 81 | + maxDataSize; // extra 2^14 bytes for large data packets. | ||
| 82 | |||
| 83 | |||
| 84 | /* | ||
| 85 | * Maximum record size for alert and change cipher spec records. | ||
| 86 | * They only contain 2 and 1 bytes of data, respectively. | ||
| 87 | * Allocate a smaller array. | ||
| 88 | */ | ||
| 89 | static final int maxAlertRecordSize = | ||
| 90 | headerSize // header | ||
| 91 | + maxIVLength // iv | ||
| 92 | + 2 // alert | ||
| 93 | + maxPadding // padding | ||
| 94 | + trailerSize; // MAC | ||
| 95 | |||
| 96 | } | ||