grpc 1.13.0 → 1.14.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (213) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +403 -153
  3. data/include/grpc/grpc.h +0 -8
  4. data/include/grpc/grpc_security.h +59 -2
  5. data/include/grpc/impl/codegen/grpc_types.h +8 -2
  6. data/include/grpc/impl/codegen/log.h +112 -0
  7. data/include/grpc/module.modulemap +2 -0
  8. data/include/grpc/support/log.h +2 -88
  9. data/include/grpc/support/string_util.h +2 -0
  10. data/src/boringssl/err_data.c +597 -593
  11. data/src/core/ext/filters/client_channel/client_channel.cc +715 -770
  12. data/src/core/ext/filters/client_channel/client_channel.h +5 -0
  13. data/src/core/ext/filters/client_channel/client_channel_channelz.cc +111 -0
  14. data/src/core/ext/filters/client_channel/client_channel_channelz.h +69 -0
  15. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +9 -0
  16. data/src/core/ext/filters/client_channel/http_proxy.cc +22 -5
  17. data/src/core/ext/filters/client_channel/lb_policy.h +15 -0
  18. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +3 -0
  19. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +3 -3
  20. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +3 -1
  21. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c +19 -0
  22. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h +54 -0
  23. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c +19 -0
  24. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h +54 -0
  25. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +4 -17
  26. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +37 -63
  27. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +79 -0
  28. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +5 -2
  29. data/src/core/ext/filters/client_channel/lb_policy_factory.cc +8 -0
  30. data/src/core/ext/filters/client_channel/lb_policy_factory.h +4 -0
  31. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +2 -2
  32. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +317 -0
  33. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +48 -9
  34. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +40 -293
  35. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +106 -84
  36. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +6 -2
  37. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +6 -5
  38. data/src/core/ext/filters/client_channel/subchannel.cc +36 -6
  39. data/src/core/ext/filters/client_channel/subchannel.h +4 -0
  40. data/src/core/ext/filters/deadline/deadline_filter.cc +18 -15
  41. data/src/core/ext/filters/deadline/deadline_filter.h +5 -5
  42. data/src/core/ext/filters/http/client/http_client_filter.cc +10 -9
  43. data/src/core/ext/filters/http/server/http_server_filter.h +1 -1
  44. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +1 -1
  45. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +3 -2
  46. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +33 -22
  47. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +1 -1
  48. data/src/core/ext/transport/chttp2/transport/internal.h +10 -3
  49. data/src/core/ext/transport/chttp2/transport/stream_lists.cc +17 -0
  50. data/src/core/ext/transport/chttp2/transport/writing.cc +21 -16
  51. data/src/core/ext/transport/inproc/inproc_transport.cc +46 -6
  52. data/src/core/lib/channel/channel_stack.cc +22 -24
  53. data/src/core/lib/channel/channel_trace.cc +28 -63
  54. data/src/core/lib/channel/channel_trace.h +13 -17
  55. data/src/core/lib/channel/channelz.cc +143 -0
  56. data/src/core/lib/channel/channelz.h +124 -0
  57. data/src/core/lib/channel/channelz_registry.cc +7 -24
  58. data/src/core/lib/channel/channelz_registry.h +12 -8
  59. data/src/core/lib/channel/connected_channel.cc +8 -1
  60. data/src/core/{ext/filters/load_reporting/server_load_reporting_filter.h → lib/gpr/alloc.h} +7 -9
  61. data/src/core/lib/gpr/arena.cc +8 -8
  62. data/src/core/lib/gpr/string.cc +28 -0
  63. data/src/core/lib/gpr/string.h +10 -0
  64. data/src/core/lib/gprpp/abstract.h +5 -2
  65. data/src/core/lib/gprpp/inlined_vector.h +57 -3
  66. data/src/core/lib/gprpp/memory.h +2 -2
  67. data/src/core/lib/gprpp/ref_counted_ptr.h +5 -0
  68. data/src/core/lib/gprpp/thd_posix.cc +1 -1
  69. data/src/core/lib/iomgr/call_combiner.h +80 -0
  70. data/src/core/lib/iomgr/closure.h +3 -2
  71. data/src/core/lib/iomgr/endpoint_pair_posix.cc +2 -2
  72. data/src/core/lib/iomgr/error.cc +12 -0
  73. data/src/core/lib/iomgr/error.h +5 -0
  74. data/src/core/lib/iomgr/ev_epoll1_linux.cc +36 -9
  75. data/src/core/lib/iomgr/ev_epollex_linux.cc +172 -46
  76. data/src/core/lib/iomgr/ev_epollsig_linux.cc +47 -21
  77. data/src/core/lib/iomgr/ev_poll_posix.cc +10 -4
  78. data/src/core/lib/iomgr/ev_posix.cc +17 -9
  79. data/src/core/lib/iomgr/ev_posix.h +20 -4
  80. data/src/core/lib/iomgr/executor.cc +196 -140
  81. data/src/core/lib/iomgr/executor.h +47 -14
  82. data/src/core/lib/iomgr/iomgr.cc +2 -0
  83. data/src/core/lib/iomgr/iomgr.h +5 -0
  84. data/src/core/lib/iomgr/is_epollexclusive_available.cc +1 -0
  85. data/src/core/lib/iomgr/socket_utils.h +9 -0
  86. data/src/core/lib/iomgr/socket_utils_common_posix.cc +4 -0
  87. data/src/core/lib/iomgr/socket_utils_uv.cc +4 -0
  88. data/src/core/lib/iomgr/socket_utils_windows.cc +4 -0
  89. data/src/core/lib/iomgr/tcp_client_posix.cc +3 -5
  90. data/src/core/lib/iomgr/tcp_posix.cc +6 -1
  91. data/src/core/lib/iomgr/tcp_server_posix.cc +3 -3
  92. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +1 -1
  93. data/src/core/lib/iomgr/timer_manager.cc +0 -1
  94. data/src/core/lib/iomgr/udp_server.cc +2 -3
  95. data/src/core/lib/json/json.cc +10 -0
  96. data/src/core/lib/json/json.h +5 -0
  97. data/src/core/lib/security/context/security_context.cc +8 -8
  98. data/src/core/lib/security/context/security_context.h +6 -2
  99. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +2 -1
  100. data/src/core/lib/security/credentials/local/local_credentials.cc +77 -0
  101. data/src/core/lib/security/credentials/local/local_credentials.h +40 -0
  102. data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +17 -3
  103. data/src/core/lib/security/security_connector/local_security_connector.cc +245 -0
  104. data/src/core/lib/security/security_connector/local_security_connector.h +58 -0
  105. data/src/core/lib/security/security_connector/security_connector.cc +30 -5
  106. data/src/core/lib/security/security_connector/security_connector.h +1 -0
  107. data/src/core/lib/security/transport/client_auth_filter.cc +5 -1
  108. data/src/core/lib/security/transport/server_auth_filter.cc +4 -5
  109. data/src/core/lib/surface/call.cc +75 -32
  110. data/src/core/lib/surface/call.h +2 -0
  111. data/src/core/lib/surface/channel.cc +32 -13
  112. data/src/core/lib/surface/channel.h +4 -0
  113. data/src/core/lib/surface/version.cc +1 -1
  114. data/src/core/lib/transport/transport.cc +20 -9
  115. data/src/core/lib/transport/transport.h +12 -10
  116. data/src/core/lib/transport/transport_op_string.cc +0 -7
  117. data/src/core/plugin_registry/grpc_plugin_registry.cc +0 -4
  118. data/src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h +2 -2
  119. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +2 -1
  120. data/src/core/tsi/alts/handshaker/altscontext.pb.c +0 -1
  121. data/src/core/tsi/alts/handshaker/altscontext.pb.h +1 -2
  122. data/src/core/tsi/alts/handshaker/handshaker.pb.c +0 -1
  123. data/src/core/tsi/alts/handshaker/handshaker.pb.h +1 -2
  124. data/src/core/tsi/alts/handshaker/transport_security_common.pb.c +0 -1
  125. data/src/core/tsi/alts/handshaker/transport_security_common.pb.h +1 -1
  126. data/src/core/tsi/alts/handshaker/transport_security_common_api.h +2 -2
  127. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc +47 -1
  128. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.h +3 -1
  129. data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +12 -11
  130. data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h +7 -2
  131. data/src/core/tsi/local_transport_security.cc +209 -0
  132. data/src/core/tsi/local_transport_security.h +51 -0
  133. data/src/core/tsi/ssl_transport_security.cc +2 -3
  134. data/src/{core/ext → cpp/ext/filters}/census/grpc_context.cc +0 -0
  135. data/src/ruby/ext/grpc/rb_channel_credentials.c +3 -3
  136. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +18 -18
  137. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +29 -29
  138. data/src/ruby/lib/grpc/generic/active_call.rb +19 -23
  139. data/src/ruby/lib/grpc/version.rb +1 -1
  140. data/src/ruby/spec/call_credentials_spec.rb +1 -1
  141. data/src/ruby/spec/call_spec.rb +1 -1
  142. data/src/ruby/spec/channel_credentials_spec.rb +1 -1
  143. data/src/ruby/spec/channel_spec.rb +1 -1
  144. data/src/ruby/spec/client_auth_spec.rb +1 -12
  145. data/src/ruby/spec/client_server_spec.rb +1 -1
  146. data/src/ruby/spec/compression_options_spec.rb +1 -1
  147. data/src/ruby/spec/error_sanity_spec.rb +1 -1
  148. data/src/ruby/spec/generic/client_stub_spec.rb +13 -1
  149. data/src/ruby/spec/generic/rpc_desc_spec.rb +1 -1
  150. data/src/ruby/spec/generic/rpc_server_pool_spec.rb +1 -1
  151. data/src/ruby/spec/generic/service_spec.rb +1 -1
  152. data/src/ruby/spec/google_rpc_status_utils_spec.rb +1 -12
  153. data/src/ruby/spec/pb/duplicate/codegen_spec.rb +1 -0
  154. data/src/ruby/spec/pb/health/checker_spec.rb +1 -1
  155. data/src/ruby/spec/server_credentials_spec.rb +1 -1
  156. data/src/ruby/spec/server_spec.rb +1 -1
  157. data/src/ruby/spec/spec_helper.rb +1 -0
  158. data/src/ruby/spec/support/services.rb +1 -1
  159. data/src/ruby/spec/time_consts_spec.rb +1 -1
  160. data/third_party/boringssl/crypto/asn1/tasn_dec.c +40 -19
  161. data/third_party/boringssl/crypto/bytestring/cbs.c +1 -0
  162. data/third_party/boringssl/crypto/cipher_extra/e_aesccm.c +47 -15
  163. data/third_party/boringssl/crypto/ec_extra/ec_asn1.c +9 -10
  164. data/third_party/boringssl/crypto/ecdh/ecdh.c +4 -3
  165. data/third_party/boringssl/crypto/fipsmodule/bn/add.c +30 -54
  166. data/third_party/boringssl/crypto/fipsmodule/bn/bn.c +7 -1
  167. data/third_party/boringssl/crypto/fipsmodule/bn/cmp.c +8 -8
  168. data/third_party/boringssl/crypto/fipsmodule/bn/div.c +97 -11
  169. data/third_party/boringssl/crypto/fipsmodule/bn/gcd.c +274 -218
  170. data/third_party/boringssl/crypto/fipsmodule/bn/internal.h +111 -34
  171. data/third_party/boringssl/crypto/fipsmodule/bn/montgomery.c +2 -2
  172. data/third_party/boringssl/crypto/fipsmodule/bn/montgomery_inv.c +1 -1
  173. data/third_party/boringssl/crypto/fipsmodule/bn/mul.c +24 -6
  174. data/third_party/boringssl/crypto/fipsmodule/bn/prime.c +324 -63
  175. data/third_party/boringssl/crypto/fipsmodule/bn/random.c +74 -21
  176. data/third_party/boringssl/crypto/fipsmodule/bn/shift.c +128 -86
  177. data/third_party/boringssl/crypto/fipsmodule/bn/sqrt.c +1 -1
  178. data/third_party/boringssl/crypto/fipsmodule/ec/ec_key.c +67 -112
  179. data/third_party/boringssl/crypto/fipsmodule/ec/internal.h +8 -1
  180. data/third_party/boringssl/crypto/fipsmodule/ec/oct.c +5 -5
  181. data/third_party/boringssl/crypto/fipsmodule/ec/p224-64.c +9 -17
  182. data/third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64-table.h +5378 -5418
  183. data/third_party/boringssl/crypto/fipsmodule/ec/simple.c +32 -32
  184. data/third_party/boringssl/crypto/fipsmodule/ecdsa/ecdsa.c +5 -11
  185. data/third_party/boringssl/crypto/fipsmodule/rsa/blinding.c +16 -40
  186. data/third_party/boringssl/crypto/fipsmodule/rsa/internal.h +1 -6
  187. data/third_party/boringssl/crypto/fipsmodule/rsa/rsa.c +41 -29
  188. data/third_party/boringssl/crypto/fipsmodule/rsa/rsa_impl.c +63 -49
  189. data/third_party/boringssl/crypto/x509/vpm_int.h +1 -0
  190. data/third_party/boringssl/crypto/x509/x509_vfy.c +4 -0
  191. data/third_party/boringssl/crypto/x509/x509_vpm.c +44 -22
  192. data/third_party/boringssl/include/openssl/aead.h +8 -2
  193. data/third_party/boringssl/include/openssl/asn1.h +1 -0
  194. data/third_party/boringssl/include/openssl/base.h +4 -0
  195. data/third_party/boringssl/include/openssl/bn.h +13 -3
  196. data/third_party/boringssl/include/openssl/bytestring.h +4 -4
  197. data/third_party/boringssl/include/openssl/ec.h +10 -4
  198. data/third_party/boringssl/include/openssl/ec_key.h +0 -3
  199. data/third_party/boringssl/include/openssl/rsa.h +1 -0
  200. data/third_party/boringssl/include/openssl/ssl.h +8 -3
  201. data/third_party/boringssl/include/openssl/ssl3.h +0 -1
  202. data/third_party/boringssl/include/openssl/x509.h +1 -0
  203. data/third_party/boringssl/include/openssl/x509v3.h +1 -0
  204. data/third_party/boringssl/ssl/handshake_client.cc +36 -64
  205. data/third_party/boringssl/ssl/ssl_cipher.cc +4 -0
  206. data/third_party/boringssl/ssl/ssl_lib.cc +1 -1
  207. metadata +45 -38
  208. data/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc +0 -222
  209. data/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc +0 -71
  210. data/src/core/ext/filters/load_reporting/server_load_reporting_plugin.h +0 -61
  211. data/src/ruby/spec/pb/package_with_underscore/checker_spec.rb +0 -51
  212. data/src/ruby/spec/pb/package_with_underscore/data.proto +0 -23
  213. data/src/ruby/spec/pb/package_with_underscore/service.proto +0 -23
