grpc 1.30.2 → 1.31.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 (317) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +560 -619
  3. data/include/grpc/grpc_security_constants.h +3 -0
  4. data/include/grpc/impl/codegen/grpc_types.h +7 -5
  5. data/include/grpc/impl/codegen/port_platform.h +0 -32
  6. data/src/core/ext/filters/client_channel/backend_metric.cc +12 -9
  7. data/src/core/ext/filters/client_channel/client_channel.cc +406 -265
  8. data/src/core/ext/filters/client_channel/config_selector.cc +62 -0
  9. data/src/core/ext/filters/client_channel/config_selector.h +93 -0
  10. data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +24 -2
  11. data/src/core/ext/filters/client_channel/health/health_check_client.cc +2 -0
  12. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +6 -5
  13. data/src/core/ext/filters/client_channel/http_proxy.cc +6 -4
  14. data/src/core/ext/filters/client_channel/lb_policy.h +2 -0
  15. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +39 -23
  16. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +4 -6
  17. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_routing.cc +376 -68
  18. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +4 -5
  19. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +5 -2
  20. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +6 -5
  21. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +8 -6
  22. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +9 -7
  23. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +7 -5
  24. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +33 -48
  25. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +6 -2
  26. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +21 -18
  27. data/src/core/ext/filters/client_channel/resolver_registry.cc +13 -14
  28. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +6 -7
  29. data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +33 -28
  30. data/src/core/ext/filters/client_channel/resolving_lb_policy.h +39 -20
  31. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +142 -0
  32. data/src/core/ext/filters/client_channel/subchannel.cc +1 -1
  33. data/src/core/ext/filters/client_channel/xds/xds_api.cc +327 -123
  34. data/src/core/ext/filters/client_channel/xds/xds_api.h +72 -7
  35. data/src/core/ext/filters/client_channel/xds/xds_bootstrap.cc +12 -23
  36. data/src/core/ext/filters/client_channel/xds/xds_client.cc +112 -33
  37. data/src/core/ext/filters/client_channel/xds/xds_client_stats.h +10 -10
  38. data/src/core/ext/filters/http/client/http_client_filter.cc +5 -5
  39. data/src/core/ext/filters/http/http_filters_plugin.cc +2 -1
  40. data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +74 -33
  41. data/src/core/ext/filters/http/message_compress/message_decompress_filter.h +3 -1
  42. data/src/core/ext/filters/message_size/message_size_filter.cc +56 -80
  43. data/src/core/ext/filters/message_size/message_size_filter.h +6 -0
  44. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +383 -347
  45. data/src/core/ext/transport/chttp2/server/chttp2_server.h +6 -2
  46. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +1 -1
  47. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +7 -13
  48. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +7 -8
  49. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +19 -4
  50. data/src/core/ext/transport/chttp2/transport/flow_control.cc +22 -27
  51. data/src/core/ext/transport/chttp2/transport/flow_control.h +14 -16
  52. data/src/core/ext/transport/chttp2/transport/frame_data.cc +9 -12
  53. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +4 -6
  54. data/src/core/ext/transport/chttp2/transport/frame_ping.cc +5 -6
  55. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +12 -13
  56. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +6 -7
  57. data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +9 -12
  58. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +25 -29
  59. data/src/core/ext/transport/chttp2/transport/hpack_table.cc +13 -17
  60. data/src/core/ext/transport/chttp2/transport/internal.h +13 -0
  61. data/src/core/ext/transport/chttp2/transport/parsing.cc +33 -43
  62. data/src/core/ext/transport/chttp2/transport/writing.cc +9 -14
  63. data/src/core/ext/transport/inproc/inproc_transport.cc +35 -15
  64. data/src/core/ext/upb-generated/envoy/annotations/deprecation.upb.h +0 -1
  65. data/src/core/ext/upb-generated/envoy/annotations/resource.upb.h +3 -4
  66. data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h +0 -1
  67. data/src/core/ext/upb-generated/envoy/api/v2/auth/common.upb.h +80 -69
  68. data/src/core/ext/upb-generated/envoy/api/v2/auth/secret.upb.h +24 -23
  69. data/src/core/ext/upb-generated/envoy/api/v2/auth/tls.upb.h +66 -56
  70. data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h +1 -2
  71. data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.c +2 -2
  72. data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.h +317 -311
  73. data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h +42 -34
  74. data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.h +7 -7
  75. data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h +79 -61
  76. data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h +55 -49
  77. data/src/core/ext/upb-generated/envoy/api/v2/core/backoff.upb.h +9 -8
  78. data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c +1 -1
  79. data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h +163 -169
  80. data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h +51 -45
  81. data/src/core/ext/upb-generated/envoy/api/v2/core/event_service_config.upb.h +4 -5
  82. data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h +107 -100
  83. data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h +137 -117
  84. data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.h +9 -9
  85. data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h +105 -87
  86. data/src/core/ext/upb-generated/envoy/api/v2/core/socket_option.upb.h +12 -13
  87. data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c +1 -1
  88. data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h +95 -101
  89. data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.h +1 -2
  90. data/src/core/ext/upb-generated/envoy/api/v2/endpoint.upb.c +1 -1
  91. data/src/core/ext/upb-generated/envoy/api/v2/endpoint.upb.h +49 -65
  92. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h +0 -1
  93. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint_components.upb.h +49 -42
  94. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h +70 -62
  95. data/src/core/ext/upb-generated/envoy/api/v2/lds.upb.h +1 -2
  96. data/src/core/ext/upb-generated/envoy/api/v2/listener.upb.h +81 -65
  97. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener.upb.h +0 -1
  98. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener_components.upb.c +1 -1
  99. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener_components.upb.h +91 -80
  100. data/src/core/ext/upb-generated/envoy/api/v2/listener/udp_listener_config.upb.h +9 -10
  101. data/src/core/ext/upb-generated/envoy/api/v2/rds.upb.h +1 -2
  102. data/src/core/ext/upb-generated/envoy/api/v2/route.upb.h +36 -31
  103. data/src/core/ext/upb-generated/envoy/api/v2/route/route.upb.h +0 -1
  104. data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.c +7 -7
  105. data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.h +648 -696
  106. data/src/core/ext/upb-generated/envoy/api/v2/scoped_route.upb.h +16 -15
  107. data/src/core/ext/upb-generated/envoy/api/v2/srds.upb.h +1 -2
  108. data/src/core/ext/upb-generated/envoy/config/filter/accesslog/v2/accesslog.upb.c +1 -1
  109. data/src/core/ext/upb-generated/envoy/config/filter/accesslog/v2/accesslog.upb.h +95 -88
  110. data/src/core/ext/upb-generated/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.h +234 -199
  111. data/src/core/ext/upb-generated/envoy/config/listener/v2/api_listener.upb.h +5 -5
  112. data/src/core/ext/upb-generated/envoy/config/trace/v2/http_tracer.upb.h +13 -13
  113. data/src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h +1 -2
  114. data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h +20 -18
  115. data/src/core/ext/upb-generated/envoy/type/http.upb.h +0 -1
  116. data/src/core/ext/upb-generated/envoy/type/matcher/regex.upb.h +18 -17
  117. data/src/core/ext/upb-generated/envoy/type/matcher/string.upb.h +14 -14
  118. data/src/core/ext/upb-generated/envoy/type/metadata/v2/metadata.upb.h +23 -23
  119. data/src/core/ext/upb-generated/envoy/type/percent.upb.h +8 -9
  120. data/src/core/ext/upb-generated/envoy/type/range.upb.h +15 -16
  121. data/src/core/ext/upb-generated/envoy/type/semantic_version.upb.h +7 -8
  122. data/src/core/ext/upb-generated/envoy/type/tracing/v2/custom_tag.upb.h +36 -35
  123. data/src/core/ext/upb-generated/gogoproto/gogo.upb.h +0 -1
  124. data/src/core/ext/upb-generated/google/api/annotations.upb.h +0 -1
  125. data/src/core/ext/upb-generated/google/api/http.upb.h +29 -28
  126. data/src/core/ext/upb-generated/google/protobuf/any.upb.h +5 -6
  127. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c +3 -3
  128. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h +412 -386
  129. data/src/core/ext/upb-generated/google/protobuf/duration.upb.h +5 -6
  130. data/src/core/ext/upb-generated/google/protobuf/empty.upb.h +1 -2
  131. data/src/core/ext/upb-generated/google/protobuf/struct.upb.c +1 -1
  132. data/src/core/ext/upb-generated/google/protobuf/struct.upb.h +33 -54
  133. data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.h +5 -6
  134. data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.h +27 -28
  135. data/src/core/ext/upb-generated/google/rpc/status.upb.h +8 -8
  136. data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c +1 -1
  137. data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h +32 -45
  138. data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c +4 -4
  139. data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h +157 -178
  140. data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h +14 -13
  141. data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h +6 -7
  142. data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h +59 -56
  143. data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.h +11 -12
  144. data/src/core/ext/upb-generated/udpa/annotations/sensitive.upb.h +0 -1
  145. data/src/core/ext/upb-generated/udpa/annotations/status.upb.h +5 -6
  146. data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c +6 -6
  147. data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h +41 -68
  148. data/src/core/ext/upb-generated/validate/validate.upb.h +536 -535
  149. data/src/core/lib/channel/channel_trace.cc +2 -6
  150. data/src/core/lib/channel/channelz.cc +5 -15
  151. data/src/core/lib/gpr/log_linux.cc +6 -8
  152. data/src/core/lib/gpr/log_posix.cc +6 -8
  153. data/src/core/lib/gpr/string.cc +10 -9
  154. data/src/core/lib/gpr/string.h +4 -2
  155. data/src/core/lib/gprpp/global_config_env.cc +8 -6
  156. data/src/core/lib/http/httpcli.cc +13 -10
  157. data/src/core/lib/http/httpcli_security_connector.cc +5 -5
  158. data/src/core/lib/iomgr/cfstream_handle.cc +1 -0
  159. data/src/core/lib/iomgr/endpoint_pair_posix.cc +10 -10
  160. data/src/core/lib/iomgr/error_cfstream.cc +9 -8
  161. data/src/core/lib/iomgr/ev_epoll1_linux.cc +5 -6
  162. data/src/core/lib/iomgr/ev_epollex_linux.cc +15 -21
  163. data/src/core/lib/iomgr/ev_poll_posix.cc +6 -5
  164. data/src/core/lib/iomgr/ev_posix.cc +2 -0
  165. data/src/core/lib/iomgr/iomgr.cc +10 -0
  166. data/src/core/lib/iomgr/iomgr.h +10 -0
  167. data/src/core/lib/iomgr/is_epollexclusive_available.cc +14 -0
  168. data/src/core/lib/iomgr/port.h +1 -21
  169. data/src/core/lib/iomgr/resolve_address_custom.cc +13 -18
  170. data/src/core/lib/iomgr/resolve_address_windows.cc +8 -8
  171. data/src/core/lib/iomgr/resource_quota.cc +34 -31
  172. data/src/core/lib/iomgr/sockaddr_utils.cc +7 -5
  173. data/src/core/lib/iomgr/sockaddr_utils.h +1 -1
  174. data/src/core/lib/iomgr/socket_utils_common_posix.cc +95 -55
  175. data/src/core/lib/iomgr/socket_windows.cc +4 -5
  176. data/src/core/lib/iomgr/tcp_client_cfstream.cc +9 -11
  177. data/src/core/lib/iomgr/tcp_client_custom.cc +6 -9
  178. data/src/core/lib/iomgr/tcp_client_posix.cc +27 -36
  179. data/src/core/lib/iomgr/tcp_client_windows.cc +9 -9
  180. data/src/core/lib/iomgr/tcp_custom.cc +1 -1
  181. data/src/core/lib/iomgr/tcp_custom.h +1 -1
  182. data/src/core/lib/iomgr/tcp_server.cc +3 -4
  183. data/src/core/lib/iomgr/tcp_server.h +7 -5
  184. data/src/core/lib/iomgr/tcp_server_custom.cc +6 -14
  185. data/src/core/lib/iomgr/tcp_server_posix.cc +34 -41
  186. data/src/core/lib/iomgr/tcp_server_utils_posix.h +3 -4
  187. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +5 -7
  188. data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +4 -9
  189. data/src/core/lib/iomgr/tcp_server_windows.cc +16 -16
  190. data/src/core/lib/iomgr/timer_generic.cc +13 -12
  191. data/src/core/lib/iomgr/udp_server.cc +24 -23
  192. data/src/core/lib/iomgr/udp_server.h +5 -2
  193. data/src/core/lib/iomgr/unix_sockets_posix.cc +9 -14
  194. data/src/core/lib/iomgr/unix_sockets_posix.h +3 -1
  195. data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +5 -2
  196. data/src/core/lib/json/json_reader.cc +20 -21
  197. data/src/core/lib/security/credentials/credentials.h +5 -3
  198. data/src/core/lib/security/credentials/google_default/credentials_generic.cc +8 -6
  199. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +12 -9
  200. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +7 -4
  201. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +19 -28
  202. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +6 -6
  203. data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +20 -0
  204. data/src/core/lib/security/credentials/ssl/ssl_credentials.h +10 -0
  205. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +10 -0
  206. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +10 -10
  207. data/src/core/lib/security/security_connector/security_connector.cc +2 -0
  208. data/src/core/lib/security/security_connector/security_connector.h +1 -1
  209. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +18 -11
  210. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.h +5 -0
  211. data/src/core/lib/security/security_connector/ssl_utils.cc +44 -23
  212. data/src/core/lib/security/security_connector/ssl_utils.h +6 -2
  213. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +27 -24
  214. data/src/core/lib/security/transport/client_auth_filter.cc +10 -9
  215. data/src/core/lib/security/util/json_util.cc +12 -13
  216. data/src/core/lib/slice/slice.cc +38 -1
  217. data/src/core/lib/slice/slice_internal.h +1 -0
  218. data/src/core/lib/surface/call.cc +40 -41
  219. data/src/core/lib/surface/completion_queue.cc +271 -14
  220. data/src/core/lib/surface/completion_queue.h +8 -0
  221. data/src/core/lib/surface/init.cc +2 -0
  222. data/src/core/lib/surface/server.cc +565 -632
  223. data/src/core/lib/surface/server.h +34 -12
  224. data/src/core/lib/surface/version.cc +2 -2
  225. data/src/core/lib/transport/transport.h +6 -0
  226. data/src/core/lib/uri/uri_parser.cc +8 -15
  227. data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -0
  228. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +23 -13
  229. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +2 -0
  230. data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +2 -0
  231. data/src/core/tsi/ssl_transport_security.cc +102 -11
  232. data/src/core/tsi/ssl_transport_security.h +14 -2
  233. data/src/core/tsi/transport_security_interface.h +5 -0
  234. data/src/ruby/ext/grpc/extconf.rb +5 -2
  235. data/src/ruby/ext/grpc/rb_call.c +3 -2
  236. data/src/ruby/ext/grpc/rb_call.h +4 -0
  237. data/src/ruby/ext/grpc/rb_call_credentials.c +54 -10
  238. data/src/ruby/lib/grpc/generic/interceptors.rb +1 -1
  239. data/src/ruby/lib/grpc/version.rb +1 -1
  240. data/third_party/boringssl-with-bazel/err_data.c +89 -83
  241. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bitstr.c +3 -3
  242. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_enum.c +3 -3
  243. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_int.c +1 -1
  244. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +3 -3
  245. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_time.c +2 -2
  246. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_type.c +1 -1
  247. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_lib.c +1 -1
  248. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn_pack.c +1 -1
  249. data/third_party/boringssl-with-bazel/src/crypto/asn1/f_enum.c +1 -1
  250. data/third_party/boringssl-with-bazel/src/crypto/asn1/f_int.c +1 -1
  251. data/third_party/boringssl-with-bazel/src/crypto/asn1/f_string.c +1 -1
  252. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/tls_cbc.c +1 -0
  253. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/hash_to_curve.c +12 -52
  254. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/internal.h +0 -22
  255. data/third_party/boringssl-with-bazel/src/crypto/evp/evp_asn1.c +143 -0
  256. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/mode_wrappers.c +17 -1
  257. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/internal.h +11 -1
  258. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +2 -1
  259. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p224-64.c +13 -11
  260. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-x86_64.c +24 -23
  261. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256.c +20 -16
  262. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple_mul.c +2 -2
  263. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/util.c +3 -3
  264. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +62 -0
  265. data/third_party/boringssl-with-bazel/src/crypto/mem.c +29 -15
  266. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/internal.h +7 -0
  267. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +36 -5
  268. data/third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h +0 -29
  269. data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +116 -363
  270. data/third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.c +7 -45
  271. data/third_party/boringssl-with-bazel/src/crypto/x509/a_strex.c +4 -4
  272. data/third_party/boringssl-with-bazel/src/crypto/x509/algorithm.c +8 -0
  273. data/third_party/boringssl-with-bazel/src/crypto/x509/asn1_gen.c +4 -4
  274. data/third_party/boringssl-with-bazel/src/crypto/x509/x509.c +0 -67
  275. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +13 -6
  276. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +10 -0
  277. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +41 -0
  278. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +4 -1
  279. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +28 -9
  280. data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +25 -0
  281. data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +35 -13
  282. data/third_party/boringssl-with-bazel/src/crypto/x509/x_pubkey.c +0 -154
  283. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c +28 -6
  284. data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +5 -0
  285. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +74 -35
  286. data/third_party/boringssl-with-bazel/src/include/openssl/aes.h +16 -4
  287. data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +22 -22
  288. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +1 -1
  289. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +69 -0
  290. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +33 -16
  291. data/third_party/boringssl-with-bazel/src/include/openssl/trust_token.h +1 -10
  292. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +789 -715
  293. data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +3 -3
  294. data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +9 -2
  295. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +2 -2
  296. data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +9 -0
  297. data/third_party/boringssl-with-bazel/src/ssl/internal.h +17 -14
  298. data/third_party/boringssl-with-bazel/src/ssl/ssl_asn1.cc +7 -7
  299. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +28 -0
  300. data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +4 -24
  301. data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +5 -5
  302. data/third_party/boringssl-with-bazel/src/ssl/t1_enc.cc +45 -24
  303. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +31 -21
  304. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +12 -9
  305. data/third_party/upb/upb/decode.c +467 -504
  306. data/third_party/upb/upb/encode.c +163 -121
  307. data/third_party/upb/upb/msg.c +130 -64
  308. data/third_party/upb/upb/msg.h +418 -14
  309. data/third_party/upb/upb/port_def.inc +35 -6
  310. data/third_party/upb/upb/port_undef.inc +8 -1
  311. data/third_party/upb/upb/table.c +53 -75
  312. data/third_party/upb/upb/table.int.h +11 -43
  313. data/third_party/upb/upb/upb.c +148 -124
  314. data/third_party/upb/upb/upb.h +65 -147
  315. data/third_party/upb/upb/upb.hpp +86 -0
  316. metadata +40 -37
  317. data/third_party/upb/upb/generated_util.h +0 -105
