提交 ac872e93 编写于 作者: X xuelei

7192393: Better Checking of order of TLS Messages

Summary: Also reviewed by Andrew Gross<Andrew.Gross@Oracle.COM>
Reviewed-by: weijun
上级 e7107cee
...@@ -128,9 +128,8 @@ final class ClientHandshaker extends Handshaker { ...@@ -128,9 +128,8 @@ final class ClientHandshaker extends Handshaker {
* in the constructor. * in the constructor.
*/ */
void processMessage(byte type, int messageLen) throws IOException { void processMessage(byte type, int messageLen) throws IOException {
if (state > type if (state >= type
&& (type != HandshakeMessage.ht_hello_request && (type != HandshakeMessage.ht_hello_request)) {
&& state != HandshakeMessage.ht_client_hello)) {
throw new SSLProtocolException( throw new SSLProtocolException(
"Handshake message sequence violation, " + type); "Handshake message sequence violation, " + type);
} }
......
...@@ -150,7 +150,7 @@ final class ServerHandshaker extends Handshaker { ...@@ -150,7 +150,7 @@ final class ServerHandshaker extends Handshaker {
// In SSLv3 and TLS, messages follow strictly increasing // In SSLv3 and TLS, messages follow strictly increasing
// numerical order _except_ for one annoying special case. // numerical order _except_ for one annoying special case.
// //
if ((state > type) if ((state >= type)
&& (state != HandshakeMessage.ht_client_key_exchange && (state != HandshakeMessage.ht_client_key_exchange
&& type != HandshakeMessage.ht_certificate_verify)) { && type != HandshakeMessage.ht_certificate_verify)) {
throw new SSLProtocolException( throw new SSLProtocolException(
...@@ -250,13 +250,15 @@ final class ServerHandshaker extends Handshaker { ...@@ -250,13 +250,15 @@ final class ServerHandshaker extends Handshaker {
} }
// //
// Move the state machine forward except for that annoying // Move state machine forward if the message handling
// special case. This means that clients could send extra // code didn't already do so
// cert verify messages; not a problem so long as all of
// them actually check out.
// //
if (state < type && type != HandshakeMessage.ht_certificate_verify) { if (state < type) {
state = type; if(type == HandshakeMessage.ht_certificate_verify) {
state = type + 2; // an annoying special case
} else {
state = type;
}
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册