grpc 1.38.0 → 1.40.0

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 (340) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +68 -21
  3. data/include/grpc/event_engine/endpoint_config.h +48 -0
  4. data/include/grpc/event_engine/event_engine.h +23 -29
  5. data/include/grpc/event_engine/port.h +2 -0
  6. data/include/grpc/event_engine/slice_allocator.h +21 -36
  7. data/include/grpc/grpc.h +9 -2
  8. data/include/grpc/grpc_security.h +32 -0
  9. data/include/grpc/grpc_security_constants.h +1 -0
  10. data/include/grpc/impl/codegen/grpc_types.h +33 -19
  11. data/include/grpc/impl/codegen/port_platform.h +41 -0
  12. data/src/core/ext/filters/client_channel/client_channel.cc +415 -249
  13. data/src/core/ext/filters/client_channel/client_channel.h +42 -18
  14. data/src/core/ext/filters/client_channel/config_selector.h +19 -6
  15. data/src/core/ext/filters/client_channel/health/health_check_client.cc +2 -0
  16. data/src/core/ext/filters/client_channel/health/health_check_client.h +3 -3
  17. data/src/core/ext/filters/client_channel/http_proxy.cc +16 -1
  18. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +7 -8
  19. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +12 -21
  20. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +3 -5
  21. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +734 -0
  22. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +10 -0
  23. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +8 -15
  24. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +3 -6
  25. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +18 -36
  26. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +14 -22
  27. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +2 -9
  28. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +68 -103
  29. data/src/core/ext/filters/client_channel/lb_policy.cc +1 -15
  30. data/src/core/ext/filters/client_channel/lb_policy.h +70 -46
  31. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +1 -3
  32. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_event_engine.cc +31 -0
  33. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_event_engine.cc +28 -0
  34. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +1 -3
  35. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +7 -2
  36. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +116 -76
  37. data/src/core/ext/filters/client_channel/retry_filter.cc +967 -544
  38. data/src/core/ext/filters/client_channel/retry_service_config.cc +57 -28
  39. data/src/core/ext/filters/client_channel/retry_service_config.h +9 -3
  40. data/src/core/ext/filters/client_channel/service_config_call_data.h +45 -5
  41. data/src/core/ext/filters/client_idle/client_idle_filter.cc +1 -1
  42. data/src/core/ext/filters/http/client/http_client_filter.cc +5 -2
  43. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +2 -1
  44. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +5 -1
  45. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +3 -2
  46. data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +1 -1
  47. data/src/core/{lib/event_engine/slice_allocator.cc → ext/transport/chttp2/transport/chttp2_slice_allocator.cc} +23 -16
  48. data/src/core/ext/transport/chttp2/transport/chttp2_slice_allocator.h +74 -0
  49. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +12 -10
  50. data/src/core/ext/transport/chttp2/transport/flow_control.h +1 -1
  51. data/src/core/ext/transport/chttp2/transport/frame_data.cc +4 -4
  52. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +8 -8
  53. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +5 -5
  54. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +639 -752
  55. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +190 -69
  56. data/src/core/ext/transport/chttp2/transport/internal.h +2 -1
  57. data/src/core/ext/transport/chttp2/transport/parsing.cc +72 -56
  58. data/src/core/ext/transport/chttp2/transport/varint.cc +6 -4
  59. data/src/core/ext/transport/inproc/inproc_transport.cc +42 -31
  60. data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c +56 -35
  61. data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.h +180 -76
  62. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +35 -27
  63. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +97 -48
  64. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +45 -9
  65. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +67 -7
  66. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +66 -9
  67. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +227 -0
  68. data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.c +46 -0
  69. data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.h +121 -0
  70. data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c +1 -0
  71. data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.c +35 -0
  72. data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.h +90 -0
  73. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +32 -24
  74. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +120 -73
  75. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +4 -2
  76. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +15 -0
  77. data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.c +48 -0
  78. data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.h +171 -0
  79. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c +8 -6
  80. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.h +27 -19
  81. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +1 -0
  82. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c +24 -7
  83. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.h +57 -0
  84. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +29 -17
  85. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +72 -0
  86. data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.c +3 -2
  87. data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.h +4 -0
  88. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c +6 -5
  89. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.h +15 -11
  90. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +85 -43
  91. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +274 -91
  92. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +11 -8
  93. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +30 -13
  94. data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.c +33 -5
  95. data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.h +115 -0
  96. data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.c +60 -0
  97. data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.h +181 -0
  98. data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.c +1 -0
  99. data/src/core/ext/upb-generated/validate/validate.upb.c +82 -66
  100. data/src/core/ext/upb-generated/validate/validate.upb.h +220 -124
  101. data/src/core/ext/upbdefs-generated/envoy/annotations/deprecation.upbdefs.c +15 -7
  102. data/src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.c +53 -52
  103. data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.c +318 -277
  104. data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.h +5 -0
  105. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.c +437 -410
  106. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.c +198 -170
  107. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.h +10 -0
  108. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.c +9 -8
  109. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +219 -163
  110. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.h +15 -0
  111. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/resolver.upbdefs.c +59 -0
  112. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/resolver.upbdefs.h +40 -0
  113. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/substitution_format_string.upbdefs.c +29 -25
  114. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/udp_socket_config.upbdefs.c +52 -0
  115. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/udp_socket_config.upbdefs.h +35 -0
  116. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.c +135 -125
  117. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.h +5 -0
  118. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener_components.upbdefs.c +131 -123
  119. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/quic_config.upbdefs.c +90 -0
  120. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/quic_config.upbdefs.h +35 -0
  121. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/udp_listener_config.upbdefs.c +32 -24
  122. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.c +69 -55
  123. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.h +5 -0
  124. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +684 -664
  125. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.h +5 -0
  126. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.c +13 -10
  127. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.c +13 -10
  128. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +441 -375
  129. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.h +10 -0
  130. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.c +122 -114
  131. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +1 -1
  132. data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.c +112 -79
  133. data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.h +5 -0
  134. data/src/core/ext/upbdefs-generated/envoy/type/http/v3/path_transformation.upbdefs.c +64 -0
  135. data/src/core/ext/upbdefs-generated/envoy/type/http/v3/path_transformation.upbdefs.h +50 -0
  136. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/regex.upbdefs.c +35 -32
  137. data/src/core/ext/upbdefs-generated/google/rpc/status.upbdefs.c +4 -4
  138. data/src/core/ext/upbdefs-generated/validate/validate.upbdefs.c +182 -160
  139. data/src/core/ext/xds/certificate_provider_store.h +1 -1
  140. data/src/core/ext/xds/xds_api.cc +582 -257
  141. data/src/core/ext/xds/xds_api.h +46 -8
  142. data/src/core/ext/xds/xds_bootstrap.cc +4 -1
  143. data/src/core/ext/xds/xds_client.cc +66 -43
  144. data/src/core/ext/xds/xds_client.h +0 -4
  145. data/src/core/ext/xds/xds_http_filters.cc +3 -2
  146. data/src/core/ext/xds/xds_http_filters.h +3 -0
  147. data/src/core/lib/address_utils/sockaddr_utils.cc +13 -0
  148. data/src/core/lib/address_utils/sockaddr_utils.h +10 -0
  149. data/src/core/lib/channel/call_tracer.h +85 -0
  150. data/src/core/lib/channel/channel_stack.h +1 -1
  151. data/src/core/lib/channel/channelz.h +3 -0
  152. data/src/core/lib/channel/context.h +3 -0
  153. data/src/core/lib/channel/status_util.h +4 -0
  154. data/src/core/lib/compression/stream_compression.h +1 -1
  155. data/src/core/lib/compression/stream_compression_gzip.h +1 -1
  156. data/src/core/lib/compression/stream_compression_identity.h +1 -1
  157. data/src/core/lib/debug/stats.h +1 -1
  158. data/src/core/lib/event_engine/endpoint_config.cc +46 -0
  159. data/src/core/lib/event_engine/endpoint_config_internal.h +42 -0
  160. data/src/core/lib/event_engine/event_engine.cc +50 -0
  161. data/src/core/lib/event_engine/sockaddr.cc +14 -12
  162. data/src/core/lib/event_engine/sockaddr.h +44 -0
  163. data/src/core/lib/gpr/murmur_hash.cc +4 -2
  164. data/src/core/lib/gpr/wrap_memcpy.cc +2 -1
  165. data/src/core/lib/gprpp/manual_constructor.h +1 -1
  166. data/src/core/lib/gprpp/orphanable.h +3 -3
  167. data/src/core/lib/gprpp/status_helper.h +3 -0
  168. data/src/core/lib/gprpp/sync.h +2 -30
  169. data/src/core/lib/iomgr/buffer_list.cc +1 -1
  170. data/src/core/lib/iomgr/endpoint_pair_event_engine.cc +33 -0
  171. data/src/core/lib/iomgr/error.cc +5 -4
  172. data/src/core/lib/iomgr/error.h +1 -1
  173. data/src/core/lib/iomgr/ev_apple.h +1 -1
  174. data/src/core/lib/iomgr/event_engine/closure.cc +54 -0
  175. data/src/core/lib/iomgr/event_engine/closure.h +33 -0
  176. data/src/core/lib/iomgr/event_engine/endpoint.cc +192 -0
  177. data/src/core/lib/iomgr/event_engine/endpoint.h +53 -0
  178. data/src/core/lib/iomgr/event_engine/iomgr.cc +105 -0
  179. data/src/core/lib/iomgr/event_engine/iomgr.h +24 -0
  180. data/src/core/lib/iomgr/event_engine/pollset.cc +87 -0
  181. data/{include/grpc/event_engine/channel_args.h → src/core/lib/iomgr/event_engine/pollset.h} +7 -10
  182. data/src/core/lib/iomgr/event_engine/promise.h +51 -0
  183. data/src/core/lib/iomgr/event_engine/resolved_address_internal.cc +41 -0
  184. data/src/core/lib/iomgr/event_engine/resolved_address_internal.h +35 -0
  185. data/src/core/lib/iomgr/event_engine/resolver.cc +110 -0
  186. data/src/core/lib/iomgr/event_engine/tcp.cc +263 -0
  187. data/src/core/lib/iomgr/event_engine/timer.cc +57 -0
  188. data/src/core/lib/iomgr/exec_ctx.cc +8 -0
  189. data/src/core/lib/iomgr/exec_ctx.h +3 -4
  190. data/src/core/lib/iomgr/executor/threadpool.cc +2 -3
  191. data/src/core/lib/iomgr/executor/threadpool.h +2 -2
  192. data/src/core/lib/iomgr/iomgr.cc +1 -1
  193. data/src/core/lib/iomgr/iomgr_posix.cc +2 -0
  194. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +40 -10
  195. data/src/core/lib/iomgr/pollset_custom.cc +2 -2
  196. data/src/core/lib/iomgr/pollset_custom.h +3 -1
  197. data/src/core/lib/iomgr/pollset_uv.cc +3 -1
  198. data/src/core/lib/iomgr/pollset_uv.h +5 -1
  199. data/src/core/lib/iomgr/port.h +7 -5
  200. data/src/core/lib/iomgr/python_util.h +1 -1
  201. data/src/core/lib/iomgr/resolve_address.cc +5 -1
  202. data/src/core/lib/iomgr/resolve_address.h +6 -0
  203. data/src/core/lib/iomgr/resource_quota.cc +2 -0
  204. data/src/core/lib/iomgr/sockaddr.h +1 -0
  205. data/src/core/lib/iomgr/socket_mutator.cc +15 -2
  206. data/src/core/lib/iomgr/socket_mutator.h +26 -2
  207. data/src/core/lib/iomgr/socket_utils_common_posix.cc +4 -4
  208. data/src/core/lib/iomgr/socket_utils_posix.h +2 -2
  209. data/src/core/lib/iomgr/tcp_client_posix.cc +7 -2
  210. data/src/core/lib/iomgr/tcp_client_windows.cc +2 -0
  211. data/src/core/lib/iomgr/tcp_posix.cc +42 -39
  212. data/src/core/lib/iomgr/tcp_posix.h +8 -0
  213. data/src/core/lib/iomgr/tcp_server_custom.cc +3 -4
  214. data/src/core/lib/iomgr/tcp_server_posix.cc +7 -0
  215. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +2 -1
  216. data/src/core/lib/iomgr/timer.h +6 -1
  217. data/src/core/lib/iomgr/timer_manager.cc +1 -1
  218. data/src/core/lib/json/json_reader.cc +1 -2
  219. data/src/core/lib/matchers/matchers.cc +8 -20
  220. data/src/core/lib/matchers/matchers.h +2 -1
  221. data/src/core/lib/security/authorization/authorization_engine.h +44 -0
  222. data/src/core/lib/security/authorization/authorization_policy_provider.h +32 -0
  223. data/src/core/lib/security/authorization/authorization_policy_provider_vtable.cc +46 -0
  224. data/src/core/lib/security/authorization/evaluate_args.cc +209 -0
  225. data/src/core/lib/security/authorization/evaluate_args.h +91 -0
  226. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +3 -1
  227. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +49 -0
  228. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +7 -0
  229. data/src/core/lib/security/credentials/tls/tls_utils.cc +32 -0
  230. data/src/core/lib/security/credentials/tls/tls_utils.h +13 -0
  231. data/src/core/lib/security/security_connector/local/local_security_connector.cc +9 -6
  232. data/src/core/lib/security/security_connector/ssl_utils.cc +5 -0
  233. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +6 -18
  234. data/src/core/lib/security/transport/security_handshaker.cc +12 -4
  235. data/src/core/lib/security/transport/server_auth_filter.cc +0 -7
  236. data/src/core/lib/slice/slice.cc +12 -2
  237. data/src/core/lib/slice/slice_internal.h +1 -0
  238. data/src/core/lib/surface/call.cc +26 -7
  239. data/src/core/lib/surface/call.h +11 -0
  240. data/src/core/lib/surface/completion_queue.cc +22 -22
  241. data/src/core/lib/surface/completion_queue.h +1 -1
  242. data/src/core/lib/surface/completion_queue_factory.cc +1 -2
  243. data/src/core/lib/surface/init.cc +1 -3
  244. data/src/core/lib/surface/init.h +10 -1
  245. data/src/core/lib/surface/server.cc +3 -1
  246. data/src/core/lib/surface/server.h +3 -3
  247. data/src/core/lib/surface/version.cc +2 -4
  248. data/src/core/lib/transport/error_utils.cc +2 -2
  249. data/src/core/lib/transport/metadata_batch.cc +13 -2
  250. data/src/core/lib/transport/metadata_batch.h +7 -0
  251. data/src/core/lib/transport/transport.h +2 -0
  252. data/src/core/lib/transport/transport_op_string.cc +1 -1
  253. data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -0
  254. data/src/core/tsi/alts/crypt/gsec.h +2 -0
  255. data/src/ruby/ext/grpc/extconf.rb +2 -0
  256. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +6 -0
  257. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +10 -1
  258. data/src/ruby/lib/grpc/version.rb +1 -1
  259. data/third_party/boringssl-with-bazel/err_data.c +269 -263
  260. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +8 -6
  261. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/cipher_extra.c +4 -0
  262. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +1 -1
  263. data/third_party/boringssl-with-bazel/src/crypto/curve25519/internal.h +1 -1
  264. data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +9 -0
  265. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/prime.c +0 -4
  266. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +7 -0
  267. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/md32_common.h +87 -121
  268. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md4/md4.c +20 -30
  269. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md5/md5.c +19 -30
  270. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +1 -4
  271. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +0 -13
  272. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +26 -24
  273. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +10 -7
  274. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1.c +28 -39
  275. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha256.c +48 -66
  276. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +4 -5
  277. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +362 -371
  278. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7_x509.c +4 -2
  279. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/passive.c +2 -2
  280. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_asn1.c +1 -2
  281. data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +101 -11
  282. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509a.c +3 -0
  283. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +2 -2
  284. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +3 -0
  285. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +1 -1
  286. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +2 -0
  287. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +14 -15
  288. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vpm.c +53 -73
  289. data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +31 -0
  290. data/third_party/boringssl-with-bazel/src/crypto/x509/x509rset.c +3 -0
  291. data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.c +3 -0
  292. data/third_party/boringssl-with-bazel/src/crypto/x509/x_req.c +5 -8
  293. data/third_party/boringssl-with-bazel/src/crypto/x509/x_sig.c +5 -0
  294. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +3 -0
  295. data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +7 -0
  296. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +1 -1
  297. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +5 -8
  298. data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +1 -1
  299. data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +66 -1
  300. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +40 -9
  301. data/third_party/boringssl-with-bazel/src/include/openssl/bytestring.h +1 -0
  302. data/third_party/boringssl-with-bazel/src/include/openssl/chacha.h +1 -1
  303. data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +6 -2
  304. data/third_party/boringssl-with-bazel/src/include/openssl/ecdsa.h +14 -0
  305. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +19 -11
  306. data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +325 -0
  307. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +23 -7
  308. data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +99 -63
  309. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +139 -109
  310. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +12 -19
  311. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +48 -50
  312. data/third_party/boringssl-with-bazel/src/include/openssl/x509_vfy.h +451 -435
  313. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +0 -1
  314. data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +2 -2
  315. data/third_party/boringssl-with-bazel/src/ssl/d1_srtp.cc +1 -1
  316. data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +773 -84
  317. data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +80 -47
  318. data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +24 -19
  319. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +189 -86
  320. data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +45 -56
  321. data/third_party/boringssl-with-bazel/src/ssl/internal.h +272 -167
  322. data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +2 -2
  323. data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +2 -2
  324. data/third_party/boringssl-with-bazel/src/ssl/s3_pkt.cc +14 -19
  325. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +34 -102
  326. data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +2 -0
  327. data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +8 -31
  328. data/third_party/boringssl-with-bazel/src/ssl/ssl_stat.cc +3 -0
  329. data/third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc +4 -3
  330. data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +7 -3
  331. data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +576 -648
  332. data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +31 -3
  333. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +98 -39
  334. data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +141 -94
  335. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +58 -68
  336. data/third_party/xxhash/xxhash.h +77 -195
  337. metadata +81 -39
  338. data/src/core/lib/gpr/arena.h +0 -47
  339. data/third_party/boringssl-with-bazel/src/crypto/hpke/internal.h +0 -267
  340. data/third_party/boringssl-with-bazel/src/crypto/x509/vpm_int.h +0 -71