@@ -66,7 +66,7 @@
66
66
  #include "../internal.h"
67
67
 
68
68
 
69
- int i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp)
69
+ int i2d_ASN1_OBJECT(const ASN1_OBJECT *a, unsigned char **pp)
70
70
  {
71
71
  unsigned char *p, *allocated = NULL;
72
72
  int objsize;
@@ -98,12 +98,12 @@ int i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp)
98
98
  return objsize;
99
99
  }
100
100
 
101
- int i2t_ASN1_OBJECT(char *buf, int buf_len, ASN1_OBJECT *a)
101
+ int i2t_ASN1_OBJECT(char *buf, int buf_len, const ASN1_OBJECT *a)
102
102
  {
103
103
  return OBJ_obj2txt(buf, buf_len, a, 0);
104
104
  }
105
105
 
106
- int i2a_ASN1_OBJECT(BIO *bp, ASN1_OBJECT *a)
106
+ int i2a_ASN1_OBJECT(BIO *bp, const ASN1_OBJECT *a)
107
107
  {
108
108
  char buf[80], *p = buf;
109
109
  int i;
@@ -100,7 +100,7 @@ ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t,
100
100
  return ASN1_GENERALIZEDTIME_adj(s, t, offset_day, offset_sec);
101
101
  }
102
102
 
