grpc 1.37.1 → 1.38.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 (544) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +64 -58
  3. data/include/grpc/event_engine/README.md +38 -0
  4. data/include/grpc/event_engine/channel_args.h +28 -0
  5. data/include/grpc/event_engine/event_engine.h +336 -0
  6. data/include/grpc/event_engine/port.h +39 -0
  7. data/include/grpc/event_engine/slice_allocator.h +81 -0
  8. data/include/grpc/grpc.h +2 -2
  9. data/include/grpc/grpc_security_constants.h +14 -0
  10. data/include/grpc/impl/codegen/grpc_types.h +11 -0
  11. data/include/grpc/impl/codegen/port_platform.h +5 -0
  12. data/include/grpc/module.modulemap +14 -14
  13. data/src/core/ext/filters/client_channel/backup_poller.cc +3 -3
  14. data/src/core/ext/filters/client_channel/channel_connectivity.cc +177 -202
  15. data/src/core/ext/filters/client_channel/client_channel.cc +628 -3101
  16. data/src/core/ext/filters/client_channel/client_channel.h +489 -55
  17. data/src/core/ext/filters/client_channel/client_channel_channelz.h +1 -1
  18. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +4 -1
  19. data/src/core/ext/filters/client_channel/config_selector.h +1 -1
  20. data/src/core/ext/filters/client_channel/connector.h +1 -1
  21. data/src/core/ext/filters/client_channel/dynamic_filters.cc +9 -10
  22. data/src/core/ext/filters/client_channel/dynamic_filters.h +3 -3
  23. data/src/core/ext/filters/client_channel/health/health_check_client.cc +26 -27
  24. data/src/core/ext/filters/client_channel/health/health_check_client.h +27 -26
  25. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +24 -21
  26. data/src/core/ext/filters/client_channel/lb_policy.cc +1 -1
  27. data/src/core/ext/filters/client_channel/lb_policy.h +4 -4
  28. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +6 -6
  29. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +46 -43
  30. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +1 -1
  31. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +2 -1
  32. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +5 -5
  33. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +14 -12
  34. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +4 -4
  35. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +1 -1
  36. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +15 -15
  37. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +36 -30
  38. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +23 -23
  39. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +31 -46
  40. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +84 -61
  41. data/src/core/ext/filters/client_channel/lb_policy_factory.h +1 -1
  42. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +4 -4
  43. data/src/core/ext/filters/client_channel/lb_policy_registry.h +1 -1
  44. data/src/core/ext/filters/client_channel/resolver.h +2 -2
  45. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +23 -15
  46. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +1 -1
  47. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +3 -3
  48. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +2 -2
  49. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +14 -14
  50. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +33 -24
  51. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +1 -1
  52. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +1 -1
  53. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +1 -1
  54. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +17 -9
  55. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +20 -28
  56. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +7 -5
  57. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +13 -11
  58. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +1 -1
  59. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +43 -28
  60. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +32 -239
  61. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +20 -49
  62. data/src/core/ext/filters/client_channel/retry_filter.cc +2188 -0
  63. data/src/core/ext/filters/client_channel/retry_filter.h +30 -0
  64. data/src/core/ext/filters/client_channel/retry_service_config.cc +287 -0
  65. data/src/core/ext/filters/client_channel/retry_service_config.h +90 -0
  66. data/src/core/ext/filters/client_channel/server_address.cc +1 -1
  67. data/src/core/ext/filters/client_channel/service_config.cc +15 -14
  68. data/src/core/ext/filters/client_channel/service_config.h +7 -6
  69. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +5 -4
  70. data/src/core/ext/filters/client_channel/service_config_parser.cc +6 -6
  71. data/src/core/ext/filters/client_channel/service_config_parser.h +7 -4
  72. data/src/core/ext/filters/client_channel/subchannel.cc +17 -16
  73. data/src/core/ext/filters/client_channel/subchannel.h +7 -6
  74. data/src/core/ext/filters/client_idle/client_idle_filter.cc +16 -15
  75. data/src/core/ext/filters/deadline/deadline_filter.cc +10 -10
  76. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +19 -18
  77. data/src/core/ext/filters/fault_injection/service_config_parser.cc +5 -5
  78. data/src/core/ext/filters/fault_injection/service_config_parser.h +1 -1
  79. data/src/core/ext/filters/http/client/http_client_filter.cc +28 -21
  80. data/src/core/ext/filters/http/client_authority_filter.cc +3 -3
  81. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +23 -22
  82. data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +21 -21
  83. data/src/core/ext/filters/http/server/http_server_filter.cc +27 -23
  84. data/src/core/ext/filters/max_age/max_age_filter.cc +12 -10
  85. data/src/core/ext/filters/message_size/message_size_filter.cc +14 -11
  86. data/src/core/ext/filters/message_size/message_size_filter.h +1 -1
  87. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +4 -3
  88. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +7 -7
  89. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +7 -7
  90. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +2 -2
  91. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +1 -1
  92. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +3 -3
  93. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +44 -45
  94. data/src/core/ext/transport/chttp2/server/chttp2_server.h +2 -2
  95. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +3 -4
  96. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +2 -2
  97. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +3 -4
  98. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +129 -116
  99. data/src/core/ext/transport/chttp2/transport/context_list.cc +4 -5
  100. data/src/core/ext/transport/chttp2/transport/context_list.h +4 -4
  101. data/src/core/ext/transport/chttp2/transport/flow_control.cc +3 -3
  102. data/src/core/ext/transport/chttp2/transport/flow_control.h +8 -8
  103. data/src/core/ext/transport/chttp2/transport/frame_data.cc +8 -8
  104. data/src/core/ext/transport/chttp2/transport/frame_data.h +10 -10
  105. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +7 -8
  106. data/src/core/ext/transport/chttp2/transport/frame_goaway.h +6 -6
  107. data/src/core/ext/transport/chttp2/transport/frame_ping.cc +7 -8
  108. data/src/core/ext/transport/chttp2/transport/frame_ping.h +7 -6
  109. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +7 -7
  110. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +6 -6
  111. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +6 -5
  112. data/src/core/ext/transport/chttp2/transport/frame_settings.h +6 -6
  113. data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +4 -6
  114. data/src/core/ext/transport/chttp2/transport/frame_window_update.h +4 -6
  115. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +237 -208
  116. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +10 -10
  117. data/src/core/ext/transport/chttp2/transport/hpack_table.cc +4 -3
  118. data/src/core/ext/transport/chttp2/transport/hpack_table.h +4 -4
  119. data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +2 -2
  120. data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +2 -2
  121. data/src/core/ext/transport/chttp2/transport/internal.h +31 -27
  122. data/src/core/ext/transport/chttp2/transport/parsing.cc +63 -56
  123. data/src/core/ext/transport/chttp2/transport/writing.cc +7 -3
  124. data/src/core/ext/transport/inproc/inproc_transport.cc +30 -29
  125. data/src/core/ext/xds/certificate_provider_factory.h +1 -1
  126. data/src/core/ext/xds/certificate_provider_store.h +3 -3
  127. data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +3 -3
  128. data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +2 -2
  129. data/src/core/ext/xds/xds_api.cc +101 -93
  130. data/src/core/ext/xds/xds_api.h +6 -6
  131. data/src/core/ext/xds/xds_bootstrap.cc +97 -159
  132. data/src/core/ext/xds/xds_bootstrap.h +19 -24
  133. data/src/core/ext/xds/xds_certificate_provider.cc +4 -4
  134. data/src/core/ext/xds/xds_certificate_provider.h +4 -4
  135. data/src/core/ext/xds/xds_channel_args.h +5 -2
  136. data/src/core/ext/xds/xds_client.cc +310 -178
  137. data/src/core/ext/xds/xds_client.h +41 -27
  138. data/src/core/ext/xds/xds_client_stats.h +3 -2
  139. data/src/core/ext/xds/xds_server_config_fetcher.cc +34 -20
  140. data/src/core/lib/{iomgr → address_utils}/parse_address.cc +17 -17
  141. data/src/core/lib/{iomgr → address_utils}/parse_address.h +7 -7
  142. data/src/core/lib/{iomgr → address_utils}/sockaddr_utils.cc +3 -20
  143. data/src/core/lib/{iomgr → address_utils}/sockaddr_utils.h +6 -11
  144. data/src/core/lib/channel/channel_stack.cc +10 -9
  145. data/src/core/lib/channel/channel_stack.h +10 -9
  146. data/src/core/lib/channel/channel_stack_builder.cc +2 -2
  147. data/src/core/lib/channel/channel_stack_builder.h +1 -1
  148. data/src/core/lib/channel/channelz.cc +21 -13
  149. data/src/core/lib/channel/connected_channel.cc +4 -4
  150. data/src/core/lib/channel/handshaker.cc +7 -6
  151. data/src/core/lib/channel/handshaker.h +5 -5
  152. data/src/core/lib/event_engine/slice_allocator.cc +59 -0
  153. data/src/core/lib/event_engine/sockaddr.cc +38 -0
  154. data/src/core/lib/gprpp/ref_counted.h +28 -14
  155. data/src/core/lib/gprpp/status_helper.cc +407 -0
  156. data/src/core/lib/gprpp/status_helper.h +180 -0
  157. data/src/core/lib/http/httpcli.cc +11 -11
  158. data/src/core/lib/http/httpcli_security_connector.cc +11 -7
  159. data/src/core/lib/http/parser.cc +16 -16
  160. data/src/core/lib/http/parser.h +4 -4
  161. data/src/core/lib/iomgr/buffer_list.cc +7 -9
  162. data/src/core/lib/iomgr/buffer_list.h +4 -5
  163. data/src/core/lib/iomgr/call_combiner.cc +15 -12
  164. data/src/core/lib/iomgr/call_combiner.h +12 -14
  165. data/src/core/lib/iomgr/cfstream_handle.cc +3 -3
  166. data/src/core/lib/iomgr/cfstream_handle.h +1 -1
  167. data/src/core/lib/iomgr/closure.h +7 -6
  168. data/src/core/lib/iomgr/combiner.cc +14 -12
  169. data/src/core/lib/iomgr/combiner.h +2 -2
  170. data/src/core/lib/iomgr/endpoint.cc +1 -1
  171. data/src/core/lib/iomgr/endpoint.h +2 -2
  172. data/src/core/lib/iomgr/endpoint_cfstream.cc +11 -13
  173. data/src/core/lib/iomgr/endpoint_pair_windows.cc +1 -1
  174. data/src/core/lib/iomgr/error.cc +167 -61
  175. data/src/core/lib/iomgr/error.h +217 -106
  176. data/src/core/lib/iomgr/error_cfstream.cc +3 -2
  177. data/src/core/lib/iomgr/error_cfstream.h +2 -2
  178. data/src/core/lib/iomgr/error_internal.h +5 -1
  179. data/src/core/lib/iomgr/ev_apple.cc +5 -5
  180. data/src/core/lib/iomgr/ev_epoll1_linux.cc +19 -19
  181. data/src/core/lib/iomgr/ev_epollex_linux.cc +48 -45
  182. data/src/core/lib/iomgr/ev_poll_posix.cc +26 -23
  183. data/src/core/lib/iomgr/ev_posix.cc +9 -8
  184. data/src/core/lib/iomgr/ev_posix.h +9 -9
  185. data/src/core/lib/iomgr/exec_ctx.cc +4 -4
  186. data/src/core/lib/iomgr/exec_ctx.h +1 -1
  187. data/src/core/lib/iomgr/executor.cc +8 -8
  188. data/src/core/lib/iomgr/executor.h +2 -2
  189. data/src/core/lib/iomgr/iomgr.cc +1 -1
  190. data/src/core/lib/iomgr/iomgr.h +1 -1
  191. data/src/core/lib/iomgr/iomgr_custom.cc +1 -1
  192. data/src/core/lib/iomgr/iomgr_internal.cc +2 -2
  193. data/src/core/lib/iomgr/iomgr_internal.h +3 -3
  194. data/src/core/lib/iomgr/iomgr_posix.cc +1 -1
  195. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +2 -2
  196. data/src/core/lib/iomgr/iomgr_windows.cc +1 -1
  197. data/src/core/lib/iomgr/load_file.cc +4 -4
  198. data/src/core/lib/iomgr/load_file.h +2 -2
  199. data/src/core/lib/iomgr/lockfree_event.cc +5 -5
  200. data/src/core/lib/iomgr/lockfree_event.h +1 -1
  201. data/src/core/lib/iomgr/pollset.cc +5 -5
  202. data/src/core/lib/iomgr/pollset.h +9 -9
  203. data/src/core/lib/iomgr/pollset_custom.cc +5 -5
  204. data/src/core/lib/iomgr/pollset_windows.cc +5 -5
  205. data/src/core/lib/iomgr/port.h +1 -1
  206. data/src/core/lib/iomgr/python_util.h +1 -1
  207. data/src/core/lib/iomgr/resolve_address.cc +3 -3
  208. data/src/core/lib/iomgr/resolve_address.h +6 -6
  209. data/src/core/lib/iomgr/resolve_address_custom.cc +10 -9
  210. data/src/core/lib/iomgr/resolve_address_custom.h +3 -3
  211. data/src/core/lib/iomgr/resolve_address_posix.cc +3 -3
  212. data/src/core/lib/iomgr/resolve_address_windows.cc +4 -4
  213. data/src/core/lib/iomgr/resource_quota.cc +11 -10
  214. data/src/core/lib/iomgr/socket_utils_common_posix.cc +22 -20
  215. data/src/core/lib/iomgr/socket_utils_posix.h +20 -20
  216. data/src/core/lib/iomgr/tcp_client_cfstream.cc +4 -4
  217. data/src/core/lib/iomgr/tcp_client_custom.cc +5 -6
  218. data/src/core/lib/iomgr/tcp_client_posix.cc +15 -17
  219. data/src/core/lib/iomgr/tcp_client_posix.h +3 -4
  220. data/src/core/lib/iomgr/tcp_client_windows.cc +5 -5
  221. data/src/core/lib/iomgr/tcp_custom.cc +14 -16
  222. data/src/core/lib/iomgr/tcp_custom.h +13 -12
  223. data/src/core/lib/iomgr/tcp_posix.cc +36 -34
  224. data/src/core/lib/iomgr/tcp_server.cc +6 -6
  225. data/src/core/lib/iomgr/tcp_server.h +12 -11
  226. data/src/core/lib/iomgr/tcp_server_custom.cc +23 -21
  227. data/src/core/lib/iomgr/tcp_server_posix.cc +22 -21
  228. data/src/core/lib/iomgr/tcp_server_utils_posix.h +13 -12
  229. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +19 -17
  230. data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +9 -9
  231. data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc +4 -4
  232. data/src/core/lib/iomgr/tcp_server_windows.cc +26 -25
  233. data/src/core/lib/iomgr/tcp_uv.cc +25 -23
  234. data/src/core/lib/iomgr/tcp_windows.cc +13 -13
  235. data/src/core/lib/iomgr/tcp_windows.h +2 -2
  236. data/src/core/lib/iomgr/timer_custom.cc +2 -1
  237. data/src/core/lib/iomgr/timer_custom.h +1 -1
  238. data/src/core/lib/iomgr/timer_generic.cc +6 -6
  239. data/src/core/lib/iomgr/udp_server.cc +21 -20
  240. data/src/core/lib/iomgr/unix_sockets_posix.cc +3 -3
  241. data/src/core/lib/iomgr/unix_sockets_posix.h +2 -2
  242. data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +10 -7
  243. data/src/core/lib/iomgr/wakeup_fd_eventfd.cc +3 -3
  244. data/src/core/lib/iomgr/wakeup_fd_pipe.cc +4 -4
  245. data/src/core/lib/iomgr/wakeup_fd_posix.cc +3 -3
  246. data/src/core/lib/iomgr/wakeup_fd_posix.h +8 -6
  247. data/src/core/lib/iomgr/work_serializer.h +17 -1
  248. data/src/core/lib/json/json.h +1 -1
  249. data/src/core/lib/json/json_reader.cc +4 -4
  250. data/src/core/lib/matchers/matchers.cc +39 -39
  251. data/src/core/lib/matchers/matchers.h +28 -28
  252. data/src/core/lib/security/credentials/composite/composite_credentials.cc +4 -4
  253. data/src/core/lib/security/credentials/composite/composite_credentials.h +2 -2
  254. data/src/core/lib/security/credentials/credentials.h +2 -2
  255. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +17 -13
  256. data/src/core/lib/security/credentials/external/aws_external_account_credentials.h +13 -11
  257. data/src/core/lib/security/credentials/external/aws_request_signer.cc +2 -1
  258. data/src/core/lib/security/credentials/external/aws_request_signer.h +1 -1
  259. data/src/core/lib/security/credentials/external/external_account_credentials.cc +15 -12
  260. data/src/core/lib/security/credentials/external/external_account_credentials.h +9 -8
  261. data/src/core/lib/security/credentials/external/file_external_account_credentials.cc +5 -4
  262. data/src/core/lib/security/credentials/external/file_external_account_credentials.h +4 -3
  263. data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +8 -8
  264. data/src/core/lib/security/credentials/external/url_external_account_credentials.h +9 -7
  265. data/src/core/lib/security/credentials/fake/fake_credentials.cc +2 -2
  266. data/src/core/lib/security/credentials/fake/fake_credentials.h +2 -2
  267. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +9 -9
  268. data/src/core/lib/security/credentials/iam/iam_credentials.cc +2 -2
  269. data/src/core/lib/security/credentials/iam/iam_credentials.h +2 -2
  270. data/src/core/lib/security/credentials/jwt/json_token.cc +2 -2
  271. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +3 -3
  272. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +2 -2
  273. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +7 -5
  274. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +21 -19
  275. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +5 -5
  276. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +5 -5
  277. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +2 -2
  278. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc +8 -7
  279. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h +9 -9
  280. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +19 -13
  281. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +4 -0
  282. data/src/core/lib/security/credentials/xds/xds_credentials.cc +3 -3
  283. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +13 -3
  284. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +13 -3
  285. data/src/core/lib/security/security_connector/insecure/insecure_security_connector.cc +2 -2
  286. data/src/core/lib/security/security_connector/insecure/insecure_security_connector.h +12 -2
  287. data/src/core/lib/security/security_connector/load_system_roots_linux.cc +1 -1
  288. data/src/core/lib/security/security_connector/local/local_security_connector.cc +14 -4
  289. data/src/core/lib/security/security_connector/security_connector.h +9 -4
  290. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +16 -6
  291. data/src/core/lib/security/security_connector/ssl_utils.cc +22 -4
  292. data/src/core/lib/security/security_connector/ssl_utils.h +4 -4
  293. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +56 -60
  294. data/src/core/lib/security/security_connector/tls/tls_security_connector.h +66 -48
  295. data/src/core/lib/security/transport/client_auth_filter.cc +18 -10
  296. data/src/core/lib/security/transport/secure_endpoint.cc +4 -4
  297. data/src/core/lib/security/transport/security_handshaker.cc +33 -32
  298. data/src/core/lib/security/transport/server_auth_filter.cc +19 -13
  299. data/src/core/lib/security/transport/tsi_error.cc +2 -1
  300. data/src/core/lib/security/transport/tsi_error.h +2 -1
  301. data/src/core/lib/security/util/json_util.cc +2 -2
  302. data/src/core/lib/security/util/json_util.h +1 -1
  303. data/src/core/lib/surface/call.cc +46 -45
  304. data/src/core/lib/surface/call.h +2 -2
  305. data/src/core/lib/surface/channel.cc +6 -6
  306. data/src/core/lib/surface/channel.h +3 -2
  307. data/src/core/lib/surface/channel_ping.cc +1 -1
  308. data/src/core/lib/surface/completion_queue.cc +46 -47
  309. data/src/core/lib/surface/completion_queue.h +2 -1
  310. data/src/core/lib/surface/lame_client.cc +11 -11
  311. data/src/core/lib/surface/lame_client.h +1 -1
  312. data/src/core/lib/surface/server.cc +28 -22
  313. data/src/core/lib/surface/server.h +16 -15
  314. data/src/core/lib/surface/validate_metadata.cc +7 -7
  315. data/src/core/lib/surface/validate_metadata.h +3 -2
  316. data/src/core/lib/surface/version.cc +4 -2
  317. data/src/core/lib/transport/byte_stream.cc +5 -5
  318. data/src/core/lib/transport/byte_stream.h +8 -8
  319. data/src/core/lib/transport/connectivity_state.cc +1 -1
  320. data/src/core/lib/transport/error_utils.cc +19 -8
  321. data/src/core/lib/transport/error_utils.h +11 -5
  322. data/src/core/lib/transport/metadata_batch.cc +37 -37
  323. data/src/core/lib/transport/metadata_batch.h +19 -18
  324. data/src/core/lib/transport/transport.cc +4 -3
  325. data/src/core/lib/transport/transport.h +4 -4
  326. data/src/core/lib/transport/transport_op_string.cc +5 -5
  327. data/src/core/tsi/alts/crypt/gsec.h +4 -0
  328. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +5 -4
  329. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +7 -6
  330. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h +2 -1
  331. data/src/core/tsi/ssl_transport_security.cc +32 -14
  332. data/src/core/tsi/ssl_transport_security.h +3 -4
  333. data/src/ruby/bin/math_services_pb.rb +1 -1
  334. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +1 -1
  335. data/src/ruby/lib/grpc/version.rb +1 -1
  336. data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +1 -1
  337. data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +6 -6
  338. data/third_party/abseil-cpp/absl/algorithm/container.h +3 -3
  339. data/third_party/abseil-cpp/absl/base/attributes.h +24 -4
  340. data/third_party/abseil-cpp/absl/base/call_once.h +2 -9
  341. data/third_party/abseil-cpp/absl/base/config.h +37 -9
  342. data/third_party/abseil-cpp/absl/base/dynamic_annotations.h +24 -10
  343. data/third_party/abseil-cpp/absl/base/internal/direct_mmap.h +4 -1
  344. data/third_party/abseil-cpp/absl/base/internal/endian.h +61 -0
  345. data/third_party/abseil-cpp/absl/base/internal/low_level_scheduling.h +2 -3
  346. data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +34 -32
  347. data/third_party/abseil-cpp/absl/base/internal/raw_logging.h +16 -6
  348. data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +11 -2
  349. data/third_party/abseil-cpp/absl/base/internal/spinlock.h +14 -5
  350. data/third_party/abseil-cpp/absl/base/internal/spinlock_akaros.inc +2 -2
  351. data/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc +3 -3
  352. data/third_party/abseil-cpp/absl/base/internal/spinlock_posix.inc +2 -2
  353. data/third_party/abseil-cpp/absl/base/internal/spinlock_wait.h +11 -11
  354. data/third_party/abseil-cpp/absl/base/internal/spinlock_win32.inc +5 -5
  355. data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +1 -1
  356. data/third_party/abseil-cpp/absl/base/internal/thread_identity.cc +5 -2
  357. data/third_party/abseil-cpp/absl/base/internal/thread_identity.h +43 -42
  358. data/third_party/abseil-cpp/absl/base/internal/throw_delegate.cc +111 -7
  359. data/third_party/abseil-cpp/absl/base/internal/unaligned_access.h +0 -76
  360. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc +1 -3
  361. data/third_party/abseil-cpp/absl/base/log_severity.h +4 -4
  362. data/third_party/abseil-cpp/absl/base/macros.h +11 -0
  363. data/third_party/abseil-cpp/absl/base/optimization.h +10 -7
  364. data/third_party/abseil-cpp/absl/base/options.h +1 -1
  365. data/third_party/abseil-cpp/absl/base/port.h +0 -1
  366. data/third_party/abseil-cpp/absl/base/thread_annotations.h +1 -1
  367. data/third_party/abseil-cpp/absl/container/fixed_array.h +2 -2
  368. data/third_party/abseil-cpp/absl/container/inlined_vector.h +5 -3
  369. data/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h +1 -1
  370. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +5 -1
  371. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +2 -1
  372. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler_force_weak_definition.cc +2 -1
  373. data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +141 -66
  374. data/third_party/abseil-cpp/absl/container/internal/layout.h +4 -4
  375. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +14 -1
  376. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +136 -136
  377. data/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +16 -12
  378. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +5 -2
  379. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_config.h +3 -12
  380. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +6 -1
  381. data/third_party/abseil-cpp/absl/debugging/internal/symbolize.h +3 -5
  382. data/third_party/abseil-cpp/absl/debugging/symbolize_darwin.inc +2 -2
  383. data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +2 -2
  384. data/third_party/abseil-cpp/absl/hash/internal/city.cc +15 -12
  385. data/third_party/abseil-cpp/absl/hash/internal/city.h +1 -19
  386. data/third_party/abseil-cpp/absl/hash/internal/hash.cc +25 -10
  387. data/third_party/abseil-cpp/absl/hash/internal/hash.h +86 -37
  388. data/third_party/abseil-cpp/absl/hash/internal/wyhash.cc +111 -0
  389. data/third_party/abseil-cpp/absl/hash/internal/wyhash.h +48 -0
  390. data/third_party/abseil-cpp/absl/meta/type_traits.h +16 -2
  391. data/third_party/abseil-cpp/absl/numeric/bits.h +177 -0
  392. data/third_party/abseil-cpp/absl/numeric/int128.cc +3 -3
  393. data/third_party/abseil-cpp/absl/numeric/internal/bits.h +358 -0
  394. data/third_party/abseil-cpp/absl/numeric/internal/representation.h +55 -0
  395. data/third_party/abseil-cpp/absl/status/internal/status_internal.h +18 -0
  396. data/third_party/abseil-cpp/absl/status/internal/statusor_internal.h +4 -7
  397. data/third_party/abseil-cpp/absl/status/status.cc +29 -22
  398. data/third_party/abseil-cpp/absl/status/status.h +81 -20
  399. data/third_party/abseil-cpp/absl/status/statusor.h +3 -3
  400. data/third_party/abseil-cpp/absl/strings/charconv.cc +5 -5
  401. data/third_party/abseil-cpp/absl/strings/cord.cc +326 -371
  402. data/third_party/abseil-cpp/absl/strings/cord.h +182 -64
  403. data/third_party/abseil-cpp/absl/strings/escaping.cc +4 -4
  404. data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc +6 -6
  405. data/third_party/abseil-cpp/absl/strings/internal/cord_internal.cc +83 -0
  406. data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +387 -17
  407. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_flat.h +146 -0
  408. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_ring.cc +897 -0
  409. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_ring.h +589 -0
  410. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_ring_reader.h +114 -0
  411. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc +14 -0
  412. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +14 -0
  413. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.cc +15 -1
  414. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h +19 -4
  415. data/third_party/abseil-cpp/absl/strings/internal/str_format/checker.h +14 -0
  416. data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc +36 -18
  417. data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.h +14 -0
  418. data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc +14 -0
  419. data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h +14 -0
  420. data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +15 -40
  421. data/third_party/abseil-cpp/absl/strings/internal/string_constant.h +64 -0
  422. data/third_party/abseil-cpp/absl/strings/match.cc +6 -3
  423. data/third_party/abseil-cpp/absl/strings/match.h +16 -6
  424. data/third_party/abseil-cpp/absl/strings/numbers.cc +132 -4
  425. data/third_party/abseil-cpp/absl/strings/numbers.h +10 -10
  426. data/third_party/abseil-cpp/absl/strings/str_join.h +1 -1
  427. data/third_party/abseil-cpp/absl/strings/str_split.h +38 -4
  428. data/third_party/abseil-cpp/absl/synchronization/internal/futex.h +154 -0
  429. data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +2 -1
  430. data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc +2 -2
  431. data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h +4 -4
  432. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.cc +1 -65
  433. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.h +2 -6
  434. data/third_party/abseil-cpp/absl/synchronization/mutex.cc +71 -59
  435. data/third_party/abseil-cpp/absl/synchronization/mutex.h +79 -62
  436. data/third_party/abseil-cpp/absl/time/clock.cc +146 -130
  437. data/third_party/abseil-cpp/absl/time/clock.h +2 -2
  438. data/third_party/abseil-cpp/absl/time/duration.cc +3 -2
  439. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h +7 -11
  440. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc +7 -1
  441. data/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h +4 -4
  442. data/third_party/abseil-cpp/absl/time/time.cc +4 -3
  443. data/third_party/abseil-cpp/absl/time/time.h +26 -24
  444. data/third_party/abseil-cpp/absl/types/internal/variant.h +1 -1
  445. data/third_party/abseil-cpp/absl/types/variant.h +9 -4
  446. data/third_party/boringssl-with-bazel/err_data.c +477 -461
  447. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bool.c +1 -1
  448. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +1 -1
  449. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_type.c +18 -8
  450. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_lib.c +1 -2
  451. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_locl.h +5 -0
  452. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +1 -1
  453. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_fre.c +1 -1
  454. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_tls.c +1 -88
  455. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/internal.h +14 -3
  456. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/tls_cbc.c +119 -273
  457. data/third_party/boringssl-with-bazel/src/crypto/err/err.c +87 -80
  458. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c +1 -0
  459. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/internal.h +1 -1
  460. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/cipher.c +11 -3
  461. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/e_aes.c +25 -2
  462. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digests.c +10 -2
  463. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/md32_common.h +4 -43
  464. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec.c +4 -0
  465. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_key.c +0 -1
  466. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +0 -4
  467. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +104 -93
  468. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/internal.h +39 -0
  469. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md4/md4.c +43 -46
  470. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md5/md5.c +43 -46
  471. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cbc.c +33 -22
  472. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cfb.c +9 -8
  473. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ctr.c +9 -8
  474. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm.c +17 -13
  475. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/internal.h +1 -22
  476. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ofb.c +2 -1
  477. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +26 -7
  478. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/fips.c +79 -0
  479. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +14 -9
  480. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1.c +45 -48
  481. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha256.c +38 -43
  482. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +37 -45
  483. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +103 -42
  484. data/third_party/boringssl-with-bazel/src/crypto/hpke/internal.h +58 -37
  485. data/third_party/boringssl-with-bazel/src/crypto/internal.h +65 -0
  486. data/third_party/boringssl-with-bazel/src/crypto/mem.c +14 -0
  487. data/third_party/boringssl-with-bazel/src/crypto/obj/obj.c +3 -3
  488. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7_x509.c +1 -1
  489. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +95 -48
  490. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/rand_extra.c +1 -1
  491. data/third_party/boringssl-with-bazel/src/crypto/thread_pthread.c +0 -28
  492. data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +19 -0
  493. data/third_party/boringssl-with-bazel/src/crypto/x509/t_req.c +2 -0
  494. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_att.c +19 -25
  495. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +3 -2
  496. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +39 -89
  497. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +9 -16
  498. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +1 -1
  499. data/third_party/boringssl-with-bazel/src/crypto/x509/x_algor.c +21 -17
  500. data/third_party/boringssl-with-bazel/src/crypto/x509/x_attrib.c +7 -25
  501. data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +5 -0
  502. data/third_party/boringssl-with-bazel/src/crypto/x509/x_pubkey.c +25 -22
  503. data/third_party/boringssl-with-bazel/src/crypto/x509/x_val.c +2 -0
  504. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_cpols.c +2 -4
  505. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +1 -1
  506. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c +1 -0
  507. data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +0 -3
  508. data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +120 -41
  509. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +9 -0
  510. data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +0 -8
  511. data/third_party/boringssl-with-bazel/src/include/openssl/crypto.h +24 -4
  512. data/third_party/boringssl-with-bazel/src/include/openssl/ec.h +5 -2
  513. data/third_party/boringssl-with-bazel/src/include/openssl/ecdsa.h +19 -0
  514. data/third_party/boringssl-with-bazel/src/include/openssl/err.h +3 -2
  515. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +1 -38
  516. data/third_party/boringssl-with-bazel/src/{crypto/x509/x509_r2x.c → include/openssl/evp_errors.h} +41 -58
  517. data/third_party/boringssl-with-bazel/src/include/openssl/obj.h +24 -5
  518. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +2 -0
  519. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs8.h +9 -1
  520. data/third_party/boringssl-with-bazel/src/include/openssl/rand.h +2 -2
  521. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +185 -17
  522. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +1 -0
  523. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +416 -121
  524. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +2 -0
  525. data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +5 -0
  526. data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +444 -0
  527. data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +244 -1
  528. data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +43 -12
  529. data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +149 -8
  530. data/third_party/boringssl-with-bazel/src/ssl/internal.h +220 -46
  531. data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +7 -1
  532. data/third_party/boringssl-with-bazel/src/ssl/ssl_cert.cc +4 -6
  533. data/third_party/boringssl-with-bazel/src/ssl/ssl_key_share.cc +23 -26
  534. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +74 -15
  535. data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +98 -64
  536. data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +34 -4
  537. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +205 -100
  538. data/third_party/boringssl-with-bazel/src/ssl/tls_method.cc +4 -2
  539. metadata +68 -45
  540. data/src/core/lib/iomgr/poller/eventmanager_libuv.cc +0 -88
  541. data/src/core/lib/iomgr/poller/eventmanager_libuv.h +0 -88
  542. data/third_party/abseil-cpp/absl/base/internal/bits.h +0 -219
  543. data/third_party/abseil-cpp/absl/synchronization/internal/mutex_nonprod.inc +0 -249
  544. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/is_fips.c +0 -29
