aboutsummaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authorDavid Benjamin <davidben@google.com>2021-05-20 15:57:09 -0400
committerDavid Benjamin <davidben@google.com>2021-06-11 18:36:38 +0000
commit83a49939abb5a15508548ed1d33af8128d70cab5 (patch)
tree92124e67e0431fe53bd31862e73975bc5e4f49eb /tool
parent24545c541c424b4f9bd8f42edc06d84d6542e764 (diff)
downloadboringssl-83a49939abb5a15508548ed1d33af8128d70cab5.zip
boringssl-83a49939abb5a15508548ed1d33af8128d70cab5.tar.gz
boringssl-83a49939abb5a15508548ed1d33af8128d70cab5.tar.bz2
Add most of an ECH client implementation.
Based on an initial implementation by Dan McArdle at https://boringssl-review.googlesource.com/c/boringssl/+/46784 This CL contains most of a client implementation for draft-ietf-tls-esni-10. The pieces missing so far, which will be done in follow-up CLs are: 1. While the ClientHelloInner is padded, the server Certificate message is not. I'll add that once we resolve the spec discussions on how to do that. (We were originally going to use TLS record-level padding, but that doesn't work well with QUIC.) 2. The client should check the public name is a valid DNS name before copying it into ClientHelloOuter.server_name. 3. The ClientHelloOuter handshake flow is not yet implemented. This CL can detect when the server selects ClientHelloOuter, but for now the handshake immediately fails. A follow-up CL will remove that logic and instead add the APIs and extra checks needed. Otherwise, this should be complete, including padding and compression. The main interesting point design-wise is that we run through ClientHello construction multiple times. We need to construct ClientHelloInner and ClientHelloOuter. Then each of those has slight variants: EncodedClientHelloInner is the compressed form, and ClientHelloOuterAAD just has the ECH extension erased to avoid a circular dependency. I've computed ClientHelloInner and EncodedClientHelloInner concurrently because the compression scheme requires shifting the extensions around to be contiguous. However, I've computed ClientHelloOuterAAD and ClientHelloOuter by running through the logic twice. This probably can be done better, but the next draft revises the construction anyway, so I'm thinking I'll rework it then. (In the next draft, we use a placeholder payload of the same length, so we can construct the ClientHello once and fill in the payload.) Additionally, now that we have a client available in ssl_test, this adds a threading test to confirm that SSL_CTX_set1_ech_keys is properly synchronized. (Confirmed that, if I drop the lock in SSL_CTX_set1_ech_keys, TSan notices.) Change-Id: Icaff68b595035bdcc73c468ff638e67c84239ef4 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/48004 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'tool')
-rw-r--r--tool/client.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/tool/client.cc b/tool/client.cc
index a36d7ea..6f738e3 100644
--- a/tool/client.cc
+++ b/tool/client.cc
@@ -64,6 +64,13 @@ static const struct argument kArguments[] = {
"-server-name", kOptionalArgument, "The server name to advertise",
},
{
+ "-ech-grease", kBooleanArgument, "Enable ECH GREASE",
+ },
+ {
+ "-ech-config-list", kOptionalArgument,
+ "Path to file containing serialized ECHConfigs",
+ },
+ {
"-select-next-proto", kOptionalArgument,
"An NPN protocol to select if the server supports NPN",
},
@@ -265,6 +272,24 @@ static bool DoConnection(SSL_CTX *ctx,
SSL_set_tlsext_host_name(ssl.get(), args_map["-server-name"].c_str());
}
+ if (args_map.count("-ech-grease") != 0) {
+ SSL_set_enable_ech_grease(ssl.get(), 1);
+ }
+
+ if (args_map.count("-ech-config-list") != 0) {
+ const char *filename = args_map["-ech-config-list"].c_str();
+ ScopedFILE f(fopen(filename, "rb"));
+ std::vector<uint8_t> data;
+ if (f == nullptr || !ReadAll(&data, f.get())) {
+ fprintf(stderr, "Error reading %s.\n", filename);
+ return false;
+ }
+ if (!SSL_set1_ech_config_list(ssl.get(), data.data(), data.size())) {
+ fprintf(stderr, "Error setting ECHConfigList\n");
+ return false;
+ }
+ }
+
if (args_map.count("-session-in") != 0) {
bssl::UniquePtr<BIO> in(BIO_new_file(args_map["-session-in"].c_str(),
"rb"));