grpc 1.38.0 → 1.39.0.pre1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (199) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +50 -19
  3. data/include/grpc/event_engine/endpoint_config.h +48 -0
  4. data/include/grpc/event_engine/event_engine.h +13 -15
  5. data/include/grpc/event_engine/port.h +2 -0
  6. data/include/grpc/event_engine/slice_allocator.h +17 -7
  7. data/include/grpc/grpc.h +9 -2
  8. data/include/grpc/grpc_security.h +32 -0
  9. data/include/grpc/grpc_security_constants.h +1 -0
  10. data/include/grpc/impl/codegen/grpc_types.h +17 -13
  11. data/include/grpc/impl/codegen/port_platform.h +17 -0
  12. data/src/core/ext/filters/client_channel/client_channel.cc +2 -2
  13. data/src/core/ext/filters/client_channel/health/health_check_client.cc +2 -0
  14. data/src/core/ext/filters/client_channel/health/health_check_client.h +3 -3
  15. data/src/core/ext/filters/client_channel/http_proxy.cc +16 -1
  16. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +755 -0
  17. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +10 -0
  18. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +10 -24
  19. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +63 -95
  20. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +1 -3
  21. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_event_engine.cc +31 -0
  22. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_event_engine.cc +28 -0
  23. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +1 -3
  24. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +7 -2
  25. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +15 -3
  26. data/src/core/ext/filters/client_channel/retry_filter.cc +665 -404
  27. data/src/core/ext/filters/client_channel/retry_service_config.cc +43 -24
  28. data/src/core/ext/filters/client_channel/retry_service_config.h +8 -2
  29. data/src/core/ext/filters/client_idle/client_idle_filter.cc +1 -1
  30. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +6 -0
  31. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +2 -1
  32. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +3 -2
  33. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +10 -4
  34. data/src/core/ext/transport/chttp2/transport/internal.h +1 -0
  35. data/src/core/ext/transport/chttp2/transport/parsing.cc +2 -2
  36. data/src/core/ext/transport/inproc/inproc_transport.cc +42 -31
  37. data/src/core/ext/xds/xds_api.cc +247 -106
  38. data/src/core/ext/xds/xds_api.h +15 -6
  39. data/src/core/lib/address_utils/sockaddr_utils.cc +13 -0
  40. data/src/core/lib/address_utils/sockaddr_utils.h +10 -0
  41. data/src/core/lib/channel/channelz.h +3 -0
  42. data/src/core/lib/event_engine/endpoint_config.cc +46 -0
  43. data/src/core/lib/event_engine/endpoint_config_internal.h +42 -0
  44. data/src/core/lib/event_engine/event_engine.cc +50 -0
  45. data/src/core/lib/event_engine/slice_allocator.cc +33 -3
  46. data/src/core/lib/event_engine/sockaddr.cc +14 -12
  47. data/src/core/lib/event_engine/sockaddr.h +44 -0
  48. data/src/core/lib/gpr/wrap_memcpy.cc +2 -1
  49. data/src/core/lib/gprpp/status_helper.h +3 -0
  50. data/src/core/lib/iomgr/endpoint_pair_event_engine.cc +33 -0
  51. data/src/core/lib/iomgr/error.cc +5 -4
  52. data/src/core/lib/iomgr/error.h +1 -1
  53. data/src/core/lib/iomgr/event_engine/closure.cc +54 -0
  54. data/src/core/lib/iomgr/event_engine/closure.h +33 -0
  55. data/src/core/lib/iomgr/event_engine/endpoint.cc +194 -0
  56. data/src/core/lib/iomgr/event_engine/endpoint.h +53 -0
  57. data/src/core/lib/iomgr/event_engine/iomgr.cc +105 -0
  58. data/src/core/lib/iomgr/event_engine/iomgr.h +24 -0
  59. data/src/core/lib/iomgr/event_engine/pollset.cc +87 -0
  60. data/{include/grpc/event_engine/channel_args.h → src/core/lib/iomgr/event_engine/pollset.h} +7 -10
  61. data/src/core/lib/iomgr/event_engine/promise.h +51 -0
  62. data/src/core/lib/iomgr/event_engine/resolved_address_internal.cc +41 -0
  63. data/src/core/lib/iomgr/event_engine/resolved_address_internal.h +35 -0
  64. data/src/core/lib/iomgr/event_engine/resolver.cc +110 -0
  65. data/src/core/lib/iomgr/event_engine/tcp.cc +243 -0
  66. data/src/core/lib/iomgr/event_engine/timer.cc +57 -0
  67. data/src/core/lib/iomgr/exec_ctx.cc +8 -0
  68. data/src/core/lib/iomgr/exec_ctx.h +3 -4
  69. data/src/core/lib/iomgr/executor/threadpool.cc +2 -3
  70. data/src/core/lib/iomgr/executor/threadpool.h +2 -2
  71. data/src/core/lib/iomgr/iomgr.cc +1 -1
  72. data/src/core/lib/iomgr/iomgr_posix.cc +2 -0
  73. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +40 -10
  74. data/src/core/lib/iomgr/pollset_custom.cc +2 -2
  75. data/src/core/lib/iomgr/pollset_custom.h +3 -1
  76. data/src/core/lib/iomgr/pollset_uv.cc +3 -1
  77. data/src/core/lib/iomgr/pollset_uv.h +5 -1
  78. data/src/core/lib/iomgr/port.h +7 -5
  79. data/src/core/lib/iomgr/resolve_address.cc +5 -1
  80. data/src/core/lib/iomgr/resolve_address.h +6 -0
  81. data/src/core/lib/iomgr/sockaddr.h +1 -0
  82. data/src/core/lib/iomgr/socket_mutator.cc +15 -2
  83. data/src/core/lib/iomgr/socket_mutator.h +26 -2
  84. data/src/core/lib/iomgr/socket_utils_common_posix.cc +4 -4
  85. data/src/core/lib/iomgr/socket_utils_posix.h +2 -2
  86. data/src/core/lib/iomgr/tcp_client_posix.cc +7 -2
  87. data/src/core/lib/iomgr/tcp_posix.cc +42 -39
  88. data/src/core/lib/iomgr/tcp_posix.h +8 -0
  89. data/src/core/lib/iomgr/tcp_server_custom.cc +3 -4
  90. data/src/core/lib/iomgr/tcp_server_posix.cc +6 -0
  91. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +2 -1
  92. data/src/core/lib/iomgr/timer.h +6 -1
  93. data/src/core/lib/security/authorization/authorization_engine.h +44 -0
  94. data/src/core/lib/security/authorization/authorization_policy_provider.h +32 -0
  95. data/src/core/lib/security/authorization/authorization_policy_provider_vtable.cc +46 -0
  96. data/src/core/lib/security/authorization/evaluate_args.cc +209 -0
  97. data/src/core/lib/security/authorization/evaluate_args.h +91 -0
  98. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +3 -1
  99. data/src/core/lib/security/credentials/tls/tls_utils.cc +32 -0
  100. data/src/core/lib/security/credentials/tls/tls_utils.h +13 -0
  101. data/src/core/lib/security/security_connector/local/local_security_connector.cc +9 -6
  102. data/src/core/lib/security/security_connector/ssl_utils.cc +5 -0
  103. data/src/core/lib/surface/call.cc +21 -1
  104. data/src/core/lib/surface/call.h +11 -0
  105. data/src/core/lib/surface/completion_queue.cc +22 -22
  106. data/src/core/lib/surface/completion_queue.h +1 -1
  107. data/src/core/lib/surface/completion_queue_factory.cc +1 -2
  108. data/src/core/lib/surface/init.cc +1 -3
  109. data/src/core/lib/surface/init.h +10 -1
  110. data/src/core/lib/surface/version.cc +1 -1
  111. data/src/core/lib/transport/error_utils.cc +2 -2
  112. data/src/core/lib/transport/transport.h +2 -0
  113. data/src/core/lib/transport/transport_op_string.cc +1 -1
  114. data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -0
  115. data/src/core/tsi/alts/crypt/gsec.h +2 -0
  116. data/src/ruby/ext/grpc/extconf.rb +2 -0
  117. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +6 -0
  118. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +10 -1
  119. data/src/ruby/lib/grpc/version.rb +1 -1
  120. data/third_party/boringssl-with-bazel/err_data.c +269 -263
  121. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +8 -6
  122. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/cipher_extra.c +4 -0
  123. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +1 -1
  124. data/third_party/boringssl-with-bazel/src/crypto/curve25519/internal.h +1 -1
  125. data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +9 -0
  126. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/prime.c +0 -4
  127. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +7 -0
  128. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/md32_common.h +87 -121
  129. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md4/md4.c +20 -30
  130. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md5/md5.c +19 -30
  131. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +1 -4
  132. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +0 -13
  133. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +26 -24
  134. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +10 -7
  135. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1.c +28 -39
  136. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha256.c +48 -66
  137. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +4 -5
  138. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +362 -371
  139. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7_x509.c +4 -2
  140. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/passive.c +2 -2
  141. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_asn1.c +1 -2
  142. data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +101 -11
  143. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509a.c +3 -0
  144. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +2 -2
  145. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +3 -0
  146. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +1 -1
  147. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +2 -0
  148. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +14 -15
  149. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vpm.c +53 -73
  150. data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +31 -0
  151. data/third_party/boringssl-with-bazel/src/crypto/x509/x509rset.c +3 -0
  152. data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.c +3 -0
  153. data/third_party/boringssl-with-bazel/src/crypto/x509/x_req.c +5 -8
  154. data/third_party/boringssl-with-bazel/src/crypto/x509/x_sig.c +5 -0
  155. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +3 -0
  156. data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +7 -0
  157. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +1 -1
  158. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +5 -8
  159. data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +1 -1
  160. data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +66 -1
  161. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +40 -9
  162. data/third_party/boringssl-with-bazel/src/include/openssl/bytestring.h +1 -0
  163. data/third_party/boringssl-with-bazel/src/include/openssl/chacha.h +1 -1
  164. data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +6 -2
  165. data/third_party/boringssl-with-bazel/src/include/openssl/ecdsa.h +14 -0
  166. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +19 -11
  167. data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +325 -0
  168. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +23 -7
  169. data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +99 -63
  170. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +139 -109
  171. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +12 -19
  172. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +48 -50
  173. data/third_party/boringssl-with-bazel/src/include/openssl/x509_vfy.h +451 -435
  174. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +0 -1
  175. data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +2 -2
  176. data/third_party/boringssl-with-bazel/src/ssl/d1_srtp.cc +1 -1
  177. data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +773 -84
  178. data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +80 -47
  179. data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +24 -19
  180. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +189 -86
  181. data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +45 -56
  182. data/third_party/boringssl-with-bazel/src/ssl/internal.h +272 -167
  183. data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +2 -2
  184. data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +2 -2
  185. data/third_party/boringssl-with-bazel/src/ssl/s3_pkt.cc +14 -19
  186. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +34 -102
  187. data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +2 -0
  188. data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +8 -31
  189. data/third_party/boringssl-with-bazel/src/ssl/ssl_stat.cc +3 -0
  190. data/third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc +4 -3
  191. data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +7 -3
  192. data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +576 -648
  193. data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +31 -3
  194. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +98 -39
  195. data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +141 -94
  196. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +58 -68
  197. metadata +65 -40
  198. data/third_party/boringssl-with-bazel/src/crypto/hpke/internal.h +0 -267
  199. data/third_party/boringssl-with-bazel/src/crypto/x509/vpm_int.h +0 -71