@@ -257,6 +257,7 @@ extern "C" {
257
257
  // extension number.
258
258
  #define TLSEXT_TYPE_encrypted_client_hello 0xfe09
259
259
  #define TLSEXT_TYPE_ech_is_inner 0xda09
260
+ #define TLSEXT_TYPE_ech_outer_extensions 0xfd00
260
261
 
261
262
  // ExtensionType value from RFC6962
262
263
  #define TLSEXT_TYPE_certificate_timestamp 18
@@ -115,17 +115,6 @@ DECLARE_ASN1_SET_OF(X509_ALGOR)
115
115
 
116
116
  typedef STACK_OF(X509_ALGOR) X509_ALGORS;
117
117
 
118
- struct X509_val_st {
119
- ASN1_TIME *notBefore;
120
- ASN1_TIME *notAfter;
121
- } /* X509_VAL */;
122
-
123
- struct X509_pubkey_st {
124
- X509_ALGOR *algor;
125
- ASN1_BIT_STRING *public_key;
126
- EVP_PKEY *pkey;
127
- };
128
-
129
118
  struct X509_sig_st {
130
119
  X509_ALGOR *algor;
131
120
  ASN1_OCTET_STRING *digest;
@@ -164,17 +153,6 @@ typedef STACK_OF(X509_EXTENSION) X509_EXTENSIONS;
164
153
  DEFINE_STACK_OF(X509_EXTENSION)
165
154
  DECLARE_ASN1_SET_OF(X509_EXTENSION)
166
155
 
167
- // a sequence of these are used
168
- struct x509_attributes_st {
169
- ASN1_OBJECT *object;
170
- int single; // 0 for a set, 1 for a single item (which is wrong)
171
- union {
172
- char *ptr;
173
- /* 0 */ STACK_OF(ASN1_TYPE) *set;
174
- /* 1 */ ASN1_TYPE *single;
175
- } value;
176
- } /* X509_ATTRIBUTE */;
177
-
178
156
  DEFINE_STACK_OF(X509_ATTRIBUTE)
179
157
  DECLARE_ASN1_SET_OF(X509_ATTRIBUTE)
180
158
 
@@ -475,16 +453,34 @@ extern "C" {
475
453
  // it is safe to call mutating functions is a little tricky due to various
476
454
  // internal caches.
477
455
 
478
- // X509_get_version returns the numerical value of |x509|'s version. That is,
479
- // it returns zero for X.509v1, one for X.509v2, and two for X.509v3. Unknown
480
- // versions are rejected by the parser, but a manually-created |X509| object may
481
- // encode invalid versions. In that case, the function will return the invalid
482
- // version, or -1 on overflow.
456
+ // The following constants are version numbers of X.509-related structures. Note
457
+ // APIs typically return the numerical value of X.509 versions, which are one
458
+ // less than the named version.
459
+ #define X509V1_VERSION 0
460
+ #define X509V2_VERSION 1
461
+ #define X509V3_VERSION 2
462
+
463
+ // X509_get_version returns the numerical value of |x509|'s version. Callers may
464
+ // compare the result to the |X509V*_VERSION| constants. Unknown versions are
465
+ // rejected by the parser, but a manually-created |X509| object may encode
466
+ // invalid versions. In that case, the function will return the invalid version,
467
+ // or -1 on overflow.
483
468
  OPENSSL_EXPORT long X509_get_version(const X509 *x509);
484
469
 
470
+ // X509_set_version sets |x509|'s version to |version|, which should be one of
471
+ // the |X509V*_VERSION| constants. It returns one on success and zero on error.
472
+ //
473
+ // If unsure, use |X509V3_VERSION|.
474
+ OPENSSL_EXPORT int X509_set_version(X509 *x509, long version);
475
+
485
476
  // X509_get0_serialNumber returns |x509|'s serial number.
486
477
  OPENSSL_EXPORT const ASN1_INTEGER *X509_get0_serialNumber(const X509 *x509);
487
478
 
479
+ // X509_set_serialNumber sets |x509|'s serial number to |serial|. It returns one
480
+ // on success and zero on error.
481
+ OPENSSL_EXPORT int X509_set_serialNumber(X509 *x509,
482
+ const ASN1_INTEGER *serial);
483
+
488
484
  // X509_get0_notBefore returns |x509|'s notBefore time.
489
485
  OPENSSL_EXPORT const ASN1_TIME *X509_get0_notBefore(const X509 *x509);
490
486
 
@@ -523,20 +519,16 @@ OPENSSL_EXPORT int X509_set_notBefore(X509 *x509, const ASN1_TIME *tm);
523
519
  // instead.
524
520
  OPENSSL_EXPORT int X509_set_notAfter(X509 *x509, const ASN1_TIME *tm);
525
521
 
526
- // X509_get0_uids sets |*out_issuer_uid| and |*out_subject_uid| to non-owning
527
- // pointers to the issuerUID and subjectUID fields, respectively, of |x509|.
528
- // Either output pointer may be NULL to skip the field.
522
+ // X509_get0_uids sets |*out_issuer_uid| to a non-owning pointer to the
523
+ // issuerUID field of |x509|, or NULL if |x509| has no issuerUID. It similarly
524
+ // outputs |x509|'s subjectUID field to |*out_subject_uid|.
525
+ //
526
+ // Callers may pass NULL to either |out_issuer_uid| or |out_subject_uid| to
527
+ // ignore the corresponding field.
529
528
  OPENSSL_EXPORT void X509_get0_uids(const X509 *x509,
530
529
  const ASN1_BIT_STRING **out_issuer_uid,
531
530
  const ASN1_BIT_STRING **out_subject_uid);
532
531
 
533
- // X509_get_cert_info returns |x509|'s TBSCertificate structure. Note this
534
- // function is not const-correct for legacy reasons.
535
- //
536
- // This function is deprecated and may be removed in the future. It is not
537
- // present in OpenSSL and constrains some improvements to the library.
538
- OPENSSL_EXPORT X509_CINF *X509_get_cert_info(const X509 *x509);
539
-
540
532
  // X509_extract_key is a legacy alias to |X509_get_pubkey|. Use
541
533
  // |X509_get_pubkey| instead.
542
534
  #define X509_extract_key(x) X509_get_pubkey(x)
@@ -550,9 +542,9 @@ OPENSSL_EXPORT X509_CINF *X509_get_cert_info(const X509 *x509);
550
542
  // |EXFLAG_INVALID| bit.
551
543
  OPENSSL_EXPORT long X509_get_pathlen(X509 *x509);
552
544
 
553
- // X509_REQ_get_version returns the numerical value of |req|'s version. That is,
554
- // it returns zero for a v1 request. If |req| is invalid, it may return another
555
- // value, or -1 on overflow.
545
+ // X509_REQ_get_version returns the numerical value of |req|'s version. Callers
546
+ // may compare the result to |X509V*_VERSION| constants. If |req| is invalid, it
547
+ // may return another value, or -1 on overflow.
556
548
  OPENSSL_EXPORT long X509_REQ_get_version(const X509_REQ *req);
557
549
 
558
550
  // X509_REQ_get_subject_name returns |req|'s subject name. Note this function is
@@ -565,9 +557,9 @@ OPENSSL_EXPORT X509_NAME *X509_REQ_get_subject_name(const X509_REQ *req);
565
557
  // X509_name_cmp is a legacy alias for |X509_NAME_cmp|.
566
558
  #define X509_name_cmp(a, b) X509_NAME_cmp((a), (b))
567
559
 
568
- // X509_REQ_get_version returns the numerical value of |crl|'s version. That is,
569
- // it returns zero for a v1 CRL and one for a v2 CRL. If |crl| is invalid, it
570
- // may return another value, or -1 on overflow.
560
+ // X509_CRL_get_version returns the numerical value of |crl|'s version. Callers
561
+ // may compare the result to |X509V*_VERSION| constants. If |crl| is invalid,
562
+ // it may return another value, or -1 on overflow.
571
563
  OPENSSL_EXPORT long X509_CRL_get_version(const X509_CRL *crl);
572
564
 
573
565
  // X509_CRL_get0_lastUpdate returns |crl|'s lastUpdate time.
@@ -602,33 +594,19 @@ OPENSSL_EXPORT ASN1_TIME *X509_CRL_get_nextUpdate(X509_CRL *crl);
602
594
  // const-correct for legacy reasons.
603
595
  OPENSSL_EXPORT X509_NAME *X509_CRL_get_issuer(const X509_CRL *crl);
604
596
 
605
- // X509_CRL_get_REVOKED returns the list of revoked certificates in |crl|.
597
+ // X509_CRL_get_REVOKED returns the list of revoked certificates in |crl|, or
598
+ // NULL if |crl| omits it.
606
599
  //
607
600
  // TOOD(davidben): This function was originally a macro, without clear const
608
601
  // semantics. It should take a const input and give const output, but the latter
609
602
  // would break existing callers. For now, we match upstream.
610
603
  OPENSSL_EXPORT STACK_OF(X509_REVOKED) *X509_CRL_get_REVOKED(X509_CRL *crl);
611
604
 
612
- // X509_CRL_get0_extensions returns |crl|'s extension list.
605
+ // X509_CRL_get0_extensions returns |crl|'s extension list, or NULL if |crl|
606
+ // omits it.
613
607
  OPENSSL_EXPORT const STACK_OF(X509_EXTENSION) *X509_CRL_get0_extensions(
614
608
  const X509_CRL *crl);
615
609
 
616
- // X509_CINF_set_modified marks |cinf| as modified so that changes will be
617
- // reflected in serializing the structure.
618
- //
619
- // This function is deprecated and may be removed in the future. It is not
620
- // present in OpenSSL and constrains some improvements to the library.
621
- OPENSSL_EXPORT void X509_CINF_set_modified(X509_CINF *cinf);
622
-
623
- // X509_CINF_get_signature returns the signature algorithm in |cinf|. Note this
624
- // isn't the signature itself, but the extra copy of the signature algorithm
625
- // in the TBSCertificate.
626
- //
627
- // This function is deprecated and may be removed in the future. It is not
628
- // present in OpenSSL and constrains some improvements to the library. Use
629
- // |X509_get0_tbs_sigalg| instead.
630
- OPENSSL_EXPORT const X509_ALGOR *X509_CINF_get_signature(const X509_CINF *cinf);
631
-
632
610
  // X509_SIG_get0 sets |*out_alg| and |*out_digest| to non-owning pointers to
633
611
  // |sig|'s algorithm and digest fields, respectively. Either |out_alg| and
634
612
  // |out_digest| may be NULL to skip those fields.
@@ -892,12 +870,54 @@ OPENSSL_EXPORT X509_CRL *X509_CRL_dup(X509_CRL *crl);
892
870
  OPENSSL_EXPORT X509_REVOKED *X509_REVOKED_dup(X509_REVOKED *rev);
893
871
  OPENSSL_EXPORT X509_REQ *X509_REQ_dup(X509_REQ *req);
894
872
  OPENSSL_EXPORT X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn);
895
- OPENSSL_EXPORT int X509_ALGOR_set0(X509_ALGOR *alg, const ASN1_OBJECT *aobj,
896
- int ptype, void *pval);
897
- OPENSSL_EXPORT void X509_ALGOR_get0(const ASN1_OBJECT **paobj, int *pptype,
898
- const void **ppval,
899
- const X509_ALGOR *algor);
873
+
874
+ // X509_ALGOR_set0 sets |alg| to an AlgorithmIdentifier with algorithm |obj| and
875
+ // parameter determined by |param_type| and |param_value|. It returns one on
876
+ // success and zero on error. This function takes ownership of |obj| and
877
+ // |param_value| on success.
878
+ //
879
+ // If |param_type| is |V_ASN1_UNDEF|, the parameter is omitted. If |param_type|
880
+ // is zero, the parameter is left unchanged. Otherwise, |param_type| and
881
+ // |param_value| are interpreted as in |ASN1_TYPE_set|.
882
+ //
883
+ // Note omitting the parameter (|V_ASN1_UNDEF|) and encoding an explicit NULL
884
+ // value (|V_ASN1_NULL|) are different. Some algorithms require one and some the
885
+ // other. Consult the relevant specification before calling this function. The
886
+ // correct parameter for an RSASSA-PKCS1-v1_5 signature is |V_ASN1_NULL|. The
887
+ // correct one for an ECDSA or Ed25519 signature is |V_ASN1_UNDEF|.
888
+ OPENSSL_EXPORT int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *obj,
889
+ int param_type, void *param_value);
890
+
891
+ // X509_ALGOR_get0 sets |*out_obj| to the |alg|'s algorithm. If |alg|'s
892
+ // parameter is omitted, it sets |*out_param_type| and |*out_param_value| to
893
+ // |V_ASN1_UNDEF| and NULL. Otherwise, it sets |*out_param_type| and
894
+ // |*out_param_value| to the parameter, using the same representation as
895
+ // |ASN1_TYPE_set0|. See |ASN1_TYPE_set0| and |ASN1_TYPE| for details.
896
+ //
897
+ // Callers that require the parameter in serialized form should, after checking
898
+ // for |V_ASN1_UNDEF|, use |ASN1_TYPE_set1| and |d2i_ASN1_TYPE|, rather than
899
+ // inspecting |*out_param_value|.
900
+ //
901
+ // Each of |out_obj|, |out_param_type|, and |out_param_value| may be NULL to
902
+ // ignore the output. If |out_param_type| is NULL, |out_param_value| is ignored.
903
+ //
904
+ // WARNING: If |*out_param_type| is set to |V_ASN1_UNDEF|, OpenSSL and older
905
+ // revisions of BoringSSL leave |*out_param_value| unset rather than setting it
906
+ // to NULL. Callers that support both OpenSSL and BoringSSL should not assume
907
+ // |*out_param_value| is uniformly initialized.
908
+ OPENSSL_EXPORT void X509_ALGOR_get0(const ASN1_OBJECT **out_obj,
909
+ int *out_param_type,
910
+ const void **out_param_value,
911
+ const X509_ALGOR *alg);
912
+
913
+ // X509_ALGOR_set_md sets |alg| to the hash function |md|. Note this
914
+ // AlgorithmIdentifier represents the hash function itself, not a signature
915
+ // algorithm that uses |md|.
900
916
  OPENSSL_EXPORT void X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md);
