|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
|
|
package sun.security.ssl; |
|
|
|
import java.io.IOException; |
|
import java.nio.ByteBuffer; |
|
import java.util.Map; |
|
import sun.security.ssl.SSLHandshake.HandshakeMessage; |
|
|
|
|
|
|
|
*/ |
|
final class ServerKeyExchange { |
|
static final SSLConsumer handshakeConsumer = |
|
new ServerKeyExchangeConsumer(); |
|
static final HandshakeProducer handshakeProducer = |
|
new ServerKeyExchangeProducer(); |
|
|
|
|
|
|
|
*/ |
|
private static final |
|
class ServerKeyExchangeProducer implements HandshakeProducer { |
|
|
|
private ServerKeyExchangeProducer() { |
|
// blank |
|
} |
|
|
|
@Override |
|
public byte[] produce(ConnectionContext context, |
|
HandshakeMessage message) throws IOException { |
|
|
|
ServerHandshakeContext shc = (ServerHandshakeContext)context; |
|
|
|
SSLKeyExchange ke = SSLKeyExchange.valueOf( |
|
shc.negotiatedCipherSuite.keyExchange, |
|
shc.negotiatedProtocol); |
|
if (ke != null) { |
|
for (Map.Entry<Byte, HandshakeProducer> hc : |
|
ke.getHandshakeProducers(shc)) { |
|
if (hc.getKey() == SSLHandshake.SERVER_KEY_EXCHANGE.id) { |
|
return hc.getValue().produce(context, message); |
|
} |
|
} |
|
} |
|
|
|
|
|
throw shc.conContext.fatal(Alert.HANDSHAKE_FAILURE, |
|
"No ServerKeyExchange handshake message can be produced."); |
|
} |
|
} |
|
|
|
|
|
|
|
*/ |
|
private static final |
|
class ServerKeyExchangeConsumer implements SSLConsumer { |
|
|
|
private ServerKeyExchangeConsumer() { |
|
// blank |
|
} |
|
|
|
@Override |
|
public void consume(ConnectionContext context, |
|
ByteBuffer message) throws IOException { |
|
|
|
ClientHandshakeContext chc = (ClientHandshakeContext)context; |
|
|
|
|
|
chc.handshakeConsumers.remove(SSLHandshake.SERVER_KEY_EXCHANGE.id); |
|
|
|
SSLConsumer certStatCons = chc.handshakeConsumers.remove( |
|
SSLHandshake.CERTIFICATE_STATUS.id); |
|
if (certStatCons != null) { |
|
// Stapling was active but no certificate status message |
|
// was sent. We need to run the absence handler which will |
|
|
|
CertificateStatus.handshakeAbsence.absent(context, null); |
|
} |
|
|
|
SSLKeyExchange ke = SSLKeyExchange.valueOf( |
|
chc.negotiatedCipherSuite.keyExchange, |
|
chc.negotiatedProtocol); |
|
if (ke != null) { |
|
for (Map.Entry<Byte, SSLConsumer> hc : |
|
ke.getHandshakeConsumers(chc)) { |
|
if (hc.getKey() == SSLHandshake.SERVER_KEY_EXCHANGE.id) { |
|
hc.getValue().consume(context, message); |
|
return; |
|
} |
|
} |
|
} |
|
|
|
|
|
throw chc.conContext.fatal(Alert.UNEXPECTED_MESSAGE, |
|
"Unexpected ServerKeyExchange handshake message."); |
|
} |
|
} |
|
} |
|
|