grpc 1.85.0 → 1.86.0.pre1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (634) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +13 -9
  3. data/etc/roots.pem +0 -583
  4. data/include/grpc/channel_factory.h +78 -0
  5. data/include/grpc/credentials.h +21 -0
  6. data/include/grpc/grpc.h +7 -0
  7. data/include/grpc/grpc_security_constants.h +2 -0
  8. data/include/grpc/module.modulemap +1 -0
  9. data/src/core/call/call_filters.cc +4 -1
  10. data/src/core/call/call_filters.h +3 -1
  11. data/src/core/call/call_spine.h +12 -6
  12. data/src/core/call/call_state.h +3 -3
  13. data/src/core/call/client_call.cc +4 -1
  14. data/src/core/call/client_call.h +1 -0
  15. data/src/core/call/evaluate_args.cc +15 -14
  16. data/src/core/call/filter_fusion.h +2 -15
  17. data/src/core/call/interception_chain.h +2 -7
  18. data/src/core/call/metadata_batch.cc +5 -0
  19. data/src/core/call/metadata_batch.h +34 -3
  20. data/src/core/call/request_buffer.cc +1 -1
  21. data/src/core/call/server_call.cc +3 -3
  22. data/src/core/call/server_call.h +15 -0
  23. data/src/core/channelz/channelz_registry.cc +4 -4
  24. data/src/core/channelz/ztrace_collector.h +11 -2
  25. data/src/core/client_channel/backup_poller.cc +1 -2
  26. data/src/core/client_channel/channel_factory.cc +110 -0
  27. data/src/core/client_channel/channel_factory.h +45 -0
  28. data/src/core/client_channel/global_subchannel_pool.cc +2 -2
  29. data/src/core/client_channel/lame_channel.cc +59 -0
  30. data/src/core/client_channel/lame_channel.h +86 -0
  31. data/src/core/credentials/call/external/aws_request_signer.cc +2 -1
  32. data/src/core/credentials/call/external/url_external_account_credentials.cc +6 -17
  33. data/src/core/credentials/call/external/url_external_account_credentials.h +0 -1
  34. data/src/core/credentials/call/jwt/jwt_verifier.cc +25 -13
  35. data/src/core/credentials/call/oauth2/oauth2_credentials.cc +6 -4
  36. data/src/core/credentials/call/regional_access_boundary_fetcher.cc +16 -0
  37. data/src/core/credentials/call/regional_access_boundary_fetcher.h +6 -2
  38. data/src/core/credentials/transport/tls/grpc_tls_credentials_options.cc +14 -0
  39. data/src/core/credentials/transport/tls/grpc_tls_credentials_options.h +12 -2
  40. data/src/core/credentials/transport/tls/ssl_utils.cc +20 -0
  41. data/src/core/credentials/transport/tls/ssl_utils.h +4 -0
  42. data/src/core/credentials/transport/tls/tls_security_connector.cc +6 -2
  43. data/src/core/ext/filters/http/server/http_server_filter.cc +6 -1
  44. data/src/core/ext/filters/rbac/rbac_filter.cc +3 -41
  45. data/src/core/ext/filters/rbac/rbac_filter.h +2 -11
  46. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +2 -2
  47. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +31 -24
  48. data/src/core/ext/transport/chttp2/server/chttp2_server.h +1 -2
  49. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +69 -102
  50. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +1 -1
  51. data/src/core/ext/transport/chttp2/transport/flow_control.h +2 -2
  52. data/src/core/ext/transport/chttp2/transport/flow_control_manager.h +1 -1
  53. data/src/core/ext/transport/chttp2/transport/frame.cc +15 -19
  54. data/src/core/ext/transport/chttp2/transport/frame.h +1 -1
  55. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +18 -61
  56. data/src/core/ext/transport/chttp2/transport/frame_goaway.h +0 -4
  57. data/src/core/ext/transport/chttp2/transport/frame_security.cc +1 -2
  58. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +9 -0
  59. data/src/core/ext/transport/chttp2/transport/goaway.cc +1 -1
  60. data/src/core/ext/transport/chttp2/transport/goaway.h +0 -5
  61. data/src/core/ext/transport/chttp2/transport/header_assembler.h +1 -5
  62. data/src/core/ext/transport/chttp2/transport/hpack_parse_result.cc +3 -0
  63. data/src/core/ext/transport/chttp2/transport/hpack_parse_result.h +8 -0
  64. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +33 -0
  65. data/src/core/ext/transport/chttp2/transport/http2_client_transport.cc +34 -19
  66. data/src/core/ext/transport/chttp2/transport/http2_client_transport.h +5 -2
  67. data/src/core/ext/transport/chttp2/transport/http2_server_transport.cc +134 -82
  68. data/src/core/ext/transport/chttp2/transport/http2_server_transport.h +30 -15
  69. data/src/core/ext/transport/chttp2/transport/http2_settings_promises.h +4 -3
  70. data/src/core/ext/transport/chttp2/transport/http2_transport.cc +9 -33
  71. data/src/core/ext/transport/chttp2/transport/http2_transport.h +1 -6
  72. data/src/core/ext/transport/chttp2/transport/http2_transport_stats.h +60 -0
  73. data/src/core/ext/transport/chttp2/transport/internal.h +6 -1
  74. data/src/core/ext/transport/chttp2/transport/keepalive.h +1 -4
  75. data/src/core/ext/transport/chttp2/transport/parsing.cc +4 -8
  76. data/src/core/ext/transport/chttp2/transport/ping_promise.cc +35 -11
  77. data/src/core/ext/transport/chttp2/transport/ping_promise.h +52 -47
  78. data/src/core/ext/transport/chttp2/transport/read_context.h +19 -5
  79. data/src/core/ext/transport/chttp2/transport/security_frame.h +7 -6
  80. data/src/core/ext/transport/chttp2/transport/stream_data_queue.h +7 -5
  81. data/src/core/ext/transport/chttp2/transport/transport_common.cc +47 -0
  82. data/src/core/ext/transport/chttp2/transport/transport_common.h +29 -0
  83. data/src/core/ext/transport/chttp2/transport/writable_streams.h +1 -1
  84. data/src/core/ext/transport/inproc/legacy_inproc_transport.cc +1 -7
  85. data/src/core/ext/upb-gen/envoy/admin/v3/clusters.upb.h +16 -0
  86. data/src/core/ext/upb-gen/envoy/admin/v3/clusters.upb_minitable.c +4 -3
  87. data/src/core/ext/upb-gen/envoy/admin/v3/server_info.upb.h +129 -81
  88. data/src/core/ext/upb-gen/envoy/admin/v3/server_info.upb_minitable.c +50 -39
  89. data/src/core/ext/upb-gen/envoy/config/bootstrap/v3/bootstrap.upb.h +411 -163
  90. data/src/core/ext/upb-gen/envoy/config/bootstrap/v3/bootstrap.upb_minitable.c +95 -44
  91. data/src/core/ext/upb-gen/envoy/config/bootstrap/v3/bootstrap.upb_minitable.h +3 -0
  92. data/src/core/ext/upb-gen/envoy/config/cluster/v3/circuit_breaker.upb.h +41 -8
  93. data/src/core/ext/upb-gen/envoy/config/cluster/v3/circuit_breaker.upb_minitable.c +8 -5
  94. data/src/core/ext/upb-gen/envoy/config/cluster/v3/cluster.upb.h +427 -222
  95. data/src/core/ext/upb-gen/envoy/config/cluster/v3/cluster.upb_minitable.c +97 -66
  96. data/src/core/ext/upb-gen/envoy/config/cluster/v3/cluster.upb_minitable.h +1 -0
  97. data/src/core/ext/upb-gen/envoy/config/cluster/v3/outlier_detection.upb.h +130 -99
  98. data/src/core/ext/upb-gen/envoy/config/cluster/v3/outlier_detection.upb_minitable.c +29 -27
  99. data/src/core/ext/upb-gen/envoy/config/core/v3/address.upb.h +49 -33
  100. data/src/core/ext/upb-gen/envoy/config/core/v3/address.upb_minitable.c +19 -8
  101. data/src/core/ext/upb-gen/envoy/config/core/v3/base.upb.h +95 -3
  102. data/src/core/ext/upb-gen/envoy/config/core/v3/base.upb_minitable.c +33 -6
  103. data/src/core/ext/upb-gen/envoy/config/core/v3/base.upb_minitable.h +1 -0
  104. data/src/core/ext/upb-gen/envoy/config/core/v3/http_service.upb.h +93 -11
  105. data/src/core/ext/upb-gen/envoy/config/core/v3/http_service.upb_minitable.c +8 -5
  106. data/src/core/ext/upb-gen/envoy/config/core/v3/protocol.upb.h +656 -134
  107. data/src/core/ext/upb-gen/envoy/config/core/v3/protocol.upb_minitable.c +117 -51
  108. data/src/core/ext/upb-gen/envoy/config/core/v3/protocol.upb_minitable.h +2 -0
  109. data/src/core/ext/upb-gen/envoy/config/core/v3/socket_option.upb.h +45 -23
  110. data/src/core/ext/upb-gen/envoy/config/core/v3/socket_option.upb_minitable.c +19 -10
  111. data/src/core/ext/upb-gen/envoy/config/endpoint/v3/endpoint_components.upb.h +99 -34
  112. data/src/core/ext/upb-gen/envoy/config/endpoint/v3/endpoint_components.upb_minitable.c +12 -7
  113. data/src/core/ext/upb-gen/envoy/config/listener/v3/listener.upb.h +344 -273
  114. data/src/core/ext/upb-gen/envoy/config/listener/v3/listener.upb_minitable.c +62 -69
  115. data/src/core/ext/upb-gen/envoy/config/listener/v3/listener.upb_minitable.h +1 -3
  116. data/src/core/ext/upb-gen/envoy/config/metrics/v3/stats.upb.h +53 -22
  117. data/src/core/ext/upb-gen/envoy/config/metrics/v3/stats.upb_minitable.c +9 -7
  118. data/src/core/ext/upb-gen/envoy/config/overload/v3/overload.upb.h +108 -0
  119. data/src/core/ext/upb-gen/envoy/config/overload/v3/overload.upb_minitable.c +26 -2
  120. data/src/core/ext/upb-gen/envoy/config/overload/v3/overload.upb_minitable.h +1 -0
  121. data/src/core/ext/upb-gen/envoy/config/route/v3/route_components.upb.h +809 -231
  122. data/src/core/ext/upb-gen/envoy/config/route/v3/route_components.upb_minitable.c +183 -77
  123. data/src/core/ext/upb-gen/envoy/config/route/v3/route_components.upb_minitable.h +3 -0
  124. data/src/core/ext/upb-gen/envoy/config/trace/v3/opentelemetry.upb.h +151 -26
  125. data/src/core/ext/upb-gen/envoy/config/trace/v3/opentelemetry.upb_minitable.c +17 -9
  126. data/src/core/ext/upb-gen/envoy/config/trace/v3/zipkin.upb.h +24 -8
  127. data/src/core/ext/upb-gen/envoy/config/trace/v3/zipkin.upb_minitable.c +6 -5
  128. data/src/core/ext/upb-gen/envoy/data/accesslog/v3/accesslog.upb.h +2 -1
  129. data/src/core/ext/upb-gen/envoy/extensions/filters/http/composite/v3/composite.upb.h +224 -16
  130. data/src/core/ext/upb-gen/envoy/extensions/filters/http/composite/v3/composite.upb_minitable.c +83 -10
  131. data/src/core/ext/upb-gen/envoy/extensions/filters/http/composite/v3/composite.upb_minitable.h +2 -0
  132. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upb.h +95 -79
  133. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upb_minitable.c +23 -22
  134. data/src/core/ext/upb-gen/envoy/extensions/filters/http/fault/v3/fault.upb.h +34 -18
  135. data/src/core/ext/upb-gen/envoy/extensions/filters/http/fault/v3/fault.upb_minitable.c +10 -9
  136. data/src/core/ext/upb-gen/envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upb.h +243 -2
  137. data/src/core/ext/upb-gen/envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upb_minitable.c +53 -5
  138. data/src/core/ext/upb-gen/envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upb_minitable.h +3 -0
  139. data/src/core/ext/upb-gen/envoy/extensions/filters/http/router/v3/router.upb.h +53 -22
  140. data/src/core/ext/upb-gen/envoy/extensions/filters/http/router/v3/router.upb_minitable.c +9 -7
  141. data/src/core/ext/upb-gen/envoy/extensions/filters/http/stateful_session/v3/stateful_session.upb.h +23 -7
  142. data/src/core/ext/upb-gen/envoy/extensions/filters/http/stateful_session/v3/stateful_session.upb_minitable.c +9 -4
  143. data/src/core/ext/upb-gen/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +516 -215
  144. data/src/core/ext/upb-gen/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb_minitable.c +99 -60
  145. data/src/core/ext/upb-gen/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb_minitable.h +1 -0
  146. data/src/core/ext/upb-gen/envoy/extensions/load_balancing_policies/client_side_weighted_round_robin/v3/client_side_weighted_round_robin.upb.h +60 -28
  147. data/src/core/ext/upb-gen/envoy/extensions/load_balancing_policies/client_side_weighted_round_robin/v3/client_side_weighted_round_robin.upb_minitable.c +12 -10
  148. data/src/core/ext/upb-gen/envoy/extensions/load_balancing_policies/common/v3/common.upb.h +109 -0
  149. data/src/core/ext/upb-gen/envoy/extensions/load_balancing_policies/common/v3/common.upb_minitable.c +32 -2
  150. data/src/core/ext/upb-gen/envoy/extensions/load_balancing_policies/common/v3/common.upb_minitable.h +1 -0
  151. data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/http_11_proxy/v3/upstream_http_11_connect.upb.h +37 -4
  152. data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/http_11_proxy/v3/upstream_http_11_connect.upb_minitable.c +7 -4
  153. data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/tls/v3/common.upb.h +65 -47
  154. data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/tls/v3/common.upb_minitable.c +29 -12
  155. data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/tls/v3/tls_spiffe_validator_config.upb.h +20 -4
  156. data/src/core/ext/upb-gen/envoy/extensions/transport_sockets/tls/v3/tls_spiffe_validator_config.upb_minitable.c +6 -3
  157. data/src/core/ext/upb-gen/envoy/service/ext_proc/v3/external_processor.upb.h +776 -88
  158. data/src/core/ext/upb-gen/envoy/service/ext_proc/v3/external_processor.upb_minitable.c +195 -35
  159. data/src/core/ext/upb-gen/envoy/service/ext_proc/v3/external_processor.upb_minitable.h +5 -0
  160. data/src/core/ext/upb-gen/envoy/type/matcher/v3/address.upb.h +23 -7
  161. data/src/core/ext/upb-gen/envoy/type/matcher/v3/address.upb_minitable.c +10 -3
  162. data/src/core/ext/upb-gen/envoy/type/matcher/v3/status_code_input.upb.h +44 -0
  163. data/src/core/ext/upb-gen/envoy/type/matcher/v3/status_code_input.upb_minitable.c +11 -2
  164. data/src/core/ext/upb-gen/envoy/type/matcher/v3/status_code_input.upb_minitable.h +1 -0
  165. data/src/core/ext/upb-gen/envoy/type/v3/scope.upb.h +218 -0
  166. data/src/core/ext/upb-gen/envoy/type/v3/scope.upb_minitable.c +70 -0
  167. data/src/core/ext/upb-gen/envoy/type/v3/scope.upb_minitable.h +31 -0
  168. data/src/core/ext/upbdefs-gen/envoy/admin/v3/clusters.upbdefs.c +30 -24
  169. data/src/core/ext/upbdefs-gen/envoy/admin/v3/server_info.upbdefs.c +166 -152
  170. data/src/core/ext/upbdefs-gen/envoy/config/bootstrap/v3/bootstrap.upbdefs.c +467 -422
  171. data/src/core/ext/upbdefs-gen/envoy/config/bootstrap/v3/bootstrap.upbdefs.h +15 -0
  172. data/src/core/ext/upbdefs-gen/envoy/config/cluster/v3/circuit_breaker.upbdefs.c +120 -110
  173. data/src/core/ext/upbdefs-gen/envoy/config/cluster/v3/cluster.upbdefs.c +912 -857
  174. data/src/core/ext/upbdefs-gen/envoy/config/cluster/v3/cluster.upbdefs.h +5 -0
  175. data/src/core/ext/upbdefs-gen/envoy/config/cluster/v3/outlier_detection.upbdefs.c +26 -19
  176. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/address.upbdefs.c +59 -54
  177. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/base.upbdefs.c +356 -346
  178. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/base.upbdefs.h +5 -0
  179. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/http_service.upbdefs.c +49 -37
  180. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/protocol.upbdefs.c +599 -483
  181. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/protocol.upbdefs.h +10 -0
  182. data/src/core/ext/upbdefs-gen/envoy/config/core/v3/socket_option.upbdefs.c +65 -49
  183. data/src/core/ext/upbdefs-gen/envoy/config/endpoint/v3/endpoint_components.upbdefs.c +165 -161
  184. data/src/core/ext/upbdefs-gen/envoy/config/listener/v3/listener.upbdefs.c +369 -327
  185. data/src/core/ext/upbdefs-gen/envoy/config/listener/v3/listener.upbdefs.h +5 -15
  186. data/src/core/ext/upbdefs-gen/envoy/config/metrics/v3/stats.upbdefs.c +129 -121
  187. data/src/core/ext/upbdefs-gen/envoy/config/overload/v3/overload.upbdefs.c +224 -204
  188. data/src/core/ext/upbdefs-gen/envoy/config/overload/v3/overload.upbdefs.h +5 -0
  189. data/src/core/ext/upbdefs-gen/envoy/config/route/v3/route_components.upbdefs.c +2046 -1932
  190. data/src/core/ext/upbdefs-gen/envoy/config/route/v3/route_components.upbdefs.h +15 -0
  191. data/src/core/ext/upbdefs-gen/envoy/config/trace/v3/opentelemetry.upbdefs.c +70 -37
  192. data/src/core/ext/upbdefs-gen/envoy/config/trace/v3/zipkin.upbdefs.c +7 -3
  193. data/src/core/ext/upbdefs-gen/envoy/data/accesslog/v3/accesslog.upbdefs.c +5 -3
  194. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/composite/v3/composite.upbdefs.c +121 -78
  195. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/composite/v3/composite.upbdefs.h +10 -0
  196. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upbdefs.c +165 -160
  197. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/fault/v3/fault.upbdefs.c +121 -118
  198. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upbdefs.c +68 -37
  199. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upbdefs.h +15 -0
  200. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/router/v3/router.upbdefs.c +48 -40
  201. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/stateful_session/v3/stateful_session.upbdefs.c +44 -37
  202. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +919 -870
  203. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.h +5 -0
  204. data/src/core/ext/upbdefs-gen/envoy/extensions/transport_sockets/http_11_proxy/v3/upstream_http_11_connect.upbdefs.c +26 -14
  205. data/src/core/ext/upbdefs-gen/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.c +44 -36
  206. data/src/core/ext/upbdefs-gen/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +372 -371
  207. data/src/core/ext/upbdefs-gen/envoy/extensions/transport_sockets/tls/v3/tls_spiffe_validator_config.upbdefs.c +32 -28
  208. data/src/core/ext/upbdefs-gen/envoy/type/matcher/v3/address.upbdefs.c +17 -15
  209. data/src/core/ext/upbdefs-gen/envoy/type/matcher/v3/status_code_input.upbdefs.c +4 -1
  210. data/src/core/ext/upbdefs-gen/envoy/type/matcher/v3/status_code_input.upbdefs.h +5 -0
  211. data/src/core/ext/upbdefs-gen/envoy/type/v3/scope.upbdefs.c +76 -0
  212. data/src/core/ext/upbdefs-gen/envoy/type/v3/scope.upbdefs.h +37 -0
  213. data/src/core/ext/upbdefs-gen/envoy/type/v3/token_bucket.upbdefs.c +1 -1
  214. data/src/core/filter/ext_proc/ext_proc_filter.cc +537 -259
  215. data/src/core/filter/ext_proc/ext_proc_filter.h +47 -14
  216. data/src/core/filter/ext_proc/ext_proc_messages.cc +38 -17
  217. data/src/core/filter/ext_proc/ext_proc_messages.h +19 -7
  218. data/src/core/filter/filter_args.h +5 -60
  219. data/src/core/handshaker/http_connect/http_connect_client_handshaker.cc +1 -1
  220. data/src/core/handshaker/security/pipelined_secure_endpoint.cc +23 -22
  221. data/src/core/handshaker/security/secure_endpoint.cc +16 -16
  222. data/src/core/lib/channel/channel_stack.cc +0 -12
  223. data/src/core/lib/channel/channel_stack.h +0 -8
  224. data/src/core/lib/channel/promise_based_filter.cc +57 -44
  225. data/src/core/lib/channel/promise_based_filter.h +29 -41
  226. data/src/core/lib/event_engine/ares_resolver.cc +10 -4
  227. data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +1 -1
  228. data/src/core/lib/event_engine/cf_engine/dns_service_resolver.cc +3 -3
  229. data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +1 -5
  230. data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +10 -12
  231. data/src/core/lib/event_engine/posix_engine/file_descriptor_collection.cc +3 -17
  232. data/src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h +21 -1
  233. data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +5 -5
  234. data/src/core/lib/event_engine/posix_engine/posix_engine.cc +10 -12
  235. data/src/core/lib/event_engine/posix_engine/posix_interface.h +1 -1
  236. data/src/core/lib/event_engine/posix_engine/timer.cc +2 -2
  237. data/src/core/lib/event_engine/shim.cc +1 -6
  238. data/src/core/lib/event_engine/shim.h +0 -5
  239. data/src/core/lib/event_engine/windows/windows_engine.cc +4 -4
  240. data/src/core/lib/event_engine/windows/windows_listener.cc +1 -1
  241. data/src/core/lib/experiments/experiments.cc +144 -261
  242. data/src/core/lib/experiments/experiments.h +48 -120
  243. data/src/core/lib/iomgr/iomgr_windows.cc +1 -6
  244. data/src/core/lib/iomgr/tcp_posix.cc +21 -21
  245. data/src/core/lib/iomgr/tcp_server_posix.cc +64 -242
  246. data/src/core/lib/iomgr/tcp_server_windows.cc +0 -469
  247. data/src/core/lib/promise/activity.cc +8 -8
  248. data/src/core/lib/promise/activity.h +5 -5
  249. data/src/core/lib/promise/inter_activity_pipe.h +3 -3
  250. data/src/core/lib/promise/party.cc +5 -5
  251. data/src/core/lib/promise/status_flag.h +7 -2
  252. data/src/core/lib/resource_quota/memory_quota.cc +2 -2
  253. data/src/core/lib/security/authorization/rbac_policy.h +2 -2
  254. data/src/core/lib/surface/call.cc +13 -3
  255. data/src/core/lib/surface/call.h +23 -6
  256. data/src/core/lib/surface/channel_create.cc +7 -1
  257. data/src/core/lib/surface/channel_init.h +1 -8
  258. data/src/core/lib/surface/filter_stack_call.cc +16 -0
  259. data/src/core/lib/surface/filter_stack_call.h +1 -0
  260. data/src/core/lib/surface/init.cc +3 -3
  261. data/src/core/lib/surface/legacy_channel.cc +4 -1
  262. data/src/core/lib/surface/version.cc +2 -2
  263. data/src/core/lib/transport/transport.cc +15 -8
  264. data/src/core/lib/transport/transport_framing_endpoint_extension.h +8 -2
  265. data/src/core/load_balancing/outlier_detection/outlier_detection.cc +99 -8
  266. data/src/core/load_balancing/outlier_detection/outlier_detection_metrics.cc +38 -0
  267. data/src/core/load_balancing/outlier_detection/outlier_detection_metrics.h +55 -0
  268. data/src/core/load_balancing/ring_hash/ring_hash.cc +2 -1
  269. data/src/core/load_balancing/rls/rls.cc +21 -1
  270. data/src/core/load_balancing/xds/cds.cc +4 -51
  271. data/src/core/plugin_registry/grpc_plugin_registry.cc +10 -13
  272. data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +0 -7
  273. data/src/core/resolver/xds/xds_resolver.cc +1 -1
  274. data/src/core/server/server.cc +60 -4
  275. data/src/core/server/server_config_selector.h +4 -18
  276. data/src/core/server/server_config_selector_filter.cc +20 -146
  277. data/src/core/server/server_config_selector_filter.h +2 -2
  278. data/src/core/server/xds_server_config_fetcher.cc +5 -20
  279. data/src/core/transport/auth_context.cc +15 -5
  280. data/src/core/transport/auth_context.h +5 -0
  281. data/src/core/tsi/ssl_telemetry_utils.cc +9 -1
  282. data/src/core/tsi/ssl_transport_security.cc +158 -52
  283. data/src/core/tsi/ssl_transport_security.h +18 -2
  284. data/src/core/tsi/ssl_transport_security_utils.cc +123 -12
  285. data/src/core/tsi/ssl_transport_security_utils.h +19 -0
  286. data/src/core/util/latent_see.cc +65 -3
  287. data/src/core/util/latent_see.h +57 -12
  288. data/src/core/util/linux/cpu.cc +12 -6
  289. data/src/core/util/mpscq.cc +2 -2
  290. data/src/core/util/sync_abseil.cc +3 -3
  291. data/src/core/util/trie_lookup.h +5 -1
  292. data/src/core/util/windows/env.cc +1 -0
  293. data/src/core/util/work_serializer.cc +1 -1
  294. data/src/core/xds/grpc/file_watcher_certificate_provider_factory.cc +10 -9
  295. data/src/core/xds/grpc/file_watcher_certificate_provider_factory.h +3 -3
  296. data/src/core/xds/grpc/streaming_call_promise_wrapper.cc +5 -2
  297. data/src/core/xds/grpc/streaming_call_promise_wrapper.h +2 -5
  298. data/src/core/xds/grpc/xds_audit_logger_registry.cc +0 -54
  299. data/src/core/xds/grpc/xds_audit_logger_registry.h +0 -8
  300. data/src/core/xds/grpc/xds_bootstrap_grpc_builder.cc +2 -28
  301. data/src/core/xds/grpc/xds_bootstrap_grpc_builder.h +0 -20
  302. data/src/core/xds/grpc/xds_client_grpc.cc +4 -4
  303. data/src/core/xds/grpc/xds_client_grpc.h +1 -1
  304. data/src/core/xds/grpc/xds_cluster_parser.cc +5 -1
  305. data/src/core/xds/grpc/xds_common_types_parser.cc +12 -0
  306. data/src/core/xds/grpc/xds_endpoint_parser.cc +3 -3
  307. data/src/core/xds/grpc/xds_http_composite_filter.cc +0 -5
  308. data/src/core/xds/grpc/xds_http_composite_filter.h +1 -27
  309. data/src/core/xds/grpc/xds_http_ext_proc_filter.cc +1 -5
  310. data/src/core/xds/grpc/xds_http_ext_proc_filter.h +3 -29
  311. data/src/core/xds/grpc/xds_http_fault_filter.cc +0 -4
  312. data/src/core/xds/grpc/xds_http_fault_filter.h +0 -26
  313. data/src/core/xds/grpc/xds_http_filter.h +1 -63
  314. data/src/core/xds/grpc/xds_http_gcp_authn_filter.cc +0 -5
  315. data/src/core/xds/grpc/xds_http_gcp_authn_filter.h +1 -27
  316. data/src/core/xds/grpc/xds_http_rbac_filter.cc +0 -527
  317. data/src/core/xds/grpc/xds_http_rbac_filter.h +0 -15
  318. data/src/core/xds/grpc/xds_http_stateful_session_filter.cc +0 -5
  319. data/src/core/xds/grpc/xds_http_stateful_session_filter.h +0 -26
  320. data/src/core/xds/grpc/xds_listener.cc +0 -2
  321. data/src/core/xds/grpc/xds_listener.h +0 -2
  322. data/src/core/xds/grpc/xds_listener_parser.cc +0 -7
  323. data/src/core/xds/grpc/xds_matcher.cc +17 -11
  324. data/src/core/xds/grpc/xds_matcher.h +2 -1
  325. data/src/core/xds/grpc/xds_matcher_context.cc +11 -0
  326. data/src/core/xds/grpc/xds_matcher_context.h +3 -2
  327. data/src/core/xds/grpc/xds_matcher_input.cc +19 -1
  328. data/src/core/xds/grpc/xds_matcher_parse.cc +3 -2
  329. data/src/core/xds/grpc/xds_route_config.cc +0 -2
  330. data/src/core/xds/grpc/xds_route_config.h +0 -2
  331. data/src/core/xds/grpc/xds_route_config_parser.cc +0 -5
  332. data/src/core/xds/grpc/xds_routing.cc +22 -112
  333. data/src/core/xds/grpc/xds_routing.h +2 -27
  334. data/src/core/xds/grpc/xds_transport_factory_grpc.cc +236 -0
  335. data/src/core/xds/grpc/xds_transport_factory_grpc.h +95 -0
  336. data/src/core/xds/grpc/xds_transport_grpc.cc +78 -241
  337. data/src/core/xds/grpc/xds_transport_grpc.h +41 -51
  338. data/src/core/xds/xds_client/lrs_client.cc +3 -5
  339. data/src/core/xds/xds_client/lrs_client.h +2 -1
  340. data/src/core/xds/xds_client/xds_client.cc +36 -23
  341. data/src/core/xds/xds_client/xds_client.h +6 -5
  342. data/src/core/xds/xds_client/xds_transport.h +110 -108
  343. data/src/core/xds/xds_client/xds_transport_factory.h +43 -0
  344. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +4 -0
  345. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +6 -0
  346. data/src/ruby/lib/grpc/generic/rpc_server.rb +2 -2
  347. data/src/ruby/lib/grpc/version.rb +1 -1
  348. data/third_party/boringssl-with-bazel/crypto/asn1/a_type.cc +54 -19
  349. data/third_party/boringssl-with-bazel/crypto/asn1/asn1_lib.cc +1 -1
  350. data/third_party/boringssl-with-bazel/crypto/asn1/internal.h +58 -12
  351. data/third_party/boringssl-with-bazel/crypto/asn1/tasn_dec.cc +13 -13
  352. data/third_party/boringssl-with-bazel/crypto/asn1/tasn_enc.cc +13 -11
  353. data/third_party/boringssl-with-bazel/crypto/asn1/tasn_fre.cc +14 -18
  354. data/third_party/boringssl-with-bazel/crypto/asn1/tasn_new.cc +31 -35
  355. data/third_party/boringssl-with-bazel/crypto/asn1/tasn_typ.cc +0 -2
  356. data/third_party/boringssl-with-bazel/crypto/asn1/tasn_utl.cc +17 -24
  357. data/third_party/boringssl-with-bazel/crypto/bio/bio.cc +0 -1
  358. data/third_party/boringssl-with-bazel/crypto/bio/bio_mem.cc +9 -3
  359. data/third_party/boringssl-with-bazel/crypto/bio/connect.cc +3 -3
  360. data/third_party/boringssl-with-bazel/crypto/bio/fd.cc +0 -1
  361. data/third_party/boringssl-with-bazel/crypto/bio/file.cc +0 -1
  362. data/third_party/boringssl-with-bazel/crypto/bio/internal.h +2 -3
  363. data/third_party/boringssl-with-bazel/crypto/bio/pair.cc +0 -1
  364. data/third_party/boringssl-with-bazel/crypto/bio/socket.cc +1 -1
  365. data/third_party/boringssl-with-bazel/crypto/bytestring/cbb.cc +70 -45
  366. data/third_party/boringssl-with-bazel/crypto/bytestring/cbs.cc +15 -34
  367. data/third_party/boringssl-with-bazel/crypto/bytestring/internal.h +5 -0
  368. data/third_party/boringssl-with-bazel/crypto/cipher/e_aesgcmsiv.cc +20 -165
  369. data/third_party/boringssl-with-bazel/crypto/cipher/e_tls.cc +7 -4
  370. data/third_party/boringssl-with-bazel/crypto/cipher/internal.h +159 -0
  371. data/third_party/boringssl-with-bazel/crypto/curve25519/curve25519.cc +295 -16
  372. data/third_party/boringssl-with-bazel/crypto/curve25519/internal.h +25 -14
  373. data/third_party/boringssl-with-bazel/crypto/dh/params.cc +1 -1
  374. data/third_party/boringssl-with-bazel/crypto/ec/hash_to_curve.cc +208 -36
  375. data/third_party/boringssl-with-bazel/crypto/err/err.cc +3 -2
  376. data/third_party/boringssl-with-bazel/crypto/evp/evp.cc +3 -0
  377. data/third_party/boringssl-with-bazel/crypto/evp/evp_kem.cc +25 -6
  378. data/third_party/boringssl-with-bazel/crypto/evp/internal.h +15 -11
  379. data/third_party/boringssl-with-bazel/crypto/evp/p_ec.cc +121 -0
  380. data/third_party/boringssl-with-bazel/crypto/evp/p_mlkem.cc +34 -9
  381. data/third_party/boringssl-with-bazel/crypto/evp/p_rsa.cc +76 -8
  382. data/third_party/boringssl-with-bazel/crypto/evp/p_xwing.cc +47 -20
  383. data/third_party/boringssl-with-bazel/crypto/ex_data.cc +1 -1
  384. data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/aes_nohw.cc.inc +1 -1
  385. data/third_party/boringssl-with-bazel/crypto/fipsmodule/aes/gcm.cc.inc +2 -2
  386. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bcm.cc +1 -0
  387. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/add.cc.inc +9 -4
  388. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/asm/x86_64-gcc.cc.inc +4 -4
  389. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/exponentiation.cc.inc +2 -2
  390. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/internal.h +12 -6
  391. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/jacobi.cc.inc +1 -1
  392. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/montgomery_inv.cc.inc +4 -4
  393. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/prime.cc.inc +3 -3
  394. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/rsaz_exp.cc.inc +6 -6
  395. data/third_party/boringssl-with-bazel/crypto/fipsmodule/bn/sqrt.cc.inc +21 -21
  396. data/third_party/boringssl-with-bazel/crypto/fipsmodule/cipher/aead.cc.inc +4 -2
  397. data/third_party/boringssl-with-bazel/crypto/fipsmodule/cipher/cipher.cc.inc +97 -132
  398. data/third_party/boringssl-with-bazel/crypto/fipsmodule/cipher/internal.h +7 -6
  399. data/third_party/boringssl-with-bazel/crypto/fipsmodule/dh/dh.cc.inc +3 -3
  400. data/third_party/boringssl-with-bazel/crypto/fipsmodule/dh/internal.h +1 -1
  401. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/ec.cc.inc +77 -17
  402. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/ec_montgomery.cc.inc +13 -13
  403. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/felem.cc.inc +117 -34
  404. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/internal.h +67 -18
  405. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/oct.cc.inc +29 -151
  406. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/p256-nistz.cc.inc +740 -0
  407. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/p256-nistz.h +207 -0
  408. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/p256.cc.inc +407 -519
  409. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/simple.cc.inc +27 -28
  410. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ecdsa/ecdsa.cc.inc +1 -1
  411. data/third_party/boringssl-with-bazel/crypto/fipsmodule/entropy/jitter.cc.inc +1 -1
  412. data/third_party/boringssl-with-bazel/crypto/fipsmodule/fips_shared_support.cc +4 -4
  413. data/third_party/boringssl-with-bazel/crypto/fipsmodule/keccak/internal.h +70 -1
  414. data/third_party/boringssl-with-bazel/crypto/fipsmodule/keccak/keccak.cc.inc +292 -52
  415. data/third_party/boringssl-with-bazel/crypto/fipsmodule/mldsa/mldsa.cc.inc +226 -69
  416. data/third_party/boringssl-with-bazel/crypto/fipsmodule/mlkem/mlkem.cc.inc +238 -83
  417. data/third_party/boringssl-with-bazel/crypto/fipsmodule/rsa/rsa_impl.cc.inc +6 -6
  418. data/third_party/boringssl-with-bazel/crypto/fipsmodule/sha/sha1.cc.inc +2 -2
  419. data/third_party/boringssl-with-bazel/crypto/fipsmodule/slhdsa/fors.cc.inc +1 -1
  420. data/third_party/boringssl-with-bazel/crypto/hpke/hpke.cc +327 -272
  421. data/third_party/boringssl-with-bazel/crypto/hrss/hrss.cc +14 -14
  422. data/third_party/boringssl-with-bazel/crypto/internal.h +63 -0
  423. data/third_party/boringssl-with-bazel/crypto/mem_internal.h +38 -3
  424. data/third_party/boringssl-with-bazel/crypto/obj/obj_dat.h +97 -1
  425. data/third_party/boringssl-with-bazel/crypto/pem/internal.h +86 -0
  426. data/third_party/boringssl-with-bazel/crypto/pem/pem_all.cc +8 -5
  427. data/third_party/boringssl-with-bazel/crypto/pem/pem_lib.cc +41 -73
  428. data/third_party/boringssl-with-bazel/crypto/pem/pem_pk8.cc +3 -0
  429. data/third_party/boringssl-with-bazel/crypto/pem/pem_pkey.cc +10 -4
  430. data/third_party/boringssl-with-bazel/crypto/pem/pem_x509.cc +3 -0
  431. data/third_party/boringssl-with-bazel/crypto/pem/pem_xaux.cc +3 -0
  432. data/third_party/boringssl-with-bazel/crypto/pkcs7/pkcs7.cc +1 -1
  433. data/third_party/boringssl-with-bazel/crypto/pkcs7/pkcs7_x509.cc +2 -2
  434. data/third_party/boringssl-with-bazel/crypto/pkcs8/pkcs8_x509.cc +1 -1
  435. data/third_party/boringssl-with-bazel/crypto/poly1305/internal.h +17 -0
  436. data/third_party/boringssl-with-bazel/crypto/poly1305/poly1305_arm.cc +1 -13
  437. data/third_party/boringssl-with-bazel/crypto/poly1305/poly1305_vec.cc +3 -3
  438. data/third_party/boringssl-with-bazel/crypto/slhdsa/slhdsa.cc +23 -6
  439. data/third_party/boringssl-with-bazel/crypto/stack/stack.cc +7 -0
  440. data/third_party/boringssl-with-bazel/crypto/trust_token/internal.h +1 -1
  441. data/third_party/boringssl-with-bazel/crypto/x509/a_verify.cc +14 -7
  442. data/third_party/boringssl-with-bazel/crypto/x509/internal.h +110 -76
  443. data/third_party/boringssl-with-bazel/crypto/x509/name_print.cc +1 -1
  444. data/third_party/boringssl-with-bazel/crypto/x509/rsa_pss.cc +1 -1
  445. data/third_party/boringssl-with-bazel/crypto/x509/t_req.cc +1 -1
  446. data/third_party/boringssl-with-bazel/crypto/x509/t_x509.cc +6 -5
  447. data/third_party/boringssl-with-bazel/crypto/x509/v3_crld.cc +11 -53
  448. data/third_party/boringssl-with-bazel/crypto/x509/v3_ncons.cc +5 -5
  449. data/third_party/boringssl-with-bazel/crypto/x509/v3_purp.cc +16 -39
  450. data/third_party/boringssl-with-bazel/crypto/x509/v3_skey.cc +1 -1
  451. data/third_party/boringssl-with-bazel/crypto/x509/v3_utl.cc +12 -16
  452. data/third_party/boringssl-with-bazel/crypto/x509/x509_cmp.cc +9 -11
  453. data/third_party/boringssl-with-bazel/crypto/x509/x509_mtc.cc +598 -0
  454. data/third_party/boringssl-with-bazel/crypto/x509/x509_obj.cc +9 -8
  455. data/third_party/boringssl-with-bazel/crypto/x509/x509_set.cc +14 -18
  456. data/third_party/boringssl-with-bazel/crypto/x509/x509_vfy.cc +315 -390
  457. data/third_party/boringssl-with-bazel/crypto/x509/x509_vpm.cc +1 -1
  458. data/third_party/boringssl-with-bazel/crypto/x509/x509name.cc +31 -29
  459. data/third_party/boringssl-with-bazel/crypto/x509/x_all.cc +10 -9
  460. data/third_party/boringssl-with-bazel/crypto/x509/x_crl.cc +3 -53
  461. data/third_party/boringssl-with-bazel/crypto/x509/x_name.cc +37 -59
  462. data/third_party/boringssl-with-bazel/crypto/x509/x_pubkey.cc +29 -47
  463. data/third_party/boringssl-with-bazel/crypto/x509/x_req.cc +2 -1
  464. data/third_party/boringssl-with-bazel/crypto/x509/x_x509.cc +53 -53
  465. data/third_party/boringssl-with-bazel/gen/boringssl_prefix_symbols_internal_x86_64_win_asm.inc +24 -0
  466. data/third_party/boringssl-with-bazel/gen/boringssl_prefix_symbols_internal_x86_win_asm.inc +24 -0
  467. data/third_party/boringssl-with-bazel/gen/crypto/err_data.cc +509 -497
  468. data/third_party/boringssl-with-bazel/include/openssl/aead.h +7 -19
  469. data/third_party/boringssl-with-bazel/include/openssl/asm_base.h +1 -1
  470. data/third_party/boringssl-with-bazel/include/openssl/asn1.h +6 -10
  471. data/third_party/boringssl-with-bazel/include/openssl/base.h +43 -16
  472. data/third_party/boringssl-with-bazel/include/openssl/bio.h +25 -10
  473. data/third_party/boringssl-with-bazel/include/openssl/bytestring.h +33 -1
  474. data/third_party/boringssl-with-bazel/include/openssl/cipher.h +11 -9
  475. data/third_party/boringssl-with-bazel/include/openssl/configuration.h +18 -0
  476. data/third_party/boringssl-with-bazel/include/openssl/curve25519.h +36 -0
  477. data/third_party/boringssl-with-bazel/include/openssl/digest.h +4 -4
  478. data/third_party/boringssl-with-bazel/include/openssl/ec.h +35 -1
  479. data/third_party/boringssl-with-bazel/include/openssl/ec_key.h +2 -2
  480. data/third_party/boringssl-with-bazel/include/openssl/evp.h +120 -3
  481. data/third_party/boringssl-with-bazel/include/openssl/evp_errors.h +1 -0
  482. data/third_party/boringssl-with-bazel/include/openssl/hmac.h +2 -2
  483. data/third_party/boringssl-with-bazel/include/openssl/hpke.h +38 -7
  484. data/third_party/boringssl-with-bazel/include/openssl/mem.h +5 -5
  485. data/third_party/boringssl-with-bazel/include/openssl/nid.h +42 -0
  486. data/third_party/boringssl-with-bazel/include/openssl/pem.h +650 -351
  487. data/third_party/boringssl-with-bazel/include/openssl/posix_time.h +4 -4
  488. data/third_party/boringssl-with-bazel/include/openssl/prefix_symbols.h +130 -4
  489. data/third_party/boringssl-with-bazel/include/openssl/prefix_symbols_internal_S.h +48 -0
  490. data/third_party/boringssl-with-bazel/include/openssl/prefix_symbols_internal_c.h +24 -0
  491. data/third_party/boringssl-with-bazel/include/openssl/rsa.h +1 -1
  492. data/third_party/boringssl-with-bazel/include/openssl/slhdsa.h +25 -1
  493. data/third_party/boringssl-with-bazel/include/openssl/ssl.h +256 -87
  494. data/third_party/boringssl-with-bazel/include/openssl/stack.h +9 -0
  495. data/third_party/boringssl-with-bazel/include/openssl/types.h +18 -0
  496. data/third_party/boringssl-with-bazel/include/openssl/x509.h +40 -21
  497. data/third_party/boringssl-with-bazel/ssl/bio_ssl.cc +3 -5
  498. data/third_party/boringssl-with-bazel/ssl/d1_both.cc +146 -81
  499. data/third_party/boringssl-with-bazel/ssl/d1_lib.cc +39 -34
  500. data/third_party/boringssl-with-bazel/ssl/d1_pkt.cc +6 -6
  501. data/third_party/boringssl-with-bazel/ssl/d1_srtp.cc +10 -8
  502. data/third_party/boringssl-with-bazel/ssl/dtls_method.cc +4 -4
  503. data/third_party/boringssl-with-bazel/ssl/dtls_record.cc +15 -14
  504. data/third_party/boringssl-with-bazel/ssl/encrypted_client_hello.cc +41 -25
  505. data/third_party/boringssl-with-bazel/ssl/extensions.cc +153 -171
  506. data/third_party/boringssl-with-bazel/ssl/handoff.cc +79 -64
  507. data/third_party/boringssl-with-bazel/ssl/handshake.cc +15 -16
  508. data/third_party/boringssl-with-bazel/ssl/handshake_client.cc +35 -78
  509. data/third_party/boringssl-with-bazel/ssl/handshake_server.cc +75 -155
  510. data/third_party/boringssl-with-bazel/ssl/internal.h +419 -308
  511. data/third_party/boringssl-with-bazel/ssl/s3_both.cc +17 -150
  512. data/third_party/boringssl-with-bazel/ssl/s3_lib.cc +2 -3
  513. data/third_party/boringssl-with-bazel/ssl/s3_pkt.cc +10 -9
  514. data/third_party/boringssl-with-bazel/ssl/ssl_asn1.cc +13 -13
  515. data/third_party/boringssl-with-bazel/ssl/ssl_buffer.cc +8 -8
  516. data/third_party/boringssl-with-bazel/ssl/ssl_cert.cc +58 -24
  517. data/third_party/boringssl-with-bazel/ssl/ssl_cipher.cc +198 -26
  518. data/third_party/boringssl-with-bazel/ssl/ssl_credential.cc +164 -37
  519. data/third_party/boringssl-with-bazel/ssl/ssl_file.cc +10 -8
  520. data/third_party/boringssl-with-bazel/ssl/ssl_key_share.cc +2 -95
  521. data/third_party/boringssl-with-bazel/ssl/ssl_lib.cc +785 -472
  522. data/third_party/boringssl-with-bazel/ssl/ssl_privkey.cc +78 -67
  523. data/third_party/boringssl-with-bazel/ssl/ssl_session.cc +187 -150
  524. data/third_party/boringssl-with-bazel/ssl/ssl_stat.cc +6 -3
  525. data/third_party/boringssl-with-bazel/ssl/ssl_transcript.cc +1 -1
  526. data/third_party/boringssl-with-bazel/ssl/ssl_versions.cc +25 -19
  527. data/third_party/boringssl-with-bazel/ssl/ssl_x509.cc +148 -114
  528. data/third_party/boringssl-with-bazel/ssl/t1_enc.cc +28 -19
  529. data/third_party/boringssl-with-bazel/ssl/tls13_both.cc +24 -22
  530. data/third_party/boringssl-with-bazel/ssl/tls13_client.cc +30 -30
  531. data/third_party/boringssl-with-bazel/ssl/tls13_enc.cc +17 -16
  532. data/third_party/boringssl-with-bazel/ssl/tls13_server.cc +55 -63
  533. data/third_party/boringssl-with-bazel/ssl/tls_method.cc +12 -12
  534. data/third_party/boringssl-with-bazel/ssl/tls_record.cc +23 -20
  535. data/third_party/boringssl-with-bazel/third_party/fiat/p256_64.h +38 -0
  536. data/third_party/boringssl-with-bazel/third_party/fiat/p256_64_msvc.h +2 -0
  537. data/third_party/boringssl-with-bazel/third_party/fiat/p256_field.c.inc +26 -0
  538. data/third_party/boringssl-with-bazel/third_party/fiat/p256_point.br.c.inc +0 -54
  539. data/third_party/cares/cares/include/ares.h +8 -0
  540. data/third_party/cares/cares/include/ares_dns_record.h +3 -2
  541. data/third_party/cares/cares/include/ares_version.h +3 -3
  542. data/third_party/cares/cares/src/lib/ares_addrinfo_localhost.c +20 -20
  543. data/third_party/cares/cares/src/lib/ares_cancel.c +17 -8
  544. data/third_party/cares/cares/src/lib/ares_close_sockets.c +81 -16
  545. data/third_party/cares/cares/src/lib/ares_conn.c +256 -10
  546. data/third_party/cares/cares/src/lib/ares_conn.h +40 -3
  547. data/third_party/cares/cares/src/lib/ares_cookie.c +2 -2
  548. data/third_party/cares/cares/src/lib/ares_destroy.c +75 -10
  549. data/third_party/cares/cares/src/lib/ares_getaddrinfo.c +85 -10
  550. data/third_party/cares/cares/src/lib/ares_gethostbyaddr.c +5 -0
  551. data/third_party/cares/cares/src/lib/ares_gethostbyname.c +4 -0
  552. data/third_party/cares/cares/src/lib/ares_getnameinfo.c +10 -2
  553. data/third_party/cares/cares/src/lib/ares_hosts_file.c +8 -0
  554. data/third_party/cares/cares/src/lib/ares_inet_net_pton.h +28 -0
  555. data/third_party/cares/cares/src/lib/ares_init.c +55 -10
  556. data/third_party/cares/cares/src/lib/ares_library_init.c +25 -7
  557. data/third_party/cares/cares/src/lib/ares_options.c +38 -10
  558. data/third_party/cares/cares/src/lib/ares_parse_into_addrinfo.c +1 -1
  559. data/third_party/cares/cares/src/lib/ares_private.h +186 -27
  560. data/third_party/cares/cares/src/lib/ares_process.c +604 -112
  561. data/third_party/cares/cares/src/lib/ares_qcache.c +200 -36
  562. data/third_party/cares/cares/src/lib/ares_query.c +5 -0
  563. data/third_party/cares/cares/src/lib/ares_search.c +10 -0
  564. data/third_party/cares/cares/src/lib/ares_send.c +81 -10
  565. data/third_party/cares/cares/src/lib/ares_set_socket_functions.c +3 -1
  566. data/third_party/cares/cares/src/lib/ares_socket.c +28 -0
  567. data/third_party/cares/cares/src/lib/ares_socket.h +23 -0
  568. data/third_party/cares/cares/src/lib/ares_sysconfig.c +6 -3
  569. data/third_party/cares/cares/src/lib/ares_sysconfig_files.c +33 -11
  570. data/third_party/cares/cares/src/lib/ares_sysconfig_win.c +132 -80
  571. data/third_party/cares/cares/src/lib/ares_timeout.c +11 -0
  572. data/third_party/cares/cares/src/lib/ares_update_servers.c +55 -11
  573. data/third_party/cares/cares/src/lib/dsa/ares_array.c +20 -5
  574. data/third_party/cares/cares/src/lib/dsa/ares_htable.c +8 -4
  575. data/third_party/cares/cares/src/lib/dsa/ares_htable_dict.c +2 -0
  576. data/third_party/cares/cares/src/lib/dsa/ares_llist.c +4 -1
  577. data/third_party/cares/cares/src/lib/event/ares_event_configchg.c +5 -2
  578. data/third_party/cares/cares/src/lib/event/ares_event_select.c +14 -1
  579. data/third_party/cares/cares/src/lib/event/ares_event_thread.c +8 -0
  580. data/third_party/cares/cares/src/lib/event/ares_event_wake_pipe.c +7 -1
  581. data/third_party/cares/cares/src/lib/event/ares_event_win32.c +3 -0
  582. data/third_party/cares/cares/src/lib/include/ares_mem.h +3 -0
  583. data/third_party/cares/cares/src/lib/include/ares_str.h +17 -0
  584. data/third_party/cares/cares/src/lib/inet_net_pton.c +37 -28
  585. data/third_party/cares/cares/src/lib/legacy/ares_expand_name.c +1 -1
  586. data/third_party/cares/cares/src/lib/legacy/ares_parse_a_reply.c +5 -2
  587. data/third_party/cares/cares/src/lib/legacy/ares_parse_aaaa_reply.c +5 -2
  588. data/third_party/cares/cares/src/lib/legacy/ares_parse_ns_reply.c +2 -2
  589. data/third_party/cares/cares/src/lib/legacy/ares_parse_ptr_reply.c +2 -2
  590. data/third_party/cares/cares/src/lib/legacy/ares_parse_uri_reply.c +1 -1
  591. data/third_party/cares/cares/src/lib/record/ares_dns_mapping.c +19 -4
  592. data/third_party/cares/cares/src/lib/record/ares_dns_multistring.c +3 -1
  593. data/third_party/cares/cares/src/lib/record/ares_dns_name.c +67 -4
  594. data/third_party/cares/cares/src/lib/record/ares_dns_parse.c +62 -34
  595. data/third_party/cares/cares/src/lib/record/ares_dns_private.h +4 -0
  596. data/third_party/cares/cares/src/lib/record/ares_dns_record.c +47 -7
  597. data/third_party/cares/cares/src/lib/record/ares_dns_write.c +13 -5
  598. data/third_party/cares/cares/src/lib/str/ares_buf.c +33 -16
  599. data/third_party/cares/cares/src/lib/str/ares_str.c +54 -0
  600. data/third_party/cares/cares/src/lib/util/ares_iface_ips.c +22 -10
  601. data/third_party/cares/cares/src/lib/util/ares_iface_ips.h +1 -0
  602. data/third_party/cares/cares/src/lib/util/ares_math.c +17 -2
  603. data/third_party/cares/cares/src/lib/util/ares_math.h +32 -7
  604. data/third_party/cares/cares/src/lib/util/ares_rand.c +4 -4
  605. data/third_party/cares/cares/src/lib/util/ares_threads.c +1 -2
  606. data/third_party/cares/cares/src/lib/util/ares_time.h +1 -0
  607. data/third_party/cares/cares/src/lib/util/ares_uri.c +9 -3
  608. data/third_party/zlib/compress.c +34 -10
  609. data/third_party/zlib/crc32.c +49 -115
  610. data/third_party/zlib/deflate.c +107 -61
  611. data/third_party/zlib/deflate.h +7 -1
  612. data/third_party/zlib/gzguts.h +33 -31
  613. data/third_party/zlib/infback.c +20 -67
  614. data/third_party/zlib/inffast.c +7 -6
  615. data/third_party/zlib/inffixed.h +91 -91
  616. data/third_party/zlib/inflate.c +38 -151
  617. data/third_party/zlib/inflate.h +1 -1
  618. data/third_party/zlib/inftrees.c +134 -9
  619. data/third_party/zlib/inftrees.h +3 -1
  620. data/third_party/zlib/trees.c +14 -12
  621. data/third_party/zlib/uncompr.c +39 -23
  622. data/third_party/zlib/zconf.h +27 -19
  623. data/third_party/zlib/zlib.h +215 -96
  624. data/third_party/zlib/zutil.c +49 -35
  625. data/third_party/zlib/zutil.h +87 -10
  626. metadata +4095 -4049
  627. data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +0 -916
  628. data/src/core/ext/filters/rbac/rbac_service_config_parser.h +0 -84
  629. data/src/core/server/xds_channel_stack_modifier.cc +0 -108
  630. data/src/core/server/xds_channel_stack_modifier.h +0 -62
  631. data/src/core/server/xds_server_config_fetcher_legacy.cc +0 -1340
  632. data/third_party/boringssl-with-bazel/crypto/fipsmodule/ec/p256_internal.h +0 -193
  633. data/third_party/boringssl-with-bazel/crypto/kyber/internal.h +0 -165
  634. data/third_party/boringssl-with-bazel/crypto/kyber/kyber.cc +0 -870