917
+
918
+ // X509_ALGOR_cmp returns zero if |a| and |b| are equal, and some non-zero value
919
+ // otherwise. Note this function can only be used for equality checks, not an
920
+ // ordering.
901
921
  OPENSSL_EXPORT int X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b);
902
922
 
903
923
  OPENSSL_EXPORT X509_NAME *X509_NAME_dup(X509_NAME *xn);
@@ -923,7 +943,6 @@ OPENSSL_EXPORT const char *X509_get_default_private_dir(void);
923
943
 
924
944
  OPENSSL_EXPORT X509_REQ *X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey,
925
945
  const EVP_MD *md);
926
- OPENSSL_EXPORT X509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey);
927
946
 
928
947
  DECLARE_ASN1_ENCODE_FUNCTIONS(X509_ALGORS, X509_ALGORS, X509_ALGORS)
929
948
  DECLARE_ASN1_FUNCTIONS(X509_VAL)
@@ -938,7 +957,12 @@ DECLARE_ASN1_FUNCTIONS(X509_REQ_INFO)
938
957
  DECLARE_ASN1_FUNCTIONS(X509_REQ)
939
958
 
940
959
  DECLARE_ASN1_FUNCTIONS(X509_ATTRIBUTE)
941
- OPENSSL_EXPORT X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype,
960
+
961
+ // X509_ATTRIBUTE_create returns a newly-allocated |X509_ATTRIBUTE|, or NULL on
962
+ // error. The attribute has type |nid| and contains a single value determined by
963
+ // |attrtype| and |value|, which are interpreted as in |ASN1_TYPE_set|. Note
964
+ // this function takes ownership of |value|.
965
+ OPENSSL_EXPORT X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int attrtype,
942
966
  void *value);
