Home | History | Annotate | Download | only in record
      1 /*
      2  * Copyright (C) 2014 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 package libcore.tlswire.record;
     17 
     18 import java.io.DataInput;
     19 import java.io.IOException;
     20 import libcore.tlswire.util.TlsProtocolVersion;
     21 
     22 /**
     23  * TLS Record Protocol record from TLS 1.2 RFC 5246.
     24  */
     25 public class TlsRecord {
     26     public int type;
     27     public TlsProtocolVersion version;
     28     public byte[] fragment;
     29     public static TlsRecord read(DataInput in) throws IOException {
     30         TlsRecord result = new TlsRecord();
     31         result.type = in.readUnsignedByte();
     32         result.version = TlsProtocolVersion.read(in);
     33         int fragmentLength = in.readUnsignedShort();
     34         result.fragment = new byte[fragmentLength];
     35         in.readFully(result.fragment);
     36         return result;
     37     }
     38 }
     39