@@ -180,16 +180,13 @@ ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
180
180
  }
181
181
  }
182
182
 
183
- /*
184
- * only the ASN1_OBJECTs from the 'table' will have values for ->sn or
185
- * ->ln
186
- */
187
183
  if ((a == NULL) || ((*a) == NULL) ||
188
184
  !((*a)->flags & ASN1_OBJECT_FLAG_DYNAMIC)) {
189
185
  if ((ret = ASN1_OBJECT_new()) == NULL)
190
186
  return (NULL);
191
- } else
187
+ } else {
192
188
  ret = (*a);
189
+ }
193
190
 
194
191
  p = *pp;
195
192
  /* detach data from object */
@@ -208,12 +205,17 @@ ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
208
205
  ret->flags |= ASN1_OBJECT_FLAG_DYNAMIC_DATA;
209
206
  }
210
207
  OPENSSL_memcpy(data, p, length);
208
+ /* If there are dynamic strings, free them here, and clear the flag */
209
+ if ((ret->flags & ASN1_OBJECT_FLAG_DYNAMIC_STRINGS) != 0) {
210
+ OPENSSL_free((char *)ret->sn);
211
+ OPENSSL_free((char *)ret->ln);
212
+ ret->flags &= ~ASN1_OBJECT_FLAG_DYNAMIC_STRINGS;
213
+ }
211
214
  /* reattach data to object, after which it remains const */