943
967
 
944
968
  DECLARE_ASN1_FUNCTIONS(X509_EXTENSION)
@@ -955,8 +979,8 @@ DECLARE_ASN1_FUNCTIONS(X509_CINF)
955
979
  DECLARE_ASN1_FUNCTIONS(X509)
956
980
  DECLARE_ASN1_FUNCTIONS(X509_CERT_AUX)
957
981
 
958
- // X509_up_ref adds one to the reference count of |x| and returns one.
959
- OPENSSL_EXPORT int X509_up_ref(X509 *x);
982
+ // X509_up_ref adds one to the reference count of |x509| and returns one.
983
+ OPENSSL_EXPORT int X509_up_ref(X509 *x509);
960
984
 
961
985
  OPENSSL_EXPORT int X509_get_ex_new_index(long argl, void *argp,
962
986
  CRYPTO_EX_unused *unused,
@@ -1014,9 +1038,22 @@ OPENSSL_EXPORT int X509_set1_signature_algo(X509 *x509, const X509_ALGOR *algo);
1014
1038
  OPENSSL_EXPORT int X509_set1_signature_value(X509 *x509, const uint8_t *sig,
1015
1039
  size_t sig_len);
1016
1040
 
1017
- OPENSSL_EXPORT void X509_get0_signature(const ASN1_BIT_STRING **psig,
1018
- const X509_ALGOR **palg, const X509 *x);
1019
- OPENSSL_EXPORT int X509_get_signature_nid(const X509 *x);
1041
+ // X509_get0_signature sets |*out_sig| and |*out_alg| to the signature and
1042
+ // signature algorithm of |x509|, respectively. Either output pointer may be
1043
+ // NULL to ignore the value.
1044
+ //
1045
+ // This function outputs the outer signature algorithm. For the one in the
1046
+ // TBSCertificate, see |X509_get0_tbs_sigalg|. Certificates with mismatched
1047
+ // signature algorithms will successfully parse, but they will be rejected when
1048
+ // verifying.
1049
+ OPENSSL_EXPORT void X509_get0_signature(const ASN1_BIT_STRING **out_sig,
1050
+ const X509_ALGOR **out_alg,
1051
+ const X509 *x509);
1052
+
1053
+ // X509_get_signature_nid returns the NID corresponding to |x509|'s signature
1054
+ // algorithm, or |NID_undef| if the signature algorithm does not correspond to
1055
+ // a known NID.
1056
+ OPENSSL_EXPORT int X509_get_signature_nid(const X509 *x509);
1020
1057
 
1021
1058
  OPENSSL_EXPORT int X509_alias_set1(X509 *x, const unsigned char *name, int len);
1022
1059
  OPENSSL_EXPORT int X509_keyid_set1(X509 *x, const unsigned char *id, int len);
@@ -1071,66 +1108,220 @@ OPENSSL_EXPORT int ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1,
1071
1108
  ASN1_BIT_STRING *signature, void *asn,
1072
1109
  EVP_MD_CTX *ctx);