@@ -36,278 +36,165 @@ extern "C" {
36
36
  // PEM.
37
37
  //
38
38
  // This library contains functions for reading and writing data encoded in PEM
39
- // format. This format originated in Privacy-Enhanced Mail (RFC 1421).
39
+ // format. This format originated in Privacy-Enhanced Mail (RFC 1421). PEM
40
+ // consists of a series of PEM blocks, which are line-wrapped, base64-encoded
41
+ // data, wrapped in BEGIN and END lines, for example:
40
42
  //
41
- // TODO(crbug.com/42290574): Finish documenting this header.
43
+ // -----BEGIN PUBLIC KEY-----
44
+ // MCowBQYDK2VwAyEAGb9ECWmEzf6FQbrBZ9w7lshQhqowtrbLDFw4rXAxZuE=
45
+ // -----END PUBLIC KEY-----
46
+ //
47
+ // The BEGIN and END markers specify the type of data encoded. Multiple PEM
48
+ // blocks can be concatenated together. For example, it is common to represent a
49
+ // certificate chain as a series of PEM blocks of type CERTIFICATE. Owing to its
50
+ // email roots, PEM blocks can also be embedded in non-PEM data. The parsers in
51
+ // this library will generally skip over any non-PEM data, as well as any PEM
52
+ // blocks that are not of the expected type.
53
+ //
54
+ // PEM blocks can be encrypted with a password, specified in RFC 1423. PEM
55
+ // encryption is vulnerable to padding oracle attacks and should not be used as
56
+ // a load-bearing security measure. It is implemented for interoperability with
57
+ // legacy systems only.
58
+ //
59
+ // Callers should only use PEM for compatibility with legacy systems. PEM use
60
+ // should be limited to the components that directly interoperate with those
61
+ // systems, converting to and from more modern formats. PEM adds overhead to fit
62
+ // in email's 7-bit ASCII limitations, a constraint that is not relevant to most
63
+ // applications.
64
+
65
+
66
+ // API conventions.
67
+
68
+ // pem_password_cb is an application-supplied callback to supply a PEM password.
69
+ // On success, the callback should write the password into `out`, which has room
70
+ // for at most `max_out` bytes. On error, including if `max_out` is too small,
71
+ // it should return -1. `enc` is one if the password will be used for encrypting
72
+ // and zero if it is used for decrypting. `userdata` is the application-supplied
73
+ // parameter of the same name to the PEM function.
74
+ typedef int pem_password_cb(char *out, int max_out, int enc, void *userdata);
75
+
76
+ // PEM_def_callback is the default implementation of `pem_password_cb`. It
77
+ // interprets `userdata` as a NUL-terminated C string and outputs it according
78
+ // to `pem_password_cb`. If `userdata` is NULL, it returns -1.
79
+ //
80
+ // This differs from OpenSSL, which interactively prompts for a password by
81
+ // default.
82
+ OPENSSL_EXPORT int PEM_def_callback(char *buf, int size, int enc,
83
+ void *userdata);
42
84
 
85
+ // The following sample functions document the calling conventions used by this
86
+ // library.
43
87
 
44
- #define PEM_BUFSIZE 1024
88
+ #if 0 // Sample functions
45
89
 
46
- #define PEM_STRING_X509_OLD "X509 CERTIFICATE"
47
- #define PEM_STRING_X509 "CERTIFICATE"
48
- #define PEM_STRING_X509_PAIR "CERTIFICATE PAIR"
49
- #define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE"
50
- #define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST"
51
- #define PEM_STRING_X509_REQ "CERTIFICATE REQUEST"
52
- #define PEM_STRING_X509_CRL "X509 CRL"
53
- #define PEM_STRING_EVP_PKEY "ANY PRIVATE KEY"
54
- #define PEM_STRING_PUBLIC "PUBLIC KEY"
55
- #define PEM_STRING_RSA "RSA PRIVATE KEY"
56
- #define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY"
57
- #define PEM_STRING_DSA "DSA PRIVATE KEY"
58
- #define PEM_STRING_DSA_PUBLIC "DSA PUBLIC KEY"
59
- #define PEM_STRING_EC "EC PRIVATE KEY"
60
- #define PEM_STRING_PKCS7 "PKCS7"
61
- #define PEM_STRING_PKCS7_SIGNED "PKCS #7 SIGNED DATA"
62
- #define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY"
63
- #define PEM_STRING_PKCS8INF "PRIVATE KEY"
64
- #define PEM_STRING_DHPARAMS "DH PARAMETERS"
65
- #define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS"
66
- #define PEM_STRING_DSAPARAMS "DSA PARAMETERS"
67
- #define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY"
68
- #define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY"
69
- #define PEM_STRING_CMS "CMS"
90
+ // PEM_read_bio_SAMPLE reads a PEM block from `bio`, skipping non-PEM data and
91
+ // unexpected block types. It then decodes the resulting PEM block and returns a
92
+ // newly-allocated `SAMPLE` object containing the parsed structure. If `out` is
93
+ // non-NULL, it additionally frees the previous value at `*out` and updates
94
+ // `*out` to the result.
95
+ //
96
+ // On decode or allocation error, or if EOF is reached before a matching PEM
97
+ // block is found, it returns NULL. In the error case, it will add
98
+ // `PEM_R_NO_START_LINE` to the error queue. Callers can check the error queue
99
+ // to distinguish these cases.
100
+ //
101
+ // If the PEM block is encrypted, `cb` will be called to look up the password.
102
+ // See `pem_password_cb` for details. If `cb` is NULL, `PEM_def_callback` is
103
+ // used and `userdata` should be a NUL-terminated C string containing the
104
+ // password. Set both `cb` and `userdata` to NULL to only handle plaintext
105
+ // blocks.
106
+ SAMPLE *PEM_read_bio_SAMPLE(BIO *bio, SAMPLE **out, pem_password_cb *cb,
107
+ void *userdata);
108
+
109
+ // PEM_write_bio_SAMPLE encodes `in` as a PEM block and writes it to `bio`. It
110
+ // returns one on success and zero on error.
111
+ //
112
+ // If `enc` is non-NULL, the PEM block is encrypted with the specified cipher
113
+ // and a password. If `pass` is non-NULL, `pass_len` bytes from `pass` is
114
+ // used as the password. Otherwise, `cb` is called. If `cb` is NULL,
115
+ // `PEM_def_callback` is used. PEM encryption is vulnerable to padding oracle
116
+ // attacks and should not be used.
117
+ //
118
+ // Some functions of this convention do not support encryption. In this case,
119
+ // the encryption-related parameters will be omitted.
120
+ //
121
+ // On error, the state of `bio` is undefined. It is possible a prefix of a PEM
122
+ // block was left in the `bio`.
123
+ int PEM_write_bio_SAMPLE(BIO *bio, const SAMPLE *in, const EVP_CIPHER *enc,
124
+ const uint8_t *pass, int pass_len, pem_password_cb *cb,
125
+ void *userdata);
70
126
 
71
- #define PEM_TYPE_ENCRYPTED 10
72
- #define PEM_TYPE_MIC_ONLY 20
73
- #define PEM_TYPE_MIC_CLEAR 30
74
- #define PEM_TYPE_CLEAR 40
75
-
76
- // These macros make the PEM_read/PEM_write functions easier to maintain and
77
- // write. Now they are all implemented with either:
78
- // IMPLEMENT_PEM_rw(...) or IMPLEMENT_PEM_rw_cb(...)
79
-
80
-
81
- #define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \
82
- static void *pem_read_##name##_d2i(void **x, const unsigned char **inp, \
83
- long len) { \
84
- return d2i_##asn1((type **)x, inp, len); \
85
- } \
86
- OPENSSL_EXPORT type *PEM_read_##name(FILE *fp, type **x, \
87
- pem_password_cb *cb, void *u) { \
88
- return (type *)PEM_ASN1_read(pem_read_##name##_d2i, str, fp, (void **)x, \
89
- cb, u); \
90
- }
91
-
92
- #define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \
93
- static int pem_write_##name##_i2d(const void *x, unsigned char **outp) { \
94
- return i2d_##asn1((type *)x, outp); \
95
- } \
96
- OPENSSL_EXPORT int PEM_write_##name(FILE *fp, type *x) { \
97
- return PEM_ASN1_write(pem_write_##name##_i2d, str, fp, x, NULL, NULL, 0, \
98
- NULL, NULL); \
99
- }
100
-
101
- #define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \
102
- static int pem_write_##name##_i2d(const void *x, unsigned char **outp) { \
103
- return i2d_##asn1((const type *)x, outp); \
104
- } \
105
- OPENSSL_EXPORT int PEM_write_##name(FILE *fp, const type *x) { \
106
- return PEM_ASN1_write(pem_write_##name##_i2d, str, fp, (void *)x, NULL, \
107
- NULL, 0, NULL, NULL); \
108
- }
109
-
110
- #define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \
111
- static int pem_write_##name##_i2d(const void *x, unsigned char **outp) { \
112
- return i2d_##asn1((type *)x, outp); \
113
- } \
114
- OPENSSL_EXPORT int PEM_write_##name( \
115
- FILE *fp, type *x, const EVP_CIPHER *enc, const unsigned char *pass, \
116
- int pass_len, pem_password_cb *cb, void *u) { \
117
- return PEM_ASN1_write(pem_write_##name##_i2d, str, fp, x, enc, pass, \
118
- pass_len, cb, u); \
119
- }
120
-
121
- #define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \
122
- static int pem_write_##name##_i2d(const void *x, unsigned char **outp) { \
123
- return i2d_##asn1((const type *)x, outp); \
124
- } \
125
- OPENSSL_EXPORT int PEM_write_##name( \
126
- FILE *fp, type *x, const EVP_CIPHER *enc, const unsigned char *pass, \
127
- int pass_len, pem_password_cb *cb, void *u) { \
128
- return PEM_ASN1_write(pem_write_##name##_i2d, str, fp, x, enc, pass, \
129
- pass_len, cb, u); \
130
- }
131
-
132
-
133
- #define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
134
- static void *pem_read_bio_##name##_d2i(void **x, const unsigned char **inp, \
135
- long len) { \
136
- return d2i_##asn1((type **)x, inp, len); \
137
- } \
138
- OPENSSL_EXPORT type *PEM_read_bio_##name(BIO *bp, type **x, \
139
- pem_password_cb *cb, void *u) { \
140
- return (type *)PEM_ASN1_read_bio(pem_read_bio_##name##_d2i, str, bp, \
141
- (void **)x, cb, u); \
142
- }
143
-
144
- #define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
145
- static int pem_write_bio_##name##_i2d(const void *x, unsigned char **outp) { \
146
- return i2d_##asn1((type *)x, outp); \
147
- } \
148
- OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, type *x) { \
149
- return PEM_ASN1_write_bio(pem_write_bio_##name##_i2d, str, bp, x, NULL, \
150
- NULL, 0, NULL, NULL); \
151
- }
152
-
153
- #define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
154
- static int pem_write_bio_##name##_i2d(const void *x, unsigned char **outp) { \
155
- return i2d_##asn1((const type *)x, outp); \
156
- } \
157
- OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, const type *x) { \
158
- return PEM_ASN1_write_bio(pem_write_bio_##name##_i2d, str, bp, (void *)x, \
159
- NULL, NULL, 0, NULL, NULL); \
160
- }
161
-
162
- #define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
163
- static int pem_write_bio_##name##_i2d(const void *x, unsigned char **outp) { \
164
- return i2d_##asn1((type *)x, outp); \
165
- } \
166
- OPENSSL_EXPORT int PEM_write_bio_##name( \
167
- BIO *bp, type *x, const EVP_CIPHER *enc, const unsigned char *pass, \
168
- int pass_len, pem_password_cb *cb, void *u) { \
169
- return PEM_ASN1_write_bio(pem_write_bio_##name##_i2d, str, bp, x, enc, \
170
- pass, pass_len, cb, u); \
171
- }
172
-
173
- #define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
174
- static int pem_write_bio_##name##_i2d(const void *x, unsigned char **outp) { \
175
- return i2d_##asn1((const type *)x, outp); \
176
- } \
177
- OPENSSL_EXPORT int PEM_write_bio_##name( \
178
- BIO *bp, type *x, const EVP_CIPHER *enc, const unsigned char *pass, \
179
- int pass_len, pem_password_cb *cb, void *u) { \
180
- return PEM_ASN1_write_bio(pem_write_bio_##name##_i2d, str, bp, (void *)x, \
181
- enc, pass, pass_len, cb, u); \
182
- }
183
-
184
- #define IMPLEMENT_PEM_write(name, type, str, asn1) \
185
- IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
186
- IMPLEMENT_PEM_write_fp(name, type, str, asn1)
187
-
188
- #define IMPLEMENT_PEM_write_const(name, type, str, asn1) \
189
- IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
190
- IMPLEMENT_PEM_write_fp_const(name, type, str, asn1)
191
-
192
- #define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \
193
- IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
194
- IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1)
195
-
196
- #define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \
197
- IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
198
- IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1)
199
-
200
- #define IMPLEMENT_PEM_read(name, type, str, asn1) \
201
- IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
202
- IMPLEMENT_PEM_read_fp(name, type, str, asn1)
203
-
204
- #define IMPLEMENT_PEM_rw(name, type, str, asn1) \
205
- IMPLEMENT_PEM_read(name, type, str, asn1) \
206
- IMPLEMENT_PEM_write(name, type, str, asn1)
207
-
208
- #define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \
209
- IMPLEMENT_PEM_read(name, type, str, asn1) \
210
- IMPLEMENT_PEM_write_const(name, type, str, asn1)
211
-
212
- #define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \
213
- IMPLEMENT_PEM_read(name, type, str, asn1) \
214
- IMPLEMENT_PEM_write_cb(name, type, str, asn1)
215
-
216
- // These are the same except they are for the declarations
217
-
218
- #define DECLARE_PEM_read_fp(name, type) \
219
- OPENSSL_EXPORT type *PEM_read_##name(FILE *fp, type **x, \
220
- pem_password_cb *cb, void *u);
221
-
222
- #define DECLARE_PEM_write_fp(name, type) \
223
- OPENSSL_EXPORT int PEM_write_##name(FILE *fp, type *x);
224
-
225
- #define DECLARE_PEM_write_fp_const(name, type) \
226
- OPENSSL_EXPORT int PEM_write_##name(FILE *fp, const type *x);
227
-
228
- #define DECLARE_PEM_write_cb_fp(name, type) \
229
- OPENSSL_EXPORT int PEM_write_##name( \
230
- FILE *fp, type *x, const EVP_CIPHER *enc, const unsigned char *pass, \
231
- int pass_len, pem_password_cb *cb, void *u);
232
-
233
- #define DECLARE_PEM_read_bio(name, type) \
234
- OPENSSL_EXPORT type *PEM_read_bio_##name(BIO *bp, type **x, \
235
- pem_password_cb *cb, void *u);
236
-
237
- #define DECLARE_PEM_write_bio(name, type) \
238
- OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, type *x);
239
-
240
- #define DECLARE_PEM_write_bio_const(name, type) \
241
- OPENSSL_EXPORT int PEM_write_bio_##name(BIO *bp, const type *x);
242
-
243
- #define DECLARE_PEM_write_cb_bio(name, type) \
244
- OPENSSL_EXPORT int PEM_write_bio_##name( \
245
- BIO *bp, type *x, const EVP_CIPHER *enc, const unsigned char *pass, \
246
- int pass_len, pem_password_cb *cb, void *u);
247
-
248
-
249
- #define DECLARE_PEM_write(name, type) \
250
- DECLARE_PEM_write_bio(name, type) \
251
- DECLARE_PEM_write_fp(name, type)
252
-
253
- #define DECLARE_PEM_write_const(name, type) \
254
- DECLARE_PEM_write_bio_const(name, type) \
255
- DECLARE_PEM_write_fp_const(name, type)
256
-
257
- #define DECLARE_PEM_write_cb(name, type) \
258
- DECLARE_PEM_write_cb_bio(name, type) \
259
- DECLARE_PEM_write_cb_fp(name, type)
260
-
261
- #define DECLARE_PEM_read(name, type) \
262
- DECLARE_PEM_read_bio(name, type) \
263
- DECLARE_PEM_read_fp(name, type)
264
-
265
- #define DECLARE_PEM_rw(name, type) \
266
- DECLARE_PEM_read(name, type) \
267
- DECLARE_PEM_write(name, type)
268
-
269
- #define DECLARE_PEM_rw_const(name, type) \
270
- DECLARE_PEM_read(name, type) \
271
- DECLARE_PEM_write_const(name, type)
272
-
273
- #define DECLARE_PEM_rw_cb(name, type) \
274
- DECLARE_PEM_read(name, type) \
275
- DECLARE_PEM_write_cb(name, type)
276
-
277
- // "userdata": new with OpenSSL 0.9.4
278
- typedef int pem_password_cb(char *buf, int size, int rwflag, void *userdata);
127
+ #endif // Sample functions
279
128
 
