grpc 1.43.1 → 1.44.0.pre2

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 (382) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +84 -64
  3. data/include/grpc/grpc_security.h +10 -0
  4. data/include/grpc/impl/codegen/compression_types.h +0 -2
  5. data/include/grpc/impl/codegen/grpc_types.h +6 -0
  6. data/src/core/ext/filters/client_channel/backend_metric.h +1 -1
  7. data/src/core/ext/filters/client_channel/client_channel.cc +62 -68
  8. data/src/core/ext/filters/client_channel/client_channel.h +8 -8
  9. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +1 -1
  10. data/src/core/ext/filters/client_channel/config_selector.h +4 -4
  11. data/src/core/ext/filters/client_channel/dynamic_filters.h +1 -1
  12. data/src/core/ext/filters/client_channel/health/health_check_client.cc +16 -14
  13. data/src/core/ext/filters/client_channel/health/health_check_client.h +3 -3
  14. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +1 -1
  15. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +4 -3
  16. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +6 -5
  17. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +3 -7
  18. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +31 -32
  19. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +0 -7
  20. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +1 -1
  21. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +1 -1
  22. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +1 -1
  23. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +43 -29
  24. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +6 -2
  25. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +120 -68
  26. data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +60 -48
  27. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +62 -61
  28. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +16 -11
  29. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +11 -5
  30. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +19 -15
  31. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.h +1 -1
  32. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +14 -12
  33. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +3 -2
  34. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +50 -105
  35. data/src/core/ext/filters/client_channel/lb_policy.cc +15 -14
  36. data/src/core/ext/filters/client_channel/lb_policy.h +19 -3
  37. data/src/core/ext/filters/client_channel/resolver/binder/binder_resolver.cc +3 -3
  38. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +207 -81
  39. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +22 -12
  40. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +19 -15
  41. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +23 -38
  42. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +118 -207
  43. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +25 -32
  44. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +1 -1
  45. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +82 -73
  46. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +10 -10
  47. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +2 -1
  48. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +2 -5
  49. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +5 -5
  50. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +157 -67
  51. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +1 -1
  52. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +2 -2
  53. data/src/core/ext/filters/client_channel/retry_filter.cc +37 -64
  54. data/src/core/ext/filters/client_channel/retry_service_config.cc +1 -1
  55. data/src/core/ext/filters/client_channel/retry_service_config.h +1 -1
  56. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +1 -1
  57. data/src/core/ext/filters/client_channel/subchannel.cc +12 -16
  58. data/src/core/ext/filters/client_channel/subchannel.h +2 -3
  59. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +37 -48
  60. data/src/core/ext/filters/fault_injection/service_config_parser.cc +6 -8
  61. data/src/core/ext/filters/fault_injection/service_config_parser.h +1 -1
  62. data/src/core/ext/filters/http/client/http_client_filter.cc +51 -122
  63. data/src/core/ext/filters/http/client_authority_filter.cc +8 -24
  64. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +42 -140
  65. data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +5 -25
  66. data/src/core/ext/filters/http/server/http_server_filter.cc +50 -135
  67. data/src/core/ext/filters/message_size/message_size_filter.cc +1 -1
  68. data/src/core/ext/filters/message_size/message_size_filter.h +1 -1
  69. data/src/core/ext/filters/rbac/rbac_filter.cc +157 -0
  70. data/src/core/ext/filters/rbac/rbac_filter.h +74 -0
  71. data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +605 -0
  72. data/src/core/ext/filters/rbac/rbac_service_config_parser.h +70 -0
  73. data/src/core/ext/filters/server_config_selector/server_config_selector.h +3 -2
  74. data/src/core/ext/filters/server_config_selector/server_config_selector_filter.cc +11 -6
  75. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +1 -1
  76. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +1 -1
  77. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +89 -29
  78. data/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +0 -1
  79. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +45 -186
  80. data/src/core/ext/transport/chttp2/transport/frame_data.cc +0 -1
  81. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +341 -279
  82. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +69 -159
  83. data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc +1 -1
  84. data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.h +2 -0
  85. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +19 -32
  86. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +0 -1
  87. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +94 -1
  88. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +2 -24
  89. data/src/core/ext/transport/chttp2/transport/internal.h +0 -33
  90. data/src/core/ext/transport/chttp2/transport/parsing.cc +0 -6
  91. data/src/core/ext/transport/chttp2/transport/writing.cc +47 -116
  92. data/src/core/ext/transport/inproc/inproc_plugin.cc +0 -4
  93. data/src/core/ext/transport/inproc/inproc_transport.cc +11 -63
  94. data/src/core/ext/transport/inproc/inproc_transport.h +0 -3
  95. data/src/core/ext/upb-generated/envoy/extensions/filters/http/rbac/v3/rbac.upb.c +61 -0
  96. data/src/core/ext/upb-generated/envoy/extensions/filters/http/rbac/v3/rbac.upb.h +146 -0
  97. data/src/core/ext/upbdefs-generated/envoy/config/rbac/v3/rbac.upbdefs.c +188 -0
  98. data/src/core/ext/upbdefs-generated/envoy/config/rbac/v3/rbac.upbdefs.h +70 -0
  99. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/rbac/v3/rbac.upbdefs.c +56 -0
  100. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/rbac/v3/rbac.upbdefs.h +40 -0
  101. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/checked.upbdefs.c +154 -0
  102. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/checked.upbdefs.h +95 -0
  103. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/eval.upbdefs.c +58 -0
  104. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/eval.upbdefs.h +55 -0
  105. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/explain.upbdefs.c +44 -0
  106. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/explain.upbdefs.h +40 -0
  107. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/syntax.upbdefs.c +153 -0
  108. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/syntax.upbdefs.h +100 -0
  109. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/value.upbdefs.c +75 -0
  110. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/value.upbdefs.h +55 -0
  111. data/src/core/ext/xds/upb_utils.h +65 -0
  112. data/src/core/ext/xds/xds_api.cc +81 -3458
  113. data/src/core/ext/xds/xds_api.h +56 -611
  114. data/src/core/ext/xds/xds_bootstrap.cc +189 -125
  115. data/src/core/ext/xds/xds_bootstrap.h +20 -15
  116. data/src/core/ext/xds/xds_certificate_provider.h +1 -0
  117. data/src/core/ext/xds/xds_channel_creds.cc +108 -0
  118. data/src/core/ext/xds/xds_channel_creds.h +50 -0
  119. data/src/core/ext/xds/xds_client.cc +584 -994
  120. data/src/core/ext/xds/xds_client.h +78 -135
  121. data/src/core/ext/xds/xds_cluster.cc +451 -0
  122. data/src/core/ext/xds/xds_cluster.h +111 -0
  123. data/src/core/ext/xds/xds_common_types.cc +388 -0
  124. data/src/core/ext/xds/xds_common_types.h +110 -0
  125. data/src/core/ext/xds/xds_endpoint.cc +364 -0
  126. data/src/core/ext/xds/xds_endpoint.h +135 -0
  127. data/src/core/ext/xds/xds_http_filters.cc +5 -0
  128. data/src/core/ext/xds/xds_http_rbac_filter.cc +563 -0
  129. data/src/core/ext/xds/xds_http_rbac_filter.h +54 -0
  130. data/src/core/ext/xds/xds_listener.cc +1036 -0
  131. data/src/core/ext/xds/xds_listener.h +220 -0
  132. data/src/core/ext/{transport/chttp2/transport/hpack_utils.h → xds/xds_resource_type.cc} +12 -9
  133. data/src/core/ext/xds/xds_resource_type.h +98 -0
  134. data/src/core/ext/xds/xds_resource_type_impl.h +87 -0
  135. data/src/core/ext/xds/xds_route_config.cc +993 -0
  136. data/src/core/ext/xds/xds_route_config.h +215 -0
  137. data/src/core/ext/xds/xds_routing.cc +11 -8
  138. data/src/core/ext/xds/xds_routing.h +8 -5
  139. data/src/core/ext/xds/xds_server_config_fetcher.cc +159 -99
  140. data/src/core/lib/address_utils/parse_address.cc +20 -0
  141. data/src/core/lib/address_utils/parse_address.h +5 -0
  142. data/src/core/lib/address_utils/sockaddr_utils.cc +33 -36
  143. data/src/core/lib/address_utils/sockaddr_utils.h +1 -16
  144. data/src/core/lib/backoff/backoff.cc +4 -30
  145. data/src/core/lib/backoff/backoff.h +3 -3
  146. data/src/core/lib/channel/channel_args.cc +0 -1
  147. data/src/core/lib/channel/channel_stack.cc +8 -0
  148. data/src/core/lib/channel/channel_stack.h +1 -1
  149. data/src/core/lib/channel/channel_stack_builder.cc +5 -9
  150. data/src/core/lib/channel/channel_stack_builder.h +4 -7
  151. data/src/core/lib/channel/channelz.cc +1 -0
  152. data/src/core/lib/compression/compression.cc +19 -111
  153. data/src/core/lib/compression/compression_internal.cc +142 -202
  154. data/src/core/lib/compression/compression_internal.h +64 -69
  155. data/src/core/lib/compression/message_compress.cc +11 -11
  156. data/src/core/lib/compression/message_compress.h +2 -2
  157. data/src/core/lib/gpr/useful.h +4 -0
  158. data/src/core/lib/gprpp/bitset.h +7 -0
  159. data/src/core/lib/gprpp/chunked_vector.h +45 -3
  160. data/src/core/lib/gprpp/status_helper.cc +20 -28
  161. data/src/core/lib/gprpp/status_helper.h +6 -19
  162. data/src/core/lib/gprpp/table.h +11 -0
  163. data/src/core/lib/http/httpcli.cc +37 -46
  164. data/src/core/lib/http/httpcli.h +3 -15
  165. data/src/core/lib/iomgr/call_combiner.cc +15 -4
  166. data/src/core/lib/iomgr/closure.h +29 -9
  167. data/src/core/lib/iomgr/combiner.cc +25 -3
  168. data/src/core/lib/iomgr/error.cc +2 -0
  169. data/src/core/lib/iomgr/error.h +3 -0
  170. data/src/core/lib/iomgr/event_engine/iomgr.cc +3 -2
  171. data/src/core/lib/iomgr/event_engine/resolved_address_internal.cc +6 -0
  172. data/src/core/lib/iomgr/event_engine/resolved_address_internal.h +2 -0
  173. data/src/core/lib/iomgr/event_engine/resolver.cc +66 -48
  174. data/src/core/lib/iomgr/event_engine/resolver.h +56 -0
  175. data/src/core/lib/iomgr/exec_ctx.cc +22 -9
  176. data/src/core/lib/iomgr/executor.cc +10 -1
  177. data/src/core/lib/iomgr/fork_posix.cc +3 -2
  178. data/src/core/lib/iomgr/iomgr_custom.cc +4 -1
  179. data/src/core/lib/iomgr/iomgr_posix.cc +2 -2
  180. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +2 -2
  181. data/src/core/lib/iomgr/iomgr_windows.cc +2 -2
  182. data/src/core/lib/iomgr/port.h +2 -2
  183. data/src/core/lib/iomgr/resolve_address.cc +5 -24
  184. data/src/core/lib/iomgr/resolve_address.h +47 -44
  185. data/src/core/lib/iomgr/resolve_address_custom.cc +131 -109
  186. data/src/core/lib/iomgr/resolve_address_custom.h +101 -19
  187. data/src/core/lib/iomgr/resolve_address_impl.h +59 -0
  188. data/src/core/lib/iomgr/resolve_address_posix.cc +82 -66
  189. data/src/core/lib/iomgr/resolve_address_posix.h +47 -0
  190. data/src/core/lib/iomgr/resolve_address_windows.cc +93 -74
  191. data/src/core/lib/iomgr/resolve_address_windows.h +47 -0
  192. data/src/core/lib/iomgr/resolved_address.h +39 -0
  193. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +1 -0
  194. data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +1 -0
  195. data/src/core/lib/iomgr/unix_sockets_posix.cc +22 -34
  196. data/src/core/lib/iomgr/unix_sockets_posix.h +4 -7
  197. data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +6 -15
  198. data/src/core/lib/matchers/matchers.cc +1 -1
  199. data/src/core/lib/promise/activity.h +49 -20
  200. data/src/core/lib/promise/detail/status.h +5 -0
  201. data/src/core/{ext/filters/client_channel → lib/resolver}/resolver.cc +17 -25
  202. data/src/core/{ext/filters/client_channel → lib/resolver}/resolver.h +43 -44
  203. data/src/core/{ext/filters/client_channel → lib/resolver}/resolver_factory.h +10 -5
  204. data/src/core/{ext/filters/client_channel → lib/resolver}/resolver_registry.cc +3 -2
  205. data/src/core/{ext/filters/client_channel → lib/resolver}/resolver_registry.h +4 -5
  206. data/src/core/{ext/filters/client_channel → lib/resolver}/server_address.cc +1 -1
  207. data/src/core/{ext/filters/client_channel → lib/resolver}/server_address.h +4 -4
  208. data/src/core/lib/resource_quota/api.h +0 -1
  209. data/src/core/lib/{gprpp → resource_quota}/arena.cc +16 -13
  210. data/src/core/lib/{gprpp → resource_quota}/arena.h +24 -13
  211. data/src/core/lib/security/authorization/evaluate_args.cc +30 -15
  212. data/src/core/lib/security/authorization/evaluate_args.h +1 -0
  213. data/src/core/lib/security/authorization/grpc_authorization_engine.cc +60 -0
  214. data/src/core/lib/security/authorization/grpc_authorization_engine.h +62 -0
  215. data/src/core/lib/security/authorization/matchers.cc +227 -0
  216. data/src/core/lib/security/authorization/matchers.h +211 -0
  217. data/src/core/lib/security/authorization/rbac_policy.cc +442 -0
  218. data/src/core/lib/security/authorization/rbac_policy.h +170 -0
  219. data/src/core/lib/security/context/security_context.cc +4 -2
  220. data/src/core/lib/security/context/security_context.h +1 -1
  221. data/src/core/lib/security/credentials/composite/composite_credentials.cc +5 -5
  222. data/src/core/lib/security/credentials/composite/composite_credentials.h +4 -3
  223. data/src/core/lib/security/credentials/credentials.h +10 -20
  224. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +6 -9
  225. data/src/core/lib/security/credentials/external/external_account_credentials.cc +7 -9
  226. data/src/core/lib/security/credentials/external/external_account_credentials.h +2 -7
  227. data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +2 -3
  228. data/src/core/lib/security/credentials/fake/fake_credentials.cc +5 -4
  229. data/src/core/lib/security/credentials/fake/fake_credentials.h +8 -7
  230. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +2 -5
  231. data/src/core/lib/security/credentials/iam/iam_credentials.cc +16 -19
  232. data/src/core/lib/security/credentials/iam/iam_credentials.h +6 -5
  233. data/src/core/lib/security/credentials/jwt/json_token.cc +4 -6
  234. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +16 -28
  235. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +8 -8
  236. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +6 -13
  237. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +44 -57
  238. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +13 -15
  239. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +6 -7
  240. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +5 -4
  241. data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +1 -10
  242. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +6 -0
  243. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +7 -0
  244. data/src/core/lib/security/credentials/xds/xds_credentials.h +1 -1
  245. data/src/core/lib/security/security_connector/security_connector.cc +0 -4
  246. data/src/core/lib/security/security_connector/security_connector.h +5 -1
  247. data/src/core/lib/security/security_connector/ssl_utils.cc +14 -24
  248. data/src/core/lib/security/security_connector/ssl_utils.h +5 -14
  249. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +2 -3
  250. data/src/core/lib/security/transport/auth_filters.h +7 -0
  251. data/src/core/lib/security/transport/client_auth_filter.cc +53 -33
  252. data/src/core/lib/security/transport/server_auth_filter.cc +40 -35
  253. data/src/core/{ext → lib}/service_config/service_config.cc +2 -2
  254. data/src/core/{ext → lib}/service_config/service_config.h +4 -4
  255. data/src/core/{ext → lib}/service_config/service_config_call_data.h +5 -5
  256. data/src/core/{ext → lib}/service_config/service_config_parser.cc +1 -1
  257. data/src/core/{ext → lib}/service_config/service_config_parser.h +3 -3
  258. data/src/core/lib/slice/slice.cc +3 -1
  259. data/src/core/lib/slice/slice.h +43 -13
  260. data/src/core/lib/slice/slice_intern.cc +3 -101
  261. data/src/core/lib/slice/slice_internal.h +1 -2
  262. data/src/core/lib/slice/slice_refcount.h +4 -13
  263. data/src/core/lib/slice/slice_refcount_base.h +0 -16
  264. data/src/core/lib/surface/call.cc +140 -382
  265. data/src/core/lib/surface/call.h +4 -4
  266. data/src/core/lib/surface/channel.cc +42 -44
  267. data/src/core/lib/surface/channel.h +4 -4
  268. data/src/core/lib/surface/init.cc +0 -2
  269. data/src/core/lib/surface/lame_client.cc +0 -1
  270. data/src/core/lib/surface/server.cc +12 -29
  271. data/src/core/lib/surface/server.h +2 -2
  272. data/src/core/lib/surface/version.cc +2 -2
  273. data/src/core/lib/transport/error_utils.h +14 -0
  274. data/src/core/lib/transport/metadata_batch.h +799 -717
  275. data/src/core/lib/transport/parsed_metadata.cc +2 -0
  276. data/src/core/lib/transport/parsed_metadata.h +95 -92
  277. data/src/core/lib/transport/timeout_encoding.cc +200 -66
  278. data/src/core/lib/transport/timeout_encoding.h +40 -10
  279. data/src/core/lib/transport/transport.h +1 -1
  280. data/src/core/lib/transport/transport_op_string.cc +6 -39
  281. data/src/core/lib/uri/uri_parser.cc +223 -53
  282. data/src/core/lib/uri/uri_parser.h +36 -23
  283. data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -3
  284. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +1 -1
  285. data/src/core/tsi/ssl/session_cache/ssl_session.h +2 -4
  286. data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +3 -5
  287. data/src/core/tsi/ssl_transport_security.cc +53 -13
  288. data/src/core/tsi/ssl_transport_security.h +18 -6
  289. data/src/ruby/ext/grpc/extconf.rb +10 -3
  290. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
  291. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +3 -0
  292. data/src/ruby/lib/grpc/version.rb +1 -1
  293. data/src/ruby/pb/src/proto/grpc/testing/test_pb.rb +2 -1
  294. data/third_party/abseil-cpp/absl/base/internal/fast_type_id.h +48 -0
  295. data/third_party/abseil-cpp/absl/random/bernoulli_distribution.h +200 -0
  296. data/third_party/abseil-cpp/absl/random/beta_distribution.h +427 -0
  297. data/third_party/abseil-cpp/absl/random/discrete_distribution.cc +98 -0
  298. data/third_party/abseil-cpp/absl/random/discrete_distribution.h +247 -0
  299. data/third_party/abseil-cpp/absl/random/distributions.h +452 -0
  300. data/third_party/abseil-cpp/absl/random/exponential_distribution.h +165 -0
  301. data/third_party/abseil-cpp/absl/random/gaussian_distribution.cc +104 -0
  302. data/third_party/abseil-cpp/absl/random/gaussian_distribution.h +275 -0
  303. data/third_party/abseil-cpp/absl/random/internal/distribution_caller.h +92 -0
  304. data/third_party/abseil-cpp/absl/random/internal/fast_uniform_bits.h +268 -0
  305. data/third_party/abseil-cpp/absl/random/internal/fastmath.h +57 -0
  306. data/third_party/abseil-cpp/absl/random/internal/generate_real.h +144 -0
  307. data/third_party/abseil-cpp/absl/random/internal/iostream_state_saver.h +245 -0
  308. data/third_party/abseil-cpp/absl/random/internal/nonsecure_base.h +150 -0
  309. data/third_party/abseil-cpp/absl/random/internal/pcg_engine.h +308 -0
  310. data/third_party/abseil-cpp/absl/random/internal/platform.h +171 -0
  311. data/third_party/abseil-cpp/absl/random/internal/pool_urbg.cc +253 -0
  312. data/third_party/abseil-cpp/absl/random/internal/pool_urbg.h +131 -0
  313. data/third_party/abseil-cpp/absl/random/internal/randen.cc +91 -0
  314. data/third_party/abseil-cpp/absl/random/internal/randen.h +102 -0
  315. data/third_party/abseil-cpp/absl/random/internal/randen_detect.cc +221 -0
  316. data/third_party/abseil-cpp/absl/random/internal/randen_detect.h +33 -0
  317. data/third_party/abseil-cpp/absl/random/internal/randen_engine.h +239 -0
  318. data/third_party/abseil-cpp/absl/random/internal/randen_hwaes.cc +526 -0
  319. data/third_party/abseil-cpp/absl/random/internal/randen_hwaes.h +50 -0
  320. data/third_party/abseil-cpp/absl/random/internal/randen_round_keys.cc +462 -0
  321. data/third_party/abseil-cpp/absl/random/internal/randen_slow.cc +471 -0
  322. data/third_party/abseil-cpp/absl/random/internal/randen_slow.h +40 -0
  323. data/third_party/abseil-cpp/absl/random/internal/randen_traits.h +88 -0
  324. data/third_party/abseil-cpp/absl/random/internal/salted_seed_seq.h +167 -0
  325. data/third_party/abseil-cpp/absl/random/internal/seed_material.cc +267 -0
  326. data/third_party/abseil-cpp/absl/random/internal/seed_material.h +104 -0
  327. data/third_party/abseil-cpp/absl/random/internal/traits.h +101 -0
  328. data/third_party/abseil-cpp/absl/random/internal/uniform_helper.h +244 -0
  329. data/third_party/abseil-cpp/absl/random/internal/wide_multiply.h +111 -0
  330. data/third_party/abseil-cpp/absl/random/log_uniform_int_distribution.h +257 -0
  331. data/third_party/abseil-cpp/absl/random/poisson_distribution.h +258 -0
  332. data/third_party/abseil-cpp/absl/random/random.h +189 -0
  333. data/third_party/abseil-cpp/absl/random/seed_gen_exception.cc +46 -0
  334. data/third_party/abseil-cpp/absl/random/seed_gen_exception.h +55 -0
  335. data/third_party/abseil-cpp/absl/random/seed_sequences.cc +29 -0
  336. data/third_party/abseil-cpp/absl/random/seed_sequences.h +110 -0
  337. data/third_party/abseil-cpp/absl/random/uniform_int_distribution.h +275 -0
  338. data/third_party/abseil-cpp/absl/random/uniform_real_distribution.h +202 -0
  339. data/third_party/abseil-cpp/absl/random/zipf_distribution.h +271 -0
  340. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +1 -0
  341. data/third_party/boringssl-with-bazel/src/crypto/base64/base64.c +13 -0
  342. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +21 -0
  343. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/cipher.c +12 -0
  344. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +1 -2
  345. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +2 -2
  346. data/third_party/boringssl-with-bazel/src/crypto/mem.c +1 -1
  347. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7.c +29 -0
  348. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/internal.h +0 -1
  349. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8.c +1 -1
  350. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +1 -1
  351. data/third_party/boringssl-with-bazel/src/include/openssl/base64.h +8 -0
  352. data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +13 -1
  353. data/third_party/boringssl-with-bazel/src/include/openssl/dsa.h +10 -0
  354. data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +1 -1
  355. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +9 -4
  356. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs8.h +6 -1
  357. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +23 -2
  358. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +4 -0
  359. data/third_party/xxhash/xxhash.h +607 -352
  360. metadata +149 -77
  361. data/src/core/ext/transport/chttp2/transport/hpack_encoder_index.h +0 -107
  362. data/src/core/ext/transport/chttp2/transport/hpack_utils.cc +0 -46
  363. data/src/core/ext/transport/chttp2/transport/popularity_count.h +0 -60
  364. data/src/core/lib/compression/algorithm_metadata.h +0 -62
  365. data/src/core/lib/compression/compression_args.cc +0 -140
  366. data/src/core/lib/compression/compression_args.h +0 -58
  367. data/src/core/lib/compression/stream_compression.cc +0 -81
  368. data/src/core/lib/compression/stream_compression.h +0 -117
  369. data/src/core/lib/compression/stream_compression_gzip.cc +0 -231
  370. data/src/core/lib/compression/stream_compression_gzip.h +0 -28
  371. data/src/core/lib/compression/stream_compression_identity.cc +0 -91
  372. data/src/core/lib/compression/stream_compression_identity.h +0 -29
  373. data/src/core/lib/security/credentials/credentials_metadata.cc +0 -61
  374. data/src/core/lib/slice/static_slice.cc +0 -377
  375. data/src/core/lib/slice/static_slice.h +0 -300
  376. data/src/core/lib/transport/metadata.cc +0 -714
  377. data/src/core/lib/transport/metadata.h +0 -449
  378. data/src/core/lib/transport/metadata_batch.cc +0 -99
  379. data/src/core/lib/transport/static_metadata.cc +0 -1032
  380. data/src/core/lib/transport/static_metadata.h +0 -322
  381. data/src/core/lib/transport/status_metadata.cc +0 -63
  382. data/src/core/lib/transport/status_metadata.h +0 -48
