grpc 1.55.0 → 1.56.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (395) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +102 -68
  3. data/include/grpc/event_engine/event_engine.h +4 -3
  4. data/include/grpc/grpc_audit_logging.h +96 -0
  5. data/include/grpc/grpc_security.h +19 -0
  6. data/include/grpc/module.modulemap +2 -0
  7. data/include/grpc/support/json.h +218 -0
  8. data/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +5 -0
  9. data/src/core/ext/filters/client_channel/backend_metric.cc +2 -0
  10. data/src/core/ext/filters/client_channel/channel_connectivity.cc +4 -4
  11. data/src/core/ext/filters/client_channel/client_channel.cc +86 -104
  12. data/src/core/ext/filters/client_channel/client_channel.h +6 -0
  13. data/src/core/ext/filters/client_channel/client_channel_channelz.cc +19 -18
  14. data/src/core/ext/filters/client_channel/client_channel_internal.h +16 -21
  15. data/src/core/ext/filters/client_channel/config_selector.h +9 -24
  16. data/src/core/ext/filters/client_channel/lb_policy/backend_metric_data.h +3 -0
  17. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +5 -4
  18. data/src/core/ext/filters/client_channel/lb_policy/health_check_client.cc +455 -0
  19. data/src/core/ext/filters/client_channel/lb_policy/health_check_client.h +54 -0
  20. data/src/core/ext/filters/client_channel/lb_policy/health_check_client_internal.h +186 -0
  21. data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.cc +2 -7
  22. data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.cc +53 -21
  23. data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h +23 -2
  24. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +19 -6
  25. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +1 -9
  26. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +16 -7
  27. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +18 -1
  28. data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +12 -9
  29. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +6 -4
  30. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +36 -13
  31. data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/static_stride_scheduler.cc +76 -6
  32. data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/weighted_round_robin.cc +42 -40
  33. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +4 -10
  34. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +52 -47
  35. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +1 -9
  36. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +14 -16
  37. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +40 -43
  38. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_override_host.cc +7 -12
  39. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_wrr_locality.cc +12 -19
  40. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +35 -33
  41. data/src/core/ext/filters/client_channel/resolver/dns/event_engine/event_engine_client_channel_resolver.cc +29 -4
  42. data/src/core/ext/filters/client_channel/resolver/dns/event_engine/service_config_helper.cc +1 -1
  43. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +28 -27
  44. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +163 -46
  45. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h +16 -1
  46. data/src/core/ext/filters/client_channel/retry_service_config.cc +1 -0
  47. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +10 -40
  48. data/src/core/ext/filters/client_channel/subchannel.cc +10 -196
  49. data/src/core/ext/filters/client_channel/subchannel.h +3 -43
  50. data/src/core/ext/filters/http/message_compress/compression_filter.cc +5 -5
  51. data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +100 -6
  52. data/src/core/ext/filters/server_config_selector/server_config_selector_filter.cc +6 -8
  53. data/src/core/ext/filters/stateful_session/stateful_session_filter.cc +3 -3
  54. data/src/core/ext/filters/stateful_session/stateful_session_filter.h +16 -1
  55. data/src/core/ext/transport/chttp2/transport/flow_control.cc +46 -95
  56. data/src/core/ext/transport/chttp2/transport/hpack_parse_result.cc +176 -0
  57. data/src/core/ext/transport/chttp2/transport/hpack_parse_result.h +325 -0
  58. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +567 -543
  59. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +150 -9
  60. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +46 -32
  61. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +18 -5
  62. data/src/core/ext/transport/chttp2/transport/internal.h +1 -15
  63. data/src/core/ext/transport/chttp2/transport/parsing.cc +12 -12
  64. data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.c +11 -2
  65. data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.h +15 -0
  66. data/src/core/ext/xds/certificate_provider_store.cc +4 -9
  67. data/src/core/ext/xds/certificate_provider_store.h +1 -1
  68. data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +30 -42
  69. data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +14 -9
  70. data/src/core/ext/xds/xds_api.cc +9 -6
  71. data/src/core/ext/xds/xds_api.h +3 -2
  72. data/src/core/ext/xds/xds_audit_logger_registry.cc +122 -0
  73. data/src/core/ext/xds/xds_audit_logger_registry.h +68 -0
  74. data/src/core/ext/xds/xds_bootstrap_grpc.cc +21 -9
  75. data/src/core/ext/xds/xds_bootstrap_grpc.h +5 -0
  76. data/src/core/ext/xds/xds_client.cc +5 -4
  77. data/src/core/ext/xds/xds_client_stats.h +1 -1
  78. data/src/core/ext/xds/xds_cluster.cc +20 -19
  79. data/src/core/ext/xds/xds_cluster_specifier_plugin.cc +11 -8
  80. data/src/core/ext/xds/xds_common_types.cc +3 -1
  81. data/src/core/ext/xds/xds_http_fault_filter.cc +16 -13
  82. data/src/core/ext/xds/xds_http_fault_filter.h +2 -1
  83. data/src/core/ext/xds/xds_http_filters.h +4 -2
  84. data/src/core/ext/xds/xds_http_rbac_filter.cc +154 -67
  85. data/src/core/ext/xds/xds_http_rbac_filter.h +2 -1
  86. data/src/core/ext/xds/xds_http_stateful_session_filter.cc +15 -11
  87. data/src/core/ext/xds/xds_http_stateful_session_filter.h +2 -1
  88. data/src/core/ext/xds/xds_lb_policy_registry.cc +22 -16
  89. data/src/core/ext/xds/xds_listener.cc +1 -0
  90. data/src/core/ext/xds/xds_route_config.cc +40 -3
  91. data/src/core/ext/xds/xds_routing.cc +2 -2
  92. data/src/core/ext/xds/xds_transport_grpc.cc +3 -1
  93. data/src/core/lib/avl/avl.h +5 -0
  94. data/src/core/lib/backoff/random_early_detection.h +5 -0
  95. data/src/core/lib/channel/channel_args.cc +80 -22
  96. data/src/core/lib/channel/channel_args.h +34 -1
  97. data/src/core/lib/channel/channel_trace.cc +16 -12
  98. data/src/core/lib/channel/channelz.cc +159 -132
  99. data/src/core/lib/channel/channelz.h +42 -35
  100. data/src/core/lib/channel/channelz_registry.cc +23 -20
  101. data/src/core/lib/channel/connected_channel.cc +17 -6
  102. data/src/core/lib/channel/promise_based_filter.cc +0 -4
  103. data/src/core/lib/channel/promise_based_filter.h +2 -0
  104. data/src/core/lib/compression/compression_internal.cc +2 -5
  105. data/src/core/lib/config/config_vars.cc +20 -18
  106. data/src/core/lib/config/config_vars.h +4 -4
  107. data/src/core/lib/config/load_config.cc +13 -0
  108. data/src/core/lib/config/load_config.h +6 -0
  109. data/src/core/lib/debug/event_log.h +1 -1
  110. data/src/core/lib/debug/stats_data.h +1 -1
  111. data/src/core/lib/debug/trace.cc +24 -55
  112. data/src/core/lib/debug/trace.h +3 -1
  113. data/src/core/lib/event_engine/cf_engine/cf_engine.cc +211 -0
  114. data/src/core/lib/event_engine/cf_engine/cf_engine.h +86 -0
  115. data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +354 -0
  116. data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.h +146 -0
  117. data/src/core/lib/event_engine/cf_engine/cftype_unique_ref.h +79 -0
  118. data/src/core/lib/event_engine/default_event_engine.cc +13 -1
  119. data/src/core/lib/event_engine/default_event_engine_factory.cc +14 -2
  120. data/src/core/lib/event_engine/poller.h +2 -2
  121. data/src/core/lib/event_engine/posix.h +4 -0
  122. data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +1 -1
  123. data/src/core/lib/event_engine/posix_engine/lockfree_event.cc +7 -18
  124. data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +9 -0
  125. data/src/core/lib/event_engine/posix_engine/posix_engine.cc +33 -19
  126. data/src/core/lib/event_engine/posix_engine/posix_engine.h +2 -1
  127. data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +33 -4
  128. data/src/core/lib/event_engine/posix_engine/posix_engine_listener.h +10 -8
  129. data/src/core/lib/event_engine/posix_engine/timer_manager.h +1 -1
  130. data/src/core/lib/event_engine/shim.cc +7 -1
  131. data/src/core/lib/event_engine/{thread_pool.cc → thread_pool/original_thread_pool.cc} +28 -25
  132. data/src/core/lib/event_engine/{thread_pool.h → thread_pool/original_thread_pool.h} +11 -15
  133. data/src/core/lib/event_engine/thread_pool/thread_pool.h +50 -0
  134. data/src/core/lib/event_engine/{executor/executor.h → thread_pool/thread_pool_factory.cc} +17 -15
  135. data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc +489 -0
  136. data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.h +249 -0
  137. data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.cc +166 -0
  138. data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.h +108 -0
  139. data/src/core/lib/event_engine/windows/iocp.cc +4 -3
  140. data/src/core/lib/event_engine/windows/iocp.h +3 -3
  141. data/src/core/lib/event_engine/windows/win_socket.cc +6 -6
  142. data/src/core/lib/event_engine/windows/win_socket.h +4 -4
  143. data/src/core/lib/event_engine/windows/windows_endpoint.cc +11 -10
  144. data/src/core/lib/event_engine/windows/windows_endpoint.h +3 -2
  145. data/src/core/lib/event_engine/windows/windows_engine.cc +19 -17
  146. data/src/core/lib/event_engine/windows/windows_engine.h +6 -6
  147. data/src/core/lib/event_engine/windows/windows_listener.cc +3 -3
  148. data/src/core/lib/event_engine/windows/windows_listener.h +3 -2
  149. data/src/core/lib/event_engine/work_queue/basic_work_queue.cc +63 -0
  150. data/src/core/lib/event_engine/work_queue/basic_work_queue.h +71 -0
  151. data/src/core/lib/event_engine/work_queue/work_queue.h +62 -0
  152. data/src/core/lib/experiments/config.cc +38 -7
  153. data/src/core/lib/experiments/config.h +16 -0
  154. data/src/core/lib/experiments/experiments.cc +67 -20
  155. data/src/core/lib/experiments/experiments.h +27 -21
  156. data/src/core/lib/gpr/log_internal.h +55 -0
  157. data/src/core/lib/gprpp/crash.cc +10 -0
  158. data/src/core/lib/gprpp/crash.h +3 -0
  159. data/src/core/lib/gprpp/per_cpu.cc +33 -0
  160. data/src/core/lib/gprpp/per_cpu.h +29 -6
  161. data/src/core/lib/gprpp/time.cc +1 -0
  162. data/src/core/lib/iomgr/cfstream_handle.cc +1 -1
  163. data/src/core/lib/iomgr/endpoint_cfstream.cc +10 -8
  164. data/src/core/lib/iomgr/ev_apple.cc +12 -12
  165. data/src/core/lib/iomgr/ev_epoll1_linux.cc +10 -3
  166. data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +15 -1
  167. data/src/core/lib/iomgr/iocp_windows.cc +24 -3
  168. data/src/core/lib/iomgr/iocp_windows.h +11 -0
  169. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +1 -1
  170. data/src/core/lib/iomgr/socket_utils_common_posix.cc +4 -2
  171. data/src/core/lib/iomgr/socket_windows.cc +61 -7
  172. data/src/core/lib/iomgr/socket_windows.h +9 -2
  173. data/src/core/lib/iomgr/tcp_client_cfstream.cc +14 -3
  174. data/src/core/lib/iomgr/tcp_server_posix.cc +182 -119
  175. data/src/core/lib/iomgr/tcp_server_utils_posix.h +13 -1
  176. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +21 -0
  177. data/src/core/lib/iomgr/tcp_server_windows.cc +1 -1
  178. data/src/core/lib/json/json.h +2 -166
  179. data/src/core/lib/json/json_object_loader.cc +8 -9
  180. data/src/core/lib/json/json_object_loader.h +25 -18
  181. data/src/core/lib/json/json_reader.cc +13 -6
  182. data/src/core/lib/json/json_util.cc +6 -11
  183. data/src/core/lib/json/json_writer.cc +7 -8
  184. data/src/core/lib/load_balancing/lb_policy.h +13 -0
  185. data/src/core/lib/load_balancing/lb_policy_registry.cc +2 -1
  186. data/src/core/lib/matchers/matchers.cc +3 -4
  187. data/src/core/lib/matchers/matchers.h +2 -1
  188. data/src/core/lib/promise/activity.cc +5 -0
  189. data/src/core/lib/promise/activity.h +10 -0
  190. data/src/core/lib/promise/detail/promise_factory.h +1 -1
  191. data/src/core/lib/promise/party.cc +31 -13
  192. data/src/core/lib/promise/party.h +11 -2
  193. data/src/core/lib/promise/pipe.h +9 -2
  194. data/src/core/lib/promise/prioritized_race.h +95 -0
  195. data/src/core/lib/promise/sleep.cc +2 -1
  196. data/src/core/lib/resolver/server_address.cc +0 -8
  197. data/src/core/lib/resolver/server_address.h +0 -6
  198. data/src/core/lib/resource_quota/memory_quota.cc +7 -7
  199. data/src/core/lib/resource_quota/memory_quota.h +1 -2
  200. data/src/core/lib/security/authorization/audit_logging.cc +98 -0
  201. data/src/core/lib/security/authorization/audit_logging.h +73 -0
  202. data/src/core/lib/security/authorization/grpc_authorization_engine.cc +47 -2
  203. data/src/core/lib/security/authorization/grpc_authorization_engine.h +18 -1
  204. data/src/core/lib/security/authorization/rbac_policy.cc +36 -4
  205. data/src/core/lib/security/authorization/rbac_policy.h +19 -2
  206. data/src/core/lib/security/authorization/stdout_logger.cc +75 -0
  207. data/src/core/lib/security/authorization/stdout_logger.h +61 -0
  208. data/src/core/lib/security/certificate_provider/certificate_provider_factory.h +8 -4
  209. data/src/core/lib/security/certificate_provider/certificate_provider_registry.cc +8 -18
  210. data/src/core/lib/security/certificate_provider/certificate_provider_registry.h +14 -8
  211. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +19 -12
  212. data/src/core/lib/security/credentials/external/external_account_credentials.cc +4 -2
  213. data/src/core/lib/security/credentials/external/file_external_account_credentials.cc +1 -0
  214. data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +1 -0
  215. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +1 -0
  216. data/src/core/lib/security/credentials/jwt/json_token.cc +15 -14
  217. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +4 -2
  218. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +1 -0
  219. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -0
  220. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +8 -0
  221. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +5 -1
  222. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +1 -5
  223. data/src/core/lib/security/security_connector/ssl_utils.cc +2 -1
  224. data/src/core/lib/security/security_connector/ssl_utils.h +1 -1
  225. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +1 -1
  226. data/src/core/lib/security/util/json_util.cc +1 -0
  227. data/src/core/lib/service_config/service_config_call_data.h +49 -20
  228. data/src/core/lib/service_config/service_config_impl.cc +2 -1
  229. data/src/core/lib/surface/call.cc +38 -23
  230. data/src/core/lib/surface/completion_queue.cc +6 -2
  231. data/src/core/lib/surface/validate_metadata.cc +37 -22
  232. data/src/core/lib/surface/validate_metadata.h +13 -3
  233. data/src/core/lib/surface/version.cc +2 -2
  234. data/src/core/lib/transport/batch_builder.cc +15 -12
  235. data/src/core/lib/transport/batch_builder.h +39 -35
  236. data/src/core/plugin_registry/grpc_plugin_registry.cc +0 -2
  237. data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +2 -0
  238. data/src/core/tsi/ssl_transport_security.cc +5 -2
  239. data/src/core/tsi/ssl_transport_security.h +13 -1
  240. data/src/ruby/ext/grpc/extconf.rb +8 -9
  241. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
  242. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +3 -0
  243. data/src/ruby/lib/grpc/version.rb +1 -1
  244. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_mbstr.c +9 -8
  245. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_strnid.c +1 -1
  246. data/third_party/boringssl-with-bazel/src/crypto/asn1/internal.h +3 -3
  247. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_dec.c +10 -6
  248. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +7 -4
  249. data/third_party/boringssl-with-bazel/src/crypto/bio/bio.c +6 -4
  250. data/third_party/boringssl-with-bazel/src/crypto/bio/fd.c +2 -1
  251. data/third_party/boringssl-with-bazel/src/crypto/bio/file.c +5 -9
  252. data/third_party/boringssl-with-bazel/src/crypto/bio/pair.c +4 -2
  253. data/third_party/boringssl-with-bazel/src/crypto/blake2/blake2.c +31 -22
  254. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_tls.c +29 -26
  255. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/internal.h +8 -0
  256. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/tls_cbc.c +189 -13
  257. data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_openbsd.c +62 -0
  258. data/third_party/boringssl-with-bazel/src/crypto/cpu_arm_openbsd.c +31 -0
  259. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +6 -4
  260. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519_tables.h +795 -795
  261. data/third_party/boringssl-with-bazel/src/crypto/curve25519/internal.h +1 -5
  262. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +4 -0
  263. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/hash_to_curve.c +18 -6
  264. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/internal.h +15 -7
  265. data/third_party/boringssl-with-bazel/src/crypto/ecdh_extra/ecdh_extra.c +1 -1
  266. data/third_party/boringssl-with-bazel/src/crypto/evp/p_rsa.c +1 -1
  267. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c +1 -0
  268. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/dh.c +3 -0
  269. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec.c +24 -24
  270. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_key.c +1 -1
  271. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_montgomery.c +7 -7
  272. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +74 -74
  273. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/oct.c +1 -2
  274. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p224-64.c +11 -11
  275. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-nistz.c +12 -12
  276. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256.c +14 -15
  277. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256_table.h +1 -1
  278. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple.c +10 -10
  279. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple_mul.c +23 -23
  280. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/wnaf.c +13 -13
  281. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdh/ecdh.c +1 -1
  282. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +2 -2
  283. data/third_party/boringssl-with-bazel/src/crypto/{hkdf → fipsmodule/hkdf}/hkdf.c +1 -1
  284. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cbc.c +2 -10
  285. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ctr.c +1 -4
  286. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm.c +115 -133
  287. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm_nohw.c +12 -14
  288. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/internal.h +57 -47
  289. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ofb.c +1 -8
  290. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/polyval.c +27 -28
  291. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +11 -23
  292. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/internal.h +21 -16
  293. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/padding.c +5 -288
  294. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +143 -83
  295. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +95 -183
  296. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +71 -0
  297. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/tls/internal.h +8 -0
  298. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/tls/kdf.c +33 -0
  299. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +162 -6
  300. data/third_party/boringssl-with-bazel/src/crypto/internal.h +18 -0
  301. data/third_party/boringssl-with-bazel/src/crypto/kyber/kyber.c +18 -11
  302. data/third_party/boringssl-with-bazel/src/crypto/obj/obj_dat.h +6 -13
  303. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_lib.c +18 -14
  304. data/third_party/boringssl-with-bazel/src/crypto/{refcount_lock.c → refcount_no_threads.c} +3 -13
  305. data/third_party/boringssl-with-bazel/src/crypto/refcount_win.c +89 -0
  306. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/internal.h +77 -0
  307. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_crypt.c +568 -0
  308. data/third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h +62 -0
  309. data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +218 -44
  310. data/third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.c +35 -0
  311. data/third_party/boringssl-with-bazel/src/crypto/trust_token/voprf.c +588 -39
  312. data/third_party/boringssl-with-bazel/src/crypto/x509/a_sign.c +27 -18
  313. data/third_party/boringssl-with-bazel/src/crypto/x509/asn1_gen.c +1 -1
  314. data/third_party/boringssl-with-bazel/src/crypto/x509/name_print.c +17 -39
  315. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509.c +39 -48
  316. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_att.c +0 -140
  317. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +72 -23
  318. data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +11 -14
  319. data/third_party/boringssl-with-bazel/src/crypto/x509/x509spki.c +1 -1
  320. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +2 -2
  321. data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +1 -1
  322. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_conf.c +33 -46
  323. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_cpols.c +1 -0
  324. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_info.c +3 -5
  325. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_lib.c +14 -46
  326. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_prn.c +14 -26
  327. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c +17 -10
  328. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +1 -1
  329. data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +5 -7
  330. data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +6 -4
  331. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +32 -1
  332. data/third_party/boringssl-with-bazel/src/include/openssl/bio.h +0 -4
  333. data/third_party/boringssl-with-bazel/src/include/openssl/blake2.h +1 -4
  334. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +3 -3
  335. data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +28 -0
  336. data/third_party/boringssl-with-bazel/src/include/openssl/nid.h +2 -11
  337. data/third_party/boringssl-with-bazel/src/include/openssl/pem.h +0 -3
  338. data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +91 -1
  339. data/third_party/boringssl-with-bazel/src/include/openssl/span.h +5 -0
  340. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +149 -20
  341. data/third_party/boringssl-with-bazel/src/include/openssl/thread.h +4 -0
  342. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +4 -0
  343. data/third_party/boringssl-with-bazel/src/include/openssl/trust_token.h +8 -0
  344. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +774 -615
  345. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +42 -10
  346. data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +11 -6
  347. data/third_party/boringssl-with-bazel/src/ssl/extensions.cc +2 -4
  348. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +24 -16
  349. data/third_party/boringssl-with-bazel/src/ssl/internal.h +65 -18
  350. data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +37 -18
  351. data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +187 -193
  352. data/third_party/boringssl-with-bazel/src/ssl/ssl_key_share.cc +13 -129
  353. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +85 -10
  354. data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +17 -4
  355. data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +27 -19
  356. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +1 -1
  357. data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +5 -21
  358. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +5 -2
  359. data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_64_msvc.h +1281 -0
  360. data/third_party/boringssl-with-bazel/src/third_party/fiat/p256_64_msvc.h +2002 -0
  361. data/third_party/cares/cares/include/ares.h +23 -1
  362. data/third_party/cares/cares/{src/lib → include}/ares_nameser.h +9 -7
  363. data/third_party/cares/cares/include/ares_rules.h +2 -2
  364. data/third_party/cares/cares/include/ares_version.h +3 -3
  365. data/third_party/cares/cares/src/lib/ares__addrinfo2hostent.c +266 -0
  366. data/third_party/cares/cares/src/lib/ares__addrinfo_localhost.c +240 -0
  367. data/third_party/cares/cares/src/lib/ares__parse_into_addrinfo.c +49 -80
  368. data/third_party/cares/cares/src/lib/ares__readaddrinfo.c +37 -43
  369. data/third_party/cares/cares/src/lib/ares__sortaddrinfo.c +12 -4
  370. data/third_party/cares/cares/src/lib/ares_data.c +16 -0
  371. data/third_party/cares/cares/src/lib/ares_data.h +7 -0
  372. data/third_party/cares/cares/src/lib/ares_destroy.c +8 -0
  373. data/third_party/cares/cares/src/lib/ares_expand_name.c +17 -6
  374. data/third_party/cares/cares/src/lib/ares_freeaddrinfo.c +1 -0
  375. data/third_party/cares/cares/src/lib/ares_getaddrinfo.c +156 -78
  376. data/third_party/cares/cares/src/lib/ares_gethostbyname.c +130 -326
  377. data/third_party/cares/cares/src/lib/ares_init.c +97 -485
  378. data/third_party/cares/cares/src/lib/ares_library_init.c +2 -89
  379. data/third_party/cares/cares/src/lib/ares_parse_a_reply.c +23 -142
  380. data/third_party/cares/cares/src/lib/ares_parse_aaaa_reply.c +22 -142
  381. data/third_party/cares/cares/src/lib/ares_parse_uri_reply.c +184 -0
  382. data/third_party/cares/cares/src/lib/ares_private.h +30 -16
  383. data/third_party/cares/cares/src/lib/ares_process.c +55 -16
  384. data/third_party/cares/cares/src/lib/ares_query.c +1 -35
  385. data/third_party/cares/cares/src/lib/ares_rand.c +279 -0
  386. data/third_party/cares/cares/src/lib/ares_send.c +5 -7
  387. data/third_party/cares/cares/src/lib/ares_strdup.c +12 -19
  388. data/third_party/cares/cares/src/lib/ares_strsplit.c +44 -128
  389. data/third_party/cares/cares/src/lib/ares_strsplit.h +9 -10
  390. data/third_party/cares/cares/src/lib/inet_net_pton.c +78 -116
  391. data/third_party/cares/cares/src/tools/ares_getopt.h +53 -0
  392. metadata +50 -12
  393. data/src/core/ext/filters/client_channel/health/health_check_client.cc +0 -175
  394. data/src/core/ext/filters/client_channel/health/health_check_client.h +0 -43
  395. data/third_party/cares/cares/src/lib/ares_library_init.h +0 -43