280
- // PEM_read_bio reads from `bp`, until the next PEM block. If one is found, it
281
- // returns one and sets `*name`, `*header`, and `*data` to newly-allocated
282
- // buffers containing the PEM type, the header block, and the decoded data,
283
- // respectively. `*name` and `*header` are NUL-terminated C strings, while
284
- // `*data` has `*len` bytes. The caller must release each of `*name`, `*header`,
285
- // and `*data` with `OPENSSL_free` when done. If no PEM block is found, this
286
- // function returns zero and pushes `PEM_R_NO_START_LINE` to the error queue. If
287
- // one is found, but there is an error decoding it, it returns zero and pushes
288
- // some other error to the error queue.
289
- OPENSSL_EXPORT int PEM_read_bio(BIO *bp, char **name, char **header,
290
- unsigned char **data, long *len);
291
129
 
292
- // PEM_write_bio writes a PEM block to `bp`, containing `len` bytes from `data`
293
- // as data. `name` and `hdr` are NUL-terminated C strings containing the PEM
294
- // type and header block, respectively. This function returns zero on error and
295
- // the number of bytes written on success.
296
- OPENSSL_EXPORT int PEM_write_bio(BIO *bp, const char *name, const char *hdr,
297
- const unsigned char *data, long len);
130
+ // Reading and writing X.509 structures as PEM.
298
131
 