1073
1110
 
1074
- OPENSSL_EXPORT int X509_set_version(X509 *x, long version);
1075
- OPENSSL_EXPORT int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial);
1076
- OPENSSL_EXPORT ASN1_INTEGER *X509_get_serialNumber(X509 *x);
1077
- OPENSSL_EXPORT int X509_set_issuer_name(X509 *x, X509_NAME *name);
1078
- OPENSSL_EXPORT X509_NAME *X509_get_issuer_name(const X509 *a);
1079
- OPENSSL_EXPORT int X509_set_subject_name(X509 *x, X509_NAME *name);
1080
- OPENSSL_EXPORT X509_NAME *X509_get_subject_name(const X509 *a);
1081
- OPENSSL_EXPORT int X509_set_pubkey(X509 *x, EVP_PKEY *pkey);
1082
- OPENSSL_EXPORT EVP_PKEY *X509_get_pubkey(X509 *x);
1083
- OPENSSL_EXPORT ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x);
1111
+ // X509_get_serialNumber returns a mutable pointer to |x509|'s serial number.
1112
+ // Prefer |X509_get0_serialNumber|.
1113
+ OPENSSL_EXPORT ASN1_INTEGER *X509_get_serialNumber(X509 *x509);
1114
+
1115
+ // X509_set_issuer_name sets |x509|'s issuer to a copy of |name|. It returns one
1116
+ // on success and zero on error.
1117
+ OPENSSL_EXPORT int X509_set_issuer_name(X509 *x509, X509_NAME *name);
1118
+
1119
+ // X509_get_issuer_name returns |x509|'s issuer.
1120
+ OPENSSL_EXPORT X509_NAME *X509_get_issuer_name(const X509 *x509);
1121
+
1122
+ // X509_set_subject_name sets |x509|'s subject to a copy of |name|. It returns
1123
+ // one on success and zero on error.
1124
+ OPENSSL_EXPORT int X509_set_subject_name(X509 *x509, X509_NAME *name);
1125
+
1126
+ // X509_get_issuer_name returns |x509|'s subject.
1127
+ OPENSSL_EXPORT X509_NAME *X509_get_subject_name(const X509 *x509);
1128
+
1129
+ // X509_set_pubkey sets |x509|'s public key to |pkey|. It returns one on success
1130
+ // and zero on error. This function does not take ownership of |pkey| and
1131
+ // internally copies and updates reference counts as needed.
1132
+ OPENSSL_EXPORT int X509_set_pubkey(X509 *x509, EVP_PKEY *pkey);
1133
+
1134
+ // X509_get_pubkey returns |x509|'s public key as an |EVP_PKEY|, or NULL if the
1135
+ // public key was unsupported or could not be decoded. This function returns a
1136
+ // reference to the |EVP_PKEY|. The caller must release the result with
1137
+ // |EVP_PKEY_free| when done.
1138
+ OPENSSL_EXPORT EVP_PKEY *X509_get_pubkey(X509 *x509);
1139
+
1140
+ // X509_get0_pubkey_bitstr returns the BIT STRING portion of |x509|'s public
1141
+ // key. Note this does not contain the AlgorithmIdentifier portion.
1142
+ //
1143
+ // WARNING: This function returns a non-const pointer for OpenSSL compatibility,
1144
+ // but the caller must not modify the resulting object. Doing so will break
1145
+ // internal invariants in |x509|.
1146
+ OPENSSL_EXPORT ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x509);
1147
+
1148
+ // X509_get0_extensions returns |x509|'s extension list, or NULL if |x509| omits
1149
+ // it.
1084
1150
  OPENSSL_EXPORT const STACK_OF(X509_EXTENSION) *X509_get0_extensions(
1085
- const X509 *x);
1086
- OPENSSL_EXPORT const X509_ALGOR *X509_get0_tbs_sigalg(const X509 *x);
1151
+ const X509 *x509);
1152
+
1153
+ // X509_get0_tbs_sigalg returns the signature algorithm in |x509|'s
1154
+ // TBSCertificate. For the outer signature algorithm, see |X509_get0_signature|.
1155
+ //
1156
+ // Certificates with mismatched signature algorithms will successfully parse,
1157
+ // but they will be rejected when verifying.
1158
+ OPENSSL_EXPORT const X509_ALGOR *X509_get0_tbs_sigalg(const X509 *x509);
1159
+
1160
+ // X509_REQ_set_version sets |req|'s version to |version|, which should be
1161
+ // |X509V1_VERSION|. It returns one on success and zero on error.
1162
+ //
1163
+ // Note no versions other than |X509V1_VERSION| are defined for CSRs.
1164
+ OPENSSL_EXPORT int X509_REQ_set_version(X509_REQ *req, long version);
1087
1165
 