103
- int ASN1_TIME_check(ASN1_TIME *t)
103
+ int ASN1_TIME_check(const ASN1_TIME *t)
104
104
  {
105
105
  if (t->type == V_ASN1_GENERALIZEDTIME)
106
106
  return ASN1_GENERALIZEDTIME_check(t);
@@ -110,7 +110,7 @@ int ASN1_TIME_check(ASN1_TIME *t)
110
110
  }
111
111
 
112
112
  /* Convert an ASN1_TIME structure to GeneralizedTime */
113
- ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t,
113
+ ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(const ASN1_TIME *t,
114
114
  ASN1_GENERALIZEDTIME **out)
115
115
  {
116
116
  ASN1_GENERALIZEDTIME *ret = NULL;
@@ -61,7 +61,7 @@
61
61
  #include <openssl/mem.h>
62
62
  #include <openssl/obj.h>
63
63
 
64
- int ASN1_TYPE_get(ASN1_TYPE *a)
64
+ int ASN1_TYPE_get(const ASN1_TYPE *a)
65
65
  {
66
66
  if ((a->value.ptr != NULL) || (a->type == V_ASN1_NULL))
67
67
  return (a->type);
@@ -430,7 +430,7 @@ void ASN1_STRING_length_set(ASN1_STRING *x, int len)
430
430
  return;
431
431
  }
432
432
 
433
- int ASN1_STRING_type(ASN1_STRING *x)
433
+ int ASN1_STRING_type(const ASN1_STRING *x)
434
434
  {
435
435
  return M_ASN1_STRING_type(x);
436
436
  }
@@ -93,7 +93,7 @@ ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_STRING **oct)
93
93
 