299
- OPENSSL_EXPORT int PEM_bytes_read_bio(unsigned char **pdata, long *plen,
300
- char **pnm, const char *name, BIO *bp,
301
- pem_password_cb *cb, void *u);
302
- OPENSSL_EXPORT void *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name,
303
- BIO *bp, void **x, pem_password_cb *cb,
304
- void *u);
305
- OPENSSL_EXPORT int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name,
306
- BIO *bp, void *x, const EVP_CIPHER *enc,
307
- const unsigned char *pass, int pass_len,
308
- pem_password_cb *cb, void *u);
132
+ // PEM_read_bio_X509 reads a PEM block of type "CERTIFICATE" (RFC 7468) or "X509
133
+ // CERTIFICATE", as described in `PEM_read_bio_SAMPLE`.
134
+ OPENSSL_EXPORT X509 *PEM_read_bio_X509(BIO *bio, X509 **out,
135
+ pem_password_cb *cb, void *userdata);
136
+
137
+ // PEM_write_bio_X509 writes a PEM block of type "CERTIFICATE" (RFC 7468), as
138
+ // described in `PEM_write_bio_SAMPLE`.
139
+ OPENSSL_EXPORT int PEM_write_bio_X509(BIO *bio, const X509 *in);
140
+
141
+ // PEM_read_bio_X509_AUX reads a PEM block of type "CERTIFICATE" (RFC 7468),
142
+ // "X509 CERTIFICATE", or "TRUSTED CERTIFICATE", as described in
143
+ // `PEM_read_bio_SAMPLE`.
144
+ //
145
+ // WARNING: This function parses auxiliary properties as in `d2i_X509_AUX`.
146
+ // Passing untrusted input to this function allows an attacker to influence
147
+ // those properties. See `d2i_X509_AUX` for details.
148
+ OPENSSL_EXPORT X509 *PEM_read_bio_X509_AUX(BIO *bio, X509 **out,
149
+ pem_password_cb *cb, void *userdata);
150
+
151
+ // PEM_write_bio_X509_AUX writes a PEM block of type "TRUSTED CERTIFICATE", as
152
+ // described in `PEM_write_bio_SAMPLE`.
153
+ //
154
+ // WARNING: This function writes a custom OpenSSL-specific format that includes
155
+ // auxiliary properties. See `i2d_X509_AUX`.
156
+ OPENSSL_EXPORT int PEM_write_bio_X509_AUX(BIO *bio, const X509 *in);
157
+
158
+ // PEM_read_bio_X509_CRL reads a PEM block of type "X509 CRL" (RFC 7468), as
159
+ // described in `PEM_read_bio_SAMPLE`.
160
+ OPENSSL_EXPORT X509_CRL *PEM_read_bio_X509_CRL(BIO *bio, X509_CRL **out,
161
+ pem_password_cb *cb,
162
+ void *userdata);
163
+
164
+ // PEM_write_bio_X509_CRL writes a PEM block of type "X509 CRL" (RFC 7468), as
165
+ // described in `PEM_write_bio_SAMPLE`.
166
+ OPENSSL_EXPORT int PEM_write_bio_X509_CRL(BIO *bio, const X509_CRL *in);
167
+
168
+ // PEM_read_bio_X509_REQ reads a PEM block of type "CERTIFICATE REQUEST"
169
+ // (RFC 7468) or "NEW CERTIFICATE REQUEST", as described in
170
+ // `PEM_read_bio_SAMPLE`.
171
+ OPENSSL_EXPORT X509_REQ *PEM_read_bio_X509_REQ(BIO *bio, X509_REQ **out,
172
+ pem_password_cb *cb,
173
+ void *userdata);
174
+
175
+ // PEM_write_bio_X509_REQ writes a PEM block of type "CERTIFICATE REQUEST"
176
+ // (RFC 7468), as described in `PEM_write_bio_SAMPLE`.
177
+ OPENSSL_EXPORT int PEM_write_bio_X509_REQ(BIO *bio, const X509_REQ *in);
178
+
179
+ // PEM_write_bio_X509_REQ_NEW writes a PEM block of type "NEW CERTIFICATE
180
+ // REQUEST", as described in `PEM_write_bio_SAMPLE`. Prefer to use
181
+ // `PEM_write_bio_X509_REQ`. "NEW CERTIFICATE REQUEST" is the older type.
182
+ OPENSSL_EXPORT int PEM_write_bio_X509_REQ_NEW(BIO *bio, const X509_REQ *in);
183
+
184
+ // PEM_read_bio_PKCS7 reads a PEM block of type "PKCS7" (RFC 7468) or "PKCS #7
185
+ // SIGNED DATA", as described in `PEM_read_bio_SAMPLE`.
186
+ //
187
+ // This function also accepts type "CERTIFICATE" but decodes the contents as a
188
+ // PKCS #7 structure rather than a certificate. This is a historical workaround
189
+ // for an old CA bug.
190
+ OPENSSL_EXPORT PKCS7 *PEM_read_bio_PKCS7(BIO *bio, PKCS7 **out,
191
+ pem_password_cb *cb, void *userdata);
192
+
193
+ // PEM_write_bio_PKCS7 writes a PEM block of type "PKCS7" (RFC 7468), as
194
+ // described in `PEM_write_bio_SAMPLE`.
195
+ OPENSSL_EXPORT int PEM_write_bio_PKCS7(BIO *bio, const PKCS7 *in);
309
196
 
