ServerKeyExchangepublic class ServerKeyExchange extends org.apache.harmony.xnet.provider.jsse.Message Represents server key exchange message. |
Fields Summary |
---|
final BigInteger | par1 | final byte[] | bytes1 | final BigInteger | par2 | final byte[] | bytes2 | final BigInteger | par3 | final byte[] | bytes3 | final byte[] | hashSignature | private RSAPublicKey | key |
Constructors Summary |
---|
public ServerKeyExchange(BigInteger par1, BigInteger par2, BigInteger par3, byte[] hash)Creates outbound message
this.par1 = par1;
this.par2 = par2;
this.par3 = par3;
this.hash = hash;
byte[] bb = this.par1.toByteArray();
if (bb[0] == 0) {
// XXX check for par1 == 0 or bb.length > 1
bytes1 = new byte[bb.length - 1];
System.arraycopy(bb, 1, bytes1, 0, bytes1.length);
} else {
bytes1 = bb;
}
bb = this.par2.toByteArray();
if (bb[0] == 0) {
bytes2 = new byte[bb.length - 1];
System.arraycopy(bb, 1, bytes2, 0, bytes2.length);
} else {
bytes2 = bb;
}
length = 4 + bytes1.length + bytes2.length;
if (hash != null) {
length += 2 + hash.length;
}
if (par3 == null) {
bytes3 = null;
return;
}
bb = this.par3.toByteArray();
if (bb[0] == 0) {
bytes3 = new byte[bb.length - 1];
System.arraycopy(bb, 1, bytes3, 0, bytes3.length);
} else {
bytes3 = bb;
}
length += 2 + bytes3.length;
| public ServerKeyExchange(HandshakeIODataStream in, int length, int keyExchange)Creates inbound message
int size = in.readUint16();
bytes1 = in.read(size);
par1 = new BigInteger(1, bytes1);
this.length = 2 + bytes1.length;
size = in.readUint16();
bytes2 = in.read(size);
par2 = new BigInteger(1, bytes2);
this.length += 2 + bytes2.length;
if (keyExchange != CipherSuite.KeyExchange_RSA_EXPORT) {
size = in.readUint16();
bytes3 = in.read(size);
par3 = new BigInteger(1, bytes3);
this.length += 2 + bytes3.length;
} else {
par3 = null;
bytes3 = null;
}
if (keyExchange != CipherSuite.KeyExchange_DH_anon_EXPORT
&& keyExchange != CipherSuite.KeyExchange_DH_anon) {
size = in.readUint16();
hash = in.read(size);
this.length += 2 + hash.length;
} else {
hash = null;
}
if (this.length != length) {
fatalAlert(AlertProtocol.DECODE_ERROR,
"DECODE ERROR: incorrect ServerKeyExchange");
}
|
Methods Summary |
---|
public java.security.interfaces.RSAPublicKey | getRSAPublicKey()Returns RSAPublicKey generated using ServerRSAParams
(rsa_modulus and rsa_exponent).
if (key != null) {
return key;
}
try {
KeyFactory kf = KeyFactory.getInstance("RSA");
key = (RSAPublicKey) kf.generatePublic(new RSAPublicKeySpec(par1,
par2));
} catch (Exception e) {
return null;
}
return key;
| public int | getType()Returns message type
return Handshake.SERVER_KEY_EXCHANGE;
| public void | send(HandshakeIODataStream out)Sends message
out.writeUint16(bytes1.length);
out.write(bytes1);
out.writeUint16(bytes2.length);
out.write(bytes2);
if (bytes3 != null) {
out.writeUint16(bytes3.length);
out.write(bytes3);
}
if (hash != null) {
out.writeUint16(hash.length);
out.write(hash);
}
|
|