Check the second ClientHello's PSK binder on resumption.

We perform all our negotiation based on the first ClientHello (for
consistency with what |select_certificate_cb| observed), which is in the
transcript, so we can ignore most of the second one.

However, we ought to check the second PSK binder. That covers the client
key share, which we do consume. In particular, we'll want to check if it
we ever send half-RTT data on these connections (we do not currently do
this). It is also a tricky computation, so we enforce the peer handled
it correctly.

Tested that both Chrome and Firefox continue to interop with this check,
when configuring uncommon curve preferences that trigger HRR. (Normally
neither browser sees HRRs against BoringSSL servers.)

Update-Note: This does enforce some client behavior that we hadn't been
    enforcing previously. However, it only figures into TLS 1.3 (not many
    implementations yet), and only clients which hit HelloRetryRequest
    (rare), so this should be low risk.
Change-Id: I42126585ec0685d009542094192e674cbd22520d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37124
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
This commit is contained in:
David Benjamin
2019-08-16 15:32:03 -04:00
committed by CQ bot account: commit-bot@chromium.org
parent 44544d9d2d
commit 9806ae005b
11 changed files with 273 additions and 160 deletions

View File

@@ -137,6 +137,7 @@
#include <openssl/buf.h>
#include <openssl/digest.h>
#include <openssl/err.h>
#include "internal.h"
@@ -205,8 +206,20 @@ bool SSLTranscript::UpdateForHelloRetryRequest() {
return true;
}
bool SSLTranscript::CopyHashContext(EVP_MD_CTX *ctx) {
return EVP_MD_CTX_copy_ex(ctx, hash_.get());
bool SSLTranscript::CopyToHashContext(EVP_MD_CTX *ctx, const EVP_MD *digest) {
const EVP_MD *transcript_digest = Digest();
if (transcript_digest != nullptr &&
EVP_MD_type(transcript_digest) == EVP_MD_type(digest)) {
return EVP_MD_CTX_copy_ex(ctx, hash_.get());
}
if (buffer_) {
return EVP_DigestInit_ex(ctx, digest, nullptr) &&
EVP_DigestUpdate(ctx, buffer_->data, buffer_->length);
}
OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
return false;
}
bool SSLTranscript::Update(Span<const uint8_t> in) {