310
- // PEM_X509_INFO_read_bio reads PEM blocks from `bp` and decodes any
197
+ // PEM_X509_INFO_read_bio reads PEM blocks from `bio` and decodes any
311
198
  // certificates, CRLs, and private keys found. It returns a
312
199
  // `STACK_OF(X509_INFO)` structure containing the results, or NULL on error.
313
200
  //
@@ -319,7 +206,7 @@ OPENSSL_EXPORT int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name,
319
206
  // on success. In this case, the caller retains ownership of `sk` in both
320
207
  // success and failure.
321
208
  //
322
- // This function will decrypt any encrypted certificates in `bp`, using `cb`,
209
+ // This function will decrypt any encrypted certificates in `bio`, using `cb`,
323
210
  // but it will not decrypt encrypted private keys. Encrypted private keys are
324
211
  // instead represented as placeholder `X509_INFO` objects with an empty `x_pkey`
325
212
  // field. This allows this function to be used with inputs with unencrypted
@@ -332,117 +219,529 @@ OPENSSL_EXPORT int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name,
332
219
  // input to this function allows an attacker to influence those properties. See
333
220
  // `d2i_X509_AUX` for details.
334
221
  OPENSSL_EXPORT STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(
335
- BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u);
336
-
337
- // PEM_X509_INFO_read behaves like `PEM_X509_INFO_read_bio` but reads from a
338
- // `FILE`.
339
- OPENSSL_EXPORT STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp,
340
- STACK_OF(X509_INFO) *sk,
341
- pem_password_cb *cb,
342
- void *u);
343
-
344
- OPENSSL_EXPORT int PEM_read(FILE *fp, char **name, char **header,
345
- unsigned char **data, long *len);
346
- OPENSSL_EXPORT int PEM_write(FILE *fp, const char *name, const char *hdr,
347
- const unsigned char *data, long len);
348
- OPENSSL_EXPORT void *PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp,
349
- void **x, pem_password_cb *cb, void *u);
350
- OPENSSL_EXPORT int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp,
351
- void *x, const EVP_CIPHER *enc,
352
- const unsigned char *pass, int pass_len,
353
- pem_password_cb *callback, void *u);
354
-
355
- // PEM_def_callback treats `userdata` as a string and copies it into `buf`,
356
- // assuming its `size` is sufficient. Returns the length of the string, or -1 on
357
- // error. Error cases the buffer being too small, or `buf` and `userdata` being
358
- // NULL. Note that this is different from OpenSSL, which prompts for a password.
359
- OPENSSL_EXPORT int PEM_def_callback(char *buf, int size, int rwflag,
360
- void *userdata);
361
-
362
-
363
- DECLARE_PEM_rw(X509, X509)
222
+ BIO *bio, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *userdata);
364
223
 