@@ -0,0 +1,271 @@
1
+ // Copyright 2017 The Abseil Authors.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // https://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ #ifndef ABSL_RANDOM_ZIPF_DISTRIBUTION_H_
16
+ #define ABSL_RANDOM_ZIPF_DISTRIBUTION_H_
17
+
18
+ #include <cassert>
19
+ #include <cmath>
20
+ #include <istream>
21
+ #include <limits>
22
+ #include <ostream>
23
+ #include <type_traits>
24
+
25
+ #include "absl/random/internal/iostream_state_saver.h"
26
+ #include "absl/random/uniform_real_distribution.h"
27
+
28
+ namespace absl {
29
+ ABSL_NAMESPACE_BEGIN
30
+
31
+ // absl::zipf_distribution produces random integer-values in the range [0, k],
32
+ // distributed according to the discrete probability function:
33
+ //
34
+ // P(x) = (v + x) ^ -q
35
+ //
36
+ // The parameter `v` must be greater than 0 and the parameter `q` must be
37
+ // greater than 1. If either of these parameters take invalid values then the
38
+ // behavior is undefined.
39
+ //
40
+ // IntType is the result_type generated by the generator. It must be of integral
41
+ // type; a static_assert ensures this is the case.
42
+ //
43
+ // The implementation is based on W.Hormann, G.Derflinger:
44
+ //
45
+ // "Rejection-Inversion to Generate Variates from Monotone Discrete
46
+ // Distributions"
47
+ //
48
+ // http://eeyore.wu-wien.ac.at/papers/96-04-04.wh-der.ps.gz
49
+ //
50
+ template <typename IntType = int>
51
+ class zipf_distribution {
52
+ public:
53
+ using result_type = IntType;
54
+
55
+ class param_type {
56
+ public:
57
+ using distribution_type = zipf_distribution;
58
+
59
+ // Preconditions: k > 0, v > 0, q > 1
60
+ // The precondidtions are validated when NDEBUG is not defined via
61
+ // a pair of assert() directives.
62
+ // If NDEBUG is defined and either or both of these parameters take invalid
63
+ // values, the behavior of the class is undefined.
64
+ explicit param_type(result_type k = (std::numeric_limits<IntType>::max)(),
65
+ double q = 2.0, double v = 1.0);
66
+
67
+ result_type k() const { return k_; }
68
+ double q() const { return q_; }
69
+ double v() const { return v_; }
70
+
71
+ friend bool operator==(const param_type& a, const param_type& b) {
72
+ return a.k_ == b.k_ && a.q_ == b.q_ && a.v_ == b.v_;
73
+ }
74
+ friend bool operator!=(const param_type& a, const param_type& b) {
75
+ return !(a == b);
76
+ }
77
+
78
+ private:
79
+ friend class zipf_distribution;
80
+ inline double h(double x) const;
81
+ inline double hinv(double x) const;
82
+ inline double compute_s() const;
83
+ inline double pow_negative_q(double x) const;
84
+
85
+ // Parameters here are exactly the same as the parameters of Algorithm ZRI
86
+ // in the paper.
87
+ IntType k_;
88
+ double q_;
89
+ double v_;
90
+
91
+ double one_minus_q_; // 1-q
92
+ double s_;
93
+ double one_minus_q_inv_; // 1 / 1-q
94
+ double hxm_; // h(k + 0.5)
95
+ double hx0_minus_hxm_; // h(x0) - h(k + 0.5)
96
+
97
+ static_assert(std::is_integral<IntType>::value,
98
+ "Class-template absl::zipf_distribution<> must be "
99
+ "parameterized using an integral type.");
100
+ };
101
+
102
+ zipf_distribution()
103
+ : zipf_distribution((std::numeric_limits<IntType>::max)()) {}
104
+
105
+ explicit zipf_distribution(result_type k, double q = 2.0, double v = 1.0)
106
+ : param_(k, q, v) {}
107
+
108
+ explicit zipf_distribution(const param_type& p) : param_(p) {}
109
+
110
+ void reset() {}
111
+
112
+ template <typename URBG>
113
+ result_type operator()(URBG& g) { // NOLINT(runtime/references)
114
+ return (*this)(g, param_);
115
+ }
116
+
117
+ template <typename URBG>
118
+ result_type operator()(URBG& g, // NOLINT(runtime/references)
119
+ const param_type& p);
120
+
121
+ result_type k() const { return param_.k(); }
122
+ double q() const { return param_.q(); }
123
+ double v() const { return param_.v(); }
124
+
125
+ param_type param() const { return param_; }
126
+ void param(const param_type& p) { param_ = p; }
127
+
128
+ result_type(min)() const { return 0; }
129
+ result_type(max)() const { return k(); }
130
+
131
+ friend bool operator==(const zipf_distribution& a,
132
+ const zipf_distribution& b) {
133
+ return a.param_ == b.param_;
134
+ }
135
+ friend bool operator!=(const zipf_distribution& a,
136
+ const zipf_distribution& b) {
137
+ return a.param_ != b.param_;
138
+ }
139
+
140
+ private:
141
+ param_type param_;
142
+ };
143
+
144
+ // --------------------------------------------------------------------------
145
+ // Implementation details follow
146
+ // --------------------------------------------------------------------------
147
+
148
+ template <typename IntType>
149
+ zipf_distribution<IntType>::param_type::param_type(
150
+ typename zipf_distribution<IntType>::result_type k, double q, double v)
151
+ : k_(k), q_(q), v_(v), one_minus_q_(1 - q) {
152
+ assert(q > 1);
153
+ assert(v > 0);
154
+ assert(k > 0);
155
+ one_minus_q_inv_ = 1 / one_minus_q_;
156
+
157
+ // Setup for the ZRI algorithm (pg 17 of the paper).
158
+ // Compute: h(i max) => h(k + 0.5)
159
+ constexpr double kMax = 18446744073709549568.0;
160
+ double kd = static_cast<double>(k);
161
+ // TODO(absl-team): Determine if this check is needed, and if so, add a test
162
+ // that fails for k > kMax
163
+ if (kd > kMax) {
164
+ // Ensure that our maximum value is capped to a value which will
165
+ // round-trip back through double.
166
+ kd = kMax;
167
+ }
168
+ hxm_ = h(kd + 0.5);
169
+
170
+ // Compute: h(0)
171
+ const bool use_precomputed = (v == 1.0 && q == 2.0);
172
+ const double h0x5 = use_precomputed ? (-1.0 / 1.5) // exp(-log(1.5))
173
+ : h(0.5);
174
+ const double elogv_q = (v_ == 1.0) ? 1 : pow_negative_q(v_);
175
+
176
+ // h(0) = h(0.5) - exp(log(v) * -q)
177
+ hx0_minus_hxm_ = (h0x5 - elogv_q) - hxm_;
178
+
179
+ // And s
180
+ s_ = use_precomputed ? 0.46153846153846123 : compute_s();
181
+ }
182
+
183
+ template <typename IntType>
184
+ double zipf_distribution<IntType>::param_type::h(double x) const {
185
+ // std::exp(one_minus_q_ * std::log(v_ + x)) * one_minus_q_inv_;
186
+ x += v_;
187
+ return (one_minus_q_ == -1.0)
188
+ ? (-1.0 / x) // -exp(-log(x))
189
+ : (std::exp(std::log(x) * one_minus_q_) * one_minus_q_inv_);
190
+ }
191
+
192
+ template <typename IntType>
193
+ double zipf_distribution<IntType>::param_type::hinv(double x) const {
194
+ // std::exp(one_minus_q_inv_ * std::log(one_minus_q_ * x)) - v_;
195
+ return -v_ + ((one_minus_q_ == -1.0)
196
+ ? (-1.0 / x) // exp(-log(-x))
197
+ : std::exp(one_minus_q_inv_ * std::log(one_minus_q_ * x)));
198
+ }
199
+
200
+ template <typename IntType>
201
+ double zipf_distribution<IntType>::param_type::compute_s() const {
202
+ // 1 - hinv(h(1.5) - std::exp(std::log(v_ + 1) * -q_));
203
+ return 1.0 - hinv(h(1.5) - pow_negative_q(v_ + 1.0));
204
+ }
205
+
206
+ template <typename IntType>
207
+ double zipf_distribution<IntType>::param_type::pow_negative_q(double x) const {
208
+ // std::exp(std::log(x) * -q_);
209
+ return q_ == 2.0 ? (1.0 / (x * x)) : std::exp(std::log(x) * -q_);
210
+ }
211
+
212
+ template <typename IntType>
213
+ template <typename URBG>
214
+ typename zipf_distribution<IntType>::result_type
215
+ zipf_distribution<IntType>::operator()(
216
+ URBG& g, const param_type& p) { // NOLINT(runtime/references)
217
+ absl::uniform_real_distribution<double> uniform_double;
218
+ double k;
219
+ for (;;) {
220
+ const double v = uniform_double(g);
221
+ const double u = p.hxm_ + v * p.hx0_minus_hxm_;
222
+ const double x = p.hinv(u);
223
+ k = rint(x); // std::floor(x + 0.5);
224
+ if (k > p.k()) continue; // reject k > max_k
225
+ if (k - x <= p.s_) break;
226
+ const double h = p.h(k + 0.5);
227
+ const double r = p.pow_negative_q(p.v_ + k);
228
+ if (u >= h - r) break;
229
+ }
230
+ IntType ki = static_cast<IntType>(k);
231
+ assert(ki <= p.k_);
232
+ return ki;
233
+ }
234
+
235
+ template <typename CharT, typename Traits, typename IntType>
236
+ std::basic_ostream<CharT, Traits>& operator<<(
237
+ std::basic_ostream<CharT, Traits>& os, // NOLINT(runtime/references)
238
+ const zipf_distribution<IntType>& x) {
239
+ using stream_type =
240
+ typename random_internal::stream_format_type<IntType>::type;
241
+ auto saver = random_internal::make_ostream_state_saver(os);
242
+ os.precision(random_internal::stream_precision_helper<double>::kPrecision);
243
+ os << static_cast<stream_type>(x.k()) << os.fill() << x.q() << os.fill()
244
+ << x.v();
245
+ return os;
246
+ }
247
+
248
+ template <typename CharT, typename Traits, typename IntType>
249
+ std::basic_istream<CharT, Traits>& operator>>(
250
+ std::basic_istream<CharT, Traits>& is, // NOLINT(runtime/references)
251
+ zipf_distribution<IntType>& x) { // NOLINT(runtime/references)
252
+ using result_type = typename zipf_distribution<IntType>::result_type;
253
+ using param_type = typename zipf_distribution<IntType>::param_type;
254
+ using stream_type =
255
+ typename random_internal::stream_format_type<IntType>::type;
256
+ stream_type k;
257
+ double q;
258
+ double v;
259
+
260
+ auto saver = random_internal::make_istream_state_saver(is);
261
+ is >> k >> q >> v;
262
+ if (!is.fail()) {
263
+ x.param(param_type(static_cast<result_type>(k), q, v));
264
+ }
265
+ return is;
266
+ }
267
+
268
+ ABSL_NAMESPACE_END
269
+ } // namespace absl
270
+
271
+ #endif // ABSL_RANDOM_ZIPF_DISTRIBUTION_H_
@@ -56,6 +56,7 @@
56
56
 