1088
- OPENSSL_EXPORT int X509_REQ_set_version(X509_REQ *x, long version);
1166
+ // X509_REQ_set_subject_name sets |req|'s subject to a copy of |name|. It
1167
+ // returns one on success and zero on error.
1089
1168
  OPENSSL_EXPORT int X509_REQ_set_subject_name(X509_REQ *req, X509_NAME *name);
1169
+
1170
+ // X509_REQ_get0_signature sets |*out_sig| and |*out_alg| to the signature and
1171
+ // signature algorithm of |req|, respectively. Either output pointer may be NULL
1172
+ // to ignore the value.
1090
1173
  OPENSSL_EXPORT void X509_REQ_get0_signature(const X509_REQ *req,
1091
- const ASN1_BIT_STRING **psig,
1092
- const X509_ALGOR **palg);
1174
+ const ASN1_BIT_STRING **out_sig,
1175
+ const X509_ALGOR **out_alg);
1176
+
1177
+ // X509_REQ_get_signature_nid returns the NID corresponding to |req|'s signature
1178
+ // algorithm, or |NID_undef| if the signature algorithm does not correspond to
1179
+ // a known NID.
1093
1180
  OPENSSL_EXPORT int X509_REQ_get_signature_nid(const X509_REQ *req);
1094
- OPENSSL_EXPORT int i2d_re_X509_REQ_tbs(X509_REQ *req, unsigned char **pp);
1095
- OPENSSL_EXPORT int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);
1181
+
1182
+ // i2d_re_X509_REQ_tbs serializes the CertificationRequestInfo (see RFC2986)
1183
+ // portion of |req|. If |outp| is NULL, nothing is written. Otherwise, if
1184
+ // |*outp| is not NULL, the result is written to |*outp|, which must have enough
1185
+ // space available, and |*outp| is advanced just past the output. If |outp| is
1186
+ // non-NULL and |*outp| is NULL, it sets |*outp| to a newly-allocated buffer
1187
+ // containing the result. The caller is responsible for releasing the buffer
1188
+ // with |OPENSSL_free|. In all cases, this function returns the number of bytes
1189
+ // in the result, whether written or not, or a negative value on error.
1190
+ //
1191
+ // This function re-encodes the CertificationRequestInfo and may not reflect
1192
+ // |req|'s original encoding. It may be used to manually generate a signature
1193
+ // for a new certificate request.
1194
+ OPENSSL_EXPORT int i2d_re_X509_REQ_tbs(X509_REQ *req, uint8_t **outp);
1195
+
1196
+ // X509_REQ_set_pubkey sets |req|'s public key to |pkey|. It returns one on
1197
+ // success and zero on error. This function does not take ownership of |pkey|
1198
+ // and internally copies and updates reference counts as needed.
1199
+ OPENSSL_EXPORT int X509_REQ_set_pubkey(X509_REQ *req, EVP_PKEY *pkey);
1200
+
1201
+ // X509_REQ_get_pubkey returns |req|'s public key as an |EVP_PKEY|, or NULL if
1202
+ // the public key was unsupported or could not be decoded. This function returns
1203
+ // a reference to the |EVP_PKEY|. The caller must release the result with
1204
+ // |EVP_PKEY_free| when done.
1096
1205
  OPENSSL_EXPORT EVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req);
1206
+
1207
+ // X509_REQ_extension_nid returns one if |nid| is a supported CSR attribute type
1208
+ // for carrying extensions and zero otherwise. The supported types are
1209
+ // |NID_ext_req| (pkcs-9-at-extensionRequest from RFC2985) and |NID_ms_ext_req|
1210
+ // (a Microsoft szOID_CERT_EXTENSIONS variant).
1097
1211
  OPENSSL_EXPORT int X509_REQ_extension_nid(int nid);
1098
- OPENSSL_EXPORT const int *X509_REQ_get_extension_nids(void);
1099
- OPENSSL_EXPORT void X509_REQ_set_extension_nids(const int *nids);
1212
+
1213
+ // X509_REQ_get_extensions decodes the list of requested extensions in |req| and
1214
+ // returns a newly-allocated |STACK_OF(X509_EXTENSION)| containing the result.
1215
+ // It returns NULL on error, or if |req| did not request extensions.
1216
+ //
1217
+ // This function supports both pkcs-9-at-extensionRequest from RFC2985 and the
1218
+ // Microsoft szOID_CERT_EXTENSIONS variant.
1100
1219
  OPENSSL_EXPORT STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req);