212
215
  ret->data = data;
213
216
  ret->length = length;
214
217
  ret->sn = NULL;
215
218
  ret->ln = NULL;
216
- /* ret->flags=ASN1_OBJECT_FLAG_DYNAMIC; we know it is dynamic */
217
219
  p += length;
218
220
 
219
221
  if (a != NULL)
@@ -89,6 +89,10 @@ const EVP_CIPHER *EVP_get_cipherbynid(int nid) {
89
89
  }
90
90
 
91
91
  const EVP_CIPHER *EVP_get_cipherbyname(const char *name) {
92
+ if (name == NULL) {
93
+ return NULL;
94
+ }
95
+
92
96
  if (OPENSSL_strcasecmp(name, "rc4") == 0) {
93
97
  return EVP_rc4();
94
98
  } else if (OPENSSL_strcasecmp(name, "des-cbc") == 0) {
@@ -820,7 +820,7 @@ static void table_select(ge_precomp *t, int pos, signed char b) {
820
820
  //
821
821
  // Preconditions:
822
822
  // a[31] <= 127
823
- void x25519_ge_scalarmult_base(ge_p3 *h, const uint8_t *a) {
823
+ void x25519_ge_scalarmult_base(ge_p3 *h, const uint8_t a[32]) {
824
824
  signed char e[64];
825
825
  signed char carry;
826
826
  ge_p1p1 r;
@@ -106,7 +106,7 @@ typedef struct {
106
106
  } ge_cached;
107
107
 
108
108
  void x25519_ge_tobytes(uint8_t s[32], const ge_p2 *h);
109
- int x25519_ge_frombytes_vartime(ge_p3 *h, const uint8_t *s);
109
+ int x25519_ge_frombytes_vartime(ge_p3 *h, const uint8_t s[32]);
110
110
  void x25519_ge_p3_to_cached(ge_cached *r, const ge_p3 *p);
111
111
  void x25519_ge_p1p1_to_p2(ge_p2 *r, const ge_p1p1 *p);
112
112
  void x25519_ge_p1p1_to_p3(ge_p3 *r, const ge_p1p1 *p);
@@ -429,6 +429,15 @@ int EVP_PKEY_CTX_get_signature_md(EVP_PKEY_CTX *ctx, const EVP_MD **out_md) {
429
429
  0, (void *)out_md);
430
430
  }
431
431
 
432
+ void *EVP_PKEY_get0(const EVP_PKEY *pkey) {
433
+ // Node references, but never calls this function, so for now we return NULL.
434
+ // If other projects require complete support, call |EVP_PKEY_get0_RSA|, etc.,
435
+ // rather than reading |pkey->pkey.ptr| directly. This avoids problems if our
436
+ // internal representation does not match the type the caller expects from
437
+ // OpenSSL.
438
+ return NULL;
439
+ }
440
+
432
441
  void OpenSSL_add_all_algorithms(void) {}
433
442
 
434
443
  void OPENSSL_add_all_algorithms_conf(void) {}
@@ -115,10 +115,6 @@
115
115
  #include "../../internal.h"
116
116
 
117
117
 
118
- // The quick sieve algorithm approach to weeding out primes is Philip
119
- // Zimmermann's, as implemented in PGP. I have had a read of his comments and
120
- // implemented my own version.
121
-
122
118
  // kPrimes contains the first 1024 primes.
123
119
  static const uint16_t kPrimes[] = {
124
120
  2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37,
@@ -177,6 +177,13 @@ int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in) {
177
177
  return 1;
178
178
  }
179
179
 
180
+ void EVP_MD_CTX_move(EVP_MD_CTX *out, EVP_MD_CTX *in) {
181
+ EVP_MD_CTX_cleanup(out);
182
+ // While not guaranteed, |EVP_MD_CTX| is currently safe to move with |memcpy|.
183
+ OPENSSL_memcpy(out, in, sizeof(EVP_MD_CTX));
184
+ EVP_MD_CTX_init(in);
185
+ }
186
+
180
187
  int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in) {
181
188
  EVP_MD_CTX_init(out);
182
189
  return EVP_MD_CTX_copy_ex(out, in);
@@ -46,6 +46,9 @@
46
46
  * OF THE POSSIBILITY OF SUCH DAMAGE.
47
47
  * ==================================================================== */
48
48
 
49
+ #ifndef OPENSSL_HEADER_DIGEST_MD32_COMMON_H
50
+ #define OPENSSL_HEADER_DIGEST_MD32_COMMON_H
51
+
49
52
  #include <openssl/base.h>
50
53
 
51
54
  #include <assert.h>
@@ -59,22 +62,15 @@ extern "C" {
59
62
 
60
63
  // This is a generic 32-bit "collector" for message digest algorithms. It
61
64
  // collects input character stream into chunks of 32-bit values and invokes the
62
- // block function that performs the actual hash calculations. To make use of
63
- // this mechanism, the following macros must be defined before including
64
- // md32_common.h.
65
- //
66
- // One of |DATA_ORDER_IS_BIG_ENDIAN| or |DATA_ORDER_IS_LITTLE_ENDIAN| must be
67
- // defined to specify the byte order of the input stream.
68
- //
69
- // |HASH_CBLOCK| must be defined as the integer block size, in bytes.
65
+ // block function that performs the actual hash calculations.
70
66
  //
71
- // |HASH_CTX| must be defined as the name of the context structure, which must
72
- // have at least the following members:
67
+ // To make use of this mechanism, the hash context should be defined with the
68
+ // following parameters.
73
69
  //
74
70
  // typedef struct <name>_state_st {
75
71
  // uint32_t h[<chaining length> / sizeof(uint32_t)];
76
72
  // uint32_t Nl, Nh;
77
- // uint8_t data[HASH_CBLOCK];
73
+ // uint8_t data[<block size>];
78
74
  // unsigned num;
79
75
  // ...
80
76
  // } <NAME>_CTX;
@@ -83,147 +79,117 @@ extern "C" {
83
79
  // any truncation (e.g. 64 for SHA-224 and SHA-256, 128 for SHA-384 and
84
80
  // SHA-512).
85
81
  //
86
- // |HASH_UPDATE| must be defined as the name of the "Update" function to
87
- // generate.
88
- //
89
- // |HASH_TRANSFORM| must be defined as the the name of the "Transform"
90
- // function to generate.
91
- //
92
- // |HASH_FINAL| must be defined as the name of "Final" function to generate.
93
- //
94
- // |HASH_BLOCK_DATA_ORDER| must be defined as the name of the "Block" function.
95
- // That function must be implemented manually. It must be capable of operating
96
- // on *unaligned* input data in its original (data) byte order. It must have
97
- // this signature:
98
- //
99
- // void HASH_BLOCK_DATA_ORDER(uint32_t *state, const uint8_t *data,
100
- // size_t num);
101
- //
102
- // It must update the hash state |state| with |num| blocks of data from |data|,
103
- // where each block is |HASH_CBLOCK| bytes; i.e. |data| points to a array of
104
- // |HASH_CBLOCK * num| bytes. |state| points to the |h| member of a |HASH_CTX|,
105
- // and so will have |<chaining length> / sizeof(uint32_t)| elements.
106
- //
107
- // |HASH_MAKE_STRING(c, s)| must be defined as a block statement that converts
108
- // the hash state |c->h| into the output byte order, storing the result in |s|.
109
-
110
- #if !defined(DATA_ORDER_IS_BIG_ENDIAN) && !defined(DATA_ORDER_IS_LITTLE_ENDIAN)
111
- #error "DATA_ORDER must be defined!"
112
- #endif
113
-
114
- #ifndef HASH_CBLOCK
115
- #error "HASH_CBLOCK must be defined!"
116
- #endif
117
- #ifndef HASH_CTX
118
- #error "HASH_CTX must be defined!"
119
- #endif
120
-
121
- #ifndef HASH_UPDATE
122
- #error "HASH_UPDATE must be defined!"
123
- #endif
124
- #ifndef HASH_TRANSFORM
125
- #error "HASH_TRANSFORM must be defined!"
126
- #endif
127
- #ifndef HASH_FINAL
128
- #error "HASH_FINAL must be defined!"
129
- #endif
130
-
131
- #ifndef HASH_BLOCK_DATA_ORDER
132
- #error "HASH_BLOCK_DATA_ORDER must be defined!"
133
- #endif
134
-
135
- #ifndef HASH_MAKE_STRING
136
- #error "HASH_MAKE_STRING must be defined!"
137
- #endif
138
-
139
- int HASH_UPDATE(HASH_CTX *c, const void *data_, size_t len) {
140
- const uint8_t *data = data_;
141
-
82
+ // |h| is the hash state and is updated by a function of type
83
+ // |crypto_md32_block_func|. |data| is the partial unprocessed block and has
84
+ // |num| bytes. |Nl| and |Nh| maintain the number of bits processed so far.
85
+
86
+ // A crypto_md32_block_func should incorporate |num_blocks| of input from |data|
87
+ // into |state|. It is assumed the caller has sized |state| and |data| for the
88
+ // hash function.
89
+ typedef void (*crypto_md32_block_func)(uint32_t *state, const uint8_t *data,
90
+ size_t num_blocks);
91
+
92
+ // crypto_md32_update adds |len| bytes from |in| to the digest. |data| must be a
93
+ // buffer of length |block_size| with the first |*num| bytes containing a
94
+ // partial block. This function combines the partial block with |in| and
95
+ // incorporates any complete blocks into the digest state |h|. It then updates
96
+ // |data| and |*num| with the new partial block and updates |*Nh| and |*Nl| with
97
+ // the data consumed.
98
+ static inline void crypto_md32_update(crypto_md32_block_func block_func,
99
+ uint32_t *h, uint8_t *data,
100
+ size_t block_size, unsigned *num,
101
+ uint32_t *Nh, uint32_t *Nl,
102
+ const uint8_t *in, size_t len) {
142
103
  if (len == 0) {
143
- return 1;
104
+ return;
144
105
  }
145
106
 
146
- uint32_t l = c->Nl + (((uint32_t)len) << 3);
147
- if (l < c->Nl) {
107
+ uint32_t l = *Nl + (((uint32_t)len) << 3);
108
+ if (l < *Nl) {
148
109
  // Handle carries.
149
- c->Nh++;
110
+ (*Nh)++;
150
111
  }
151
- c->Nh += (uint32_t)(len >> 29);
152
- c->Nl = l;
112
+ *Nh += (uint32_t)(len >> 29);
113
+ *Nl = l;
153
114
 
154
- size_t n = c->num;
115
+ size_t n = *num;
155
116
  if (n != 0) {
156
- if (len >= HASH_CBLOCK || len + n >= HASH_CBLOCK) {
157
- OPENSSL_memcpy(c->data + n, data, HASH_CBLOCK - n);
158
- HASH_BLOCK_DATA_ORDER(c->h, c->data, 1);
159
- n = HASH_CBLOCK - n;
160
- data += n;
117
+ if (len >= block_size || len + n >= block_size) {
118
+ OPENSSL_memcpy(data + n, in, block_size - n);
119
+ block_func(h, data, 1);
120
+ n = block_size - n;
121
+ in += n;
161
122
  len -= n;
162
- c->num = 0;
163
- // Keep |c->data| zeroed when unused.
164
- OPENSSL_memset(c->data, 0, HASH_CBLOCK);
123
+ *num = 0;
124
+ // Keep |data| zeroed when unused.
125
+ OPENSSL_memset(data, 0, block_size);
165
126
  } else {
166
- OPENSSL_memcpy(c->data + n, data, len);
167
- c->num += (unsigned)len;
168
- return 1;
127
+ OPENSSL_memcpy(data + n, in, len);
128
+ *num += (unsigned)len;
129
+ return;
169
130
  }
170
131
  }
171
132
 
172
- n = len / HASH_CBLOCK;
133
+ n = len / block_size;
173
134
  if (n > 0) {
174
- HASH_BLOCK_DATA_ORDER(c->h, data, n);
175
- n *= HASH_CBLOCK;
176
- data += n;
135
+ block_func(h, in, n);
136
+ n *= block_size;
137
+ in += n;
177
138
  len -= n;
178
139
  }
179
140
 
180
141
  if (len != 0) {
181
- c->num = (unsigned)len;
182
- OPENSSL_memcpy(c->data, data, len);
142
+ *num = (unsigned)len;
143
+ OPENSSL_memcpy(data, in, len);
183
144
  }
184
- return 1;
185
- }
186
-
187
-
188
- void HASH_TRANSFORM(HASH_CTX *c, const uint8_t data[HASH_CBLOCK]) {
189
- HASH_BLOCK_DATA_ORDER(c->h, data, 1);
190
145
  }
191
146
 
192
-
193
- int HASH_FINAL(uint8_t out[HASH_DIGEST_LENGTH], HASH_CTX *c) {
194
- // |c->data| always has room for at least one byte. A full block would have
147
+ // crypto_md32_final incorporates the partial block and trailing length into the
148
+ // digest state |h|. The trailing length is encoded in little-endian if
149
+ // |is_big_endian| is zero and big-endian otherwise. |data| must be a buffer of
150
+ // length |block_size| with the first |*num| bytes containing a partial block.
151
+ // |Nh| and |Nl| contain the total number of bits processed. On return, this
152
+ // function clears the partial block in |data| and
153
+ // |*num|.
154
+ //
155
+ // This function does not serialize |h| into a final digest. This is the
156
+ // responsibility of the caller.
157
+ static inline void crypto_md32_final(crypto_md32_block_func block_func,
158
+ uint32_t *h, uint8_t *data,
159
+ size_t block_size, unsigned *num,
160
+ uint32_t Nh, uint32_t Nl,
161
+ int is_big_endian) {
162
+ // |data| always has room for at least one byte. A full block would have
195
163
  // been consumed.
196
- size_t n = c->num;
197
- assert(n < HASH_CBLOCK);
198
- c->data[n] = 0x80;
164
+ size_t n = *num;
165
+ assert(n < block_size);
166
+ data[n] = 0x80;
199
167
  n++;
200
168
 
201
169
  // Fill the block with zeros if there isn't room for a 64-bit length.
202
- if (n > (HASH_CBLOCK - 8)) {
203
- OPENSSL_memset(c->data + n, 0, HASH_CBLOCK - n);
170
+ if (n > block_size - 8) {
171
+ OPENSSL_memset(data + n, 0, block_size - n);
204
172
  n = 0;
205
- HASH_BLOCK_DATA_ORDER(c->h, c->data, 1);
173
+ block_func(h, data, 1);
206
174
  }
207
- OPENSSL_memset(c->data + n, 0, HASH_CBLOCK - 8 - n);
175
+ OPENSSL_memset(data + n, 0, block_size - 8 - n);
208
176
 
209
177
  // Append a 64-bit length to the block and process it.
210
- uint8_t *p = c->data + HASH_CBLOCK - 8;
211
- #if defined(DATA_ORDER_IS_BIG_ENDIAN)
212
- CRYPTO_store_u32_be(p, c->Nh);
213
- CRYPTO_store_u32_be(p + 4, c->Nl);
214
- #elif defined(DATA_ORDER_IS_LITTLE_ENDIAN)
215
- CRYPTO_store_u32_le(p, c->Nl);
216
- CRYPTO_store_u32_le(p + 4, c->Nh);
217
- #endif
218
- HASH_BLOCK_DATA_ORDER(c->h, c->data, 1);
219
- c->num = 0;
220
- OPENSSL_memset(c->data, 0, HASH_CBLOCK);
221
-
222
- HASH_MAKE_STRING(c, out);
223
- return 1;
178
+ if (is_big_endian) {
179
+ CRYPTO_store_u32_be(data + block_size - 8, Nh);
180
+ CRYPTO_store_u32_be(data + block_size - 4, Nl);
181
+ } else {
182
+ CRYPTO_store_u32_le(data + block_size - 8, Nl);
183
+ CRYPTO_store_u32_le(data + block_size - 4, Nh);
184
+ }
185
+ block_func(h, data, 1);
186
+ *num = 0;
187
+ OPENSSL_memset(data, 0, block_size);
224
188
  }
225
189
 
226
190
 
227
191
  #if defined(__cplusplus)
228
192
  } // extern C
229
193
  #endif
194
+
195
+ #endif // OPENSSL_HEADER_DIGEST_MD32_COMMON_H
@@ -60,6 +60,7 @@
60
60
  #include <string.h>
61
61
 
62
62
  #include "../../internal.h"
63
+ #include "../digest/md32_common.h"
63
64
 
64
65
 
65
66
  uint8_t *MD4(const uint8_t *data, size_t len, uint8_t out[MD4_DIGEST_LENGTH]) {
@@ -84,28 +85,26 @@ int MD4_Init(MD4_CTX *md4) {
84
85
 
85
86
  void md4_block_data_order(uint32_t *state, const uint8_t *data, size_t num);
86
87
 
87
- #define DATA_ORDER_IS_LITTLE_ENDIAN
88
-
89
- #define HASH_CTX MD4_CTX
90
- #define HASH_CBLOCK 64
91
- #define HASH_DIGEST_LENGTH 16
92
- #define HASH_UPDATE MD4_Update
93
- #define HASH_TRANSFORM MD4_Transform
94
- #define HASH_FINAL MD4_Final
95
- #define HASH_MAKE_STRING(c, s) \
96
- do { \
97
- CRYPTO_store_u32_le((s), (c)->h[0]); \
98
- (s) += 4; \
99
- CRYPTO_store_u32_le((s), (c)->h[1]); \
100
- (s) += 4; \
101
- CRYPTO_store_u32_le((s), (c)->h[2]); \
102
- (s) += 4; \
103
- CRYPTO_store_u32_le((s), (c)->h[3]); \
104
- (s) += 4; \
105
- } while (0)
106
- #define HASH_BLOCK_DATA_ORDER md4_block_data_order
88
+ void MD4_Transform(MD4_CTX *c, const uint8_t data[MD4_CBLOCK]) {
89
+ md4_block_data_order(c->h, data, 1);
90
+ }
107
91
 
108
- #include "../digest/md32_common.h"
92
+ int MD4_Update(MD4_CTX *c, const void *data, size_t len) {
93
+ crypto_md32_update(&md4_block_data_order, c->h, c->data, MD4_CBLOCK, &c->num,
94
+ &c->Nh, &c->Nl, data, len);
95
+ return 1;
96
+ }
97
+
98
+ int MD4_Final(uint8_t out[MD4_DIGEST_LENGTH], MD4_CTX *c) {
99
+ crypto_md32_final(&md4_block_data_order, c->h, c->data, MD4_CBLOCK, &c->num,
100
+ c->Nh, c->Nl, /*is_big_endian=*/0);
101
+
102
+ CRYPTO_store_u32_le(out, c->h[0]);
103
+ CRYPTO_store_u32_le(out + 4, c->h[1]);
104
+ CRYPTO_store_u32_le(out + 8, c->h[2]);
105
+ CRYPTO_store_u32_le(out + 12, c->h[3]);
106
+ return 1;
107
+ }
109
108
 
110
109
  // As pointed out by Wei Dai <weidai@eskimo.com>, the above can be
111
110
  // simplified to the code below. Wei attributes these optimizations
@@ -235,15 +234,6 @@ void md4_block_data_order(uint32_t *state, const uint8_t *data, size_t num) {
235
234
  }
236
235
  }
237
236
 
238
- #undef DATA_ORDER_IS_LITTLE_ENDIAN
239
- #undef HASH_CTX
240
- #undef HASH_CBLOCK
241
- #undef HASH_DIGEST_LENGTH
242
- #undef HASH_UPDATE
243
- #undef HASH_TRANSFORM
244
- #undef HASH_FINAL
245
- #undef HASH_MAKE_STRING
246
- #undef HASH_BLOCK_DATA_ORDER
247
237
  #undef F
248
238
  #undef G
249
239
  #undef H