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

ClientKeyExchange

public class ClientKeyExchange extends org.apache.harmony.xnet.provider.jsse.Message
Represents client key exchange message
see
TLS 1.0 spec., 7.4.7. Client key exchange message

Fields Summary
final byte[]
exchange_keys
Exchange keys
boolean
isTLS
Equals true if TLS1.0 protocol is used
final boolean
isRSA
Equals true if key exchange algorithm is RSA
Constructors Summary
public ClientKeyExchange(byte[] encrypted_pre_master_secret, boolean isTLS)
Creates outbound message

param
encrypted_pre_master_secret
param
isTLS

        this.exchange_keys = encrypted_pre_master_secret;    
        length = this.exchange_keys.length;
        if (isTLS) {
            length += 2;
        }
        this.isTLS = isTLS;
        isRSA = true;
    
public ClientKeyExchange(BigInteger dh_Yc)
Creates outbound message

param
dh_Yc

        byte[] bb = dh_Yc.toByteArray();
        if (bb[0] == 0) {
            exchange_keys = new byte[bb.length-1]; 
            System.arraycopy(bb, 1, exchange_keys, 0, exchange_keys.length);
        } else {
            exchange_keys = bb;
        }
        length = exchange_keys.length +2;
        isRSA = false;
    
public ClientKeyExchange()
Creates empty message

        exchange_keys = new byte[0];
        length = 0;
        isRSA = false;
    
public ClientKeyExchange(org.apache.harmony.xnet.provider.jsse.HandshakeIODataStream in, int length, boolean isTLS, boolean isRSA)
Creates inbound message

param
length
param
isTLS
param
isRSA
throws
IOException

        this.isTLS = isTLS;
        this.isRSA = isRSA;
        if (length == 0) {
            this.length = 0;
            exchange_keys = new byte[0];
        } else {
            int size;
            if (isRSA && !isTLS) {// SSL3.0 RSA
                size = length;
                this.length = size;
            } else { // DH or TLSv1 RSA
                size = in.readUint16();
                this.length = 2 + size;
            }
            exchange_keys = new byte[size];
            in.read(exchange_keys, 0, size);
            if (this.length != length) {
                fatalAlert(AlertProtocol.DECODE_ERROR, "DECODE ERROR: incorrect ClientKeyExchange");
            }
        }
    
Methods Summary
public intgetType()
Returns message type

return

        return Handshake.CLIENT_KEY_EXCHANGE;
    
public booleanisEmpty()
Returns true if the message is empty (in case of implicit DH Yc)

return

        return (exchange_keys.length == 0);
    
public voidsend(org.apache.harmony.xnet.provider.jsse.HandshakeIODataStream out)
Sends message

param
out

        if (exchange_keys.length != 0) {    
            if (!isRSA || isTLS) {// DH or TLSv1 RSA
                out.writeUint16(exchange_keys.length);
            }
            out.write(exchange_keys);
        }