57
57
  #include <openssl/asn1.h>
58
58
 
59
+ #include <assert.h>
59
60
  #include <limits.h>
60
61
  #include <string.h>
61
62
 
@@ -122,6 +122,19 @@ int EVP_EncodedLength(size_t *out_len, size_t len) {
122
122
  return 1;
123
123
  }
124
124
 
125
+ EVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void) {
126
+ EVP_ENCODE_CTX *ret = OPENSSL_malloc(sizeof(EVP_ENCODE_CTX));
127
+ if (ret == NULL) {
128
+ return NULL;
129
+ }
130
+ OPENSSL_memset(ret, 0, sizeof(EVP_ENCODE_CTX));
131
+ return ret;
132
+ }
133
+
134
+ void EVP_ENCODE_CTX_free(EVP_ENCODE_CTX *ctx) {
135
+ OPENSSL_free(ctx);
136
+ }
137
+
125
138
  void EVP_EncodeInit(EVP_ENCODE_CTX *ctx) {
126
139
  OPENSSL_memset(ctx, 0, sizeof(EVP_ENCODE_CTX));
127
140
  }
@@ -550,6 +550,27 @@ void DSA_SIG_free(DSA_SIG *sig) {
550
550
  OPENSSL_free(sig);
551
551
  }
552
552
 
