FileDocCategorySizeDatePackage
ServerHello.javaAPI DocAndroid 1.5 API3917Wed May 06 22:41:06 BST 2009org.apache.harmony.xnet.provider.jsse

ServerHello

public class ServerHello extends org.apache.harmony.xnet.provider.jsse.Message
Represents server hello message.
see
TLS 1.0 spec., 7.4.1.3. Server hello.

Fields Summary
byte[]
server_version
Server version
byte[]
random
Random bytes
byte[]
session_id
Session id
CipherSuite
cipher_suite
Selected cipher suite
byte
compression_method
Selected compression method
Constructors Summary
public ServerHello(SecureRandom sr, byte[] server_version, byte[] session_id, CipherSuite cipher_suite, byte compression_method)
Creates outbound message

param
sr
param
server_version
param
session_id
param
cipher_suite
param
compression_method


                      
        
                  
        long gmt_unix_time = new java.util.Date().getTime() / 1000;
        sr.nextBytes(random);
        random[0] = (byte) ((gmt_unix_time & 0xFF000000) >>> 24);
        random[1] = (byte) ((gmt_unix_time & 0xFF0000) >>> 16);
        random[2] = (byte) ((gmt_unix_time & 0xFF00) >>> 8);
        random[3] = (byte) (gmt_unix_time & 0xFF);
        this.session_id = session_id;
        this.cipher_suite = cipher_suite;
        this.compression_method = compression_method;
        this.server_version = server_version;
        length = 38 + session_id.length;
    
public ServerHello(HandshakeIODataStream in, int length)
Creates inbound message

param
in
param
length
throws
IOException

        
        server_version[0] = (byte) in.read();
        server_version[1] = (byte) in.read();
        in.read(random, 0, 32);
        int size = in.readUint8();
        session_id = new byte[size];
        in.read(session_id, 0, size);
        byte b0 = (byte) in.read();
        byte b1 = (byte) in.read();
        cipher_suite = CipherSuite.getByCode(b0, b1);
        compression_method = (byte) in.read();
        this.length = 38 + session_id.length;
        if (this.length != length) {
            fatalAlert(AlertProtocol.DECODE_ERROR, "DECODE ERROR: incorrect ServerHello");
        }

    
Methods Summary
public byte[]getRandom()
Returns server random

return

        return random;
    
public intgetType()
Returns message type

return

        return Handshake.SERVER_HELLO;
    
public voidsend(HandshakeIODataStream out)
Sends message

param
out

        out.write(server_version);
        out.write(random);
        out.writeUint8(session_id.length);
        out.write(session_id);
        out.write(cipher_suite.toBytes());
        out.write(compression_method);
        length = 38 + session_id.length;