365
- // TODO(crbug.com/boringssl/426): When documenting these, copy the warning
366
- // about auxiliary properties from `PEM_X509_INFO_read_bio`.
367
224
 
368
- DECLARE_PEM_rw(X509_AUX, X509)
369
-
370
- DECLARE_PEM_rw(X509_REQ, X509_REQ)
371
- DECLARE_PEM_write(X509_REQ_NEW, X509_REQ)
372
-
373
- DECLARE_PEM_rw(X509_CRL, X509_CRL)
374
-
375
- DECLARE_PEM_rw(PKCS7, PKCS7)
376
- DECLARE_PEM_rw(PKCS8, X509_SIG)
377
-
378
- DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO)
379
-
380
- DECLARE_PEM_rw_cb(RSAPrivateKey, RSA)
381
-
382
- DECLARE_PEM_rw_const(RSAPublicKey, RSA)
383
- DECLARE_PEM_rw(RSA_PUBKEY, RSA)
384
-
385
- #ifndef OPENSSL_NO_DSA
225
+ // Reading and writing keys as PEM.
226
+ //
227
+ // There are multiple PEM formats for public and private keys:
228
+ //
229
+ // Public keys are generally encoded with type "PUBLIC KEY" (RFC 7468), which
230
+ // encodes a SubjectPublicKeyInfo structure (RFC 5280).
231
+ //
232
+ // Private keys may be encoded with type "PRIVATE KEY" or "ENCRYPTED PRIVATE
233
+ // KEY" (RFC 7468), which encode a PrivateKeyInfo or EncryptedPrivateKeyInfo
234
+ // (RFC 5208) structure. EncryptedPrivateKeyInfo is, itself, a mechanism for
235
+ // encrypting private keys with a password, so private keys may be encrypted
236
+ // with PEM encryption, PKCS #8 encryption, or both.
237
+ //
238
+ // There are also older algorithm-specific PEM types for public and private
239
+ // keys, including "RSA PUBLIC KEY", "RSA PRIVATE KEY", "EC PRIVATE KEY", and
240
+ // "DSA PRIVATE KEY". Some functions in this library will read or write them.
241
+ //
242
+ // If unsure, use the "PUBLIC KEY" and "PRIVATE KEY" formats.
386
243
 
387
- DECLARE_PEM_rw_cb(DSAPrivateKey, DSA)
244
+ // PEM_read_bio_PrivateKey reads a PEM block containing a private key, as
245
+ // described in `PEM_read_bio_SAMPLE`. It handles generic PKCS #8 blocks of type
246
+ // "PRIVATE KEY" and "ENCRYPTED PRIVATE KEY", as well as key-specific formats
247
+ // like "RSA PRIVATE KEY", "EC PRIVATE KEY", and "DSA PRIVATE KEY".
248
+ //
249
+ // `cb` and `userdata` are used to look up the password for both PEM-level
250
+ // encryption as well as PKCS #8 encryption, in the case of "ENCRYPTED PRIVATE
251
+ // KEY" blocks.
252
+ OPENSSL_EXPORT EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bio, EVP_PKEY **out,
253
+ pem_password_cb *cb,
254
+ void *userdata);
255
+
256
+ // PEM_write_bio_PrivateKey writes `in` to `bio` in PKCS#8 format, as described
257
+ // in `PEM_write_bio_SAMPLE`. However, it interprets encryption parameters
258
+ // differently:
259
+ //
260
+ // - If not encrypting (`enc` is NULL), it writes the key as a PEM block of type
261
+ // "PRIVATE KEY".
262
+ //
263
+ // - If encrypted (`enc` is not NULL), it encrypts the key in an
264
+ // EncryptedPrivateKeyInfo using PBES2 (see `PKCS8_encrypt`) and writes the
265
+ // result as a PEM block of type "ENCRYPTED PRIVATE KEY".
266
+ OPENSSL_EXPORT int PEM_write_bio_PrivateKey(BIO *bio, const EVP_PKEY *in,
267
+ const EVP_CIPHER *enc,
268
+ const uint8_t *pass, int pass_len,
269
+ pem_password_cb *cb,
270
+ void *userdata);
271
+
272
+ // PEM_read_bio_PUBKEY reads a PEM block of type "PUBLIC KEY", as described in
273
+ // `PEM_read_bio_SAMPLE`.
274
+ OPENSSL_EXPORT EVP_PKEY *PEM_read_bio_PUBKEY(BIO *bio, EVP_PKEY **out,
275
+ pem_password_cb *cb,
276
+ void *userdata);
277
+
278
+ // PEM_write_bio_PUBKEY writes `in` as a PEM block of type "PUBLIC KEY", as
279
+ // described in `PEM_write_bio_SAMPLE`.
280
+ OPENSSL_EXPORT int PEM_write_bio_PUBKEY(BIO *bio, const EVP_PKEY *in);
281
+
282
+ // PEM_write_bio_PKCS8PrivateKey_nid behaves like `PEM_write_bio_PrivateKey`
283
+ // but uses the PBES1 algorithm specified by `nid` for encryption. See also
284
+ // `PKCS8_encrypt`. If `nid` is -1, it writes the private key unencrypted.
285
+ OPENSSL_EXPORT int PEM_write_bio_PKCS8PrivateKey_nid(
286
+ BIO *bio, const EVP_PKEY *in, int nid, const char *pass, int pass_len,
287
+ pem_password_cb *cb, void *userdata);
288
+
289
+ // PEM_write_bio_PKCS8PrivateKey is an alias for `PEM_write_bio_PrivateKey`.
290
+ OPENSSL_EXPORT int PEM_write_bio_PKCS8PrivateKey(BIO *bio, const EVP_PKEY *in,
291
+ const EVP_CIPHER *enc,
292
+ const char *pass, int pass_len,
293
+ pem_password_cb *cb,
294
+ void *userdata);
388
295
 
389
- DECLARE_PEM_rw(DSA_PUBKEY, DSA)
296
+ // PEM_write_PKCS8PrivateKey_nid behaves like
297
+ // `PEM_write_bio_PKCS8PrivateKey_nid` but writes to `fp`.
298
+ OPENSSL_EXPORT int PEM_write_PKCS8PrivateKey_nid(FILE *fp, const EVP_PKEY *in,
299
+ int nid, const char *pass,
300
+ int pass_len,
301
+ pem_password_cb *cb,
302
+ void *userdata);
390
303
 
391
- DECLARE_PEM_rw_const(DSAparams, DSA)
304
+ // PEM_write_PKCS8PrivateKey behaves like `PEM_write_bio_PKCS8PrivateKey` but
305
+ // writes to `fp`.
306
+ OPENSSL_EXPORT int PEM_write_PKCS8PrivateKey(FILE *fp, const EVP_PKEY *in,
307
+ const EVP_CIPHER *enc,
308
+ const char *pass, int pass_len,
309
+ pem_password_cb *cb,
310
+ void *userdata);
392
311
 