553
+ void DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **out_r,
554
+ const BIGNUM **out_s) {
555
+ if (out_r != NULL) {
556
+ *out_r = sig->r;
557
+ }
558
+ if (out_s != NULL) {
559
+ *out_s = sig->s;
560
+ }
561
+ }
562
+
563
+ int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s) {
564
+ if (r == NULL || s == NULL) {
565
+ return 0;
566
+ }
567
+ BN_free(sig->r);
568
+ BN_free(sig->s);
569
+ sig->r = r;
570
+ sig->s = s;
571
+ return 1;
572
+ }
573
+
553
574
  // mod_mul_consttime sets |r| to |a| * |b| modulo |mont->N|, treating |a| and
554
575
  // |b| as secret. This function internally uses Montgomery reduction, but
555
576
  // neither inputs nor outputs are in Montgomery form.
@@ -629,6 +629,18 @@ int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
629
629
  return EVP_CipherInit(ctx, cipher, key, iv, 0);
630
630
  }
631
631
 
632
+ int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len) {
633
+ return EVP_CipherFinal_ex(ctx, out, out_len);
634
+ }
635
+
636
+ int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len) {
637
+ return EVP_EncryptFinal_ex(ctx, out, out_len);
638
+ }
639
+
640
+ int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len) {
641
+ return EVP_DecryptFinal_ex(ctx, out, out_len);
642
+ }
643
+
632
644
  int EVP_add_cipher_alias(const char *a, const char *b) {
633
645
  return 1;
634
646
  }
