Skip to content

Commit

Permalink
Apply GREASE to the version extension.
Browse files Browse the repository at this point in the history
BUG=106

Change-Id: Iaa12aeb67627f3c22fe4a917c89c646cb3dc1843
Reviewed-on: https://boringssl-review.googlesource.com/11325
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>
  • Loading branch information
davidben authored and CQ bot account: commit-bot@chromium.org committed Sep 27, 2016
1 parent 9f16ce1 commit d9791bf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions ssl/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,7 @@ enum ssl_grease_index_t {
ssl_grease_group,
ssl_grease_extension1,
ssl_grease_extension2,
ssl_grease_version,
};

/* ssl_get_grease_value returns a GREASE value for |ssl|. For a given
Expand Down
6 changes: 6 additions & 0 deletions ssl/t1_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -2279,6 +2279,12 @@ static int ext_supported_versions_add_clienthello(SSL *ssl, CBB *out) {
return 0;
}

/* Add a fake version. See draft-davidben-tls-grease-01. */
if (ssl->ctx->grease_enabled &&
!CBB_add_u16(&versions, ssl_get_grease_value(ssl, ssl_grease_version))) {
return 0;
}

for (uint16_t version = max_version; version >= min_version; version--) {
if (!CBB_add_u16(&versions, ssl->method->version_to_wire(version))) {
return 0;
Expand Down
10 changes: 8 additions & 2 deletions ssl/test/runner/handshake_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,16 @@ func (hs *serverHandshakeState) readClientHello() error {
c.vers = config.Bugs.NegotiateVersionOnRenego
} else if len(hs.clientHello.supportedVersions) > 0 {
// Use the versions extension if supplied.
var foundVersion bool
var foundVersion, foundGREASE bool
for _, extVersion := range hs.clientHello.supportedVersions {
if isGREASEValue(extVersion) {
foundGREASE = true
}
extVersion, ok = wireToVersion(extVersion, c.isDTLS)
if !ok {
continue
}
if config.isSupportedVersion(extVersion, c.isDTLS) {
if config.isSupportedVersion(extVersion, c.isDTLS) && !foundVersion {
c.vers = extVersion
foundVersion = true
break
Expand All @@ -249,6 +252,9 @@ func (hs *serverHandshakeState) readClientHello() error {
c.sendAlert(alertProtocolVersion)
return errors.New("tls: client did not offer any supported protocol versions")
}
if config.Bugs.ExpectGREASE && !foundGREASE {
return errors.New("tls: no GREASE version value found")
}
} else {
// Otherwise, use the legacy ClientHello version.
version := clientVersion
Expand Down

0 comments on commit d9791bf

Please sign in to comment.