Replace reuse_message with an explicit next_message call.
This means that ssl_get_message (soon to be replaced with a BIO-less
version) is idempotent which avoids the SSL3_ST_SR_KEY_EXCH_B
contortion. It also eases converting the TLS 1.2 state machine. See
https://docs.google.com/a/google.com/document/d/11n7LHsT3GwE34LAJIe3EFs4165TI4UR_3CqiM9LJVpI/edit?usp=sharing
for details.
Bug: 128
Change-Id: Iddd4f951389e8766da07a9de595b552e75f8acf0
Reviewed-on: https://boringssl-review.googlesource.com/18805
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
diff --git a/ssl/handshake_client.cc b/ssl/handshake_client.cc
index 385f726..c43bda3 100644
--- a/ssl/handshake_client.cc
+++ b/ssl/handshake_client.cc
@@ -776,7 +776,6 @@
if (ssl->s3->tmp.message_type != DTLS1_MT_HELLO_VERIFY_REQUEST) {
ssl->d1->send_cookie = false;
- ssl->s3->tmp.reuse_message = 1;
return 1;
}
@@ -794,6 +793,7 @@
ssl->d1->cookie_len = CBS_len(&cookie);
ssl->d1->send_cookie = true;
+ ssl->method->next_message(ssl);
return 1;
}
@@ -1060,6 +1060,7 @@
return -1;
}
+ ssl->method->next_message(ssl);
return 1;
}
@@ -1130,6 +1131,7 @@
}
}
+ ssl->method->next_message(ssl);
return 1;
}
@@ -1143,7 +1145,6 @@
if (ssl->s3->tmp.message_type != SSL3_MT_CERTIFICATE_STATUS) {
/* A server may send status_request in ServerHello and then change
* its mind about sending CertificateStatus. */
- ssl->s3->tmp.reuse_message = 1;
return 1;
}
@@ -1171,6 +1172,7 @@
return -1;
}
+ ssl->method->next_message(ssl);
return 1;
}
@@ -1189,7 +1191,6 @@
return -1;
}
- ssl->s3->tmp.reuse_message = 1;
return 1;
}
@@ -1359,6 +1360,8 @@
return -1;
}
}
+
+ ssl->method->next_message(ssl);
return 1;
}
@@ -1370,7 +1373,6 @@
}
if (ssl->s3->tmp.message_type == SSL3_MT_SERVER_HELLO_DONE) {
- ssl->s3->tmp.reuse_message = 1;
/* If we get here we don't need the handshake buffer as we won't be doing
* client auth. */
hs->transcript.FreeBuffer();
@@ -1426,6 +1428,7 @@
hs->cert_request = 1;
hs->ca_names = std::move(ca_names);
ssl->ctx->x509_method->hs_flush_cached_ca_names(hs);
+ ssl->method->next_message(ssl);
return 1;
}
@@ -1448,6 +1451,7 @@
return -1;
}
+ ssl->method->next_message(ssl);
return 1;
}
@@ -1818,6 +1822,7 @@
* negotiating the extension. The value of |ticket_expected| is checked in
* |ssl_update_cache| so is cleared here to avoid an unnecessary update. */
hs->ticket_expected = 0;
+ ssl->method->next_message(ssl);
return 1;
}
@@ -1861,6 +1866,7 @@
ssl->session = renewed_session.release();
}
+ ssl->method->next_message(ssl);
return 1;
}