@@ -68,8 +68,7 @@
68
68
 
69
69
 
70
70
  // digest_to_scalar interprets |digest_len| bytes from |digest| as a scalar for
71
- // ECDSA. Note this value is not fully reduced modulo the order, only the
72
- // correct number of bits.
71
+ // ECDSA.
73
72
  static void digest_to_scalar(const EC_GROUP *group, EC_SCALAR *out,
74
73
  const uint8_t *digest, size_t digest_len) {
75
74
  const BIGNUM *order = &group->order;
@@ -30,7 +30,7 @@
30
30
  #include "../internal.h"
31
31
 
32
32
 
33
- // This file implements draft-irtf-cfrg-hpke-08.
33
+ // This file implements draft-irtf-cfrg-hpke-12.
34
34
 
35
35
  #define MAX_SEED_LEN X25519_PRIVATE_KEY_LEN
36
36
  #define MAX_SHARED_SECRET_LEN SHA256_DIGEST_LENGTH
@@ -115,7 +115,7 @@ static int hpke_labeled_expand(const EVP_MD *hkdf_md, uint8_t *out_key,
115
115
  // KEM implementations.
116
116
 
117
117
  // dhkem_extract_and_expand implements the ExtractAndExpand operation in the
118
- // DHKEM construction. See section 4.1 of draft-irtf-cfrg-hpke-08.
118
+ // DHKEM construction. See section 4.1 of draft-irtf-cfrg-hpke-12.
119
119
  static int dhkem_extract_and_expand(uint16_t kem_id, const EVP_MD *hkdf_md,
120
120
  uint8_t *out_key, size_t out_len,
121
121
  const uint8_t *dh, size_t dh_len,
@@ -132,7 +132,7 @@ static const uint8_t kBoringSSLBinaryTag[18] = {
132
132
  0x8c, 0x62, 0x20, 0x0b, 0xd2, 0xa0, 0x72, 0x58,
133
133
  0x44, 0xa8, 0x96, 0x69, 0xad, 0x55, 0x7e, 0xec,
134
134
  // Current source iteration. Incremented ~monthly.
135
- 1, 0,
135
+ 2, 0,
136
136
  };
137
137
 
138
138
  void *OPENSSL_malloc(size_t size) {
@@ -131,6 +131,35 @@ err:
131
131
  return ret;
132
132
  }
133
133
 
134
+ static int pkcs7_bundle_raw_certificates_cb(CBB *out, const void *arg) {
135
+ const STACK_OF(CRYPTO_BUFFER) *certs = arg;
136
+ CBB certificates;
137
+
138
+ // See https://tools.ietf.org/html/rfc2315#section-9.1
139
+ if (!CBB_add_asn1(out, &certificates,
140
+ CBS_ASN1_CONTEXT_SPECIFIC | CBS_ASN1_CONSTRUCTED | 0)) {
141
+ return 0;
142
+ }
143
+
144
+ for (size_t i = 0; i < sk_CRYPTO_BUFFER_num(certs); i++) {
145
+ CRYPTO_BUFFER *cert = sk_CRYPTO_BUFFER_value(certs, i);
146
+ if (!CBB_add_bytes(&certificates, CRYPTO_BUFFER_data(cert),
147
+ CRYPTO_BUFFER_len(cert))) {
148
+ return 0;
149
+ }
150
+ }
151
+
152
+ // |certificates| is a implicitly-tagged SET OF.
153
+ return CBB_flush_asn1_set_of(&certificates) && CBB_flush(out);
154
+ }
155
+
156
+ int PKCS7_bundle_raw_certificates(CBB *out,
157
+ const STACK_OF(CRYPTO_BUFFER) *certs) {
158
+ return pkcs7_add_signed_data(out, /*digest_algos_cb=*/NULL,
159
+ pkcs7_bundle_raw_certificates_cb,
160
+ /*signer_infos_cb=*/NULL, certs);
161
+ }
162
+
134
163
  int pkcs7_add_signed_data(CBB *out,
135
164
  int (*digest_algos_cb)(CBB *out, const void *arg),
136
165
  int (*cert_crl_cb)(CBB *out, const void *arg),
@@ -112,7 +112,6 @@ struct pbe_suite {
112
112
  const char *pass, size_t pass_len, CBS *param);
113
113
  };
114
114
 
115
- #define PKCS5_DEFAULT_ITERATIONS 2048
116
115
  #define PKCS5_SALT_LEN 8
117
116
 
118
117
  int PKCS5_pbe2_decrypt_init(const struct pbe_suite *suite, EVP_CIPHER_CTX *ctx,
@@ -469,7 +469,7 @@ int PKCS8_marshal_encrypted_private_key(CBB *out, int pbe_nid,
469
469
  }
470
470
 
471
471
  if (iterations <= 0) {
472
- iterations = PKCS5_DEFAULT_ITERATIONS;
472
+ iterations = PKCS12_DEFAULT_ITER;
473
473
  }
474
474
 
475
475
  // Serialize the input key.
@@ -1161,7 +1161,7 @@ PKCS12 *PKCS12_create(const char *password, const char *name,
1161
1161
  cert_nid = NID_pbe_WithSHA1And40BitRC2_CBC;
1162
1162
  }
1163
1163
  if (iterations == 0) {
1164
- iterations = PKCS5_DEFAULT_ITERATIONS;
1164
+ iterations = PKCS12_DEFAULT_ITER;
1165
1165
  }
1166
1166
  if (mac_iterations == 0) {
1167
1167
  mac_iterations = 1;
@@ -111,6 +111,14 @@ OPENSSL_EXPORT int EVP_DecodeBase64(uint8_t *out, size_t *out_len,
111
111
  // very specific to PEM. It is also very lenient of invalid input. Use of any of
112
112
  // these functions is thus deprecated.
113
113
 
114
+ // EVP_ENCODE_CTX_new returns a newly-allocated |EVP_ENCODE_CTX| or NULL on
115
+ // error. The caller must release the result with |EVP_ENCODE_CTX_free| when
116
+ // done.
117
+ OPENSSL_EXPORT EVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void);
118
+
119
+ // EVP_ENCODE_CTX_free releases memory associated with |ctx|.
120
+ OPENSSL_EXPORT void EVP_ENCODE_CTX_free(EVP_ENCODE_CTX *ctx);
121
+
114
122
  // EVP_EncodeInit initialises |*ctx|, which is typically stack
115
123
  // allocated, for an encoding operation.
116
124
  //
@@ -201,7 +201,7 @@ OPENSSL_EXPORT int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, uint8_t *out,
201
201
  //
202
202
  // WARNING: it is unsafe to call this function with unauthenticated
203
203
  // ciphertext if padding is enabled.
204
- OPENSSL_EXPORT int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out,
204
+ OPENSSL_EXPORT int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, uint8_t *out,
205
205
  int *out_len);
206
206
 
207
207
  // EVP_Cipher performs a one-shot encryption/decryption operation. No partial
@@ -408,6 +408,18 @@ OPENSSL_EXPORT int EVP_DecryptInit(EVP_CIPHER_CTX *ctx,
408
408
  const EVP_CIPHER *cipher, const uint8_t *key,
409
409
  const uint8_t *iv);
410
410
 
411
+ // EVP_CipherFinal calls |EVP_CipherFinal_ex|.
412
+ OPENSSL_EXPORT int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, uint8_t *out,
413
+ int *out_len);
414
+
415
+ // EVP_EncryptFinal calls |EVP_EncryptFinal_ex|.
416
+ OPENSSL_EXPORT int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, uint8_t *out,
417
+ int *out_len);
418
+
419
+ // EVP_DecryptFinal calls |EVP_DecryptFinal_ex|.
420
+ OPENSSL_EXPORT int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, uint8_t *out,
421
+ int *out_len);
422
+
411
423
  // EVP_add_cipher_alias does nothing and returns one.
412
424
  OPENSSL_EXPORT int EVP_add_cipher_alias(const char *a, const char *b);
413
425
 
@@ -189,6 +189,16 @@ OPENSSL_EXPORT DSA_SIG *DSA_SIG_new(void);
189
189
  // DSA_SIG_free frees the contents of |sig| and then frees |sig| itself.
190
190
  OPENSSL_EXPORT void DSA_SIG_free(DSA_SIG *sig);
191
191
 
192
+ // DSA_SIG_get0 sets |*out_r| and |*out_s|, if non-NULL, to the two components
193
+ // of |sig|.
194
+ OPENSSL_EXPORT void DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **out_r,
195
+ const BIGNUM **out_s);
196
+
197
+ // DSA_SIG_set0 sets |sig|'s components to |r| and |s|, neither of which may be
198
+ // NULL. On success, it takes ownership of each argument and returns one.
199
+ // Otherwise, it returns zero.
200
+ OPENSSL_EXPORT int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s);
201
+
192
202
  // DSA_do_sign returns a signature of the hash in |digest| by the key in |dsa|