@@ -25,4 +25,4 @@
25
25
 
26
26
  const char* grpc_version_string(void) { return "6.0.0"; }
27
27
 
28
- const char* grpc_g_stands_for(void) { return "gloriosa"; }
28
+ const char* grpc_g_stands_for(void) { return "gladiolus"; }
@@ -212,21 +212,32 @@ void grpc_transport_stream_op_batch_finish_with_failure(
212
212
  if (batch->send_message) {
213
213
  batch->payload->send_message.send_message.reset();
214
214
  }
215
- if (batch->recv_message) {
216
- GRPC_CALL_COMBINER_START(
217
- call_combiner, batch->payload->recv_message.recv_message_ready,
218
- GRPC_ERROR_REF(error), "failing recv_message_ready");
215
+ if (batch->cancel_stream) {
216
+ GRPC_ERROR_UNREF(batch->payload->cancel_stream.cancel_error);
219
217
  }
218
+ // Construct a list of closures to execute.
219
+ grpc_core::CallCombinerClosureList closures;
220
220
  if (batch->recv_initial_metadata) {
221
- GRPC_CALL_COMBINER_START(
222
- call_combiner,
221
+ closures.Add(
223
222
  batch->payload->recv_initial_metadata.recv_initial_metadata_ready,
224
223
  GRPC_ERROR_REF(error), "failing recv_initial_metadata_ready");
225
224
  }
226
- GRPC_CLOSURE_SCHED(batch->on_complete, error);
227
- if (batch->cancel_stream) {
228
- GRPC_ERROR_UNREF(batch->payload->cancel_stream.cancel_error);
225
+ if (batch->recv_message) {
226
+ closures.Add(batch->payload->recv_message.recv_message_ready,
227
+ GRPC_ERROR_REF(error), "failing recv_message_ready");
228
+ }
229
+ if (batch->recv_trailing_metadata) {
230
+ closures.Add(
231
+ batch->payload->recv_trailing_metadata.recv_trailing_metadata_ready,
232
+ GRPC_ERROR_REF(error), "failing recv_trailing_metadata_ready");
233
+ }
234
+ if (batch->on_complete != nullptr) {
235
+ closures.Add(batch->on_complete, GRPC_ERROR_REF(error),
236
+ "failing on_complete");
229
237
  }
238
+ // Execute closures.
239
+ closures.RunClosures(call_combiner);
240
+ GRPC_ERROR_UNREF(error);
230
241
  }
231
242
 
232
243
  typedef struct {
@@ -122,9 +122,15 @@ typedef struct grpc_transport_stream_op_batch_payload
122
122
  /* Transport stream op: a set of operations to perform on a transport
123
123
  against a single stream */
124
124
  typedef struct grpc_transport_stream_op_batch {
125
- /** Should be enqueued when all requested operations (excluding recv_message
126
- and recv_initial_metadata which have their own closures) in a given batch
127
- have been completed. */
125
+ /** Should be scheduled when all of the non-recv operations in the batch
126
+ are complete.
127
+
128
+ The recv ops (recv_initial_metadata, recv_message, and
129
+ recv_trailing_metadata) each have their own callbacks. If a batch
130
+ contains both recv ops and non-recv ops, on_complete should be
131
+ scheduled as soon as the non-recv ops are complete, regardless of
132
+ whether or not the recv ops are complete. If a batch contains
133
+ only recv ops, on_complete can be null. */
128
134
  grpc_closure* on_complete;
129
135
 
130
136
  /** Values for the stream op (fields set are determined by flags above) */
@@ -149,9 +155,6 @@ typedef struct grpc_transport_stream_op_batch {
149
155
  */
150
156
  bool recv_trailing_metadata : 1;
151
157
 
152
- /** Collect any stats into provided buffer, zero internal stat counters */
153
- bool collect_stats : 1;
154
-
155
158
  /** Cancel this stream with the provided error */
156
159
  bool cancel_stream : 1;
157
160
 
@@ -219,11 +222,10 @@ struct grpc_transport_stream_op_batch_payload {
219
222
 
220
223
  struct {
221
224
  grpc_metadata_batch* recv_trailing_metadata;
222
- } recv_trailing_metadata;
223
-
224
- struct {
225
225
  grpc_transport_stream_stats* collect_stats;
226
- } collect_stats;
226
+ /** Should be enqueued when initial metadata is ready to be processed. */
227
+ grpc_closure* recv_trailing_metadata_ready;
228
+ } recv_trailing_metadata;
227
229
 
228
230
  /** Forcefully close this stream.
229
231
  The HTTP2 semantics should be:
@@ -120,13 +120,6 @@ char* grpc_transport_stream_op_batch_string(
120
120
  gpr_strvec_add(&b, tmp);
121
121
  }
122
122
 
123
- if (op->collect_stats) {
124
- gpr_strvec_add(&b, gpr_strdup(" "));
125
- gpr_asprintf(&tmp, "COLLECT_STATS:%p",
126
- op->payload->collect_stats.collect_stats);
127
- gpr_strvec_add(&b, tmp);
128
- }
129
-
130
123
  out = gpr_strvec_flatten(&b, nullptr);
131
124
  gpr_strvec_destroy(&b);
132
125
 
@@ -46,8 +46,6 @@ void grpc_resolver_dns_native_init(void);
46
46
  void grpc_resolver_dns_native_shutdown(void);
47
47
  void grpc_resolver_sockaddr_init(void);
48
48
  void grpc_resolver_sockaddr_shutdown(void);
49
- void grpc_server_load_reporting_plugin_init(void);
50
- void grpc_server_load_reporting_plugin_shutdown(void);
51
49
  void grpc_max_age_filter_init(void);
52
50
  void grpc_max_age_filter_shutdown(void);
53
51
  void grpc_message_size_filter_init(void);
@@ -84,8 +82,6 @@ void grpc_register_built_in_plugins(void) {
84
82
  grpc_resolver_dns_native_shutdown);
85
83
  grpc_register_plugin(grpc_resolver_sockaddr_init,
86
84
  grpc_resolver_sockaddr_shutdown);
87
- grpc_register_plugin(grpc_server_load_reporting_plugin_init,
88
- grpc_server_load_reporting_plugin_shutdown);
89
85
  grpc_register_plugin(grpc_max_age_filter_init,
90
86
  grpc_max_age_filter_shutdown);
91
87
  grpc_register_plugin(grpc_message_size_filter_init,
@@ -21,8 +21,8 @@
21
21
 
22
22
  #include <grpc/support/port_platform.h>
23
23
 
24
- #include "third_party/nanopb/pb_decode.h"
25
- #include "third_party/nanopb/pb_encode.h"
24
+ #include "pb_decode.h"
25
+ #include "pb_encode.h"
26
26
 
27
27
  #include <grpc/slice.h>
28
28
  #include <grpc/slice_buffer.h>
@@ -127,7 +127,8 @@ static tsi_result handshaker_result_create_zero_copy_grpc_protector(
127
127
  tsi_result ok = alts_zero_copy_grpc_protector_create(
128
128
  reinterpret_cast<const uint8_t*>(result->key_data),
129
129
  kAltsAes128GcmRekeyKeyLength, /*is_rekey=*/true, result->is_client,
130
- /*is_integrity_only=*/false, max_output_protected_frame_size, protector);
130
+ /*is_integrity_only=*/false, /*enable_extra_copy=*/false,
131
+ max_output_protected_frame_size, protector);
131
132
  if (ok != TSI_OK) {
132
133
  gpr_log(GPR_ERROR, "Failed to create zero-copy grpc protector");
133
134
  }
@@ -2,7 +2,6 @@
2
2
  /* Generated by nanopb-0.3.7-dev */
3
3
 
4
4
  #include "src/core/tsi/alts/handshaker/altscontext.pb.h"
5
-
6
5
  /* @@protoc_insertion_point(includes) */
7
6
  #if PB_PROTO_HEADER_VERSION != 30
8
7
  #error Regenerate this file with the current version of nanopb generator.
@@ -3,9 +3,8 @@
3
3
 
4
4
  #ifndef PB_GRPC_GCP_ALTSCONTEXT_PB_H_INCLUDED
5
5
  #define PB_GRPC_GCP_ALTSCONTEXT_PB_H_INCLUDED
6
- #include "third_party/nanopb/pb.h"
6
+ #include "pb.h"
7
7
  #include "src/core/tsi/alts/handshaker/transport_security_common.pb.h"
8
-
9
8
  /* @@protoc_insertion_point(includes) */
10
9
  #if PB_PROTO_HEADER_VERSION != 30
11
10
  #error Regenerate this file with the current version of nanopb generator.
@@ -2,7 +2,6 @@
2
2
  /* Generated by nanopb-0.3.7-dev */
3
3
 
4
4
  #include "src/core/tsi/alts/handshaker/handshaker.pb.h"
5
-
6
5
  /* @@protoc_insertion_point(includes) */
7
6
  #if PB_PROTO_HEADER_VERSION != 30
8
7
  #error Regenerate this file with the current version of nanopb generator.
@@ -3,9 +3,8 @@
3
3
 
4
4
  #ifndef PB_GRPC_GCP_HANDSHAKER_PB_H_INCLUDED
5
5
  #define PB_GRPC_GCP_HANDSHAKER_PB_H_INCLUDED
6
- #include "third_party/nanopb/pb.h"
6
+ #include "pb.h"
7
7
  #include "src/core/tsi/alts/handshaker/transport_security_common.pb.h"
8
-
9
8
  /* @@protoc_insertion_point(includes) */
10
9
  #if PB_PROTO_HEADER_VERSION != 30
11
10
  #error Regenerate this file with the current version of nanopb generator.
@@ -2,7 +2,6 @@
2
2
  /* Generated by nanopb-0.3.7-dev */
3
3
 
4
4
  #include "src/core/tsi/alts/handshaker/transport_security_common.pb.h"
5
-
6
5
  /* @@protoc_insertion_point(includes) */
7
6
  #if PB_PROTO_HEADER_VERSION != 30
8
7
  #error Regenerate this file with the current version of nanopb generator.
@@ -3,7 +3,7 @@
3
3
 
4
4
  #ifndef PB_GRPC_GCP_TRANSPORT_SECURITY_COMMON_PB_H_INCLUDED
5
5
  #define PB_GRPC_GCP_TRANSPORT_SECURITY_COMMON_PB_H_INCLUDED
6
- #include "third_party/nanopb/pb.h"
6
+ #include "pb.h"
7
7
  /* @@protoc_insertion_point(includes) */
8
8
  #if PB_PROTO_HEADER_VERSION != 30
9
9
  #error Regenerate this file with the current version of nanopb generator.
@@ -21,8 +21,8 @@
21
21
 
22
22
  #include <grpc/support/port_platform.h>
23
23
 
24
- #include "third_party/nanopb/pb_decode.h"
25
- #include "third_party/nanopb/pb_encode.h"
24
+ #include "pb_decode.h"
25
+ #include "pb_encode.h"
26
26
 
27
27
  #include <grpc/slice.h>
28
28
  #include <grpc/slice_buffer.h>
@@ -23,6 +23,8 @@
23
23
  #include <grpc/support/alloc.h>
24
24
  #include <grpc/support/log.h>
25
25
 
26
+ #include <string.h>
27
+
26
28
  #include "src/core/lib/slice/slice_internal.h"
27
29
  #include "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h"
28
30
  #include "src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.h"
@@ -30,12 +32,49 @@
30
32
  /* Main struct for alts_grpc_integrity_only_record_protocol. */
31
33
  typedef struct alts_grpc_integrity_only_record_protocol {
32
34
  alts_grpc_record_protocol base;
35
+ bool enable_extra_copy;
33
36
  grpc_slice_buffer data_sb;
34
37
  unsigned char* tag_buf;
35
38
  } alts_grpc_integrity_only_record_protocol;
36
39
 
37
40
  /* --- alts_grpc_record_protocol methods implementation. --- */
38
41
 
42
+ static tsi_result alts_grpc_integrity_only_extra_copy_protect(
43
+ alts_grpc_record_protocol* rp, grpc_slice_buffer* unprotected_slices,
44
+ grpc_slice_buffer* protected_slices) {
45
+ /* Allocates memory for protected frame and copies data. */
46
+ size_t data_length = unprotected_slices->length;
47
+ size_t protected_frame_size =
48
+ unprotected_slices->length + rp->header_length + rp->tag_length;
49
+ grpc_slice protected_slice = GRPC_SLICE_MALLOC(protected_frame_size);
50
+ uint8_t* data = GRPC_SLICE_START_PTR(protected_slice) + rp->header_length;
51
+ for (size_t i = 0; i < unprotected_slices->count; i++) {
52
+ memcpy(data, GRPC_SLICE_START_PTR(unprotected_slices->slices[i]),
53
+ GRPC_SLICE_LENGTH(unprotected_slices->slices[i]));
54
+ data += GRPC_SLICE_LENGTH(unprotected_slices->slices[i]);
55
+ }
56
+ /* Calls alts_iovec_record_protocol protect. */
57
+ char* error_details = nullptr;
58
+ iovec_t header_iovec = {GRPC_SLICE_START_PTR(protected_slice),
59
+ rp->header_length};
60
+ iovec_t tag_iovec = {
61
+ GRPC_SLICE_START_PTR(protected_slice) + rp->header_length + data_length,
62
+ rp->tag_length};
63
+ rp->iovec_buf[0].iov_base =
64
+ GRPC_SLICE_START_PTR(protected_slice) + rp->header_length;
65
+ rp->iovec_buf[0].iov_len = data_length;
66
+ grpc_status_code status = alts_iovec_record_protocol_integrity_only_protect(
67
+ rp->iovec_rp, rp->iovec_buf, 1, header_iovec, tag_iovec, &error_details);
68
+ if (status != GRPC_STATUS_OK) {
69
+ gpr_log(GPR_ERROR, "Failed to protect, %s", error_details);
70
+ gpr_free(error_details);
71
+ return TSI_INTERNAL_ERROR;
72
+ }
73
+ grpc_slice_buffer_add(protected_slices, protected_slice);
74
+ grpc_slice_buffer_reset_and_unref_internal(unprotected_slices);
75
+ return TSI_OK;
76
+ }
77
+
39
78
  static tsi_result alts_grpc_integrity_only_protect(
40
79
  alts_grpc_record_protocol* rp, grpc_slice_buffer* unprotected_slices,
41
80
  grpc_slice_buffer* protected_slices) {
@@ -46,6 +85,12 @@ static tsi_result alts_grpc_integrity_only_protect(
46
85
  "Invalid nullptr arguments to alts_grpc_record_protocol protect.");
47
86
  return TSI_INVALID_ARGUMENT;
48
87
  }
88
+ alts_grpc_integrity_only_record_protocol* integrity_only_record_protocol =
89
+ reinterpret_cast<alts_grpc_integrity_only_record_protocol*>(rp);
90
+ if (integrity_only_record_protocol->enable_extra_copy) {
91
+ return alts_grpc_integrity_only_extra_copy_protect(rp, unprotected_slices,
92
+ protected_slices);
93
+ }
49
94
  /* Allocates memory for header and tag slices. */
50
95
  grpc_slice header_slice = GRPC_SLICE_MALLOC(rp->header_length);
51
96
  grpc_slice tag_slice = GRPC_SLICE_MALLOC(rp->tag_length);
@@ -152,7 +197,7 @@ static const alts_grpc_record_protocol_vtable
152
197
 
153
198
  tsi_result alts_grpc_integrity_only_record_protocol_create(
154
199
  gsec_aead_crypter* crypter, size_t overflow_size, bool is_client,
155
- bool is_protect, alts_grpc_record_protocol** rp) {
200
+ bool is_protect, bool enable_extra_copy, alts_grpc_record_protocol** rp) {
156
201
  if (crypter == nullptr || rp == nullptr) {
157
202
  gpr_log(GPR_ERROR,
158
203
  "Invalid nullptr arguments to alts_grpc_record_protocol create.");
@@ -169,6 +214,7 @@ tsi_result alts_grpc_integrity_only_record_protocol_create(
169
214
  gpr_free(impl);
170
215
  return result;
171
216
  }
217
+ impl->enable_extra_copy = enable_extra_copy;
172
218
  /* Initializes slice buffer for data_sb. */
173
219
  grpc_slice_buffer_init(&impl->data_sb);
174
220
  /* Allocates tag buffer. */
@@ -38,6 +38,8 @@
38
38
  * be used at the client or server side.
39
39
  * - is_protect: a flag indicating if the alts_grpc_record_protocol instance
40
40
  * will be used for protect or unprotect.
41
+ *- enable_extra_copy: a flag indicating if the instance uses one-copy instead
42
+ * of zero-copy in the protect operation.
41
43
  * - rp: an alts_grpc_record_protocol instance to be returned from
42
44
  * the method.
43
45
  *
@@ -46,7 +48,7 @@
46
48
  */
47
49
  tsi_result alts_grpc_integrity_only_record_protocol_create(
48
50
  gsec_aead_crypter* crypter, size_t overflow_size, bool is_client,
49
- bool is_protect, alts_grpc_record_protocol** rp);
51
+ bool is_protect, bool enable_extra_copy, alts_grpc_record_protocol** rp);
50
52
 
51
53
  #endif /* GRPC_CORE_TSI_ALTS_ZERO_COPY_FRAME_PROTECTOR_ALTS_GRPC_INTEGRITY_ONLY_RECORD_PROTOCOL_H \
52
54
  */
@@ -110,7 +110,7 @@ static bool read_frame_size(const grpc_slice_buffer* sb,
110
110
  */
111
111
  static tsi_result create_alts_grpc_record_protocol(
112
112
  const uint8_t* key, size_t key_size, bool is_rekey, bool is_client,
113
- bool is_integrity_only, bool is_protect,
113
+ bool is_integrity_only, bool is_protect, bool enable_extra_copy,
114
114
  alts_grpc_record_protocol** record_protocol) {
115
115
  if (key == nullptr || record_protocol == nullptr) {
116
116
  return TSI_INVALID_ARGUMENT;
@@ -130,13 +130,13 @@ static tsi_result create_alts_grpc_record_protocol(
130
130
  : kAltsRecordProtocolFrameLimit;
131
131
  /* Creates alts_grpc_record_protocol with AEAD crypter ownership transferred.
132
132
  */
133
- tsi_result result =
134
- is_integrity_only
135
- ? alts_grpc_integrity_only_record_protocol_create(
136
- crypter, overflow_limit, is_client, is_protect, record_protocol)
137
- : alts_grpc_privacy_integrity_record_protocol_create(
138
- crypter, overflow_limit, is_client, is_protect,
139
- record_protocol);
133
+ tsi_result result = is_integrity_only
134
+ ? alts_grpc_integrity_only_record_protocol_create(
135
+ crypter, overflow_limit, is_client, is_protect,
136
+ enable_extra_copy, record_protocol)
137
+ : alts_grpc_privacy_integrity_record_protocol_create(
138
+ crypter, overflow_limit, is_client, is_protect,
139
+ record_protocol);
140
140
  if (result != TSI_OK) {
141
141
  gsec_aead_crypter_destroy(crypter);
142
142
  return result;
@@ -241,7 +241,8 @@ static const tsi_zero_copy_grpc_protector_vtable
241
241
 
242
242
  tsi_result alts_zero_copy_grpc_protector_create(
243
243
  const uint8_t* key, size_t key_size, bool is_rekey, bool is_client,
244
- bool is_integrity_only, size_t* max_protected_frame_size,
244
+ bool is_integrity_only, bool enable_extra_copy,
245
+ size_t* max_protected_frame_size,
245
246
  tsi_zero_copy_grpc_protector** protector) {
246
247
  if (grpc_core::ExecCtx::Get() == nullptr || key == nullptr ||
247
248
  protector == nullptr) {
@@ -257,11 +258,11 @@ tsi_result alts_zero_copy_grpc_protector_create(
257
258
  /* Creates alts_grpc_record_protocol objects. */
258
259
  tsi_result status = create_alts_grpc_record_protocol(
259
260
  key, key_size, is_rekey, is_client, is_integrity_only,
260
- /*is_protect=*/true, &impl->record_protocol);
261
+ /*is_protect=*/true, enable_extra_copy, &impl->record_protocol);
261
262
  if (status == TSI_OK) {
262
263
  status = create_alts_grpc_record_protocol(
263
264
  key, key_size, is_rekey, is_client, is_integrity_only,
264
- /*is_protect=*/false, &impl->unrecord_protocol);
265
+ /*is_protect=*/false, enable_extra_copy, &impl->unrecord_protocol);
265
266
  if (status == TSI_OK) {
266
267
  /* Sets maximum frame size. */
267
268
  size_t max_protected_frame_size_to_set = kDefaultFrameLength;
@@ -35,6 +35,11 @@
35
35
  * server side.
36
36
  * - is_integrity_only: a flag indicating if the protector instance will be
37
37
  * used for integrity-only or privacy-integrity mode.
38
+ * - enable_extra_copy: a flag indicating if the protector instance does one
39
+ * extra memory copy during the protect operation for integrity_only mode.
40
+ * For the unprotect operation, it is still zero-copy. If application intends
41
+ * to modify the data buffer after the protect operation, we can turn on this
42
+ * mode to avoid integrity check failure.
38
43
  * - max_protected_frame_size: an in/out parameter indicating max frame size
39
44
  * to be used by the protector. If it is nullptr, the default frame size will
40
45
  * be used. Otherwise, the provided frame size will be adjusted (if not
@@ -45,8 +50,8 @@
45
50
  */
46
51
  tsi_result alts_zero_copy_grpc_protector_create(
47
52
  const uint8_t* key, size_t key_size, bool is_rekey, bool is_client,
48
- bool is_integrity_only, size_t* max_protected_frame_size,
49
- tsi_zero_copy_grpc_protector** protector);
53
+ bool is_integrity_only, bool enable_extra_copy,
54
+ size_t* max_protected_frame_size, tsi_zero_copy_grpc_protector** protector);
50
55
 
51
56
  #endif /* GRPC_CORE_TSI_ALTS_ZERO_COPY_FRAME_PROTECTOR_ALTS_ZERO_COPY_GRPC_PROTECTOR_H \
52
57
  */
@@ -0,0 +1,209 @@
1
+ /*
2
+ *
3
+ * Copyright 2018 gRPC authors.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ */
18
+
19
+ #include <grpc/support/port_platform.h>
20
+
21
+ #include "src/core/tsi/local_transport_security.h"
22
+
23
+ #include <stdio.h>
24
+ #include <stdlib.h>
25
+ #include <string.h>
26
+
27
+ #include <grpc/support/alloc.h>
28
+ #include <grpc/support/log.h>
29
+ #include <grpc/support/string_util.h>
30
+
31
+ #include "src/core/lib/iomgr/exec_ctx.h"
32
+ #include "src/core/tsi/transport_security_grpc.h"
33
+
34
+ /* Main struct for local TSI zero-copy frame protector. */
35
+ typedef struct local_zero_copy_grpc_protector {
36
+ tsi_zero_copy_grpc_protector base;
37
+ } local_zero_copy_grpc_protector;
38
+
39
+ /* Main struct for local TSI handshaker result. */
40
+ typedef struct local_tsi_handshaker_result {
41
+ tsi_handshaker_result base;
42
+ bool is_client;
43
+ } local_tsi_handshaker_result;
44
+
45
+ /* Main struct for local TSI handshaker. */
46
+ typedef struct local_tsi_handshaker {
47
+ tsi_handshaker base;
48
+ bool is_client;
49
+ } local_tsi_handshaker;
50
+
51
+ /* --- tsi_zero_copy_grpc_protector methods implementation. --- */
52
+
53
+ static tsi_result local_zero_copy_grpc_protector_protect(
54
+ tsi_zero_copy_grpc_protector* self, grpc_slice_buffer* unprotected_slices,
55
+ grpc_slice_buffer* protected_slices) {
56
+ if (self == nullptr || unprotected_slices == nullptr ||
57
+ protected_slices == nullptr) {
58
+ gpr_log(GPR_ERROR, "Invalid nullptr arguments to zero-copy grpc protect.");
59
+ return TSI_INVALID_ARGUMENT;
60
+ }
61
+ grpc_slice_buffer_move_into(unprotected_slices, protected_slices);
62
+ return TSI_OK;
63
+ }
64
+
65
+ static tsi_result local_zero_copy_grpc_protector_unprotect(
66
+ tsi_zero_copy_grpc_protector* self, grpc_slice_buffer* protected_slices,
67
+ grpc_slice_buffer* unprotected_slices) {
68
+ if (self == nullptr || unprotected_slices == nullptr ||
69
+ protected_slices == nullptr) {
70
+ gpr_log(GPR_ERROR,
71
+ "Invalid nullptr arguments to zero-copy grpc unprotect.");
72
+ return TSI_INVALID_ARGUMENT;
73
+ }
74
+ grpc_slice_buffer_move_into(protected_slices, unprotected_slices);
75
+ return TSI_OK;
76
+ }
77
+
78
+ static void local_zero_copy_grpc_protector_destroy(
79
+ tsi_zero_copy_grpc_protector* self) {
80
+ gpr_free(self);
81
+ }
82
+
83
+ static const tsi_zero_copy_grpc_protector_vtable
84
+ local_zero_copy_grpc_protector_vtable = {
85
+ local_zero_copy_grpc_protector_protect,
86
+ local_zero_copy_grpc_protector_unprotect,
87
+ local_zero_copy_grpc_protector_destroy};
88
+
89
+ tsi_result local_zero_copy_grpc_protector_create(
90
+ tsi_zero_copy_grpc_protector** protector) {
91
+ if (grpc_core::ExecCtx::Get() == nullptr || protector == nullptr) {
92
+ gpr_log(
93
+ GPR_ERROR,
94
+ "Invalid nullptr arguments to local_zero_copy_grpc_protector create.");
95
+ return TSI_INVALID_ARGUMENT;
96
+ }
97
+ local_zero_copy_grpc_protector* impl =
98
+ static_cast<local_zero_copy_grpc_protector*>(gpr_zalloc(sizeof(*impl)));
99
+ impl->base.vtable = &local_zero_copy_grpc_protector_vtable;
100
+ *protector = &impl->base;
101
+ return TSI_OK;
102
+ }
103
+
104
+ /* --- tsi_handshaker_result methods implementation. --- */
105
+
106
+ static tsi_result handshaker_result_extract_peer(
107
+ const tsi_handshaker_result* self, tsi_peer* peer) {
108
+ return TSI_OK;
109
+ }
110
+
111
+ static tsi_result handshaker_result_create_zero_copy_grpc_protector(
112
+ const tsi_handshaker_result* self, size_t* max_output_protected_frame_size,
113
+ tsi_zero_copy_grpc_protector** protector) {
114
+ if (self == nullptr || protector == nullptr) {
115
+ gpr_log(GPR_ERROR,
116
+ "Invalid arguments to create_zero_copy_grpc_protector()");
117
+ return TSI_INVALID_ARGUMENT;
118
+ }
119
+ tsi_result ok = local_zero_copy_grpc_protector_create(protector);
120
+ if (ok != TSI_OK) {
121
+ gpr_log(GPR_ERROR, "Failed to create zero-copy grpc protector");
122
+ }
123
+ return ok;
124
+ }
125
+
126
+ static void handshaker_result_destroy(tsi_handshaker_result* self) {
127
+ if (self == nullptr) {
128
+ return;
129
+ }
130
+ local_tsi_handshaker_result* result =
131
+ reinterpret_cast<local_tsi_handshaker_result*>(
132
+ const_cast<tsi_handshaker_result*>(self));
133
+ gpr_free(result);
134
+ }
135
+
136
+ static const tsi_handshaker_result_vtable result_vtable = {
137
+ handshaker_result_extract_peer,
138
+ handshaker_result_create_zero_copy_grpc_protector,
139
+ nullptr, /* handshaker_result_create_frame_protector */
140
+ nullptr, /* handshaker_result_get_unused_bytes */
141
+ handshaker_result_destroy};
142
+
143
+ static tsi_result create_handshaker_result(bool is_client,
144
+ tsi_handshaker_result** self) {
145
+ if (self == nullptr) {
146
+ gpr_log(GPR_ERROR, "Invalid arguments to create_handshaker_result()");
147
+ return TSI_INVALID_ARGUMENT;
148
+ }
149
+ local_tsi_handshaker_result* result =
150
+ static_cast<local_tsi_handshaker_result*>(gpr_zalloc(sizeof(*result)));
151
+ result->is_client = is_client;
152
+ result->base.vtable = &result_vtable;
153
+ *self = &result->base;
154
+ return TSI_OK;
155
+ }
156
+
157
+ /* --- tsi_handshaker methods implementation. --- */
158
+
159
+ static tsi_result handshaker_next(
160
+ tsi_handshaker* self, const unsigned char* received_bytes,
161
+ size_t received_bytes_size, const unsigned char** bytes_to_send,
162
+ size_t* bytes_to_send_size, tsi_handshaker_result** result,
163
+ tsi_handshaker_on_next_done_cb cb, void* user_data) {
164
+ if (self == nullptr) {
165
+ gpr_log(GPR_ERROR, "Invalid arguments to handshaker_next()");
166
+ return TSI_INVALID_ARGUMENT;
167
+ }
168
+ /* Note that there is no interaction between TSI peers, and all operations are
169
+ * local.
170
+ */
171
+ local_tsi_handshaker* handshaker =
172
+ reinterpret_cast<local_tsi_handshaker*>(self);
173
+ *bytes_to_send_size = 0;
174
+ create_handshaker_result(handshaker->is_client, result);
175
+ return TSI_OK;
176
+ }
177
+
178
+ static void handshaker_destroy(tsi_handshaker* self) {
179
+ if (self == nullptr) {
180
+ return;
181
+ }
182
+ local_tsi_handshaker* handshaker =
183
+ reinterpret_cast<local_tsi_handshaker*>(self);
184
+ gpr_free(handshaker);
185
+ }
186
+
187
+ static const tsi_handshaker_vtable handshaker_vtable = {
188
+ nullptr, /* get_bytes_to_send_to_peer -- deprecated */
189
+ nullptr, /* process_bytes_from_peer -- deprecated */
190
+ nullptr, /* get_result -- deprecated */
191
+ nullptr, /* extract_peer -- deprecated */
192
+ nullptr, /* create_frame_protector -- deprecated */
193
+ handshaker_destroy,
194
+ handshaker_next,
195
+ nullptr, /* shutdown */
196
+ };
197
+
198
+ tsi_result local_tsi_handshaker_create(bool is_client, tsi_handshaker** self) {
199
+ if (self == nullptr) {
200
+ gpr_log(GPR_ERROR, "Invalid arguments to local_tsi_handshaker_create()");
201
+ return TSI_INVALID_ARGUMENT;
202
+ }
203
+ local_tsi_handshaker* handshaker =
204
+ static_cast<local_tsi_handshaker*>(gpr_zalloc(sizeof(*handshaker)));
205
+ handshaker->is_client = is_client;
206
+ handshaker->base.vtable = &handshaker_vtable;
207
+ *self = &handshaker->base;
208
+ return TSI_OK;
209
+ }