diff -up openssl-fips-0.9.8e/ssl/ssl3.h.keying-mitm openssl-fips-0.9.8e/ssl/ssl3.h
--- openssl-fips-0.9.8e/ssl/ssl3.h.keying-mitm 2014-06-02 15:49:35.036283939 +0200
+++ openssl-fips-0.9.8e/ssl/ssl3.h 2014-06-02 17:00:09.808186361 +0200
@@ -344,6 +344,7 @@ typedef struct ssl3_buffer_st
* effected, but we can't prevent that.
*/
#define SSL3_FLAGS_SGC_RESTART_DONE 0x0040
+#define SSL3_FLAGS_CCS_OK 0x0080
typedef struct ssl3_state_st
{
diff -up openssl-fips-0.9.8e/ssl/s3_clnt.c.keying-mitm openssl-fips-0.9.8e/ssl/s3_clnt.c
--- openssl-fips-0.9.8e/ssl/s3_clnt.c.keying-mitm 2014-06-02 15:45:18.346349601 +0200
+++ openssl-fips-0.9.8e/ssl/s3_clnt.c 2014-06-02 15:49:35.036283939 +0200
@@ -425,6 +425,7 @@ int ssl3_connect(SSL *s)
case SSL3_ST_CR_FINISHED_A:
case SSL3_ST_CR_FINISHED_B:
+ s->s3->flags |= SSL3_FLAGS_CCS_OK;
ret=ssl3_get_finished(s,SSL3_ST_CR_FINISHED_A,
SSL3_ST_CR_FINISHED_B);
if (ret <= 0) goto end;
@@ -706,6 +707,7 @@ int ssl3_get_server_hello(SSL *s)
SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT);
goto f_err;
}
+ s->s3->flags |= SSL3_FLAGS_CCS_OK;
s->hit=1;
}
else /* a miss or crap from the other end */
diff -up openssl-fips-0.9.8e/ssl/s3_pkt.c.keying-mitm openssl-fips-0.9.8e/ssl/s3_pkt.c
--- openssl-fips-0.9.8e/ssl/s3_pkt.c.keying-mitm 2014-06-02 15:45:18.375350271 +0200
+++ openssl-fips-0.9.8e/ssl/s3_pkt.c 2014-06-02 15:49:35.037283962 +0200
@@ -1133,6 +1133,15 @@ start:
goto f_err;
}
+ if (!(s->s3->flags & SSL3_FLAGS_CCS_OK))
+ {
+ al=SSL_AD_UNEXPECTED_MESSAGE;
+ SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_CCS_RECEIVED_EARLY);
+ goto f_err;
+ }
+
+ s->s3->flags &= ~SSL3_FLAGS_CCS_OK;
+
rr->length=0;
if (s->msg_callback)
@@ -1264,7 +1273,7 @@ int ssl3_do_change_cipher_spec(SSL *s)
if (s->s3->tmp.key_block == NULL)
{
- if (s->session == NULL)
+ if (s->session == NULL || s->session->master_key_length == 0)
{
/* might happen if dtls1_read_bytes() calls this */
SSLerr(SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC,SSL_R_CCS_RECEIVED_EARLY);
diff -up openssl-fips-0.9.8e/ssl/s3_srvr.c.keying-mitm openssl-fips-0.9.8e/ssl/s3_srvr.c
--- openssl-fips-0.9.8e/ssl/s3_srvr.c.keying-mitm 2014-06-02 15:45:18.362349971 +0200
+++ openssl-fips-0.9.8e/ssl/s3_srvr.c 2014-06-02 15:49:35.037283962 +0200
@@ -492,6 +492,7 @@ int ssl3_accept(SSL *s)
case SSL3_ST_SR_CERT_VRFY_A:
case SSL3_ST_SR_CERT_VRFY_B:
+ s->s3->flags |= SSL3_FLAGS_CCS_OK;
/* we should decide if we expected this one */
ret=ssl3_get_cert_verify(s);
if (ret <= 0) goto end;
@@ -502,6 +503,7 @@ int ssl3_accept(SSL *s)
case SSL3_ST_SR_FINISHED_A:
case SSL3_ST_SR_FINISHED_B:
+ s->s3->flags |= SSL3_FLAGS_CCS_OK;
ret=ssl3_get_finished(s,SSL3_ST_SR_FINISHED_A,
SSL3_ST_SR_FINISHED_B);
if (ret <= 0) goto end;