193
203
  // and returns an allocated, DSA_SIG structure, or NULL on error.
194
204
  OPENSSL_EXPORT DSA_SIG *DSA_do_sign(const uint8_t *digest, size_t digest_len,
@@ -30,7 +30,7 @@ extern "C" {
30
30
  // Hybrid Public Key Encryption (HPKE) enables a sender to encrypt messages to a
31
31
  // receiver with a public key.
32
32
  //
33
- // See https://tools.ietf.org/html/draft-irtf-cfrg-hpke-08.
33
+ // See https://tools.ietf.org/html/draft-irtf-cfrg-hpke-12.
34
34
 
35
35
 
36
36
  // Parameters.
@@ -49,10 +49,15 @@ OPENSSL_EXPORT int PKCS7_get_raw_certificates(
49
49
  // them into |X509| objects.
50
50
  OPENSSL_EXPORT int PKCS7_get_certificates(STACK_OF(X509) *out_certs, CBS *cbs);
51
51
 
52
- // PKCS7_bundle_certificates appends a PKCS#7, SignedData structure containing
53
- // |certs| to |out|. It returns one on success and zero on error. Note that
54
- // certificates in SignedData structures are unordered. The order in |certs|
55
- // will not be preserved.
52
+ // PKCS7_bundle_raw_certificates appends a PKCS#7, SignedData structure
53
+ // containing |certs| to |out|. It returns one on success and zero on error.
54
+ // Note that certificates in SignedData structures are unordered. The order in
55
+ // |certs| will not be preserved.
56
+ OPENSSL_EXPORT int PKCS7_bundle_raw_certificates(
57
+ CBB *out, const STACK_OF(CRYPTO_BUFFER) *certs);
58
+
59
+ // PKCS7_bundle_certificates behaves like |PKCS7_bundle_raw_certificates| but
60
+ // takes |X509| objects as input.
56
61
  OPENSSL_EXPORT int PKCS7_bundle_certificates(
57
62
  CBB *out, const STACK_OF(X509) *certs);
58
63
 
@@ -197,6 +197,10 @@ OPENSSL_EXPORT int PKCS12_parse(const PKCS12 *p12, const char *password,
197
197
  OPENSSL_EXPORT int PKCS12_verify_mac(const PKCS12 *p12, const char *password,
198
198
  int password_len);
199
199
 
200
+ // PKCS12_DEFAULT_ITER is the default number of KDF iterations used when
201
+ // creating a |PKCS12| object.
202
+ #define PKCS12_DEFAULT_ITER 2048
203
+
200
204
  // PKCS12_create returns a newly-allocated |PKCS12| object containing |pkey|,
201
205
  // |cert|, and |chain|, encrypted with the specified password. |name|, if not
202
206
  // NULL, specifies a user-friendly name to encode with the key and
@@ -207,7 +211,8 @@ OPENSSL_EXPORT int PKCS12_verify_mac(const PKCS12 *p12, const char *password,
207
211
  //
208
212
  // Each of |key_nid|, |cert_nid|, |iterations|, and |mac_iterations| may be zero
209
213
  // to use defaults, which are |NID_pbe_WithSHA1And3_Key_TripleDES_CBC|,
210
- // |NID_pbe_WithSHA1And40BitRC2_CBC|, 2048, and one, respectively.
214
+ // |NID_pbe_WithSHA1And40BitRC2_CBC|, |PKCS12_DEFAULT_ITER|, and one,
215
+ // respectively.
211
216
  //
212
217
  // |key_nid| or |cert_nid| may also be -1 to disable encryption of the key or
213
218
  // certificate, respectively. This option is not recommended and is only
@@ -362,10 +362,31 @@ OPENSSL_EXPORT int SSL_read(SSL *ssl, void *buf, int num);
362
362
  // SSL_peek behaves like |SSL_read| but does not consume any bytes returned.
363
363
  OPENSSL_EXPORT int SSL_peek(SSL *ssl, void *buf, int num);
364
364
 
365
- // SSL_pending returns the number of bytes available in |ssl|. It does not read
366
- // from the transport.
365
+ // SSL_pending returns the number of buffered, decrypted bytes available for
366
+ // read in |ssl|. It does not read from the transport.
367
+ //
368
+ // In DTLS, it is possible for this function to return zero while there is
369
+ // buffered, undecrypted data from the transport in |ssl|. For example,
370
+ // |SSL_read| may read a datagram with two records, decrypt the first, and leave
371
+ // the second buffered for a subsequent call to |SSL_read|. Callers that wish to
372
+ // detect this case can use |SSL_has_pending|.
367
373
  OPENSSL_EXPORT int SSL_pending(const SSL *ssl);
368
374
 
375
+ // SSL_has_pending returns one if |ssl| has buffered, decrypted bytes available
376
+ // for read, or if |ssl| has buffered data from the transport that has not yet
377
+ // been decrypted. If |ssl| has neither, this function returns zero.
378
+ //
379
+ // In TLS, BoringSSL does not implement read-ahead, so this function returns one
380
+ // if and only if |SSL_pending| would return a non-zero value. In DTLS, it is
381
+ // possible for this function to return one while |SSL_pending| returns zero.
382
+ // For example, |SSL_read| may read a datagram with two records, decrypt the
383
+ // first, and leave the second buffered for a subsequent call to |SSL_read|.
384
+ //
385
+ // As a result, if this function returns one, the next call to |SSL_read| may
386
+ // still fail, read from the transport, or both. The buffered, undecrypted data
387
+ // may be invalid or incomplete.
388
+ OPENSSL_EXPORT int SSL_has_pending(const SSL *ssl);
389
+
369
390
  // SSL_write writes up to |num| bytes from |buf| into |ssl|. It implicitly runs
370
391
  // any pending handshakes, including renegotiations when enabled. On success, it
371
392
  // returns the number of bytes written. Otherwise, it returns <= 0. The caller
@@ -1697,6 +1697,10 @@ int SSL_pending(const SSL *ssl) {
1697
1697
  return static_cast<int>(ssl->s3->pending_app_data.size());
1698
1698
  }
1699
1699
 
1700
+ int SSL_has_pending(const SSL *ssl) {
1701
+ return SSL_pending(ssl) != 0 || !ssl->s3->read_buffer.empty();
1702
+ }
1703
+
1700
1704
  int SSL_CTX_check_private_key(const SSL_CTX *ctx) {
1701
1705
  return ssl_cert_check_private_key(ctx->cert.get(),
1702
1706
  ctx->cert->privatekey.get());