393
- #endif
312
+ // PEM_read_bio_PKCS8 reads a PEM block of type "ENCRYPTED PRIVATE KEY", as
313
+ // described in `PEM_read_bio_SAMPLE`.
314
+ //
315
+ // Although this function accepts `cb` and `userdata` to decrypt the PEM-level
316
+ // encryption, it does not decrypt the EncryptedPrivateKeyInfo structure. It
317
+ // returns the encrypted key as an `X509_SIG` object which, despite its name, is
318
+ // an algorithm and octet string pair.
319
+ OPENSSL_EXPORT X509_SIG *PEM_read_bio_PKCS8(BIO *bio, X509_SIG **out,
320
+ pem_password_cb *cb,
321
+ void *userdata);
322
+
323
+ // PEM_write_bio_PKCS8 writes a PEM block of type "ENCRYPTED PRIVATE KEY", as
324
+ // described in `PEM_write_bio_SAMPLE`. `in` is used to represent an
325
+ // already-encrypted EncryptedPrivateKeyInfo structure.
326
+ OPENSSL_EXPORT int PEM_write_bio_PKCS8(BIO *bio, const X509_SIG *in);
327
+
328
+ // PEM_read_bio_PKCS8_PRIV_KEY_INFO reads a PEM block of type "PRIVATE KEY", as
329
+ // described in `PEM_read_bio_SAMPLE`.
330
+ OPENSSL_EXPORT PKCS8_PRIV_KEY_INFO *PEM_read_bio_PKCS8_PRIV_KEY_INFO(
331
+ BIO *bio, PKCS8_PRIV_KEY_INFO **out, pem_password_cb *cb, void *userdata);
332
+
333
+ // PEM_write_bio_PKCS8_PRIV_KEY_INFO writes a PEM block of type "PRIVATE KEY",
334
+ // as described in `PEM_write_bio_SAMPLE`.
335
+ OPENSSL_EXPORT int PEM_write_bio_PKCS8_PRIV_KEY_INFO(
336
+ BIO *bio, const PKCS8_PRIV_KEY_INFO *in);
337
+
338
+ // PEM_read_bio_RSAPrivateKey behaves like `PEM_read_bio_PrivateKey` but only
339
+ // returns RSA keys, represented as an `RSA` object. Keys of other types result
340
+ // in an error.
341
+ OPENSSL_EXPORT RSA *PEM_read_bio_RSAPrivateKey(BIO *bio, RSA **out,
342
+ pem_password_cb *cb,
343
+ void *userdata);
344
+
345
+ // PEM_write_bio_RSAPrivateKey writes `in` as a PEM block of type "RSA PRIVATE
346
+ // KEY", as described in `PEM_write_bio_SAMPLE`.
347
+ OPENSSL_EXPORT int PEM_write_bio_RSAPrivateKey(
348
+ BIO *bio, const RSA *in, const EVP_CIPHER *enc, const uint8_t *pass,
349
+ int pass_len, pem_password_cb *cb, void *userdata);
350
+
351
+ // PEM_read_bio_RSAPublicKey reads a PEM block of type "RSA PUBLIC KEY", as
352
+ // described in `PEM_read_bio_SAMPLE`.
353
+ OPENSSL_EXPORT RSA *PEM_read_bio_RSAPublicKey(BIO *bio, RSA **out,
354
+ pem_password_cb *cb,
355
+ void *userdata);
356
+
357
+ // PEM_write_bio_RSAPublicKey writes a PEM block of type "RSA PUBLIC KEY", as
358
+ // described in `PEM_write_bio_SAMPLE`.
359
+ OPENSSL_EXPORT int PEM_write_bio_RSAPublicKey(BIO *bio, const RSA *in);
360
+
361
+ // PEM_read_bio_RSA_PUBKEY behaves like `PEM_read_bio_PUBKEY` but only returns
362
+ // RSA keys, represented as an `RSA` object. Keys of other types result in an
363
+ // error.
364
+ OPENSSL_EXPORT RSA *PEM_read_bio_RSA_PUBKEY(BIO *bio, RSA **out,
365
+ pem_password_cb *cb,
366
+ void *userdata);
367
+
368
+ // PEM_write_bio_RSA_PUBKEY writes `in` as a PEM block of type "PUBLIC KEY", as
369
+ // described in `PEM_write_bio_SAMPLE`.
370
+ OPENSSL_EXPORT int PEM_write_bio_RSA_PUBKEY(BIO *bio, const RSA *in);
371
+
372
+ // PEM_read_bio_DSAPrivateKey behaves like `PEM_read_bio_PrivateKey` but only
373
+ // returns DSA keys, represented as a `DSA` object. Keys of other types result
374
+ // in an error.
375
+ OPENSSL_EXPORT DSA *PEM_read_bio_DSAPrivateKey(BIO *bio, DSA **out,
376
+ pem_password_cb *cb,
377
+ void *userdata);
378
+
379
+ // PEM_write_bio_DSAPrivateKey writes `in` as a PEM block of type "DSA PRIVATE
380
+ // KEY", as described in `PEM_write_bio_SAMPLE`.
381
+ OPENSSL_EXPORT int PEM_write_bio_DSAPrivateKey(
382
+ BIO *bio, const DSA *in, const EVP_CIPHER *enc, const uint8_t *pass,
383
+ int pass_len, pem_password_cb *cb, void *userdata);
384
+
385
+ // PEM_read_bio_DSA_PUBKEY behaves like `PEM_read_bio_PUBKEY` but only returns
386
+ // DSA keys, represented as a `DSA` object. Keys of other types result in an
387
+ // error.
388
+ OPENSSL_EXPORT DSA *PEM_read_bio_DSA_PUBKEY(BIO *bio, DSA **out,
389
+ pem_password_cb *cb,
390
+ void *userdata);
391
+
392
+ // PEM_write_bio_DSA_PUBKEY writes `in` in SubjectPublicKeyInfo format as a PEM
393
+ // block of type "PUBLIC KEY", as described in `PEM_write_bio_SAMPLE`.
394
+ OPENSSL_EXPORT int PEM_write_bio_DSA_PUBKEY(BIO *bio, const DSA *in);
395
+
396
+ // PEM_read_bio_DSAparams reads a PEM block of type "DSA PARAMETERS", as
397
+ // described in `PEM_read_bio_SAMPLE`.
398
+ OPENSSL_EXPORT DSA *PEM_read_bio_DSAparams(BIO *bio, DSA **out,
399
+ pem_password_cb *cb, void *userdata);
400
+
401
+ // PEM_write_bio_DSAparams writes a PEM block of type "DSA PARAMETERS", as
402
+ // described in `PEM_write_bio_SAMPLE`.
403
+ OPENSSL_EXPORT int PEM_write_bio_DSAparams(BIO *bio, const DSA *in);
404
+
405
+ // PEM_read_bio_ECPrivateKey behaves like `PEM_read_bio_PrivateKey` but only
406
+ // returns EC keys, represented as an `EC_KEY` object. Keys of other types
407
+ // result in an error.
408
+ OPENSSL_EXPORT EC_KEY *PEM_read_bio_ECPrivateKey(BIO *bio, EC_KEY **out,
409
+ pem_password_cb *cb,
410
+ void *userdata);
411
+
412
+ // PEM_write_bio_ECPrivateKey writes `in` as a PEM block of type "EC PRIVATE
413
+ // KEY", as described in `PEM_write_bio_SAMPLE`.
414
+ OPENSSL_EXPORT int PEM_write_bio_ECPrivateKey(BIO *bio, const EC_KEY *in,
415
+ const EVP_CIPHER *enc,
416
+ const uint8_t *pass, int pass_len,
417
+ pem_password_cb *cb,
418
+ void *userdata);
419
+
420
+ // PEM_read_bio_EC_PUBKEY behaves like `PEM_read_bio_PUBKEY` but only returns
421
+ // EC keys, represented as an `EC_KEY` object. Keys of other types result in an
422
+ // error.
423
+ OPENSSL_EXPORT EC_KEY *PEM_read_bio_EC_PUBKEY(BIO *bio, EC_KEY **out,
424
+ pem_password_cb *cb,
425
+ void *userdata);
426
+
427
+ // PEM_write_bio_EC_PUBKEY writes `in` in SubjectPublicKeyInfo format as a PEM
428
+ // block of type "PUBLIC KEY", as described in `PEM_write_bio_SAMPLE`.
429
+ OPENSSL_EXPORT int PEM_write_bio_EC_PUBKEY(BIO *bio, const EC_KEY *in);
430
+
431
+ // PEM_read_bio_DHparams reads a PEM block of type "DH PARAMETERS", as described
432
+ // in `PEM_read_bio_SAMPLE`.
433
+ OPENSSL_EXPORT DH *PEM_read_bio_DHparams(BIO *bio, DH **out,
434
+ pem_password_cb *cb, void *userdata);
435
+
436
+ // PEM_write_bio_DHparams writes a PEM block of type "DH PARAMETERS", as
437
+ // described in `PEM_write_bio_SAMPLE`.
438
+ OPENSSL_EXPORT int PEM_write_bio_DHparams(BIO *bio, const DH *in);
439
+
440
+
441
+ // File-based functions.
442
+
443
+ // The following functions behave like the corresponding `PEM_read_bio_*`
444
+ // functions, but read from `fp`.
445
+ OPENSSL_EXPORT X509 *PEM_read_X509(FILE *fp, X509 **out, pem_password_cb *cb,
446
+ void *userdata);
447
+ OPENSSL_EXPORT X509_CRL *PEM_read_X509_CRL(FILE *fp, X509_CRL **out,
448
+ pem_password_cb *cb, void *userdata);
449
+ OPENSSL_EXPORT X509 *PEM_read_X509_AUX(FILE *fp, X509 **out,
450
+ pem_password_cb *cb, void *userdata);
451
+ OPENSSL_EXPORT STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp,
452
+ STACK_OF(X509_INFO) *sk,
453
+ pem_password_cb *cb,
454
+ void *userdata);
455
+ OPENSSL_EXPORT X509_REQ *PEM_read_X509_REQ(FILE *fp, X509_REQ **out,
456
+ pem_password_cb *cb, void *userdata);
457
+ OPENSSL_EXPORT PKCS7 *PEM_read_PKCS7(FILE *fp, PKCS7 **out, pem_password_cb *cb,
458
+ void *userdata);
459
+ OPENSSL_EXPORT X509_SIG *PEM_read_PKCS8(FILE *fp, X509_SIG **out,
460
+ pem_password_cb *cb, void *userdata);
461
+ OPENSSL_EXPORT PKCS8_PRIV_KEY_INFO *PEM_read_PKCS8_PRIV_KEY_INFO(
462
+ FILE *fp, PKCS8_PRIV_KEY_INFO **out, pem_password_cb *cb, void *userdata);
463
+ OPENSSL_EXPORT RSA *PEM_read_RSAPrivateKey(FILE *fp, RSA **out,
464
+ pem_password_cb *cb, void *userdata);
465
+ OPENSSL_EXPORT RSA *PEM_read_RSAPublicKey(FILE *fp, RSA **out,
466
+ pem_password_cb *cb, void *userdata);
467
+ OPENSSL_EXPORT RSA *PEM_read_RSA_PUBKEY(FILE *fp, RSA **out,
468
+ pem_password_cb *cb, void *userdata);
469
+ OPENSSL_EXPORT DSA *PEM_read_DSAPrivateKey(FILE *fp, DSA **out,
470
+ pem_password_cb *cb, void *userdata);
471
+ OPENSSL_EXPORT DSA *PEM_read_DSA_PUBKEY(FILE *fp, DSA **out,
472
+ pem_password_cb *cb, void *userdata);
473
+ OPENSSL_EXPORT DSA *PEM_read_DSAparams(FILE *fp, DSA **out, pem_password_cb *cb,
474
+ void *userdata);
475
+ OPENSSL_EXPORT EC_KEY *PEM_read_ECPrivateKey(FILE *fp, EC_KEY **out,
476
+ pem_password_cb *cb,
477
+ void *userdata);
478
+ OPENSSL_EXPORT EC_KEY *PEM_read_EC_PUBKEY(FILE *fp, EC_KEY **out,
479
+ pem_password_cb *cb, void *userdata);
480
+ OPENSSL_EXPORT DH *PEM_read_DHparams(FILE *fp, DH **out, pem_password_cb *cb,
481
+ void *userdata);
482
+ OPENSSL_EXPORT EVP_PKEY *PEM_read_PrivateKey(FILE *fp, EVP_PKEY **out,
483
+ pem_password_cb *cb,
484
+ void *userdata);
485
+ OPENSSL_EXPORT EVP_PKEY *PEM_read_PUBKEY(FILE *fp, EVP_PKEY **out,
486
+ pem_password_cb *cb, void *userdata);
487
+
488
+ // The following functions behave like the corresponding `PEM_write_bio_*`
489
+ // functions, but write to `fp`.
490
+ OPENSSL_EXPORT int PEM_write_X509(FILE *fp, const X509 *x);
491
+ OPENSSL_EXPORT int PEM_write_X509_CRL(FILE *fp, const X509_CRL *in);
492
+ OPENSSL_EXPORT int PEM_write_X509_AUX(FILE *fp, const X509 *in);
493
+ OPENSSL_EXPORT int PEM_write_X509_REQ(FILE *fp, const X509_REQ *in);
494
+ OPENSSL_EXPORT int PEM_write_X509_REQ_NEW(FILE *fp, const X509_REQ *in);
495
+ OPENSSL_EXPORT int PEM_write_PKCS7(FILE *fp, const PKCS7 *in);
496
+ OPENSSL_EXPORT int PEM_write_PKCS8(FILE *fp, const X509_SIG *in);
497
+ OPENSSL_EXPORT int PEM_write_PKCS8_PRIV_KEY_INFO(FILE *fp,
498
+ const PKCS8_PRIV_KEY_INFO *in);
499
+ OPENSSL_EXPORT int PEM_write_RSAPrivateKey(FILE *fp, const RSA *in,
500
+ const EVP_CIPHER *enc,
501
+ const uint8_t *pass, int pass_len,
502
+ pem_password_cb *cb, void *userdata);
503
+ OPENSSL_EXPORT int PEM_write_RSAPublicKey(FILE *fp, const RSA *in);
504
+ OPENSSL_EXPORT int PEM_write_RSA_PUBKEY(FILE *fp, const RSA *in);
505
+ OPENSSL_EXPORT int PEM_write_DSAPrivateKey(FILE *fp, const DSA *in,
506
+ const EVP_CIPHER *enc,
507
+ const uint8_t *pass, int pass_len,
508
+ pem_password_cb *cb, void *userdata);
509
+ OPENSSL_EXPORT int PEM_write_DSA_PUBKEY(FILE *fp, const DSA *in);
510
+ OPENSSL_EXPORT int PEM_write_DSAparams(FILE *fp, const DSA *in);
511
+ OPENSSL_EXPORT int PEM_write_ECPrivateKey(FILE *fp, const EC_KEY *in,
512
+ const EVP_CIPHER *enc,
513
+ const uint8_t *pass, int pass_len,
514
+ pem_password_cb *cb, void *userdata);
515
+ OPENSSL_EXPORT int PEM_write_EC_PUBKEY(FILE *fp, const EC_KEY *in);
516
+ OPENSSL_EXPORT int PEM_write_DHparams(FILE *fp, const DH *in);
517
+ OPENSSL_EXPORT int PEM_write_PrivateKey(FILE *fp, const EVP_PKEY *in,
518
+ const EVP_CIPHER *enc,
519
+ const uint8_t *pass, int pass_len,
520
+ pem_password_cb *cb, void *userdata);
521
+ OPENSSL_EXPORT int PEM_write_PUBKEY(FILE *fp, const EVP_PKEY *in);
522
+
523
+
524
+ // Reading and writing raw PEM blocks.
525
+ //
526
+ // The functions in this section read and write PEM blocks without decoding
527
+ // their contents.
394
528
 