1101
- OPENSSL_EXPORT int X509_REQ_add_extensions_nid(X509_REQ *req,
1102
- STACK_OF(X509_EXTENSION) *exts,
1103
- int nid);
1104
- OPENSSL_EXPORT int X509_REQ_add_extensions(X509_REQ *req,
1105
- STACK_OF(X509_EXTENSION) *exts);
1220
+
1221
+ // X509_REQ_add_extensions_nid adds an attribute to |req| of type |nid|, to
1222
+ // request the certificate extensions in |exts|. It returns one on success and
1223
+ // zero on error. |nid| should be |NID_ext_req| or |NID_ms_ext_req|.
1224
+ OPENSSL_EXPORT int X509_REQ_add_extensions_nid(
1225
+ X509_REQ *req, const STACK_OF(X509_EXTENSION) *exts, int nid);
1226
+
1227
+ // X509_REQ_add_extensions behaves like |X509_REQ_add_extensions_nid|, using the
1228
+ // standard |NID_ext_req| for the attribute type.
1229
+ OPENSSL_EXPORT int X509_REQ_add_extensions(
1230
+ X509_REQ *req, const STACK_OF(X509_EXTENSION) *exts);
1231
+
1232
+ // X509_REQ_get_attr_count returns the number of attributes in |req|.
1106
1233
  OPENSSL_EXPORT int X509_REQ_get_attr_count(const X509_REQ *req);
1234
+
1235
+ // X509_REQ_get_attr_by_NID returns the index of the attribute in |req| of type
1236
+ // |nid|, or a negative number if not found. If found, callers can use
1237
+ // |X509_REQ_get_attr| to look up the attribute by index.
1238
+ //
1239
+ // If |lastpos| is non-negative, it begins searching at |lastpos| + 1. Callers
1240
+ // can thus loop over all matching attributes by first passing -1 and then
1241
+ // passing the previously-returned value until no match is returned.
1107
1242
  OPENSSL_EXPORT int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid,
1108
1243
  int lastpos);
1244
+
1245
+ // X509_REQ_get_attr_by_OBJ behaves like |X509_REQ_get_attr_by_NID| but looks
1246
+ // for attributes of type |obj|.
1109
1247
  OPENSSL_EXPORT int X509_REQ_get_attr_by_OBJ(const X509_REQ *req,
1110
- ASN1_OBJECT *obj, int lastpos);
1248
+ const ASN1_OBJECT *obj,
1249
+ int lastpos);
1250
+
1251
+ // X509_REQ_get_attr returns the attribute at index |loc| in |req|, or NULL if
1252
+ // out of bounds.
1111
1253
  OPENSSL_EXPORT X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc);
1254
+
1255
+ // X509_REQ_delete_attr removes the attribute at index |loc| in |req|. It
1256
+ // returns the removed attribute to the caller, or NULL if |loc| was out of
1257
+ // bounds. If non-NULL, the caller must release the result with
1258
+ // |X509_ATTRIBUTE_free| when done. It is also safe, but not necessary, to call
1259
+ // |X509_ATTRIBUTE_free| if the result is NULL.
1112
1260
  OPENSSL_EXPORT X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc);
1261
+
1262
+ // X509_REQ_add1_attr appends a copy of |attr| to |req|'s list of attributes. It
1263
+ // returns one on success and zero on error.
1264
+ //
1265
+ // TODO(https://crbug.com/boringssl/407): |attr| should be const.
1113
1266
  OPENSSL_EXPORT int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr);
1267
+
1268
+ // X509_REQ_add1_attr_by_OBJ appends a new attribute to |req| with type |obj|.
1269
+ // It returns one on success and zero on error. The value is determined by
1270
+ // |X509_ATTRIBUTE_set1_data|.
1271
+ //
1272
+ // WARNING: The interpretation of |attrtype|, |data|, and |len| is complex and
1273
+ // error-prone. See |X509_ATTRIBUTE_set1_data| for details.
1114
1274
  OPENSSL_EXPORT int X509_REQ_add1_attr_by_OBJ(X509_REQ *req,
1115
- const ASN1_OBJECT *obj, int type,
1116
- const unsigned char *bytes,
1275
+ const ASN1_OBJECT *obj,
1276
+ int attrtype,
1277
+ const unsigned char *data,
1117
1278
  int len);
1118
- OPENSSL_EXPORT int X509_REQ_add1_attr_by_NID(X509_REQ *req, int nid, int type,
1119
- const unsigned char *bytes,
1279
+
1280
+ // X509_REQ_add1_attr_by_NID behaves like |X509_REQ_add1_attr_by_OBJ| except the
1281
+ // attribute type is determined by |nid|.
1282
+ OPENSSL_EXPORT int X509_REQ_add1_attr_by_NID(X509_REQ *req, int nid,
1283
+ int attrtype,
1284
+ const unsigned char *data,
1120
1285
  int len);
1286
+
1287
+ // X509_REQ_add1_attr_by_txt behaves like |X509_REQ_add1_attr_by_OBJ| except the
1288
+ // attribute type is determined by calling |OBJ_txt2obj| with |attrname|.
1121
1289
  OPENSSL_EXPORT int X509_REQ_add1_attr_by_txt(X509_REQ *req,
1122
- const char *attrname, int type,
1123
- const unsigned char *bytes,
1290
+ const char *attrname, int attrtype,
1291
+ const unsigned char *data,
1124
1292
  int len);
1125
1293
 
1126
- OPENSSL_EXPORT int X509_CRL_set_version(X509_CRL *x, long version);
1127
- OPENSSL_EXPORT int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name);
1294
+ // X509_CRL_set_version sets |crl|'s version to |version|, which should be one
1295
+ // of the |X509V*_VERSION| constants. It returns one on success and zero on
1296
+ // error.
1297
+ //
1298
+ // If unsure, use |X509V2_VERSION|. Note |X509V3_VERSION| is not defined for
1299
+ // CRLs.
1300
+ OPENSSL_EXPORT int X509_CRL_set_version(X509_CRL *crl, long version);
1301
+
1302
+ // X509_CRL_set_issuer_name sets |crl|'s issuer to a copy of |name|. It returns
1303
+ // one on success and zero on error.
1304
+ OPENSSL_EXPORT int X509_CRL_set_issuer_name(X509_CRL *crl, X509_NAME *name);
1305
+
1128
1306
  OPENSSL_EXPORT int X509_CRL_sort(X509_CRL *crl);
1307
+
1308
+ // X509_CRL_up_ref adds one to the reference count of |crl| and returns one.
1129
1309
  OPENSSL_EXPORT int X509_CRL_up_ref(X509_CRL *crl);
1130
1310
 
1311
+ // X509_CRL_get0_signature sets |*out_sig| and |*out_alg| to the signature and
1312
+ // signature algorithm of |crl|, respectively. Either output pointer may be NULL
1313
+ // to ignore the value.
1314
+ //
1315
+ // This function outputs the outer signature algorithm, not the one in the
1316
+ // TBSCertList. CRLs with mismatched signature algorithms will successfully
1317
+ // parse, but they will be rejected when verifying.
1131
1318
  OPENSSL_EXPORT void X509_CRL_get0_signature(const X509_CRL *crl,
1132
- const ASN1_BIT_STRING **psig,
1133
- const X509_ALGOR **palg);
1319
+ const ASN1_BIT_STRING **out_sig,
1320
+ const X509_ALGOR **out_alg);
1321
+
1322
+ // X509_CRL_get_signature_nid returns the NID corresponding to |crl|'s signature
1323
+ // algorithm, or |NID_undef| if the signature algorithm does not correspond to
1324
+ // a known NID.
1134
1325
  OPENSSL_EXPORT int X509_CRL_get_signature_nid(const X509_CRL *crl);
1135
1326
 
1136
1327
  // i2d_re_X509_CRL_tbs serializes the TBSCertList portion of |crl|. If |outp| is
@@ -1182,7 +1373,8 @@ OPENSSL_EXPORT const ASN1_TIME *X509_REVOKED_get0_revocationDate(
1182
1373
  OPENSSL_EXPORT int X509_REVOKED_set_revocationDate(X509_REVOKED *revoked,
1183
1374
  const ASN1_TIME *tm);
1184
1375
 
1185
- // X509_REVOKED_get0_extensions returns |r|'s extensions.
1376
+ // X509_REVOKED_get0_extensions returns |r|'s extensions list, or NULL if |r|
1377
+ // omits it.
1186
1378
  OPENSSL_EXPORT const STACK_OF(X509_EXTENSION) *X509_REVOKED_get0_extensions(
1187
1379
  const X509_REVOKED *r);
1188
1380
 
@@ -1198,6 +1390,11 @@ OPENSSL_EXPORT int X509_chain_check_suiteb(int *perror_depth, X509 *x,
1198
1390
  unsigned long flags);
1199
1391
  OPENSSL_EXPORT int X509_CRL_check_suiteb(X509_CRL *crl, EVP_PKEY *pk,
1200
1392
  unsigned long flags);
1393
+
1394
+ // X509_chain_up_ref returns a newly-allocated |STACK_OF(X509)| containing a
1395
+ // shallow copy of |chain|, or NULL on error. That is, the return value has the
1396
+ // same contents as |chain|, and each |X509|'s reference count is incremented by
1397
+ // one.
1201
1398
  OPENSSL_EXPORT STACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *chain);
1202
1399
 
1203
1400
  OPENSSL_EXPORT int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b);