@@ -157,17 +157,6 @@ BSSL_NAMESPACE_BEGIN
157
157
 
158
158
  static constexpr SSL_CIPHER kCiphers[] = {
159
159
  // The RSA ciphers
160
- // Cipher 02
161
- {
162
- SSL3_TXT_RSA_NULL_SHA,
163
- "TLS_RSA_WITH_NULL_SHA",
164
- SSL3_CK_RSA_NULL_SHA,
165
- SSL_kRSA,
166
- SSL_aRSA,
167
- SSL_eNULL,
168
- SSL_SHA1,
169
- SSL_HANDSHAKE_MAC_DEFAULT,
170
- },
171
160
 
172
161
  // Cipher 0A
173
162
  {
@@ -346,6 +335,18 @@ static constexpr SSL_CIPHER kCiphers[] = {
346
335
  SSL_HANDSHAKE_MAC_DEFAULT,
347
336
  },
348
337
 
338
+ // Cipher C027
339
+ {
340
+ TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA256,
341
+ "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
342
+ TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA256,
343
+ SSL_kECDHE,
344
+ SSL_aRSA,
345
+ SSL_AES128,
346
+ SSL_SHA256,
347
+ SSL_HANDSHAKE_MAC_SHA256,
348
+ },
349
+
349
350
  // GCM based TLS v1.2 ciphersuites from RFC 5289
350
351
 
351
352
  // Cipher C02B
@@ -466,6 +467,16 @@ Span<const SSL_CIPHER> AllCiphers() {
466
467
  return MakeConstSpan(kCiphers, OPENSSL_ARRAY_SIZE(kCiphers));
467
468
  }
468
469
 
470
+ static constexpr size_t NumTLS13Ciphers() {
471
+ size_t num = 0;
472
+ for (const auto &cipher : kCiphers) {
473
+ if (cipher.algorithm_mkey == SSL_kGENERIC) {
474
+ num++;
475
+ }
476
+ }
477
+ return num;
478
+ }
479
+
469
480
  #define CIPHER_ADD 1
470
481
  #define CIPHER_KILL 2
471
482
  #define CIPHER_DEL 3
@@ -481,24 +492,26 @@ typedef struct cipher_order_st {
481
492
 
482
493
  typedef struct cipher_alias_st {
483
494
  // name is the name of the cipher alias.
484
- const char *name;
495
+ const char *name = nullptr;
485
496
 
486
497
  // The following fields are bitmasks for the corresponding fields on
487
498
  // |SSL_CIPHER|. A cipher matches a cipher alias iff, for each bitmask, the
488
499
  // bit corresponding to the cipher's value is set to 1. If any bitmask is
489
500
  // all zeroes, the alias matches nothing. Use |~0u| for the default value.
490
- uint32_t algorithm_mkey;
491
- uint32_t algorithm_auth;
492
- uint32_t algorithm_enc;
493
- uint32_t algorithm_mac;
501
+ uint32_t algorithm_mkey = ~0u;
502
+ uint32_t algorithm_auth = ~0u;
503
+ uint32_t algorithm_enc = ~0u;
504
+ uint32_t algorithm_mac = ~0u;
494
505
 
495
506
  // min_version, if non-zero, matches all ciphers which were added in that
496
507
  // particular protocol version.
497
- uint16_t min_version;
508
+ uint16_t min_version = 0;
509
+
510
+ // include_deprecated, if true, means this alias includes deprecated ciphers.
511
+ bool include_deprecated = false;
498
512
  } CIPHER_ALIAS;
499
513
 
500
514
  static const CIPHER_ALIAS kCipherAliases[] = {
501
- // "ALL" doesn't include eNULL. It must be explicitly enabled.
502
515
  {"ALL", ~0u, ~0u, ~0u, ~0u, 0},
503
516
 
504
517
  // The "COMPLEMENTOFDEFAULT" rule is omitted. It matches nothing.
@@ -599,9 +612,7 @@ bool ssl_cipher_get_evp_aead(const EVP_AEAD **out_aead,
599
612
  *out_fixed_iv_len = EVP_AEAD_nonce_length(*out_aead);
600
613
  }
601
614
  } else if (cipher->algorithm_mac == SSL_SHA1) {
602
- if (cipher->algorithm_enc == SSL_eNULL) {
603
- *out_aead = EVP_aead_null_sha1_tls();
604
- } else if (cipher->algorithm_enc == SSL_3DES) {
615
+ if (cipher->algorithm_enc == SSL_3DES) {
605
616
  if (version == TLS1_VERSION) {
606
617
  *out_aead = EVP_aead_des_ede3_cbc_sha1_tls_implicit_iv();
607
618
  *out_fixed_iv_len = 8;
@@ -627,6 +638,14 @@ bool ssl_cipher_get_evp_aead(const EVP_AEAD **out_aead,
627
638
  }
628
639
 
629
640
  *out_mac_secret_len = SHA_DIGEST_LENGTH;
641
+ } else if (cipher->algorithm_mac == SSL_SHA256) {
642
+ if (cipher->algorithm_enc == SSL_AES128) {
643
+ *out_aead = EVP_aead_aes_128_cbc_sha256_tls();
644
+ } else {
645
+ return false;
646
+ }
647
+
648
+ *out_mac_secret_len = SHA256_DIGEST_LENGTH;
630
649
  } else {
631
650
  return false;
632
651
  }
@@ -703,54 +722,6 @@ static void ll_append_head(CIPHER_ORDER **head, CIPHER_ORDER *curr,
703
722
  *head = curr;
704
723
  }
705
724
 
706
- static bool ssl_cipher_collect_ciphers(Array<CIPHER_ORDER> *out_co_list,
707
- CIPHER_ORDER **out_head,
708
- CIPHER_ORDER **out_tail) {
709
- Array<CIPHER_ORDER> co_list;
710
- if (!co_list.Init(OPENSSL_ARRAY_SIZE(kCiphers))) {
711
- return false;
712
- }
713
-
714
- size_t co_list_num = 0;
715
- for (const SSL_CIPHER &cipher : kCiphers) {
716
- // TLS 1.3 ciphers do not participate in this mechanism.
717
- if (cipher.algorithm_mkey != SSL_kGENERIC) {
718
- co_list[co_list_num].cipher = &cipher;
719
- co_list[co_list_num].next = NULL;
720
- co_list[co_list_num].prev = NULL;
721
- co_list[co_list_num].active = false;
722
- co_list[co_list_num].in_group = false;
723
- co_list_num++;
724
- }
725
- }
726
-
727
- // Prepare linked list from list entries.
728
- if (co_list_num > 0) {
729
- co_list[0].prev = NULL;
730
-
731
- if (co_list_num > 1) {
732
- co_list[0].next = &co_list[1];
733
-
734
- for (size_t i = 1; i < co_list_num - 1; i++) {
735
- co_list[i].prev = &co_list[i - 1];
736
- co_list[i].next = &co_list[i + 1];
737
- }
738
-
739
- co_list[co_list_num - 1].prev = &co_list[co_list_num - 2];
740
- }
741
-
742
- co_list[co_list_num - 1].next = NULL;
743
-
744
- *out_head = &co_list[0];
745
- *out_tail = &co_list[co_list_num - 1];
746
- } else {
747
- *out_head = nullptr;
748
- *out_tail = nullptr;
749
- }
750
- *out_co_list = std::move(co_list);
751
- return true;
752
- }
753
-
754
725
  SSLCipherPreferenceList::~SSLCipherPreferenceList() {
755
726
  OPENSSL_free(in_group_flags);
756
727
  }
@@ -797,6 +768,11 @@ void SSLCipherPreferenceList::Remove(const SSL_CIPHER *cipher) {
797
768
  sk_SSL_CIPHER_delete(ciphers.get(), index);
798
769
  }
799
770
 
771
+ bool ssl_cipher_is_deprecated(const SSL_CIPHER *cipher) {
772
+ // TODO(crbug.com/boringssl/599): Deprecate 3DES.
773
+ return cipher->id == TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA256;
774
+ }
775
+
800
776
  // ssl_cipher_apply_rule applies the rule type |rule| to ciphers matching its
801
777
  // parameters in the linked list from |*head_p| to |*tail_p|. It writes the new
802
778
  // head and tail of the list to |*head_p| and |*tail_p|, respectively.
@@ -804,19 +780,19 @@ void SSLCipherPreferenceList::Remove(const SSL_CIPHER *cipher) {
804
780
  // - If |cipher_id| is non-zero, only that cipher is selected.
805
781
  // - Otherwise, if |strength_bits| is non-negative, it selects ciphers
806
782
  // of that strength.
807
- // - Otherwise, it selects ciphers that match each bitmasks in |alg_*| and
808
- // |min_version|.
809
- static void ssl_cipher_apply_rule(
810
- uint32_t cipher_id, uint32_t alg_mkey, uint32_t alg_auth,
811
- uint32_t alg_enc, uint32_t alg_mac, uint16_t min_version, int rule,
812
- int strength_bits, bool in_group, CIPHER_ORDER **head_p,
813
- CIPHER_ORDER **tail_p) {
783
+ // - Otherwise, |alias| must be non-null. It selects ciphers that matches
784
+ // |*alias|.
785
+ static void ssl_cipher_apply_rule(uint32_t cipher_id, const CIPHER_ALIAS *alias,
786
+ int rule, int strength_bits, bool in_group,
787
+ CIPHER_ORDER **head_p,
788
+ CIPHER_ORDER **tail_p) {
814
789
  CIPHER_ORDER *head, *tail, *curr, *next, *last;
815
790
  const SSL_CIPHER *cp;
816
791
  bool reverse = false;
817
792
 
818
- if (cipher_id == 0 && strength_bits == -1 && min_version == 0 &&
819
- (alg_mkey == 0 || alg_auth == 0 || alg_enc == 0 || alg_mac == 0)) {
793
+ if (cipher_id == 0 && strength_bits == -1 && alias->min_version == 0 &&
794
+ (alias->algorithm_mkey == 0 || alias->algorithm_auth == 0 ||
795
+ alias->algorithm_enc == 0 || alias->algorithm_mac == 0)) {
820
796
  // The rule matches nothing, so bail early.
821
797
  return;
822
798
  }
@@ -862,13 +838,13 @@ static void ssl_cipher_apply_rule(
862
838
  continue;
863
839
  }
864
840
  } else {
865
- if (!(alg_mkey & cp->algorithm_mkey) ||
866
- !(alg_auth & cp->algorithm_auth) ||
867
- !(alg_enc & cp->algorithm_enc) ||
868
- !(alg_mac & cp->algorithm_mac) ||
869
- (min_version != 0 && SSL_CIPHER_get_min_version(cp) != min_version) ||
870
- // The NULL cipher must be selected explicitly.
871
- cp->algorithm_enc == SSL_eNULL) {
841
+ if (!(alias->algorithm_mkey & cp->algorithm_mkey) ||
842
+ !(alias->algorithm_auth & cp->algorithm_auth) ||
843
+ !(alias->algorithm_enc & cp->algorithm_enc) ||
844
+ !(alias->algorithm_mac & cp->algorithm_mac) ||
845
+ (alias->min_version != 0 &&
846
+ SSL_CIPHER_get_min_version(cp) != alias->min_version) ||
847
+ (!alias->include_deprecated && ssl_cipher_is_deprecated(cp))) {
872
848
  continue;
873
849
  }
874
850
  }
@@ -960,8 +936,8 @@ static bool ssl_cipher_strength_sort(CIPHER_ORDER **head_p,
960
936
  // Go through the list of used strength_bits values in descending order.
961
937
  for (int i = max_strength_bits; i >= 0; i--) {
962
938
  if (number_uses[i] > 0) {
963
- ssl_cipher_apply_rule(0, 0, 0, 0, 0, 0, CIPHER_ORD, i, false, head_p,
964
- tail_p);
939
+ ssl_cipher_apply_rule(/*cipher_id=*/0, /*alias=*/nullptr, CIPHER_ORD, i,
940
+ false, head_p, tail_p);
965
941
  }
966
942
  }
967
943
 
@@ -971,13 +947,9 @@ static bool ssl_cipher_strength_sort(CIPHER_ORDER **head_p,
971
947
  static bool ssl_cipher_process_rulestr(const char *rule_str,
972
948
  CIPHER_ORDER **head_p,
973
949
  CIPHER_ORDER **tail_p, bool strict) {
974
- uint32_t alg_mkey, alg_auth, alg_enc, alg_mac;
975
- uint16_t min_version;
976
950
  const char *l, *buf;
977
- int rule;
978
- bool multi, skip_rule, in_group = false, has_group = false;
951
+ bool in_group = false, has_group = false;
979
952
  size_t j, buf_len;
980
- uint32_t cipher_id;
981
953
  char ch;
982
954
 
983
955
  l = rule_str;
@@ -988,6 +960,7 @@ static bool ssl_cipher_process_rulestr(const char *rule_str,
988
960
  break; // done
989
961
  }
990
962
 
963
+ int rule;
991
964
  if (in_group) {
992
965
  if (ch == ']') {
993
966
  if (*tail_p) {
@@ -1042,14 +1015,13 @@ static bool ssl_cipher_process_rulestr(const char *rule_str,
1042
1015
  continue;
1043
1016
  }
1044
1017
 
1045
- multi = false;
1046
- cipher_id = 0;
1047
- alg_mkey = ~0u;
1048
- alg_auth = ~0u;
1049
- alg_enc = ~0u;
1050
- alg_mac = ~0u;
1051
- min_version = 0;
1052
- skip_rule = false;
1018
+ bool multi = false;
1019
+ uint32_t cipher_id = 0;
1020
+ CIPHER_ALIAS alias;
1021
+ bool skip_rule = false;
1022
+
1023
+ // When adding, exclude deprecated ciphers by default.
1024
+ alias.include_deprecated = rule != CIPHER_ADD;
1053
1025
 
1054
1026
  for (;;) {
1055
1027
  ch = *l;
@@ -1087,16 +1059,26 @@ static bool ssl_cipher_process_rulestr(const char *rule_str,
1087
1059
  // If not an exact cipher, look for a matching cipher alias.
1088
1060
  for (j = 0; j < kCipherAliasesLen; j++) {
1089
1061
  if (rule_equals(kCipherAliases[j].name, buf, buf_len)) {
1090
- alg_mkey &= kCipherAliases[j].algorithm_mkey;
1091
- alg_auth &= kCipherAliases[j].algorithm_auth;
1092
- alg_enc &= kCipherAliases[j].algorithm_enc;
1093
- alg_mac &= kCipherAliases[j].algorithm_mac;
1094
-
1095
- if (min_version != 0 &&
1096
- min_version != kCipherAliases[j].min_version) {
1062
+ alias.algorithm_mkey &= kCipherAliases[j].algorithm_mkey;
1063
+ alias.algorithm_auth &= kCipherAliases[j].algorithm_auth;
1064
+ alias.algorithm_enc &= kCipherAliases[j].algorithm_enc;
1065
+ alias.algorithm_mac &= kCipherAliases[j].algorithm_mac;
1066
+
1067
+ // When specifying a combination of aliases, if any aliases
1068
+ // enables deprecated ciphers, deprecated ciphers are included. This
1069
+ // is slightly different from the bitmasks in that adding aliases
1070
+ // can increase the set of matched ciphers. This is so that an alias
1071
+ // like "RSA" will only specifiy AES-based RSA ciphers, but
1072
+ // "RSA+3DES" will still specify 3DES.
1073
+ //
1074
+ // TODO(crbug.com/boringssl/599): Deprecate 3DES.
1075
+ alias.include_deprecated |= kCipherAliases[j].include_deprecated;
1076
+
1077
+ if (alias.min_version != 0 &&
1078
+ alias.min_version != kCipherAliases[j].min_version) {
1097
1079
  skip_rule = true;
1098
1080
  } else {
1099
- min_version = kCipherAliases[j].min_version;
1081
+ alias.min_version = kCipherAliases[j].min_version;
1100
1082
  }
1101
1083
  break;
1102
1084
  }
@@ -1134,8 +1116,8 @@ static bool ssl_cipher_process_rulestr(const char *rule_str,
1134
1116
  l++;
1135
1117
  }
1136
1118
  } else if (!skip_rule) {
1137
- ssl_cipher_apply_rule(cipher_id, alg_mkey, alg_auth, alg_enc, alg_mac,
1138
- min_version, rule, -1, in_group, head_p, tail_p);
1119
+ ssl_cipher_apply_rule(cipher_id, &alias, rule, -1, in_group, head_p,
1120
+ tail_p);
1139
1121
  }
1140
1122
  }
1141
1123
 
@@ -1148,73 +1130,87 @@ static bool ssl_cipher_process_rulestr(const char *rule_str,
1148
1130
  }
1149
1131
 
1150
1132
  bool ssl_create_cipher_list(UniquePtr<SSLCipherPreferenceList> *out_cipher_list,
1151
- const char *rule_str, bool strict) {
1133
+ const bool has_aes_hw, const char *rule_str,
1134
+ bool strict) {
1152
1135
  // Return with error if nothing to do.
1153
1136
  if (rule_str == NULL || out_cipher_list == NULL) {
1154
1137
  return false;
1155
1138
  }
1156
1139
 
1157
- // Now we have to collect the available ciphers from the compiled in ciphers.
1158
- // We cannot get more than the number compiled in, so it is used for
1159
- // allocation.
1160
- Array<CIPHER_ORDER> co_list;
1161
- CIPHER_ORDER *head = nullptr, *tail = nullptr;
1162
- if (!ssl_cipher_collect_ciphers(&co_list, &head, &tail)) {
1163
- return false;
1140
+ // We prefer ECDHE ciphers over non-PFS ciphers. Then we prefer AEAD over
1141
+ // non-AEAD. The constants are masked by 0xffff to remove the vestigial 0x03
1142
+ // byte from SSL 2.0.
1143
+ static const uint16_t kAESCiphers[] = {
1144
+ TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 & 0xffff,
1145
+ TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256 & 0xffff,
1146
+ TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 & 0xffff,
1147
+ TLS1_CK_ECDHE_RSA_WITH_AES_256_GCM_SHA384 & 0xffff,
1148
+ };
1149
+ static const uint16_t kChaChaCiphers[] = {
1150
+ TLS1_CK_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 & 0xffff,
1151
+ TLS1_CK_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 & 0xffff,
1152
+ TLS1_CK_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256 & 0xffff,
1153
+ };
1154
+ static const uint16_t kLegacyCiphers[] = {
1155
+ TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA & 0xffff,
1156
+ TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA & 0xffff,
1157
+ TLS1_CK_ECDHE_PSK_WITH_AES_128_CBC_SHA & 0xffff,
1158
+ TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA & 0xffff,
1159
+ TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA & 0xffff,
1160
+ TLS1_CK_ECDHE_PSK_WITH_AES_256_CBC_SHA & 0xffff,
1161
+ TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA256 & 0xffff,
1162
+ TLS1_CK_RSA_WITH_AES_128_GCM_SHA256 & 0xffff,
1163
+ TLS1_CK_RSA_WITH_AES_256_GCM_SHA384 & 0xffff,
1164
+ TLS1_CK_RSA_WITH_AES_128_SHA & 0xffff,
1165
+ TLS1_CK_PSK_WITH_AES_128_CBC_SHA & 0xffff,
1166
+ TLS1_CK_RSA_WITH_AES_256_SHA & 0xffff,
1167
+ TLS1_CK_PSK_WITH_AES_256_CBC_SHA & 0xffff,
1168
+ SSL3_CK_RSA_DES_192_CBC3_SHA & 0xffff,
1169
+ };
1170
+
1171
+ // Set up a linked list of ciphers.
1172
+ CIPHER_ORDER co_list[OPENSSL_ARRAY_SIZE(kAESCiphers) +
1173
+ OPENSSL_ARRAY_SIZE(kChaChaCiphers) +
1174
+ OPENSSL_ARRAY_SIZE(kLegacyCiphers)];
1175
+ for (size_t i = 0; i < OPENSSL_ARRAY_SIZE(co_list); i++) {
1176
+ co_list[i].next =
1177
+ i + 1 < OPENSSL_ARRAY_SIZE(co_list) ? &co_list[i + 1] : nullptr;
1178
+ co_list[i].prev = i == 0 ? nullptr : &co_list[i - 1];
1179
+ co_list[i].active = false;
1180
+ co_list[i].in_group = false;
1181
+ }
1182
+ CIPHER_ORDER *head = &co_list[0];
1183
+ CIPHER_ORDER *tail = &co_list[OPENSSL_ARRAY_SIZE(co_list) - 1];
1184
+
1185
+ // Order AES ciphers vs ChaCha ciphers based on whether we have AES hardware.
1186
+ //
1187
+ // TODO(crbug.com/boringssl/29): We should also set up equipreference groups
1188
+ // as a server.
1189
+ size_t num = 0;
1190
+ if (has_aes_hw) {
1191
+ for (uint16_t id : kAESCiphers) {
1192
+ co_list[num++].cipher = SSL_get_cipher_by_value(id);
1193
+ assert(co_list[num - 1].cipher != nullptr);
1194
+ }
1164
1195
  }
1165
-
1166
- // Now arrange all ciphers by preference:
1167
- // TODO(davidben): Compute this order once and copy it.
1168
-
1169
- // Everything else being equal, prefer ECDHE_ECDSA and ECDHE_RSA over other
1170
- // key exchange mechanisms
1171
- ssl_cipher_apply_rule(0, SSL_kECDHE, SSL_aECDSA, ~0u, ~0u, 0, CIPHER_ADD, -1,
1172
- false, &head, &tail);
1173
- ssl_cipher_apply_rule(0, SSL_kECDHE, ~0u, ~0u, ~0u, 0, CIPHER_ADD, -1, false,
1174
- &head, &tail);
1175
- ssl_cipher_apply_rule(0, ~0u, ~0u, ~0u, ~0u, 0, CIPHER_DEL, -1, false, &head,
1176
- &tail);
1177
-
1178
- // Order the bulk ciphers. First the preferred AEAD ciphers. We prefer
1179
- // CHACHA20 unless there is hardware support for fast and constant-time
1180
- // AES_GCM. Of the two CHACHA20 variants, the new one is preferred over the
1181
- // old one.
1182
- if (EVP_has_aes_hardware()) {
1183
- ssl_cipher_apply_rule(0, ~0u, ~0u, SSL_AES128GCM, ~0u, 0, CIPHER_ADD, -1,
1184
- false, &head, &tail);
1185
- ssl_cipher_apply_rule(0, ~0u, ~0u, SSL_AES256GCM, ~0u, 0, CIPHER_ADD, -1,
1186
- false, &head, &tail);
1187
- ssl_cipher_apply_rule(0, ~0u, ~0u, SSL_CHACHA20POLY1305, ~0u, 0, CIPHER_ADD,
1188
- -1, false, &head, &tail);
1189
- } else {
1190
- ssl_cipher_apply_rule(0, ~0u, ~0u, SSL_CHACHA20POLY1305, ~0u, 0, CIPHER_ADD,
1191
- -1, false, &head, &tail);
1192
- ssl_cipher_apply_rule(0, ~0u, ~0u, SSL_AES128GCM, ~0u, 0, CIPHER_ADD, -1,
1193
- false, &head, &tail);
1194
- ssl_cipher_apply_rule(0, ~0u, ~0u, SSL_AES256GCM, ~0u, 0, CIPHER_ADD, -1,
1195
- false, &head, &tail);
1196
- }
1197
-
1198
- // Then the legacy non-AEAD ciphers: AES_128_CBC, AES_256_CBC,
1199
- // 3DES_EDE_CBC_SHA.
1200
- ssl_cipher_apply_rule(0, ~0u, ~0u, SSL_AES128, ~0u, 0, CIPHER_ADD, -1, false,
1201
- &head, &tail);
1202
- ssl_cipher_apply_rule(0, ~0u, ~0u, SSL_AES256, ~0u, 0, CIPHER_ADD, -1, false,
1203
- &head, &tail);
1204
- ssl_cipher_apply_rule(0, ~0u, ~0u, SSL_3DES, ~0u, 0, CIPHER_ADD, -1, false,
1205
- &head, &tail);
1206
-
1207
- // Temporarily enable everything else for sorting
1208
- ssl_cipher_apply_rule(0, ~0u, ~0u, ~0u, ~0u, 0, CIPHER_ADD, -1, false, &head,
1209
- &tail);
1210
-
1211
- // Move ciphers without forward secrecy to the end.
1212
- ssl_cipher_apply_rule(0, (SSL_kRSA | SSL_kPSK), ~0u, ~0u, ~0u, 0, CIPHER_ORD,
1213
- -1, false, &head, &tail);
1214
-
1215
- // Now disable everything (maintaining the ordering!)
1216
- ssl_cipher_apply_rule(0, ~0u, ~0u, ~0u, ~0u, 0, CIPHER_DEL, -1, false, &head,
1217
- &tail);
1196
+ for (uint16_t id : kChaChaCiphers) {
1197
+ co_list[num++].cipher = SSL_get_cipher_by_value(id);
1198
+ assert(co_list[num - 1].cipher != nullptr);
1199
+ }
1200
+ if (!has_aes_hw) {
1201
+ for (uint16_t id : kAESCiphers) {
1202
+ co_list[num++].cipher = SSL_get_cipher_by_value(id);
1203
+ assert(co_list[num - 1].cipher != nullptr);
1204
+ }
1205
+ }
1206
+ for (uint16_t id : kLegacyCiphers) {
1207
+ co_list[num++].cipher = SSL_get_cipher_by_value(id);
1208
+ assert(co_list[num - 1].cipher != nullptr);
1209
+ }
1210
+ assert(num == OPENSSL_ARRAY_SIZE(co_list));
1211
+ static_assert(OPENSSL_ARRAY_SIZE(co_list) + NumTLS13Ciphers() ==
1212
+ OPENSSL_ARRAY_SIZE(kCiphers),
1213
+ "Not all ciphers are included in the cipher order");
1218
1214
 
1219
1215
  // If the rule_string begins with DEFAULT, apply the default rule before
1220
1216
  // using the (possibly available) additional rules.
@@ -1382,8 +1378,6 @@ int SSL_CIPHER_is_aead(const SSL_CIPHER *cipher) {
1382
1378
 
1383
1379
  int SSL_CIPHER_get_cipher_nid(const SSL_CIPHER *cipher) {
1384
1380
  switch (cipher->algorithm_enc) {
1385
- case SSL_eNULL:
1386
- return NID_undef;
1387
1381
  case SSL_3DES:
1388
1382
  return NID_des_ede3_cbc;
1389
1383
  case SSL_AES128:
@@ -1407,6 +1401,8 @@ int SSL_CIPHER_get_digest_nid(const SSL_CIPHER *cipher) {
1407
1401
  return NID_undef;
1408
1402
  case SSL_SHA1:
1409
1403
  return NID_sha1;
1404
+ case SSL_SHA256:
1405
+ return NID_sha256;
1410
1406
  }
1411
1407
  assert(0);
1412
1408
  return NID_undef;
@@ -1456,8 +1452,7 @@ int SSL_CIPHER_get_prf_nid(const SSL_CIPHER *cipher) {
1456
1452
  }
1457
1453
 
1458
1454
  int SSL_CIPHER_is_block_cipher(const SSL_CIPHER *cipher) {
1459
- return (cipher->algorithm_enc & SSL_eNULL) == 0 &&
1460
- cipher->algorithm_mac != SSL_AEAD;
1455
+ return cipher->algorithm_mac != SSL_AEAD;
1461
1456
  }
1462
1457
 
1463
1458
  uint16_t SSL_CIPHER_get_min_version(const SSL_CIPHER *cipher) {
@@ -1482,13 +1477,15 @@ uint16_t SSL_CIPHER_get_max_version(const SSL_CIPHER *cipher) {
1482
1477
  return TLS1_2_VERSION;
1483
1478
  }
1484
1479
 
1480
+ static const char* kUnknownCipher = "(NONE)";
1481
+
1485
1482
  // return the actual cipher being used
1486
1483
  const char *SSL_CIPHER_get_name(const SSL_CIPHER *cipher) {
1487
1484
  if (cipher != NULL) {
1488
1485
  return cipher->name;
1489
1486
  }
1490
1487
 
1491
- return "(NONE)";
1488
+ return kUnknownCipher;
1492
1489
  }
1493
1490
 
1494
1491
  const char *SSL_CIPHER_standard_name(const SSL_CIPHER *cipher) {
@@ -1531,14 +1528,6 @@ const char *SSL_CIPHER_get_kx_name(const SSL_CIPHER *cipher) {
1531
1528
  }
1532
1529
  }
1533
1530
 
1534
- char *SSL_CIPHER_get_rfc_name(const SSL_CIPHER *cipher) {
1535
- if (cipher == NULL) {
1536
- return NULL;
1537
- }
1538
-
1539
- return OPENSSL_strdup(SSL_CIPHER_standard_name(cipher));
1540
- }
1541
-
1542
1531
  int SSL_CIPHER_get_bits(const SSL_CIPHER *cipher, int *out_alg_bits) {
1543
1532
  if (cipher == NULL) {
1544
1533
  return 0;
@@ -1564,11 +1553,6 @@ int SSL_CIPHER_get_bits(const SSL_CIPHER *cipher, int *out_alg_bits) {
1564
1553
  strength_bits = 112;
1565
1554
  break;
1566
1555
 
1567
- case SSL_eNULL:
1568
- alg_bits = 0;
1569
- strength_bits = 0;
1570
- break;
1571
-
1572
1556
  default:
1573
1557
  assert(0);
1574
1558
  alg_bits = 0;
@@ -1659,10 +1643,6 @@ const char *SSL_CIPHER_description(const SSL_CIPHER *cipher, char *buf,
1659
1643
  enc = "ChaCha20-Poly1305";
1660
1644
  break;
1661
1645
 
1662
- case SSL_eNULL:
1663
- enc="None";
1664
- break;
1665
-
1666
1646
  default:
1667
1647
  enc = "unknown";
1668
1648
  break;
@@ -1673,6 +1653,10 @@ const char *SSL_CIPHER_description(const SSL_CIPHER *cipher, char *buf,
1673
1653
  mac = "SHA1";
1674
1654
  break;
1675
1655
 
1656
+ case SSL_SHA256:
1657
+ mac = "SHA256";
1658
+ break;
1659
+
1676
1660
  case SSL_AEAD:
1677
1661
  mac = "AEAD";
1678
1662
  break;
@@ -1712,3 +1696,13 @@ const char *SSL_COMP_get0_name(const SSL_COMP *comp) { return comp->name; }
1712
1696
  int SSL_COMP_get_id(const SSL_COMP *comp) { return comp->id; }
1713
1697
 
1714
1698
  void SSL_COMP_free_compression_methods(void) {}
1699
+
1700
+ size_t SSL_get_all_cipher_names(const char **out, size_t max_out) {
1701
+ return GetAllNames(out, max_out, MakeConstSpan(&kUnknownCipher, 1),
1702
+ &SSL_CIPHER::name, MakeConstSpan(kCiphers));
1703
+ }
1704
+
1705
+ size_t SSL_get_all_standard_cipher_names(const char **out, size_t max_out) {
1706
+ return GetAllNames(out, max_out, Span<const char *>(),
1707
+ &SSL_CIPHER::standard_name, MakeConstSpan(kCiphers));
1708
+ }