395
- DECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY)
396
- DECLARE_PEM_rw(EC_PUBKEY, EC_KEY)
529
+ // PEM_BUFSIZE is an arbitrary buffer size used within the library. Some
530
+ // external callers depend on it being defined.
531
+ #define PEM_BUFSIZE 1024
397
532
 
533
+ // The following constants are a collection of known PEM types.
534
+ #define PEM_STRING_X509_OLD "X509 CERTIFICATE"
535
+ #define PEM_STRING_X509 "CERTIFICATE"
536
+ #define PEM_STRING_X509_PAIR "CERTIFICATE PAIR"
537
+ #define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE"
538
+ #define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST"
539
+ #define PEM_STRING_X509_REQ "CERTIFICATE REQUEST"
540
+ #define PEM_STRING_X509_CRL "X509 CRL"
541
+ #define PEM_STRING_PUBLIC "PUBLIC KEY"
542
+ #define PEM_STRING_RSA "RSA PRIVATE KEY"
543
+ #define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY"
544
+ #define PEM_STRING_DSA "DSA PRIVATE KEY"
545
+ #define PEM_STRING_DSA_PUBLIC "DSA PUBLIC KEY"
546
+ #define PEM_STRING_EC "EC PRIVATE KEY"
547
+ #define PEM_STRING_PKCS7 "PKCS7"
548
+ #define PEM_STRING_PKCS7_SIGNED "PKCS #7 SIGNED DATA"
549
+ #define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY"
550
+ #define PEM_STRING_PKCS8INF "PRIVATE KEY"
551
+ #define PEM_STRING_DHPARAMS "DH PARAMETERS"
552
+ #define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS"
553
+ #define PEM_STRING_DSAPARAMS "DSA PARAMETERS"
554
+ #define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY"
555
+ #define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY"
556
+ #define PEM_STRING_CMS "CMS"
398
557
 
399
- DECLARE_PEM_rw_const(DHparams, DH)
558
+ // PEM_STRING_EVP_PKEY is not a PEM type, but is an implementation detail of
559
+ // `PEM_read_bio_PrivateKey`.
560
+ #define PEM_STRING_EVP_PKEY "ANY PRIVATE KEY"
400
561
 
562
+ // PEM_read_bio reads from `bio` until the next PEM block. If one is found, it
563
+ // returns one and sets `*out_name`, `*out_header`, and `*out_data` to
564
+ // newly-allocated buffers containing the PEM type, the header block, and the
565
+ // decoded data, respectively. `*out_name` and `*out_header` are NUL-terminated
566
+ // C strings, while `*out_data` has `*out_len` bytes. The caller must release
567
+ // each of `*out_name`, `*out_header`, and `*out_data` with `OPENSSL_free` when
568
+ // done.
569
+ //
570
+ // If no PEM block is found, this function returns zero and pushes
571
+ // `PEM_R_NO_START_LINE` to the error queue. If one is found, but there is an
572
+ // error decoding it, it returns zero and pushes some other error to the error
573
+ // queue.
574
+ //
575
+ // This function does not decrypt encrypted PEM blocks and instead returns the
576
+ // header and (possibly encrypted) data unprocessed. See `PEM_bytes_read_bio` to
577
+ // decrypt blocks.
578
+ OPENSSL_EXPORT int PEM_read_bio(BIO *bio, char **out_name, char **out_header,
579
+ uint8_t **out_data, long *out_len);
401
580
 
402
- DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY)
581
+ // PEM_read behaves like `PEM_read_bio` but reads from `fp`.
582
+ OPENSSL_EXPORT int PEM_read(FILE *fp, char **out_name, char **out_header,
583
+ uint8_t **out_data, long *out_len);
403
584
 
404
- DECLARE_PEM_rw(PUBKEY, EVP_PKEY)
585
+ // PEM_write_bio writes a PEM block to `bio`, containing `len` bytes from `data`
586
+ // as data. `name` and `hdr` are NUL-terminated C strings containing the PEM
587
+ // type and header block, respectively. This function returns zero on error and
588
+ // the number of bytes written on success.
589
+ OPENSSL_EXPORT int PEM_write_bio(BIO *bio, const char *name, const char *hdr,
590
+ const uint8_t *data, long len);
405
591
 
406
- OPENSSL_EXPORT int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, const EVP_PKEY *x,
407
- int nid, const char *pass,
408
- int pass_len,
409
- pem_password_cb *cb,
410
- void *u);
411
- OPENSSL_EXPORT int PEM_write_bio_PKCS8PrivateKey(BIO *bp, const EVP_PKEY *x,
412
- const EVP_CIPHER *enc,
413
- const char *pass, int pass_len,
414
- pem_password_cb *cb, void *u);
415
- OPENSSL_EXPORT int i2d_PKCS8PrivateKey_bio(BIO *bp, const EVP_PKEY *x,
592
+ // PEM_write behaves like `PEM_write_bio` but reads from `fp`.
593
+ OPENSSL_EXPORT int PEM_write(FILE *fp, const char *name, const char *hdr,
594
+ const uint8_t *data, long len);
595
+
596
+ // PEM_bytes_read_bio reads from `bio` until it finds a PEM block whose name
597
+ // matches `expected_name`. If one is found, it sets `*out_name` and `*out_data`
598
+ // to newly-allocated buffers containing the PEM type and (possibly decrypted)
599
+ // PEM data. `*out_name` is a NUL-terminated C string, while `*out_data` has
600
+ // `*out_len` bytes. The caller must release `*out_name` and `*out_data` with
601
+ // `OPENSSL_free` when done.
602
+ //
603
+ // If the PEM block is encrypted, `cb` will be called to look up the password.
604
+ // See `pem_password_cb` for details. If `cb` is NULL, `PEM_def_callback` is
605
+ // used and `userdata` should be a NUL-terminated C string containing the
606
+ // password. Set both `cb` and `userdata` to NULL to only handle plaintext
607
+ // blocks.
608
+ //
609
+ // `expected_name` and `*out_name` may not necessarily be the same value, so
610
+ // callers must check `*out_name` before decoding `*out_data`. In addition to an
611
+ // exact match, the following values are also accepted:
612
+ //
613
+ // - If `expected_name` is "CERTIFICATE", the older "X509 CERTIFICATE" type is
614
+ // also accepted.
615
+ //
616
+ // - If `expected_name` is "CERTIFICATE REQUEST", the older "NEW CERTIFICATE
617
+ // REQUEST" type is also accepted.
618
+ //
619
+ // - If `expected_name` is "TRUSTED CERTIFICATE", "CERTIFICATE" and the older
620
+ // "X509 CERTIFICATE" are also accepted.
621
+ //
622
+ // - If `expected_name` is "PKCS7", "PKCS #7 SIGNED DATA" is also accepted.
623
+ //
624
+ // - If `expected_name` is "PKCS7", "CERTIFICATE" is also accepted. This is an
625
+ // exposed implementation detail of `PKCS7_get_PEM_certificates`, which works
626
+ // around a 2000-era mistake by some CAs.
627
+ //
628
+ // - If `expected_name` is "ANY PRIVATE KEY", the type "ANY PRIVATE KEY" is not
629
+ // accepted and, instead, the function accepts "PRIVATE KEY", "ENCRYPTED
630
+ // PRIVATE KEY", "RSA PRIVATE KEY", "EC PRIVATE KEY", and "DSA PRIVATE KEY".
631
+ // This is an exposed implementation detail of `PEM_read_bio_PrivateKey`.
632
+ //
633
+ // TODO(davidben): Can some of the older aliases and workarounds be removed now?
634
+ //
635
+ // If no PEM block is found, this function returns zero and pushes
636
+ // `PEM_R_NO_START_LINE` to the error queue. If one is found, but there is an
637
+ // error decoding it, it returns zero and pushes some other error to the error
638
+ // queue.
639
+ OPENSSL_EXPORT int PEM_bytes_read_bio(uint8_t **out_data, long *out_len,
640
+ char **out_name,
641
+ const char *expected_name, BIO *bio,
642
+ pem_password_cb *cb, void *userdata);
643
+
644
+
645
+ // Reading and writing DER-encoded private keys.
646
+
647
+ // d2i_PKCS8PrivateKey_bio reads a DER-encoded EncryptedPrivateKey structure
648
+ // (RFC 5208) from `bio`, decrypts it with `PKCS8_decrypt`, and returns the
649
+ // result as a newly-allocated `EVP_PKEY`, or NULL on error. On success, if
650
+ // `out` is non-NULL, it additionally frees the previous value at `*out` and
651
+ // updates `*out` to the result. The password is determined by calling `cb`, or
652
+ // `PEM_def_callback` if NULL.
653
+ OPENSSL_EXPORT EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bio, EVP_PKEY **out,
654
+ pem_password_cb *cb,
655
+ void *userdata);
656
+
657
+ // i2d_PKCS8PrivateKey_bio encodes `in` as a DER-encoded structure and writes
658
+ // it to `bio`. It returns one on success and zero on error. The structure used
659
+ // depends on `enc`:
660
+ //
661
+ // - If `enc` is NULL, it writes a PrivateKeyInfo structure (RFC 5208).
662
+ //
663
+ // - If `enc` is non-NULL, it writes an EncryptedPrivateKeyInfo structure (RFC
664
+ // 5280). The key is encrypted with PBES2, as in `PKCS8_encrypt`. The password
665
+ // is specified by `pass`, `cb`, and `userdata`, as in `PEM_write_bio_SAMPLE`.
666
+ //
667
+ // WARNING: PrivateKeyInfo and EncryptedPrivateKeyInfo are different formats,
668
+ // and DER does not include a type header. The encrypted and unencrypted modes
669
+ // of this function should not be mixed in the same context.
670
+ OPENSSL_EXPORT int i2d_PKCS8PrivateKey_bio(BIO *bio, const EVP_PKEY *in,
416
671
  const EVP_CIPHER *enc,
417
672
  const char *pass, int pass_len,
418
- pem_password_cb *cb, void *u);
419
- OPENSSL_EXPORT int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, const EVP_PKEY *x,
673
+ pem_password_cb *cb, void *userdata);
674
+
675
+ // i2d_PKCS8PrivateKey_nid_bio encodes `in` as a DER-encoded structure and
676
+ // writes it to `bio`. It returns one on success and zero on error. The
677
+ // structure used depends on `nid`:
678
+ //
679
+ // - If `nid` is -1, it writes a PrivateKeyInfo structure (RFC 5208).
680
+ //
681
+ // - Otherwise, it writes an EncryptedPrivateKeyInfo structure (RFC 5280). The
682
+ // key is encrypted with PBES1, as in `PKCS8_encrypt`. The password is
683
+ // specified by `pass`, `cb`, and `userdata`, as in `PEM_write_bio_SAMPLE`.
684
+ //
685
+ // WARNING: PrivateKeyInfo and EncryptedPrivateKeyInfo are different formats,
686
+ // and DER does not include a type header. The encrypted and unencrypted modes
687
+ // of this function should not be mixed in the same context.
688
+ OPENSSL_EXPORT int i2d_PKCS8PrivateKey_nid_bio(BIO *bio, const EVP_PKEY *in,
420
689
  int nid, const char *pass,
421
690
  int pass_len,
422
- pem_password_cb *cb, void *u);
423
- OPENSSL_EXPORT EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x,
424
- pem_password_cb *cb, void *u);
691
+ pem_password_cb *cb,
692
+ void *userdata);
425
693
 
426
- OPENSSL_EXPORT int i2d_PKCS8PrivateKey_fp(FILE *fp, const EVP_PKEY *x,
694
+ // i2d_PKCS8PrivateKey_fp behaves like `i2d_PKCS8PrivateKey_bio` but writes to
695
+ // `fp`.
696
+ OPENSSL_EXPORT int i2d_PKCS8PrivateKey_fp(FILE *fp, const EVP_PKEY *in,
427
697
  const EVP_CIPHER *enc,
428
698
  const char *pass, int pass_len,
429
- pem_password_cb *cb, void *u);
430
- OPENSSL_EXPORT int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, const EVP_PKEY *x,
699
+ pem_password_cb *cb, void *userdata);
700
+
701
+ // i2d_PKCS8PrivateKey_nid_fp behaves like `i2d_PKCS8PrivateKey_nid_bio` but
702
+ // writes to `fp`.
703
+ OPENSSL_EXPORT int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, const EVP_PKEY *in,
431
704
  int nid, const char *pass,
432
705
  int pass_len, pem_password_cb *cb,
433
- void *u);
434
- OPENSSL_EXPORT int PEM_write_PKCS8PrivateKey_nid(FILE *fp, const EVP_PKEY *x,
435
- int nid, const char *pass,
436
- int pass_len,
437
- pem_password_cb *cb, void *u);
706
+ void *userdata);
438
707
 
439
- OPENSSL_EXPORT EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x,
440
- pem_password_cb *cb, void *u);
708
+ // d2i_PKCS8PrivateKey_fp behaves like `d2i_PKCS8PrivateKey_bio` but reads from
709
+ // `fp`.
710
+ OPENSSL_EXPORT EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **out,
711
+ pem_password_cb *cb,
712
+ void *userdata);
441
713
 
442
- OPENSSL_EXPORT int PEM_write_PKCS8PrivateKey(FILE *fp, const EVP_PKEY *x,
443
- const EVP_CIPHER *enc,
444
- const char *pass, int pass_len,
445
- pem_password_cb *cd, void *u);
714
+
715
+ // Internal functions.
716
+ //
717
+ // The following functions are used to implement `PEM_read_bio_*` and
718
+ // `PEM_write_bio_*`. They should not be used outside the library.
719
+
720
+ // PEM_ASN1_read_bio calls `PEM_bytes_read_bio` and then decodes the resulting
721
+ // data with `d2i`, which should behave as in `d2i_SAMPLE`.
722
+ OPENSSL_EXPORT void *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name,
723
+ BIO *bio, void **out,
724
+ pem_password_cb *cb, void *userdata);
725
+
726
+ // PEM_ASN1_read behaves like `PEM_ASN1_read_bio` but reads from `fp`.
727
+ OPENSSL_EXPORT void *PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp,
728
+ void **out, pem_password_cb *cb,
729
+ void *userdata);
730
+
731
+ // PEM_ASN1_write_bio encodes `in` with `i2d`, which should behave as in
732
+ // `i2d_SAMPLE`. It then writes the result to `bio` as in
733
+ // `PEM_write_bio_SAMPLE`.
734
+ OPENSSL_EXPORT int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name,
735
+ BIO *bio, const void *in,
736
+ const EVP_CIPHER *enc,
737
+ const uint8_t *pass, int pass_len,
738
+ pem_password_cb *cb, void *userdata);
739
+
740
+ // PEM_ASN1_write behaves like `PEM_ASN1_write_bio` but reads from `fp`.
741
+ OPENSSL_EXPORT int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp,
742
+ const void *in, const EVP_CIPHER *enc,
743
+ const uint8_t *pass, int pass_len,
744
+ pem_password_cb *callback, void *userdata);
446
745
 
447
746
 
448
747
  #if defined(__cplusplus)