handoff.cc
Go to the documentation of this file.
1 /* Copyright (c) 2018, Google Inc.
2  *
3  * Permission to use, copy, modify, and/or distribute this software for any
4  * purpose with or without fee is hereby granted, provided that the above
5  * copyright notice and this permission notice appear in all copies.
6  *
7  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
14 
15 #include <openssl/ssl.h>
16 
17 #include <openssl/bytestring.h>
18 #include <openssl/err.h>
19 
20 #include "internal.h"
21 
22 
24 
25 constexpr int kHandoffVersion = 0;
26 constexpr int kHandbackVersion = 0;
27 
28 static const unsigned kHandoffTagALPS = CBS_ASN1_CONTEXT_SPECIFIC | 0;
29 
30 // early_data_t represents the state of early data in a more compact way than
31 // the 3 bits used by the implementation.
37 
39 };
40 
41 // serialize_features adds a description of features supported by this binary to
42 // |out|. Returns true on success and false on error.
43 static bool serialize_features(CBB *out) {
44  CBB ciphers;
45  if (!CBB_add_asn1(out, &ciphers, CBS_ASN1_OCTETSTRING)) {
46  return false;
47  }
48  Span<const SSL_CIPHER> all_ciphers = AllCiphers();
49  for (const SSL_CIPHER& cipher : all_ciphers) {
50  if (!CBB_add_u16(&ciphers, static_cast<uint16_t>(cipher.id))) {
51  return false;
52  }
53  }
54  CBB curves;
55  if (!CBB_add_asn1(out, &curves, CBS_ASN1_OCTETSTRING)) {
56  return false;
57  }
58  for (const NamedGroup& g : NamedGroups()) {
59  if (!CBB_add_u16(&curves, g.group_id)) {
60  return false;
61  }
62  }
63  // ALPS is a draft protocol and may change over time. The handoff structure
64  // contains a [0] IMPLICIT OCTET STRING OPTIONAL, containing a list of u16
65  // ALPS versions that the binary supports. For now we name them by codepoint.
66  // Once ALPS is finalized and past the support horizon, this field can be
67  // removed.
68  CBB alps;
69  if (!CBB_add_asn1(out, &alps, kHandoffTagALPS) ||
71  return false;
72  }
73  return CBB_flush(out);
74 }
75 
76 bool SSL_serialize_handoff(const SSL *ssl, CBB *out,
77  SSL_CLIENT_HELLO *out_hello) {
78  const SSL3_STATE *const s3 = ssl->s3;
79  if (!ssl->server ||
80  s3->hs == nullptr ||
81  s3->rwstate != SSL_ERROR_HANDOFF) {
82  return false;
83  }
84 
85  CBB seq;
87  Span<const uint8_t> transcript = s3->hs->transcript.buffer();
88  if (!CBB_add_asn1(out, &seq, CBS_ASN1_SEQUENCE) ||
90  !CBB_add_asn1_octet_string(&seq, transcript.data(), transcript.size()) ||
92  reinterpret_cast<uint8_t *>(s3->hs_buf->data),
93  s3->hs_buf->length) ||
94  !serialize_features(&seq) ||
95  !CBB_flush(out) ||
96  !ssl->method->get_message(ssl, &msg) ||
97  !ssl_client_hello_init(ssl, out_hello, msg.body)) {
98  return false;
99  }
100 
101  return true;
102 }
103 
105  const SSL3_STATE *const s3 = ssl->s3;
106  if (!ssl->server ||
107  s3->hs == nullptr ||
108  s3->rwstate != SSL_ERROR_HANDOFF) {
109  return false;
110  }
111 
112  s3->hs->config->handoff = false;
113  return true;
114 }
115 
116 // apply_remote_features reads a list of supported features from |in| and
117 // (possibly) reconfigures |ssl| to disallow the negotation of features whose
118 // support has not been indicated. (This prevents the the handshake from
119 // committing to features that are not supported on the handoff/handback side.)
120 static bool apply_remote_features(SSL *ssl, CBS *in) {
121  CBS ciphers;
122  if (!CBS_get_asn1(in, &ciphers, CBS_ASN1_OCTETSTRING)) {
123  return false;
124  }
126  while (CBS_len(&ciphers)) {
127  uint16_t id;
128  if (!CBS_get_u16(&ciphers, &id)) {
129  return false;
130  }
131  const SSL_CIPHER *cipher = SSL_get_cipher_by_value(id);
132  if (!cipher) {
133  continue;
134  }
135  if (!sk_SSL_CIPHER_push(supported.get(), cipher)) {
136  return false;
137  }
138  }
139  STACK_OF(SSL_CIPHER) *configured =
140  ssl->config->cipher_list ? ssl->config->cipher_list->ciphers.get()
141  : ssl->ctx->cipher_list->ciphers.get();
143  for (const SSL_CIPHER *configured_cipher : configured) {
144  if (sk_SSL_CIPHER_find(supported.get(), nullptr, configured_cipher)) {
145  continue;
146  }
147  if (!sk_SSL_CIPHER_push(unsupported.get(), configured_cipher)) {
148  return false;
149  }
150  }
151  if (sk_SSL_CIPHER_num(unsupported.get()) && !ssl->config->cipher_list) {
152  ssl->config->cipher_list = bssl::MakeUnique<SSLCipherPreferenceList>();
153  if (!ssl->config->cipher_list->Init(*ssl->ctx->cipher_list)) {
154  return false;
155  }
156  }
157  for (const SSL_CIPHER *unsupported_cipher : unsupported.get()) {
158  ssl->config->cipher_list->Remove(unsupported_cipher);
159  }
160  if (sk_SSL_CIPHER_num(SSL_get_ciphers(ssl)) == 0) {
161  return false;
162  }
163 
164  CBS curves;
165  if (!CBS_get_asn1(in, &curves, CBS_ASN1_OCTETSTRING)) {
166  return false;
167  }
168  Array<uint16_t> supported_curves;
169  if (!supported_curves.Init(CBS_len(&curves) / 2)) {
170  return false;
171  }
172  size_t idx = 0;
173  while (CBS_len(&curves)) {
174  uint16_t curve;
175  if (!CBS_get_u16(&curves, &curve)) {
176  return false;
177  }
178  supported_curves[idx++] = curve;
179  }
180  Span<const uint16_t> configured_curves =
181  tls1_get_grouplist(ssl->s3->hs.get());
182  Array<uint16_t> new_configured_curves;
183  if (!new_configured_curves.Init(configured_curves.size())) {
184  return false;
185  }
186  idx = 0;
187  for (uint16_t configured_curve : configured_curves) {
188  bool ok = false;
189  for (uint16_t supported_curve : supported_curves) {
190  if (supported_curve == configured_curve) {
191  ok = true;
192  break;
193  }
194  }
195  if (ok) {
196  new_configured_curves[idx++] = configured_curve;
197  }
198  }
199  if (idx == 0) {
200  return false;
201  }
202  new_configured_curves.Shrink(idx);
203  ssl->config->supported_group_list = std::move(new_configured_curves);
204 
205  CBS alps;
206  CBS_init(&alps, nullptr, 0);
207  if (!CBS_get_optional_asn1(in, &alps, /*out_present=*/nullptr,
208  kHandoffTagALPS)) {
209  return false;
210  }
211  bool supports_alps = false;
212  while (CBS_len(&alps) != 0) {
213  uint16_t id;
214  if (!CBS_get_u16(&alps, &id)) {
215  return false;
216  }
217  // For now, we only support one ALPS code point, so we only need to extract
218  // a boolean signal from the feature list.
220  supports_alps = true;
221  break;
222  }
223  }
224  if (!supports_alps) {
225  ssl->config->alps_configs.clear();
226  }
227 
228  return true;
229 }
230 
231 // uses_disallowed_feature returns true iff |ssl| enables a feature that
232 // disqualifies it for split handshakes.
233 static bool uses_disallowed_feature(const SSL *ssl) {
234  return ssl->method->is_dtls || (ssl->config->cert && ssl->config->cert->dc) ||
235  ssl->config->quic_transport_params.size() > 0 || ssl->ctx->ech_keys;
236 }
237 
239  if (uses_disallowed_feature(ssl)) {
240  return false;
241  }
242 
243  CBS seq, handoff_cbs(handoff);
244  uint64_t handoff_version;
245  if (!CBS_get_asn1(&handoff_cbs, &seq, CBS_ASN1_SEQUENCE) ||
246  !CBS_get_asn1_uint64(&seq, &handoff_version) ||
247  handoff_version != kHandoffVersion) {
248  return false;
249  }
250 
251  CBS transcript, hs_buf;
252  if (!CBS_get_asn1(&seq, &transcript, CBS_ASN1_OCTETSTRING) ||
253  !CBS_get_asn1(&seq, &hs_buf, CBS_ASN1_OCTETSTRING) ||
254  !apply_remote_features(ssl, &seq)) {
255  return false;
256  }
257 
259 
260  SSL3_STATE *const s3 = ssl->s3;
261  s3->v2_hello_done = true;
262  s3->has_message = true;
263 
264  s3->hs_buf.reset(BUF_MEM_new());
265  if (!s3->hs_buf ||
266  !BUF_MEM_append(s3->hs_buf.get(), CBS_data(&hs_buf), CBS_len(&hs_buf))) {
267  return false;
268  }
269 
270  if (CBS_len(&transcript) != 0) {
271  s3->hs->transcript.Update(transcript);
272  s3->is_v2_hello = true;
273  }
274  s3->hs->handback = true;
275 
276  return true;
277 }
278 
279 bool SSL_serialize_handback(const SSL *ssl, CBB *out) {
280  if (!ssl->server || uses_disallowed_feature(ssl)) {
281  return false;
282  }
283  const SSL3_STATE *const s3 = ssl->s3;
284  SSL_HANDSHAKE *const hs = s3->hs.get();
286  switch (hs->state) {
289  break;
292  break;
295  break;
296  case state12_tls13:
298  return false;
299  }
301  break;
302  default:
303  return false;
304  }
305 
306  size_t hostname_len = 0;
307  if (s3->hostname) {
308  hostname_len = strlen(s3->hostname.get());
309  }
310 
311  Span<const uint8_t> transcript;
313  transcript = s3->hs->transcript.buffer();
314  }
315  size_t write_iv_len = 0;
316  const uint8_t *write_iv = nullptr;
319  ssl->version == TLS1_VERSION &&
321  !s3->aead_write_ctx->GetIV(&write_iv, &write_iv_len)) {
322  return false;
323  }
324  size_t read_iv_len = 0;
325  const uint8_t *read_iv = nullptr;
327  ssl->version == TLS1_VERSION &&
328  SSL_CIPHER_is_block_cipher(s3->aead_read_ctx->cipher()) &&
329  !s3->aead_read_ctx->GetIV(&read_iv, &read_iv_len)) {
330  return false;
331  }
332 
333  // TODO(mab): make sure everything is serialized.
334  CBB seq, key_share;
335  const SSL_SESSION *session;
336  if (type == handback_tls13) {
337  session = hs->new_session.get();
338  } else {
339  session = s3->session_reused ? ssl->session.get() : hs->new_session.get();
340  }
341  static const uint8_t kUnusedChannelID[64] = {0};
342  if (!CBB_add_asn1(out, &seq, CBS_ASN1_SEQUENCE) ||
344  !CBB_add_asn1_uint64(&seq, type) ||
346  sizeof(s3->read_sequence)) ||
348  sizeof(s3->write_sequence)) ||
350  sizeof(s3->server_random)) ||
352  sizeof(s3->client_random)) ||
353  !CBB_add_asn1_octet_string(&seq, read_iv, read_iv_len) ||
354  !CBB_add_asn1_octet_string(&seq, write_iv, write_iv_len) ||
355  !CBB_add_asn1_bool(&seq, s3->session_reused) ||
357  !ssl_session_serialize(session, &seq) ||
359  s3->next_proto_negotiated.size()) ||
361  s3->alpn_selected.size()) ||
363  &seq, reinterpret_cast<uint8_t *>(s3->hostname.get()),
364  hostname_len) ||
365  !CBB_add_asn1_octet_string(&seq, kUnusedChannelID,
366  sizeof(kUnusedChannelID)) ||
367  // These two fields were historically |token_binding_negotiated| and
368  // |negotiated_token_binding_param|.
369  !CBB_add_asn1_bool(&seq, 0) ||
370  !CBB_add_asn1_uint64(&seq, 0) ||
371  !CBB_add_asn1_bool(&seq, s3->hs->next_proto_neg_seen) ||
372  !CBB_add_asn1_bool(&seq, s3->hs->cert_request) ||
373  !CBB_add_asn1_bool(&seq, s3->hs->extended_master_secret) ||
374  !CBB_add_asn1_bool(&seq, s3->hs->ticket_expected) ||
375  !CBB_add_asn1_uint64(&seq, SSL_CIPHER_get_id(s3->hs->new_cipher)) ||
376  !CBB_add_asn1_octet_string(&seq, transcript.data(), transcript.size()) ||
377  !CBB_add_asn1(&seq, &key_share, CBS_ASN1_SEQUENCE)) {
378  return false;
379  }
380  if (type == handback_after_ecdhe &&
381  !s3->hs->key_shares[0]->Serialize(&key_share)) {
382  return false;
383  }
384  if (type == handback_tls13) {
385  early_data_t early_data;
386  // Check early data invariants.
387  if (ssl->enable_early_data ==
389  return false;
390  }
391  if (hs->early_data_offered) {
392  if (s3->early_data_accepted && !s3->skip_early_data) {
393  early_data = early_data_accepted;
394  } else if (!s3->early_data_accepted && !s3->skip_early_data) {
395  early_data = early_data_rejected_hrr;
396  } else if (!s3->early_data_accepted && s3->skip_early_data) {
397  early_data = early_data_skipped;
398  } else {
399  return false;
400  }
401  } else if (!s3->early_data_accepted && !s3->skip_early_data) {
402  early_data = early_data_not_offered;
403  } else {
404  return false;
405  }
407  hs->client_traffic_secret_0().size()) ||
409  hs->server_traffic_secret_0().size()) ||
411  hs->client_handshake_secret().size()) ||
413  hs->server_handshake_secret().size()) ||
414  !CBB_add_asn1_octet_string(&seq, hs->secret().data(),
415  hs->secret().size()) ||
417  s3->exporter_secret_len) ||
419  !CBB_add_asn1_bool(&seq, hs->accept_psk_mode) ||
420  !CBB_add_asn1_int64(&seq, s3->ticket_age_skew) ||
422  !CBB_add_asn1_uint64(&seq, early_data)) {
423  return false;
424  }
425  if (early_data == early_data_accepted &&
427  hs->early_traffic_secret().size())) {
428  return false;
429  }
430  }
431  return CBB_flush(out);
432 }
433 
434 static bool CopyExact(Span<uint8_t> out, const CBS *in) {
435  if (CBS_len(in) != out.size()) {
436  return false;
437  }
438  OPENSSL_memcpy(out.data(), CBS_data(in), out.size());
439  return true;
440 }
441 
443  if (ssl->do_handshake != nullptr ||
444  ssl->method->is_dtls) {
445  return false;
446  }
447 
448  SSL3_STATE *const s3 = ssl->s3;
449  uint64_t handback_version, unused_token_binding_param, cipher, type_u64;
450 
451  CBS seq, read_seq, write_seq, server_rand, client_rand, read_iv, write_iv,
452  next_proto, alpn, hostname, unused_channel_id, transcript, key_share;
453  int session_reused, channel_id_negotiated, cert_request,
454  extended_master_secret, ticket_expected, unused_token_binding,
455  next_proto_neg_seen;
456  SSL_SESSION *session = nullptr;
457 
458  CBS handback_cbs(handback);
459  if (!CBS_get_asn1(&handback_cbs, &seq, CBS_ASN1_SEQUENCE) ||
460  !CBS_get_asn1_uint64(&seq, &handback_version) ||
461  handback_version != kHandbackVersion ||
462  !CBS_get_asn1_uint64(&seq, &type_u64) ||
463  type_u64 > handback_max_value) {
464  return false;
465  }
466 
467  handback_t type = static_cast<handback_t>(type_u64);
468  if (!CBS_get_asn1(&seq, &read_seq, CBS_ASN1_OCTETSTRING) ||
469  CBS_len(&read_seq) != sizeof(s3->read_sequence) ||
470  !CBS_get_asn1(&seq, &write_seq, CBS_ASN1_OCTETSTRING) ||
471  CBS_len(&write_seq) != sizeof(s3->write_sequence) ||
472  !CBS_get_asn1(&seq, &server_rand, CBS_ASN1_OCTETSTRING) ||
473  CBS_len(&server_rand) != sizeof(s3->server_random) ||
474  !CBS_copy_bytes(&server_rand, s3->server_random,
475  sizeof(s3->server_random)) ||
476  !CBS_get_asn1(&seq, &client_rand, CBS_ASN1_OCTETSTRING) ||
477  CBS_len(&client_rand) != sizeof(s3->client_random) ||
478  !CBS_copy_bytes(&client_rand, s3->client_random,
479  sizeof(s3->client_random)) ||
480  !CBS_get_asn1(&seq, &read_iv, CBS_ASN1_OCTETSTRING) ||
481  !CBS_get_asn1(&seq, &write_iv, CBS_ASN1_OCTETSTRING) ||
482  !CBS_get_asn1_bool(&seq, &session_reused) ||
483  !CBS_get_asn1_bool(&seq, &channel_id_negotiated)) {
484  return false;
485  }
486 
487  s3->hs = ssl_handshake_new(ssl);
488  SSL_HANDSHAKE *const hs = s3->hs.get();
489  if (!session_reused || type == handback_tls13) {
490  hs->new_session =
491  SSL_SESSION_parse(&seq, ssl->ctx->x509_method, ssl->ctx->pool);
492  session = hs->new_session.get();
493  } else {
494  ssl->session =
495  SSL_SESSION_parse(&seq, ssl->ctx->x509_method, ssl->ctx->pool);
496  session = ssl->session.get();
497  }
498 
499  if (!session || !CBS_get_asn1(&seq, &next_proto, CBS_ASN1_OCTETSTRING) ||
500  !CBS_get_asn1(&seq, &alpn, CBS_ASN1_OCTETSTRING) ||
501  !CBS_get_asn1(&seq, &hostname, CBS_ASN1_OCTETSTRING) ||
502  !CBS_get_asn1(&seq, &unused_channel_id, CBS_ASN1_OCTETSTRING) ||
503  !CBS_get_asn1_bool(&seq, &unused_token_binding) ||
504  !CBS_get_asn1_uint64(&seq, &unused_token_binding_param) ||
505  !CBS_get_asn1_bool(&seq, &next_proto_neg_seen) ||
506  !CBS_get_asn1_bool(&seq, &cert_request) ||
507  !CBS_get_asn1_bool(&seq, &extended_master_secret) ||
508  !CBS_get_asn1_bool(&seq, &ticket_expected) ||
509  !CBS_get_asn1_uint64(&seq, &cipher)) {
510  return false;
511  }
512  if ((hs->new_cipher =
513  SSL_get_cipher_by_value(static_cast<uint16_t>(cipher))) == nullptr) {
514  return false;
515  }
516  if (!CBS_get_asn1(&seq, &transcript, CBS_ASN1_OCTETSTRING) ||
517  !CBS_get_asn1(&seq, &key_share, CBS_ASN1_SEQUENCE)) {
518  return false;
519  }
520  CBS client_handshake_secret, server_handshake_secret, client_traffic_secret_0,
521  server_traffic_secret_0, secret, exporter_secret, early_traffic_secret;
522  if (type == handback_tls13) {
523  int used_hello_retry_request, accept_psk_mode;
524  uint64_t early_data, early_data_reason;
525  int64_t ticket_age_skew;
526  if (!CBS_get_asn1(&seq, &client_traffic_secret_0, CBS_ASN1_OCTETSTRING) ||
527  !CBS_get_asn1(&seq, &server_traffic_secret_0, CBS_ASN1_OCTETSTRING) ||
528  !CBS_get_asn1(&seq, &client_handshake_secret, CBS_ASN1_OCTETSTRING) ||
529  !CBS_get_asn1(&seq, &server_handshake_secret, CBS_ASN1_OCTETSTRING) ||
530  !CBS_get_asn1(&seq, &secret, CBS_ASN1_OCTETSTRING) ||
531  !CBS_get_asn1(&seq, &exporter_secret, CBS_ASN1_OCTETSTRING) ||
532  !CBS_get_asn1_bool(&seq, &used_hello_retry_request) ||
533  !CBS_get_asn1_bool(&seq, &accept_psk_mode) ||
534  !CBS_get_asn1_int64(&seq, &ticket_age_skew) ||
535  !CBS_get_asn1_uint64(&seq, &early_data_reason) ||
536  early_data_reason > ssl_early_data_reason_max_value ||
537  !CBS_get_asn1_uint64(&seq, &early_data) ||
538  early_data > early_data_max_value) {
539  return false;
540  }
541  early_data_t early_data_type = static_cast<early_data_t>(early_data);
542  if (early_data_type == early_data_accepted &&
543  !CBS_get_asn1(&seq, &early_traffic_secret, CBS_ASN1_OCTETSTRING)) {
544  return false;
545  }
546  if (ticket_age_skew > std::numeric_limits<int32_t>::max() ||
548  return false;
549  }
550  s3->ticket_age_skew = static_cast<int32_t>(ticket_age_skew);
551  s3->used_hello_retry_request = used_hello_retry_request;
552  hs->accept_psk_mode = accept_psk_mode;
553 
554  s3->early_data_reason =
555  static_cast<ssl_early_data_reason_t>(early_data_reason);
557  s3->skip_early_data = false;
558  s3->early_data_accepted = false;
559  hs->early_data_offered = false;
560  switch (early_data_type) {
562  break;
563  case early_data_accepted:
564  s3->early_data_accepted = true;
565  hs->early_data_offered = true;
566  hs->can_early_write = true;
567  hs->can_early_read = true;
568  hs->in_early_data = true;
569  break;
571  hs->early_data_offered = true;
572  break;
573  case early_data_skipped:
574  s3->skip_early_data = true;
575  hs->early_data_offered = true;
576  break;
577  default:
578  return false;
579  }
580  } else {
582  }
583 
584  ssl->version = session->ssl_version;
585  s3->have_version = true;
586  if (!ssl_method_supports_version(ssl->method, ssl->version) ||
587  session->cipher != hs->new_cipher ||
590  return false;
591  }
593  ssl->server = true;
594  switch (type) {
597  if (!session_reused) {
598  return false;
599  }
600  break;
603  if (session_reused) {
604  return false;
605  }
606  break;
609  break;
610  case handback_tls13:
611  hs->state = state12_tls13;
613  break;
614  default:
615  return false;
616  }
617  s3->session_reused = session_reused;
618  hs->channel_id_negotiated = channel_id_negotiated;
619  s3->next_proto_negotiated.CopyFrom(next_proto);
620  s3->alpn_selected.CopyFrom(alpn);
621 
622  const size_t hostname_len = CBS_len(&hostname);
623  if (hostname_len == 0) {
624  s3->hostname.reset();
625  } else {
626  char *hostname_str = nullptr;
627  if (!CBS_strdup(&hostname, &hostname_str)) {
628  return false;
629  }
630  s3->hostname.reset(hostname_str);
631  }
632 
633  hs->next_proto_neg_seen = next_proto_neg_seen;
634  hs->wait = ssl_hs_flush;
635  hs->extended_master_secret = extended_master_secret;
636  hs->ticket_expected = ticket_expected;
637  s3->aead_write_ctx->SetVersionIfNullCipher(ssl->version);
638  hs->cert_request = cert_request;
639 
641  (!hs->transcript.Init() ||
643  !hs->transcript.Update(transcript))) {
644  return false;
645  }
646  if (type == handback_tls13) {
648  if (!CopyExact(hs->client_traffic_secret_0(), &client_traffic_secret_0) ||
649  !CopyExact(hs->server_traffic_secret_0(), &server_traffic_secret_0) ||
650  !CopyExact(hs->client_handshake_secret(), &client_handshake_secret) ||
651  !CopyExact(hs->server_handshake_secret(), &server_handshake_secret) ||
652  !CopyExact(hs->secret(), &secret) ||
654  &exporter_secret)) {
655  return false;
656  }
657  s3->exporter_secret_len = CBS_len(&exporter_secret);
658 
659  if (s3->early_data_accepted &&
660  !CopyExact(hs->early_traffic_secret(), &early_traffic_secret)) {
661  return false;
662  }
663  }
664  Array<uint8_t> key_block;
665  switch (type) {
667  // The write keys are installed after server Finished, but the client
668  // keys must wait for ChangeCipherSpec.
669  if (!tls1_configure_aead(ssl, evp_aead_seal, &key_block, session,
670  write_iv)) {
671  return false;
672  }
673  break;
675  // The premaster secret is not yet computed, so install no keys.
676  break;
678  // The handshake is complete, so both keys are installed.
679  if (!tls1_configure_aead(ssl, evp_aead_seal, &key_block, session,
680  write_iv) ||
681  !tls1_configure_aead(ssl, evp_aead_open, &key_block, session,
682  read_iv)) {
683  return false;
684  }
685  break;
686  case handback_tls13:
687  // After server Finished, the application write keys are installed, but
688  // none of the read keys. The read keys are installed in the state machine
689  // immediately after processing handback.
691  hs->new_session.get(),
692  hs->server_traffic_secret_0())) {
693  return false;
694  }
695  break;
696  }
697  if (!CopyExact({s3->read_sequence, sizeof(s3->read_sequence)}, &read_seq) ||
698  !CopyExact({s3->write_sequence, sizeof(s3->write_sequence)},
699  &write_seq)) {
700  return false;
701  }
702  if (type == handback_after_ecdhe &&
703  (hs->key_shares[0] = SSLKeyShare::Create(&key_share)) == nullptr) {
704  return false;
705  }
706  return true; // Trailing data allowed for extensibility.
707 }
708 
710 
711 using namespace bssl;
712 
714  CBB seq;
715  if (!CBB_add_asn1(out, &seq, CBS_ASN1_SEQUENCE) ||
716  !serialize_features(&seq) || //
717  !CBB_flush(out)) {
718  return 0;
719  }
720 
721  return 1;
722 }
723 
724 int SSL_request_handshake_hints(SSL *ssl, const uint8_t *client_hello,
725  size_t client_hello_len,
726  const uint8_t *capabilities,
727  size_t capabilities_len) {
728  if (SSL_is_dtls(ssl)) {
730  return 0;
731  }
732 
733  CBS cbs, seq;
734  CBS_init(&cbs, capabilities, capabilities_len);
735  UniquePtr<SSL_HANDSHAKE_HINTS> hints = MakeUnique<SSL_HANDSHAKE_HINTS>();
736  if (hints == nullptr ||
737  !CBS_get_asn1(&cbs, &seq, CBS_ASN1_SEQUENCE) ||
738  !apply_remote_features(ssl, &seq)) {
739  return 0;
740  }
741 
742  SSL3_STATE *const s3 = ssl->s3;
743  s3->v2_hello_done = true;
744  s3->has_message = true;
745 
746  Array<uint8_t> client_hello_msg;
747  ScopedCBB client_hello_cbb;
748  CBB client_hello_body;
749  if (!ssl->method->init_message(ssl, client_hello_cbb.get(),
750  &client_hello_body, SSL3_MT_CLIENT_HELLO) ||
751  !CBB_add_bytes(&client_hello_body, client_hello, client_hello_len) ||
752  !ssl->method->finish_message(ssl, client_hello_cbb.get(),
753  &client_hello_msg)) {
754  return 0;
755  }
756 
757  s3->hs_buf.reset(BUF_MEM_new());
758  if (!s3->hs_buf || !BUF_MEM_append(s3->hs_buf.get(), client_hello_msg.data(),
759  client_hello_msg.size())) {
760  return 0;
761  }
762 
763  s3->hs->hints_requested = true;
764  s3->hs->hints = std::move(hints);
765  return 1;
766 }
767 
768 // |SSL_HANDSHAKE_HINTS| is serialized as the following ASN.1 structure. We use
769 // implicit tagging to make it a little more compact.
770 //
771 // HandshakeHints ::= SEQUENCE {
772 // serverRandom [0] IMPLICIT OCTET STRING OPTIONAL,
773 // keyShareHint [1] IMPLICIT KeyShareHint OPTIONAL,
774 // signatureHint [2] IMPLICIT SignatureHint OPTIONAL,
775 // -- At most one of decryptedPSKHint or ignorePSKHint may be present. It
776 // -- corresponds to the first entry in pre_shared_keys. TLS 1.2 session
777 // -- tickets will use a separate hint, to ensure the caller does not mix
778 // -- them up.
779 // decryptedPSKHint [3] IMPLICIT OCTET STRING OPTIONAL,
780 // ignorePSKHint [4] IMPLICIT NULL OPTIONAL,
781 // compressCertificateHint [5] IMPLICIT CompressCertificateHint OPTIONAL,
782 // }
783 //
784 // KeyShareHint ::= SEQUENCE {
785 // groupId INTEGER,
786 // publicKey OCTET STRING,
787 // secret OCTET STRING,
788 // }
789 //
790 // SignatureHint ::= SEQUENCE {
791 // algorithm INTEGER,
792 // input OCTET STRING,
793 // subjectPublicKeyInfo OCTET STRING,
794 // signature OCTET STRING,
795 // }
796 //
797 // CompressCertificateHint ::= SEQUENCE {
798 // algorithm INTEGER,
799 // input OCTET STRING,
800 // compressed OCTET STRING,
801 // }
802 
803 // HandshakeHints tags.
804 static const unsigned kServerRandomTag = CBS_ASN1_CONTEXT_SPECIFIC | 0;
805 static const unsigned kKeyShareHintTag =
807 static const unsigned kSignatureHintTag =
809 static const unsigned kDecryptedPSKTag = CBS_ASN1_CONTEXT_SPECIFIC | 3;
810 static const unsigned kIgnorePSKTag = CBS_ASN1_CONTEXT_SPECIFIC | 4;
812 
814  const SSL_HANDSHAKE *hs = ssl->s3->hs.get();
815  if (!ssl->server || !hs->hints_requested) {
817  return 0;
818  }
819 
820  const SSL_HANDSHAKE_HINTS *hints = hs->hints.get();
821  CBB seq, child;
822  if (!CBB_add_asn1(out, &seq, CBS_ASN1_SEQUENCE)) {
823  return 0;
824  }
825 
826  if (!hints->server_random.empty()) {
827  if (!CBB_add_asn1(&seq, &child, kServerRandomTag) ||
829  hints->server_random.size())) {
830  return 0;
831  }
832  }
833 
834  if (hints->key_share_group_id != 0 && !hints->key_share_public_key.empty() &&
835  !hints->key_share_secret.empty()) {
836  if (!CBB_add_asn1(&seq, &child, kKeyShareHintTag) ||
839  hints->key_share_public_key.size()) ||
841  hints->key_share_secret.size())) {
842  return 0;
843  }
844  }
845 
846  if (hints->signature_algorithm != 0 && !hints->signature_input.empty() &&
847  !hints->signature.empty()) {
848  if (!CBB_add_asn1(&seq, &child, kSignatureHintTag) ||
851  hints->signature_input.size()) ||
853  hints->signature_spki.size()) ||
855  hints->signature.size())) {
856  return 0;
857  }
858  }
859 
860  if (!hints->decrypted_psk.empty()) {
861  if (!CBB_add_asn1(&seq, &child, kDecryptedPSKTag) ||
863  hints->decrypted_psk.size())) {
864  return 0;
865  }
866  }
867 
868  if (hints->ignore_psk && //
869  !CBB_add_asn1(&seq, &child, kIgnorePSKTag)) {
870  return 0;
871  }
872 
873  if (hints->cert_compression_alg_id != 0 &&
874  !hints->cert_compression_input.empty() &&
875  !hints->cert_compression_output.empty()) {
879  hints->cert_compression_input.size()) ||
881  hints->cert_compression_output.data(),
882  hints->cert_compression_output.size())) {
883  return 0;
884  }
885  }
886 
887  return CBB_flush(out);
888 }
889 
890 int SSL_set_handshake_hints(SSL *ssl, const uint8_t *hints, size_t hints_len) {
891  if (SSL_is_dtls(ssl)) {
893  return 0;
894  }
895 
896  UniquePtr<SSL_HANDSHAKE_HINTS> hints_obj = MakeUnique<SSL_HANDSHAKE_HINTS>();
897  if (hints_obj == nullptr) {
898  return 0;
899  }
900 
901  CBS cbs, seq, server_random, key_share, signature_hint, ticket, ignore_psk,
902  cert_compression;
903  int has_server_random, has_key_share, has_signature_hint, has_ticket,
904  has_ignore_psk, has_cert_compression;
905  CBS_init(&cbs, hints, hints_len);
906  if (!CBS_get_asn1(&cbs, &seq, CBS_ASN1_SEQUENCE) ||
907  !CBS_get_optional_asn1(&seq, &server_random, &has_server_random,
908  kServerRandomTag) ||
909  !CBS_get_optional_asn1(&seq, &key_share, &has_key_share,
910  kKeyShareHintTag) ||
911  !CBS_get_optional_asn1(&seq, &signature_hint, &has_signature_hint,
913  !CBS_get_optional_asn1(&seq, &ticket, &has_ticket, kDecryptedPSKTag) ||
914  !CBS_get_optional_asn1(&seq, &ignore_psk, &has_ignore_psk,
915  kIgnorePSKTag) ||
916  !CBS_get_optional_asn1(&seq, &cert_compression, &has_cert_compression,
919  return 0;
920  }
921 
922  if (has_server_random && !hints_obj->server_random.CopyFrom(server_random)) {
923  return 0;
924  }
925 
926  if (has_key_share) {
927  uint64_t group_id;
928  CBS public_key, secret;
929  if (!CBS_get_asn1_uint64(&key_share, &group_id) || //
930  group_id == 0 || group_id > 0xffff ||
931  !CBS_get_asn1(&key_share, &public_key, CBS_ASN1_OCTETSTRING) ||
932  !hints_obj->key_share_public_key.CopyFrom(public_key) ||
933  !CBS_get_asn1(&key_share, &secret, CBS_ASN1_OCTETSTRING) ||
934  !hints_obj->key_share_secret.CopyFrom(secret)) {
936  return 0;
937  }
938  hints_obj->key_share_group_id = static_cast<uint16_t>(group_id);
939  }
940 
941  if (has_signature_hint) {
942  uint64_t sig_alg;
943  CBS input, spki, signature;
944  if (!CBS_get_asn1_uint64(&signature_hint, &sig_alg) || //
945  sig_alg == 0 || sig_alg > 0xffff ||
946  !CBS_get_asn1(&signature_hint, &input, CBS_ASN1_OCTETSTRING) ||
947  !hints_obj->signature_input.CopyFrom(input) ||
948  !CBS_get_asn1(&signature_hint, &spki, CBS_ASN1_OCTETSTRING) ||
949  !hints_obj->signature_spki.CopyFrom(spki) ||
950  !CBS_get_asn1(&signature_hint, &signature, CBS_ASN1_OCTETSTRING) ||
951  !hints_obj->signature.CopyFrom(signature)) {
953  return 0;
954  }
955  hints_obj->signature_algorithm = static_cast<uint16_t>(sig_alg);
956  }
957 
958  if (has_ticket && !hints_obj->decrypted_psk.CopyFrom(ticket)) {
959  return 0;
960  }
961 
962  if (has_ignore_psk) {
963  if (CBS_len(&ignore_psk) != 0) {
964  return 0;
965  }
966  hints_obj->ignore_psk = true;
967  }
968 
969  if (has_cert_compression) {
970  uint64_t alg;
971  CBS input, output;
972  if (!CBS_get_asn1_uint64(&cert_compression, &alg) || //
973  alg == 0 || alg > 0xffff ||
974  !CBS_get_asn1(&cert_compression, &input, CBS_ASN1_OCTETSTRING) ||
975  !hints_obj->cert_compression_input.CopyFrom(input) ||
976  !CBS_get_asn1(&cert_compression, &output, CBS_ASN1_OCTETSTRING) ||
977  !hints_obj->cert_compression_output.CopyFrom(output)) {
979  return 0;
980  }
981  hints_obj->cert_compression_alg_id = static_cast<uint16_t>(alg);
982  }
983 
984  ssl->s3->hs->hints = std::move(hints_obj);
985  return 1;
986 }
SSL_HANDSHAKE::hints_requested
bool hints_requested
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2026
early_data_accepted
@ early_data_accepted
Definition: handoff.cc:34
kDecryptedPSKTag
static const unsigned kDecryptedPSKTag
Definition: handoff.cc:809
CBS_get_asn1_uint64
#define CBS_get_asn1_uint64
Definition: boringssl_prefix_symbols.h:1066
ssl_st::server
bool server
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:3777
ssl_st::enable_early_data
bool enable_early_data
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:3784
ssl_cipher_st
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:520
kSignatureHintTag
static const unsigned kSignatureHintTag
Definition: handoff.cc:807
SSL3_STATE::ticket_age_skew
int32_t ticket_age_skew
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2762
CBB_flush
#define CBB_flush
Definition: boringssl_prefix_symbols.h:1045
sk_SSL_CIPHER_new_null
#define sk_SSL_CIPHER_new_null
Definition: boringssl_prefix_symbols.h:569
Array::Init
bool Init(size_t new_size)
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:314
sk_SSL_CIPHER_find
#define sk_SSL_CIPHER_find
Definition: boringssl_prefix_symbols.h:568
public_key
Definition: hrss.c:1881
gen_build_yaml.out
dictionary out
Definition: src/benchmark/gen_build_yaml.py:24
SSL_SESSION_parse
OPENSSL_EXPORT UniquePtr< SSL_SESSION > SSL_SESSION_parse(CBS *cbs, const SSL_X509_METHOD *x509_method, CRYPTO_BUFFER_POOL *pool)
Definition: ssl_asn1.cc:555
CBS_get_u16
#define CBS_get_u16
Definition: boringssl_prefix_symbols.h:1073
Span::size
size_t size() const
Definition: boringssl-with-bazel/src/include/openssl/span.h:133
SSL_HANDSHAKE_HINTS::cert_compression_alg_id
uint16_t cert_compression_alg_id
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1715
SSLTranscript::InitHash
bool InitHash(uint16_t version, const SSL_CIPHER *cipher)
Definition: ssl_transcript.cc:161
SSL_HANDSHAKE::hints
UniquePtr< SSL_HANDSHAKE_HINTS > hints
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1943
cbs_st
Definition: bytestring.h:39
SSL3_STATE::have_version
bool have_version
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2690
ssl_server_handshake
enum ssl_hs_wait_t ssl_server_handshake(SSL_HANDSHAKE *hs)
Definition: handshake_server.cc:1816
SSL3_STATE::exporter_secret
uint8_t exporter_secret[SSL_MAX_MD_SIZE]
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2779
SSL3_STATE::aead_write_ctx
UniquePtr< SSLAEADContext > aead_write_ctx
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2771
BUF_MEM_append
#define BUF_MEM_append
Definition: boringssl_prefix_symbols.h:1007
SSL_HANDSHAKE::extended_master_secret
bool extended_master_secret
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2011
Array::data
const T * data() const
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:274
CBS_data
#define CBS_data
Definition: boringssl_prefix_symbols.h:1057
NamedGroups
Span< const NamedGroup > NamedGroups()
Definition: ssl_key_share.cc:304
SSL_set_accept_state
#define SSL_set_accept_state
Definition: boringssl_prefix_symbols.h:450
uint16_t
unsigned short uint16_t
Definition: stdint-msvc2008.h:79
SSL_HANDSHAKE_HINTS::signature_spki
Array< uint8_t > signature_spki
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1709
handback_after_ecdhe
@ handback_after_ecdhe
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1690
SSL_HANDSHAKE::new_cipher
const SSL_CIPHER * new_cipher
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1933
handback_max_value
@ handback_max_value
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1693
serialize_features
static bool serialize_features(CBB *out)
Definition: handoff.cc:43
OPENSSL_PUT_ERROR
#define OPENSSL_PUT_ERROR(library, reason)
Definition: err.h:423
SSL3_STATE
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2619
ssl_method_supports_version
bool ssl_method_supports_version(const SSL_PROTOCOL_METHOD *method, uint16_t version)
Definition: ssl_versions.cc:72
SSL_CIPHER_is_block_cipher
#define SSL_CIPHER_is_block_cipher
Definition: boringssl_prefix_symbols.h:60
CBB_add_asn1_octet_string
#define CBB_add_asn1_octet_string
Definition: boringssl_prefix_symbols.h:1022
SSL_HANDSHAKE::early_traffic_secret
Span< uint8_t > early_traffic_secret()
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1779
CBS_ASN1_OCTETSTRING
#define CBS_ASN1_OCTETSTRING
Definition: bytestring.h:209
ssl_st::config
bssl::UniquePtr< bssl::SSL_CONFIG > config
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:3712
CBB_add_asn1_int64
#define CBB_add_asn1_int64
Definition: boringssl_prefix_symbols.h:1021
SSL3_STATE::rwstate
int rwstate
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2662
CBS_ASN1_CONTEXT_SPECIFIC
#define CBS_ASN1_CONTEXT_SPECIFIC
Definition: bytestring.h:194
SSL_HANDSHAKE::server_handshake_secret
Span< uint8_t > server_handshake_secret()
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1785
ssl_st::do_handshake
bssl::ssl_hs_wait_t(* do_handshake)(bssl::SSL_HANDSHAKE *hs)
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:3728
handback_tls13
@ handback_tls13
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1692
SSL_set_handshake_hints
int SSL_set_handshake_hints(SSL *ssl, const uint8_t *hints, size_t hints_len)
Definition: handoff.cc:890
handback_after_session_resumption
@ handback_after_session_resumption
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1689
CBS_len
#define CBS_len
Definition: boringssl_prefix_symbols.h:1089
SSL3_STATE::hs
UniquePtr< SSL_HANDSHAKE > hs
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2775
ssl_early_data_disabled
ssl_early_data_disabled
Definition: ssl.h:3557
SSL_HANDSHAKE_HINTS::signature
Array< uint8_t > signature
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1710
bssl
Definition: hpke_test.cc:37
SSL_HANDSHAKE_HINTS::server_random
Array< uint8_t > server_random
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1701
Array::Shrink
void Shrink(size_t new_size)
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:348
SSL3_STATE::next_proto_negotiated
Array< uint8_t > next_proto_negotiated
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2803
CBS_get_asn1
#define CBS_get_asn1
Definition: boringssl_prefix_symbols.h:1061
state13_send_half_rtt_ticket
@ state13_send_half_rtt_ticket
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1674
kHandoffVersion
constexpr BSSL_NAMESPACE_BEGIN int kHandoffVersion
Definition: handoff.cc:25
SSL_HANDSHAKE::secret
Span< uint8_t > secret()
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1775
internal.h
SSL_HANDSHAKE::accept_psk_mode
bool accept_psk_mode
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1962
cbs
const CBS * cbs
Definition: third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h:107
SSL_HANDSHAKE::new_session
UniquePtr< SSL_SESSION > new_session
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1916
CBS_init
#define CBS_init
Definition: boringssl_prefix_symbols.h:1085
SSL_HANDSHAKE::state
int state
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1737
ssl_early_data_protocol_version
ssl_early_data_protocol_version
Definition: ssl.h:3561
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
SSL3_STATE::v2_hello_done
bool v2_hello_done
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2694
SSL3_STATE::alpn_selected
Array< uint8_t > alpn_selected
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2811
state12_read_change_cipher_spec
@ state12_read_change_cipher_spec
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1656
SSL3_MT_CLIENT_HELLO
#define SSL3_MT_CLIENT_HELLO
Definition: ssl3.h:299
Array::CopyFrom
bool CopyFrom(Span< const T > in)
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:338
ssl_st::session
bssl::UniquePtr< SSL_SESSION > session
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:3750
SSL_R_COULD_NOT_PARSE_HINTS
#define SSL_R_COULD_NOT_PARSE_HINTS
Definition: ssl.h:5583
sk_SSL_CIPHER_push
#define sk_SSL_CIPHER_push
Definition: boringssl_prefix_symbols.h:571
SSL_HANDSHAKE::can_early_write
bool can_early_write
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2000
kIgnorePSKTag
static const unsigned kIgnorePSKTag
Definition: handoff.cc:810
early_data_skipped
@ early_data_skipped
Definition: handoff.cc:36
SSL3_STATE::aead_read_ctx
UniquePtr< SSLAEADContext > aead_read_ctx
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2768
CopyExact
static bool CopyExact(Span< uint8_t > out, const CBS *in)
Definition: handoff.cc:434
tls1_get_grouplist
Span< const uint16_t > tls1_get_grouplist(const SSL_HANDSHAKE *hs)
Definition: extensions.cc:311
SSL_HANDSHAKE_HINTS::key_share_group_id
uint16_t key_share_group_id
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1703
Array::empty
bool empty() const
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:277
bytestring.h
ssl_handshake_new
UniquePtr< SSL_HANDSHAKE > ssl_handshake_new(SSL *ssl)
Definition: handshake.cc:196
in
const char * in
Definition: third_party/abseil-cpp/absl/strings/internal/str_format/parser_test.cc:391
SSL_decline_handoff
bool SSL_decline_handoff(SSL *ssl)
Definition: handoff.cc:104
CBB_add_u16
#define CBB_add_u16
Definition: boringssl_prefix_symbols.h:1027
ssl_session_st::ssl_version
uint16_t ssl_version
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:3795
SSL_HANDSHAKE
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1720
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition: abseil-cpp/absl/utility/utility.h:221
Array< uint16_t >
STACK_OF
#define STACK_OF(type)
Definition: stack.h:125
int64_t
signed __int64 int64_t
Definition: stdint-msvc2008.h:89
SSL_serialize_handshake_hints
int SSL_serialize_handshake_hints(const SSL *ssl, CBB *out)
Definition: handoff.cc:813
SSL_HANDSHAKE_HINTS::decrypted_psk
Array< uint8_t > decrypted_psk
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1712
max
int max
Definition: bloaty/third_party/zlib/examples/enough.c:170
Array::size
size_t size() const
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:276
gmock_output_test.output
output
Definition: bloaty/third_party/googletest/googlemock/test/gmock_output_test.py:175
SSL_HANDSHAKE::channel_id_negotiated
bool channel_id_negotiated
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2041
ssl_early_data_reason_max_value
ssl_early_data_reason_max_value
Definition: ssl.h:3584
ssl_st
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:3698
ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED
#define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED
Definition: err.h:372
ssl_early_callback_ctx
Definition: ssl.h:4186
CBS_strdup
#define CBS_strdup
Definition: boringssl_prefix_symbols.h:1094
SSL_HANDSHAKE::next_proto_neg_seen
bool next_proto_neg_seen
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2003
kHandbackVersion
constexpr int kHandbackVersion
Definition: handoff.cc:26
SSL_is_dtls
#define SSL_is_dtls
Definition: boringssl_prefix_symbols.h:402
uint64_t
unsigned __int64 uint64_t
Definition: stdint-msvc2008.h:90
OPENSSL_memcpy
static void * OPENSSL_memcpy(void *dst, const void *src, size_t n)
Definition: third_party/boringssl-with-bazel/src/crypto/internal.h:819
BSSL_NAMESPACE_END
#define BSSL_NAMESPACE_END
Definition: base.h:480
SSL_HANDSHAKE::client_traffic_secret_0
Span< uint8_t > client_traffic_secret_0()
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1788
CBB_add_asn1
#define CBB_add_asn1
Definition: boringssl_prefix_symbols.h:1019
SSL3_STATE::session_reused
bool session_reused
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2709
err.h
ssl_protocol_version
uint16_t ssl_protocol_version(const SSL *ssl)
Definition: ssl_versions.cc:251
state12_tls13
@ state12_tls13
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1646
SSL_CIPHER_get_min_version
#define SSL_CIPHER_get_min_version
Definition: boringssl_prefix_symbols.h:52
tls1_configure_aead
bool tls1_configure_aead(SSL *ssl, evp_aead_direction_t direction, Array< uint8_t > *key_block_cache, const SSL_SESSION *session, Span< const uint8_t > iv_override)
Definition: t1_enc.cc:205
CBS_get_asn1_bool
#define CBS_get_asn1_bool
Definition: boringssl_prefix_symbols.h:1062
evp_aead_open
@ evp_aead_open
Definition: aead.h:430
handback_t
handback_t
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1688
evp_aead_seal
@ evp_aead_seal
Definition: aead.h:431
googletest-filter-unittest.child
child
Definition: bloaty/third_party/googletest/googletest/test/googletest-filter-unittest.py:62
CBB_add_asn1_bool
#define CBB_add_asn1_bool
Definition: boringssl_prefix_symbols.h:1020
ssl_session_st::cipher
const SSL_CIPHER * cipher
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:3860
SSL3_STATE::client_random
uint8_t client_random[SSL3_RANDOM_SIZE]
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2629
min
#define min(a, b)
Definition: qsort.h:83
g
struct @717 g
SSL_HANDSHAKE::server_traffic_secret_0
Span< uint8_t > server_traffic_secret_0()
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1791
uses_disallowed_feature
static bool uses_disallowed_feature(const SSL *ssl)
Definition: handoff.cc:233
SSL3_STATE::read_sequence
uint8_t read_sequence[8]
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2625
Span
Definition: boringssl-with-bazel/src/include/openssl/span.h:32
SSL3_STATE::write_sequence
uint8_t write_sequence[8]
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2626
grpc_core::UniquePtr
std::unique_ptr< T, DefaultDeleteChar > UniquePtr
Definition: src/core/lib/gprpp/memory.h:43
SSL_get_ciphers
#define SSL_get_ciphers
Definition: boringssl_prefix_symbols.h:330
SSL_HANDSHAKE::transcript
SSLTranscript transcript
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1821
setup.idx
idx
Definition: third_party/bloaty/third_party/capstone/bindings/python/setup.py:197
msg
std::string msg
Definition: client_interceptors_end2end_test.cc:372
CBS_ASN1_CONSTRUCTED
#define CBS_ASN1_CONSTRUCTED
Definition: bytestring.h:188
state12_finish_server_handshake
@ state12_finish_server_handshake
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1662
SSL_HANDSHAKE::early_data_offered
bool early_data_offered
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1992
SSL3_STATE::server_random
uint8_t server_random[SSL3_RANDOM_SIZE]
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2628
ssl_client_hello_init
bool ssl_client_hello_init(const SSL *ssl, SSL_CLIENT_HELLO *out, Span< const uint8_t > body)
Definition: extensions.cc:211
ssl.h
apply_remote_features
static bool apply_remote_features(SSL *ssl, CBS *in)
Definition: handoff.cc:120
SSL_HANDSHAKE_HINTS::key_share_secret
Array< uint8_t > key_share_secret
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1705
SSL_HANDSHAKE::cert_request
bool cert_request
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1965
SSL_HANDSHAKE_HINTS::signature_algorithm
uint16_t signature_algorithm
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1707
early_data_max_value
@ early_data_max_value
Definition: handoff.cc:38
SSL_HANDSHAKE::can_early_read
bool can_early_read
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1996
SSLMessage
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1140
ssl_session_st
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:3787
SSL_request_handshake_hints
int SSL_request_handshake_hints(SSL *ssl, const uint8_t *client_hello, size_t client_hello_len, const uint8_t *capabilities, size_t capabilities_len)
Definition: handoff.cc:724
SSL3_STATE::skip_early_data
bool skip_early_data
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2686
CBB_add_bytes
#define CBB_add_bytes
Definition: boringssl_prefix_symbols.h:1025
early_data_not_offered
@ early_data_not_offered
Definition: handoff.cc:33
BSSL_NAMESPACE_BEGIN
Definition: trust_token_test.cc:45
ssl_st::s3
bssl::SSL3_STATE * s3
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:3730
SSLKeyShare::Create
static HAS_VIRTUAL_DESTRUCTOR UniquePtr< SSLKeyShare > Create(uint16_t group_id)
Definition: ssl_key_share.cc:308
ssl_hs_flush
@ ssl_hs_flush
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1614
CBS_get_optional_asn1
#define CBS_get_optional_asn1
Definition: boringssl_prefix_symbols.h:1069
SSL3_STATE::hs_buf
UniquePtr< BUF_MEM > hs_buf
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2743
ssl_encryption_application
ssl_encryption_application
Definition: ssl.h:3285
kKeyShareHintTag
static const unsigned kKeyShareHintTag
Definition: handoff.cc:805
SSL_HANDSHAKE_HINTS::signature_input
Array< uint8_t > signature_input
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1708
TLS1_VERSION
#define TLS1_VERSION
Definition: ssl.h:650
AllCiphers
Span< const SSL_CIPHER > AllCiphers()
Definition: ssl_cipher.cc:465
CBS_copy_bytes
#define CBS_copy_bytes
Definition: boringssl_prefix_symbols.h:1056
SSL_HANDSHAKE::ResizeSecrets
void ResizeSecrets(size_t hash_len)
Definition: handshake.cc:167
SSL_HANDSHAKE_HINTS::ignore_psk
bool ignore_psk
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1713
SSL3_STATE::hostname
UniquePtr< char > hostname
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2814
SSL_HANDSHAKE::key_shares
UniquePtr< SSLKeyShare > key_shares[2]
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1818
SSLTranscript::Update
bool Update(Span< const uint8_t > in)
Definition: ssl_transcript.cc:220
SSL_CIPHER_get_id
#define SSL_CIPHER_get_id
Definition: boringssl_prefix_symbols.h:48
SSL_HANDSHAKE_HINTS::cert_compression_output
Array< uint8_t > cert_compression_output
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1717
kHandoffTagALPS
static const unsigned kHandoffTagALPS
Definition: handoff.cc:28
SSL_HANDSHAKE_HINTS::key_share_public_key
Array< uint8_t > key_share_public_key
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1704
SSL_apply_handoff
bool SSL_apply_handoff(SSL *ssl, Span< const uint8_t > handoff)
Definition: handoff.cc:238
CBS_get_asn1_int64
#define CBS_get_asn1_int64
Definition: boringssl_prefix_symbols.h:1065
ok
bool ok
Definition: async_end2end_test.cc:197
SSL_get_cipher_by_value
#define SSL_get_cipher_by_value
Definition: boringssl_prefix_symbols.h:328
ssl_st::method
const bssl::SSL_PROTOCOL_METHOD * method
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:3706
state12_read_client_certificate
@ state12_read_client_certificate
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1652
SSL_HANDSHAKE::client_handshake_secret
Span< uint8_t > client_handshake_secret()
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1782
input
std::string input
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/tokenizer_unittest.cc:197
SSL_HANDSHAKE_HINTS::cert_compression_input
Array< uint8_t > cert_compression_input
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1716
SSL_serialize_capabilities
int SSL_serialize_capabilities(const SSL *ssl, CBB *out)
Definition: handoff.cc:713
SSLTranscript::Init
bool Init()
Definition: ssl_transcript.cc:151
SSL3_STATE::early_data_accepted
bool early_data_accepted
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2729
BUF_MEM_new
#define BUF_MEM_new
Definition: boringssl_prefix_symbols.h:1011
TLSEXT_TYPE_application_settings
#define TLSEXT_TYPE_application_settings
Definition: tls1.h:247
kCompressCertificateTag
static const unsigned kCompressCertificateTag
Definition: handoff.cc:811
SSL_HANDSHAKE::ticket_expected
bool ticket_expected
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2007
Span::data
T * data() const
Definition: boringssl-with-bazel/src/include/openssl/span.h:132
SSL_HANDSHAKE::tls13_state
int tls13_state
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1741
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
kServerRandomTag
static const unsigned kServerRandomTag
Definition: handoff.cc:804
early_data_rejected_hrr
@ early_data_rejected_hrr
Definition: handoff.cc:35
SSL3_STATE::exporter_secret_len
uint8_t exporter_secret_len
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2782
SSL3_STATE::used_hello_retry_request
bool used_hello_retry_request
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2740
early_data_t
early_data_t
Definition: handoff.cc:32
SSL3_STATE::has_message
bool has_message
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2702
SSL_HANDSHAKE_HINTS
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1698
sk_SSL_CIPHER_num
#define sk_SSL_CIPHER_num
Definition: boringssl_prefix_symbols.h:570
CBS_ASN1_SEQUENCE
#define CBS_ASN1_SEQUENCE
Definition: bytestring.h:214
int32_t
signed int int32_t
Definition: stdint-msvc2008.h:77
tls13_set_traffic_key
bool tls13_set_traffic_key(SSL *ssl, enum ssl_encryption_level_t level, enum evp_aead_direction_t direction, const SSL_SESSION *session, Span< const uint8_t > traffic_secret)
Definition: tls13_enc.cc:156
NamedGroup
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1118
ssl_st::version
uint16_t version
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:3715
SSL_HANDSHAKE::in_early_data
bool in_early_data
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1989
ssl_st::ctx
bssl::UniquePtr< SSL_CTX > ctx
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:3754
handback_after_handshake
@ handback_after_handshake
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1691
SSL_serialize_handback
bool SSL_serialize_handback(const SSL *ssl, CBB *out)
Definition: handoff.cc:279
SSL3_STATE::early_data_reason
enum ssl_early_data_reason_t early_data_reason
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2765
ssl_session_serialize
OPENSSL_EXPORT int ssl_session_serialize(const SSL_SESSION *in, CBB *cbb)
Definition: ssl_asn1.cc:811
SSL_serialize_handoff
bool SSL_serialize_handoff(const SSL *ssl, CBB *out, SSL_CLIENT_HELLO *out_hello)
Definition: handoff.cc:76
SSL_CIPHER_get_max_version
#define SSL_CIPHER_get_max_version
Definition: boringssl_prefix_symbols.h:51
SSL3_STATE::is_v2_hello
bool is_v2_hello
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:2698
SSL_apply_handback
bool SSL_apply_handback(SSL *ssl, Span< const uint8_t > handback)
Definition: handoff.cc:442
SSLTranscript::DigestLen
size_t DigestLen() const
Definition: ssl_transcript.cc:175
id
uint32_t id
Definition: flow_control_fuzzer.cc:70
SSL_HANDSHAKE::wait
enum ssl_hs_wait_t wait
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:1733
CBB_add_asn1_uint64
#define CBB_add_asn1_uint64
Definition: boringssl_prefix_symbols.h:1024
cbb_st
Definition: bytestring.h:375
SSL_ERROR_HANDOFF
#define SSL_ERROR_HANDOFF
Definition: ssl.h:579


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:00