@@ -168,7 +168,7 @@ static bool add_record_to_flight(SSL *ssl, uint8_t type,
168
168
  return true;
169
169
  }
170
170
 
171
- bool tls_init_message(SSL *ssl, CBB *cbb, CBB *body, uint8_t type) {
171
+ bool tls_init_message(const SSL *ssl, CBB *cbb, CBB *body, uint8_t type) {
172
172
  // Pick a modest size hint to save most of the |realloc| calls.
173
173
  if (!CBB_init(cbb, 64) ||
174
174
  !CBB_add_u8(cbb, type) ||
@@ -181,7 +181,7 @@ bool tls_init_message(SSL *ssl, CBB *cbb, CBB *body, uint8_t type) {
181
181
  return true;
182
182
  }
183
183
 
184
- bool tls_finish_message(SSL *ssl, CBB *cbb, Array<uint8_t> *out_msg) {
184
+ bool tls_finish_message(const SSL *ssl, CBB *cbb, Array<uint8_t> *out_msg) {
185
185
  return CBBFinishArray(cbb, out_msg);
186
186
  }
187
187
 
@@ -164,7 +164,8 @@
164
164
  BSSL_NAMESPACE_BEGIN
165
165
 
166
166
  SSL3_STATE::SSL3_STATE()
167
- : skip_early_data(false),
167
+ : ech_accept(false),
168
+ skip_early_data(false),
168
169
  have_version(false),
169
170
  v2_hello_done(false),
170
171
  is_v2_hello(false),
@@ -177,7 +178,6 @@ SSL3_STATE::SSL3_STATE()
177
178
  key_update_pending(false),
178
179
  wpend_pending(false),
179
180
  early_data_accepted(false),
180
- token_binding_negotiated(false),
181
181
  alert_dispatch(false),
182
182
  renegotiate_pending(false),
183
183
  used_hello_retry_request(false) {}
@@ -112,6 +112,8 @@
112
112
  #include <limits.h>
113
113
  #include <string.h>
114
114
 
115
+ #include <algorithm>
116
+
115
117
  #include <openssl/err.h>
116
118
  #include <openssl/evp.h>
117
119
  #include <openssl/mem.h>
@@ -138,10 +140,9 @@ int tls_write_app_data(SSL *ssl, bool *out_needs_handshake, const uint8_t *in,
138
140
  return -1;
139
141
  }
140
142
 
141
- unsigned tot, n, nw;
142
-
143
+ // TODO(davidben): Switch this logic to |size_t| and |bssl::Span|.
143
144
  assert(ssl->s3->wnum <= INT_MAX);
144
- tot = ssl->s3->wnum;
145
+ unsigned tot = ssl->s3->wnum;
145
146
  ssl->s3->wnum = 0;
146
147
 
147
148
  // Ensure that if we end up with a smaller value of data to write out than
@@ -159,29 +160,23 @@ int tls_write_app_data(SSL *ssl, bool *out_needs_handshake, const uint8_t *in,
159
160
  const int is_early_data_write =
160
161
  !ssl->server && SSL_in_early_data(ssl) && ssl->s3->hs->can_early_write;
161
162
 
162
- n = len - tot;
163
+ unsigned n = len - tot;
163
164
  for (;;) {
164
- // max contains the maximum number of bytes that we can put into a record.
165
- unsigned max = ssl->max_send_fragment;
166
- if (is_early_data_write &&
167
- max > ssl->session->ticket_max_early_data -
168
- ssl->s3->hs->early_data_written) {
169
- max =
170
- ssl->session->ticket_max_early_data - ssl->s3->hs->early_data_written;
171
- if (max == 0) {
165
+ size_t max_send_fragment = ssl->max_send_fragment;
166
+ if (is_early_data_write) {
167
+ SSL_HANDSHAKE *hs = ssl->s3->hs.get();
168
+ if (hs->early_data_written >= hs->early_session->ticket_max_early_data) {
172
169
  ssl->s3->wnum = tot;
173
- ssl->s3->hs->can_early_write = false;
170
+ hs->can_early_write = false;
174
171
  *out_needs_handshake = true;
175
172
  return -1;
176
173
  }
174
+ max_send_fragment = std::min(
175
+ max_send_fragment, size_t{hs->early_session->ticket_max_early_data -
176
+ hs->early_data_written});
177
177
  }
178
178
 
179
- if (n > max) {
180
- nw = max;
181
- } else {
182
- nw = n;
183
- }
184
-
179
+ const size_t nw = std::min(max_send_fragment, size_t{n});
185
180
  int ret = do_tls_write(ssl, SSL3_RT_APPLICATION_DATA, &in[tot], nw);
186
181
  if (ret <= 0) {
187
182
  ssl->s3->wnum = tot;
@@ -275,9 +275,7 @@ ssl_open_record_t ssl_open_app_data(SSL *ssl, Span<uint8_t> *out,
275
275
  void ssl_update_cache(SSL_HANDSHAKE *hs, int mode) {
276
276
  SSL *const ssl = hs->ssl;
277
277
  SSL_CTX *ctx = ssl->session_ctx.get();
278
- // Never cache sessions with empty session IDs.
279
- if (ssl->s3->established_session->session_id_length == 0 ||
280
- ssl->s3->established_session->not_resumable ||
278
+ if (!SSL_SESSION_is_resumable(ssl->s3->established_session.get()) ||
281
279
  (ctx->session_cache_mode & mode) != mode) {
282
280
  return;
283
281
  }
@@ -463,7 +461,8 @@ static bool ssl_can_renegotiate(const SSL *ssl) {
463
461
  return false;
464
462
  }
465
463
 
466
- if (ssl_protocol_version(ssl) >= TLS1_3_VERSION) {
464
+ if (ssl->s3->have_version &&
465
+ ssl_protocol_version(ssl) >= TLS1_3_VERSION) {
467
466
  return false;
468
467
  }
469
468
 
@@ -563,6 +562,7 @@ ssl_ctx_st::ssl_ctx_st(const SSL_METHOD *ssl_method)
563
562
  signed_cert_timestamps_enabled(false),
564
563
  channel_id_enabled(false),
565
564
  grease_enabled(false),
565
+ permute_extensions(false),
566
566
  allow_unknown_alpn_protos(false),
567
567
  false_start_allowed_without_alpn(false),
568
568
  handoff(false),
@@ -685,6 +685,7 @@ SSL *SSL_new(SSL_CTX *ctx) {
685
685
  ssl->config->custom_verify_callback = ctx->custom_verify_callback;
686
686
  ssl->config->retain_only_sha256_of_client_certs =
687
687
  ctx->retain_only_sha256_of_client_certs;
688
+ ssl->config->permute_extensions = ctx->permute_extensions;
688
689
 
689
690
  if (!ssl->config->supported_group_list.CopyFrom(ctx->supported_group_list) ||
690
691
  !ssl->config->alpn_client_proto_list.CopyFrom(
@@ -731,7 +732,8 @@ SSL_CONFIG::SSL_CONFIG(SSL *ssl_arg)
731
732
  handoff(false),
732
733
  shed_handshake_config(false),
733
734
  jdk11_workaround(false),
734
- quic_use_legacy_codepoint(true) {
735
+ quic_use_legacy_codepoint(false),
736
+ permute_extensions(false) {
735
737
  assert(ssl);
736
738
  }
737
739
 
@@ -1099,11 +1101,6 @@ int SSL_write(SSL *ssl, const void *buf, int num) {
1099
1101
  return -1;
1100
1102
  }
1101
1103
 
1102
- if (ssl->s3->write_shutdown != ssl_shutdown_none) {
1103
- OPENSSL_PUT_ERROR(SSL, SSL_R_PROTOCOL_IS_SHUTDOWN);
1104
- return -1;
1105
- }
1106
-
1107
1104
  int ret = 0;
1108
1105
  bool needs_handshake = false;
1109
1106
  do {
@@ -1317,8 +1314,6 @@ const char *SSL_early_data_reason_string(enum ssl_early_data_reason_t reason) {
1317
1314
  return "alpn_mismatch";
1318
1315
  case ssl_early_data_channel_id:
1319
1316
  return "channel_id";
1320
- case ssl_early_data_token_binding:
1321
- return "token_binding";
1322
1317
  case ssl_early_data_ticket_age_skew:
1323
1318
  return "ticket_age_skew";
1324
1319
  case ssl_early_data_quic_parameter_mismatch:
@@ -1372,7 +1367,6 @@ int SSL_get_error(const SSL *ssl, int ret_code) {
1372
1367
  case SSL_ERROR_HANDOFF:
1373
1368
  case SSL_ERROR_HANDBACK:
1374
1369
  case SSL_ERROR_WANT_X509_LOOKUP:
1375
- case SSL_ERROR_WANT_CHANNEL_ID_LOOKUP:
1376
1370
  case SSL_ERROR_WANT_PRIVATE_KEY_OPERATION:
1377
1371
  case SSL_ERROR_PENDING_TICKET:
1378
1372
  case SSL_ERROR_EARLY_DATA_REJECTED:
@@ -1446,8 +1440,6 @@ const char *SSL_error_description(int err) {
1446
1440
  return "WANT_CONNECT";
1447
1441
  case SSL_ERROR_WANT_ACCEPT:
1448
1442
  return "WANT_ACCEPT";
1449
- case SSL_ERROR_WANT_CHANNEL_ID_LOOKUP:
1450
- return "WANT_CHANNEL_ID_LOOKUP";
1451
1443
  case SSL_ERROR_PENDING_SESSION:
1452
1444
  return "PENDING_SESSION";
1453
1445
  case SSL_ERROR_PENDING_CERTIFICATE:
@@ -1464,6 +1456,8 @@ const char *SSL_error_description(int err) {
1464
1456
  return "HANDOFF";
1465
1457
  case SSL_ERROR_HANDBACK:
1466
1458
  return "HANDBACK";
1459
+ case SSL_ERROR_WANT_RENEGOTIATE:
1460
+ return "WANT_RENEGOTIATE";
1467
1461
  case SSL_ERROR_HANDSHAKE_HINTS_READY:
1468
1462
  return "HANDSHAKE_HINTS_READY";
1469
1463
  default:
@@ -1471,13 +1465,6 @@ const char *SSL_error_description(int err) {
1471
1465
  }
1472
1466
  }
1473
1467
 
1474
- void SSL_set_enable_ech_grease(SSL *ssl, int enable) {
1475
- if (!ssl->config) {
1476
- return;
1477
- }
1478
- ssl->config->ech_grease_enabled = !!enable;
1479
- }
1480
-
1481
1468
  uint32_t SSL_CTX_set_options(SSL_CTX *ctx, uint32_t options) {
1482
1469
  ctx->options |= options;
1483
1470
  return ctx->options;
@@ -1788,6 +1775,9 @@ int SSL_renegotiate(SSL *ssl) {
1788
1775
  return 0;
1789
1776
  }
1790
1777
 
1778
+ // We should not have told the caller to release the private key.
1779
+ assert(!SSL_can_release_private_key(ssl));
1780
+
1791
1781
  // Renegotiation is only supported at quiescent points in the application
1792
1782
  // protocol, namely in HTTPS, just before reading the HTTP response.
1793
1783
  // Require the record-layer be idle and avoid complexities of sending a
@@ -2189,63 +2179,6 @@ int SSL_CTX_set_tlsext_servername_arg(SSL_CTX *ctx, void *arg) {
2189
2179
  return 1;
2190
2180
  }
2191
2181
 
2192
- SSL_ECH_SERVER_CONFIG_LIST *SSL_ECH_SERVER_CONFIG_LIST_new() {
2193
- return New<SSL_ECH_SERVER_CONFIG_LIST>();
2194
- }
2195
-
2196
- void SSL_ECH_SERVER_CONFIG_LIST_up_ref(SSL_ECH_SERVER_CONFIG_LIST *configs) {
2197
- CRYPTO_refcount_inc(&configs->references);
2198
- }
2199
-
2200
- void SSL_ECH_SERVER_CONFIG_LIST_free(SSL_ECH_SERVER_CONFIG_LIST *configs) {
2201
- if (configs == nullptr ||
2202
- !CRYPTO_refcount_dec_and_test_zero(&configs->references)) {
2203
- return;
2204
- }
2205
-
2206
- configs->~ssl_ech_server_config_list_st();
2207
- OPENSSL_free(configs);
2208
- }
2209
-
2210
- int SSL_ECH_SERVER_CONFIG_LIST_add(SSL_ECH_SERVER_CONFIG_LIST *configs,
2211
- int is_retry_config,
2212
- const uint8_t *ech_config,
2213
- size_t ech_config_len,
2214
- const uint8_t *private_key,
2215
- size_t private_key_len) {
2216
- ECHServerConfig parsed_config;
2217
- if (!parsed_config.Init(MakeConstSpan(ech_config, ech_config_len),
2218
- MakeConstSpan(private_key, private_key_len),
2219
- !!is_retry_config)) {
2220
- OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
2221
- return 0;
2222
- }
2223
- if (!configs->configs.Push(std::move(parsed_config))) {
2224
- OPENSSL_PUT_ERROR(SSL, ERR_R_MALLOC_FAILURE);
2225
- return 0;
2226
- }
2227
- return 1;
2228
- }
2229
-
2230
- int SSL_CTX_set1_ech_server_config_list(SSL_CTX *ctx,
2231
- SSL_ECH_SERVER_CONFIG_LIST *list) {
2232
- bool has_retry_config = false;
2233
- for (const bssl::ECHServerConfig &config : list->configs) {
2234
- if (config.is_retry_config()) {
2235
- has_retry_config = true;
2236
- break;
2237
- }
2238
- }
2239
- if (!has_retry_config) {
2240
- OPENSSL_PUT_ERROR(SSL, SSL_R_ECH_SERVER_WOULD_HAVE_NO_RETRY_CONFIGS);
2241
- return 0;
2242
- }
2243
- UniquePtr<SSL_ECH_SERVER_CONFIG_LIST> owned_list = UpRef(list);
2244
- MutexWriteLock lock(&ctx->lock);
2245
- ctx->ech_server_config_list.swap(owned_list);
2246
- return 1;
2247
- }
2248
-
2249
2182
  int SSL_select_next_proto(uint8_t **out, uint8_t *out_len, const uint8_t *peer,
2250
2183
  unsigned peer_len, const uint8_t *supported,
2251
2184
  unsigned supported_len) {
@@ -2432,8 +2365,6 @@ int SSL_CTX_set1_tls_channel_id(SSL_CTX *ctx, EVP_PKEY *private_key) {
2432
2365
  }
2433
2366
 
2434
2367
  ctx->channel_id_private = UpRef(private_key);
2435
- ctx->channel_id_enabled = true;
2436
-
2437
2368
  return 1;
2438
2369
  }
2439
2370
 
@@ -2447,8 +2378,6 @@ int SSL_set1_tls_channel_id(SSL *ssl, EVP_PKEY *private_key) {
2447
2378
  }
2448
2379
 
2449
2380
  ssl->config->channel_id_private = UpRef(private_key);
2450
- ssl->config->channel_id_enabled = true;
2451
-
2452
2381
  return 1;
2453
2382
  }
2454
2383
 
@@ -2460,25 +2389,6 @@ size_t SSL_get_tls_channel_id(SSL *ssl, uint8_t *out, size_t max_out) {
2460
2389
  return 64;
2461
2390
  }
2462
2391
 
2463
- int SSL_set_token_binding_params(SSL *ssl, const uint8_t *params, size_t len) {
2464
- if (!ssl->config) {
2465
- return 0;
2466
- }
2467
- if (len > 256) {
2468
- OPENSSL_PUT_ERROR(SSL, ERR_R_OVERFLOW);
2469
- return 0;
2470
- }
2471
- return ssl->config->token_binding_params.CopyFrom(MakeConstSpan(params, len));
2472
- }
2473
-
2474
- int SSL_is_token_binding_negotiated(const SSL *ssl) {
2475
- return ssl->s3->token_binding_negotiated;
2476
- }
2477
-
2478
- uint8_t SSL_get_negotiated_token_binding_param(const SSL *ssl) {
2479
- return ssl->s3->negotiated_token_binding_param;
2480
- }
2481
-
2482
2392
  size_t SSL_get0_certificate_types(const SSL *ssl, const uint8_t **out_types) {
2483
2393
  Span<const uint8_t> types;
2484
2394
  if (!ssl->server && ssl->s3->hs != nullptr) {
@@ -2840,6 +2750,17 @@ void SSL_CTX_set_current_time_cb(SSL_CTX *ctx,
2840
2750
  ctx->current_time_cb = cb;
2841
2751
  }
2842
2752
 
2753
+ int SSL_can_release_private_key(const SSL *ssl) {
2754
+ if (ssl_can_renegotiate(ssl)) {
2755
+ // If the connection can renegotiate (client only), the private key may be
2756
+ // used in a future handshake.
2757
+ return 0;
2758
+ }
2759
+
2760
+ // Otherwise, this is determined by the current handshake.
2761
+ return !ssl->s3->hs || ssl->s3->hs->can_release_private_key;
2762
+ }
2763
+
2843
2764
  int SSL_is_init_finished(const SSL *ssl) {
2844
2765
  return !SSL_in_init(ssl);
2845
2766
  }
@@ -2992,6 +2913,17 @@ void SSL_CTX_set_grease_enabled(SSL_CTX *ctx, int enabled) {
2992
2913
  ctx->grease_enabled = !!enabled;
2993
2914
  }
2994
2915
 
2916
+ void SSL_CTX_set_permute_extensions(SSL_CTX *ctx, int enabled) {
2917
+ ctx->permute_extensions = !!enabled;
2918
+ }
2919
+
2920
+ void SSL_set_permute_extensions(SSL *ssl, int enabled) {
2921
+ if (!ssl->config) {
2922
+ return;
2923
+ }
2924
+ ssl->config->permute_extensions = !!enabled;
2925
+ }
2926
+
2995
2927
  int32_t SSL_get_ticket_age_skew(const SSL *ssl) {
2996
2928
  return ssl->s3->ticket_age_skew;
2997
2929
  }
@@ -203,6 +203,7 @@ enum ssl_private_key_result_t ssl_private_key_sign(
203
203
  SSL *const ssl = hs->ssl;
204
204
  const SSL_PRIVATE_KEY_METHOD *key_method = hs->config->cert->key_method;
205
205
  EVP_PKEY *privatekey = hs->config->cert->privatekey.get();
206
+ assert(!hs->can_release_private_key);
206
207
  if (ssl_signing_with_dc(hs)) {
207
208
  key_method = hs->config->cert->dc_key_method;
208
209
  privatekey = hs->config->cert->dc_privatekey.get();
@@ -254,6 +255,7 @@ enum ssl_private_key_result_t ssl_private_key_decrypt(SSL_HANDSHAKE *hs,
254
255
  size_t max_out,
255
256
  Span<const uint8_t> in) {
256
257
  SSL *const ssl = hs->ssl;
258
+ assert(!hs->can_release_private_key);
257
259
  if (hs->config->cert->key_method != NULL) {
258
260
  enum ssl_private_key_result_t ret;
259
261
  if (hs->pending_private_key_op) {
@@ -350,19 +350,19 @@ const EVP_MD *ssl_session_get_digest(const SSL_SESSION *session) {
350
350
  session->cipher);
351
351
  }
352
352
 
353
- int ssl_get_new_session(SSL_HANDSHAKE *hs, int is_server) {
353
+ bool ssl_get_new_session(SSL_HANDSHAKE *hs) {
354
354
  SSL *const ssl = hs->ssl;
355
355
  if (ssl->mode & SSL_MODE_NO_SESSION_CREATION) {
356
356
  OPENSSL_PUT_ERROR(SSL, SSL_R_SESSION_MAY_NOT_BE_CREATED);
357
- return 0;
357
+ return false;
358
358
  }
359
359
 
360
360
  UniquePtr<SSL_SESSION> session = ssl_session_new(ssl->ctx->x509_method);
361
361
  if (session == NULL) {
362
- return 0;
362
+ return false;
363
363
  }
364
364
 
365
- session->is_server = is_server;
365
+ session->is_server = ssl->server;
366
366
  session->ssl_version = ssl->version;
367
367
  session->is_quic = ssl->quic_method != nullptr;
368
368
 
@@ -384,24 +384,9 @@ int ssl_get_new_session(SSL_HANDSHAKE *hs, int is_server) {
384
384
  session->auth_timeout = ssl->session_ctx->session_timeout;
385
385
  }
386
386
 
387
- if (is_server) {
388
- if (hs->ticket_expected || version >= TLS1_3_VERSION) {
389
- // Don't set session IDs for sessions resumed with tickets. This will keep
390
- // them out of the session cache.
391
- session->session_id_length = 0;
392
- } else {
393
- session->session_id_length = SSL3_SSL_SESSION_ID_LENGTH;
394
- if (!RAND_bytes(session->session_id, session->session_id_length)) {
395
- return 0;
396
- }
397
- }
398
- } else {
399
- session->session_id_length = 0;
400
- }
401
-
402
387
  if (hs->config->cert->sid_ctx_length > sizeof(session->sid_ctx)) {
403
388
  OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
404
- return 0;
389
+ return false;
405
390
  }
406
391
  OPENSSL_memcpy(session->sid_ctx, hs->config->cert->sid_ctx,
407
392
  hs->config->cert->sid_ctx_length);
@@ -413,7 +398,7 @@ int ssl_get_new_session(SSL_HANDSHAKE *hs, int is_server) {
413
398
 
414
399
  hs->new_session = std::move(session);
415
400
  ssl_set_session(ssl, NULL);
416
- return 1;
401
+ return true;
417
402
  }
418
403
 
419
404
  int ssl_ctx_rotate_ticket_encryption_key(SSL_CTX *ctx) {
@@ -1019,7 +1004,8 @@ int SSL_SESSION_should_be_single_use(const SSL_SESSION *session) {
1019
1004
  }
1020
1005
 
1021
1006
  int SSL_SESSION_is_resumable(const SSL_SESSION *session) {
1022
- return !session->not_resumable;
1007
+ return !session->not_resumable &&
1008
+ (session->session_id_length != 0 || !session->ticket.empty());
1023
1009
  }
1024
1010
 
1025
1011
  int SSL_SESSION_has_ticket(const SSL_SESSION *session) {
@@ -1298,12 +1284,3 @@ void (*SSL_CTX_get_info_callback(SSL_CTX *ctx))(const SSL *ssl, int type,
1298
1284
  int value) {
1299
1285
  return ctx->info_callback;
1300
1286
  }
1301
-
1302
- void SSL_CTX_set_channel_id_cb(SSL_CTX *ctx,
1303
- void (*cb)(SSL *ssl, EVP_PKEY **pkey)) {
1304
- ctx->channel_id_cb = cb;
1305
- }
1306
-
1307
- void (*SSL_CTX_get_channel_id_cb(SSL_CTX *ctx))(SSL *ssl, EVP_PKEY **pkey) {
1308
- return ctx->channel_id_cb;
1309
- }