94
94
  /* Extract an ASN1 object from an ASN1_STRING */
95
95
 
96
- void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it)
96
+ void *ASN1_item_unpack(const ASN1_STRING *oct, const ASN1_ITEM *it)
97
97
  {
98
98
  const unsigned char *p;
99
99
  void *ret;
@@ -60,7 +60,7 @@
60
60
 
61
61
  /* Based on a_int.c: equivalent ENUMERATED functions */
62
62
 
63
- int i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a)
63
+ int i2a_ASN1_ENUMERATED(BIO *bp, const ASN1_ENUMERATED *a)
64
64
  {
65
65
  int i, n = 0;
66
66
  static const char *h = "0123456789ABCDEF";
@@ -58,7 +58,7 @@
58
58
 
59
59
  #include <openssl/bio.h>
60
60
 
61
- int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a)
61
+ int i2a_ASN1_INTEGER(BIO *bp, const ASN1_INTEGER *a)
62
62
  {
63
63
  int i, n = 0;
64
64
  static const char *h = "0123456789ABCDEF";
@@ -58,7 +58,7 @@
58
58
 
59
59
  #include <openssl/bio.h>
60
60
 
61
- int i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type)
61
+ int i2a_ASN1_STRING(BIO *bp, const ASN1_STRING *a, int type)
62
62
  {
63
63
  int i, n = 0;
64
64
  static const char *h = "0123456789ABCDEF";
@@ -133,6 +133,7 @@ void EVP_tls_cbc_copy_mac(uint8_t *out, size_t md_size, const uint8_t *in,
133
133
  assert(orig_len >= in_len);
134
134
  assert(in_len >= md_size);
135
135
  assert(md_size <= EVP_MAX_MD_SIZE);
136
+ assert(md_size > 0);
136
137
 
137
138
  // scan_start contains the number of bytes that we can ignore because
138
139
  // the MAC's position can only vary by 255 bytes.
@@ -50,12 +50,10 @@
50
50
 
51
51
  // expand_message_xmd implements the operation described in section 5.3.1 of
52
52
  // draft-irtf-cfrg-hash-to-curve-07. It returns one on success and zero on
53
- // allocation failure or if |out_len| was too large. If |is_draft06| is one, it
54
- // implements the operation from draft-irtf-cfrg-hash-to-curve-06 instead.
53
+ // allocation failure or if |out_len| was too large.
55
54
  static int expand_message_xmd(const EVP_MD *md, uint8_t *out, size_t out_len,
56
55
  const uint8_t *msg, size_t msg_len,
57
- const uint8_t *dst, size_t dst_len,
58
- int is_draft06) {
56
+ const uint8_t *dst, size_t dst_len) {
59
57
  int ret = 0;
60
58
  const size_t block_size = EVP_MD_block_size(md);
61
59
  const size_t md_size = EVP_MD_size(md);
@@ -88,9 +86,8 @@ static int expand_message_xmd(const EVP_MD *md, uint8_t *out, size_t out_len,
88
86
  !EVP_DigestUpdate(&ctx, kZeros, block_size) ||
89
87
  !EVP_DigestUpdate(&ctx, msg, msg_len) ||
90
88
  !EVP_DigestUpdate(&ctx, l_i_b_str_zero, sizeof(l_i_b_str_zero)) ||
91
- (is_draft06 && !EVP_DigestUpdate(&ctx, &dst_len_u8, 1)) ||
92
89
  !EVP_DigestUpdate(&ctx, dst, dst_len) ||
93
- (!is_draft06 && !EVP_DigestUpdate(&ctx, &dst_len_u8, 1)) ||
90
+ !EVP_DigestUpdate(&ctx, &dst_len_u8, 1) ||
94
91
  !EVP_DigestFinal_ex(&ctx, b_0, NULL)) {
95
92
  goto err;
96
93
  }
@@ -114,9 +111,8 @@ static int expand_message_xmd(const EVP_MD *md, uint8_t *out, size_t out_len,
114
111
  if (!EVP_DigestInit_ex(&ctx, md, NULL) ||
115
112
  !EVP_DigestUpdate(&ctx, b_i, md_size) ||
116
113
  !EVP_DigestUpdate(&ctx, &i, 1) ||
117
- (is_draft06 && !EVP_DigestUpdate(&ctx, &dst_len_u8, 1)) ||
118
114
  !EVP_DigestUpdate(&ctx, dst, dst_len) ||
119
- (!is_draft06 && !EVP_DigestUpdate(&ctx, &dst_len_u8, 1)) ||
115
+ !EVP_DigestUpdate(&ctx, &dst_len_u8, 1) ||
120
116
  !EVP_DigestFinal_ex(&ctx, b_i, NULL)) {
121
117
  goto err;
122
118
  }
@@ -175,12 +171,11 @@ static void big_endian_to_words(BN_ULONG *out, size_t num_words,
175
171
  static int hash_to_field2(const EC_GROUP *group, const EVP_MD *md,
176
172
  EC_FELEM *out1, EC_FELEM *out2, const uint8_t *dst,
177
173
  size_t dst_len, unsigned k, const uint8_t *msg,
178
- size_t msg_len, int is_draft06) {
174
+ size_t msg_len) {
179
175
  size_t L;
180
176
  uint8_t buf[4 * EC_MAX_BYTES];
181
177
  if (!num_bytes_to_derive(&L, &group->field, k) ||
182
- !expand_message_xmd(md, buf, 2 * L, msg, msg_len, dst, dst_len,
183
- is_draft06)) {
178
+ !expand_message_xmd(md, buf, 2 * L, msg, msg_len, dst, dst_len)) {
184
179
  return 0;
185
180
  }
186
181
  BN_ULONG words[2 * EC_MAX_WORDS];
@@ -196,12 +191,11 @@ static int hash_to_field2(const EC_GROUP *group, const EVP_MD *md,
196
191
  // group order rather than a field element. |k| is the security factor.
197
192
  static int hash_to_scalar(const EC_GROUP *group, const EVP_MD *md,
198
193
  EC_SCALAR *out, const uint8_t *dst, size_t dst_len,
199
- unsigned k, const uint8_t *msg, size_t msg_len,
200
- int is_draft06) {
194
+ unsigned k, const uint8_t *msg, size_t msg_len) {
201
195
  size_t L;
202
196
  uint8_t buf[EC_MAX_BYTES * 2];
203
197
  if (!num_bytes_to_derive(&L, &group->order, k) ||
204
- !expand_message_xmd(md, buf, L, msg, msg_len, dst, dst_len, is_draft06)) {
198
+ !expand_message_xmd(md, buf, L, msg, msg_len, dst, dst_len)) {
205
199
  return 0;
206
200
  }
207
201
 
@@ -310,10 +304,9 @@ static int map_to_curve_simple_swu(const EC_GROUP *group, const EC_FELEM *Z,
310
304
  static int hash_to_curve(const EC_GROUP *group, const EVP_MD *md,
311
305
  const EC_FELEM *Z, const EC_FELEM *c2, unsigned k,
312
306
  EC_RAW_POINT *out, const uint8_t *dst, size_t dst_len,
313
- const uint8_t *msg, size_t msg_len, int is_draft06) {
307
+ const uint8_t *msg, size_t msg_len) {
314
308
  EC_FELEM u0, u1;
315
- if (!hash_to_field2(group, md, &u0, &u1, dst, dst_len, k, msg, msg_len,
316
- is_draft06)) {
309
+ if (!hash_to_field2(group, md, &u0, &u1, dst, dst_len, k, msg, msg_len)) {
317
310
  return 0;
318
311
  }
319
312
 
@@ -376,7 +369,7 @@ int ec_hash_to_curve_p384_xmd_sha512_sswu_draft07(
376
369
  ec_felem_neg(group, &Z, &Z);
377
370
 
378
371
  return hash_to_curve(group, EVP_sha512(), &Z, &c2, /*k=*/192, out, dst,
379
- dst_len, msg, msg_len, /*is_draft06=*/0);
372
+ dst_len, msg, msg_len);
380
373
  }
381
374
 
382
375
  int ec_hash_to_scalar_p384_xmd_sha512_draft07(
@@ -388,38 +381,5 @@ int ec_hash_to_scalar_p384_xmd_sha512_draft07(
388
381
  }
389
382
 
390
383
  return hash_to_scalar(group, EVP_sha512(), out, dst, dst_len, /*k=*/192, msg,
391
- msg_len, /*is_draft06=*/0);
392
- }
393
-
394
- int ec_hash_to_curve_p521_xmd_sha512_sswu_draft06(
395
- const EC_GROUP *group, EC_RAW_POINT *out, const uint8_t *dst,
396
- size_t dst_len, const uint8_t *msg, size_t msg_len) {
397
- // See section 8.3 of draft-irtf-cfrg-hash-to-curve-06.
398
- if (EC_GROUP_get_curve_name(group) != NID_secp521r1) {
399
- OPENSSL_PUT_ERROR(EC, EC_R_GROUP_MISMATCH);
400
- return 0;
401
- }
402
-
403
- // Z = -4, c2 = 8.
404
- EC_FELEM Z, c2;
405
- if (!felem_from_u8(group, &Z, 4) ||
406
- !felem_from_u8(group, &c2, 8)) {
407
- return 0;
408
- }
409
- ec_felem_neg(group, &Z, &Z);
410
-
411
- return hash_to_curve(group, EVP_sha512(), &Z, &c2, /*k=*/256, out, dst,
412
- dst_len, msg, msg_len, /*is_draft06=*/1);
413
- }
414
-
415
- int ec_hash_to_scalar_p521_xmd_sha512_draft06(
416
- const EC_GROUP *group, EC_SCALAR *out, const uint8_t *dst, size_t dst_len,
417
- const uint8_t *msg, size_t msg_len) {
418
- if (EC_GROUP_get_curve_name(group) != NID_secp521r1) {
419
- OPENSSL_PUT_ERROR(EC, EC_R_GROUP_MISMATCH);
420
- return 0;
421
- }
422
-
423
- return hash_to_scalar(group, EVP_sha512(), out, dst, dst_len, /*k=*/256, msg,
424
- msg_len, /*is_draft06=*/1);
384
+ msg_len);
425
385
  }
@@ -48,28 +48,6 @@ OPENSSL_EXPORT int ec_hash_to_scalar_p384_xmd_sha512_draft07(
48
48
  const EC_GROUP *group, EC_SCALAR *out, const uint8_t *dst, size_t dst_len,
49
49
  const uint8_t *msg, size_t msg_len);
50
50
 
51
- // ec_hash_to_curve_p521_xmd_sha512_sswu_draft06 hashes |msg| to a point on
52
- // |group| and writes the result to |out|, implementing the
53
- // P521_XMD:SHA-512_SSWU_RO_ suite from draft-irtf-cfrg-hash-to-curve-06. It
54
- // returns one on success and zero on error.
55
- //
56
- // This function implements an older version of the draft and should not be used
57
- // in new code.
58
- OPENSSL_EXPORT int ec_hash_to_curve_p521_xmd_sha512_sswu_draft06(
59
- const EC_GROUP *group, EC_RAW_POINT *out, const uint8_t *dst,
60
- size_t dst_len, const uint8_t *msg, size_t msg_len);
61
-
62
- // ec_hash_to_scalar_p521_xmd_sha512_draft06 hashes |msg| to a scalar on |group|
63
- // and writes the result to |out|, using the hash_to_field operation from the
64
- // P521_XMD:SHA-512_SSWU_RO_ suite from draft-irtf-cfrg-hash-to-curve-06, but
65
- // generating a value modulo the group order rather than a field element.
66
- //
67
- // This function implements an older version of the draft and should not be used
68
- // in new code.
69
- OPENSSL_EXPORT int ec_hash_to_scalar_p521_xmd_sha512_draft06(
70
- const EC_GROUP *group, EC_SCALAR *out, const uint8_t *dst, size_t dst_len,
71
- const uint8_t *msg, size_t msg_len);
72
-
73
51
 
74
52
  #if defined(__cplusplus)
75
53
  } // extern C
@@ -65,6 +65,7 @@
65
65
  #include <openssl/rsa.h>
66
66
 
67
67
  #include "internal.h"
68
+ #include "../bytestring/internal.h"
68
69
  #include "../internal.h"
69
70
 
70
71
 
@@ -386,3 +387,145 @@ err:
386
387
  EVP_PKEY_free(ret);
387
388
  return NULL;
388
389
  }
390
+
391
+ EVP_PKEY *d2i_PUBKEY(EVP_PKEY **out, const uint8_t **inp, long len) {
392
+ if (len < 0) {
393
+ return NULL;
394
+ }
395
+ CBS cbs;
396
+ CBS_init(&cbs, *inp, (size_t)len);
397
+ EVP_PKEY *ret = EVP_parse_public_key(&cbs);
398
+ if (ret == NULL) {
399
+ return NULL;
400
+ }
401
+ if (out != NULL) {
402
+ EVP_PKEY_free(*out);
403
+ *out = ret;
404
+ }
405
+ *inp = CBS_data(&cbs);
406
+ return ret;
407
+ }
408
+
409
+ int i2d_PUBKEY(const EVP_PKEY *pkey, uint8_t **outp) {
410
+ CBB cbb;
411
+ if (!CBB_init(&cbb, 128) ||
412
+ !EVP_marshal_public_key(&cbb, pkey)) {
413
+ CBB_cleanup(&cbb);
414
+ return -1;
415
+ }
416
+ return CBB_finish_i2d(&cbb, outp);
417
+ }
418
+
419
+ RSA *d2i_RSA_PUBKEY(RSA **out, const uint8_t **inp, long len) {
420
+ if (len < 0) {
421
+ return NULL;
422
+ }
423
+ CBS cbs;
424
+ CBS_init(&cbs, *inp, (size_t)len);
425
+ EVP_PKEY *pkey = EVP_parse_public_key(&cbs);
426
+ if (pkey == NULL) {
427
+ return NULL;
428
+ }
429
+ RSA *rsa = EVP_PKEY_get1_RSA(pkey);
430
+ EVP_PKEY_free(pkey);
431
+ if (rsa == NULL) {
432
+ return NULL;
433
+ }
434
+ if (out != NULL) {
435
+ RSA_free(*out);
436
+ *out = rsa;
437
+ }
438
+ *inp = CBS_data(&cbs);
439
+ return rsa;
440
+ }
441
+
442
+ int i2d_RSA_PUBKEY(const RSA *rsa, uint8_t **outp) {
443
+ int ret = -1;
444
+ EVP_PKEY *pkey = EVP_PKEY_new();
445
+ if (pkey == NULL ||
446
+ !EVP_PKEY_set1_RSA(pkey, (RSA *)rsa)) {
447
+ goto err;
448
+ }
449
+
450
+ ret = i2d_PUBKEY(pkey, outp);
451
+
452
+ err:
453
+ EVP_PKEY_free(pkey);
454
+ return ret;
455
+ }
456
+
457
+ DSA *d2i_DSA_PUBKEY(DSA **out, const uint8_t **inp, long len) {
458
+ if (len < 0) {
459
+ return NULL;
460
+ }
461
+ CBS cbs;
462
+ CBS_init(&cbs, *inp, (size_t)len);
463
+ EVP_PKEY *pkey = EVP_parse_public_key(&cbs);
464
+ if (pkey == NULL) {
465
+ return NULL;
466
+ }
467
+ DSA *dsa = EVP_PKEY_get1_DSA(pkey);
468
+ EVP_PKEY_free(pkey);
469
+ if (dsa == NULL) {
470
+ return NULL;
471
+ }
472
+ if (out != NULL) {
473
+ DSA_free(*out);
474
+ *out = dsa;
475
+ }
476
+ *inp = CBS_data(&cbs);
477
+ return dsa;
478
+ }
479
+
480
+ int i2d_DSA_PUBKEY(const DSA *dsa, uint8_t **outp) {
481
+ int ret = -1;
482
+ EVP_PKEY *pkey = EVP_PKEY_new();
483
+ if (pkey == NULL ||
484
+ !EVP_PKEY_set1_DSA(pkey, (DSA *)dsa)) {
485
+ goto err;
486
+ }
487
+
488
+ ret = i2d_PUBKEY(pkey, outp);
489
+
490
+ err:
491
+ EVP_PKEY_free(pkey);
492
+ return ret;
493
+ }
494
+
495
+ EC_KEY *d2i_EC_PUBKEY(EC_KEY **out, const uint8_t **inp, long len) {
496
+ if (len < 0) {
497
+ return NULL;
498
+ }
499
+ CBS cbs;
500
+ CBS_init(&cbs, *inp, (size_t)len);
501
+ EVP_PKEY *pkey = EVP_parse_public_key(&cbs);
502
+ if (pkey == NULL) {
503
+ return NULL;
504
+ }
505
+ EC_KEY *ec_key = EVP_PKEY_get1_EC_KEY(pkey);
506
+ EVP_PKEY_free(pkey);
507
+ if (ec_key == NULL) {
508
+ return NULL;
509
+ }
510
+ if (out != NULL) {
511
+ EC_KEY_free(*out);
512
+ *out = ec_key;
513
+ }
514
+ *inp = CBS_data(&cbs);
515
+ return ec_key;
516
+ }
517
+
518
+ int i2d_EC_PUBKEY(const EC_KEY *ec_key, uint8_t **outp) {
519
+ int ret = -1;
520
+ EVP_PKEY *pkey = EVP_PKEY_new();
521
+ if (pkey == NULL ||
522
+ !EVP_PKEY_set1_EC_KEY(pkey, (EC_KEY *)ec_key)) {
523
+ goto err;
524
+ }
525
+
526
+ ret = i2d_PUBKEY(pkey, outp);
527
+
528
+ err:
529
+ EVP_PKEY_free(pkey);
530
+ return ret;
531
+ }
@@ -57,7 +57,23 @@
57
57
  void AES_ctr128_encrypt(const uint8_t *in, uint8_t *out, size_t len,
58
58
  const AES_KEY *key, uint8_t ivec[AES_BLOCK_SIZE],
59
59
  uint8_t ecount_buf[AES_BLOCK_SIZE], unsigned int *num) {
60
- CRYPTO_ctr128_encrypt(in, out, len, key, ivec, ecount_buf, num, AES_encrypt);
60
+ if (hwaes_capable()) {
61
+ CRYPTO_ctr128_encrypt_ctr32(in, out, len, key, ivec, ecount_buf, num,
62
+ aes_hw_ctr32_encrypt_blocks);
63
+ } else if (vpaes_capable()) {
64
+ #if defined(VPAES_CTR32)
65
+ // TODO(davidben): On ARM, where |BSAES| is additionally defined, this could
66
+ // use |vpaes_ctr32_encrypt_blocks_with_bsaes|.
67
+ CRYPTO_ctr128_encrypt_ctr32(in, out, len, key, ivec, ecount_buf, num,
68
+ vpaes_ctr32_encrypt_blocks);
69
+ #else
70
+ CRYPTO_ctr128_encrypt(in, out, len, key, ivec, ecount_buf, num,
71
+ vpaes_encrypt);
72
+ #endif
73
+ } else {
74
+ CRYPTO_ctr128_encrypt_ctr32(in, out, len, key, ivec, ecount_buf, num,
75
+ aes_nohw_ctr32_encrypt_blocks);
76
+ }
61
77
  }
62
78
 
63
79
  void AES_ecb_encrypt(const uint8_t *in, uint8_t *out, const AES_KEY *key,
@@ -404,9 +404,19 @@ uint64_t bn_mont_n0(const BIGNUM *n);
404
404
  int bn_mod_exp_base_2_consttime(BIGNUM *r, unsigned p, const BIGNUM *n,
405
405
  BN_CTX *ctx);
406
406
 
407
- #if defined(OPENSSL_X86_64) && defined(_MSC_VER)
407
+ #if defined(_MSC_VER)
408
+ #if defined(OPENSSL_X86_64)
408
409
  #define BN_UMULT_LOHI(low, high, a, b) ((low) = _umul128((a), (b), &(high)))
410
+ #elif defined(OPENSSL_AARCH64)
411
+ #define BN_UMULT_LOHI(low, high, a, b) \
412
+ do { \
413
+ const BN_ULONG _a = (a); \
414
+ const BN_ULONG _b = (b); \
415
+ (low) = _a * _b; \
416
+ (high) = __umulh(_a, _b); \
417
+ } while (0)
409
418
  #endif
419
+ #endif // _MSC_VER
410
420
 
411
421
  #if !defined(BN_ULLONG) && !defined(BN_UMULT_LOHI)
412
422
  #error "Either BN_ULLONG or BN_UMULT_LOHI must be defined on every platform."