@@ -1431,22 +1628,96 @@ OPENSSL_EXPORT STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(
1431
1628
  OPENSSL_EXPORT void *X509at_get0_data_by_OBJ(STACK_OF(X509_ATTRIBUTE) *x,
1432
1629
  ASN1_OBJECT *obj, int lastpos,
1433
1630
  int type);
1631
+
1632
+ // X509_ATTRIBUTE_create_by_NID returns a newly-allocated |X509_ATTRIBUTE| of
1633
+ // type |nid|, or NULL on error. The value is determined as in
1634
+ // |X509_ATTRIBUTE_set1_data|.
1635
+ //
1636
+ // If |attr| is non-NULL, the resulting |X509_ATTRIBUTE| is also written to
1637
+ // |*attr|. If |*attr| was non-NULL when the function was called, |*attr| is
1638
+ // reused instead of creating a new object.
1639
+ //
1640
+ // WARNING: The interpretation of |attrtype|, |data|, and |len| is complex and
1641
+ // error-prone. See |X509_ATTRIBUTE_set1_data| for details.
1642
+ //
1643
+ // WARNING: The object reuse form is deprecated and may be removed in the
1644
+ // future. It also currently incorrectly appends to the reused object's value
1645
+ // set rather than overwriting it.
1434
1646
  OPENSSL_EXPORT X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(
1435
- X509_ATTRIBUTE **attr, int nid, int atrtype, const void *data, int len);
1647
+ X509_ATTRIBUTE **attr, int nid, int attrtype, const void *data, int len);
1648
+
1649
+ // X509_ATTRIBUTE_create_by_OBJ behaves like |X509_ATTRIBUTE_create_by_NID|
1650
+ // except the attribute's type is determined by |obj|.
1436
1651
  OPENSSL_EXPORT X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(
1437
- X509_ATTRIBUTE **attr, const ASN1_OBJECT *obj, int atrtype,
1652
+ X509_ATTRIBUTE **attr, const ASN1_OBJECT *obj, int attrtype,
1438
1653
  const void *data, int len);
1654
+
1655
+ // X509_ATTRIBUTE_create_by_txt behaves like |X509_ATTRIBUTE_create_by_NID|
1656
+ // except the attribute's type is determined by calling |OBJ_txt2obj| with
1657
+ // |attrname|.
1439
1658
  OPENSSL_EXPORT X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(
1440
- X509_ATTRIBUTE **attr, const char *atrname, int type,
1659
+ X509_ATTRIBUTE **attr, const char *attrname, int type,
1441
1660
  const unsigned char *bytes, int len);
1661
+
1662
+ // X509_ATTRIBUTE_set1_object sets |attr|'s type to |obj|. It returns one on
1663
+ // success and zero on error.
1442
1664
  OPENSSL_EXPORT int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr,
1443
1665
  const ASN1_OBJECT *obj);
1666
+
1667
+ // X509_ATTRIBUTE_set1_data appends a value to |attr|'s value set and returns
1668
+ // one on success or zero on error. The value is determined as follows:
1669
+ //
1670
+ // If |attrtype| is a |MBSTRING_*| constant, the value is an ASN.1 string. The
1671
+ // string is determined by decoding |len| bytes from |data| in the encoding
1672
+ // specified by |attrtype|, and then re-encoding it in a form appropriate for
1673
+ // |attr|'s type. If |len| is -1, |strlen(data)| is used instead. See
1674
+ // |ASN1_STRING_set_by_NID| for details.
1675
+ //
1676
+ // TODO(davidben): Document |ASN1_STRING_set_by_NID| so the reference is useful.
1677
+ //
1678
+ // Otherwise, if |len| is not -1, the value is an ASN.1 string. |attrtype| is an
1679
+ // |ASN1_STRING| type value and the |len| bytes from |data| are copied as the
1680
+ // type-specific representation of |ASN1_STRING|. See |ASN1_STRING| for details.
1681
+ //
1682
+ // WARNING: If this form is used to construct a negative INTEGER or ENUMERATED,
1683
+ // |attrtype| includes the |V_ASN1_NEG| flag for |ASN1_STRING|, but the function
1684
+ // forgets to clear the flag for |ASN1_TYPE|. This matches OpenSSL but is
1685
+ // probably a bug. For now, do not use this form with negative values.
1686
+ //
1687
+ // Otherwise, if |len| is -1, the value is constructed by passing |attrtype| and
1688
+ // |data| to |ASN1_TYPE_set1|. That is, |attrtype| is an |ASN1_TYPE| type value,
1689
+ // and |data| is cast to the corresponding pointer type.
1690
+ //
1691
+ // WARNING: Despite the name, this function appends to |attr|'s value set,
1692
+ // rather than overwriting it. To overwrite the value set, create a new
1693
+ // |X509_ATTRIBUTE| with |X509_ATTRIBUTE_new|.
1694
+ //
1695
+ // WARNING: If using the |MBSTRING_*| form, pass a length rather than relying on
1696
+ // |strlen|. In particular, |strlen| will not behave correctly if the input is
1697
+ // |MBSTRING_BMP| or |MBSTRING_UNIV|.
1698
+ //
1699
+ // WARNING: This function currently misinterprets |V_ASN1_OTHER| as an
1700
+ // |MBSTRING_*| constant. This matches OpenSSL but means it is impossible to
1701
+ // construct a value with a non-universal tag.
1444
1702
  OPENSSL_EXPORT int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype,
1445
1703
  const void *data, int len);
1704
+
1705
+ // X509_ATTRIBUTE_get0_data returns the |idx|th value of |attr| in a
1706
+ // type-specific representation to |attrtype|, or NULL if out of bounds or the
1707
+ // type does not match. |attrtype| is one of the type values in |ASN1_TYPE|. On
1708
+ // match, the return value uses the same representation as |ASN1_TYPE_set0|. See
1709
+ // |ASN1_TYPE| for details.
1446
1710
  OPENSSL_EXPORT void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx,
1447
- int atrtype, void *data);
1448
- OPENSSL_EXPORT int X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr);
1711
+ int attrtype, void *unused);
1712
+
1713
+ // X509_ATTRIBUTE_count returns the number of values in |attr|.
1714
+ OPENSSL_EXPORT int X509_ATTRIBUTE_count(const X509_ATTRIBUTE *attr);
1715
+
1716
+ // X509_ATTRIBUTE_get0_object returns the type of |attr|.
1449
1717
  OPENSSL_EXPORT ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr);
1718
+
1719
+ // X509_ATTRIBUTE_get0_type returns the |idx|th value in |attr|, or NULL if out
1720
+ // of bounds. Note this function returns one of |attr|'s values, not the type.
1450
1721
  OPENSSL_EXPORT ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr,
1451
1722
  int idx);
1452
1723
 
@@ -1472,13 +1743,36 @@ OPENSSL_EXPORT int PKCS8_pkey_get0(ASN1_OBJECT **ppkalg,
1472
1743
  const unsigned char **pk, int *ppklen,
1473
1744
  X509_ALGOR **pa, PKCS8_PRIV_KEY_INFO *p8);
1474
1745
 
1475
- OPENSSL_EXPORT int X509_PUBKEY_set0_param(X509_PUBKEY *pub,
1476
- const ASN1_OBJECT *aobj, int ptype,
1477
- void *pval, unsigned char *penc,
1478
- int penclen);
1479
- OPENSSL_EXPORT int X509_PUBKEY_get0_param(ASN1_OBJECT **ppkalg,
1480
- const unsigned char **pk, int *ppklen,
1481
- X509_ALGOR **pa, X509_PUBKEY *pub);
1746
+ // X509_PUBKEY_set0_param sets |pub| to a key with AlgorithmIdentifier
1747
+ // determined by |obj|, |param_type|, and |param_value|, and an encoded
1748
+ // public key of |key|. On success, it takes ownership of all its parameters and
1749
+ // returns one. Otherwise, it returns zero. |key| must have been allocated by
1750
+ // |OPENSSL_malloc|.
1751
+ //
1752
+ // |obj|, |param_type|, and |param_value| are interpreted as in
1753
+ // |X509_ALGOR_set0|. See |X509_ALGOR_set0| for details.
1754
+ OPENSSL_EXPORT int X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *obj,
1755
+ int param_type, void *param_value,
1756
+ uint8_t *key, int key_len);
1757
+
1758
+ // X509_PUBKEY_get0_param outputs fields of |pub| and returns one. If |out_obj|
1759
+ // is not NULL, it sets |*out_obj| to AlgorithmIdentifier's OID. If |out_key|
1760
+ // is not NULL, it sets |*out_key| and |*out_key_len| to the encoded public key.
1761
+ // If |out_alg| is not NULL, it sets |*out_alg| to the AlgorithmIdentifier.
1762
+ //
1763
+ // Note: X.509 SubjectPublicKeyInfo structures store the encoded public key as a
1764
+ // BIT STRING. |*out_key| and |*out_key_len| will silently pad the key with zero
1765
+ // bits if |pub| did not contain a whole number of bytes. Use
1766
+ // |X509_PUBKEY_get0_public_key| to preserve this information.
1767
+ OPENSSL_EXPORT int X509_PUBKEY_get0_param(ASN1_OBJECT **out_obj,
1768
+ const uint8_t **out_key,
1769
+ int *out_key_len,
1770
+ X509_ALGOR **out_alg,
1771
+ X509_PUBKEY *pub);
1772
+
1773
+ // X509_PUBKEY_get0_public_key returns |pub|'s encoded public key.
1774
+ OPENSSL_EXPORT const ASN1_BIT_STRING *X509_PUBKEY_get0_public_key(
1775
+ const X509_PUBKEY *pub);
1482
1776
 
1483
1777
  OPENSSL_EXPORT int X509_check_trust(X509 *x, int id, int flags);
1484
1778
  OPENSSL_EXPORT int X509_TRUST_get_count(void);
@@ -1518,6 +1812,7 @@ BORINGSSL_MAKE_DELETER(RSA_PSS_PARAMS, RSA_PSS_PARAMS_free)
1518
1812
  BORINGSSL_MAKE_DELETER(X509, X509_free)
1519
1813
  BORINGSSL_MAKE_UP_REF(X509, X509_up_ref)
1520
1814
  BORINGSSL_MAKE_DELETER(X509_ALGOR, X509_ALGOR_free)
1815
+ BORINGSSL_MAKE_DELETER(X509_ATTRIBUTE, X509_ATTRIBUTE_free)
1521
1816
  BORINGSSL_MAKE_DELETER(X509_CRL, X509_CRL_free)
1522
1817
  BORINGSSL_MAKE_UP_REF(X509_CRL, X509_CRL_up_ref)
1523
1818
  BORINGSSL_MAKE_DELETER(X509_CRL_METHOD, X509_CRL_METHOD_free)